@seanmars/tospec 0.19.0-beta.7 → 0.20.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 (429) hide show
  1. package/CHANGELOG.md +60 -231
  2. package/README.md +69 -82
  3. package/assets/dashboard/app.js +14 -3
  4. package/assets/dashboard/style.css +7 -0
  5. package/assets/rules/tospec/decision.md +3 -0
  6. package/dist/cli/index.d.ts.map +1 -1
  7. package/dist/cli/index.js +227 -86
  8. package/dist/cli/index.js.map +1 -1
  9. package/dist/commands/config.d.ts +9 -17
  10. package/dist/commands/config.d.ts.map +1 -1
  11. package/dist/commands/config.js +366 -107
  12. package/dist/commands/config.js.map +1 -1
  13. package/dist/commands/dashboard.d.ts +57 -99
  14. package/dist/commands/dashboard.d.ts.map +1 -1
  15. package/dist/commands/dashboard.js +224 -282
  16. package/dist/commands/dashboard.js.map +1 -1
  17. package/dist/commands/decision.d.ts +41 -19
  18. package/dist/commands/decision.d.ts.map +1 -1
  19. package/dist/commands/decision.js +385 -79
  20. package/dist/commands/decision.js.map +1 -1
  21. package/dist/commands/metrics.d.ts +28 -51
  22. package/dist/commands/metrics.d.ts.map +1 -1
  23. package/dist/commands/metrics.js +62 -93
  24. package/dist/commands/metrics.js.map +1 -1
  25. package/dist/commands/shared-output.d.ts +18 -21
  26. package/dist/commands/shared-output.d.ts.map +1 -1
  27. package/dist/commands/shared-output.js +49 -23
  28. package/dist/commands/shared-output.js.map +1 -1
  29. package/dist/commands/show.d.ts +7 -0
  30. package/dist/commands/show.d.ts.map +1 -1
  31. package/dist/commands/show.js +29 -7
  32. package/dist/commands/show.js.map +1 -1
  33. package/dist/commands/validate.d.ts +43 -45
  34. package/dist/commands/validate.d.ts.map +1 -1
  35. package/dist/commands/validate.js +262 -129
  36. package/dist/commands/validate.js.map +1 -1
  37. package/dist/commands/workflow/index.d.ts +6 -10
  38. package/dist/commands/workflow/index.d.ts.map +1 -1
  39. package/dist/commands/workflow/index.js +6 -10
  40. package/dist/commands/workflow/index.js.map +1 -1
  41. package/dist/commands/workflow/instructions.d.ts +21 -8
  42. package/dist/commands/workflow/instructions.d.ts.map +1 -1
  43. package/dist/commands/workflow/instructions.js +254 -95
  44. package/dist/commands/workflow/instructions.js.map +1 -1
  45. package/dist/commands/workflow/new-change.d.ts +4 -5
  46. package/dist/commands/workflow/new-change.d.ts.map +1 -1
  47. package/dist/commands/workflow/new-change.js +90 -25
  48. package/dist/commands/workflow/new-change.js.map +1 -1
  49. package/dist/commands/workflow/schemas.d.ts +3 -5
  50. package/dist/commands/workflow/schemas.d.ts.map +1 -1
  51. package/dist/commands/workflow/schemas.js +37 -11
  52. package/dist/commands/workflow/schemas.js.map +1 -1
  53. package/dist/commands/workflow/shared.d.ts +48 -21
  54. package/dist/commands/workflow/shared.d.ts.map +1 -1
  55. package/dist/commands/workflow/shared.js +36 -33
  56. package/dist/commands/workflow/shared.js.map +1 -1
  57. package/dist/commands/workflow/status.d.ts +10 -6
  58. package/dist/commands/workflow/status.d.ts.map +1 -1
  59. package/dist/commands/workflow/status.js +81 -42
  60. package/dist/commands/workflow/status.js.map +1 -1
  61. package/dist/commands/workflow/templates.d.ts +10 -3
  62. package/dist/commands/workflow/templates.d.ts.map +1 -1
  63. package/dist/commands/workflow/templates.js +39 -40
  64. package/dist/commands/workflow/templates.js.map +1 -1
  65. package/dist/core/archive.d.ts +26 -21
  66. package/dist/core/archive.d.ts.map +1 -1
  67. package/dist/core/archive.js +378 -235
  68. package/dist/core/archive.js.map +1 -1
  69. package/dist/core/artifact-graph/graph.d.ts +25 -42
  70. package/dist/core/artifact-graph/graph.d.ts.map +1 -1
  71. package/dist/core/artifact-graph/graph.js +45 -63
  72. package/dist/core/artifact-graph/graph.js.map +1 -1
  73. package/dist/core/artifact-graph/index.d.ts +1 -1
  74. package/dist/core/artifact-graph/index.d.ts.map +1 -1
  75. package/dist/core/artifact-graph/index.js +1 -1
  76. package/dist/core/artifact-graph/index.js.map +1 -1
  77. package/dist/core/artifact-graph/instruction-loader.d.ts +97 -103
  78. package/dist/core/artifact-graph/instruction-loader.d.ts.map +1 -1
  79. package/dist/core/artifact-graph/instruction-loader.js +146 -119
  80. package/dist/core/artifact-graph/instruction-loader.js.map +1 -1
  81. package/dist/core/artifact-graph/outputs.d.ts +9 -23
  82. package/dist/core/artifact-graph/outputs.d.ts.map +1 -1
  83. package/dist/core/artifact-graph/outputs.js +45 -38
  84. package/dist/core/artifact-graph/outputs.js.map +1 -1
  85. package/dist/core/artifact-graph/resolver.d.ts +44 -63
  86. package/dist/core/artifact-graph/resolver.d.ts.map +1 -1
  87. package/dist/core/artifact-graph/resolver.js +85 -86
  88. package/dist/core/artifact-graph/resolver.js.map +1 -1
  89. package/dist/core/artifact-graph/schema.d.ts +0 -6
  90. package/dist/core/artifact-graph/schema.d.ts.map +1 -1
  91. package/dist/core/artifact-graph/schema.js +7 -32
  92. package/dist/core/artifact-graph/schema.js.map +1 -1
  93. package/dist/core/artifact-graph/state.d.ts +1 -8
  94. package/dist/core/artifact-graph/state.d.ts.map +1 -1
  95. package/dist/core/artifact-graph/state.js +2 -17
  96. package/dist/core/artifact-graph/state.js.map +1 -1
  97. package/dist/core/artifact-graph/stub-detection.d.ts +12 -0
  98. package/dist/core/artifact-graph/stub-detection.d.ts.map +1 -0
  99. package/dist/core/artifact-graph/stub-detection.js +39 -0
  100. package/dist/core/artifact-graph/stub-detection.js.map +1 -0
  101. package/dist/core/artifact-graph/types.d.ts +4 -0
  102. package/dist/core/artifact-graph/types.d.ts.map +1 -1
  103. package/dist/core/artifact-graph/types.js +30 -10
  104. package/dist/core/artifact-graph/types.js.map +1 -1
  105. package/dist/core/available-tools.d.ts +3 -12
  106. package/dist/core/available-tools.d.ts.map +1 -1
  107. package/dist/core/available-tools.js +4 -13
  108. package/dist/core/available-tools.js.map +1 -1
  109. package/dist/core/change-metadata/schema.d.ts +1 -1
  110. package/dist/core/change-metadata/schema.d.ts.map +1 -1
  111. package/dist/core/change-metadata/schema.js +10 -7
  112. package/dist/core/change-metadata/schema.js.map +1 -1
  113. package/dist/core/change-presenter.d.ts +23 -18
  114. package/dist/core/change-presenter.d.ts.map +1 -1
  115. package/dist/core/change-presenter.js +102 -43
  116. package/dist/core/change-presenter.js.map +1 -1
  117. package/dist/core/change-status-policy.d.ts +8 -1
  118. package/dist/core/change-status-policy.d.ts.map +1 -1
  119. package/dist/core/change-status-policy.js +25 -1
  120. package/dist/core/change-status-policy.js.map +1 -1
  121. package/dist/core/codex-metrics.d.ts +25 -45
  122. package/dist/core/codex-metrics.d.ts.map +1 -1
  123. package/dist/core/codex-metrics.js +44 -88
  124. package/dist/core/codex-metrics.js.map +1 -1
  125. package/dist/core/codex-residue.d.ts +14 -15
  126. package/dist/core/codex-residue.d.ts.map +1 -1
  127. package/dist/core/codex-residue.js +18 -22
  128. package/dist/core/codex-residue.js.map +1 -1
  129. package/dist/core/command-generation/adapters/claude.d.ts +2 -9
  130. package/dist/core/command-generation/adapters/claude.d.ts.map +1 -1
  131. package/dist/core/command-generation/adapters/claude.js +2 -12
  132. package/dist/core/command-generation/adapters/claude.js.map +1 -1
  133. package/dist/core/command-generation/adapters/index.d.ts +1 -9
  134. package/dist/core/command-generation/adapters/index.d.ts.map +1 -1
  135. package/dist/core/command-generation/adapters/index.js +1 -9
  136. package/dist/core/command-generation/adapters/index.js.map +1 -1
  137. package/dist/core/command-generation/generator.d.ts +0 -17
  138. package/dist/core/command-generation/generator.d.ts.map +1 -1
  139. package/dist/core/command-generation/generator.js +0 -17
  140. package/dist/core/command-generation/generator.js.map +1 -1
  141. package/dist/core/command-generation/index.d.ts +2 -5
  142. package/dist/core/command-generation/index.d.ts.map +1 -1
  143. package/dist/core/command-generation/index.js +0 -9
  144. package/dist/core/command-generation/index.js.map +1 -1
  145. package/dist/core/command-generation/types.d.ts +10 -36
  146. package/dist/core/command-generation/types.d.ts.map +1 -1
  147. package/dist/core/command-generation/types.js +0 -6
  148. package/dist/core/command-generation/types.js.map +1 -1
  149. package/dist/core/command-generation/yaml.d.ts +3 -18
  150. package/dist/core/command-generation/yaml.d.ts.map +1 -1
  151. package/dist/core/command-generation/yaml.js +5 -23
  152. package/dist/core/command-generation/yaml.js.map +1 -1
  153. package/dist/core/config-prompts.d.ts +2 -4
  154. package/dist/core/config-prompts.d.ts.map +1 -1
  155. package/dist/core/config-prompts.js +2 -7
  156. package/dist/core/config-prompts.js.map +1 -1
  157. package/dist/core/config-schema.d.ts +8 -53
  158. package/dist/core/config-schema.d.ts.map +1 -1
  159. package/dist/core/config-schema.js +49 -62
  160. package/dist/core/config-schema.js.map +1 -1
  161. package/dist/core/config.d.ts +39 -26
  162. package/dist/core/config.d.ts.map +1 -1
  163. package/dist/core/config.js +36 -22
  164. package/dist/core/config.js.map +1 -1
  165. package/dist/core/dashboard-activity.d.ts +7 -9
  166. package/dist/core/dashboard-activity.d.ts.map +1 -1
  167. package/dist/core/dashboard-activity.js +26 -24
  168. package/dist/core/dashboard-activity.js.map +1 -1
  169. package/dist/core/dashboard-data.d.ts +40 -22
  170. package/dist/core/dashboard-data.d.ts.map +1 -1
  171. package/dist/core/dashboard-data.js +62 -70
  172. package/dist/core/dashboard-data.js.map +1 -1
  173. package/dist/core/global-config.d.ts +24 -53
  174. package/dist/core/global-config.d.ts.map +1 -1
  175. package/dist/core/global-config.js +38 -67
  176. package/dist/core/global-config.js.map +1 -1
  177. package/dist/core/init.d.ts +25 -19
  178. package/dist/core/init.d.ts.map +1 -1
  179. package/dist/core/init.js +168 -181
  180. package/dist/core/init.js.map +1 -1
  181. package/dist/core/list.d.ts +1 -1
  182. package/dist/core/list.d.ts.map +1 -1
  183. package/dist/core/list.js +121 -28
  184. package/dist/core/list.js.map +1 -1
  185. package/dist/core/local-server.d.ts +41 -83
  186. package/dist/core/local-server.d.ts.map +1 -1
  187. package/dist/core/local-server.js +53 -98
  188. package/dist/core/local-server.js.map +1 -1
  189. package/dist/core/markdown-render.d.ts +25 -0
  190. package/dist/core/markdown-render.d.ts.map +1 -0
  191. package/dist/core/markdown-render.js +94 -0
  192. package/dist/core/markdown-render.js.map +1 -0
  193. package/dist/core/migrate.d.ts +29 -14
  194. package/dist/core/migrate.d.ts.map +1 -1
  195. package/dist/core/migrate.js +184 -122
  196. package/dist/core/migrate.js.map +1 -1
  197. package/dist/core/parsers/change-parser.d.ts +7 -10
  198. package/dist/core/parsers/change-parser.d.ts.map +1 -1
  199. package/dist/core/parsers/change-parser.js +48 -56
  200. package/dist/core/parsers/change-parser.js.map +1 -1
  201. package/dist/core/parsers/markdown-parser.d.ts +8 -9
  202. package/dist/core/parsers/markdown-parser.d.ts.map +1 -1
  203. package/dist/core/parsers/markdown-parser.js +31 -22
  204. package/dist/core/parsers/markdown-parser.js.map +1 -1
  205. package/dist/core/parsers/requirement-blocks.d.ts +43 -15
  206. package/dist/core/parsers/requirement-blocks.d.ts.map +1 -1
  207. package/dist/core/parsers/requirement-blocks.js +142 -70
  208. package/dist/core/parsers/requirement-blocks.js.map +1 -1
  209. package/dist/core/parsers/requirement-text.d.ts +73 -79
  210. package/dist/core/parsers/requirement-text.d.ts.map +1 -1
  211. package/dist/core/parsers/requirement-text.js +137 -79
  212. package/dist/core/parsers/requirement-text.js.map +1 -1
  213. package/dist/core/parsers/spec-structure.d.ts.map +1 -1
  214. package/dist/core/parsers/spec-structure.js +10 -6
  215. package/dist/core/parsers/spec-structure.js.map +1 -1
  216. package/dist/core/profiles.d.ts +3 -10
  217. package/dist/core/profiles.d.ts.map +1 -1
  218. package/dist/core/profiles.js +5 -12
  219. package/dist/core/profiles.js.map +1 -1
  220. package/dist/core/project-config.d.ts +43 -44
  221. package/dist/core/project-config.d.ts.map +1 -1
  222. package/dist/core/project-config.js +107 -82
  223. package/dist/core/project-config.js.map +1 -1
  224. package/dist/core/project-layout.d.ts +9 -17
  225. package/dist/core/project-layout.d.ts.map +1 -1
  226. package/dist/core/project-layout.js +16 -26
  227. package/dist/core/project-layout.js.map +1 -1
  228. package/dist/core/root-selection.d.ts +11 -7
  229. package/dist/core/root-selection.d.ts.map +1 -1
  230. package/dist/core/root-selection.js +7 -8
  231. package/dist/core/root-selection.js.map +1 -1
  232. package/dist/core/rules.d.ts +6 -1
  233. package/dist/core/rules.d.ts.map +1 -1
  234. package/dist/core/rules.js +23 -2
  235. package/dist/core/rules.js.map +1 -1
  236. package/dist/core/schema-names.d.ts +16 -0
  237. package/dist/core/schema-names.d.ts.map +1 -0
  238. package/dist/core/schema-names.js +16 -0
  239. package/dist/core/schema-names.js.map +1 -0
  240. package/dist/core/schemas/base.schema.d.ts +3 -0
  241. package/dist/core/schemas/base.schema.d.ts.map +1 -1
  242. package/dist/core/schemas/base.schema.js +22 -6
  243. package/dist/core/schemas/base.schema.js.map +1 -1
  244. package/dist/core/schemas/change.schema.d.ts +16 -0
  245. package/dist/core/schemas/change.schema.d.ts.map +1 -1
  246. package/dist/core/schemas/change.schema.js +41 -10
  247. package/dist/core/schemas/change.schema.js.map +1 -1
  248. package/dist/core/schemas/spec.schema.d.ts +2 -0
  249. package/dist/core/schemas/spec.schema.d.ts.map +1 -1
  250. package/dist/core/shared/index.d.ts +3 -8
  251. package/dist/core/shared/index.d.ts.map +1 -1
  252. package/dist/core/shared/index.js +3 -8
  253. package/dist/core/shared/index.js.map +1 -1
  254. package/dist/core/shared/rules-generation.d.ts +19 -8
  255. package/dist/core/shared/rules-generation.d.ts.map +1 -1
  256. package/dist/core/shared/rules-generation.js +117 -50
  257. package/dist/core/shared/rules-generation.js.map +1 -1
  258. package/dist/core/shared/skill-generation.d.ts +28 -43
  259. package/dist/core/shared/skill-generation.d.ts.map +1 -1
  260. package/dist/core/shared/skill-generation.js +82 -51
  261. package/dist/core/shared/skill-generation.js.map +1 -1
  262. package/dist/core/shared/tool-detection.d.ts +39 -61
  263. package/dist/core/shared/tool-detection.d.ts.map +1 -1
  264. package/dist/core/shared/tool-detection.js +88 -80
  265. package/dist/core/shared/tool-detection.js.map +1 -1
  266. package/dist/core/skill-metrics.d.ts +36 -63
  267. package/dist/core/skill-metrics.d.ts.map +1 -1
  268. package/dist/core/skill-metrics.js +34 -73
  269. package/dist/core/skill-metrics.js.map +1 -1
  270. package/dist/core/spec-presenter.js +6 -6
  271. package/dist/core/spec-presenter.js.map +1 -1
  272. package/dist/core/specs-apply.d.ts +22 -23
  273. package/dist/core/specs-apply.d.ts.map +1 -1
  274. package/dist/core/specs-apply.js +166 -193
  275. package/dist/core/specs-apply.js.map +1 -1
  276. package/dist/core/templates/fragments/interview.d.ts +2 -6
  277. package/dist/core/templates/fragments/interview.d.ts.map +1 -1
  278. package/dist/core/templates/fragments/interview.js +2 -6
  279. package/dist/core/templates/fragments/interview.js.map +1 -1
  280. package/dist/core/templates/fragments/next-step.d.ts +4 -8
  281. package/dist/core/templates/fragments/next-step.d.ts.map +1 -1
  282. package/dist/core/templates/fragments/next-step.js +4 -8
  283. package/dist/core/templates/fragments/next-step.js.map +1 -1
  284. package/dist/core/templates/fragments/validate.d.ts +13 -0
  285. package/dist/core/templates/fragments/validate.d.ts.map +1 -0
  286. package/dist/core/templates/fragments/validate.js +13 -0
  287. package/dist/core/templates/fragments/validate.js.map +1 -0
  288. package/dist/core/templates/fragments/verify.d.ts +9 -12
  289. package/dist/core/templates/fragments/verify.d.ts.map +1 -1
  290. package/dist/core/templates/fragments/verify.js +9 -12
  291. package/dist/core/templates/fragments/verify.js.map +1 -1
  292. package/dist/core/templates/index.d.ts +0 -6
  293. package/dist/core/templates/index.d.ts.map +1 -1
  294. package/dist/core/templates/index.js +0 -7
  295. package/dist/core/templates/index.js.map +1 -1
  296. package/dist/core/templates/skill-templates.d.ts +1 -5
  297. package/dist/core/templates/skill-templates.d.ts.map +1 -1
  298. package/dist/core/templates/skill-templates.js +0 -5
  299. package/dist/core/templates/skill-templates.js.map +1 -1
  300. package/dist/core/templates/types.d.ts +3 -7
  301. package/dist/core/templates/types.d.ts.map +1 -1
  302. package/dist/core/templates/types.js +0 -3
  303. package/dist/core/templates/types.js.map +1 -1
  304. package/dist/core/templates/workflows/apply.d.ts +3 -9
  305. package/dist/core/templates/workflows/apply.d.ts.map +1 -1
  306. package/dist/core/templates/workflows/apply.js +11 -13
  307. package/dist/core/templates/workflows/apply.js.map +1 -1
  308. package/dist/core/templates/workflows/archive.d.ts +0 -6
  309. package/dist/core/templates/workflows/archive.d.ts.map +1 -1
  310. package/dist/core/templates/workflows/archive.js +19 -6
  311. package/dist/core/templates/workflows/archive.js.map +1 -1
  312. package/dist/core/templates/workflows/decision.js +4 -4
  313. package/dist/core/templates/workflows/decision.js.map +1 -1
  314. package/dist/core/templates/workflows/explore.js +1 -1
  315. package/dist/core/templates/workflows/grill.d.ts.map +1 -1
  316. package/dist/core/templates/workflows/grill.js +0 -2
  317. package/dist/core/templates/workflows/grill.js.map +1 -1
  318. package/dist/core/templates/workflows/issue.d.ts +0 -6
  319. package/dist/core/templates/workflows/issue.d.ts.map +1 -1
  320. package/dist/core/templates/workflows/issue.js +3 -2
  321. package/dist/core/templates/workflows/issue.js.map +1 -1
  322. package/dist/core/templates/workflows/propose.d.ts +0 -6
  323. package/dist/core/templates/workflows/propose.d.ts.map +1 -1
  324. package/dist/core/templates/workflows/propose.js +2 -2
  325. package/dist/core/templates/workflows/propose.js.map +1 -1
  326. package/dist/core/templates/workflows/sync.d.ts +2 -8
  327. package/dist/core/templates/workflows/sync.d.ts.map +1 -1
  328. package/dist/core/templates/workflows/sync.js +4 -3
  329. package/dist/core/templates/workflows/sync.js.map +1 -1
  330. package/dist/core/templates/workflows/update.d.ts +0 -6
  331. package/dist/core/templates/workflows/update.d.ts.map +1 -1
  332. package/dist/core/templates/workflows/update.js +9 -2
  333. package/dist/core/templates/workflows/update.js.map +1 -1
  334. package/dist/core/update.d.ts +23 -23
  335. package/dist/core/update.d.ts.map +1 -1
  336. package/dist/core/update.js +139 -118
  337. package/dist/core/update.js.map +1 -1
  338. package/dist/core/user-state-migration.d.ts +13 -15
  339. package/dist/core/user-state-migration.d.ts.map +1 -1
  340. package/dist/core/user-state-migration.js +16 -20
  341. package/dist/core/user-state-migration.js.map +1 -1
  342. package/dist/core/validation/constants.d.ts +4 -10
  343. package/dist/core/validation/constants.d.ts.map +1 -1
  344. package/dist/core/validation/constants.js +25 -20
  345. package/dist/core/validation/constants.js.map +1 -1
  346. package/dist/core/validation/prose-length.d.ts +15 -0
  347. package/dist/core/validation/prose-length.d.ts.map +1 -0
  348. package/dist/core/validation/prose-length.js +29 -0
  349. package/dist/core/validation/prose-length.js.map +1 -0
  350. package/dist/core/validation/purpose-placeholder.d.ts +9 -16
  351. package/dist/core/validation/purpose-placeholder.d.ts.map +1 -1
  352. package/dist/core/validation/purpose-placeholder.js +30 -44
  353. package/dist/core/validation/purpose-placeholder.js.map +1 -1
  354. package/dist/core/validation/section-validator.d.ts +4 -4
  355. package/dist/core/validation/section-validator.d.ts.map +1 -1
  356. package/dist/core/validation/section-validator.js +43 -7
  357. package/dist/core/validation/section-validator.js.map +1 -1
  358. package/dist/core/validation/task-numbering.d.ts +6 -3
  359. package/dist/core/validation/task-numbering.d.ts.map +1 -1
  360. package/dist/core/validation/task-numbering.js +23 -11
  361. package/dist/core/validation/task-numbering.js.map +1 -1
  362. package/dist/core/validation/types.d.ts +18 -0
  363. package/dist/core/validation/types.d.ts.map +1 -1
  364. package/dist/core/validation/types.js +12 -1
  365. package/dist/core/validation/types.js.map +1 -1
  366. package/dist/core/validation/validator.d.ts +43 -63
  367. package/dist/core/validation/validator.d.ts.map +1 -1
  368. package/dist/core/validation/validator.js +500 -267
  369. package/dist/core/validation/validator.js.map +1 -1
  370. package/dist/prompts/searchable-multi-select.d.ts +3 -8
  371. package/dist/prompts/searchable-multi-select.d.ts.map +1 -1
  372. package/dist/prompts/searchable-multi-select.js +16 -39
  373. package/dist/prompts/searchable-multi-select.js.map +1 -1
  374. package/dist/utils/change-metadata.d.ts +11 -50
  375. package/dist/utils/change-metadata.d.ts.map +1 -1
  376. package/dist/utils/change-metadata.js +48 -67
  377. package/dist/utils/change-metadata.js.map +1 -1
  378. package/dist/utils/change-utils.d.ts +30 -54
  379. package/dist/utils/change-utils.d.ts.map +1 -1
  380. package/dist/utils/change-utils.js +133 -91
  381. package/dist/utils/change-utils.js.map +1 -1
  382. package/dist/utils/file-lock.d.ts +39 -0
  383. package/dist/utils/file-lock.d.ts.map +1 -0
  384. package/dist/utils/file-lock.js +149 -0
  385. package/dist/utils/file-lock.js.map +1 -0
  386. package/dist/utils/file-system.d.ts +12 -32
  387. package/dist/utils/file-system.d.ts.map +1 -1
  388. package/dist/utils/file-system.js +16 -40
  389. package/dist/utils/file-system.js.map +1 -1
  390. package/dist/utils/frontmatter.d.ts +7 -11
  391. package/dist/utils/frontmatter.d.ts.map +1 -1
  392. package/dist/utils/frontmatter.js +11 -11
  393. package/dist/utils/frontmatter.js.map +1 -1
  394. package/dist/utils/interactive.d.ts +4 -9
  395. package/dist/utils/interactive.d.ts.map +1 -1
  396. package/dist/utils/interactive.js +2 -4
  397. package/dist/utils/interactive.js.map +1 -1
  398. package/dist/utils/item-discovery.d.ts +15 -10
  399. package/dist/utils/item-discovery.d.ts.map +1 -1
  400. package/dist/utils/item-discovery.js +42 -47
  401. package/dist/utils/item-discovery.js.map +1 -1
  402. package/dist/utils/link.d.ts +9 -18
  403. package/dist/utils/link.d.ts.map +1 -1
  404. package/dist/utils/link.js +9 -18
  405. package/dist/utils/link.js.map +1 -1
  406. package/dist/utils/requirement-diff.d.ts +13 -23
  407. package/dist/utils/requirement-diff.d.ts.map +1 -1
  408. package/dist/utils/requirement-diff.js +13 -23
  409. package/dist/utils/requirement-diff.js.map +1 -1
  410. package/dist/utils/spec-files.d.ts +7 -20
  411. package/dist/utils/spec-files.d.ts.map +1 -1
  412. package/dist/utils/spec-files.js +26 -51
  413. package/dist/utils/spec-files.js.map +1 -1
  414. package/dist/utils/task-progress.d.ts +11 -9
  415. package/dist/utils/task-progress.d.ts.map +1 -1
  416. package/dist/utils/task-progress.js +53 -32
  417. package/dist/utils/task-progress.js.map +1 -1
  418. package/dist/utils/timestamp.d.ts +5 -8
  419. package/dist/utils/timestamp.d.ts.map +1 -1
  420. package/dist/utils/timestamp.js +5 -8
  421. package/dist/utils/timestamp.js.map +1 -1
  422. package/package.json +2 -3
  423. package/schemas/decision/templates/decision.md +3 -1
  424. package/schemas/decision/templates/index.md +2 -2
  425. package/schemas/issue/schema.yaml +8 -1
  426. package/schemas/issue/templates/spec.md +27 -2
  427. package/schemas/sdd/schema.yaml +20 -1
  428. package/schemas/sdd/templates/spec.md +27 -2
  429. /package/assets/rules/tospec/{single-sourc-of-truth.md → single-source-of-truth.md} +0 -0
