repometry 0.4.2 → 0.6.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 (269) hide show
  1. package/README.md +36 -14
  2. package/package.json +1 -1
  3. package/target/main/resources/report/json/comparison-v1.schema.json +6 -6
  4. package/target/main/resources/report/json/file-metrics-v1.schema.json +7 -6
  5. package/target/main/resources/report/json/pull-review-v1.schema.json +5 -5
  6. package/target/main/resources/report/json/report-v2.schema.json +210 -11
  7. package/target/main/resources/report/json/repository-summary-v1.schema.json +161 -14
  8. package/target/main/resources/report/json/viewer-inspection-v1.schema.json +518 -6
  9. package/target/main/resources/viewer/styles.css +7 -2
  10. package/target/main/ts/api/git/changes.d.ts +1 -1
  11. package/target/main/ts/api/git/changes.js +3 -3
  12. package/target/main/ts/api/git/commit-metadata.js +6 -4
  13. package/target/main/ts/api/git/git.d.ts +2 -1
  14. package/target/main/ts/api/git/git.js +16 -4
  15. package/target/main/ts/api/git/inspection-source.d.ts +1 -1
  16. package/target/main/ts/api/git/inspection-source.js +4 -10
  17. package/target/main/ts/api/git/local.d.ts +1 -1
  18. package/target/main/ts/api/git/local.js +41 -7
  19. package/target/main/ts/api/process/docker-tool-runner.d.ts +13 -0
  20. package/target/main/ts/api/process/docker-tool-runner.js +108 -0
  21. package/target/main/ts/api/process/failure.d.ts +1 -0
  22. package/target/main/ts/api/process/failure.js +12 -0
  23. package/target/main/ts/api/process/plugin.d.ts +10 -0
  24. package/target/main/ts/api/process/plugin.js +96 -0
  25. package/target/main/ts/api/worker/remote-executor.d.ts +1 -1
  26. package/target/main/ts/api/worker/remote-executor.js +2 -2
  27. package/target/main/ts/api/worker/worker-protocol.d.ts +2 -2
  28. package/target/main/ts/api/worker/worker-protocol.js +8 -8
  29. package/target/main/ts/api/worker/worker.d.ts +1 -1
  30. package/target/main/ts/api/worker/worker.js +4 -4
  31. package/target/main/ts/cli/main.js +4 -3
  32. package/target/main/ts/cli/reporting.d.ts +1 -1
  33. package/target/main/ts/cli/reporting.js +1 -1
  34. package/target/main/ts/compose/analysis-files.d.ts +13 -0
  35. package/target/main/ts/compose/analysis-files.js +95 -0
  36. package/target/main/ts/compose/analysis-imports.d.ts +7 -0
  37. package/target/main/ts/compose/analysis-imports.js +34 -0
  38. package/target/main/ts/compose/analysis-report.d.ts +5 -0
  39. package/target/main/ts/compose/analysis-report.js +78 -0
  40. package/target/main/ts/compose/analysis-repository.d.ts +6 -0
  41. package/target/main/ts/compose/analysis-repository.js +61 -0
  42. package/target/main/ts/compose/analysis-results.d.ts +38 -0
  43. package/target/main/ts/compose/analysis-results.js +78 -0
  44. package/target/main/ts/compose/analysis-sources.d.ts +73 -0
  45. package/target/main/ts/compose/analysis-sources.js +47 -0
  46. package/target/main/ts/compose/analyze-snapshot.d.ts +3 -2
  47. package/target/main/ts/compose/analyze-snapshot.js +19 -197
  48. package/target/main/ts/compose/diff-coverage.d.ts +2 -0
  49. package/target/main/ts/compose/diff-coverage.js +6 -4
  50. package/target/main/ts/compose/inspect.d.ts +5 -0
  51. package/target/main/ts/compose/inspect.js +14 -7
  52. package/target/main/ts/compose/languages.d.ts +29 -0
  53. package/target/main/ts/compose/languages.js +87 -0
  54. package/target/main/ts/compose/sources.js +14 -12
  55. package/target/main/ts/core/engine/execute.d.ts +3 -1
  56. package/target/main/ts/core/engine/execute.js +14 -2
  57. package/target/main/ts/core/engine/manifest.d.ts +2 -2
  58. package/target/main/ts/core/engine/manifest.js +25 -5
  59. package/target/main/ts/core/engine/operation-cache.d.ts +14 -0
  60. package/target/main/ts/core/engine/operation-cache.js +66 -0
  61. package/target/main/ts/core/engine/plan.d.ts +3 -4
  62. package/target/main/ts/core/engine/plan.js +28 -11
  63. package/target/main/ts/core/engine/plugin.d.ts +10 -2
  64. package/target/main/ts/core/engine/plugin.js +1 -3
  65. package/target/main/ts/core/engine/report-products.js +2 -13
  66. package/target/main/ts/core/model/clone-source.d.ts +1 -0
  67. package/target/main/ts/core/model/clone-source.js +2 -1
  68. package/target/main/ts/core/model/code-structure.d.ts +5 -0
  69. package/target/main/ts/core/model/code-structure.js +10 -1
  70. package/target/main/ts/core/model/finding-ignore.js +1 -1
  71. package/target/main/ts/core/model/finding.js +1 -1
  72. package/target/main/ts/core/model/language.d.ts +10 -0
  73. package/target/main/ts/core/model/language.js +6 -0
  74. package/target/main/ts/core/model/line-coverage.d.ts +5 -1
  75. package/target/main/ts/core/model/line-coverage.js +14 -11
  76. package/target/main/ts/core/model/measurement.d.ts +7 -6
  77. package/target/main/ts/core/model/measurement.js +18 -7
  78. package/target/main/ts/core/model/plugin-data.d.ts +5 -0
  79. package/target/main/ts/core/model/plugin-data.js +15 -1
  80. package/target/main/ts/core/model/quality-summary.js +6 -5
  81. package/target/main/ts/core/model/report.d.ts +1 -2
  82. package/target/main/ts/core/model/report.js +0 -1
  83. package/target/main/ts/core/model/scanner-import.js +1 -1
  84. package/target/main/ts/core/model/snapshot.d.ts +1 -2
  85. package/target/main/ts/core/model/snapshot.js +5 -7
  86. package/target/main/ts/core/model/source.d.ts +3 -0
  87. package/target/main/ts/core/model/source.js +15 -0
  88. package/target/main/ts/core/ports/tool-runner.d.ts +18 -0
  89. package/target/main/ts/core/ports/tool-runner.js +2 -0
  90. package/target/main/ts/core/usecases/compare.js +61 -17
  91. package/target/main/ts/core/usecases/inspect.js +2 -2
  92. package/target/main/ts/plugin.d.ts +10 -3
  93. package/target/main/ts/plugin.js +4 -2
  94. package/target/main/ts/plugins/coverage/coverage.d.ts +5 -2
  95. package/target/main/ts/plugins/coverage/coverage.js +35 -10
  96. package/target/main/ts/plugins/duplication/duplication.js +10 -4
  97. package/target/main/ts/plugins/language-js/babel-provider.js +8 -2
  98. package/target/main/ts/plugins/language-js/extensions.d.ts +3 -0
  99. package/target/main/ts/plugins/language-js/extensions.js +4 -0
  100. package/target/main/ts/plugins/language-js/function-facts.d.ts +1 -0
  101. package/target/main/ts/plugins/language-js/function-facts.js +30 -4
  102. package/target/main/ts/plugins/language-js/js-security.js +3 -2
  103. package/target/main/ts/report/html/app/viewer-chart-bars.d.ts +11 -0
  104. package/target/main/ts/report/html/app/viewer-chart-bars.js +54 -0
  105. package/target/main/ts/report/html/app/viewer-chart-label.d.ts +15 -0
  106. package/target/main/ts/report/html/app/viewer-chart-label.js +43 -0
  107. package/target/main/ts/report/html/app/viewer-chart-line.d.ts +24 -0
  108. package/target/main/ts/report/html/app/viewer-chart-line.js +89 -0
  109. package/target/main/ts/report/html/app/viewer-chart-points.d.ts +49 -0
  110. package/target/main/ts/report/html/app/viewer-chart-points.js +74 -0
  111. package/target/main/ts/report/html/app/viewer-chart-scale.d.ts +21 -0
  112. package/target/main/ts/report/html/app/viewer-chart-scale.js +93 -0
  113. package/target/main/ts/report/html/app/viewer-chart-svg.d.ts +28 -0
  114. package/target/main/ts/report/html/app/viewer-chart-svg.js +41 -0
  115. package/target/main/ts/report/html/app/viewer-chart-time.d.ts +26 -0
  116. package/target/main/ts/report/html/app/viewer-chart-time.js +150 -0
  117. package/target/main/ts/report/html/app/viewer-chart-tip.d.ts +4 -0
  118. package/target/main/ts/report/html/app/viewer-chart-tip.js +210 -0
  119. package/target/main/ts/report/html/app/viewer-chart-x.d.ts +12 -0
  120. package/target/main/ts/report/html/app/viewer-chart-x.js +50 -0
  121. package/target/main/ts/report/html/app/viewer-chart.d.ts +4 -98
  122. package/target/main/ts/report/html/app/viewer-chart.js +16 -677
  123. package/target/main/ts/report/html/app/viewer-code-map.d.ts +27 -0
  124. package/target/main/ts/report/html/app/viewer-code-map.js +175 -0
  125. package/target/main/ts/report/html/app/viewer-columns.d.ts +38 -0
  126. package/target/main/ts/report/html/app/viewer-columns.js +92 -0
  127. package/target/main/ts/report/html/app/viewer-commit-picker.d.ts +12 -0
  128. package/target/main/ts/report/html/app/viewer-commit-picker.js +229 -0
  129. package/target/main/ts/report/html/app/viewer-commits.d.ts +5 -9
  130. package/target/main/ts/report/html/app/viewer-commits.js +17 -216
  131. package/target/main/ts/report/html/app/viewer-controls.d.ts +43 -0
  132. package/target/main/ts/report/html/app/viewer-controls.js +141 -0
  133. package/target/main/ts/report/html/app/viewer-copy.d.ts +17 -0
  134. package/target/main/ts/report/html/app/viewer-copy.js +64 -0
  135. package/target/main/ts/report/html/app/viewer-data.d.ts +1 -1
  136. package/target/main/ts/report/html/app/viewer-data.js +2 -29
  137. package/target/main/ts/report/html/app/viewer-diagnostics.d.ts +4 -0
  138. package/target/main/ts/report/html/app/viewer-diagnostics.js +60 -0
  139. package/target/main/ts/report/html/app/viewer-dom.d.ts +27 -0
  140. package/target/main/ts/report/html/app/viewer-dom.js +99 -0
  141. package/target/main/ts/report/html/app/viewer-file-aside.d.ts +19 -0
  142. package/target/main/ts/report/html/app/viewer-file-aside.js +124 -0
  143. package/target/main/ts/report/html/app/viewer-file-figures.d.ts +15 -0
  144. package/target/main/ts/report/html/app/viewer-file-figures.js +60 -0
  145. package/target/main/ts/report/html/app/viewer-file-source.d.ts +7 -0
  146. package/target/main/ts/report/html/app/viewer-file-source.js +119 -0
  147. package/target/main/ts/report/html/app/viewer-files.d.ts +2 -118
  148. package/target/main/ts/report/html/app/viewer-files.js +24 -2184
  149. package/target/main/ts/report/html/app/viewer-filter.d.ts +3 -51
  150. package/target/main/ts/report/html/app/viewer-filter.js +111 -450
  151. package/target/main/ts/report/html/app/viewer-hotspots.d.ts +4 -0
  152. package/target/main/ts/report/html/app/viewer-hotspots.js +131 -0
  153. package/target/main/ts/report/html/app/viewer-inspection.d.ts +69 -0
  154. package/target/main/ts/report/html/app/viewer-inspection.js +36 -0
  155. package/target/main/ts/report/html/app/viewer-issue-group.d.ts +27 -0
  156. package/target/main/ts/report/html/app/viewer-issue-group.js +174 -0
  157. package/target/main/ts/report/html/app/viewer-issues.d.ts +4 -0
  158. package/target/main/ts/report/html/app/viewer-issues.js +173 -0
  159. package/target/main/ts/report/html/app/viewer-language-bar.d.ts +9 -0
  160. package/target/main/ts/report/html/app/viewer-language-bar.js +72 -0
  161. package/target/main/ts/report/html/app/viewer-languages.d.ts +27 -0
  162. package/target/main/ts/report/html/app/viewer-languages.js +93 -0
  163. package/target/main/ts/report/html/app/viewer-layout.d.ts +14 -0
  164. package/target/main/ts/report/html/app/viewer-layout.js +134 -0
  165. package/target/main/ts/report/html/app/viewer-line-coverage.d.ts +47 -0
  166. package/target/main/ts/report/html/app/viewer-line-coverage.js +121 -0
  167. package/target/main/ts/report/html/app/viewer-locations.d.ts +16 -0
  168. package/target/main/ts/report/html/app/viewer-locations.js +31 -0
  169. package/target/main/ts/report/html/app/viewer-map-scale.d.ts +26 -0
  170. package/target/main/ts/report/html/app/viewer-map-scale.js +147 -0
  171. package/target/main/ts/report/html/app/viewer-map-shape.d.ts +42 -0
  172. package/target/main/ts/report/html/app/viewer-map-shape.js +102 -0
  173. package/target/main/ts/report/html/app/viewer-metric-format.d.ts +23 -0
  174. package/target/main/ts/report/html/app/viewer-metric-format.js +93 -0
  175. package/target/main/ts/report/html/app/viewer-metric-registry.d.ts +0 -20
  176. package/target/main/ts/report/html/app/viewer-metric-registry.js +7 -84
  177. package/target/main/ts/report/html/app/viewer-metrics-view.d.ts +4 -0
  178. package/target/main/ts/report/html/app/viewer-metrics-view.js +162 -0
  179. package/target/main/ts/report/html/app/viewer-metrics.d.ts +6 -1
  180. package/target/main/ts/report/html/app/viewer-metrics.js +53 -35
  181. package/target/main/ts/report/html/app/viewer-overview-cards.d.ts +12 -0
  182. package/target/main/ts/report/html/app/viewer-overview-cards.js +118 -0
  183. package/target/main/ts/report/html/app/viewer-overview-hotspots.d.ts +9 -0
  184. package/target/main/ts/report/html/app/viewer-overview-hotspots.js +173 -0
  185. package/target/main/ts/report/html/app/viewer-overview-lead.d.ts +12 -0
  186. package/target/main/ts/report/html/app/viewer-overview-lead.js +116 -0
  187. package/target/main/ts/report/html/app/viewer-profile-badges.d.ts +11 -0
  188. package/target/main/ts/report/html/app/viewer-profile-badges.js +119 -0
  189. package/target/main/ts/report/html/app/viewer-profile-table.d.ts +29 -0
  190. package/target/main/ts/report/html/app/viewer-profile-table.js +124 -0
  191. package/target/main/ts/report/html/app/viewer-profile.d.ts +2 -6
  192. package/target/main/ts/report/html/app/viewer-profile.js +6 -248
  193. package/target/main/ts/report/html/app/viewer-pull-sections.d.ts +4 -0
  194. package/target/main/ts/report/html/app/viewer-pull-sections.js +118 -0
  195. package/target/main/ts/report/html/app/viewer-pull-trend.d.ts +5 -0
  196. package/target/main/ts/report/html/app/viewer-pull-trend.js +63 -0
  197. package/target/main/ts/report/html/app/viewer-pulls.d.ts +0 -1
  198. package/target/main/ts/report/html/app/viewer-pulls.js +28 -178
  199. package/target/main/ts/report/html/app/viewer-query-field.d.ts +19 -0
  200. package/target/main/ts/report/html/app/viewer-query-field.js +203 -0
  201. package/target/main/ts/report/html/app/viewer-route.d.ts +34 -0
  202. package/target/main/ts/report/html/app/viewer-route.js +55 -0
  203. package/target/main/ts/report/html/app/viewer-shell.d.ts +20 -0
  204. package/target/main/ts/report/html/app/viewer-shell.js +116 -0
  205. package/target/main/ts/report/html/app/viewer-source-view.d.ts +49 -0
  206. package/target/main/ts/report/html/app/viewer-source-view.js +150 -0
  207. package/target/main/ts/report/html/app/viewer-source.d.ts +0 -84
  208. package/target/main/ts/report/html/app/viewer-source.js +7 -365
  209. package/target/main/ts/report/html/app/viewer-suggest.d.ts +13 -0
  210. package/target/main/ts/report/html/app/viewer-suggest.js +91 -0
  211. package/target/main/ts/report/html/app/viewer-sunburst.d.ts +5 -0
  212. package/target/main/ts/report/html/app/viewer-sunburst.js +40 -0
  213. package/target/main/ts/report/html/app/viewer-table-cells.d.ts +25 -0
  214. package/target/main/ts/report/html/app/viewer-table-cells.js +129 -0
  215. package/target/main/ts/report/html/app/viewer-table-rows.d.ts +54 -0
  216. package/target/main/ts/report/html/app/viewer-table-rows.js +95 -0
  217. package/target/main/ts/report/html/app/viewer-tokenizer.d.ts +16 -0
  218. package/target/main/ts/report/html/app/viewer-tokenizer.js +192 -0
  219. package/target/main/ts/report/html/app/viewer-totals.d.ts +14 -0
  220. package/target/main/ts/report/html/app/viewer-totals.js +89 -0
  221. package/target/main/ts/report/html/app/viewer-treemap.d.ts +24 -0
  222. package/target/main/ts/report/html/app/viewer-treemap.js +112 -0
  223. package/target/main/ts/report/html/app/viewer-trend-data.d.ts +54 -0
  224. package/target/main/ts/report/html/app/viewer-trend-data.js +109 -0
  225. package/target/main/ts/report/html/app/viewer-trend-nav.d.ts +5 -0
  226. package/target/main/ts/report/html/app/viewer-trend-nav.js +85 -0
  227. package/target/main/ts/report/html/app/viewer-trend-points.d.ts +30 -0
  228. package/target/main/ts/report/html/app/viewer-trend-points.js +128 -0
  229. package/target/main/ts/report/html/app/viewer-trend-series.d.ts +26 -0
  230. package/target/main/ts/report/html/app/viewer-trend-series.js +98 -0
  231. package/target/main/ts/report/html/app/viewer-trends.d.ts +2 -70
  232. package/target/main/ts/report/html/app/viewer-trends.js +41 -392
  233. package/target/main/ts/report/html/app/viewer.js +152 -663
  234. package/target/main/ts/report/html/site/export-site.d.ts +3 -4
  235. package/target/main/ts/report/html/site/export-site.js +24 -41
  236. package/target/main/ts/report/html/site/exported-server.js +2 -1
  237. package/target/main/ts/report/html/site/local-server.d.ts +1 -1
  238. package/target/main/ts/report/html/site/local-server.js +13 -19
  239. package/target/main/ts/report/html/site/projects.js +8 -17
  240. package/target/main/ts/report/json/projections/commit-summary.d.ts +2 -2
  241. package/target/main/ts/report/json/projections/commit-summary.js +18 -19
  242. package/target/main/ts/report/json/projections/file-metrics.js +31 -24
  243. package/target/main/ts/report/json/projections/inspection-context.js +10 -1
  244. package/target/main/ts/report/json/projections/inspection-details.d.ts +1 -1
  245. package/target/main/ts/report/json/projections/inspection-details.js +2 -2
  246. package/target/main/ts/report/json/projections/metric-values.d.ts +1 -0
  247. package/target/main/ts/report/json/projections/metric-values.js +15 -5
  248. package/target/main/ts/report/json/store/local-store.js +2 -12
  249. package/target/main/ts/report/json/store/operation-cache.d.ts +8 -0
  250. package/target/main/ts/report/json/store/operation-cache.js +32 -0
  251. package/target/main/ts/report/json/store/pull-review-store.js +1 -2
  252. package/target/main/ts/report/json/store/replace-file.d.ts +1 -0
  253. package/target/main/ts/report/json/store/replace-file.js +14 -0
  254. package/target/main/ts/report/json/validation/report.d.ts +1 -1
  255. package/target/main/ts/report/json/validation/report.js +10 -8
  256. package/target/main/ts/report/json/validation/summary-validation.js +1 -3
  257. package/target/main/ts/report/json/wire/file-metrics-model.d.ts +2 -0
  258. package/target/main/ts/report/json/wire/inspection-details-model.d.ts +0 -5
  259. package/target/main/ts/report/json/wire/public-history-model.d.ts +0 -6
  260. package/target/main/ts/report/json/wire/public-history-model.js +0 -1
  261. package/target/main/ts/report.d.ts +3 -3
  262. package/target/main/ts/report.js +2 -2
  263. package/target/main/resources/report/json/inspection-context-v1.schema.json +0 -172
  264. package/target/main/resources/report/json/public-history-v1.schema.json +0 -50
  265. package/target/main/resources/report/json/quality-history-v1.schema.json +0 -51
  266. package/target/main/resources/report/json/report-v1.schema.json +0 -65
  267. package/target/main/resources/report/json/viewer-details-v1.schema.json +0 -346
  268. package/target/main/ts/report/json/projections/public-history.d.ts +0 -4
  269. package/target/main/ts/report/json/projections/public-history.js +0 -17
