@tiangong-lca/pcr 0.0.0-stage → 0.1.2

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 (572) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE.md +5 -0
  3. package/README.md +86 -2
  4. package/node_modules/ajv/.runkit_example.js +23 -0
  5. package/node_modules/ajv/LICENSE +22 -0
  6. package/node_modules/ajv/README.md +207 -0
  7. package/node_modules/ajv/dist/2019.d.ts +19 -0
  8. package/node_modules/ajv/dist/2019.js +61 -0
  9. package/node_modules/ajv/dist/2019.js.map +1 -0
  10. package/node_modules/ajv/dist/2020.d.ts +19 -0
  11. package/node_modules/ajv/dist/2020.js +55 -0
  12. package/node_modules/ajv/dist/2020.js.map +1 -0
  13. package/node_modules/ajv/dist/ajv.d.ts +18 -0
  14. package/node_modules/ajv/dist/ajv.js +50 -0
  15. package/node_modules/ajv/dist/ajv.js.map +1 -0
  16. package/node_modules/ajv/dist/compile/codegen/code.d.ts +40 -0
  17. package/node_modules/ajv/dist/compile/codegen/code.js +156 -0
  18. package/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
  19. package/node_modules/ajv/dist/compile/codegen/index.d.ts +79 -0
  20. package/node_modules/ajv/dist/compile/codegen/index.js +697 -0
  21. package/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
  22. package/node_modules/ajv/dist/compile/codegen/scope.d.ts +79 -0
  23. package/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
  24. package/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
  25. package/node_modules/ajv/dist/compile/errors.d.ts +13 -0
  26. package/node_modules/ajv/dist/compile/errors.js +123 -0
  27. package/node_modules/ajv/dist/compile/errors.js.map +1 -0
  28. package/node_modules/ajv/dist/compile/index.d.ts +80 -0
  29. package/node_modules/ajv/dist/compile/index.js +242 -0
  30. package/node_modules/ajv/dist/compile/index.js.map +1 -0
  31. package/node_modules/ajv/dist/compile/jtd/parse.d.ts +4 -0
  32. package/node_modules/ajv/dist/compile/jtd/parse.js +350 -0
  33. package/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -0
  34. package/node_modules/ajv/dist/compile/jtd/serialize.d.ts +4 -0
  35. package/node_modules/ajv/dist/compile/jtd/serialize.js +236 -0
  36. package/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -0
  37. package/node_modules/ajv/dist/compile/jtd/types.d.ts +6 -0
  38. package/node_modules/ajv/dist/compile/jtd/types.js +14 -0
  39. package/node_modules/ajv/dist/compile/jtd/types.js.map +1 -0
  40. package/node_modules/ajv/dist/compile/names.d.ts +20 -0
  41. package/node_modules/ajv/dist/compile/names.js +28 -0
  42. package/node_modules/ajv/dist/compile/names.js.map +1 -0
  43. package/node_modules/ajv/dist/compile/ref_error.d.ts +6 -0
  44. package/node_modules/ajv/dist/compile/ref_error.js +12 -0
  45. package/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
  46. package/node_modules/ajv/dist/compile/resolve.d.ts +12 -0
  47. package/node_modules/ajv/dist/compile/resolve.js +155 -0
  48. package/node_modules/ajv/dist/compile/resolve.js.map +1 -0
  49. package/node_modules/ajv/dist/compile/rules.d.ts +28 -0
  50. package/node_modules/ajv/dist/compile/rules.js +26 -0
  51. package/node_modules/ajv/dist/compile/rules.js.map +1 -0
  52. package/node_modules/ajv/dist/compile/util.d.ts +40 -0
  53. package/node_modules/ajv/dist/compile/util.js +178 -0
  54. package/node_modules/ajv/dist/compile/util.js.map +1 -0
  55. package/node_modules/ajv/dist/compile/validate/applicability.d.ts +6 -0
  56. package/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
  57. package/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
  58. package/node_modules/ajv/dist/compile/validate/boolSchema.d.ts +4 -0
  59. package/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
  60. package/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
  61. package/node_modules/ajv/dist/compile/validate/dataType.d.ts +17 -0
  62. package/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
  63. package/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
  64. package/node_modules/ajv/dist/compile/validate/defaults.d.ts +2 -0
  65. package/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
  66. package/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
  67. package/node_modules/ajv/dist/compile/validate/index.d.ts +42 -0
  68. package/node_modules/ajv/dist/compile/validate/index.js +520 -0
  69. package/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
  70. package/node_modules/ajv/dist/compile/validate/keyword.d.ts +8 -0
  71. package/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
  72. package/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
  73. package/node_modules/ajv/dist/compile/validate/subschema.d.ts +47 -0
  74. package/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
  75. package/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
  76. package/node_modules/ajv/dist/core.d.ts +174 -0
  77. package/node_modules/ajv/dist/core.js +618 -0
  78. package/node_modules/ajv/dist/core.js.map +1 -0
  79. package/node_modules/ajv/dist/jtd.d.ts +47 -0
  80. package/node_modules/ajv/dist/jtd.js +72 -0
  81. package/node_modules/ajv/dist/jtd.js.map +1 -0
  82. package/node_modules/ajv/dist/refs/data.json +13 -0
  83. package/node_modules/ajv/dist/refs/json-schema-2019-09/index.d.ts +2 -0
  84. package/node_modules/ajv/dist/refs/json-schema-2019-09/index.js +28 -0
  85. package/node_modules/ajv/dist/refs/json-schema-2019-09/index.js.map +1 -0
  86. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/applicator.json +53 -0
  87. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/content.json +17 -0
  88. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/core.json +57 -0
  89. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/format.json +14 -0
  90. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/meta-data.json +37 -0
  91. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json +90 -0
  92. package/node_modules/ajv/dist/refs/json-schema-2019-09/schema.json +39 -0
  93. package/node_modules/ajv/dist/refs/json-schema-2020-12/index.d.ts +2 -0
  94. package/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +30 -0
  95. package/node_modules/ajv/dist/refs/json-schema-2020-12/index.js.map +1 -0
  96. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.json +48 -0
  97. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.json +17 -0
  98. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.json +51 -0
  99. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.json +14 -0
  100. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.json +37 -0
  101. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.json +15 -0
  102. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json +90 -0
  103. package/node_modules/ajv/dist/refs/json-schema-2020-12/schema.json +55 -0
  104. package/node_modules/ajv/dist/refs/json-schema-draft-06.json +137 -0
  105. package/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
  106. package/node_modules/ajv/dist/refs/json-schema-secure.json +88 -0
  107. package/node_modules/ajv/dist/refs/jtd-schema.d.ts +3 -0
  108. package/node_modules/ajv/dist/refs/jtd-schema.js +118 -0
  109. package/node_modules/ajv/dist/refs/jtd-schema.js.map +1 -0
  110. package/node_modules/ajv/dist/runtime/equal.d.ts +6 -0
  111. package/node_modules/ajv/dist/runtime/equal.js +7 -0
  112. package/node_modules/ajv/dist/runtime/equal.js.map +1 -0
  113. package/node_modules/ajv/dist/runtime/parseJson.d.ts +18 -0
  114. package/node_modules/ajv/dist/runtime/parseJson.js +185 -0
  115. package/node_modules/ajv/dist/runtime/parseJson.js.map +1 -0
  116. package/node_modules/ajv/dist/runtime/quote.d.ts +5 -0
  117. package/node_modules/ajv/dist/runtime/quote.js +30 -0
  118. package/node_modules/ajv/dist/runtime/quote.js.map +1 -0
  119. package/node_modules/ajv/dist/runtime/re2.d.ts +6 -0
  120. package/node_modules/ajv/dist/runtime/re2.js +6 -0
  121. package/node_modules/ajv/dist/runtime/re2.js.map +1 -0
  122. package/node_modules/ajv/dist/runtime/timestamp.d.ts +5 -0
  123. package/node_modules/ajv/dist/runtime/timestamp.js +42 -0
  124. package/node_modules/ajv/dist/runtime/timestamp.js.map +1 -0
  125. package/node_modules/ajv/dist/runtime/ucs2length.d.ts +5 -0
  126. package/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
  127. package/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
  128. package/node_modules/ajv/dist/runtime/uri.d.ts +6 -0
  129. package/node_modules/ajv/dist/runtime/uri.js +6 -0
  130. package/node_modules/ajv/dist/runtime/uri.js.map +1 -0
  131. package/node_modules/ajv/dist/runtime/validation_error.d.ts +7 -0
  132. package/node_modules/ajv/dist/runtime/validation_error.js +11 -0
  133. package/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
  134. package/node_modules/ajv/dist/standalone/index.d.ts +6 -0
  135. package/node_modules/ajv/dist/standalone/index.js +90 -0
  136. package/node_modules/ajv/dist/standalone/index.js.map +1 -0
  137. package/node_modules/ajv/dist/standalone/instance.d.ts +12 -0
  138. package/node_modules/ajv/dist/standalone/instance.js +35 -0
  139. package/node_modules/ajv/dist/standalone/instance.js.map +1 -0
  140. package/node_modules/ajv/dist/types/index.d.ts +183 -0
  141. package/node_modules/ajv/dist/types/index.js +3 -0
  142. package/node_modules/ajv/dist/types/index.js.map +1 -0
  143. package/node_modules/ajv/dist/types/json-schema.d.ts +125 -0
  144. package/node_modules/ajv/dist/types/json-schema.js +3 -0
  145. package/node_modules/ajv/dist/types/json-schema.js.map +1 -0
  146. package/node_modules/ajv/dist/types/jtd-schema.d.ts +174 -0
  147. package/node_modules/ajv/dist/types/jtd-schema.js +3 -0
  148. package/node_modules/ajv/dist/types/jtd-schema.js.map +1 -0
  149. package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.d.ts +8 -0
  150. package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
  151. package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
  152. package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.d.ts +6 -0
  153. package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
  154. package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
  155. package/node_modules/ajv/dist/vocabularies/applicator/allOf.d.ts +3 -0
  156. package/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
  157. package/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
  158. package/node_modules/ajv/dist/vocabularies/applicator/anyOf.d.ts +4 -0
  159. package/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
  160. package/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
  161. package/node_modules/ajv/dist/vocabularies/applicator/contains.d.ts +7 -0
  162. package/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
  163. package/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
  164. package/node_modules/ajv/dist/vocabularies/applicator/dependencies.d.ts +21 -0
  165. package/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
  166. package/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
  167. package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.d.ts +3 -0
  168. package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +11 -0
  169. package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js.map +1 -0
  170. package/node_modules/ajv/dist/vocabularies/applicator/if.d.ts +6 -0
  171. package/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
  172. package/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
  173. package/node_modules/ajv/dist/vocabularies/applicator/index.d.ts +13 -0
  174. package/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
  175. package/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
  176. package/node_modules/ajv/dist/vocabularies/applicator/items.d.ts +5 -0
  177. package/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
  178. package/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
  179. package/node_modules/ajv/dist/vocabularies/applicator/items2020.d.ts +6 -0
  180. package/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
  181. package/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
  182. package/node_modules/ajv/dist/vocabularies/applicator/not.d.ts +4 -0
  183. package/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
  184. package/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
  185. package/node_modules/ajv/dist/vocabularies/applicator/oneOf.d.ts +6 -0
  186. package/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
  187. package/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
  188. package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.d.ts +3 -0
  189. package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
  190. package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
  191. package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.d.ts +3 -0
  192. package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
  193. package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
  194. package/node_modules/ajv/dist/vocabularies/applicator/properties.d.ts +3 -0
  195. package/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
  196. package/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
  197. package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.d.ts +6 -0
  198. package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
  199. package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
  200. package/node_modules/ajv/dist/vocabularies/applicator/thenElse.d.ts +3 -0
  201. package/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
  202. package/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
  203. package/node_modules/ajv/dist/vocabularies/code.d.ts +17 -0
  204. package/node_modules/ajv/dist/vocabularies/code.js +131 -0
  205. package/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
  206. package/node_modules/ajv/dist/vocabularies/core/id.d.ts +3 -0
  207. package/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
  208. package/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
  209. package/node_modules/ajv/dist/vocabularies/core/index.d.ts +3 -0
  210. package/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
  211. package/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
  212. package/node_modules/ajv/dist/vocabularies/core/ref.d.ts +8 -0
  213. package/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
  214. package/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
  215. package/node_modules/ajv/dist/vocabularies/discriminator/index.d.ts +5 -0
  216. package/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
  217. package/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
  218. package/node_modules/ajv/dist/vocabularies/discriminator/types.d.ts +10 -0
  219. package/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
  220. package/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
  221. package/node_modules/ajv/dist/vocabularies/draft2020.d.ts +3 -0
  222. package/node_modules/ajv/dist/vocabularies/draft2020.js +23 -0
  223. package/node_modules/ajv/dist/vocabularies/draft2020.js.map +1 -0
  224. package/node_modules/ajv/dist/vocabularies/draft7.d.ts +3 -0
  225. package/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
  226. package/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
  227. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.d.ts +5 -0
  228. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +30 -0
  229. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js.map +1 -0
  230. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.d.ts +5 -0
  231. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +51 -0
  232. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js.map +1 -0
  233. package/node_modules/ajv/dist/vocabularies/dynamic/index.d.ts +3 -0
  234. package/node_modules/ajv/dist/vocabularies/dynamic/index.js +9 -0
  235. package/node_modules/ajv/dist/vocabularies/dynamic/index.js.map +1 -0
  236. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.d.ts +3 -0
  237. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +16 -0
  238. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js.map +1 -0
  239. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.d.ts +3 -0
  240. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +10 -0
  241. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js.map +1 -0
  242. package/node_modules/ajv/dist/vocabularies/errors.d.ts +9 -0
  243. package/node_modules/ajv/dist/vocabularies/errors.js +3 -0
  244. package/node_modules/ajv/dist/vocabularies/errors.js.map +1 -0
  245. package/node_modules/ajv/dist/vocabularies/format/format.d.ts +8 -0
  246. package/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
  247. package/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
  248. package/node_modules/ajv/dist/vocabularies/format/index.d.ts +3 -0
  249. package/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
  250. package/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
  251. package/node_modules/ajv/dist/vocabularies/jtd/discriminator.d.ts +6 -0
  252. package/node_modules/ajv/dist/vocabularies/jtd/discriminator.js +71 -0
  253. package/node_modules/ajv/dist/vocabularies/jtd/discriminator.js.map +1 -0
  254. package/node_modules/ajv/dist/vocabularies/jtd/elements.d.ts +5 -0
  255. package/node_modules/ajv/dist/vocabularies/jtd/elements.js +24 -0
  256. package/node_modules/ajv/dist/vocabularies/jtd/elements.js.map +1 -0
  257. package/node_modules/ajv/dist/vocabularies/jtd/enum.d.ts +6 -0
  258. package/node_modules/ajv/dist/vocabularies/jtd/enum.js +43 -0
  259. package/node_modules/ajv/dist/vocabularies/jtd/enum.js.map +1 -0
  260. package/node_modules/ajv/dist/vocabularies/jtd/error.d.ts +9 -0
  261. package/node_modules/ajv/dist/vocabularies/jtd/error.js +20 -0
  262. package/node_modules/ajv/dist/vocabularies/jtd/error.js.map +1 -0
  263. package/node_modules/ajv/dist/vocabularies/jtd/index.d.ts +10 -0
  264. package/node_modules/ajv/dist/vocabularies/jtd/index.js +29 -0
  265. package/node_modules/ajv/dist/vocabularies/jtd/index.js.map +1 -0
  266. package/node_modules/ajv/dist/vocabularies/jtd/metadata.d.ts +5 -0
  267. package/node_modules/ajv/dist/vocabularies/jtd/metadata.js +25 -0
  268. package/node_modules/ajv/dist/vocabularies/jtd/metadata.js.map +1 -0
  269. package/node_modules/ajv/dist/vocabularies/jtd/nullable.d.ts +4 -0
  270. package/node_modules/ajv/dist/vocabularies/jtd/nullable.js +22 -0
  271. package/node_modules/ajv/dist/vocabularies/jtd/nullable.js.map +1 -0
  272. package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.d.ts +3 -0
  273. package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js +15 -0
  274. package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js.map +1 -0
  275. package/node_modules/ajv/dist/vocabularies/jtd/properties.d.ts +22 -0
  276. package/node_modules/ajv/dist/vocabularies/jtd/properties.js +149 -0
  277. package/node_modules/ajv/dist/vocabularies/jtd/properties.js.map +1 -0
  278. package/node_modules/ajv/dist/vocabularies/jtd/ref.d.ts +4 -0
  279. package/node_modules/ajv/dist/vocabularies/jtd/ref.js +67 -0
  280. package/node_modules/ajv/dist/vocabularies/jtd/ref.js.map +1 -0
  281. package/node_modules/ajv/dist/vocabularies/jtd/type.d.ts +10 -0
  282. package/node_modules/ajv/dist/vocabularies/jtd/type.js +69 -0
  283. package/node_modules/ajv/dist/vocabularies/jtd/type.js.map +1 -0
  284. package/node_modules/ajv/dist/vocabularies/jtd/union.d.ts +3 -0
  285. package/node_modules/ajv/dist/vocabularies/jtd/union.js +12 -0
  286. package/node_modules/ajv/dist/vocabularies/jtd/union.js.map +1 -0
  287. package/node_modules/ajv/dist/vocabularies/jtd/values.d.ts +5 -0
  288. package/node_modules/ajv/dist/vocabularies/jtd/values.js +51 -0
  289. package/node_modules/ajv/dist/vocabularies/jtd/values.js.map +1 -0
  290. package/node_modules/ajv/dist/vocabularies/metadata.d.ts +3 -0
  291. package/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
  292. package/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
  293. package/node_modules/ajv/dist/vocabularies/next.d.ts +3 -0
  294. package/node_modules/ajv/dist/vocabularies/next.js +8 -0
  295. package/node_modules/ajv/dist/vocabularies/next.js.map +1 -0
  296. package/node_modules/ajv/dist/vocabularies/unevaluated/index.d.ts +3 -0
  297. package/node_modules/ajv/dist/vocabularies/unevaluated/index.js +7 -0
  298. package/node_modules/ajv/dist/vocabularies/unevaluated/index.js.map +1 -0
  299. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.d.ts +6 -0
  300. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +40 -0
  301. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js.map +1 -0
  302. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.d.ts +6 -0
  303. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +65 -0
  304. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js.map +1 -0
  305. package/node_modules/ajv/dist/vocabularies/validation/const.d.ts +6 -0
  306. package/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
  307. package/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
  308. package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.d.ts +5 -0
  309. package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +12 -0
  310. package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js.map +1 -0
  311. package/node_modules/ajv/dist/vocabularies/validation/enum.d.ts +8 -0
  312. package/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
  313. package/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
  314. package/node_modules/ajv/dist/vocabularies/validation/index.d.ts +16 -0
  315. package/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
  316. package/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
  317. package/node_modules/ajv/dist/vocabularies/validation/limitContains.d.ts +3 -0
  318. package/node_modules/ajv/dist/vocabularies/validation/limitContains.js +15 -0
  319. package/node_modules/ajv/dist/vocabularies/validation/limitContains.js.map +1 -0
  320. package/node_modules/ajv/dist/vocabularies/validation/limitItems.d.ts +3 -0
  321. package/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
  322. package/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
  323. package/node_modules/ajv/dist/vocabularies/validation/limitLength.d.ts +3 -0
  324. package/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
  325. package/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
  326. package/node_modules/ajv/dist/vocabularies/validation/limitNumber.d.ts +11 -0
  327. package/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
  328. package/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
  329. package/node_modules/ajv/dist/vocabularies/validation/limitProperties.d.ts +3 -0
  330. package/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
  331. package/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
  332. package/node_modules/ajv/dist/vocabularies/validation/multipleOf.d.ts +8 -0
  333. package/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
  334. package/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
  335. package/node_modules/ajv/dist/vocabularies/validation/pattern.d.ts +8 -0
  336. package/node_modules/ajv/dist/vocabularies/validation/pattern.js +33 -0
  337. package/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
  338. package/node_modules/ajv/dist/vocabularies/validation/required.d.ts +8 -0
  339. package/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
  340. package/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
  341. package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.d.ts +9 -0
  342. package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
  343. package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
  344. package/node_modules/ajv/lib/2019.ts +81 -0
  345. package/node_modules/ajv/lib/2020.ts +75 -0
  346. package/node_modules/ajv/lib/ajv.ts +70 -0
  347. package/node_modules/ajv/lib/compile/codegen/code.ts +169 -0
  348. package/node_modules/ajv/lib/compile/codegen/index.ts +852 -0
  349. package/node_modules/ajv/lib/compile/codegen/scope.ts +215 -0
  350. package/node_modules/ajv/lib/compile/errors.ts +184 -0
  351. package/node_modules/ajv/lib/compile/index.ts +324 -0
  352. package/node_modules/ajv/lib/compile/jtd/parse.ts +411 -0
  353. package/node_modules/ajv/lib/compile/jtd/serialize.ts +277 -0
  354. package/node_modules/ajv/lib/compile/jtd/types.ts +16 -0
  355. package/node_modules/ajv/lib/compile/names.ts +27 -0
  356. package/node_modules/ajv/lib/compile/ref_error.ts +13 -0
  357. package/node_modules/ajv/lib/compile/resolve.ts +149 -0
  358. package/node_modules/ajv/lib/compile/rules.ts +50 -0
  359. package/node_modules/ajv/lib/compile/util.ts +213 -0
  360. package/node_modules/ajv/lib/compile/validate/applicability.ts +22 -0
  361. package/node_modules/ajv/lib/compile/validate/boolSchema.ts +47 -0
  362. package/node_modules/ajv/lib/compile/validate/dataType.ts +230 -0
  363. package/node_modules/ajv/lib/compile/validate/defaults.ts +32 -0
  364. package/node_modules/ajv/lib/compile/validate/index.ts +582 -0
  365. package/node_modules/ajv/lib/compile/validate/keyword.ts +171 -0
  366. package/node_modules/ajv/lib/compile/validate/subschema.ts +135 -0
  367. package/node_modules/ajv/lib/core.ts +892 -0
  368. package/node_modules/ajv/lib/jtd.ts +132 -0
  369. package/node_modules/ajv/lib/refs/data.json +13 -0
  370. package/node_modules/ajv/lib/refs/json-schema-2019-09/index.ts +28 -0
  371. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/applicator.json +53 -0
  372. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/content.json +17 -0
  373. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/core.json +57 -0
  374. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/format.json +14 -0
  375. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/meta-data.json +37 -0
  376. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/validation.json +90 -0
  377. package/node_modules/ajv/lib/refs/json-schema-2019-09/schema.json +39 -0
  378. package/node_modules/ajv/lib/refs/json-schema-2020-12/index.ts +30 -0
  379. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/applicator.json +48 -0
  380. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/content.json +17 -0
  381. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/core.json +51 -0
  382. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/format-annotation.json +14 -0
  383. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/meta-data.json +37 -0
  384. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/unevaluated.json +15 -0
  385. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/validation.json +90 -0
  386. package/node_modules/ajv/lib/refs/json-schema-2020-12/schema.json +55 -0
  387. package/node_modules/ajv/lib/refs/json-schema-draft-06.json +137 -0
  388. package/node_modules/ajv/lib/refs/json-schema-draft-07.json +151 -0
  389. package/node_modules/ajv/lib/refs/json-schema-secure.json +88 -0
  390. package/node_modules/ajv/lib/refs/jtd-schema.ts +130 -0
  391. package/node_modules/ajv/lib/runtime/equal.ts +7 -0
  392. package/node_modules/ajv/lib/runtime/parseJson.ts +177 -0
  393. package/node_modules/ajv/lib/runtime/quote.ts +31 -0
  394. package/node_modules/ajv/lib/runtime/re2.ts +6 -0
  395. package/node_modules/ajv/lib/runtime/timestamp.ts +46 -0
  396. package/node_modules/ajv/lib/runtime/ucs2length.ts +20 -0
  397. package/node_modules/ajv/lib/runtime/uri.ts +6 -0
  398. package/node_modules/ajv/lib/runtime/validation_error.ts +13 -0
  399. package/node_modules/ajv/lib/standalone/index.ts +100 -0
  400. package/node_modules/ajv/lib/standalone/instance.ts +36 -0
  401. package/node_modules/ajv/lib/types/index.ts +244 -0
  402. package/node_modules/ajv/lib/types/json-schema.ts +187 -0
  403. package/node_modules/ajv/lib/types/jtd-schema.ts +273 -0
  404. package/node_modules/ajv/lib/vocabularies/applicator/additionalItems.ts +56 -0
  405. package/node_modules/ajv/lib/vocabularies/applicator/additionalProperties.ts +118 -0
  406. package/node_modules/ajv/lib/vocabularies/applicator/allOf.ts +22 -0
  407. package/node_modules/ajv/lib/vocabularies/applicator/anyOf.ts +14 -0
  408. package/node_modules/ajv/lib/vocabularies/applicator/contains.ts +109 -0
  409. package/node_modules/ajv/lib/vocabularies/applicator/dependencies.ts +112 -0
  410. package/node_modules/ajv/lib/vocabularies/applicator/dependentSchemas.ts +11 -0
  411. package/node_modules/ajv/lib/vocabularies/applicator/if.ts +80 -0
  412. package/node_modules/ajv/lib/vocabularies/applicator/index.ts +53 -0
  413. package/node_modules/ajv/lib/vocabularies/applicator/items.ts +59 -0
  414. package/node_modules/ajv/lib/vocabularies/applicator/items2020.ts +36 -0
  415. package/node_modules/ajv/lib/vocabularies/applicator/not.ts +38 -0
  416. package/node_modules/ajv/lib/vocabularies/applicator/oneOf.ts +82 -0
  417. package/node_modules/ajv/lib/vocabularies/applicator/patternProperties.ts +91 -0
  418. package/node_modules/ajv/lib/vocabularies/applicator/prefixItems.ts +12 -0
  419. package/node_modules/ajv/lib/vocabularies/applicator/properties.ts +57 -0
  420. package/node_modules/ajv/lib/vocabularies/applicator/propertyNames.ts +50 -0
  421. package/node_modules/ajv/lib/vocabularies/applicator/thenElse.ts +13 -0
  422. package/node_modules/ajv/lib/vocabularies/code.ts +168 -0
  423. package/node_modules/ajv/lib/vocabularies/core/id.ts +10 -0
  424. package/node_modules/ajv/lib/vocabularies/core/index.ts +16 -0
  425. package/node_modules/ajv/lib/vocabularies/core/ref.ts +129 -0
  426. package/node_modules/ajv/lib/vocabularies/discriminator/index.ts +113 -0
  427. package/node_modules/ajv/lib/vocabularies/discriminator/types.ts +12 -0
  428. package/node_modules/ajv/lib/vocabularies/draft2020.ts +23 -0
  429. package/node_modules/ajv/lib/vocabularies/draft7.ts +17 -0
  430. package/node_modules/ajv/lib/vocabularies/dynamic/dynamicAnchor.ts +31 -0
  431. package/node_modules/ajv/lib/vocabularies/dynamic/dynamicRef.ts +51 -0
  432. package/node_modules/ajv/lib/vocabularies/dynamic/index.ts +9 -0
  433. package/node_modules/ajv/lib/vocabularies/dynamic/recursiveAnchor.ts +14 -0
  434. package/node_modules/ajv/lib/vocabularies/dynamic/recursiveRef.ts +10 -0
  435. package/node_modules/ajv/lib/vocabularies/errors.ts +18 -0
  436. package/node_modules/ajv/lib/vocabularies/format/format.ts +120 -0
  437. package/node_modules/ajv/lib/vocabularies/format/index.ts +6 -0
  438. package/node_modules/ajv/lib/vocabularies/jtd/discriminator.ts +89 -0
  439. package/node_modules/ajv/lib/vocabularies/jtd/elements.ts +32 -0
  440. package/node_modules/ajv/lib/vocabularies/jtd/enum.ts +45 -0
  441. package/node_modules/ajv/lib/vocabularies/jtd/error.ts +23 -0
  442. package/node_modules/ajv/lib/vocabularies/jtd/index.ts +37 -0
  443. package/node_modules/ajv/lib/vocabularies/jtd/metadata.ts +24 -0
  444. package/node_modules/ajv/lib/vocabularies/jtd/nullable.ts +21 -0
  445. package/node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts +15 -0
  446. package/node_modules/ajv/lib/vocabularies/jtd/properties.ts +184 -0
  447. package/node_modules/ajv/lib/vocabularies/jtd/ref.ts +76 -0
  448. package/node_modules/ajv/lib/vocabularies/jtd/type.ts +75 -0
  449. package/node_modules/ajv/lib/vocabularies/jtd/union.ts +12 -0
  450. package/node_modules/ajv/lib/vocabularies/jtd/values.ts +58 -0
  451. package/node_modules/ajv/lib/vocabularies/metadata.ts +17 -0
  452. package/node_modules/ajv/lib/vocabularies/next.ts +8 -0
  453. package/node_modules/ajv/lib/vocabularies/unevaluated/index.ts +7 -0
  454. package/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts +47 -0
  455. package/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts +85 -0
  456. package/node_modules/ajv/lib/vocabularies/validation/const.ts +28 -0
  457. package/node_modules/ajv/lib/vocabularies/validation/dependentRequired.ts +23 -0
  458. package/node_modules/ajv/lib/vocabularies/validation/enum.ts +54 -0
  459. package/node_modules/ajv/lib/vocabularies/validation/index.ts +49 -0
  460. package/node_modules/ajv/lib/vocabularies/validation/limitContains.ts +16 -0
  461. package/node_modules/ajv/lib/vocabularies/validation/limitItems.ts +26 -0
  462. package/node_modules/ajv/lib/vocabularies/validation/limitLength.ts +30 -0
  463. package/node_modules/ajv/lib/vocabularies/validation/limitNumber.ts +42 -0
  464. package/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts +26 -0
  465. package/node_modules/ajv/lib/vocabularies/validation/multipleOf.ts +34 -0
  466. package/node_modules/ajv/lib/vocabularies/validation/pattern.ts +39 -0
  467. package/node_modules/ajv/lib/vocabularies/validation/required.ts +98 -0
  468. package/node_modules/ajv/lib/vocabularies/validation/uniqueItems.ts +79 -0
  469. package/node_modules/ajv/package.json +126 -0
  470. package/node_modules/fast-deep-equal/LICENSE +21 -0
  471. package/node_modules/fast-deep-equal/README.md +96 -0
  472. package/node_modules/fast-deep-equal/es6/index.d.ts +2 -0
  473. package/node_modules/fast-deep-equal/es6/index.js +72 -0
  474. package/node_modules/fast-deep-equal/es6/react.d.ts +2 -0
  475. package/node_modules/fast-deep-equal/es6/react.js +79 -0
  476. package/node_modules/fast-deep-equal/index.d.ts +4 -0
  477. package/node_modules/fast-deep-equal/index.js +46 -0
  478. package/node_modules/fast-deep-equal/package.json +61 -0
  479. package/node_modules/fast-deep-equal/react.d.ts +2 -0
  480. package/node_modules/fast-deep-equal/react.js +53 -0
  481. package/node_modules/fast-uri/.gitattributes +2 -0
  482. package/node_modules/fast-uri/.github/dependabot.yml +13 -0
  483. package/node_modules/fast-uri/.github/workflows/ci.yml +106 -0
  484. package/node_modules/fast-uri/.github/workflows/lock-threads.yml +19 -0
  485. package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +24 -0
  486. package/node_modules/fast-uri/LICENSE +30 -0
  487. package/node_modules/fast-uri/README.md +152 -0
  488. package/node_modules/fast-uri/benchmark/benchmark.mjs +159 -0
  489. package/node_modules/fast-uri/benchmark/equal.mjs +51 -0
  490. package/node_modules/fast-uri/benchmark/non-simple-domain.mjs +22 -0
  491. package/node_modules/fast-uri/benchmark/package.json +17 -0
  492. package/node_modules/fast-uri/benchmark/string-array-to-hex-stripped.mjs +24 -0
  493. package/node_modules/fast-uri/benchmark/ws-is-secure.mjs +65 -0
  494. package/node_modules/fast-uri/eslint.config.js +6 -0
  495. package/node_modules/fast-uri/index.js +627 -0
  496. package/node_modules/fast-uri/lib/schemes.js +272 -0
  497. package/node_modules/fast-uri/lib/utils.js +747 -0
  498. package/node_modules/fast-uri/package.json +68 -0
  499. package/node_modules/fast-uri/test/ajv.test.js +43 -0
  500. package/node_modules/fast-uri/test/component-safe-serialization.test.js +163 -0
  501. package/node_modules/fast-uri/test/equal.test.js +145 -0
  502. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +503 -0
  503. package/node_modules/fast-uri/test/fixtures/uri-js-serialize.json +120 -0
  504. package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
  505. package/node_modules/fast-uri/test/ipv6-validation.test.js +124 -0
  506. package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
  507. package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
  508. package/node_modules/fast-uri/test/parse.test.js +327 -0
  509. package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
  510. package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
  511. package/node_modules/fast-uri/test/resolve.test.js +87 -0
  512. package/node_modules/fast-uri/test/rfc-3986.test.js +90 -0
  513. package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
  514. package/node_modules/fast-uri/test/security-normalization.test.js +140 -0
  515. package/node_modules/fast-uri/test/security.test.js +431 -0
  516. package/node_modules/fast-uri/test/serialize.test.js +151 -0
  517. package/node_modules/fast-uri/test/uri-js-compatibility.test.js +33 -0
  518. package/node_modules/fast-uri/test/uri-js.test.js +912 -0
  519. package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
  520. package/node_modules/fast-uri/test/util.test.js +38 -0
  521. package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
  522. package/node_modules/fast-uri/tsconfig.json +9 -0
  523. package/node_modules/fast-uri/types/index.d.ts +60 -0
  524. package/node_modules/fast-uri/types/index.test-d.ts +17 -0
  525. package/node_modules/json-schema-traverse/.eslintrc.yml +27 -0
  526. package/node_modules/json-schema-traverse/.github/FUNDING.yml +2 -0
  527. package/node_modules/json-schema-traverse/.github/workflows/build.yml +28 -0
  528. package/node_modules/json-schema-traverse/.github/workflows/publish.yml +27 -0
  529. package/node_modules/json-schema-traverse/LICENSE +21 -0
  530. package/node_modules/json-schema-traverse/README.md +95 -0
  531. package/node_modules/json-schema-traverse/index.d.ts +40 -0
  532. package/node_modules/json-schema-traverse/index.js +93 -0
  533. package/node_modules/json-schema-traverse/package.json +43 -0
  534. package/node_modules/json-schema-traverse/spec/.eslintrc.yml +6 -0
  535. package/node_modules/json-schema-traverse/spec/fixtures/schema.js +125 -0
  536. package/node_modules/json-schema-traverse/spec/index.spec.js +171 -0
  537. package/node_modules/require-from-string/index.js +34 -0
  538. package/node_modules/require-from-string/license +21 -0
  539. package/node_modules/require-from-string/package.json +28 -0
  540. package/node_modules/require-from-string/readme.md +56 -0
  541. package/package.json +33 -4
  542. package/packages/pcr-core/schemas/classification-coverage.schema.json +187 -0
  543. package/packages/pcr-core/schemas/controlled-vocabulary.schema.json +189 -0
  544. package/packages/pcr-core/schemas/dataset-validation-input.schema.json +7 -0
  545. package/packages/pcr-core/schemas/feedback-draft-output.schema.json +12 -0
  546. package/packages/pcr-core/schemas/feedback.schema.json +27 -0
  547. package/packages/pcr-core/schemas/guidance-output.schema.json +97 -0
  548. package/packages/pcr-core/schemas/model-validation-input.schema.json +10 -0
  549. package/packages/pcr-core/schemas/pcr-id-aliases.schema.json +120 -0
  550. package/packages/pcr-core/schemas/readiness.schema.json +100 -0
  551. package/packages/pcr-core/schemas/structured-projection.schema.json +269 -0
  552. package/packages/pcr-core/schemas/validation-output.schema.json +117 -0
  553. package/packages/pcr-core/src/classification-coverage.mjs +732 -0
  554. package/packages/pcr-core/src/contracts.mjs +193 -0
  555. package/packages/pcr-core/src/generated/controlled-vocabulary.mjs +41 -0
  556. package/packages/pcr-core/src/index.mjs +2101 -0
  557. package/packages/pcr-core/src/languages.mjs +86 -0
  558. package/packages/pcr-core/src/offline-library.mjs +121 -0
  559. package/packages/pcr-core/src/output-semantics.mjs +228 -0
  560. package/packages/pcr-core/src/pcr-id-aliases.mjs +949 -0
  561. package/packages/pcr-core/src/projection-completeness.mjs +284 -0
  562. package/packages/pcr-core/src/projection-integrity.mjs +208 -0
  563. package/packages/pcr-core/src/read-context.mjs +505 -0
  564. package/packages/pcr-core/src/schema-validation.mjs +142 -0
  565. package/packages/pcr-core/src/source-context.mjs +13 -0
  566. package/packages/pcr-core/src/yaml-lite.mjs +261 -0
  567. package/packages/tiangong-pcr-cli/bin/tiangong-pcr.mjs +12 -0
  568. package/packages/tiangong-pcr-cli/src/commands.mjs +1486 -0
  569. package/skills/tiangong-pcr/SKILL.md +117 -0
  570. package/skills/tiangong-pcr/references/cli-usage.md +19 -0
  571. package/skills/tiangong-pcr/references/feedback-loop.md +16 -0
  572. package/skills/tiangong-pcr/references/model-authoring-loop.md +13 -0
