@ai-primitives-hub/app 0.2.1 → 0.2.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/README.md +5 -1
  2. package/dist/collection/affected-collections.d.ts +11 -0
  3. package/dist/collection/affected-collections.d.ts.map +1 -0
  4. package/dist/collection/affected-collections.js +90 -0
  5. package/dist/collection/affected-collections.js.map +1 -0
  6. package/dist/collection/create-plugin.d.ts +35 -0
  7. package/dist/collection/create-plugin.d.ts.map +1 -0
  8. package/dist/collection/create-plugin.js +118 -0
  9. package/dist/collection/create-plugin.js.map +1 -0
  10. package/dist/collection/index.d.ts +4 -2
  11. package/dist/collection/index.d.ts.map +1 -1
  12. package/dist/collection/index.js +8 -4
  13. package/dist/collection/index.js.map +1 -1
  14. package/dist/collection/kind-route-warning.d.ts +13 -0
  15. package/dist/collection/kind-route-warning.d.ts.map +1 -0
  16. package/dist/collection/kind-route-warning.js +40 -0
  17. package/dist/collection/kind-route-warning.js.map +1 -0
  18. package/dist/collection/plugin-item-issues.d.ts +36 -0
  19. package/dist/collection/plugin-item-issues.d.ts.map +1 -0
  20. package/dist/collection/plugin-item-issues.js +31 -0
  21. package/dist/collection/plugin-item-issues.js.map +1 -0
  22. package/dist/collection/read-collection.d.ts +1 -1
  23. package/dist/collection/read-collection.d.ts.map +1 -1
  24. package/dist/collection/read-collection.js +14 -15
  25. package/dist/collection/read-collection.js.map +1 -1
  26. package/dist/collection-editor/collection-contribution-workflow.d.ts +96 -0
  27. package/dist/collection-editor/collection-contribution-workflow.d.ts.map +1 -0
  28. package/dist/collection-editor/collection-contribution-workflow.js +479 -0
  29. package/dist/collection-editor/collection-contribution-workflow.js.map +1 -0
  30. package/dist/collection-editor/collection-editor-service.d.ts +232 -0
  31. package/dist/collection-editor/collection-editor-service.d.ts.map +1 -0
  32. package/dist/collection-editor/collection-editor-service.js +868 -0
  33. package/dist/collection-editor/collection-editor-service.js.map +1 -0
  34. package/dist/collection-editor/index.d.ts +7 -0
  35. package/dist/collection-editor/index.d.ts.map +1 -0
  36. package/dist/collection-editor/index.js +12 -0
  37. package/dist/collection-editor/index.js.map +1 -0
  38. package/dist/diagnostics/find-ancestor-file.d.ts +13 -0
  39. package/dist/diagnostics/find-ancestor-file.d.ts.map +1 -0
  40. package/dist/diagnostics/find-ancestor-file.js +85 -0
  41. package/dist/diagnostics/find-ancestor-file.js.map +1 -0
  42. package/dist/diagnostics/index.d.ts +10 -0
  43. package/dist/diagnostics/index.d.ts.map +1 -0
  44. package/dist/diagnostics/index.js +26 -0
  45. package/dist/diagnostics/index.js.map +1 -0
  46. package/dist/diagnostics/run-primitive-diagnostics.d.ts +43 -0
  47. package/dist/diagnostics/run-primitive-diagnostics.d.ts.map +1 -0
  48. package/dist/diagnostics/run-primitive-diagnostics.js +413 -0
  49. package/dist/diagnostics/run-primitive-diagnostics.js.map +1 -0
  50. package/dist/diagnostics/sandbox-snapshot.d.ts +20 -0
  51. package/dist/diagnostics/sandbox-snapshot.d.ts.map +1 -0
  52. package/dist/diagnostics/sandbox-snapshot.js +117 -0
  53. package/dist/diagnostics/sandbox-snapshot.js.map +1 -0
  54. package/dist/governance/generate-catalogue.d.ts +16 -0
  55. package/dist/governance/generate-catalogue.d.ts.map +1 -0
  56. package/dist/governance/generate-catalogue.js +67 -0
  57. package/dist/governance/generate-catalogue.js.map +1 -0
  58. package/dist/governance/hub-scoped-governance.d.ts +37 -0
  59. package/dist/governance/hub-scoped-governance.d.ts.map +1 -0
  60. package/dist/governance/hub-scoped-governance.js +110 -0
  61. package/dist/governance/hub-scoped-governance.js.map +1 -0
  62. package/dist/governance/index.d.ts +10 -0
  63. package/dist/governance/index.d.ts.map +1 -0
  64. package/dist/governance/index.js +26 -0
  65. package/dist/governance/index.js.map +1 -0
  66. package/dist/governance/load-config.d.ts +45 -0
  67. package/dist/governance/load-config.d.ts.map +1 -0
  68. package/dist/governance/load-config.js +137 -0
  69. package/dist/governance/load-config.js.map +1 -0
  70. package/dist/governance/pr-scope.d.ts +23 -0
  71. package/dist/governance/pr-scope.d.ts.map +1 -0
  72. package/dist/governance/pr-scope.js +22 -0
  73. package/dist/governance/pr-scope.js.map +1 -0
  74. package/dist/governance/report.d.ts +23 -0
  75. package/dist/governance/report.d.ts.map +1 -0
  76. package/dist/governance/report.js +177 -0
  77. package/dist/governance/report.js.map +1 -0
  78. package/dist/governance/run-governance.d.ts +22 -0
  79. package/dist/governance/run-governance.d.ts.map +1 -0
  80. package/dist/governance/run-governance.js +78 -0
  81. package/dist/governance/run-governance.js.map +1 -0
  82. package/dist/governance/source-checks.d.ts +29 -0
  83. package/dist/governance/source-checks.d.ts.map +1 -0
  84. package/dist/governance/source-checks.js +80 -0
  85. package/dist/governance/source-checks.js.map +1 -0
  86. package/dist/governance/validate-collection-governance.d.ts +46 -0
  87. package/dist/governance/validate-collection-governance.d.ts.map +1 -0
  88. package/dist/governance/validate-collection-governance.js +291 -0
  89. package/dist/governance/validate-collection-governance.js.map +1 -0
  90. package/dist/hub-editor/hub-config-editor-service.d.ts +94 -0
  91. package/dist/hub-editor/hub-config-editor-service.d.ts.map +1 -0
  92. package/dist/hub-editor/hub-config-editor-service.js +289 -0
  93. package/dist/hub-editor/hub-config-editor-service.js.map +1 -0
  94. package/dist/hub-editor/hub-contribution-workflow.d.ts +99 -0
  95. package/dist/hub-editor/hub-contribution-workflow.d.ts.map +1 -0
  96. package/dist/hub-editor/hub-contribution-workflow.js +385 -0
  97. package/dist/hub-editor/hub-contribution-workflow.js.map +1 -0
  98. package/dist/hub-editor/index.d.ts +7 -0
  99. package/dist/hub-editor/index.d.ts.map +1 -0
  100. package/dist/hub-editor/index.js +23 -0
  101. package/dist/hub-editor/index.js.map +1 -0
  102. package/dist/index.d.ts +6 -0
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +6 -0
  105. package/dist/index.js.map +1 -1
  106. package/dist/install/index.d.ts +2 -0
  107. package/dist/install/index.d.ts.map +1 -1
  108. package/dist/install/index.js +3 -1
  109. package/dist/install/index.js.map +1 -1
  110. package/dist/install/partial-target-write.d.ts +63 -0
  111. package/dist/install/partial-target-write.d.ts.map +1 -0
  112. package/dist/install/partial-target-write.js +128 -0
  113. package/dist/install/partial-target-write.js.map +1 -0
  114. package/dist/install/pipeline.d.ts +2 -1
  115. package/dist/install/pipeline.d.ts.map +1 -1
  116. package/dist/install/pipeline.js +4 -3
  117. package/dist/install/pipeline.js.map +1 -1
  118. package/dist/install/target-write.d.ts +10 -0
  119. package/dist/install/target-write.d.ts.map +1 -1
  120. package/dist/install/target-write.js +3 -2
  121. package/dist/install/target-write.js.map +1 -1
  122. package/dist/install/uninstall-pipeline.d.ts +11 -10
  123. package/dist/install/uninstall-pipeline.d.ts.map +1 -1
  124. package/dist/install/uninstall-pipeline.js +10 -11
  125. package/dist/install/uninstall-pipeline.js.map +1 -1
  126. package/dist/records/atomic-write.d.ts +11 -0
  127. package/dist/records/atomic-write.d.ts.map +1 -0
  128. package/dist/records/atomic-write.js +66 -0
  129. package/dist/records/atomic-write.js.map +1 -0
  130. package/dist/records/confine-path.d.ts +35 -0
  131. package/dist/records/confine-path.d.ts.map +1 -0
  132. package/dist/records/confine-path.js +140 -0
  133. package/dist/records/confine-path.js.map +1 -0
  134. package/dist/records/git-root.d.ts +66 -0
  135. package/dist/records/git-root.d.ts.map +1 -0
  136. package/dist/records/git-root.js +208 -0
  137. package/dist/records/git-root.js.map +1 -0
  138. package/dist/records/index.d.ts +30 -0
  139. package/dist/records/index.d.ts.map +1 -0
  140. package/dist/records/index.js +46 -0
  141. package/dist/records/index.js.map +1 -0
  142. package/dist/records/install-record-service.d.ts +496 -0
  143. package/dist/records/install-record-service.d.ts.map +1 -0
  144. package/dist/records/install-record-service.js +1365 -0
  145. package/dist/records/install-record-service.js.map +1 -0
  146. package/dist/records/install-record-services.d.ts +29 -0
  147. package/dist/records/install-record-services.d.ts.map +1 -0
  148. package/dist/records/install-record-services.js +17 -0
  149. package/dist/records/install-record-services.js.map +1 -0
  150. package/dist/records/legacy-shapes.d.ts +18 -0
  151. package/dist/records/legacy-shapes.d.ts.map +1 -0
  152. package/dist/records/legacy-shapes.js +30 -0
  153. package/dist/records/legacy-shapes.js.map +1 -0
  154. package/dist/records/map-tool-to-target.d.ts +33 -0
  155. package/dist/records/map-tool-to-target.d.ts.map +1 -0
  156. package/dist/records/map-tool-to-target.js +98 -0
  157. package/dist/records/map-tool-to-target.js.map +1 -0
  158. package/dist/records/mcp-servers.d.ts +116 -0
  159. package/dist/records/mcp-servers.d.ts.map +1 -0
  160. package/dist/records/mcp-servers.js +268 -0
  161. package/dist/records/mcp-servers.js.map +1 -0
  162. package/dist/records/modified-files.d.ts +32 -0
  163. package/dist/records/modified-files.d.ts.map +1 -0
  164. package/dist/records/modified-files.js +146 -0
  165. package/dist/records/modified-files.js.map +1 -0
  166. package/dist/records/plan-record-entries.d.ts +76 -0
  167. package/dist/records/plan-record-entries.d.ts.map +1 -0
  168. package/dist/records/plan-record-entries.js +84 -0
  169. package/dist/records/plan-record-entries.js.map +1 -0
  170. package/dist/records/read-record-text.d.ts +15 -0
  171. package/dist/records/read-record-text.d.ts.map +1 -0
  172. package/dist/records/read-record-text.js +36 -0
  173. package/dist/records/read-record-text.js.map +1 -0
  174. package/dist/records/record-entry.d.ts +31 -0
  175. package/dist/records/record-entry.d.ts.map +1 -0
  176. package/dist/records/record-entry.js +81 -0
  177. package/dist/records/record-entry.js.map +1 -0
  178. package/dist/records/record-file-shape.d.ts +90 -0
  179. package/dist/records/record-file-shape.d.ts.map +1 -0
  180. package/dist/records/record-file-shape.js +288 -0
  181. package/dist/records/record-file-shape.js.map +1 -0
  182. package/dist/records/record-hub.d.ts +42 -0
  183. package/dist/records/record-hub.d.ts.map +1 -0
  184. package/dist/records/record-hub.js +85 -0
  185. package/dist/records/record-hub.js.map +1 -0
  186. package/dist/records/record-identity.d.ts +14 -0
  187. package/dist/records/record-identity.d.ts.map +1 -0
  188. package/dist/records/record-identity.js +41 -0
  189. package/dist/records/record-identity.js.map +1 -0
  190. package/dist/records/record-migration.d.ts +118 -0
  191. package/dist/records/record-migration.d.ts.map +1 -0
  192. package/dist/records/record-migration.js +454 -0
  193. package/dist/records/record-migration.js.map +1 -0
  194. package/dist/records/record-store.d.ts +123 -0
  195. package/dist/records/record-store.d.ts.map +1 -0
  196. package/dist/records/record-store.js +291 -0
  197. package/dist/records/record-store.js.map +1 -0
  198. package/dist/records/resolve-record-source.d.ts +64 -0
  199. package/dist/records/resolve-record-source.d.ts.map +1 -0
  200. package/dist/records/resolve-record-source.js +160 -0
  201. package/dist/records/resolve-record-source.js.map +1 -0
  202. package/dist/records/sanitize-source.d.ts +18 -0
  203. package/dist/records/sanitize-source.d.ts.map +1 -0
  204. package/dist/records/sanitize-source.js +90 -0
  205. package/dist/records/sanitize-source.js.map +1 -0
  206. package/dist/records/select-record.d.ts +54 -0
  207. package/dist/records/select-record.d.ts.map +1 -0
  208. package/dist/records/select-record.js +180 -0
  209. package/dist/records/select-record.js.map +1 -0
  210. package/dist/records/serialize-record.d.ts +20 -0
  211. package/dist/records/serialize-record.d.ts.map +1 -0
  212. package/dist/records/serialize-record.js +100 -0
  213. package/dist/records/serialize-record.js.map +1 -0
  214. package/dist/records/source-fields.d.ts +21 -0
  215. package/dist/records/source-fields.d.ts.map +1 -0
  216. package/dist/records/source-fields.js +28 -0
  217. package/dist/records/source-fields.js.map +1 -0
  218. package/dist/records/to-record-source.d.ts +23 -0
  219. package/dist/records/to-record-source.d.ts.map +1 -0
  220. package/dist/records/to-record-source.js +39 -0
  221. package/dist/records/to-record-source.js.map +1 -0
  222. package/dist/records/user-home.d.ts +16 -0
  223. package/dist/records/user-home.d.ts.map +1 -0
  224. package/dist/records/user-home.js +84 -0
  225. package/dist/records/user-home.js.map +1 -0
  226. package/dist/records/writer-group.d.ts +7 -0
  227. package/dist/records/writer-group.d.ts.map +1 -0
  228. package/dist/records/writer-group.js +31 -0
  229. package/dist/records/writer-group.js.map +1 -0
  230. package/dist/registry/activate-registry-profile.d.ts.map +1 -1
  231. package/dist/registry/activate-registry-profile.js +4 -1
  232. package/dist/registry/activate-registry-profile.js.map +1 -1
  233. package/dist/registry/batch-install-profile.d.ts +76 -0
  234. package/dist/registry/batch-install-profile.d.ts.map +1 -0
  235. package/dist/registry/batch-install-profile.js +67 -0
  236. package/dist/registry/batch-install-profile.js.map +1 -0
  237. package/dist/registry/create-source-adapter.d.ts +16 -1
  238. package/dist/registry/create-source-adapter.d.ts.map +1 -1
  239. package/dist/registry/create-source-adapter.js +76 -3
  240. package/dist/registry/create-source-adapter.js.map +1 -1
  241. package/dist/registry/hub-manager.d.ts +41 -0
  242. package/dist/registry/hub-manager.d.ts.map +1 -1
  243. package/dist/registry/hub-manager.js +82 -4
  244. package/dist/registry/hub-manager.js.map +1 -1
  245. package/dist/registry/index.d.ts +1 -0
  246. package/dist/registry/index.d.ts.map +1 -1
  247. package/dist/registry/index.js +1 -0
  248. package/dist/registry/index.js.map +1 -1
  249. package/dist/registry/install-registry-bundle.js +4 -3
  250. package/dist/registry/install-registry-bundle.js.map +1 -1
  251. package/dist/registry/list-installed-bundles.d.ts +2 -3
  252. package/dist/registry/list-installed-bundles.d.ts.map +1 -1
  253. package/dist/registry/list-installed-bundles.js.map +1 -1
  254. package/dist/registry/load-hub-sources.d.ts +8 -0
  255. package/dist/registry/load-hub-sources.d.ts.map +1 -1
  256. package/dist/registry/load-hub-sources.js +70 -3
  257. package/dist/registry/load-hub-sources.js.map +1 -1
  258. package/dist/registry/profile-lifecycle.d.ts +7 -2
  259. package/dist/registry/profile-lifecycle.d.ts.map +1 -1
  260. package/dist/registry/profile-lifecycle.js +82 -11
  261. package/dist/registry/profile-lifecycle.js.map +1 -1
  262. package/dist/registry/uninstall-installed-bundle.d.ts +2 -3
  263. package/dist/registry/uninstall-installed-bundle.d.ts.map +1 -1
  264. package/dist/registry/uninstall-installed-bundle.js.map +1 -1
  265. package/dist/registry/update-registry-bundle.d.ts +2 -2
  266. package/dist/registry/update-registry-bundle.js +2 -2
  267. package/dist/registry/update-registry-bundle.js.map +1 -1
  268. package/dist/registry/validate-hub-config-file.d.ts +14 -1
  269. package/dist/registry/validate-hub-config-file.d.ts.map +1 -1
  270. package/dist/registry/validate-hub-config-file.js +81 -44
  271. package/dist/registry/validate-hub-config-file.js.map +1 -1
  272. package/dist/release/plan-bundle-release.d.ts +6 -12
  273. package/dist/release/plan-bundle-release.d.ts.map +1 -1
  274. package/dist/release/plan-bundle-release.js +178 -7
  275. package/dist/release/plan-bundle-release.js.map +1 -1
  276. package/dist/replicate/replicate.d.ts +5 -2
  277. package/dist/replicate/replicate.d.ts.map +1 -1
  278. package/dist/replicate/replicate.js +121 -17
  279. package/dist/replicate/replicate.js.map +1 -1
  280. package/dist/security/index.d.ts +4 -0
  281. package/dist/security/index.d.ts.map +1 -0
  282. package/dist/security/index.js +22 -0
  283. package/dist/security/index.js.map +1 -0
  284. package/dist/security/rating/bundle-discovery.d.ts +19 -0
  285. package/dist/security/rating/bundle-discovery.d.ts.map +1 -0
  286. package/dist/security/rating/bundle-discovery.js +244 -0
  287. package/dist/security/rating/bundle-discovery.js.map +1 -0
  288. package/dist/security/rating/index.d.ts +5 -0
  289. package/dist/security/rating/index.d.ts.map +1 -0
  290. package/dist/security/rating/index.js +21 -0
  291. package/dist/security/rating/index.js.map +1 -0
  292. package/dist/security/rating/security-rating-markdown.d.ts +17 -0
  293. package/dist/security/rating/security-rating-markdown.d.ts.map +1 -0
  294. package/dist/security/rating/security-rating-markdown.js +131 -0
  295. package/dist/security/rating/security-rating-markdown.js.map +1 -0
  296. package/dist/security/rating/security-rating-scan.d.ts +23 -0
  297. package/dist/security/rating/security-rating-scan.d.ts.map +1 -0
  298. package/dist/security/rating/security-rating-scan.js +40 -0
  299. package/dist/security/rating/security-rating-scan.js.map +1 -0
  300. package/dist/security/rating/security-rating-templates.d.ts +40 -0
  301. package/dist/security/rating/security-rating-templates.d.ts.map +1 -0
  302. package/dist/security/rating/security-rating-templates.js +83 -0
  303. package/dist/security/rating/security-rating-templates.js.map +1 -0
  304. package/dist/security/rating/security-rating.d.ts +32 -0
  305. package/dist/security/rating/security-rating.d.ts.map +1 -0
  306. package/dist/security/rating/security-rating.js +94 -0
  307. package/dist/security/rating/security-rating.js.map +1 -0
  308. package/dist/security/security-scan-use-case.d.ts +101 -0
  309. package/dist/security/security-scan-use-case.d.ts.map +1 -0
  310. package/dist/security/security-scan-use-case.js +185 -0
  311. package/dist/security/security-scan-use-case.js.map +1 -0
  312. package/dist/stores/json-lockfile-store.d.ts.map +1 -1
  313. package/dist/stores/json-lockfile-store.js +6 -32
  314. package/dist/stores/json-lockfile-store.js.map +1 -1
  315. package/dist/transform/transformer-registry.d.ts.map +1 -1
  316. package/dist/transform/transformer-registry.js +3 -0
  317. package/dist/transform/transformer-registry.js.map +1 -1
  318. package/dist/transform/transformers/windsurf-transformer.d.ts +5 -0
  319. package/dist/transform/transformers/windsurf-transformer.d.ts.map +1 -1
  320. package/dist/transform/transformers/windsurf-transformer.js.map +1 -1
  321. package/dist/writers/file-tree-writer.d.ts +14 -1
  322. package/dist/writers/file-tree-writer.d.ts.map +1 -1
  323. package/dist/writers/file-tree-writer.js +23 -71
  324. package/dist/writers/file-tree-writer.js.map +1 -1
  325. package/package.json +5 -4
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.discoverBundles = void 0;
37
+ /**
38
+ * Find the bundles inside a source checkout, without needing a release archive.
39
+ *
40
+ * A bundle is the installable form of a collection, so the files that matter are the ones the
41
+ * collection lists. Two layouts are recognised, in this order:
42
+ *
43
+ * - `collections/*.collection.yml`: one bundle per collection (id = collection id). Its files are
44
+ * the collection file, every item (a `skill` item brings its whole folder) and the readme.
45
+ * - `skills/<name>/SKILL.md`: one bundle per skill folder, with the id the skills adapter builds:
46
+ * `skills-<owner>-<repo>-<name>`.
47
+ *
48
+ * Paths that leave the repository, and symlinks, are ignored.
49
+ * @module app/security/rating/bundle-discovery
50
+ */
51
+ const crypto = __importStar(require("node:crypto"));
52
+ const fs = __importStar(require("node:fs"));
53
+ const path = __importStar(require("node:path"));
54
+ const core_1 = require("@ai-primitives-hub/core");
55
+ const yaml = __importStar(require("js-yaml"));
56
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
57
+ const toPosix = (value) => value.split(path.sep).join('/');
58
+ const isOutside = (relative) => relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative);
59
+ /**
60
+ * Resolve a repository-relative path inside `root`, or undefined when it escapes (also through a
61
+ * symlinked folder) or is invalid. A path that does not exist yet is returned as is.
62
+ * @param root - Repository root
63
+ * @param relative - Path from a collection or option
64
+ */
65
+ const resolveInside = (root, relative) => {
66
+ if (typeof relative !== 'string') {
67
+ return undefined;
68
+ }
69
+ try {
70
+ const normalized = (0, core_1.normalizeRepoRelativePath)(relative);
71
+ const absolute = path.resolve(root, normalized);
72
+ const inside = path.relative(path.resolve(root), absolute);
73
+ if (inside === '' || isOutside(inside)) {
74
+ return undefined;
75
+ }
76
+ try {
77
+ const real = path.relative(fs.realpathSync(root), fs.realpathSync(absolute));
78
+ return isOutside(real) ? undefined : normalized;
79
+ }
80
+ catch (error) {
81
+ return error.code === 'ENOENT' ? normalized : undefined;
82
+ }
83
+ }
84
+ catch {
85
+ return undefined;
86
+ }
87
+ };
88
+ const regularFilesUnder = (root, folder) => {
89
+ const files = [];
90
+ const walk = (directory) => {
91
+ for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
92
+ const absolute = path.join(directory, entry.name);
93
+ if (entry.isSymbolicLink()) {
94
+ continue;
95
+ }
96
+ if (entry.isDirectory()) {
97
+ walk(absolute);
98
+ }
99
+ else if (entry.isFile()) {
100
+ files.push(toPosix(path.relative(root, absolute)));
101
+ }
102
+ }
103
+ };
104
+ walk(path.join(root, folder));
105
+ return files.toSorted();
106
+ };
107
+ const isFile = (absolute) => {
108
+ try {
109
+ const stat = fs.lstatSync(absolute);
110
+ return stat.isFile() && !stat.isSymbolicLink();
111
+ }
112
+ catch {
113
+ return false;
114
+ }
115
+ };
116
+ const listDirectory = (absolute) => {
117
+ try {
118
+ return fs.readdirSync(absolute, { withFileTypes: true }).toSorted((a, b) => a.name.localeCompare(b.name));
119
+ }
120
+ catch {
121
+ return [];
122
+ }
123
+ };
124
+ const discoverCollections = (root, collectionsPath) => {
125
+ const folder = resolveInside(root, collectionsPath);
126
+ const bundles = [];
127
+ const warnings = [];
128
+ if (folder === undefined) {
129
+ warnings.push(`${collectionsPath}: collections path is outside the repository or invalid`);
130
+ return { bundles, warnings };
131
+ }
132
+ for (const entry of listDirectory(path.join(root, folder))) {
133
+ if (!entry.isFile() || !entry.name.endsWith('.collection.yml')) {
134
+ continue;
135
+ }
136
+ const collectionFile = `${folder}/${entry.name}`;
137
+ let document;
138
+ try {
139
+ document = yaml.load(fs.readFileSync(path.join(root, collectionFile), 'utf8'));
140
+ }
141
+ catch {
142
+ continue;
143
+ }
144
+ if (!isRecord(document) || typeof document.id !== 'string' || document.id.trim() === '') {
145
+ continue;
146
+ }
147
+ const files = new Set([collectionFile]);
148
+ const kinds = {};
149
+ const references = Array.isArray(document.items)
150
+ ? document.items.filter((candidate) => isRecord(candidate)).map((item) => ({ path: item.path, kind: item.kind }))
151
+ : [];
152
+ if (isRecord(document.readme)) {
153
+ references.push({ path: document.readme.path });
154
+ }
155
+ for (const reference of references) {
156
+ const relative = resolveInside(root, reference.path);
157
+ if (relative === undefined || !isFile(path.join(root, relative))) {
158
+ warnings.push(`${collectionFile}: item not found or outside the repository: ${String(reference.path)}`);
159
+ continue;
160
+ }
161
+ const kind = (0, core_1.normalizePrimitiveKind)(reference.kind);
162
+ // A skill or plugin item brings its folder, but never the whole repository for a root-level file.
163
+ const skillFolder = path.posix.dirname(relative);
164
+ if ((kind === 'skill' || kind === 'plugin') && skillFolder !== '.') {
165
+ for (const file of regularFilesUnder(root, skillFolder)) {
166
+ files.add(file);
167
+ }
168
+ }
169
+ else {
170
+ files.add(relative);
171
+ }
172
+ if (kind !== null) {
173
+ kinds[kind] = (kinds[kind] ?? 0) + 1;
174
+ }
175
+ }
176
+ const mcp = isRecord(document.mcp) ? document.mcp.items : undefined;
177
+ const servers = isRecord(document.mcpServers) ? document.mcpServers : (isRecord(mcp) ? mcp : undefined);
178
+ if (servers !== undefined && Object.keys(servers).length > 0) {
179
+ kinds['mcp-server'] = Object.keys(servers).length;
180
+ }
181
+ const tags = Array.isArray(document.tags)
182
+ ? [...new Set(document.tags.filter((tag) => typeof tag === 'string' && tag !== ''))]
183
+ : [];
184
+ const metadata = {
185
+ author: typeof document.author === 'string' && document.author !== '' ? document.author : null,
186
+ kind: Object.fromEntries(Object.entries(kinds).toSorted(([a], [b]) => a.localeCompare(b))),
187
+ labels: tags
188
+ };
189
+ bundles.push({
190
+ id: document.id.trim(),
191
+ version: typeof document.version === 'string' || typeof document.version === 'number' ? String(document.version) : '1.0.0',
192
+ files: [...files].toSorted(),
193
+ metadata
194
+ });
195
+ }
196
+ return { bundles, warnings };
197
+ };
198
+ const contentHash = (root, files) => {
199
+ const digest = crypto.createHash('sha1');
200
+ for (const file of files) {
201
+ digest.update(file);
202
+ digest.update(fs.readFileSync(path.join(root, file)));
203
+ }
204
+ return `hash:${digest.digest('hex').slice(0, 12)}`;
205
+ };
206
+ const discoverSkills = (root, skillsPath, repository) => {
207
+ const folder = resolveInside(root, skillsPath);
208
+ if (folder === undefined) {
209
+ return { bundles: [], warnings: [`${skillsPath}: skills path is outside the repository or invalid`] };
210
+ }
211
+ const [owner = '', repo = ''] = repository.split('/');
212
+ const bundles = [];
213
+ for (const entry of listDirectory(path.join(root, folder))) {
214
+ if (!entry.isDirectory() || entry.isSymbolicLink() || !isFile(path.join(root, folder, entry.name, 'SKILL.md'))) {
215
+ continue;
216
+ }
217
+ const files = regularFilesUnder(root, `${folder}/${entry.name}`);
218
+ bundles.push({
219
+ id: `skills-${owner}-${repo}-${entry.name}`,
220
+ version: contentHash(root, files),
221
+ files,
222
+ metadata: { author: owner === '' ? null : owner, kind: { skill: 1 }, labels: [] }
223
+ });
224
+ }
225
+ return { bundles, warnings: [] };
226
+ };
227
+ /**
228
+ * Find the bundles of a source checkout: collections first, then skill folders.
229
+ * @param root - Repository root
230
+ * @param options - Repository name and folder overrides
231
+ */
232
+ const discoverBundles = (root, options) => {
233
+ const collections = discoverCollections(root, options.collectionsPath ?? 'collections');
234
+ if (collections.bundles.length > 0) {
235
+ return { mode: 'collections', bundles: collections.bundles, warnings: collections.warnings };
236
+ }
237
+ const skills = discoverSkills(root, options.skillsPath ?? 'skills', options.repository);
238
+ const warnings = [...collections.warnings, ...skills.warnings];
239
+ return skills.bundles.length > 0
240
+ ? { mode: 'skills', bundles: skills.bundles, warnings }
241
+ : { mode: 'repository', bundles: [], warnings };
242
+ };
243
+ exports.discoverBundles = discoverBundles;
244
+ //# sourceMappingURL=bundle-discovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-discovery.js","sourceRoot":"","sources":["../../../src/security/rating/bundle-discovery.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;GAaG;AACH,oDAAsC;AACtC,4CAA8B;AAC9B,gDAAkC;AAMlC,kDAGiC;AACjC,8CAAgC;AAehC,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,MAAM,OAAO,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE3E,MAAM,SAAS,GAAG,CAAC,QAAgB,EAAW,EAAE,CAAC,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAExI;;;;;GAKG;AACH,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,QAAiB,EAAsB,EAAE;IAC5E,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAA,gCAAyB,EAAC,QAAQ,CAAC,CAAC;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,C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AAG,CAAC,IAAY,EAAE,OAA+B,EAAqB,EAAE;IAClG,MAAM,WAAW,GAAG,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,eAAe,IAAI,aAAa,CAAC,CAAC;IACxF,IAAI,WAAW,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC;IAC/F,CAAC;IACD,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,IAAI,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACxF,MAAM,QAAQ,GAAG,CAAC,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC;QAC9B,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE;QACvD,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC;AACpD,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B"}
@@ -0,0 +1,5 @@
1
+ export * from './bundle-discovery';
2
+ export * from './security-rating-markdown';
3
+ export * from './security-rating';
4
+ export * from './security-rating-scan';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/security/rating/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./bundle-discovery"), exports);
18
+ __exportStar(require("./security-rating-markdown"), exports);
19
+ __exportStar(require("./security-rating"), exports);
20
+ __exportStar(require("./security-rating-scan"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/rating/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,6DAA2C;AAC3C,oDAAkC;AAClC,yDAAuC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Markdown for a security rating report: the job summary or pull-request comment.
3
+ *
4
+ * Score bars, risk badges, a collapsible findings table per failing bundle, and the full table
5
+ * collapsed. GitHub renders the tables and `<details>` blocks; the text still reads without them.
6
+ * The layout lives in `security-rating-templates`; this module only prepares the values.
7
+ * @module app/security/rating/security-rating-markdown
8
+ */
9
+ import { type SecurityRatingReport, type SecurityRatingRisk } from '@ai-primitives-hub/core';
10
+ export declare const riskBadge: (risk: SecurityRatingRisk) => string;
11
+ export declare const scoreBar: (score: number | null, width?: number) => string;
12
+ /**
13
+ * Render a security rating report as markdown.
14
+ * @param report - Report from the rating use case
15
+ */
16
+ export declare const renderSecurityRatingMarkdown: (report: SecurityRatingReport) => string;
17
+ //# sourceMappingURL=security-rating-markdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-rating-markdown.d.ts","sourceRoot":"","sources":["../../../src/security/rating/security-rating-markdown.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EAExB,MAAM,yBAAyB,CAAC;AAYjC,eAAO,MAAM,SAAS,GAAI,MAAM,kBAAkB,KAAG,MAAkC,CAAC;AAExF,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,GAAG,IAAI,EAAE,cAAU,KAAG,MAM3D,CAAC;AAgFF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GAAI,QAAQ,oBAAoB,KAAG,MA8B3E,CAAC"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderSecurityRatingMarkdown = exports.scoreBar = exports.riskBadge = void 0;
4
+ /**
5
+ * Markdown for a security rating report: the job summary or pull-request comment.
6
+ *
7
+ * Score bars, risk badges, a collapsible findings table per failing bundle, and the full table
8
+ * collapsed. GitHub renders the tables and `<details>` blocks; the text still reads without them.
9
+ * The layout lives in `security-rating-templates`; this module only prepares the values.
10
+ * @module app/security/rating/security-rating-markdown
11
+ */
12
+ const core_1 = require("@ai-primitives-hub/core");
13
+ const security_rating_templates_1 = require("./security-rating-templates");
14
+ const ICONS = { low: '🟢', medium: '🟡', high: '🟠', critical: '🔴', unknown: '⚪' };
15
+ const RISK_ORDER = ['critical', 'high', 'medium', 'low'];
16
+ const OK = '✅';
17
+ const FAIL = '❌';
18
+ const WARN = '⚠️';
19
+ const riskBadge = (risk) => `${ICONS[risk]} ${risk}`;
20
+ exports.riskBadge = riskBadge;
21
+ const scoreBar = (score, width = 10) => {
22
+ if (score === null) {
23
+ return '—';
24
+ }
25
+ const filled = Math.max(0, Math.min(width, Math.round((score / 100) * width)));
26
+ return '█'.repeat(filled) + '░'.repeat(width - filled);
27
+ };
28
+ exports.scoreBar = scoreBar;
29
+ const scoreCell = (score) => (score === null ? '—' : (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.scoreCell, { bar: (0, exports.scoreBar)(score), score: String(score) }));
30
+ const riskCounts = (bundles) => {
31
+ const counts = new Map();
32
+ for (const bundle of bundles) {
33
+ if (bundle.score !== null) {
34
+ counts.set(bundle.risk, (counts.get(bundle.risk) ?? 0) + 1);
35
+ }
36
+ }
37
+ const parts = RISK_ORDER.filter((risk) => (counts.get(risk) ?? 0) > 0).map((risk) => `${ICONS[risk]} ${String(counts.get(risk))} ${risk}`);
38
+ return parts.length > 0 ? parts.join(' · ') : 'no scored bundles';
39
+ };
40
+ const severityCounts = (counts) => ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW'].map((severity) => `${String(counts[severity])}${severity[0]}`).join(' ');
41
+ const details = (summary, body) => (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.details, { summary, body: body.join('\n') });
42
+ const findingsTable = (findings, limit = 5) => [
43
+ security_rating_templates_1.TEMPLATES.findingsHeader,
44
+ ...findings.slice(0, limit).map((item) => (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.findingRow, {
45
+ points: String(item.points), ruleId: item.ruleId, title: item.title, where: `${item.file}:${String(item.line)}`, fix: item.fix
46
+ })),
47
+ ...(findings.length > limit ? [(0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.findingsMore, { count: String(findings.length - limit) })] : [])
48
+ ];
49
+ const bundlesTable = (bundles, failOn) => [
50
+ security_rating_templates_1.TEMPLATES.bundlesHeader,
51
+ ...bundles.toSorted((a, b) => (a.score ?? -1) - (b.score ?? -1) || a.id.localeCompare(b.id)).map((bundle) => (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.bundleRow, {
52
+ status: (0, core_1.gateFailed)(bundle.score, failOn) ? FAIL : OK,
53
+ id: bundle.id,
54
+ version: bundle.version,
55
+ score: scoreCell(bundle.score),
56
+ risk: (0, exports.riskBadge)(bundle.risk),
57
+ counts: severityCounts(bundle.counts),
58
+ top: bundle.findings.at(0)?.title ?? '-'
59
+ }))
60
+ ];
61
+ const bundleSections = (bundles, failOn, attentionLimit = 10) => {
62
+ const failing = bundles.filter((bundle) => (0, core_1.gateFailed)(bundle.score, failOn));
63
+ const lowest = bundles.filter((bundle) => bundle.penalty > 0 && bundle.score !== null)
64
+ .toSorted((a, b) => (a.score ?? 0) - (b.score ?? 0)).slice(0, 5);
65
+ const shown = (failing.length > 0 ? failing : lowest)
66
+ .toSorted((a, b) => (a.score ?? 0) - (b.score ?? 0) || a.id.localeCompare(b.id)).slice(0, attentionLimit);
67
+ const parts = [];
68
+ if (shown.length > 0) {
69
+ parts.push(failing.length > 0 ? (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.attentionHeading, { failing: String(failing.length) }) : security_rating_templates_1.TEMPLATES.lowestHeading, '');
70
+ for (const bundle of shown.filter((item) => item.findings.length > 0)) {
71
+ const summary = (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.bundleSummary, { id: bundle.id, score: String(bundle.score), risk: (0, exports.riskBadge)(bundle.risk) });
72
+ parts.push(details(summary, findingsTable(bundle.findings)));
73
+ }
74
+ if (failing.length > shown.length) {
75
+ parts.push((0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.moreBelowLimit, { count: String(failing.length - shown.length) }), '');
76
+ }
77
+ }
78
+ parts.push(details((0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.allBundles, { count: String(bundles.length) }), bundlesTable(bundles, failOn)));
79
+ return parts.join('\n');
80
+ };
81
+ const gateLine = (failOn, failing, total) => {
82
+ if (failOn === 'none') {
83
+ return security_rating_templates_1.TEMPLATES.gateOff;
84
+ }
85
+ const counts = { failing: String(failing), total: String(total) };
86
+ const verdict = (0, security_rating_templates_1.fillTemplate)(failing > 0 ? security_rating_templates_1.TEMPLATES.gateFailing : security_rating_templates_1.TEMPLATES.gatePassing, counts);
87
+ return (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.gate, { failOn, limit: String((0, core_1.gateScoreLimit)(failOn)), verdict });
88
+ };
89
+ const howScoringWorks = () => {
90
+ const { curveScale, riskBands } = core_1.DEFAULT_SCORING_WEIGHTS;
91
+ return (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.scoring, {
92
+ scale: String(curveScale), low: String(riskBands.low), medium: String(riskBands.medium), high: String(riskBands.high)
93
+ });
94
+ };
95
+ /**
96
+ * Render a security rating report as markdown.
97
+ * @param report - Report from the rating use case
98
+ */
99
+ const renderSecurityRatingMarkdown = (report) => {
100
+ const failOn = report.gate.failOn === 'NONE' ? 'none' : report.gate.failOn;
101
+ const failed = !report.gate.passed;
102
+ const { repo, bundles } = report;
103
+ const common = {
104
+ title: (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.title, { icon: failed ? FAIL : OK, verdict: failed ? 'failed' : 'passed' }),
105
+ score: String(repo.score),
106
+ risk: (0, exports.riskBadge)(repo.risk),
107
+ scoreCell: scoreCell(repo.score),
108
+ scoring: howScoringWorks()
109
+ };
110
+ if (repo.basis === 'bundles-average') {
111
+ const failing = bundles.filter((bundle) => (0, core_1.gateFailed)(bundle.score, failOn)).length;
112
+ return (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.bundlesReport, {
113
+ ...common,
114
+ count: String(bundles.length),
115
+ plural: bundles.length === 1 ? '' : 's',
116
+ riskCounts: riskCounts(bundles),
117
+ gate: gateLine(failOn, failing, bundles.length),
118
+ sections: bundleSections(bundles, failOn)
119
+ });
120
+ }
121
+ return (0, security_rating_templates_1.fillTemplate)(security_rating_templates_1.TEMPLATES.repositoryReport, {
122
+ ...common,
123
+ warn: WARN,
124
+ gate: gateLine(failOn, failed ? 1 : 0, 1),
125
+ findings: repo.findings.length > 0
126
+ ? `${details(security_rating_templates_1.TEMPLATES.costliestFindings, findingsTable(repo.findings, 10))}\n`
127
+ : ''
128
+ });
129
+ };
130
+ exports.renderSecurityRatingMarkdown = renderSecurityRatingMarkdown;
131
+ //# sourceMappingURL=security-rating-markdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-rating-markdown.js","sourceRoot":"","sources":["../../../src/security/rating/security-rating-markdown.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,kDASiC;AACjC,2EAGqC;AAErC,MAAM,KAAK,GAAiD,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAClI,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAClE,MAAM,EAAE,GAAG,GAAG,CAAC;AACf,MAAM,IAAI,GAAG,GAAG,CAAC;AACjB,MAAM,IAAI,GAAG,IAAI,CAAC;AAEX,MAAM,SAAS,GAAG,CAAC,IAAwB,EAAU,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;AAA3E,QAAA,SAAS,aAAkE;AAEjF,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAE,KAAK,GAAG,EAAE,EAAU,EAAE;IACnE,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/E,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;AACzD,CAA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YAC/E,CAAC,CAAC,EAAE;KACP,CAAC,CAAC;AACL,CAAC,CAAC;AA9BW,QAAA,4BAA4B,gCA8BvC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Scan a source checkout with the security scanner, then rate its bundles from the findings.
3
+ * @module app/security/rating/security-rating-scan
4
+ */
5
+ import type { SecurityResourceLimits } from '@ai-primitives-hub/core';
6
+ import { type SecurityScanDependencies, type SecurityScanOptions, type SecurityScanResult } from '../security-scan-use-case';
7
+ import { type SecurityRatingRequest, type SecurityRatingResult } from './security-rating';
8
+ export interface SecurityRatingScanResult extends SecurityRatingResult {
9
+ /** The underlying scan, for coverage and operational errors. */
10
+ scan: SecurityScanResult;
11
+ }
12
+ /**
13
+ * Scan a checkout and rate its bundles.
14
+ * @param options - Scan dependencies plus the rating request
15
+ */
16
+ export declare const scanAndRate: (options: SecurityScanDependencies & {
17
+ request: Omit<SecurityRatingRequest, "scannerName"> & {
18
+ scannerName?: string;
19
+ };
20
+ scanOptions?: SecurityScanOptions;
21
+ limits?: SecurityResourceLimits;
22
+ }) => Promise<SecurityRatingScanResult>;
23
+ //# sourceMappingURL=security-rating-scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-rating-scan.d.ts","sourceRoot":"","sources":["../../../src/security/rating/security-rating-scan.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EACV,sBAAsB,EACvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,mBAAmB,CAAC;AAI3B,MAAM,WAAW,wBAAyB,SAAQ,oBAAoB;IACpE,gEAAgE;IAChE,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,GACtB,SAAS,wBAAwB,GAAG;IAClC,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,aAAa,CAAC,GAAG;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/E,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,MAAM,CAAC,EAAE,sBAAsB,CAAC;CACjC,KACA,OAAO,CAAC,wBAAwB,CA2BlC,CAAC"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scanAndRate = void 0;
4
+ const security_scan_use_case_1 = require("../security-scan-use-case");
5
+ const security_rating_1 = require("./security-rating");
6
+ const DEFAULT_SCANNER_NAME = 'ai-primitives-hub-security';
7
+ /**
8
+ * Scan a checkout and rate its bundles.
9
+ * @param options - Scan dependencies plus the rating request
10
+ */
11
+ const scanAndRate = async (options) => {
12
+ const { request } = options;
13
+ const scan = await (0, security_scan_use_case_1.runSecurityScan)({
14
+ input: options.input,
15
+ engine: options.engine,
16
+ clock: options.clock,
17
+ cancellation: options.cancellation,
18
+ limits: options.limits,
19
+ scanOptions: options.scanOptions,
20
+ failOn: 'none',
21
+ request: {
22
+ roots: [request.root],
23
+ extensions: ['.md', '.markdown'],
24
+ recursive: true,
25
+ excludes: ['.git', 'node_modules'],
26
+ // Documentation costs fewer points in the rating but is still rated.
27
+ includeDocFiles: true,
28
+ // Repository suppressions are ignored so a rating cannot be tuned by the rated repository.
29
+ ignoreTrust: 'none'
30
+ }
31
+ });
32
+ const rated = (0, security_rating_1.runSecurityRating)({
33
+ findings: scan.findings,
34
+ generatedAt: options.clock.nowIso(),
35
+ request: { ...request, scannerName: request.scannerName ?? DEFAULT_SCANNER_NAME }
36
+ });
37
+ return { ...rated, scan };
38
+ };
39
+ exports.scanAndRate = scanAndRate;
40
+ //# sourceMappingURL=security-rating-scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-rating-scan.js","sourceRoot":"","sources":["../../../src/security/rating/security-rating-scan.ts"],"names":[],"mappings":";;;AAOA,sEAKmC;AACnC,uDAI2B;AAE3B,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAO1D;;;GAGG;AACI,MAAM,WAAW,GAAG,KAAK,EAC9B,OAIC,EACkC,EAAE;IACrC,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC5B,MAAM,IAAI,GAAG,MAAM,IAAA,wCAAe,EAAC;QACjC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;YACrB,UAAU,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC;YAChC,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,CAAC;YAClC,qEAAqE;YACrE,eAAe,EAAE,IAAI;YACrB,2FAA2F;YAC3F,WAAW,EAAE,MAAM;SACpB;KACF,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,IAAA,mCAAiB,EAAC;QAC9B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE;QACnC,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,oBAAoB,EAAE;KAClF,CAAC,CAAC;IACH,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC,CAAC;AAjCW,QAAA,WAAW,eAiCtB"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Layout of the security rating Markdown report as templates with `{{slot}}` placeholders.
3
+ *
4
+ * `fillTemplate` escapes every value for the place it lands: `{{name}}` escapes it as a table
5
+ * cell (pipes and line breaks), `{{name|html}}` as HTML text, and `{{name|raw}}` inserts it as is
6
+ * for pieces this module already built. A slot without a value is an error, so a typo cannot
7
+ * silently drop part of the report. Values are inserted in a single pass and are not expanded
8
+ * again, so text from a finding cannot add slots of its own.
9
+ * @module app/security/rating/security-rating-templates
10
+ */
11
+ /**
12
+ * Fill the slots of a template.
13
+ * @param template - Text with `{{name}}`, `{{name|html}}` or `{{name|raw}}` slots
14
+ * @param values - Value of every slot used
15
+ */
16
+ export declare const fillTemplate: (template: string, values: Readonly<Record<string, string>>) => string;
17
+ export declare const TEMPLATES: {
18
+ readonly title: "## {{icon|raw}} Security scan: {{verdict|raw}}";
19
+ readonly bundlesReport: string;
20
+ readonly repositoryReport: string;
21
+ readonly gateOff: "Gate: off (report only).";
22
+ readonly gate: "Gate `{{failOn|raw}}`: a bundle fails below a score of {{limit|raw}}. {{verdict|raw}}";
23
+ readonly gateFailing: "**{{failing|raw}} of {{total|raw}} bundle(s) are below the limit.**";
24
+ readonly gatePassing: "All {{total|raw}} bundle(s) pass.";
25
+ readonly findingsHeader: "| Cost | Rule | Where | How to fix |\n|---:|---|---|---|";
26
+ readonly findingRow: "| -{{points|raw}} | `{{ruleId}}` {{title}} | `{{where}}` | {{fix}} |";
27
+ readonly findingsMore: "| | _{{count|raw}} more in the JSON report_ | | |";
28
+ readonly bundlesHeader: "| | Bundle | Score | Risk | Findings | Costliest finding |\n|:-:|---|---|---|---|---|";
29
+ readonly bundleRow: "| {{status|raw}} | `{{id}}` {{version}} | {{score|raw}} | {{risk|raw}} | {{counts|raw}} | {{top}} |";
30
+ readonly details: "<details><summary>{{summary|raw}}</summary>\n\n{{body|raw}}\n\n</details>\n";
31
+ readonly bundleSummary: "<b><code>{{id|html}}</code></b> &nbsp; {{score|raw}}/100 &nbsp; {{risk|raw}}";
32
+ readonly attentionHeading: "#### Needs attention ({{failing|raw}} below the gate limit)";
33
+ readonly lowestHeading: "#### Lowest scoring bundles";
34
+ readonly moreBelowLimit: "_{{count|raw}} more below the limit are in the full table._";
35
+ readonly allBundles: "All {{count|raw}} bundles";
36
+ readonly costliestFindings: "Costliest findings";
37
+ readonly scoreCell: "`{{bar|raw}}` **{{score|raw}}**";
38
+ readonly scoring: string;
39
+ };
40
+ //# sourceMappingURL=security-rating-templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security-rating-templates.d.ts","sourceRoot":"","sources":["../../../src/security/rating/security-rating-templates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,UAAU,MAAM,EAAE,QAAQ,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,KAAG,MAMtF,CAAC;AAEL,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;CAuDZ,CAAC"}