@@ -1,14 +1,10 @@
1
1
  /**
2
2
  * Plumbing shared by every local web command (`dashboard`, `metrics`).
3
3
  *
4
- * Two of these are trust boundaries, and that is the reason this module exists
5
- * rather than each command carrying its own copy: `isAllowedHostHeader` is a
6
- * DNS-rebinding guard and `serveAsset` is a path-escape guard. A second
7
- * implementation of either is a hole that survives fixing the first one.
8
- *
9
- * `serveAsset` takes its root directory as an argument — the commands serve
10
- * different asset trees, and parameterising the directory is what lets one
11
- * implementation serve both.
4
+ * Shared rather than copied per command because several of these are trust
5
+ * boundaries — `isAllowedHostHeader` (DNS rebinding), `serveAsset` (path
6
+ * escape), `assertBindableHost` (bind policy). A second implementation of any of
7
+ * them is a hole that survives fixing the first.
12
8
  */
13
9
  import { promises as fs } from 'node:fs';
14
10
  import * as path from 'node:path';
@@ -21,21 +17,12 @@ const ASSET_CONTENT_TYPES = {
21
17
  };
22
18
  /**
23
19
  * Canonical form of a bind address or Host-header name, so the sets below hold
24
- * addresses rather than spellings.
25
- *
26
- * `::`, `::0` and `0:0:0:0:0:0:0:0` are one address, and every one of them is
27
- * something a user can legitimately type after `--host`. Matching spellings
28
- * means the next one nobody thought to list silently takes the wrong branch —
29
- * which is how `--allow-remote --host ::0` bound every interface and then 403'd
30
- * every request that arrived on one.
20
+ * addresses rather than spellings: `::`, `::0` and `0:0:0:0:0:0:0:0` are one
21
+ * address a user may type after `--host`.
31
22
  *
32
- * The WHATWG URL parser is the normalizer because it is the only IPv6/IPv4
33
- * canonicalizer already in Node's core: it collapses every spelling above to
34
- * `::`, and the brackets it adds back are stripped here.
35
- *
36
- * Anything that does not parse as a host is returned lowercased and otherwise
37
- * untouched. Every check in this module treats an unrecognized value as neither
38
- * loopback nor wildcard, which is the refusing side of each of them.
23
+ * The WHATWG URL parser is the normalizer because it is Node's only built-in
24
+ * IPv6/IPv4 canonicalizer. An unparseable value is returned lowercased, and
25
+ * every check here treats it as neither loopback nor wildcard.
39
26
  */