@@ -0,0 +1,1486 @@
1
+ import { createRequire } from "node:module";
2
+ import { OfflineLibrary } from "../../pcr-core/src/offline-library.mjs";
3
+ import { withPcrSource } from "../../pcr-core/src/source-context.mjs";
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ import {
9
+ CLASSIFICATION_COVERAGE_STATUSES,
10
+ FEEDBACK_TYPES,
11
+ PCR_CATALOG_SCOPES,
12
+ buildGuidance,
13
+ buildPcrTree,
14
+ createFeedbackDraft,
15
+ getClassificationCoverageSummary,
16
+ listClassificationCoverage,
17
+ listPcrs,
18
+ readPcrMarkdown,
19
+ resolveClassification,
20
+ resolvePcrIdentity,
21
+ validateDatasetAgainstGuidance,
22
+ validateModelAgainstGuidance,
23
+ } from "../../pcr-core/src/index.mjs";
24
+ import {
25
+ CONTENT_MATURITY_VALUES,
26
+ PCR_STATUS_VALUES,
27
+ } from "../../pcr-core/src/generated/controlled-vocabulary.mjs";
28
+
29
+ const defaultRoot = path.resolve(fileURLToPath(new URL("../../..", import.meta.url)));
30
+ const VALID_FAIL_ON = new Set(["never", "error", "warning"]);
31
+ const VALID_LANGUAGES = new Set(["en-US", "zh-CN"]);
32
+ const VALID_PCR_STATUSES = new Set(PCR_STATUS_VALUES);
33
+ const VALID_CONTENT_MATURITIES = new Set(CONTENT_MATURITY_VALUES);
34
+ const VALID_CATALOG_SCOPES = new Set(PCR_CATALOG_SCOPES);
35
+ const VALID_COVERAGE_STATUSES = new Set(CLASSIFICATION_COVERAGE_STATUSES);
36
+ const GLOBAL_OPTIONS = new Set(["root", "library", "library-sha256", "format", "help"]);
37
+ const GLOBAL_HELP_OPTIONS = new Set(["root", "library", "library-sha256", "help"]);
38
+ const COMMAND_OPTIONS = {
39
+ library: new Set(),
40
+ "library:info": new Set(),
41
+ "library:verify": new Set(),
42
+ list: new Set(["status", "content-maturity", "path-prefix", "scope", "page", "page-size"]),
43
+ tree: new Set(["depth", "scope"]),
44
+ coverage: new Set(),
45
+ "coverage:summary": new Set(["classification"]),
46
+ "coverage:list": new Set(["classification", "status", "page", "page-size"]),
47
+ resolve: new Set(["classification", "pcr"]),
48
+ show: new Set(["pcr", "lang"]),
49
+ guidance: new Set(["pcr"]),
50
+ "validate-model": new Set(["pcr", "input", "fail-on"]),
51
+ "validate-dataset": new Set(["pcr", "input", "fail-on"]),
52
+ "feedback:draft": new Set([
53
+ "pcr",
54
+ "type",
55
+ "affected-section",
56
+ "process-id",
57
+ "flow-role",
58
+ "summary",
59
+ "evidence",
60
+ "proposed-change",
61
+ ]),
62
+ };
63
+ const COMMAND_DEFINITIONS = [
64
+ { key: "library", command: "library", formats: ["json"], defaultFormat: "json" },
65
+ { key: "library:info", command: "library", positional: ["info"], formats: ["json"], defaultFormat: "json" },
66
+ { key: "library:verify", command: "library", positional: ["verify"], formats: ["json"], defaultFormat: "json" },
67
+ { key: "list", command: "list", formats: ["json", "markdown", "table"], defaultFormat: "table" },
68
+ { key: "tree", command: "tree", formats: ["json", "markdown"], defaultFormat: "markdown" },
69
+ { key: "coverage", command: "coverage", formats: ["json", "table"], defaultFormat: "table" },
70
+ {
71
+ key: "coverage:summary",
72
+ command: "coverage",
73
+ positional: ["summary"],
74
+ formats: ["json", "table"],
75
+ defaultFormat: "table",
76
+ },
77
+ {
78
+ key: "coverage:list",
79
+ command: "coverage",
80
+ positional: ["list"],
81
+ formats: ["json", "table"],
82
+ defaultFormat: "table",
83
+ },
84
+ { key: "resolve", command: "resolve", formats: ["json"], defaultFormat: "json" },
85
+ { key: "show", command: "show", formats: ["markdown"], defaultFormat: "markdown" },
86
+ { key: "guidance", command: "guidance", formats: ["json"], defaultFormat: "json" },
87
+ { key: "validate-model", command: "validate-model", formats: ["json"], defaultFormat: "json" },
88
+ { key: "validate-dataset", command: "validate-dataset", formats: ["json"], defaultFormat: "json" },
89
+ {
90
+ key: "feedback:draft",
91
+ command: "feedback",
92
+ positional: ["draft"],
93
+ formats: ["json", "markdown"],
94
+ defaultFormat: "markdown",
95
+ },
96
+ ];
97
+
98
+ export class CliError extends Error {
99
+ constructor(code, message, details = undefined) {
100
+ super(message);
101
+ this.name = "CliError";
102
+ this.code = code;
103
+ this.details = details === undefined ? undefined : structuredClone(details);
104
+ }
105
+ }
106
+
107
+ function installedLibrary() {
108
+ for (const filename of [path.join(process.cwd(), "package.json"), import.meta.url]) {
109
+ try { return path.join(path.dirname(createRequire(filename).resolve("@tiangong-lca/pcr-library/package.json")), "library.sqlite"); } catch {}
110
+ }
111
+ return null;
112
+ }
113
+
114
+ function toolVersion() {
115
+ const developmentManifest = fileURLToPath(new URL("../package.json", import.meta.url));
116
+ const filename = existsSync(developmentManifest) ? developmentManifest : path.join(defaultRoot, "package.json");
117
+ return JSON.parse(readFileSync(filename, "utf8")).version;
118
+ }
119
+
120
+ export function runTiangongPcr(argv) {
121
+ let library;
122
+ try {
123
+ if (argv.length === 1 && argv[0] === "--version") return ok(`${toolVersion()}\n`);
124
+ const { command, positional, options } = parseArgs(argv);
125
+ if (!command || command === "help" || options.help) return runCommand(argv);
126
+ if (command === "library" && positional.length === 0) throw new CliError("PCR_CLI_MISSING_SUBCOMMAND", "Use library info or library verify with --library <file>.");
127
+ if (options.root && options.library) throw new CliError("PCR_CLI_SOURCE_CONFLICT", "Choose either --root or --library.");
128
+ const filename = options.library ?? (options.root ? null : process.env.PCR_LIBRARY ?? (existsSync(path.join(defaultRoot, "library/catalog.yaml")) ? null : installedLibrary()));
129
+ if (!filename) {
130
+ if (options["library-sha256"] || command === "library") throw new CliError("PCR_LIBRARY_REQUIRED", "Select a local snapshot with --library <library.sqlite>.");
131
+ if (!options.root && !existsSync(path.join(defaultRoot, "library/catalog.yaml"))) throw new CliError("PCR_LIBRARY_REQUIRED", "No offline library found. Install @tiangong-lca/pcr-library or pass --library <library.sqlite>.");
132
+ return runCommand(argv);
133
+ }
134
+ // Validate the command before opening a potentially large data file.
135
+ const definition = requireCommandDefinition(command, positional);
136
+ validateCommandOptions(definition, options);
137
+ validateCommandFormat(definition, options.format);
138
+ library = new OfflineLibrary(String(filename), { expectedSha256: options["library-sha256"] ?? null, verify: command === "library" && positional[0] === "verify" });
139
+ if (command === "library") return ok(`${JSON.stringify({ tool_version: toolVersion(), ...library.manifest, verified: positional[0] === "verify" || Boolean(options["library-sha256"]) }, null, 2)}\n`);
140
+ return withPcrSource(library.root, library, () => runCommand(argv, { root: library.root, library: path.resolve(filename), "library-sha256": options["library-sha256"] }));
141
+ } catch (error) {
142
+ return fail(error, requestedFormatFromArgv(argv), requestedRootFromArgv(argv));
143
+ } finally { library?.close(); }
144
+ }
145
+
146
+ function runCommand(argv, selected = null) {
147
+ const requestedFormat = requestedFormatFromArgv(argv);
148
+ const requestedRoot = requestedRootFromArgv(argv);
149
+ try {
150
+ const { command, positional, options } = parseArgs(argv);
151
+
152
+ if (command === "help" || !command) {
153
+ validateHelpInvocation({ command, positional, options });
154
+ return ok(helpText(command, positional));
155
+ }
156
+ const definition = requireCommandDefinition(command, positional);
157
+ validateCommandOptions(definition, options);
158
+ if (options.help) {
159
+ return ok(helpText(command, positional));
160
+ }
161
+
162
+ if (selected) options.library = selected.library;
163
+ const root = selected?.root ?? path.resolve(String(options.root ?? defaultRoot));
164
+ const format = validateCommandFormat(definition, options.format);
165
+
166
+ if (command === "list") {
167
+ validateListOptions(options);
168
+ const scope = effectiveCatalogScope(options);
169
+ const page = paginateList(
170
+ filterPcrs(listPcrs({ root, scope: scope.effective }), options),
171
+ options,
172
+ scope,
173
+ );
174
+ return ok(writeOutput(page, format, formatListTable));
175
+ }
176
+ if (command === "tree") {
177
+ const depth = positiveIntegerOption(options.depth, "depth", 2);
178
+ const scope = effectiveCatalogScope(options);
179
+ const tree = buildPcrTree({ root, depth, scope: scope.effective });
180
+ if (format === "json") {
181
+ return ok(`${JSON.stringify(treeOutput(tree, depth, scope), null, 2)}\n`);
182
+ }
183
+ return ok(`${formatTreeMarkdown(tree, depth, scope)}\n`);
184
+ }
185
+ if (command === "coverage" && positional.length === 0) {
186
+ throw new CliError(
187
+ "PCR_CLI_MISSING_SUBCOMMAND",
188
+ "Missing coverage subcommand. Use `coverage summary --classification <system>:<version>` or `coverage list --classification <system>:<version>`.",
189
+ { command: "coverage", valid_subcommands: ["summary", "list"] },
190
+ );
191
+ }
192
+ if (command === "coverage" && positional[0] === "summary") {
193
+ const classification = parseClassificationSelector(options.classification, {
194
+ includeCode: false,
195
+ });
196
+ const summary = coverageSummaryOutput(
197
+ getClassificationCoverageSummary({ root, ...classification }),
198
+ options,
199
+ );
200
+ return ok(writeOutput(summary, format, formatCoverageSummary));
201
+ }
202
+ if (command === "coverage" && positional[0] === "list") {
203
+ const classification = parseClassificationSelector(options.classification, {
204
+ includeCode: false,
205
+ });
206
+ validateCoverageListOptions(options);
207
+ const result = listClassificationCoverage({
208
+ root,
209
+ ...classification,
210
+ status: options.status === undefined ? null : String(options.status),
211
+ });
212
+ const page = paginateCoverage(result, classification, options);
213
+ return ok(writeOutput(page, format, formatCoverageList));
214
+ }
215
+ if (command === "resolve") {
216
+ validateResolveSelector(options);
217
+ if (options.pcr !== undefined) {
218
+ const resolution = resolvePcrIdentity({ root, pcrId: String(options.pcr) });
219
+ return ok(`${JSON.stringify(resolvePcrIdentityOutput(resolution, options), null, 2)}\n`);
220
+ }
221
+ const classification = parseClassificationSelector(options.classification, {
222
+ includeCode: true,
223
+ });
224
+ const resolution = resolveClassification({ root, ...classification });
225
+ return ok(`${JSON.stringify(resolveOutput(resolution, options), null, 2)}\n`);
226
+ }
227
+ if (command === "show") {
228
+ requireOption(options, "pcr");
229
+ const language = String(options.lang ?? "en-US");
230
+ if (!VALID_LANGUAGES.has(language)) {
231
+ throw invalidChoiceError("lang", language, [...VALID_LANGUAGES]);
232
+ }
233
+ return ok(readPcrMarkdown({ root, pcrId: String(options.pcr), language }));
234
+ }
235
+ if (command === "guidance") {
236
+ requireOption(options, "pcr");
237
+ return ok(writeOutput(buildGuidance({ root, pcrId: String(options.pcr) }), format, JSON.stringify));
238
+ }
239
+ if (command === "validate-model") {
240
+ requireOption(options, "pcr");
241
+ requireOption(options, "input");
242
+ const failOn = validateFailOn(options["fail-on"]);
243
+ const modelText = readInputFile(options.input);
244
+ const report = validateModelAgainstGuidance({ root, pcrId: String(options.pcr), model: modelText });
245
+ return ok(writeOutput(
246
+ report,
247
+ format,
248
+ JSON.stringify,
249
+ ), validationExitCode(report, failOn));
250
+ }
251
+ if (command === "validate-dataset") {
252
+ requireOption(options, "pcr");
253
+ requireOption(options, "input");
254
+ const failOn = validateFailOn(options["fail-on"]);
255
+ const datasetText = readInputFile(options.input);
256
+ const dataset = parseDatasetInput(datasetText);
257
+ const report = validateDatasetAgainstGuidance({ root, pcrId: String(options.pcr), dataset });
258
+ return ok(writeOutput(
259
+ report,
260
+ format,
261
+ JSON.stringify,
262
+ ), validationExitCode(report, failOn));
263
+ }
264
+ if (command === "feedback" && positional[0] === "draft") {
265
+ requireOption(options, "type");
266
+ const feedbackType = String(options.type);
267
+ if (!FEEDBACK_TYPES.includes(feedbackType)) {
268
+ throw invalidChoiceError("type", feedbackType, FEEDBACK_TYPES);
269
+ }
270
+ const draft = createFeedbackDraft({
271
+ root,
272
+ pcrId: options.pcr ? String(options.pcr) : "",
273
+ type: feedbackType,
274
+ affectedSection: String(options["affected-section"] ?? ""),
275
+ processId: String(options["process-id"] ?? ""),
276
+ flowRole: String(options["flow-role"] ?? ""),
277
+ summary: String(options.summary ?? ""),
278
+ evidence: String(options.evidence ?? ""),
279
+ proposedChange: String(options["proposed-change"] ?? ""),
280
+ });
281
+ if (format === "json") {
282
+ return ok(`${JSON.stringify(draft, null, 2)}\n`);
283
+ }
284
+ return ok(`# ${draft.title}\n\n${draft.body}`);
285
+ }
286
+
287
+ throw new CliError(
288
+ "PCR_CLI_UNKNOWN_COMMAND",
289
+ `Unknown command: ${[command, ...positional].filter(Boolean).join(" ")}`,
290
+ );
291
+ } catch (error) {
292
+ return fail(error, requestedFormat, requestedRoot, selected);
293
+ }
294
+ }
295
+
296
+ function ok(stdout, exitCode = 0) {
297
+ return { stdout, stderr: "", exitCode };
298
+ }
299
+
300
+ function fail(error, requestedFormat, requestedRoot, selected = null) {
301
+ const normalized = normalizeError(error);
302
+ if (
303
+ normalized.code === "PCR_LEGACY_ID_REDIRECT"
304
+ && normalized.details?.target
305
+ ) {
306
+ const originalNextCommand = normalized.details.next_command;
307
+ const nextCommand = legacyRedirectCommand(
308
+ normalized.details.target,
309
+ { root: requestedRoot, library: selected?.library, "library-sha256": selected?.["library-sha256"] },
310
+ );
311
+ normalized.details.next_command = nextCommand;
312
+ normalized.message = typeof originalNextCommand === "string"
313
+ && normalized.message.includes(originalNextCommand)
314
+ ? normalized.message.replace(originalNextCommand, nextCommand)
315
+ : `${normalized.message} Next: ${nextCommand}`;
316
+ }
317
+ if (requestedFormat === "json") {
318
+ return {
319
+ stdout: "",
320
+ stderr: `${JSON.stringify({ error: { ...normalized, exit_code: 1 } }, null, 2)}\n`,
321
+ exitCode: 1,
322
+ };
323
+ }
324
+ return {
325
+ stdout: "",
326
+ stderr: `[${normalized.code}] ${normalized.message}\n`,
327
+ exitCode: 1,
328
+ };
329
+ }
330
+
331
+ function requestedFormatFromArgv(argv) {
332
+ for (let index = argv.length - 2; index >= 0; index -= 1) {
333
+ if (argv[index] === "--format" && argv[index + 1] === "json") {
334
+ return "json";
335
+ }
336
+ }
337
+ const index = argv.lastIndexOf("--format");
338
+ return index >= 0 && typeof argv[index + 1] === "string" ? argv[index + 1] : null;
339
+ }
340
+
341
+ function requestedRootFromArgv(argv) {
342
+ const index = argv.lastIndexOf("--root");
343
+ const value = index >= 0 ? argv[index + 1] : undefined;
344
+ return typeof value === "string" && !value.startsWith("--") ? value : undefined;
345
+ }
346
+
347
+ function normalizeError(error) {
348
+ const message = error instanceof Error ? error.message : String(error);
349
+ const code = error instanceof CliError || /^PCR_/u.test(String(error?.code ?? ""))
350
+ ? String(error.code)
351
+ : "PCR_CLI_RUNTIME_ERROR";
352
+ const details = coreOrCliErrorDetails(error);
353
+ return details === undefined ? { code, message } : { code, message, details };
354
+ }
355
+
356
+ function coreOrCliErrorDetails(error) {
357
+ if (error instanceof CliError) {
358
+ return error.details;
359
+ }
360
+ if (error?.details !== undefined) {
361
+ return structuredClone(error.details);
362
+ }
363
+ if (error?.readiness !== undefined) {
364
+ return { readiness: structuredClone(error.readiness) };
365
+ }
366
+ if (typeof error?.toJSON === "function") {
367
+ const serialized = error.toJSON();
368
+ if (serialized && typeof serialized === "object") {
369
+ const { code: _code, ...details } = serialized;
370
+ return details;
371
+ }
372
+ }
373
+ if (error?.details && typeof error.details === "object") {
374
+ return structuredClone(error.details);
375
+ }
376
+ return undefined;
377
+ }
378
+
379
+ function commandDefinitionFor(command, positional = []) {
380
+ return COMMAND_DEFINITIONS.find((definition) => {
381
+ if (definition.command !== command) {
382
+ return false;
383
+ }
384
+ const expectedPositionals = definition.positional ?? [];
385
+ return expectedPositionals.length === positional.length
386
+ && expectedPositionals.every((value, index) => positional[index] === value);
387
+ });
388
+ }
389
+
390
+ function requireCommandDefinition(command, positional) {
391
+ const definition = commandDefinitionFor(command, positional);
392
+ if (definition) {
393
+ return definition;
394
+ }
395
+
396
+ if (command === "coverage") {
397
+ const subcommand = positional[0] ?? "";
398
+ if (!["summary", "list"].includes(subcommand)) {
399
+ throw new CliError(
400
+ "PCR_CLI_UNKNOWN_SUBCOMMAND",
401
+ `Unknown coverage subcommand${subcommand ? `: ${subcommand}` : ""}. Use \`coverage summary --classification <system>:<version>\` or \`coverage list --classification <system>:<version>\`.`,
402
+ { command: "coverage", subcommand: subcommand || null, valid_subcommands: ["summary", "list"] },
403
+ );
404
+ }
405
+ throw new CliError(
406
+ "PCR_CLI_UNEXPECTED_POSITIONAL",
407
+ `Unexpected positional argument(s) for coverage ${subcommand}: ${positional.slice(1).join(" ")}`,
408
+ );
409
+ }
410
+
411
+ const commandDefinitions = COMMAND_DEFINITIONS.filter((candidate) => candidate.command === command);
412
+ if (commandDefinitions.length > 0) {
413
+ const expected = commandDefinitions[0].positional ?? [];
414
+ const isExpectedPrefix = expected.every((value, index) => positional[index] === value);
415
+ if (isExpectedPrefix && positional.length > expected.length) {
416
+ throw new CliError(
417
+ "PCR_CLI_UNEXPECTED_POSITIONAL",
418
+ `Unexpected positional argument(s) for ${[command, ...expected].join(" ")}: ${positional.slice(expected.length).join(" ")}`,
419
+ );
420
+ }
421
+ }
422
+ throw new CliError(
423
+ "PCR_CLI_UNKNOWN_COMMAND",
424
+ `Unknown command: ${[command, ...positional].filter(Boolean).join(" ")}`,
425
+ );
426
+ }
427
+
428
+ function validateHelpInvocation({ command, positional, options }) {
429
+ if (command === "help" && positional.length > 0) {
430
+ throw new CliError(
431
+ "PCR_CLI_UNEXPECTED_POSITIONAL",
432
+ `Unexpected positional argument(s) for help: ${positional.join(" ")}`,
433
+ );
434
+ }
435
+ validateOptionsAgainst(options, GLOBAL_HELP_OPTIONS);
436
+ if (!command && options.help !== true && Object.keys(options).length > 0) {
437
+ throw new CliError(
438
+ "PCR_CLI_MISSING_COMMAND",
439
+ "Missing command. Run tiangong-pcr --help to inspect available commands.",
440
+ );
441
+ }
442
+ }
443
+
444
+ function validateCommandOptions(definition, options) {
445
+ const allowed = new Set([...GLOBAL_OPTIONS, ...(COMMAND_OPTIONS[definition.key] ?? [])]);
446
+ validateOptionsAgainst(options, allowed);
447
+ }
448
+
449
+ function validateOptionsAgainst(options, allowed) {
450
+ for (const [key, value] of Object.entries(options)) {
451
+ if (!allowed.has(key)) {
452
+ throw new CliError("PCR_CLI_UNKNOWN_OPTION", `Unknown option --${key}`, { option: key });
453
+ }
454
+ if (key === "help") {
455
+ if (value !== true) {
456
+ throw new CliError(
457
+ "PCR_CLI_INVALID_OPTION",
458
+ "Option --help does not accept a value.",
459
+ { option: key, value },
460
+ );
461
+ }
462
+ continue;
463
+ }
464
+ if (value === true) {
465
+ throw new CliError(
466
+ "PCR_CLI_MISSING_OPTION_VALUE",
467
+ `Option --${key} requires a value.`,
468
+ { option: key },
469
+ );
470
+ }
471
+ }
472
+ }
473
+
474
+ function validateCommandFormat(definition, formatValue) {
475
+ const format = String(formatValue ?? definition.defaultFormat);
476
+ if (!definition.formats.includes(format)) {
477
+ throw invalidChoiceError("format", format, definition.formats, {
478
+ command: [definition.command, ...(definition.positional ?? [])].join(" "),
479
+ });
480
+ }
481
+ return format;
482
+ }
483
+
484
+ function parseArgs(argv) {
485
+ const options = {};
486
+ const positional = [];
487
+ let command = "";
488
+
489
+ for (let index = 0; index < argv.length; index += 1) {
490
+ const token = argv[index];
491
+ if (token.startsWith("--")) {
492
+ const key = token.slice(2);
493
+ if (!key) {
494
+ throw new CliError("PCR_CLI_INVALID_ARGUMENT", "Unexpected bare -- argument.");
495
+ }
496
+ if (Object.hasOwn(options, key)) {
497
+ throw new CliError("PCR_CLI_DUPLICATE_OPTION", `Duplicate option --${key}`, { option: key });
498
+ }
499
+ const next = argv[index + 1];
500
+ if (next === undefined || next.startsWith("--")) {
501
+ options[key] = true;
502
+ continue;
503
+ }
504
+ options[key] = next;
505
+ index += 1;
506
+ continue;
507
+ }
508
+ if (!command) {
509
+ command = token;
510
+ continue;
511
+ }
512
+ positional.push(token);
513
+ }
514
+
515
+ return { command, positional, options };
516
+ }
517
+
518
+ function writeOutput(value, format, tableFormatter) {
519
+ if (format === "json") {
520
+ return `${JSON.stringify(value, null, 2)}\n`;
521
+ }
522
+ if (format === "markdown") {
523
+ return `${tableFormatter(value)}\n`;
524
+ }
525
+ return `${tableFormatter(value)}\n`;
526
+ }
527
+
528
+ function parseDatasetInput(text) {
529
+ try {
530
+ return JSON.parse(text);
531
+ } catch (error) {
532
+ throw new CliError(
533
+ "PCR_CLI_INVALID_DATASET_JSON",
534
+ `Malformed dataset JSON: ${error.message}`,
535
+ );
536
+ }
537
+ }
538
+
539
+ function readInputFile(value) {
540
+ const inputPath = path.resolve(String(value));
541
+ try {
542
+ return readFileSync(inputPath, "utf8");
543
+ } catch (error) {
544
+ throw new CliError(
545
+ "PCR_CLI_INPUT_READ_FAILED",
546
+ `Unable to read --input file ${inputPath}: ${error.message}`,
547
+ { input: inputPath },
548
+ );
549
+ }
550
+ }
551
+
552
+ function parseClassificationSelector(value, { includeCode }) {
553
+ const classification = String(value ?? "");
554
+ const parts = classification.split(":");
555
+ const expectedParts = includeCode ? 3 : 2;
556
+ if (parts.length !== expectedParts || parts.some((part) => part.length === 0)) {
557
+ const expected = includeCode
558
+ ? "<system>:<version>:<code>, for example cpc:3.0:01111"
559
+ : "<system>:<version>, for example cpc:3.0";
560
+ throw new CliError(
561
+ "PCR_CLI_INVALID_CLASSIFICATION",
562
+ `Use --classification ${expected}`,
563
+ { value: classification, expected_segments: expectedParts },
564
+ );
565
+ }
566
+ const [system, version, code] = parts;
567
+ if (
568
+ !/^[A-Za-z0-9][A-Za-z0-9_-]*$/u.test(system)
569
+ || !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(version)
570
+ || (includeCode && !/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(code))
571
+ ) {
572
+ throw new CliError(
573
+ "PCR_CLI_INVALID_CLASSIFICATION",
574
+ `Invalid --classification "${classification}". Use identifier tokens without spaces or path separators.`,
575
+ { value: classification },
576
+ );
577
+ }
578
+ if (includeCode) {
579
+ return { system, version, code };
580
+ }
581
+ return { system, version };
582
+ }
583
+
584
+ function validateResolveSelector(options) {
585
+ const supplied = ["classification", "pcr"].filter(
586
+ (key) => options[key] !== undefined,
587
+ );
588
+ if (supplied.length !== 1) {
589
+ throw new CliError(
590
+ "PCR_CLI_EXACTLY_ONE_SELECTOR_REQUIRED",
591
+ "Resolve requires exactly one selector: --classification <system>:<version>:<code> or --pcr <pcr-id>.",
592
+ {
593
+ required_exactly_one_of: ["classification", "pcr"],
594
+ supplied,
595
+ },
596
+ );
597
+ }
598
+ }
599
+
600
+ function validateListOptions(options) {
601
+ if (options.status !== undefined && !VALID_PCR_STATUSES.has(String(options.status))) {
602
+ throw invalidChoiceError("status", String(options.status), PCR_STATUS_VALUES);
603
+ }
604
+ if (
605
+ options["content-maturity"] !== undefined
606
+ && !VALID_CONTENT_MATURITIES.has(String(options["content-maturity"]))
607
+ ) {
608
+ throw invalidChoiceError(
609
+ "content-maturity",
610
+ String(options["content-maturity"]),
611
+ CONTENT_MATURITY_VALUES,
612
+ );
613
+ }
614
+ if (options["path-prefix"] !== undefined) {
615
+ normalizePathPrefix(options["path-prefix"]);
616
+ }
617
+ validateCatalogScope(options.scope);
618
+ positiveIntegerOption(options.page, "page", 1);
619
+ positiveIntegerOption(options["page-size"], "page-size", 10, 100);
620
+ }
621
+
622
+ function validateCoverageListOptions(options) {
623
+ if (options.status !== undefined && !VALID_COVERAGE_STATUSES.has(String(options.status))) {
624
+ throw invalidChoiceError("status", String(options.status), CLASSIFICATION_COVERAGE_STATUSES, {
625
+ command: "coverage list",
626
+ });
627
+ }
628
+ positiveIntegerOption(options.page, "page", 1);
629
+ positiveIntegerOption(options["page-size"], "page-size", 10, 100);
630
+ }
631
+
632
+ function validateCatalogScope(value) {
633
+ if (value !== undefined && !VALID_CATALOG_SCOPES.has(String(value))) {
634
+ throw invalidChoiceError("scope", String(value), PCR_CATALOG_SCOPES);
635
+ }
636
+ }
637
+
638
+ function effectiveCatalogScope(options) {
639
+ validateCatalogScope(options.scope);
640
+ if (options.scope !== undefined) {
641
+ return {
642
+ requested: String(options.scope),
643
+ effective: String(options.scope),
644
+ source: "explicit",
645
+ };
646
+ }
647
+ if (String(options.status ?? "") === "scaffold") {
648
+ return { requested: null, effective: "legacy", source: "derived_from_status" };
649
+ }
650
+ if (String(options["content-maturity"] ?? "") === "empty_scaffold") {
651
+ return { requested: null, effective: "legacy", source: "derived_from_content_maturity" };
652
+ }
653
+ return { requested: null, effective: "material", source: "default" };
654
+ }
655
+
656
+ function filterPcrs(pcrs, options) {
657
+ let result = pcrs;
658
+ if (options.status) {
659
+ result = result.filter((entry) => entry.status === String(options.status));
660
+ }
661
+ if (options["content-maturity"]) {
662
+ result = result.filter((entry) => entry.content_maturity === String(options["content-maturity"]));
663
+ }
664
+ if (options["path-prefix"]) {
665
+ const prefix = normalizePathPrefix(options["path-prefix"]);
666
+ result = result.filter((entry) => {
667
+ const relativePath = String(entry.path).replace(/^library\/pcrs\/?/u, "");
668
+ return relativePath === prefix || relativePath.startsWith(`${prefix}/`);
669
+ });
670
+ }
671
+ return result;
672
+ }
673
+
674
+ function paginateList(pcrs, options, scope) {
675
+ const pageSize = positiveIntegerOption(options["page-size"], "page-size", 10, 100);
676
+ const page = positiveIntegerOption(options.page, "page", 1);
677
+ const totalCount = pcrs.length;
678
+ const totalPages = Math.max(1, Math.ceil(totalCount / pageSize));
679
+ if (page > totalPages) {
680
+ throw new CliError(
681
+ "PCR_CLI_PAGE_OUT_OF_RANGE",
682
+ `--page ${page} is out of range. Available pages: 1-${totalPages}.`,
683
+ { page, total_pages: totalPages },
684
+ );
685
+ }
686
+ const startIndex = (page - 1) * pageSize;
687
+ const items = pcrs.slice(startIndex, startIndex + pageSize);
688
+ const nextPage = page < totalPages ? page + 1 : null;
689
+ const previousPage = page > 1 ? page - 1 : null;
690
+
691
+ return {
692
+ filters: {
693
+ scope: scope.effective,
694
+ status: options.status ? String(options.status) : null,
695
+ content_maturity: options["content-maturity"]
696
+ ? String(options["content-maturity"])
697
+ : null,
698
+ path_prefix: options["path-prefix"]
699
+ ? normalizePathPrefix(options["path-prefix"])
700
+ : null,
701
+ },
702
+ requested_scope: scope.requested,
703
+ effective_scope: scope.effective,
704
+ scope_source: scope.source,
705
+ page,
706
+ page_size: pageSize,
707
+ total_count: totalCount,
708
+ total_pages: totalPages,
709
+ has_more: nextPage !== null,
710
+ items,
711
+ previous_command: previousPage ? buildListCommand({ ...options, page: previousPage }) : null,
712
+ next_command: nextPage ? buildListCommand({ ...options, page: nextPage }) : null,
713
+ next_steps: [
714
+ "If you have a classification code, prefer npm --silent run tiangong-pcr -- resolve --classification <system>:<version>:<code>.",
715
+ "If the correct PCR is unclear, inspect npm --silent run tiangong-pcr -- tree --depth 3 and then open candidate guidance.",
716
+ "Check items[].readiness and run npm --silent run tiangong-pcr -- guidance --pcr <pcr-id> --format json only when usable_for_guidance is true.",
717
+ ],
718
+ };
719
+ }
720
+
721
+ function coverageSummaryOutput(summary, options) {
722
+ const classification = `${String(summary.classification_system).toLowerCase()}:${summary.classification_version}`;
723
+ return {
724
+ ...summary,
725
+ completeness: {
726
+ status: "complete",
727
+ bounded: true,
728
+ entry_details_included: false,
729
+ },
730
+ next_command: buildCoverageListCommand({
731
+ ...options,
732
+ classification: options.classification ?? classification,
733
+ page: 1,
734
+ }),
735
+ next_steps: [
736
+ "Use coverage list with --status to inspect a bounded, paginated subset.",
737
+ "Use resolve --classification <system>:<version>:<code> for deterministic resolution; candidate suggestions are never selected automatically.",
738
+ ],
739
+ };
740
+ }
741
+
742
+ function paginateCoverage(result, classification, options) {
743
+ const pageSize = positiveIntegerOption(options["page-size"], "page-size", 10, 100);
744
+ const page = positiveIntegerOption(options.page, "page", 1);
745
+ const totalCount = result.entries.length;
746
+ const totalPages = Math.max(1, Math.ceil(totalCount / pageSize));
747
+ if (page > totalPages) {
748
+ throw new CliError(
749
+ "PCR_CLI_PAGE_OUT_OF_RANGE",
750
+ `--page ${page} is out of range. Available pages: 1-${totalPages}.`,
751
+ { page, total_pages: totalPages },
752
+ );
753
+ }
754
+ const startIndex = (page - 1) * pageSize;
755
+ const items = result.entries.slice(startIndex, startIndex + pageSize);
756
+ const previousPage = page > 1 ? page - 1 : null;
757
+ const nextPage = page < totalPages ? page + 1 : null;
758
+ const commandOptions = {
759
+ ...options,
760
+ classification: options.classification ?? `${classification.system}:${classification.version}`,
761
+ };
762
+ return {
763
+ classification: {
764
+ system: result.classification_system,
765
+ version: result.classification_version,
766
+ },
767
+ filters: {
768
+ status: options.status === undefined ? null : String(options.status),
769
+ },
770
+ available_statuses: result.available_statuses,
771
+ completeness: {
772
+ status: nextPage === null && previousPage === null ? "complete" : "paginated",
773
+ page,
774
+ page_size: pageSize,
775
+ returned_count: items.length,
776
+ total_count: totalCount,
777
+ total_pages: totalPages,
778
+ has_more: nextPage !== null,
779
+ },
780
+ items,
781
+ previous_command: previousPage
782
+ ? buildCoverageListCommand({ ...commandOptions, page: previousPage })
783
+ : null,
784
+ next_command: nextPage
785
+ ? buildCoverageListCommand({ ...commandOptions, page: nextPage })
786
+ : null,
787
+ next_steps: [
788
+ "Continue with previous_command or next_command when present; pagination is explicit and deterministic.",
789
+ "Run resolve --classification <system>:<version>:<code> for an exact code. This command does not fuzzy-match or auto-select candidate suggestions.",
790
+ ],
791
+ };
792
+ }
793
+
794
+ function buildCoverageListCommand(options) {
795
+ const parts = [...commandPrefix(options), "coverage", "list"];
796
+ parts.push("--classification", shellToken(String(options.classification)));
797
+ if (options.status) {
798
+ parts.push("--status", shellToken(String(options.status)));
799
+ }
800
+ if (options["page-size"]) {
801
+ parts.push("--page-size", shellToken(String(options["page-size"])));
802
+ }
803
+ if (options.page) {
804
+ parts.push("--page", shellToken(String(options.page)));
805
+ }
806
+ parts.push(...sourceArguments(options));
807
+ if (options.format) {
808
+ parts.push("--format", shellToken(String(options.format)));
809
+ }
810
+ return parts.join(" ");
811
+ }
812
+
813
+ function treeOutput(tree, depth, scope) {
814
+ return {
815
+ scope: "library/pcrs",
816
+ requested_scope: scope.requested,
817
+ effective_scope: scope.effective,
818
+ scope_source: scope.source,
819
+ depth,
820
+ completeness: depth >= 3 ? "complete" : "partial",
821
+ tree,
822
+ next_steps: depth >= 3
823
+ ? [
824
+ "Inspect PCR leaf readiness and run npm --silent run tiangong-pcr -- guidance --pcr <pcr-id> --format json only when usable_for_guidance is true.",
825
+ ]
826
+ : [
827
+ "Choose a visible path and run npm --silent run tiangong-pcr -- list --path-prefix <path> --format json.",
828
+ "Use --depth 3 only when a complete hierarchy is required; the full tree is large.",
829
+ ],
830
+ };
831
+ }
832
+
833
+ function resolveOutput(resolution, options) {
834
+ const usable = resolution.pcr?.readiness?.usable_for_guidance === true;
835
+ const pcrId = resolution.mapping?.pcr_id;
836
+ const guidanceCommand = usable && resolution.resolution_status === "mapped" && pcrId
837
+ ? [
838
+ `${commandPrefix(options).join(" ")} guidance`,
839
+ `--pcr ${shellToken(String(pcrId))}`,
840
+ sourceArguments(options).join(" "),
841
+ "--format json",
842
+ ].filter(Boolean).join(" ")
843
+ : null;
844
+ if (resolution.resolution_status === "unmapped") {
845
+ const [system, version] = String(options.classification).split(":");
846
+ const coverageCommand = buildCoverageListCommand({
847
+ classification: `${system}:${version}`,
848
+ status: resolution.coverage_status,
849
+ root: options.root,
850
+ library: options.library,
851
+ "library-sha256": options["library-sha256"],
852
+ format: "json",
853
+ page: 1,
854
+ });
855
+ return {
856
+ ...resolution,
857
+ next_command: coverageCommand,
858
+ next_steps: [
859
+ "No accepted PCR mapping was selected. Candidate suggestions and manual-review targets remain evidence only.",
860
+ "Use next_command to inspect the same coverage status, or draft missing_pcr feedback with supporting evidence.",
861
+ ],
862
+ };
863
+ }
864
+ if (resolution.resolution_status === "legacy_scaffold_compatibility") {
865
+ return {
866
+ ...resolution,
867
+ next_command: null,
868
+ next_steps: [
869
+ "This is a legacy scaffold compatibility reference, not usable PCR methodology.",
870
+ "Do not run guidance. Draft missing_pcr feedback if material methodology is required.",
871
+ ],
872
+ };
873
+ }
874
+ return {
875
+ ...resolution,
876
+ next_command: guidanceCommand,
877
+ next_steps: usable
878
+ ? ["Run next_command to obtain foreground data-production guidance."]
879
+ : [
880
+ "The mapping identifies a PCR, but its readiness blocks guidance; inspect pcr.readiness.blockers.",
881
+ "Draft feedback when the mapping or missing methodology prevents the requested work.",
882
+ ],
883
+ };
884
+ }
885
+
886
+ function resolvePcrIdentityOutput(resolution, options) {
887
+ if (resolution.resolution_status === "legacy_id_redirect") {
888
+ const nextCommand = legacyRedirectCommand(resolution.redirect.target, options);
889
+ return {
890
+ ...resolution,
891
+ redirect: {
892
+ ...resolution.redirect,
893
+ next_command: nextCommand,
894
+ },
895
+ next_command: nextCommand,
896
+ next_steps: [
897
+ "This PCR id is retired. The target is a locator, not automatically selected methodology.",
898
+ "Run next_command explicitly to inspect the classification coverage or canonical PCR target.",
899
+ ],
900
+ };
901
+ }
902
+
903
+ const usable = resolution.pcr?.readiness?.usable_for_guidance === true;
904
+ const nextCommand = usable
905
+ ? [
906
+ `${commandPrefix(options).join(" ")} guidance`,
907
+ `--pcr ${shellToken(String(resolution.pcr.id))}`,
908
+ sourceArguments(options).join(" "),
909
+ "--format json",
910
+ ].filter(Boolean).join(" ")
911
+ : null;
912
+ return {
913
+ ...resolution,
914
+ next_command: nextCommand,
915
+ next_steps: usable
916
+ ? ["The PCR id is canonical. Run next_command to obtain foreground data-production guidance."]
917
+ : [
918
+ "The PCR id is canonical, but readiness blocks guidance; inspect pcr.readiness.blockers.",
919
+ ],
920
+ };
921
+ }
922
+
923
+ function legacyRedirectCommand(target, options) {
924
+ const selector = target.kind === "classification_coverage"
925
+ ? [
926
+ "--classification",
927
+ shellToken(
928
+ `${target.classification_system}:${target.classification_version}:${target.code}`,
929
+ ),
930
+ ]
931
+ : ["--pcr", shellToken(String(target.pcr_id))];
932
+ return [
933
+ `${commandPrefix(options).join(" ")} resolve`,
934
+ ...selector,
935
+ sourceArguments(options).join(" "),
936
+ "--format json",
937
+ ].filter(Boolean).join(" ");
938
+ }
939
+
940
+ function validationExitCode(report, failOnValue) {
941
+ const failOn = validateFailOn(failOnValue);
942
+ if (failOn === "never") {
943
+ return 0;
944
+ }
945
+ if (report.validation_status === "inconclusive") {
946
+ return 2;
947
+ }
948
+ const errorCount = report.finding_summary?.error ?? 0;
949
+ const warningCount = report.finding_summary?.warning ?? 0;
950
+ if (failOn === "error" && errorCount > 0) {
951
+ return 2;
952
+ }
953
+ if (failOn === "warning" && errorCount + warningCount > 0) {
954
+ return 2;
955
+ }
956
+ return 0;
957
+ }
958
+
959
+ function formatListTable(page) {
960
+ const lines = [
961
+ "PCR id | Status | Readiness | Title | Record kind",
962
+ "--- | --- | --- | --- | ---",
963
+ ];
964
+ for (const pcr of page.items) {
965
+ lines.push(`${pcr.id} | ${pcr.status} | ${pcr.readiness?.status ?? "unknown"} | ${pcr.title["en-US"] ?? ""} | ${pcr.record_kind}`);
966
+ }
967
+ const start = page.total_count === 0 ? 0 : (page.page - 1) * page.page_size + 1;
968
+ const end = Math.min(page.page * page.page_size, page.total_count);
969
+ lines.push("");
970
+ lines.push(`Effective scope: ${page.effective_scope} (${page.scope_source}).`);
971
+ lines.push(`Showing ${start}-${end} of ${page.total_count} PCR records. Page ${page.page} of ${page.total_pages}.`);
972
+ if (page.previous_command) {
973
+ lines.push(`Previous page: ${page.previous_command}`);
974
+ }
975
+ if (page.next_command) {
976
+ lines.push(`Next page: ${page.next_command}`);
977
+ }
978
+ lines.push("Next step: inspect readiness and run `npm --silent run tiangong-pcr -- guidance --pcr <pcr-id> --format json` only when `usable_for_guidance` is true; use `npm --silent run tiangong-pcr -- resolve` when you have a classification code.");
979
+ return lines.join("\n");
980
+ }
981
+
982
+ function formatCoverageSummary(result) {
983
+ const lines = [
984
+ `Classification coverage: ${result.classification_system} ${result.classification_version}`,
985
+ "",
986
+ "Status | Count",
987
+ "--- | ---:",
988
+ ];
989
+ for (const status of CLASSIFICATION_COVERAGE_STATUSES) {
990
+ lines.push(`${status} | ${result.summary[status]}`);
991
+ }
992
+ lines.push(`total | ${result.summary.total}`);
993
+ lines.push("");
994
+ lines.push("Summary is complete and bounded; individual entries are not included.");
995
+ lines.push(`Next: ${result.next_command}`);
996
+ return lines.join("\n");
997
+ }
998
+
999
+ function formatCoverageList(result) {
1000
+ const lines = [
1001
+ `Classification coverage: ${result.classification.system} ${result.classification.version}`,
1002
+ "",
1003
+ "Code | Coverage status | Label | Resolution evidence",
1004
+ "--- | --- | --- | ---",
1005
+ ];
1006
+ for (const entry of result.items) {
1007
+ const evidence = entry.mapping?.pcr_id ?? entry.legacy_reference?.pcr_id ?? "none";
1008
+ lines.push(`${entry.code} | ${entry.coverage_status} | ${entry.label} | ${evidence}`);
1009
+ }
1010
+ const completeness = result.completeness;
1011
+ lines.push("");
1012
+ lines.push(
1013
+ `Filter status: ${result.filters.status ?? "all"}. Showing ${completeness.returned_count} of ${completeness.total_count} entries on page ${completeness.page} of ${completeness.total_pages}.`,
1014
+ );
1015
+ if (result.previous_command) {
1016
+ lines.push(`Previous page: ${result.previous_command}`);
1017
+ }
1018
+ if (result.next_command) {
1019
+ lines.push(`Next page: ${result.next_command}`);
1020
+ }
1021
+ lines.push("Next: run `npm --silent run tiangong-pcr -- resolve --classification <system>:<version>:<code> --format json` for an exact code; no fuzzy or candidate auto-selection is performed.");
1022
+ return lines.join("\n");
1023
+ }
1024
+
1025
+ function positiveIntegerOption(value, optionName, fallback, maximum = Infinity) {
1026
+ if (value === undefined) {
1027
+ return fallback;
1028
+ }
1029
+ const token = String(value);
1030
+ const parsed = Number(token);
1031
+ if (!/^[1-9][0-9]*$/u.test(token) || !Number.isSafeInteger(parsed) || parsed > maximum) {
1032
+ const expectation = Number.isFinite(maximum)
1033
+ ? `a positive safe integer no greater than ${maximum}`
1034
+ : "a positive safe integer";
1035
+ throw new CliError(
1036
+ "PCR_CLI_INVALID_INTEGER_OPTION",
1037
+ `Invalid --${optionName} "${value}". Expected ${expectation}.`,
1038
+ { option: optionName, value: String(value), maximum: Number.isFinite(maximum) ? maximum : null },
1039
+ );
1040
+ }
1041
+ return parsed;
1042
+ }
1043
+
1044
+ function validateFailOn(value) {
1045
+ const failOn = String(value ?? "error");
1046
+ if (!VALID_FAIL_ON.has(failOn)) {
1047
+ throw invalidChoiceError("fail-on", failOn, [...VALID_FAIL_ON]);
1048
+ }
1049
+ return failOn;
1050
+ }
1051
+
1052
+ function invalidChoiceError(option, value, choices, details = {}) {
1053
+ return new CliError(
1054
+ "PCR_CLI_INVALID_CHOICE",
1055
+ `Invalid --${option} "${value}". Expected one of: ${choices.join(", ")}.`,
1056
+ { option, value, choices: [...choices], ...details },
1057
+ );
1058
+ }
1059
+
1060
+ function normalizePathPrefix(value) {
1061
+ const original = String(value);
1062
+ const prefix = original.replace(/^library\/pcrs\/?/u, "").replace(/^\/+|\/+$/gu, "");
1063
+ const segments = prefix.split("/");
1064
+ if (
1065
+ prefix.length === 0
1066
+ || original.includes("\\")
1067
+ || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")
1068
+ ) {
1069
+ throw new CliError(
1070
+ "PCR_CLI_INVALID_PATH_PREFIX",
1071
+ `Invalid --path-prefix "${original}". Use a slash-delimited path below library/pcrs without . or .. segments.`,
1072
+ { option: "path-prefix", value: original },
1073
+ );
1074
+ }
1075
+ return prefix;
1076
+ }
1077
+
1078
+ function buildListCommand(options) {
1079
+ const parts = [...commandPrefix(options), "list"];
1080
+ if (options.scope) {
1081
+ parts.push("--scope", shellToken(String(options.scope)));
1082
+ }
1083
+ if (options.status) {
1084
+ parts.push("--status", shellToken(String(options.status)));
1085
+ }
1086
+ if (options["content-maturity"]) {
1087
+ parts.push("--content-maturity", shellToken(String(options["content-maturity"])));
1088
+ }
1089
+ if (options["path-prefix"]) {
1090
+ parts.push("--path-prefix", shellToken(String(options["path-prefix"])));
1091
+ }
1092
+ if (options["page-size"]) {
1093
+ parts.push("--page-size", shellToken(String(options["page-size"])));
1094
+ }
1095
+ if (options.page) {
1096
+ parts.push("--page", shellToken(String(options.page)));
1097
+ }
1098
+ parts.push(...sourceArguments(options));
1099
+ if (options.format) {
1100
+ parts.push("--format", shellToken(String(options.format)));
1101
+ }
1102
+ return parts.join(" ");
1103
+ }
1104
+
1105
+ function commandPrefix(options) {
1106
+ return options.library ? ["tiangong-pcr"] : ["npm", "--silent", "run", "tiangong-pcr", "--"];
1107
+ }
1108
+ function sourceArguments(options) {
1109
+ const parts = options.library ? ["--library", shellToken(String(options.library))] : options.root ? ["--root", shellToken(String(options.root))] : [];
1110
+ if (options["library-sha256"]) parts.push("--library-sha256", shellToken(String(options["library-sha256"])));
1111
+ return parts;
1112
+ }
1113
+
1114
+ function shellToken(value) {
1115
+ return /^[A-Za-z0-9_./:-]+$/u.test(value)
1116
+ ? value
1117
+ : `'${String(value).replaceAll("'", `'"'"'`)}'`;
1118
+ }
1119
+
1120
+ function formatTreeMarkdown(tree, depth, scope) {
1121
+ const lines = [];
1122
+ lines.push(`Effective scope: ${scope.effective} (${scope.source}).`);
1123
+ lines.push("");
1124
+ renderTreeNode(tree, lines, 0);
1125
+ lines.push("");
1126
+ if (depth < 3) {
1127
+ lines.push(`This hierarchy is partial at depth ${depth}.`);
1128
+ lines.push("Next: run `npm --silent run tiangong-pcr -- list --path-prefix <visible-path>` to inspect paginated PCR records and readiness.");
1129
+ } else {
1130
+ lines.push("Next: inspect leaf readiness and run `npm --silent run tiangong-pcr -- guidance --pcr <pcr-id> --format json` only when `usable_for_guidance` is true.");
1131
+ }
1132
+ return lines.join("\n");
1133
+ }
1134
+
1135
+ function renderTreeNode(node, lines, depth) {
1136
+ for (const [segment, value] of Object.entries(node).sort(([left], [right]) => left.localeCompare(right))) {
1137
+ lines.push(`${" ".repeat(depth)}- ${segment}`);
1138
+ for (const pcr of value.pcrs ?? []) {
1139
+ const readiness = pcr.readiness ?? {};
1140
+ lines.push(
1141
+ `${" ".repeat(depth + 1)}- ${pcr.id} (readiness: ${readiness.status ?? "unknown"}; usable_for_guidance: ${readiness.usable_for_guidance === true})`,
1142
+ );
1143
+ }
1144
+ renderTreeNode(value.children ?? {}, lines, depth + 1);
1145
+ }
1146
+ }
1147
+
1148
+ function requireOption(options, key) {
1149
+ if (!options[key]) {
1150
+ throw new CliError(
1151
+ "PCR_CLI_MISSING_REQUIRED_OPTION",
1152
+ `Missing required option --${key}`,
1153
+ { option: key },
1154
+ );
1155
+ }
1156
+ }
1157
+
1158
+ function helpText(command = "", positional = []) {
1159
+ const definition = commandDefinitionFor(command, positional);
1160
+ if (command === "library") return `Usage: tiangong-pcr library info|verify --library <library.sqlite> [--library-sha256 sha256:<hex>] [--format json]\n\nRead snapshot identity, or verify the entire database checksum and SQLite integrity. No writes or network requests. Keep the manifest and pin with your task.\n`;
1161
+ if (!definition) {
1162
+ return globalHelpText();
1163
+ }
1164
+ if (definition.key === "list") {
1165
+ return `Usage: tiangong-pcr list [options]
1166
+
1167
+ Browse PCR records explicitly. This is catalog browsing, not fuzzy search.
1168
+
1169
+ Options:
1170
+ --scope all|material|legacy Record scope. Defaults to material. A scaffold/empty-scaffold filter derives legacy when scope is omitted.
1171
+ --status <status> Filter by manifest status, for example candidate or scaffold.
1172
+ --content-maturity <state> Filter by content maturity.
1173
+ --path-prefix <path> Filter below library/pcrs by a slash-delimited path prefix.
1174
+ --page <n> Page number. Defaults to 1.
1175
+ --page-size <n> Records per page, from 1 to 100. Defaults to 10 records per page.
1176
+ --format json|markdown|table Output format. Defaults to table.
1177
+ --root <path> PCR repository root.
1178
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1179
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1180
+ --help Show this command help.
1181
+
1182
+ JSON output:
1183
+ {
1184
+ "filters": { "scope": "material", "status": null, "content_maturity": null, "path_prefix": null },
1185
+ "effective_scope": "material",
1186
+ "scope_source": "default",
1187
+ "page": 1,
1188
+ "page_size": 10,
1189
+ "total_count": 3,
1190
+ "total_pages": 1,
1191
+ "has_more": false,
1192
+ "items": [{ "id": "<pcr-id>", "readiness": { "usable_for_guidance": true } }],
1193
+ "previous_command": null,
1194
+ "next_command": null,
1195
+ "next_steps": []
1196
+ }
1197
+
1198
+ Agent next step:
1199
+ Follow next_command when present. Use --scope all or --scope legacy only when those records are required.
1200
+ Inspect each record's readiness, and only when
1201
+ usable_for_guidance is true run:
1202
+ npm --silent run tiangong-pcr -- guidance --pcr <pcr-id> --format json
1203
+ `;
1204
+ }
1205
+ if (definition.key === "tree") {
1206
+ return `Usage: tiangong-pcr tree [options]
1207
+
1208
+ Show the PCR directory hierarchy so an Agent can inspect available categories before selecting a PCR.
1209
+
1210
+ Options:
1211
+ --depth <n> Limit hierarchy depth. Defaults to 2.
1212
+ --scope all|material|legacy Record scope. Defaults to material.
1213
+ --format json|markdown Output format. Defaults to markdown.
1214
+ --root <path> PCR repository root.
1215
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1216
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1217
+ --help Show this command help.
1218
+
1219
+ JSON output includes scope, requested depth, completeness, tree, and next_steps.
1220
+
1221
+ Agent next step:
1222
+ Use tree to narrow the category area, then run:
1223
+ npm --silent run tiangong-pcr -- list --path-prefix <path>
1224
+ Markdown PCR leaves include readiness and usable_for_guidance when --depth reaches them.
1225
+ `;
1226
+ }
1227
+ if (definition.key === "coverage") {
1228
+ return `Usage: tiangong-pcr coverage <summary|list> [options]
1229
+
1230
+ Inspect deterministic PCR coverage for one explicit classification system and version.
1231
+ This command family does not perform fuzzy search or automatically select candidate suggestions.
1232
+
1233
+ Subcommands:
1234
+ coverage summary --classification <system>:<version> [--format json|table]
1235
+ Return bounded aggregate counts without leaf entries.
1236
+ coverage list --classification <system>:<version> [--status <coverage-status>] [--page <n>] [--page-size <n>] [--format json|table]
1237
+ Return an explicitly filtered, paginated leaf list with completeness and continuation commands.
1238
+
1239
+ Selector:
1240
+ --classification <system>:<version> Example: cpc:3.0. A leaf code belongs only on resolve.
1241
+
1242
+ Output:
1243
+ summary and list support json|table. JSON stdout is stable and remains clean on success.
1244
+
1245
+ Agent next step:
1246
+ Start with:
1247
+ npm --silent run tiangong-pcr -- coverage summary --classification cpc:3.0 --format json
1248
+ Then follow next_command or run coverage list with an explicit status filter.
1249
+ `;
1250
+ }
1251
+ if (definition.key === "coverage:summary") {
1252
+ return `Usage: tiangong-pcr coverage summary --classification <system>:<version> [options]
1253
+
1254
+ Show bounded aggregate coverage for one explicit classification system and version.
1255
+ This command does not list leaves and does not perform fuzzy search.
1256
+
1257
+ Options:
1258
+ --classification <value> Example: cpc:3.0.
1259
+ --format json|table Output format. Defaults to table.
1260
+ --root <path> PCR repository root.
1261
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1262
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1263
+ --help Show this command help.
1264
+
1265
+ JSON output includes source, complete status counts, a bounded completeness marker, and next_command.
1266
+
1267
+ Agent next step:
1268
+ Run next_command or use coverage list --classification cpc:3.0 --status <status>
1269
+ to inspect a paginated subset.
1270
+ `;
1271
+ }
1272
+ if (definition.key === "coverage:list") {
1273
+ return `Usage: tiangong-pcr coverage list --classification <system>:<version> [options]
1274
+
1275
+ List explicit classification leaves and their PCR coverage status. This is deterministic coverage browsing, not fuzzy search.
1276
+
1277
+ Options:
1278
+ --classification <value> Example: cpc:3.0.
1279
+ --status <status> Filter by mapped, unmapped, candidate_suggestion, manual_review, or unknown.
1280
+ --page <n> Page number. Defaults to 1.
1281
+ --page-size <n> Entries per page, from 1 to 100. Defaults to 10.
1282
+ --format json|table Output format. Defaults to table.
1283
+ --root <path> PCR repository root.
1284
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1285
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1286
+ --help Show this command help.
1287
+
1288
+ JSON output keeps filters, completeness, items, previous_command, and next_command stable.
1289
+ Candidate suggestions and manual-review targets are evidence only and are never selected as accepted PCR mappings.
1290
+
1291
+ Agent next step:
1292
+ Follow the pagination commands, then run resolve --classification <system>:<version>:<code> for an exact leaf.
1293
+ `;
1294
+ }
1295
+ if (definition.key === "resolve") {
1296
+ return `Usage: tiangong-pcr resolve (--classification <system>:<version>:<code> | --pcr <pcr-id>) [options]
1297
+
1298
+ Resolve exactly one external classification code or PCR identity through deterministic contracts.
1299
+ This command does not perform fuzzy search and never silently follows a retired PCR id.
1300
+ Only coverage_status=mapped selects a material PCR. Known unmapped codes return success with mapping and pcr set to null.
1301
+ Retired PCR ids return a redirect locator and copyable next command without automatically following the target.
1302
+ Candidate suggestions and manual-review targets are never auto-selected.
1303
+ Even a mapped result does not prove that the methodology is usable; inspect PCR readiness.
1304
+
1305
+ Options:
1306
+ --classification <value> Example: cpc:3.0:01111.
1307
+ --pcr <pcr-id> Exact current or retired PCR id. Mutually exclusive with --classification.
1308
+ --format json Output format. JSON is recommended for Agents.
1309
+ --root <path> PCR repository root.
1310
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1311
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1312
+ --help Show this command help.
1313
+
1314
+ Examples:
1315
+ npm --silent run tiangong-pcr -- resolve --classification cpc:3.0:01111 --format json
1316
+ npm --silent run tiangong-pcr -- resolve --pcr <pcr-id> --format json
1317
+
1318
+ Agent next step:
1319
+ Inspect resolution_status. For legacy_id_redirect, run next_command explicitly; the target was not auto-selected.
1320
+ Only when the selected canonical or mapped PCR has readiness.usable_for_guidance=true, run:
1321
+ npm --silent run tiangong-pcr -- guidance --pcr <mapping.pcr_id> --format json
1322
+ `;
1323
+ }
1324
+ if (definition.key === "show") {
1325
+ return `Usage: tiangong-pcr show --pcr <pcr-id> [options]
1326
+
1327
+ Offline snapshots contain English only; use --lang en-US. Other languages require repository mode.
1328
+
1329
+ Print the human-readable PCR Markdown.
1330
+
1331
+ Options:
1332
+ --pcr <pcr-id> PCR id to display.
1333
+ --lang en-US|zh-CN Markdown language. Defaults to en-US.
1334
+ --format markdown Output format. Defaults to markdown.
1335
+ --root <path> PCR repository root.
1336
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1337
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1338
+ --help Show this command help.
1339
+
1340
+ Agent next step:
1341
+ Use show for human review. Use guidance for machine-readable foreground data-production rules.
1342
+ `;
1343
+ }
1344
+ if (definition.key === "guidance") {
1345
+ return `Usage: tiangong-pcr guidance --pcr <pcr-id> [options]
1346
+
1347
+ Print Agent-facing structured PCR guidance from generated structured.yaml.
1348
+ This command rejects scaffold, incomplete, deprecated, or otherwise unusable PCR methodology.
1349
+
1350
+ Options:
1351
+ --pcr <pcr-id> PCR id.
1352
+ --format json Output format. JSON is recommended for Agents.
1353
+ --root <path> PCR repository root.
1354
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1355
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1356
+ --help Show this command help.
1357
+
1358
+ JSON output includes:
1359
+ pcr, readiness, system_boundary, reference_flow, measurement_rules, process_map,
1360
+ process_inventory, allocation_rules, validation_rules, data_sources, and validation_notes.
1361
+
1362
+ Agent next step:
1363
+ Build the foreground data package from the guidance, then run validate-dataset.
1364
+ Use process or lifecyclemodel publication and validate-model only as a downstream projection.
1365
+ `;
1366
+ }
1367
+ if (definition.key === "validate-model") {
1368
+ return `Usage: tiangong-pcr validate-model --pcr <pcr-id> --input <file> [options]
1369
+
1370
+ Check a process or lifecyclemodel draft against selected PCR guidance.
1371
+
1372
+ Options:
1373
+ --pcr <pcr-id> PCR id.
1374
+ --input <file> Model draft file.
1375
+ --format json Output format. JSON is recommended for Agents.
1376
+ --fail-on never|error|warning Exit 2 at the selected finding threshold. Defaults to error.
1377
+ --root <path> PCR repository root.
1378
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1379
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1380
+ --help Show this command help.
1381
+
1382
+ JSON output includes:
1383
+ validation_status, completeness, input, check_coverage, finding_summary, and findings.
1384
+
1385
+ Exit codes:
1386
+ 0 command completed and the configured finding threshold was not reached;
1387
+ 1 usage, input, or runtime error; 2 validation is inconclusive or the --fail-on threshold was reached.
1388
+
1389
+ Agent next step:
1390
+ Address findings in the model. If the PCR guidance is missing or unclear, create feedback draft.
1391
+ `;
1392
+ }
1393
+ if (definition.key === "validate-dataset") {
1394
+ return `Usage: tiangong-pcr validate-dataset --pcr <pcr-id> --input <file> [options]
1395
+
1396
+ Check a foreground data package JSON object against the implemented subset of selected PCR guidance.
1397
+ The report states exactly which requirement families were checked or skipped.
1398
+
1399
+ Options:
1400
+ --pcr <pcr-id> PCR id.
1401
+ --input <file> Foreground data package JSON file. The JSON root must be an object.
1402
+ --format json Output format. JSON is recommended for Agents.
1403
+ --fail-on never|error|warning Exit 2 at the selected finding threshold. Defaults to error.
1404
+ --root <path> PCR repository root.
1405
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1406
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1407
+ --help Show this command help.
1408
+
1409
+ JSON output includes:
1410
+ validation_status, completeness, input, check_coverage, finding_summary, and findings.
1411
+ A passed status applies only to checks_performed; inspect checks_skipped when completeness is partial.
1412
+
1413
+ Exit codes:
1414
+ 0 command completed and the configured finding threshold was not reached;
1415
+ 1 malformed JSON, usage, or runtime error; 2 validation is inconclusive or the --fail-on threshold was reached.
1416
+
1417
+ Agent next step:
1418
+ Address error findings and inspect skipped coverage. Draft feedback when required PCR rules cannot be evaluated.
1419
+ `;
1420
+ }
1421
+ if (definition.key === "feedback:draft") {
1422
+ return `Usage: tiangong-pcr feedback draft --type <feedback-type> [options]
1423
+
1424
+ Create issue-ready Markdown for PCR maintainer feedback. Feedback is candidate evidence, not accepted PCR truth.
1425
+
1426
+ Options:
1427
+ --pcr <pcr-id> Affected PCR id when available.
1428
+ --type <feedback-type> Feedback type.
1429
+ --affected-section <section> Affected PCR section.
1430
+ --process-id <process_id> Affected process_id.
1431
+ --flow-role <role> Affected flow role.
1432
+ --summary <text> Short finding summary.
1433
+ --evidence <text> Evidence URLs, files, or notes.
1434
+ --proposed-change <text> Suggested change.
1435
+ --format json|markdown Output format. Defaults to markdown.
1436
+ --root <path> PCR repository root.
1437
+ --library <file> Local library.sqlite (or PCR_LIBRARY). Mutually exclusive with --root.
1438
+ --library-sha256 <sha256:hex> Verify and pin the complete snapshot before reading.
1439
+ --help Show this command help.
1440
+
1441
+ Feedback types:
1442
+ ${FEEDBACK_TYPES.map((type) => ` ${type}`).join("\n")}
1443
+
1444
+ Agent next step:
1445
+ Open a GitHub issue with the generated body, or hand it to a maintainer for intake.
1446
+ `;
1447
+ }
1448
+
1449
+ return globalHelpText();
1450
+ }
1451
+
1452
+ function globalHelpText() {
1453
+ return `Version: tiangong-pcr --version
1454
+ Offline: --library <library.sqlite> (or PCR_LIBRARY); --library-sha256 sha256:<hex> pins the file.
1455
+ library info|verify --library <file> --format json
1456
+ Requires Node 24.19+ for SQLite. No automatic downloads.
1457
+
1458
+ tiangong-pcr
1459
+
1460
+ Usage:
1461
+ tiangong-pcr <command> [options]
1462
+ tiangong-pcr <command> --help
1463
+
1464
+ Commands:
1465
+ list [--scope all|material|legacy] [--status <status>] [--content-maturity <state>] [--path-prefix <path>] [--page <n>] [--page-size <n>] [--format json|markdown|table]
1466
+ tree [--scope all|material|legacy] [--depth <n>] [--format json|markdown]
1467
+ coverage summary --classification <system>:<version> [--format json|table]
1468
+ coverage list --classification <system>:<version> [--status <coverage-status>] [--page <n>] [--page-size <n>] [--format json|table]
1469
+ resolve (--classification <system>:<version>:<code> | --pcr <pcr-id>) [--format json]
1470
+ show --pcr <pcr-id> [--lang en-US|zh-CN]
1471
+ guidance --pcr <pcr-id> [--format json]
1472
+ validate-model --pcr <pcr-id> --input <file> [--format json] [--fail-on never|error|warning]
1473
+ validate-dataset --pcr <pcr-id> --input <file> [--format json] [--fail-on never|error|warning]
1474
+ feedback draft --type <type> [--pcr <pcr-id>] [--summary <text>]
1475
+
1476
+ Agent workflow:
1477
+ 1. Inspect coverage summary/list when classification completeness matters; no fuzzy matching is performed.
1478
+ 2. If a classification code is available, run resolve --classification <system>:<version>:<code> --format json.
1479
+ If a PCR id is available, run resolve --pcr <pcr-id> --format json. Supply exactly one selector.
1480
+ 3. If no code is available, use tree/list to browse explicit material PCR hierarchy. list defaults to 10 records per page.
1481
+ 4. Check resolution_status and readiness. Run guidance only for mapped material PCRs when usable_for_guidance is true.
1482
+ 5. Build a foreground data package, then run validate-dataset.
1483
+ 6. Only for downstream publication projections, build a process or lifecyclemodel and run validate-model.
1484
+ 7. If PCR guidance is missing or ambiguous, run feedback draft with the observed gap.
1485
+ `;
1486
+ }