@@ -1,26 +1,20 @@
1
1
  import { realpath } from 'node:fs/promises';
2
2
  import { basename, dirname, join, relative, resolve, sep } from 'node:path';
3
- import { gitRoot, gitUtf8, readGitCommit } from './git.js';
3
+ import { gitRoot, gitWorkingTreePaths, readGitCommit } from './git.js';
4
4
  import { containsPath, readWorkingTree } from './local.js';
5
- export async function readInspectionSource(request, excludes, claims) {
5
+ export async function readInspectionSource(request, excludes, isSource, claims) {
6
6
  const root = await realpath('workingTree' in request.source ? request.directory : await gitRoot(request.directory));
7
7
  const output = await physicalPath(resolve(request.output));
8
8
  if (containsPath(output, root) || output.split(sep).includes('.git')) {
9
9
  throw new Error('Choose a dedicated report directory outside Git metadata');
10
10
  }
11
11
  const snapshot = 'workingTree' in request.source
12
- ? await readWorkingTree(root, output, excludes, await trackedClaims(root, claims))
13
- : await readGitCommit(root, request.source.revision, excludes, claims);
12
+ ? await readWorkingTree(root, output, excludes, isSource, claims, await gitWorkingTreePaths(root))
13
+ : await readGitCommit(root, request.source.revision, excludes, isSource, claims);
14
14
  const excludedOutput = snapshot.subject.kind === 'working-tree' && containsPath(root, output)
15
15
  ? relative(root, output).split(sep).join('/') : null;
16
16
  return { root, snapshot, excludedOutput, output };
17
17
  }
18
- async function trackedClaims(directory, claims) {
19
- if (!claims || !await gitRoot(directory).catch(() => undefined))
20
- return claims;
21
- const tracked = new Set((await gitUtf8(directory, ['ls-files', '--cached', '-z', '--', '.'])).split('\0'));
22
- return (path) => tracked.has(path) && claims(path);
23
- }
24
18
  async function physicalPath(path) {
25
19
  try {
26
20
  return await realpath(path);
@@ -1,3 +1,3 @@
1
1
  import type { SourceSnapshot } from '../../core/model/snapshot.js';
2
2
  export declare function containsPath(parent: string, path: string): boolean;
3
- export declare function readWorkingTree(directory: string, output: string, excludes: (path: string) => boolean, claims?: (path: string) => boolean): Promise<SourceSnapshot>;
3
+ export declare function readWorkingTree(directory: string, output: string, excludes: (path: string) => boolean, isSource: (path: string) => boolean, claims?: (path: string) => boolean, gitPaths?: readonly string[]): Promise<SourceSnapshot>;
@@ -1,13 +1,13 @@
1
1
  import { lstat, readdir, realpath, readFile } from 'node:fs/promises';
2
- import { isAbsolute, join, relative, sep } from 'node:path';
3
- import { comparePaths, isExcludedDirectory, isSourcePath, workingSnapshot } from '../../core/model/snapshot.js';
2
+ import { isAbsolute, join, posix, relative, sep } from 'node:path';
3
+ import { comparePaths, isExcludedDirectory, workingSnapshot } from '../../core/model/snapshot.js';
4
4
  import { isClaimedText, maxClaimedFileBytes } from '../../core/model/source.js';
5
5
  import { isGeneratedSource } from '../../core/profile/exclusions.js';
6
6
  export function containsPath(parent, path) {
7
7
  const rest = relative(parent, path);
8
8
  return rest === '' || (!isAbsolute(rest) && rest !== '..' && !rest.startsWith(`..${sep}`));
9
9
  }
10
- export async function readWorkingTree(directory, output, excludes, claims) {
10
+ export async function readWorkingTree(directory, output, excludes, isSource, claims, gitPaths) {
11
11
  const root = await realpath(directory);
12
12
  const files = [];
13
13
  const generatedExcluded = [];
@@ -27,8 +27,8 @@ export async function readWorkingTree(directory, output, excludes, claims) {
27
27
  await read(path, absolute);
28
28
  }
29
29
  }
30
- async function read(path, absolute) {
31
- if (isSourcePath(path)) {
30
+ async function read(path, absolute, size) {
31
+ if (isSource(path)) {
32
32
  const bytes = await readFile(absolute);
33
33
  if (isGeneratedSource(bytes))
34
34
  generatedExcluded.push(path);
@@ -38,7 +38,7 @@ export async function readWorkingTree(directory, output, excludes, claims) {
38
38
  }
39
39
  if (!claims?.(path))
40
40
  return;
41
- if ((await lstat(absolute)).size > maxClaimedFileBytes) {
41
+ if ((size ?? (await lstat(absolute)).size) > maxClaimedFileBytes) {
42
42
  oversizedClaims.push(path);
43
43
  return;
44
44
  }
@@ -48,8 +48,42 @@ export async function readWorkingTree(directory, output, excludes, claims) {
48
48
  else if (isClaimedText(bytes))
49
49
  files.push({ path, bytes });
50
50
  }
51
- await visit(root, '');
51
+ if (gitPaths === undefined) {
52
+ await visit(root, '');
53
+ }
54
+ else {
55
+ const directories = new Map([['.', true]]);
56
+ async function regularDirectory(path) {
57
+ const cached = directories.get(path);
58
+ if (cached !== undefined)
59
+ return cached;
60
+ const allowed = !isExcludedDirectory(posix.basename(path)) && await regularDirectory(posix.dirname(path))
61
+ && (await statIfPresent(join(root, path)))?.isDirectory() === true;
62
+ directories.set(path, allowed);
63
+ return allowed;
64
+ }
65
+ for (const path of gitPaths) {
66
+ const absolute = join(root, path);
67
+ if (excludes(path) || !containsPath(root, absolute) || containsPath(output, absolute))
68
+ continue;
69
+ if (!(isSource(path) || claims?.(path)) || !await regularDirectory(posix.dirname(path)))
70
+ continue;
71
+ const stat = await statIfPresent(absolute);
72
+ if (stat?.isFile())
73
+ await read(path, absolute, stat.size);
74
+ }
75
+ }
52
76
  return { ...workingSnapshot(files), generatedExcluded: generatedExcluded.sort(comparePaths),
53
77
  ...(oversizedClaims.length ? { oversizedClaims: oversizedClaims.sort(comparePaths) } : {}) };
54
78
  }
79
+ async function statIfPresent(path) {
80
+ try {
81
+ return await lstat(path);
82
+ }
83
+ catch (error) {
84
+ if (error instanceof Error && 'code' in error && (error.code === 'ENOENT' || error.code === 'ENOTDIR'))
85
+ return undefined;
86
+ throw error;
87
+ }
88
+ }
55
89
  //# sourceMappingURL=local.js.map
@@ -0,0 +1,13 @@
1
+ import type { ToolInvocation, ToolResult, ToolRunner } from '../../core/ports/tool-runner.js';
2
+ export interface DockerToolLimits {
3
+ readonly memoryBytes?: number;
4
+ readonly pidsLimit?: number;
5
+ }
6
+ export declare class DockerToolRunner implements ToolRunner {
7
+ private readonly image;
8
+ readonly network = "none";
9
+ readonly implementation: string;
10
+ private readonly limits;
11
+ constructor(image: string, { memoryBytes, pidsLimit }?: DockerToolLimits);
12
+ run(invocation: ToolInvocation): Promise<ToolResult>;
13
+ }
@@ -0,0 +1,108 @@
1
+ import { execFile } from 'node:child_process';
2
+ import { randomUUID } from 'node:crypto';
3
+ import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises';
4
+ import { tmpdir } from 'node:os';
5
+ import { dirname, join } from 'node:path';
6
+ import { promisify } from 'node:util';
7
+ import { isSourcePathname } from '../../core/ports/source-provider.js';
8
+ import { toolFailure } from './failure.js';
9
+ const docker = promisify(execFile);
10
+ const proxyOverrides = ['HTTP_PROXY', 'HTTPS_PROXY', 'FTP_PROXY', 'ALL_PROXY', 'NO_PROXY']
11
+ .flatMap(name => ['--env', `${name}=`, '--env', `${name.toLowerCase()}=`]);
12
+ export class DockerToolRunner {
13
+ image;
14
+ network = 'none';
15
+ implementation;
16
+ limits;
17
+ constructor(image, { memoryBytes, pidsLimit } = {}) {
18
+ this.image = image;
19
+ if (!image || /[\s\0]/.test(image))
20
+ throw new Error('A locally available Docker image is required');
21
+ if ([memoryBytes, pidsLimit].some(value => value !== undefined && (!Number.isSafeInteger(value) || value < 1))) {
22
+ throw new Error('Docker memory and process limits must be positive integers');
23
+ }
24
+ this.limits = [...(memoryBytes === undefined ? [] : ['--memory', String(memoryBytes)]),
25
+ ...(pidsLimit === undefined ? [] : ['--pids-limit', String(pidsLimit)])];
26
+ this.implementation = JSON.stringify(['docker-tool-runner/v2', image, this.limits]);
27
+ }
28
+ async run(invocation) {
29
+ const [command, ...args] = invocation.argv;
30
+ if (!command || invocation.argv.some(arg => arg.includes('\0')))
31
+ throw new Error('A tool command and valid arguments are required');
32
+ if (!Number.isSafeInteger(invocation.timeoutMs) || invocation.timeoutMs < 1 || invocation.timeoutMs > 2_147_483_647) {
33
+ throw new Error('Invalid tool timeout');
34
+ }
35
+ if (!Number.isSafeInteger(invocation.maxOutputBytes) || invocation.maxOutputBytes < 1)
36
+ throw new Error('Invalid tool output limit');
37
+ const paths = new Set();
38
+ for (const { path } of invocation.files) {
39
+ if (!isSourcePathname(path) || paths.has(path))
40
+ throw new Error(`Invalid or duplicate snapshot path: ${path}`);
41
+ paths.add(path);
42
+ }
43
+ const directory = await mkdtemp(join(tmpdir(), 'repometry-tool-'));
44
+ const container = `repometry-tool-${randomUUID()}`;
45
+ try {
46
+ for (const file of invocation.files) {
47
+ const path = join(directory, file.path);
48
+ await mkdir(dirname(path), { recursive: true, mode: 0o700 });
49
+ await writeFile(path, file.bytes, { mode: 0o600, flag: 'wx' });
50
+ }
51
+ const mount = `type=bind,"source=${directory.replaceAll('"', '""')}",target=/snapshot,readonly`;
52
+ const uid = process.getuid?.();
53
+ const gid = process.getgid?.();
54
+ const user = uid === undefined || gid === undefined ? [] : ['--user', `${uid}:${gid}`];
55
+ let result;
56
+ try {
57
+ result = await runTool([
58
+ 'run', '--rm', '--name', container, '--interactive', '--pull', 'never', '--network', 'none', '--read-only',
59
+ '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--tmpfs', '/tmp:rw,nosuid,nodev', '--env', 'HOME=/tmp',
60
+ ...this.limits, ...user, ...proxyOverrides,
61
+ '--mount', mount, '--workdir', '/snapshot', '--entrypoint', command, '--', this.image, ...args,
62
+ ], invocation);
63
+ }
64
+ catch (error) {
65
+ await removeContainer(container);
66
+ throw error;
67
+ }
68
+ if ([125, 126, 127].includes(result.exitCode)) {
69
+ throw new Error(toolFailure(`Docker could not start the tool (exit code ${result.exitCode})`, result.stderr));
70
+ }
71
+ return result;
72
+ }
73
+ finally {
74
+ await rm(directory, { recursive: true, force: true });
75
+ }
76
+ }
77
+ }
78
+ function runTool(args, { stdin, timeoutMs, maxOutputBytes }) {
79
+ return new Promise((resolve, reject) => {
80
+ const child = execFile('docker', args, { encoding: 'buffer', timeout: timeoutMs, maxBuffer: maxOutputBytes, killSignal: 'SIGKILL' }, (error, stdout, stderr) => {
81
+ if (error?.code === 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER' || stdout.length + stderr.length > maxOutputBytes) {
82
+ reject(new Error('Tool exceeded the output limit'));
83
+ }
84
+ else if (error?.killed) {
85
+ reject(new Error('Tool timed out'));
86
+ }
87
+ else if (error && typeof error.code !== 'number') {
88
+ reject(new Error('Could not run the Docker tool', { cause: error }));
89
+ }
90
+ else {
91
+ resolve({ exitCode: typeof error?.code === 'number' ? error.code : 0, stdout, stderr });
92
+ }
93
+ });
94
+ child.stdin?.on('error', () => { });
95
+ child.stdin?.end(stdin);
96
+ });
97
+ }
98
+ async function removeContainer(container) {
99
+ try {
100
+ await docker('docker', ['rm', '-f', '-v', container], { timeout: 5_000, maxBuffer: 16_384 });
101
+ }
102
+ catch (error) {
103
+ if (error instanceof Error && 'stderr' in error && String(error.stderr).includes('No such container'))
104
+ return;
105
+ throw new Error('Could not confirm Docker tool cleanup', { cause: error });
106
+ }
107
+ }
108
+ //# sourceMappingURL=docker-tool-runner.js.map
@@ -0,0 +1 @@
1
+ export declare function toolFailure(message: string, stderr: Uint8Array): string;
@@ -0,0 +1,12 @@
1
+ const credentialAssignment = /\b[\w.-]*(?:password|passwd|secret|token|credential|authorization|api[_-]?key|private[_-]?key)[\w.-]*["']?\s*[:=]/i;
2
+ export function toolFailure(message, stderr) {
3
+ const lines = new TextDecoder().decode(stderr).split(/\r?\n/).map(line => line.trim()).filter(Boolean).slice(-3);
4
+ const tail = lines.map(line => {
5
+ if (credentialAssignment.test(line))
6
+ return '[redacted tool output]';
7
+ return line.replace(/[\p{Cc}\p{Cf}]/gu, '').replace(/:\/\/[^/\s]+@/g, '://[redacted]@')
8
+ .replace(/[A-Za-z0-9_+=-]{32,}/g, '[redacted]').slice(0, 240);
9
+ });
10
+ return tail.length ? `${message}\n${tail.join('\n')}` : message;
11
+ }
12
+ //# sourceMappingURL=failure.js.map
@@ -0,0 +1,10 @@
1
+ import type { Operation, Plugin } from '../../core/engine/plugin.js';
2
+ import type { ToolInvocation, ToolRunner } from '../../core/ports/tool-runner.js';
3
+ export declare const processPluginProtocol = "repometry.plugin-process/v1";
4
+ export interface ProcessOperation extends Omit<Operation, 'execute'>, Pick<ToolInvocation, 'argv' | 'timeoutMs' | 'maxOutputBytes'> {
5
+ }
6
+ export interface ProcessPluginManifest extends Omit<Plugin, 'operations' | 'tools'> {
7
+ readonly operations: readonly ProcessOperation[];
8
+ readonly tools: Readonly<Record<string, string>>;
9
+ }
10
+ export declare function processPlugin({ operations, ...manifest }: ProcessPluginManifest, runner: ToolRunner): Plugin;
@@ -0,0 +1,96 @@
1
+ import { isRecord } from '../../core/engine/plugin.js';
2
+ import { isJsonValue } from '../../core/model/plugin-data.js';
3
+ import { digest, sourceFile, sourceFiles, utf8 } from '../../core/model/snapshot.js';
4
+ import { toolFailure } from './failure.js';
5
+ export const processPluginProtocol = 'repometry.plugin-process/v1';
6
+ export function processPlugin({ operations, ...manifest }, runner) {
7
+ if (runner.network !== 'none')
8
+ throw new Error('Process plugins require a runner with networking disabled');
9
+ const versions = Object.values(manifest.tools);
10
+ if (versions.length === 0 || versions.some(version => typeof version !== 'string' || !version.trim())) {
11
+ throw new Error('Process plugins must declare their tool versions');
12
+ }
13
+ return { ...manifest, operations: operations.map(operation => bindOperation(manifest.id, manifest.settings ?? null, operation, runner)) };
14
+ }
15
+ function bindOperation(plugin, settings, operation, runner) {
16
+ const { id, role, scope, inputs, output, argv, timeoutMs, maxOutputBytes } = operation;
17
+ const implementation = digest(JSON.stringify([processPluginProtocol, operation.implementation, runner.implementation, argv, timeoutMs, maxOutputBytes]));
18
+ return { id, role, scope, inputs, output, implementation, async execute(context) {
19
+ const { files, stdin } = encodeRequest(`${plugin}/${id}`, settings, operation, context);
20
+ const result = await runner.run({ argv, timeoutMs, maxOutputBytes, files, stdin });
21
+ if (result.exitCode !== 0)
22
+ throw new Error(toolFailure(`Process plugin exited with code ${result.exitCode}`, result.stderr));
23
+ return decodeResponse(result.stdout, output.id, context);
24
+ } };
25
+ }
26
+ function encodeRequest(key, settings, operation, context) {
27
+ const files = new Map();
28
+ function referenceFile(file) {
29
+ const reference = { path: file.path, sha256: digest(file.bytes) };
30
+ const existing = files.get(file.path);
31
+ if (existing && existing.reference.sha256 !== reference.sha256)
32
+ throw new Error(`Conflicting process input file: ${file.path}`);
33
+ files.set(file.path, { file, reference });
34
+ return reference;
35
+ }
36
+ const inputs = Object.fromEntries(Object.entries(operation.inputs).map(([port, contract]) => {
37
+ const value = context.read(port, contract);
38
+ if (contract.id === sourceFile.id) {
39
+ if (!sourceFile.accepts(value))
40
+ throw new Error(`Invalid process input file: ${key}.${port}`);
41
+ return [port, { contract: contract.id, file: referenceFile(value) }];
42
+ }
43
+ if (contract.id === sourceFiles.id) {
44
+ if (!sourceFiles.accepts(value))
45
+ throw new Error(`Invalid process input file set: ${key}.${port}`);
46
+ return [port, { contract: contract.id, files: value.map(referenceFile) }];
47
+ }
48
+ if (!isJsonValue(value))
49
+ throw new Error(`Process input must be JSON data: ${key}.${port}`);
50
+ return [port, { contract: contract.id, value }];
51
+ }));
52
+ const entries = [...files.values()];
53
+ const request = { protocol: processPluginProtocol, operation: key, settings, files: entries.map(({ reference }) => reference), inputs };
54
+ return { files: entries.map(({ file }) => file), stdin: Buffer.from(`${JSON.stringify(request)}\n`) };
55
+ }
56
+ function decodeResponse(bytes, contract, context) {
57
+ let product;
58
+ for (const line of utf8(bytes).split(/\r?\n/)) {
59
+ if (!line.trim())
60
+ continue;
61
+ let entry;
62
+ try {
63
+ entry = JSON.parse(line);
64
+ }
65
+ catch {
66
+ throw new Error('Invalid JSON Lines output from the process plugin');
67
+ }
68
+ if (!isRecord(entry))
69
+ throw new Error('Invalid process plugin output record');
70
+ if (entry.kind === 'diagnostic') {
71
+ readDiagnostic(entry, context);
72
+ continue;
73
+ }
74
+ if (entry.kind !== 'product' || entry.contract !== contract || product !== undefined || !isJsonValue(entry.value)) {
75
+ throw new Error('Expected one declared product from the process plugin');
76
+ }
77
+ product = entry.value;
78
+ }
79
+ if (product === undefined)
80
+ throw new Error('Missing declared product from the process plugin');
81
+ return product;
82
+ }
83
+ function readDiagnostic(entry, context) {
84
+ if (typeof entry.message !== 'string' || !entry.message.trim())
85
+ throw new Error('Invalid process plugin diagnostic message');
86
+ switch (entry.severity) {
87
+ case undefined:
88
+ case 'info': return;
89
+ case 'warning':
90
+ context.emitDiagnostic?.(entry.message);
91
+ return;
92
+ case 'error': throw new Error(entry.message);
93
+ default: throw new Error('Invalid process plugin diagnostic severity');
94
+ }
95
+ }
96
+ //# sourceMappingURL=plugin.js.map
@@ -1,2 +1,2 @@
1
1
  import type { AnalysisExecutor } from '../../core/usecases/inspect.js';
2
- export declare function remoteExecutor(endpoint: string, token: string): AnalysisExecutor;
2
+ export declare function remoteExecutor(endpoint: string, token: string, isSource: (path: string) => boolean): AnalysisExecutor;
@@ -1,6 +1,6 @@
1
1
  import { readReport } from '../../report/json/validation/report.js';
2
2
  import { encodeWorkerInput, maxWorkerInput, maxWorkerResult, workerRoute } from './worker-protocol.js';
3
- export function remoteExecutor(endpoint, token) {
3
+ export function remoteExecutor(endpoint, token, isSource) {
4
4
  const base = new URL(endpoint);
5
5
  const local = ['127.0.0.1', '[::1]', 'localhost'].includes(base.hostname);
6
6
  if (base.protocol !== 'https:' && !(base.protocol === 'http:' && local)) {
@@ -10,7 +10,7 @@ export function remoteExecutor(endpoint, token) {
10
10
  throw new Error('Invalid worker base URL');
11
11
  base.pathname = base.pathname.replace(/\/+$/, '') + workerRoute;
12
12
  return async (input) => {
13
- const body = encodeWorkerInput(input);
13
+ const body = encodeWorkerInput(input, isSource);
14
14
  if (Buffer.byteLength(body) > maxWorkerInput)
15
15
  throw new Error('Worker input exceeds 16 MiB');
16
16
  const response = await fetch(base, { method: 'POST', headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
@@ -3,5 +3,5 @@ export declare const workerRoute = "/v1/inspect";
3
3
  export declare const maxWorkerInput: number;
4
4
  export declare const maxWorkerResult: number;
5
5
  export declare function workerToken(value?: string | undefined): string;
6
- export declare function encodeWorkerInput(input: AnalysisInput): string;
7
- export declare function decodeWorkerInput(value: unknown): AnalysisInput;
6
+ export declare function encodeWorkerInput(input: AnalysisInput, isSource: (path: string) => boolean): string;
7
+ export declare function decodeWorkerInput(value: unknown, isSource: (path: string) => boolean): AnalysisInput;
@@ -1,7 +1,7 @@
1
1
  import { isRecord } from '../../core/engine/plugin.js';
2
2
  import { validSubjectId } from '../../report/json/validation/report.js';
3
3
  import { exclusionMatcher, normalizeExclusions, sourceExclusionMatcher } from '../../core/profile/exclusions.js';
4
- import { comparePaths, isExcludedDirectory, isSourcePath, workingSnapshot } from '../../core/model/snapshot.js';
4
+ import { comparePaths, isExcludedDirectory, workingSnapshot } from '../../core/model/snapshot.js';
5
5
  import { isClaimedText } from '../../core/model/source.js';
6
6
  const schemaV1 = 'urn:repometry:schema:worker-input:1';
7
7
  const schemaV2 = 'urn:repometry:schema:worker-input:2';
@@ -14,17 +14,17 @@ export function workerToken(value = process.env.REPOMETRY_WORKER_TOKEN) {
14
14
  throw new Error('Set REPOMETRY_WORKER_TOKEN before using the worker');
15
15
  return value;
16
16
  }
17
- export function encodeWorkerInput(input) {
17
+ export function encodeWorkerInput(input, isSource) {
18
18
  const { subject, files, inventory, generatedExcluded, oversizedClaims } = input.snapshot;
19
19
  const excludedPaths = input.excludedPaths ?? [];
20
- const hasClaims = oversizedClaims?.length || files.some(file => !isSourcePath(file.path));
20
+ const hasClaims = oversizedClaims?.length || files.some(file => !isSource(file.path));
21
21
  const profile = hasClaims ? { schema: schemaV3, excludedPaths, oversizedClaims: oversizedClaims ?? [] }
22
22
  : excludedPaths.length === 0 ? { schema: schemaV1 } : { schema: schemaV2, excludedPaths };
23
23
  return JSON.stringify({ ...profile, subject, excludedOutput: input.excludedOutput, coverage: input.coverage ?? null,
24
24
  files: files.map(({ path, bytes }) => ({ path, base64: Buffer.from(bytes).toString('base64') })),
25
25
  ...(inventory === undefined ? {} : { inventory }), ...(generatedExcluded?.length ? { generatedExcluded } : {}) });
26
26
  }
27
- export function decodeWorkerInput(value) {
27
+ export function decodeWorkerInput(value, isSource) {
28
28
  if (!isRecord(value) || (value.schema !== schemaV1 && value.schema !== schemaV2 && value.schema !== schemaV3)
29
29
  || !isSubject(value.subject) || !Array.isArray(value.files)) {
30
30
  throw new Error('Invalid worker input envelope');
@@ -48,7 +48,7 @@ export function decodeWorkerInput(value) {
48
48
  const bytes = Buffer.from(item.base64, 'base64');
49
49
  if (bytes.toString('base64') !== item.base64)
50
50
  throw new Error('Invalid worker source encoding');
51
- if (!isSourcePath(item.path) && (value.schema !== schemaV3 || !isClaimedText(bytes) || excludedParent(item.path))) {
51
+ if (!isSource(item.path) && (value.schema !== schemaV3 || !isClaimedText(bytes) || excludedParent(item.path))) {
52
52
  throw new Error('Invalid worker claimed file');
53
53
  }
54
54
  paths.add(item.path);
@@ -59,7 +59,7 @@ export function decodeWorkerInput(value) {
59
59
  }
60
60
  files.sort((a, b) => comparePaths(a.path, b.path));
61
61
  const inventory = readInventory(value.inventory, excludes);
62
- const generatedExcluded = readGeneratedExclusions(value.generatedExcluded, paths, inventory);
62
+ const generatedExcluded = readGeneratedExclusions(value.generatedExcluded, paths, isSource, inventory);
63
63
  const oversizedClaims = value.schema === schemaV3 ? readOversizedClaims(value.oversizedClaims, paths, excludes) : [];
64
64
  return { snapshot: { subject, files, ...(inventory === undefined ? {} : { inventory }), generatedExcluded,
65
65
  ...(oversizedClaims.length ? { oversizedClaims } : {}) },
@@ -80,7 +80,7 @@ function readOversizedClaims(value, paths, excludes) {
80
80
  function excludedParent(path) {
81
81
  return path.split('/').slice(0, -1).some(isExcludedDirectory);
82
82
  }
83
- function readGeneratedExclusions(value, sourcePaths, inventory) {
83
+ function readGeneratedExclusions(value, sourcePaths, isSource, inventory) {
84
84
  if (value === undefined)
85
85
  return [];
86
86
  if (!Array.isArray(value))
@@ -88,7 +88,7 @@ function readGeneratedExclusions(value, sourcePaths, inventory) {
88
88
  const listed = new Set([...sourcePaths, ...(inventory ?? []).map(file => file.path)]);
89
89
  const excluded = new Set();
90
90
  for (const path of value) {
91
- if (typeof path !== 'string' || !safePath(path) || !isSourcePath(path) || listed.has(path) || excluded.has(path)) {
91
+ if (typeof path !== 'string' || !safePath(path) || !isSource(path) || listed.has(path) || excluded.has(path)) {
92
92
  throw new Error('Invalid worker generated exclusion');
93
93
  }
94
94
  excluded.add(path);
@@ -1,5 +1,5 @@
1
1
  import type { AnalysisExecutor } from '../../core/usecases/inspect.js';
2
- export declare function serveWorker(host: '127.0.0.1' | '0.0.0.0', port: number, token: string, analyze: AnalysisExecutor): Promise<{
2
+ export declare function serveWorker(host: '127.0.0.1' | '0.0.0.0', port: number, token: string, analyze: AnalysisExecutor, isSource: (path: string) => boolean): Promise<{
3
3
  url: string;
4
4
  close: () => void;
5
5
  }>;
@@ -2,7 +2,7 @@ import { timingSafeEqual } from 'node:crypto';
2
2
  import { createServer } from 'node:http';
3
3
  import { utf8 } from '../../core/model/snapshot.js';
4
4
  import { decodeWorkerInput, maxWorkerInput, maxWorkerResult, workerRoute } from './worker-protocol.js';
5
- export async function serveWorker(host, port, token, analyze) {
5
+ export async function serveWorker(host, port, token, analyze, isSource) {
6
6
  let busy = false;
7
7
  const server = createServer({ headersTimeout: 10_000, requestTimeout: 30_000, connectionsCheckingInterval: 5_000 }, (request, response) => {
8
8
  if (request.url !== workerRoute) {
@@ -22,7 +22,7 @@ export async function serveWorker(host, port, token, analyze) {
22
22
  return;
23
23
  }
24
24
  busy = true;
25
- void handle(request, response, analyze).finally(() => { busy = false; });
25
+ void handle(request, response, analyze, isSource).finally(() => { busy = false; });
26
26
  });
27
27
  await new Promise((resolve, reject) => {
28
28
  server.once('error', reject);
@@ -35,7 +35,7 @@ export async function serveWorker(host, port, token, analyze) {
35
35
  }
36
36
  return { url: `http://${host}:${address.port}/`, close: () => server.close() };
37
37
  }
38
- async function handle(request, response, analyze) {
38
+ async function handle(request, response, analyze, isSource) {
39
39
  const declared = Number(request.headers['content-length']);
40
40
  if (declared > maxWorkerInput) {
41
41
  reply(response, 413, 'Worker input exceeds 16 MiB');
@@ -54,7 +54,7 @@ async function handle(request, response, analyze) {
54
54
  }
55
55
  parts.push(bytes);
56
56
  }
57
- payload = decodeWorkerInput(JSON.parse(utf8(Buffer.concat(parts))));
57
+ payload = decodeWorkerInput(JSON.parse(utf8(Buffer.concat(parts))), isSource);
58
58
  }
59
59
  catch {
60
60
  reply(response, 400, 'Invalid worker input');
@@ -8,6 +8,7 @@ import { writeGitHubDiffCoverage, writeGitHubResult, writeGitHubReview } from '.
8
8
  import { remoteExecutor } from '../api/worker/remote-executor.js';
9
9
  import { serveWorker } from '../api/worker/worker.js';
10
10
  import { workerToken } from '../api/worker/worker-protocol.js';
11
+ import { defaultLanguages } from '../compose/languages.js';
11
12
  import { analyzeSnapshot, attachFindings, inspect } from '../compose/inspect.js';
12
13
  import { measureDiffCoverage } from '../compose/diff-coverage.js';
13
14
  import { prepareMetabranch } from '../compose/prepare-metabranch.js';
@@ -139,7 +140,7 @@ const commands = {
139
140
  const host = input.text('listen') ?? '127.0.0.1';
140
141
  if (host !== '127.0.0.1' && host !== '0.0.0.0')
141
142
  throw new Error('--listen must be 127.0.0.1 or 0.0.0.0');
142
- announce(await serveWorker(host, port(input.text('port') ?? '7331'), workerToken(), analyzeSnapshot));
143
+ announce(await serveWorker(host, port(input.text('port') ?? '7331'), workerToken(), analyzeSnapshot, defaultLanguages.isSource));
143
144
  } },
144
145
  };
145
146
  async function context(input) {
@@ -172,7 +173,7 @@ async function analyze(input) {
172
173
  const report = skipped ? await store.reader.read({ kind: 'commit', id: savedId })
173
174
  : await inspect({ directory, output, source: input.flag('working-tree') ? { workingTree: true } : { revision },
174
175
  lcov, exclude: [...config.exclude, ...input.many('exclude')], ignore: config.ignore,
175
- findingInputs: findings, findingRoot: importRoot ? resolve(directory, importRoot) : undefined }, worker === undefined ? undefined : remoteExecutor(worker, workerToken()));
176
+ findingInputs: findings, findingRoot: importRoot ? resolve(directory, importRoot) : undefined }, worker === undefined ? undefined : remoteExecutor(worker, workerToken(), defaultLanguages.isSource));
176
177
  if (github)
177
178
  await writeGitHubResult(report);
178
179
  const requested = input.many('report');
@@ -199,7 +200,7 @@ async function analyzeRange(input, range) {
199
200
  if (!commits.length)
200
201
  process.stderr.write(`No commits in ${range.base}..${range.head}.\n`);
201
202
  const worker = input.text('worker');
202
- const executor = worker === undefined ? undefined : remoteExecutor(worker, workerToken());
203
+ const executor = worker === undefined ? undefined : remoteExecutor(worker, workerToken(), defaultLanguages.isSource);
203
204
  const exclude = [...config.exclude, ...input.many('exclude')];
204
205
  const analyzed = [], partial = [], skipped = [];
205
206
  const failed = [];
@@ -3,7 +3,7 @@ import type { Invocation } from './arguments.js';
3
3
  import type { Store } from './store.js';
4
4
  declare const reporters: {
5
5
  readonly html: '.repometry/report/html';
6
- readonly json: '.repometry/report/history.json';
6
+ readonly json: '.repometry/report/summary.json';
7
7
  };
8
8
  export declare const reporterIds: string[];
9
9
  export declare function outputReports(root: string, store: Store, requested: readonly string[], input: Invocation, config: Awaited<ReturnType<typeof readConfig>>): Promise<{
@@ -12,7 +12,7 @@ import { readComponents } from '../report/json/store/components.js';
12
12
  import { listPullReviews } from '../report/json/store/pull-review-store.js';
13
13
  import { readConfig } from './config.js';
14
14
  import { findRepository, invocationDirectory, isDirectory, selectStore } from './store.js';
15
- const reporters = { html: '.repometry/report/html', json: '.repometry/report/history.json' };
15
+ const reporters = { html: '.repometry/report/html', json: '.repometry/report/summary.json' };
16
16
  export const reporterIds = Object.keys(reporters);
17
17
  export async function outputReports(root, store, requested, input, config) {
18
18
  const output = input.text('output');
@@ -0,0 +1,13 @@
1
+ import type { OperationCacheOptions } from '../core/engine/operation-cache.js';
2
+ import type { PlannedOperation } from '../core/engine/plan.js';
3
+ import type { CloneSource } from '../core/model/clone-source.js';
4
+ import type { CodeStructure } from '../core/model/code-structure.js';
5
+ import type { SourceLineRange } from '../core/model/source.js';
6
+ import type { AnalysisResults } from './analysis-results.js';
7
+ import type { AnalysisSources } from './analysis-sources.js';
8
+ export declare const defaultFilePlan: readonly PlannedOperation[];
9
+ export interface FileAnalysis {
10
+ readonly cloneSources: readonly CloneSource[];
11
+ readonly functionBodies: ReadonlyMap<string, readonly SourceLineRange[]>;
12
+ }
13
+ export declare function inspectFiles(sources: AnalysisSources, batchFacts: ReadonlyMap<string, CodeStructure>, results: AnalysisResults, withCoverage: boolean, cache?: OperationCacheOptions): Promise<FileAnalysis>;