40
27
  export function normalizeHost(host) {
41
28
  const bare = host.trim().toLowerCase().replace(/^\[|\]$/g, '');
@@ -55,64 +42,55 @@ export function normalizeHost(host) {
55
42
  */
56
43
  export const LOOPBACK_HOSTS = new Set(['127.0.0.1', 'localhost', '::1']);
57
44
  /**
58
- * Bind addresses that mean "every interface", canonical forms only. These are
59
- * not names any client sends as a Host header, which is what makes them the one
60
- * case the literal match in `isAllowedHostHeader` can never satisfy.
61
- *
62
- * `::ffff:0:0` is the IPv4-mapped spelling of the same unspecified address; it
63
- * is listed because it survives normalization as a distinct string, not because
64
- * it means anything different.
45
+ * Bind addresses meaning "every interface", canonical forms only. No client
46
+ * sends these as a Host header, which is why `isAllowedHostHeader`'s literal
47
+ * match can never satisfy them. `::ffff:0:0` is listed because it survives
48
+ * normalization as a distinct string.
65
49
  */
66
50
  export const WILDCARD_HOSTS = new Set(['0.0.0.0', '::', '::ffff:0:0']);
67
51
  /**
68
- * The bind guard, in one place because it is the third trust boundary this
69
- * module owns.
70
- *
71
- * It lived inline in `startDashboardServer`, so the metrics server — which takes
72
- * the same `host`, goes through the same `listenFrom`, and shares
73
- * `isAllowedHostHeader` and `serveAsset` from this module — had nothing to call
74
- * and bound `0.0.0.0` without objecting. That is exactly the hole this file's
75
- * header warns about: a guard with one implementation site cannot protect the
76
- * second caller that never reaches it.
52
+ * A URL a browser can actually open for a server bound to `host`. A wildcard
53
+ * bind has no connectable spelling — `http://0.0.0.0:5620` is not visitable —
54
+ * and `dashboard --list` reconstructs the loopback URL the same way.
55
+ */
56
+ export function connectableUrl(host, port) {
57
+ // Normalized like every other check here: `::0` is a wildcard bind that
58
+ // `acceptsAnyHostHeader` recognises, so printing `http://[::0]:5620` for it
59
+ // handed the user a URL no browser can open.
60
+ const displayHost = WILDCARD_HOSTS.has(normalizeHost(host)) ? '127.0.0.1' : host;
61
+ // IPv6 literals need brackets in a URL; a bare `::1` parses as host `` with a
62
+ // port of `:1`.
63
+ const bracketed = displayHost.includes(':') ? `[${displayHost}]` : displayHost;
64
+ return `http://${bracketed}:${port}`;
65
+ }
66
+ /**
67
+ * The bind guard, shared so a new local server cannot silently bind `0.0.0.0`.
77
68
  *
78
- * `serverName` appears in the message so the refusal still names what refused,
79
- * and `remedy` is supplied by the caller for the same reason one step further:
80
- * the text used to hard-code "Pass `--allow-remote`", a flag `skill-metrics`
81
- * does not register, so the one command that could not act on the advice was the
82
- * one being told to. Making it a parameter means a new local server has to state
83
- * its own escape hatch rather than silently inherit one it may not have.
69
+ * `remedy` is the caller's: `--allow-remote` is a dashboard flag that
70
+ * `skill-metrics` does not register, so each server states its own escape hatch.
84
71
  */
85
72
  export function assertBindableHost(host, serverName, allowRemote, remedy) {
86
73
  if (LOOPBACK_HOSTS.has(normalizeHost(host)) || allowRemote)
87
74
  return;
88
75
  throw new Error(`Refusing to bind non-loopback host '${host}': the ${serverName} would be readable by anyone who can reach this machine. ${remedy}`);
89
76
  }
90
- // -----------------------------------------------------------------------------
91
- // Responses
92
- // -----------------------------------------------------------------------------
93
77
  export function sendJson(res, status, payload) {
94
78
  res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' });
95
79
  res.end(JSON.stringify(payload));
96
80
  }
97
81
  /**
98
- * Absolute path to a shipped asset tree (`assets/<name>`), resolved relative to
99
- * this module's own URL.
100
- *
101
- * The depth is load-bearing: compiled to `dist/core/`, two levels up is the
102
- * package root, which is also what `dist/commands/` yields. Assets are shipped
103
- * as package `files` and never compiled, so moving this module to a different
104
- * depth would silently resolve outside the package. Every caller goes through
105
- * here so that constraint has exactly one home.
82
+ * Absolute path to a shipped asset tree (`assets/<name>`), resolved from this
83
+ * module's own URL. The depth is load-bearing: compiled to `dist/core/`, two
84
+ * levels up is the package root, so moving this module resolves outside it.
106
85
  */
107
86
  export function packageAssetsDir(name) {
108
87
  const here = path.dirname(fileURLToPath(import.meta.url));
109
88
  return path.join(here, '..', '..', 'assets', name);
110
89
  }
111
90
  /**
112
- * Serves one file from `dir`. The requested name is confined to that directory:
113
- * URL parsing already normalises `..`, but a resolved path outside `dir` is
114
- * refused regardless, since this is the only thing standing between a crafted
115
- * request and the rest of the filesystem.
91
+ * Serves one file from `dir`. URL parsing already normalises `..`, but a
92
+ * resolved path outside `dir` is refused regardless: this is the only thing
93
+ * between a crafted request and the rest of the filesystem.
116
94
  */
117
95
  export async function serveAsset(res, dir, rawName) {
118
96
  const name = decodeURIComponent(rawName);
@@ -134,15 +112,11 @@ export async function serveAsset(res, dir, rawName) {
134
112
  res.writeHead(200, { 'content-type': `${type}; charset=utf-8` });
135
113
  res.end(content);
136
114
  }
137
- // -----------------------------------------------------------------------------
138
- // Trust boundary
139
- // -----------------------------------------------------------------------------
140
115
  /**
141
116
  * DNS-rebinding guard: only requests whose Host header names loopback (or the
142
117
  * explicitly bound non-loopback address) are served. A malicious page can make
143
118
  * a victim's browser resolve an attacker domain to 127.0.0.1 and read the
144
- * server's endpoints; the attacker domain in the Host header is what gives that
145
- * away.
119
+ * server's endpoints; the attacker domain in the Host header gives that away.
146
120
  */
147
121
  export function isAllowedHostHeader(hostHeader, boundHost, acceptAnyHost = false) {
148
122
  if (!hostHeader)
@@ -152,38 +126,31 @@ export function isAllowedHostHeader(hostHeader, boundHost, acceptAnyHost = false
152
126
  if (!match)
153
127
  return false;
154
128
  // Normalized on both sides so the comparison is between addresses, not
155
- // between the spelling the client sent and the spelling the operator typed.
129
+ // between the client's spelling and the operator's.
156
130
  const name = normalizeHost(match[1]);
157
131
  if (LOOPBACK_HOSTS.has(name))
158
132
  return true;
159
- // Still parsed and still last: an unparseable Host header is refused even
160
- // here, so the opt-in widens who may be named, not what counts as a name.
133
+ // Last, and after parsing: the opt-in widens who may be named, not what counts
134
+ // as a name.
161
135
  if (acceptAnyHost)
162
136
  return true;
163
137
  return name === normalizeHost(boundHost);
164
138
  }
165
139
  /**
166
- * The Host-header policy, resolved once at startup rather than re-derived per
167
- * request — see decisions/20260910_150312-allow-remote-wildcard-host-policy.md.
140
+ * The Host-header policy, resolved once at startup rather than per request —
141
+ * see decisions/20260910_150312-allow-remote-wildcard-host-policy.md.
168
142
  *
169
143
  * A wildcard bind has no Host header that can literally match it, so
170
- * `--allow-remote --host 0.0.0.0` used to listen on every interface and then
171
- * 403 every request that arrived on one. Only that combination is relaxed: with
172
- * a concrete address the operator named the host worth accepting, and the
173
- * literal match is both free and still correct.
174
- *
175
- * Kept out of `isAllowedHostHeader` on purpose. That predicate cannot see
176
- * whether `--allow-remote` was passed, and burying "wildcard means trust
177
- * everyone" inside it would make the assumption invisible at the call site.
144
+ * `--allow-remote --host 0.0.0.0` would listen on every interface then 403 every
145
+ * request. Only that combination is relaxed; a concrete address names the host
146
+ * worth accepting. Kept out of `isAllowedHostHeader` so "wildcard means trust
147
+ * everyone" stays visible at the call site.
178
148
  */
179
149
  export function acceptsAnyHostHeader(boundHost, allowRemote) {
180
150
  if (!allowRemote)
181
151
  return false;
182
152
  return WILDCARD_HOSTS.has(normalizeHost(boundHost));
183
153
  }
184
- // -----------------------------------------------------------------------------
185
- // Lifecycle
186
- // -----------------------------------------------------------------------------
187
154
  /** Resolves once the server is listening, or rejects with the listen error. */
188
155
  export function listenOnce(server, port, host) {
189
156
  return new Promise((resolve, reject) => {
@@ -201,17 +168,12 @@ export function listenOnce(server, port, host) {
201
168
  });
202
169
  }
203
170
  /**
204
- * Binds `basePort`, advancing to the next port on `EADDRINUSE` until one is
205
- * free, and returns the port actually bound. Every local command wants the same
206
- * rule — a predictable port you can keep in your head, that still yields rather
207
- * than failing when something already holds it.
171
+ * Binds `basePort`, advancing on `EADDRINUSE` until one is free, and returns the
172
+ * port actually bound.
208
173
  *
209
- * `port: 0` is passed straight through: the OS picks a free port itself, so
210
- * there is nothing to retry and incrementing from whatever it chose would be
211
- * meaningless.
212
- *
213
- * The attempt bound is a backstop, not a policy: without it a machine that
214
- * refuses every bind for some other reason would spin through 65k ports.
174
+ * `port: 0` passes straight through — the OS picks a free port, so there is
175
+ * nothing to retry. `maxAttempts` stops a machine that refuses every bind from
176
+ * spinning through 65k ports.
215
177
  */
216
178
  export async function listenFrom(server, basePort, host, maxAttempts = 200) {
217
179
  let port = basePort;
@@ -232,14 +194,7 @@ export async function listenFrom(server, basePort, host, maxAttempts = 200) {
232
194
  const address = server.address();
233
195
  return typeof address === 'object' && address ? address.port : port;
234
196
  }
235
- // -----------------------------------------------------------------------------
236
- // Browser
237
- // -----------------------------------------------------------------------------
238
- /**
239
- * Builds the platform command that opens `url` in the default browser.
240
- * Pure (no side effects) so the platform branching is testable without
241
- * launching anything.
242
- */
197
+ /** Pure, so the platform branching is testable without launching anything. */
243
198
  export function browserOpenCommand(url, platform = process.platform) {
244
199
  if (platform === 'win32')
245
200
  return `start "" "${url}"`;
@@ -1 +1 @@
1
- {"version":3,"file":"local-server.js","sourceRoot":"","sources":["../../src/core/local-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,MAAM,mBAAmB,GAA2B;IAClD,OAAO,EAAE,WAAW;IACpB,KAAK,EAAE,iBAAiB;IACxB,MAAM,EAAE,UAAU;CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,M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AAI,EAAE,CAAC;gBACP,SAAS;YACX,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IACD,kEAAkE;IAClE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IACjC,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,kBAAkB,CAChC,GAAW,EACX,QAAQ,GAAoB,OAAO,CAAC,QAAQ;IAE5C,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,aAAa,GAAG,GAAG,CAAC;IACrD,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,SAAS,GAAG,GAAG,CAAC;IAClD,OAAO,aAAa,GAAG,GAAG,CAAC;AAC7B,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,4EAA4E;IAC5E,0EAA0E;IAC1E,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE;QAC3D,IAAI,GAAG,EAAE,CAAC;YACR,OAAO,CAAC,IAAI,CAAC,2CAA2C,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QACzE,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Markdown → HTML for the dashboard's `/api/render`, and a trust boundary rather
3
+ * than a formatting detail: the output is assigned with `innerHTML`, so it runs
4
+ * in the same origin that answers `POST /api/task`. The CSRF defence on
5
+ * `handleTaskUpdate` only stops *cross-origin* callers, so a handler smuggled in
6
+ * through a markdown file would sit inside it.
7
+ *
8
+ * Raw HTML is escaped, not allowlisted: an allowlist has to stay ahead of every
9
+ * attribute and scheme that can execute, and these documents need no markup
10
+ * markdown cannot express.
11
+ */
12
+ /**
13
+ * The URL when it is safe to emit as an attribute, otherwise null. Two rules,
14
+ * both against spellings a naive scheme regex waves through:
15
+ *
16
+ * 1. Tabs and newlines are stripped first. `java&#9;script:alert(1)` matches no
17
+ * `^javascript:` regex, but the URL parser — and the browser — strips them
18
+ * and is left with `javascript:`.
19
+ * 2. The scheme comes from `URL`, not the raw text, so case variants and
20
+ * percent-encoded forms normalize before comparison.
21
+ */
22
+ export declare function safeUrl(href: string): string | null;
23
+ /** Renders markdown to HTML with raw HTML escaped and URL schemes restricted. */
24
+ export declare function renderMarkdownSafe(markdown: string): Promise<string>;
25
+ //# sourceMappingURL=markdown-render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-render.d.ts","sourceRoot":"","sources":["../../src/core/markdown-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA6BH;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAenD;AA+BD,iFAAiF;AACjF,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE1E"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Markdown → HTML for the dashboard's `/api/render`, and a trust boundary rather
3
+ * than a formatting detail: the output is assigned with `innerHTML`, so it runs
4
+ * in the same origin that answers `POST /api/task`. The CSRF defence on
5
+ * `handleTaskUpdate` only stops *cross-origin* callers, so a handler smuggled in
6
+ * through a markdown file would sit inside it.
7
+ *
8
+ * Raw HTML is escaped, not allowlisted: an allowlist has to stay ahead of every
9
+ * attribute and scheme that can execute, and these documents need no markup
10
+ * markdown cannot express.
11
+ */
12
+ import { Marked } from 'marked';
13
+ /**
14
+ * Schemes a link or image may keep. Relative paths and fragments carry no
15
+ * scheme and are allowed by falling through the `URL` parse below.
16
+ *
17
+ * `data:` is excluded: `data:text/html` navigates to attacker markup in this
18
+ * origin, and no spec document needs an inline blob.
19
+ */
20
+ const SAFE_URL_SCHEMES = new Set(['http:', 'https:', 'mailto:']);
21
+ function escapeHtml(text) {
22
+ return text
23
+ .replace(/&/g, '&amp;')
24
+ .replace(/</g, '&lt;')
25
+ .replace(/>/g, '&gt;')
26
+ .replace(/"/g, '&quot;')
27
+ .replace(/'/g, '&#39;');
28
+ }
29
+ /**
30
+ * Base for resolving relative hrefs: a relative URL inherits this scheme, so
31
+ * `parsed.protocol` lands in the allowlist and one check covers both absolute
32
+ * and relative inputs. The host is never emitted.
33
+ */
34
+ const RELATIVE_BASE = 'https://tospec.invalid/';
35
+ /**
36
+ * The URL when it is safe to emit as an attribute, otherwise null. Two rules,
37
+ * both against spellings a naive scheme regex waves through:
38
+ *
39
+ * 1. Tabs and newlines are stripped first. `java&#9;script:alert(1)` matches no
40
+ * `^javascript:` regex, but the URL parser — and the browser — strips them
41
+ * and is left with `javascript:`.
42
+ * 2. The scheme comes from `URL`, not the raw text, so case variants and
43
+ * percent-encoded forms normalize before comparison.
44
+ */
45
+ export function safeUrl(href) {
46
+ // The same normalization the URL parser applies: C0 controls and space
47
+ // trimmed from both ends, tab/LF/CR removed throughout.
48
+ const cleaned = href.replace(/[\x00- ]+$/, '').replace(/^[\x00- ]+/, '').replace(/[\t\n\r]/g, '');
49
+ if (cleaned === '')
50
+ return null;
51
+ let parsed;
52
+ try {
53
+ parsed = new URL(cleaned, RELATIVE_BASE);
54
+ }
55
+ catch {
56
+ return null;
57
+ }
58
+ if (!SAFE_URL_SCHEMES.has(parsed.protocol))
59
+ return null;
60
+ // The cleaned form, not the input: what was validated has to be what is
61
+ // emitted, or the browser re-reads the characters removed above.
62
+ return cleaned;
63
+ }
64
+ const renderer = new Marked({
65
+ renderer: {
66
+ // Both block-level and inline raw HTML arrive here.
67
+ html({ text }) {
68
+ return escapeHtml(text);
69
+ },
70
+ link(token) {
71
+ const body = this.parser.parseInline(token.tokens);
72
+ const href = safeUrl(token.href);
73
+ // A rejected scheme keeps the text and loses the link; dropping the node
74
+ // would hide that the author wrote something the renderer refused.
75
+ if (href === null)
76
+ return body;
77
+ const title = token.title ? ` title="${escapeHtml(token.title)}"` : '';
78
+ return `<a href="${escapeHtml(href)}"${title}>${body}</a>`;
79
+ },
80
+ image(token) {
81
+ const src = safeUrl(token.href);
82
+ const alt = escapeHtml(token.text);
83
+ if (src === null)
84
+ return alt;
85
+ const title = token.title ? ` title="${escapeHtml(token.title)}"` : '';
86
+ return `<img src="${escapeHtml(src)}" alt="${alt}"${title}>`;
87
+ },
88
+ },
89
+ });
90
+ /** Renders markdown to HTML with raw HTML escaped and URL schemes restricted. */
91
+ export async function renderMarkdownSafe(markdown) {
92
+ return renderer.parse(markdown);
93
+ }
94
+ //# sourceMappingURL=markdown-render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markdown-render.js","sourceRoot":"","sources":["../../src/core/markdown-render.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAEjE,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,aAAa,GAAG,yBAAyB,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,uEAAuE;IACvE,wDAAwD;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,O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M,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,GAAG,KAAK,IAAI;gBAAE,OAAO,GAAG,CAAC;YAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACvE,OAAO,aAAa,UAAU,CAAC,GAAG,CAAC,UAAU,GAAG,IAAI,KAAK,GAAG,CAAC;QAC/D,CAAC;KACF;CACF,CAAC,CAAC;AAEH,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,QAAgB;IACvD,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC"}
@@ -1,6 +1,10 @@
1
+ import { type CommandDiagnostic } from '../commands/shared-output.js';
1
2
  export interface MigrateOptions {
2
3
  force?: boolean;
4
+ json?: boolean;
3
5
  }
6
+ /** The `--json` null-shape; mirrors the success payload with `migrate` nulled. */
7
+ export declare const MIGRATE_FAILURE_PAYLOAD: Record<string, unknown>;
4
8
  export interface MigrateSummary {
5
9
  specs: {
6
10
  copied: number;
@@ -17,22 +21,29 @@ export interface MigrateSummary {
17
21
  context: 'carried' | 'conflict' | 'empty' | 'absent';
18
22
  /** REMOVED requirements dropped during main-spec normalization (`spec/name`). */
19
23
  removedRequirements: string[];
20
- /** RENAMED requirement blocks kept as MODIFIED content (`spec/name`). */
24
+ /** Renames a RENAMED section asked for and normalization applied (`spec/from -> to`). */
25
+ renamedRequirements: string[];
26
+ /**
27
+ * RENAMED entries normalization could not act on, so the old name stands
28
+ * (`spec/name`). Reported for manual review rather than dropped.
29
+ */
21
30
  renamedKept: string[];
22
31
  }
23
32
  export declare class MigrateError extends Error {
24
- diagnostic?: {
25
- fix?: string;
26
- } | undefined;
27
- constructor(message: string, diagnostic?: {
33
+ /**
34
+ * A full `CommandDiagnostic`: `asStatus` recognises one by `typeof
35
+ * diagnostic.code === 'string'`, so a bare `{ fix }` is dropped.
36
+ */
37
+ readonly diagnostic: CommandDiagnostic;
38
+ constructor(message: string, options?: {
28
39
  fix?: string;
29
- } | undefined);
40
+ code?: string;
41
+ });
30
42
  }
31
43
  /**
32
44
  * Converts an OpenSpec archive dir name (`YYYY-MM-DD-<name>`) to the tospec
33
- * stamp form (`YYYYMMDD_000000-<name>`). OpenSpec only recorded the date, so
34
- * the time part is zero-filled. Names without the date prefix pass through
35
- * unchanged (they already parse as `<stamp>-<name>` no worse than before).
45
+ * stamp form (`YYYYMMDD_000000-<name>`). OpenSpec only recorded the date, so the
46
+ * time part is zero-filled. Names without the date prefix pass through.
36
47
  */
37
48
  export declare function convertArchiveDirName(dirName: string): string;
38
49
  /**
@@ -45,7 +56,12 @@ export declare function normalizeMainSpec(content: string, capabilityName: strin
45
56
  fixed: 'delta' | 'headerless';
46
57
  /** Names of requirements a REMOVED section dropped (recorded, not silent). */
47
58
  removed: string[];
48
- /** Names of RENAMED requirement blocks whose content was kept as MODIFIED. */
59
+ /** Renames a RENAMED section asked for and this rebuild applied. */
60
+ renamed: Array<{
61
+ from: string;
62
+ to: string;
63
+ }>;
64
+ /** RENAMED entries nothing could be applied for; the old name stands. */
49
65
  renamedKept: string[];
50
66
  } | null;
51
67
  export declare class MigrateCommand {
@@ -61,10 +77,9 @@ export declare class MigrateCommand {
61
77
  */
62
78
  private migrateMetadata;
63
79
  /**
64
- * Promote the fully-built staging tree into the target. When the target
65
- * doesn't exist, one move does it; when an (verified content-free) tospec/
66
- * dir exists — e.g. from `tospec init` — each staged top-level entry
67
- * replaces its counterpart. Reuses archive's EPERM/EXDEV-safe move helpers.
80
+ * Promotes the built staging tree into the target: one move when the target is
81
+ * absent, else entry-by-entry replacement into the content-free tospec/ that
82
+ * `tospec init` leaves. Uses archive's EPERM/EXDEV-safe helpers.
68
83
  */
69
84
  private promoteStaging;
70
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mig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