@namewta/skills-hub 0.1.49 → 0.1.52

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 (254) hide show
  1. package/README.md +4 -1
  2. package/THIRD_PARTY_NOTICES.md +19 -7
  3. package/cli.mjs +2 -2
  4. package/install.mjs +11 -4
  5. package/package.json +1 -1
  6. package/scripts/persistence/home.md +1 -1
  7. package/skills/dev/dev-build/SKILL.md +2 -0
  8. package/skills/dev/dev-build/references/implement-request.md +7 -2
  9. package/skills/dev/dev-formal-verify/SKILL.md +2 -1
  10. package/skills/dev/dev-formal-verify/references/create-check.md +3 -1
  11. package/skills/dev/dev-formal-verify/references/example.md +1 -1
  12. package/skills/dev/dev-formal-verify/references/tool-choice.md +1 -1
  13. package/skills/dev/dev-help/references/capabilities.md +6 -6
  14. package/skills/dev/dev-help/references/guide-verification.md +7 -1
  15. package/skills/dev/dev-help/references/help-method.md +7 -1
  16. package/skills/dev/dev-issue/SKILL.md +1 -0
  17. package/skills/dev/dev-issue/references/github-operations.md +8 -0
  18. package/skills/dev/dev-plan/references/plan-template.md +1 -0
  19. package/skills/dev/dev-plan/references/vertical-slicing.md +2 -0
  20. package/skills/dev/dev-pr/references/pull-request-evidence.md +2 -0
  21. package/skills/dev/dev-review/references/host-parity.md +12 -0
  22. package/skills/dev/dev-review/references/review-baseline.md +2 -0
  23. package/skills/dev/dev-setup/references/formal-options.md +1 -1
  24. package/skills/dev/dev-statechart/SKILL.md +17 -19
  25. package/skills/dev/dev-statechart/agents/openai.yaml +3 -3
  26. package/skills/dev/dev-statechart/assets/theme.css +135 -0
  27. package/skills/dev/dev-statechart/references/lean-proof.md +47 -0
  28. package/skills/dev/dev-statechart/references/render.md +15 -83
  29. package/skills/dev/dev-statechart/references/runtime.md +21 -1
  30. package/skills/dev/dev-statechart/scripts/lean/backends/lemma-chart.mjs +285 -0
  31. package/skills/dev/dev-statechart/scripts/lean/backends/mermaid.mjs +174 -0
  32. package/skills/dev/dev-statechart/scripts/lean/backends/proof-chart.mjs +540 -0
  33. package/skills/dev/dev-statechart/scripts/lean/backends/report.mjs +242 -0
  34. package/skills/dev/dev-statechart/scripts/lean/frontends/facts.mjs +234 -0
  35. package/skills/dev/dev-statechart/scripts/lean/frontends/view.mjs +217 -0
  36. package/skills/dev/dev-statechart/scripts/lean/ir.mjs +226 -0
  37. package/skills/dev/dev-statechart/scripts/lean/passes/attribute.mjs +148 -0
  38. package/skills/dev/dev-statechart/scripts/lean/passes/blocks.mjs +32 -0
  39. package/skills/dev/dev-statechart/scripts/lean/passes/budget.mjs +167 -0
  40. package/skills/dev/dev-statechart/scripts/lean/passes/check.mjs +70 -0
  41. package/skills/dev/dev-statechart/scripts/lean/passes/contract.mjs +160 -0
  42. package/skills/dev/dev-statechart/scripts/lean/passes/fold.mjs +206 -0
  43. package/skills/dev/dev-statechart/scripts/lean/passes/inline.mjs +84 -0
  44. package/skills/dev/dev-statechart/scripts/lean/passes/mark.mjs +432 -0
  45. package/skills/dev/dev-statechart/scripts/lean/passes/reduce.mjs +73 -0
  46. package/skills/dev/dev-statechart/scripts/lean/passes/trust.mjs +111 -0
  47. package/skills/dev/dev-statechart/scripts/lean/passes/view-lemmas.mjs +155 -0
  48. package/skills/dev/dev-statechart/scripts/lean/pipeline.mjs +164 -0
  49. package/skills/dev/dev-statechart/scripts/lean/run.mjs +168 -0
  50. package/skills/dev/dev-statechart/scripts/statechart.mjs +42 -23
  51. package/skills/dev/dev-statechart/scripts/worker.mjs +33 -7
  52. package/skills/dev/dev-ui-design/SKILL.md +2 -2
  53. package/skills/dev/dev-ui-design/references/interaction-review.md +9 -0
  54. package/skills/dev/dev-verify/SKILL.md +1 -1
  55. package/skills/dev/dev-verify/references/evidence-storage.md +12 -0
  56. package/skills/dev/dev-workflow/SKILL.md +6 -6
  57. package/skills/dev/dev-workflow/references/method-handoffs.md +7 -1
  58. package/skills/dev/dev-writing/SKILL.md +2 -0
  59. package/skills/dev/dev-writing/references/library-docs.md +37 -0
  60. package/skills/home/home-doctor/references/diagnosis.md +2 -2
  61. package/skills/home/home-doctor/scripts/doctor.mjs +68 -38
  62. package/skills/home/home-project-changelog/SKILL.md +7 -7
  63. package/skills/home/home-project-changelog/assets/project-changelog.example.json +188 -0
  64. package/skills/home/home-project-changelog/assets/project-changelog.schema.json +156 -0
  65. package/skills/home/home-project-changelog/assets/worker-brief.md +1 -1
  66. package/skills/home/home-project-changelog/references/git-ranges.md +2 -2
  67. package/skills/home/home-project-changelog/references/schema.md +61 -0
  68. package/skills/home/home-project-changelog/references/tools.md +28 -22
  69. package/skills/home/home-project-changelog/references/workflow.md +12 -9
  70. package/skills/home/home-project-changelog/references/writing.md +5 -3
  71. package/skills/home/home-project-changelog/scripts/changelog.mjs +42 -38
  72. package/skills/home/home-project-changelog/scripts/contract.mjs +40 -3
  73. package/skills/home/home-project-changelog/scripts/legacy-markdown.mjs +116 -0
  74. package/skills/home/home-project-changelog/scripts/migrate.mjs +122 -0
  75. package/skills/home/home-project-changelog/scripts/revision.mjs +2 -196
  76. package/skills/home/home-project-changelog/scripts/storage.mjs +120 -125
  77. package/skills/home/home-project-changelog/scripts/summary.mjs +0 -60
  78. package/skills/home/home-route/SKILL.md +2 -2
  79. package/skills/home/home-route/references/routing.md +3 -1
  80. package/skills/home/home-route/scripts/route.mjs +79 -11
  81. package/skills/home/home-setup/SKILL.md +2 -1
  82. package/skills/home/home-setup/assets/repos.schema.json +10 -0
  83. package/skills/home/home-setup/references/registry.md +18 -1
  84. package/skills/home/home-setup/scripts/registry.mjs +67 -7
  85. package/skills/home/home-website/SKILL.md +13 -9
  86. package/skills/home/home-website/assets/website/scripts/inputs.mjs +143 -128
  87. package/skills/home/home-website/assets/website/scripts/render.mjs +8 -6
  88. package/skills/home/home-website/assets/website/scripts/site.mjs +21 -10
  89. package/skills/home/home-website/assets/website/site/public/home-assets/app.js +81 -34
  90. package/skills/home/home-website/assets/website/site/public/home-assets/site.css +92 -70
  91. package/skills/home/home-website/assets/website/site/templates/favicon.png +0 -0
  92. package/skills/home/home-website/assets/website/site/templates/layout.mjs +13 -10
  93. package/skills/home/home-website/assets/website/site/templates/ledger.mjs +51 -46
  94. package/skills/home/home-website/assets/website/site/templates/model.mjs +58 -14
  95. package/skills/home/home-website/assets/website/site/templates/pages.mjs +28 -30
  96. package/skills/home/home-website/assets/website/site/templates/project-logs.mjs +3 -107
  97. package/skills/home/home-website/assets/website/site.config.json +1 -1
  98. package/skills/home/home-website/references/website.md +64 -46
  99. package/skills/home/home-website/scripts/activate.mjs +106 -0
  100. package/skills/home/home-website/scripts/init.mjs +98 -11
  101. package/skills/home/home-workflow/SKILL.md +6 -4
  102. package/skills/system/system-clash-proxy-config/SKILL.md +21 -0
  103. package/skills/system/system-clash-proxy-config/agents/openai.yaml +4 -0
  104. package/skills/system/system-clash-proxy-config/assets/clash-override.js +328 -0
  105. package/skills/system/{system-proxy → system-clash-proxy-config}/references/browser-privacy.md +2 -2
  106. package/skills/system/{system-config → system-clash-proxy-config}/references/changes.md +2 -2
  107. package/skills/system/{system-proxy → system-clash-proxy-config}/references/clash-verge.md +1 -1
  108. package/skills/system/{system-proxy → system-clash-proxy-config}/references/diagnosis.md +1 -1
  109. package/skills/system/system-clash-proxy-config/references/dns-workflow.md +42 -0
  110. package/skills/system/system-clash-proxy-config/references/egress-macos.md +31 -0
  111. package/skills/system/system-clash-proxy-config/references/egress-windows.md +37 -0
  112. package/skills/system/system-clash-proxy-config/references/egress.md +12 -0
  113. package/skills/system/{system-proxy → system-clash-proxy-config}/references/flclash.md +1 -1
  114. package/skills/system/{system-proxy → system-clash-proxy-config}/references/index.md +1 -1
  115. package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/linux-cutover.md +29 -0
  116. package/skills/system/system-clash-proxy-config/references/locale-workflow.md +9 -0
  117. package/skills/system/{system-proxy → system-clash-proxy-config}/references/mihomo.md +1 -25
  118. package/skills/system/system-clash-proxy-config/references/session.md +34 -0
  119. package/skills/system/system-clash-proxy-config/references/subscription.md +29 -0
  120. package/skills/system/{system-proxy → system-clash-proxy-config}/references/troubleshooting.md +7 -7
  121. package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/verification.md +2 -0
  122. package/skills/system/system-clash-proxy-config/scripts/prepare-session.mjs +155 -0
  123. package/skills/system/system-clash-proxy-config/scripts/run-session.mjs +138 -0
  124. package/skills/system/system-inspect/SKILL.md +1 -1
  125. package/skills/system/system-inspect/references/health-audit.md +1 -1
  126. package/upstream-skills/zh-archify/SKILL.md +11 -11
  127. package/upstream-skills/zh-archify/assets/template.html +6 -3
  128. package/upstream-skills/zh-archify/bin/archify.mjs +67 -4
  129. package/upstream-skills/zh-archify/modules/code-analysis/ARCHITECTURE.md +7 -1
  130. package/upstream-skills/zh-archify/modules/code-analysis/bin/analyze-run.mjs +2 -1
  131. package/upstream-skills/zh-archify/modules/code-analysis/bin/check.mjs +29 -15
  132. package/upstream-skills/zh-archify/modules/code-analysis/bin/drift.mjs +3 -3
  133. package/upstream-skills/zh-archify/modules/code-analysis/bin/prepare.mjs +5 -6
  134. package/upstream-skills/zh-archify/modules/code-analysis/bin/serve.mjs +66 -36
  135. package/upstream-skills/zh-archify/modules/code-analysis/bin/verify-change.mjs +43 -13
  136. package/upstream-skills/zh-archify/modules/code-analysis/docs/TECH-GUIDE.md +1 -1
  137. package/upstream-skills/zh-archify/modules/code-analysis/docs/USAGE.md +37 -4
  138. package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/functions.mjs +7 -5
  139. package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/index.mjs +4 -1
  140. package/upstream-skills/zh-archify/modules/code-analysis/extract/ts/snapshot-host.mjs +9 -0
  141. package/upstream-skills/zh-archify/modules/code-analysis/lib/architecture-drift.mjs +28 -7
  142. package/upstream-skills/zh-archify/modules/code-analysis/lib/drift-capture.mjs +4 -3
  143. package/upstream-skills/zh-archify/modules/code-analysis/lib/git-sources.mjs +5 -3
  144. package/upstream-skills/zh-archify/modules/code-analysis/lib/output.mjs +272 -0
  145. package/upstream-skills/zh-archify/modules/code-analysis/lib/pull-request.mjs +34 -4
  146. package/upstream-skills/zh-archify/modules/code-analysis/lib/task.mjs +4 -2
  147. package/upstream-skills/zh-archify/modules/code-analysis/lib/verification-context.mjs +13 -1
  148. package/upstream-skills/zh-archify/modules/code-analysis/lib/verification-history.mjs +112 -0
  149. package/upstream-skills/zh-archify/modules/code-analysis/lib/verification.mjs +6 -2
  150. package/upstream-skills/zh-archify/modules/code-analysis/overlay/atlas.mjs +71 -5
  151. package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas.css +16 -2
  152. package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas.js +121 -5
  153. package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/atlas3d.js +38 -1
  154. package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/overlay.css +14 -1
  155. package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/overlay.js +187 -27
  156. package/upstream-skills/zh-archify/modules/code-analysis/overlay/client/verification.js +1 -1
  157. package/upstream-skills/zh-archify/modules/code-analysis/overlay/i18n.mjs +9 -0
  158. package/upstream-skills/zh-archify/modules/code-analysis/overlay/inject.mjs +1 -1
  159. package/upstream-skills/zh-archify/modules/code-analysis/overlay/page.mjs +11 -6
  160. package/upstream-skills/zh-archify/modules/code-analysis/overlay/pull-request.mjs +1 -1
  161. package/upstream-skills/zh-archify/modules/code-analysis/schemas/ai-task.schema.json +1 -0
  162. package/upstream-skills/zh-archify/modules/code-analysis/test/atlas.test.mjs +88 -0
  163. package/upstream-skills/zh-archify/modules/code-analysis/test/duplicates.test.mjs +1 -1
  164. package/upstream-skills/zh-archify/modules/code-analysis/test/external-workflow.test.mjs +1 -1
  165. package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/boundary.task.json +1 -0
  166. package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/boundary.task.missing.json +1 -0
  167. package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/complexity.task.json +1 -0
  168. package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/complexity.task.valid.json +1 -0
  169. package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/import-cycle.task.changed.json +1 -0
  170. package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/import-cycle.task.json +1 -0
  171. package/upstream-skills/zh-archify/modules/code-analysis/test/fixtures/tasks/module-cycle.task.json +1 -0
  172. package/upstream-skills/zh-archify/modules/code-analysis/test/function-source-range.test.mjs +10 -0
  173. package/upstream-skills/zh-archify/modules/code-analysis/test/output-recovery.test.mjs +626 -0
  174. package/upstream-skills/zh-archify/modules/code-analysis/test/pull-request.test.mjs +98 -2
  175. package/upstream-skills/zh-archify/modules/code-analysis/test/review.test.mjs +37 -0
  176. package/upstream-skills/zh-archify/modules/code-analysis/test/source-panel.test.mjs +2 -1
  177. package/upstream-skills/zh-archify/modules/code-analysis/test/task.test.mjs +3 -2
  178. package/upstream-skills/zh-archify/modules/code-analysis/test/verification-history.test.mjs +216 -0
  179. package/upstream-skills/zh-archify/modules/code-analysis/test/verification.test.mjs +122 -0
  180. package/upstream-skills/zh-archify/package-lock.json +2 -2
  181. package/upstream-skills/zh-archify/package.json +1 -1
  182. package/upstream-skills/zh-archify/references/authoring-contract.md +2 -0
  183. package/upstream-skills/zh-archify/references/explainer-authoring.md +1 -1
  184. package/upstream-skills/zh-archify/renderers/architecture/render-architecture.mjs +1 -0
  185. package/upstream-skills/zh-archify/renderers/class/render-class.mjs +1 -0
  186. package/upstream-skills/zh-archify/renderers/dataflow/render-dataflow.mjs +2 -1
  187. package/upstream-skills/zh-archify/renderers/erd/render-erd.mjs +1 -0
  188. package/upstream-skills/zh-archify/renderers/lifecycle/render-lifecycle.mjs +4 -2
  189. package/upstream-skills/zh-archify/renderers/sequence/render-sequence.mjs +4 -2
  190. package/upstream-skills/zh-archify/renderers/shared/cli.mjs +7 -1
  191. package/upstream-skills/zh-archify/renderers/timeline/render-timeline.mjs +1 -0
  192. package/upstream-skills/zh-archify/renderers/tree/render-tree.mjs +1 -0
  193. package/upstream-skills/zh-archify/renderers/waterfall/render-waterfall.mjs +1 -0
  194. package/upstream-skills/zh-archify/renderers/workflow/render-workflow.mjs +3 -2
  195. package/upstream-skills/zh-archify/renderers/workflow/workflow-compiler.mjs +68 -7
  196. package/upstream-skills/zh-archify/skill-release.json +1 -1
  197. package/upstream-skills/zh-modern-web-guidance/SKILL.md +4 -11
  198. package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/language-detection.md +20 -0
  199. package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/language-model.md +22 -0
  200. package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/prompt-api.md +22 -0
  201. package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/summarizer.md +20 -0
  202. package/upstream-skills/zh-modern-web-guidance/guides/built-in-ai/translator.md +22 -0
  203. package/upstream-skills/zh-modern-web-guidance/guides/performance/custom-ml-model-inference.md +342 -0
  204. package/upstream-skills/zh-modern-web-guidance/guides/performance/data-parallel-computation.md +337 -0
  205. package/upstream-skills/zh-modern-web-guidance/guides/performance/improve-next-page-load-performance.md +4 -1
  206. package/upstream-skills/zh-modern-web-guidance/guides/performance/large-scene-rendering.md +350 -0
  207. package/upstream-skills/zh-modern-web-guidance/guides/ui-atoms/position-aware-tooltips.md +9 -0
  208. package/upstream-skills/zh-modern-web-guidance/guides/ui-atoms/viewport-aware-dropdowns.md +9 -0
  209. package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/animate-to-from-top-layer.md +9 -0
  210. package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/declarative-dialog-popover-control.md +9 -0
  211. package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/interest-triggered-tooltips.md +9 -0
  212. package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/scroll-target-on-load.md +29 -0
  213. package/upstream-skills/zh-modern-web-guidance/guides/ui-behaviors/sortable-table.md +1 -0
  214. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/app-menus.md +9 -0
  215. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/context-menu.md +9 -0
  216. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/copy-button.md +9 -0
  217. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/dialog.md +10 -1
  218. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/hovercard.md +9 -0
  219. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/menu.md +9 -0
  220. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/navbar.md +9 -0
  221. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/persistent-app-tours.md +9 -0
  222. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/persistent-toast-notifications.md +9 -0
  223. package/upstream-skills/zh-modern-web-guidance/guides/ui-components/toolbar.md +9 -0
  224. package/upstream-skills/zh-modern-web-guidance/guides/user-experience/content-first-noise-reduction.md +9 -0
  225. package/upstream-skills/zh-modern-web-guidance/guides/user-experience/natural-interactions.md +9 -0
  226. package/upstream-skills/zh-modern-web-guidance/guides/webmcp/agentic-javascript-tools.md +27 -0
  227. package/skills/home/home-project-changelog/assets/project-changelog.md +0 -35
  228. package/skills/system/system-clash-tun-egress/SKILL.md +0 -22
  229. package/skills/system/system-clash-tun-egress/agents/openai.yaml +0 -4
  230. package/skills/system/system-config/SKILL.md +0 -37
  231. package/skills/system/system-config/agents/openai.yaml +0 -4
  232. package/skills/system/system-config/references/ai-cli-config.md +0 -75
  233. package/skills/system/system-config/references/ai-cli-optimization.md +0 -37
  234. package/skills/system/system-config/references/index.md +0 -12
  235. package/skills/system/system-config/references/locale-workflow.md +0 -33
  236. package/skills/system/system-config/references/locale.md +0 -50
  237. package/skills/system/system-proxy/SKILL.md +0 -40
  238. package/skills/system/system-proxy/agents/openai.yaml +0 -4
  239. package/skills/system/system-proxy/assets/protected-rules.yaml +0 -7
  240. package/skills/system/system-proxy/references/dns-workflow.md +0 -152
  241. /package/skills/system/{system-config → system-clash-proxy-config}/assets/configuration.md +0 -0
  242. /package/skills/system/{system-proxy → system-clash-proxy-config}/assets/network.md +0 -0
  243. /package/skills/system/{system-proxy → system-clash-proxy-config}/references/acceptance.md +0 -0
  244. /package/skills/system/{system-proxy → system-clash-proxy-config}/references/dns-fields.md +0 -0
  245. /package/skills/system/{system-proxy → system-clash-proxy-config}/references/dns-misconceptions.md +0 -0
  246. /package/skills/system/{system-clash-tun-egress/references/troubleshooting.md → system-clash-proxy-config/references/egress-troubleshooting.md} +0 -0
  247. /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-linux.md +0 -0
  248. /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-macos.md +0 -0
  249. /package/skills/system/{system-config → system-clash-proxy-config}/references/locale-windows.md +0 -0
  250. /package/skills/system/{system-proxy → system-clash-proxy-config}/references/network-performance.md +0 -0
  251. /package/skills/system/{system-clash-tun-egress → system-clash-proxy-config}/references/nodes-and-dns.md +0 -0
  252. /package/skills/system/{system-proxy → system-clash-proxy-config}/references/platform-dns.md +0 -0
  253. /package/skills/system/{system-proxy → system-clash-proxy-config}/references/platforms.md +0 -0
  254. /package/skills/system/{system-proxy → system-clash-proxy-config}/references/tun-dns.md +0 -0
@@ -109,7 +109,9 @@
109
109
  if (restoreButton) restoreButton.focus({ preventScroll: true });
110
110
  else if (window.innerWidth <= 1000 && diagramContainer) diagramContainer.scrollIntoView({ block: 'center', behavior: matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth' });
111
111
  });
112
+ var readerView;
112
113
  function readerPage(name) {
114
+ readerView = name;
113
115
  reader.hidden = false;
114
116
  reader.querySelector('.reader-path').textContent = tr("Analysis / ") + name;
115
117
  setReaderCollapsed(false);
@@ -150,14 +152,14 @@
150
152
  overview.id = 'bauify-overview'; overview.hidden = true; overview.setAttribute('aria-label', tr("Code analysis overview"));
151
153
  reader.appendChild(overview);
152
154
  var findingById = {}; (data.findings || []).forEach(function (f) { findingById[f.id] = f; });
153
- var overviewMode = 'summary', listScroll = 0, findingReturn = null;
155
+ var overviewMode = 'summary', listScroll = 0, findingReturn = null, reading = { kind: 'overview' };
154
156
  var filters = { source: 'all', category: 'all', severity: 'all', status: 'open', search: '', unverified: false, page: 0 };
155
157
  var filterKey = 'archify-findings:' + (data.repository.root || '') + ':' + location.pathname;
156
158
  try { var restored = JSON.parse(sessionStorage.getItem(filterKey)); if (restored) Object.keys(filters).forEach(function (key) { if (typeof restored[key] === typeof filters[key]) filters[key] = restored[key]; }); } catch (error) { /* Storage is optional for offline reports. */ }
157
159
  var entryById = {}; ((data.overview && data.overview.findings) || []).forEach(function (e) { entryById[e.id] = e; });
158
160
  var moduleInfo = {};
159
161
  data.components.forEach(function (c) { c.modules.forEach(function (m) { moduleInfo[m.id] = m; }); });
160
- (data.unmapped || []).forEach(function (m) { if (!moduleInfo[m.id]) moduleInfo[m.id] = { id: m.id, label: m.label, path: m.label, files: m.files, loc: m.loc, fanIn: m.fanIn, fanOut: m.fanOut, fileList: m.fileList || [] }; });
162
+ (data.unmapped || []).forEach(function (m) { if (!moduleInfo[m.id]) moduleInfo[m.id] = { id: m.id, label: m.label, path: m.path ?? m.label, files: m.files, loc: m.loc, fanIn: m.fanIn, fanOut: m.fanOut, fileList: m.fileList || [] }; });
161
163
  var detail = document.createElement('section');
162
164
  detail.id = 'bauify-detail'; detail.hidden = true; detail.setAttribute('aria-label', tr("Bauify finding details"));
163
165
  reader.appendChild(detail);
@@ -297,6 +299,8 @@
297
299
  return camera.centerAt(x, y, { scale: camera.state ? camera.state().scale : 1, instant: true });
298
300
  }
299
301
  function showOverview() {
302
+ findingReturn = null;
303
+ reading = { kind: 'overview' };
300
304
  overviewMode = 'summary'; clearPick();
301
305
  readerPage(tr("Overview"));
302
306
  root.removeAttribute('data-bauify-source');
@@ -358,6 +362,8 @@
358
362
  return findings.length ? findings.map(findingWhat).join(';') : tr(indicator.value);
359
363
  }
360
364
  function show(id) {
365
+ findingReturn = null;
366
+ reading = { kind: 'component', id: id };
361
367
  readerPage(tr("Component"));
362
368
  root.removeAttribute('data-bauify-source');
363
369
  var c = byId[id]; if (!c) return;
@@ -484,7 +490,8 @@
484
490
  return (compact ? '' : nextStepHtml(f)) + '<div class="finding ' + esc(f.severity) + '">' + ev + ("<details class=\"technical\">" + "<summary>" + tr("Rule details and alternatives") + "</summary>" + "<b>") + esc(f.code) + '</b> · ' + esc(tr(f.severity)) + (f.id ? ' · ' + esc(f.id) : '') + '<p>' + esc(f.message) + '</p>' + fixes + '</details></div>';
485
491
  }
486
492
  // Source excerpt for one file:line, from the windows embedded at overlay time.
487
- function showCode(file, line, why, tone, full, rangeStart, rangeEnd, match, snapshot, sourcePair, returnFocus, returnLabel) {
493
+ function showCode(file, line, why, tone, full, rangeStart, rangeEnd, match, snapshot, sourcePair, returnFocus, returnPage) {
494
+ var sourceParent = returnPage || (sourcePair ? tr("Files") : readerView || tr("Component"));
488
495
  readerPage(tr("Source"));
489
496
  function captured(sources, sourceFile) {
490
497
  return sourceFile && Object.hasOwn(sources || {}, sourceFile) ? sources[sourceFile] : null;
@@ -493,7 +500,6 @@
493
500
  var before = pr && (sourcePair ? sourcePair.base : file), after = sourcePair ? sourcePair.head : file;
494
501
  var snip = snapshot === 'base' ? captured(pr && pr.beforeSources, file) : captured(data.snippets, file);
495
502
  line = Number.isInteger(line) && line > 0 ? line : null;
496
- var sourceParent = returnLabel || (sourcePair ? tr("Files") : detail.hidden ? tr("Component") : tr("Problem"));
497
503
  var h = ("<div class=\"grip\">" + "<button class=\"close\" aria-label=\"" + tr("Close") + "\">" + "×" + "</button>" + "<button type=\"button\" class=\"source-back back\">" + "← ") + sourceParent + ("</button>" + "<div class=\"k\">" + tr("Source · ")) + (line ? tr("line ") + line : (full ? tr("full file") : tr("file preview")) + tr(" · no specific finding line")) + '</div><h3>' + esc(file) + '</h3></div>';
498
504
  if (pr) h += '<div class="pr-source-sides">' +
499
505
  '<button type="button" data-pr-side="base" aria-pressed="' + (snapshot === 'base') + '"' +
@@ -540,12 +546,12 @@
540
546
  if (pr) codePane.querySelectorAll('[data-pr-side]').forEach(function (button) {
541
547
  button.addEventListener('click', function () {
542
548
  var target = button.dataset.prSide;
543
- showCode(target === 'base' ? before : after, null, why, tone, full, null, null, null, target, sourcePair, returnFocus, returnLabel);
549
+ showCode(target === 'base' ? before : after, null, why, tone, full, null, null, null, target, sourcePair, returnFocus, sourceParent);
544
550
  if (sourcePair) codePane.querySelector('[data-pr-side="' + target + '"]').focus();
545
551
  });
546
552
  });
547
553
  var sourceToggle = codePane.querySelector('.source-toggle');
548
- if (sourceToggle) sourceToggle.addEventListener('click', function () { showCode(file, line, why, tone, !full, rangeStart, rangeEnd, match, snapshot, sourcePair, returnFocus, returnLabel); });
554
+ if (sourceToggle) sourceToggle.addEventListener('click', function () { showCode(file, line, why, tone, !full, rangeStart, rangeEnd, match, snapshot, sourcePair, returnFocus, sourceParent); });
549
555
  var backToSourceParent = function () {
550
556
  codePane.hidden = true;
551
557
  document.documentElement.removeAttribute('data-bauify-source');
@@ -568,6 +574,7 @@
568
574
  if (hit) codePane.scrollTop = Math.max(0, hit.offsetTop - codePane.offsetTop - codePane.clientHeight / 2);
569
575
  }
570
576
  function showDetail(c, key) {
577
+ reading = { kind: 'indicator', id: c.id, key: key };
571
578
  readerPage(tr("Problem"));
572
579
  root.removeAttribute('data-bauify-source');
573
580
  panel.hidden = true;
@@ -582,11 +589,11 @@
582
589
  if (!externalGroup) h += ("<details class=\"relationship\">" + "<summary>" + tr("Relationships and metrics") + "</summary>") + diagram(c, key, fl) + '</details>';
583
590
  h += ("<div class=\"k\">" + tr("Findings · ")) + fl.length + '</div>';
584
591
  if (!fl.length) h += '<div class="ev">' + (key === 'instability' ? tr("Instability measures dependency direction: out / (in + out). 0 = no outgoing dependencies, 1 = no incoming dependents. It is not a failure probability or a quality verdict.") : tr("No finding for this indicator; this is not a safety guarantee.")) + '</div>';
585
- fl.forEach(function (f) { h += f.external ? findingListRow(f) : quickHandoff(f) + evidencePreview(f) + findingCard(f) + taskHtml(f); });
592
+ fl.forEach(function (f) { h += '<div data-evidence-owner="' + esc(f.id) + '">' + (f.external ? findingListRow(f) : quickHandoff(f) + evidencePreview(f) + findingCard(f) + taskHtml(f)) + '</div>'; });
586
593
  detail.innerHTML = h;
587
594
  detail.hidden = false;
588
595
  codePane.hidden = true;
589
- var backToComponent = function () { readerPage(tr("Component")); detail.hidden = true; codePane.hidden = true; panel.hidden = false; panel.querySelectorAll('.ind.active').forEach(function (x) { x.classList.remove('active'); }); };
596
+ var backToComponent = function () { reading = { kind: 'component', id: c.id }; readerPage(tr("Component")); detail.hidden = true; codePane.hidden = true; panel.hidden = false; panel.querySelectorAll('.ind.active').forEach(function (x) { x.classList.remove('active'); }); };
590
597
  detail.querySelector('.close').addEventListener('click', backToComponent);
591
598
  detail.querySelector('.back').addEventListener('click', backToComponent);
592
599
  wireRefs();
@@ -598,7 +605,7 @@
598
605
  el.addEventListener('click', function () {
599
606
  detail.querySelectorAll('.ref.active').forEach(function (x) { x.classList.remove('active'); }); el.classList.add('active');
600
607
  var match = el.getAttribute('data-match');
601
- showCode(el.getAttribute('data-file'), parseInt(el.getAttribute('data-line'), 10), el.getAttribute('data-why'), el.getAttribute('data-tone'), false, Number(el.getAttribute('data-range-start')), Number(el.getAttribute('data-range-end')), match ? JSON.parse(match) : null);
608
+ showCode(el.getAttribute('data-file'), parseInt(el.getAttribute('data-line'), 10), el.getAttribute('data-why'), el.getAttribute('data-tone'), false, Number(el.getAttribute('data-range-start')), Number(el.getAttribute('data-range-end')), match ? JSON.parse(match) : null, null, null, function () { el.focus({ preventScroll: true }); });
602
609
  });
603
610
  });
604
611
  }
@@ -696,6 +703,8 @@
696
703
  (review.status === 'accepted' ? ("<span class=\"finding-row-state\">" + tr("Accepted")) + (f.severity === 'error' ? tr(" · still present") : '') + '</span>' : review.status === 'accepted-changed' ? ("<span class=\"finding-row-state attention\">" + tr("Accepted evidence changed · review again") + "</span>") : external && external.binding !== 'verified' ? ("<span class=\"finding-row-state attention\">" + tr("Report binding: ")) + esc(bindingLabel(external.binding).toLowerCase()) + '</span>' : '') + '</button>';
697
704
  }
698
705
  function showFindings(source) {
706
+ findingReturn = null;
707
+ reading = { kind: 'findings' };
699
708
  if (typeof source === 'string') { filters.source = source; filters.category = 'all'; filters.severity = 'all'; filters.status = 'open'; filters.unverified = false; filters.search = ''; filters.page = 0; listScroll = 0; }
700
709
  overviewMode = 'findings'; clearPick(); readerPage(tr("Findings")); root.removeAttribute('data-bauify-source');
701
710
  panel.hidden = detail.hidden = codePane.hidden = true; overview.hidden = false; setFocus([]);
@@ -703,6 +712,7 @@
703
712
  }
704
713
  function renderFindingList() {
705
714
  var sources = externalSources(), dimensions = [...new Set(data.findings.map(function (f) { return f.dimension; }))].sort();
715
+ if (!sources.length) filters.unverified = false;
706
716
  var option = function (value, label) { return '<option value="' + esc(value) + '">' + esc(label) + '</option>'; };
707
717
  overview.innerHTML = ("<button type=\"button\" class=\"back findings-back\">" + tr("← Overview") + "</button>" + "<div class=\"findings-heading\">" + "<h3>" + tr("Findings") + "</h3>") + (sources.length ? ("<button type=\"button\" class=\"text-action view-sources\">" + tr("Sources · ")) + sources.length + '</button>' : '') + '</div>' +
708
718
  ("<label class=\"sr-only\" for=\"finding-search\">" + tr("Search findings") + "</label>" + "<input id=\"finding-search\" class=\"finding-search\" type=\"search\" placeholder=\"" + tr("Search rule, message or file…") + "\" value=\"") + esc(filters.search) + '">' +
@@ -742,6 +752,8 @@
742
752
  pagination.querySelectorAll('button').forEach(function (button) { button.addEventListener('click', function () { filters.page += Number(button.getAttribute('data-page')); renderFindingRows(); overview.scrollTop = 0; }); });
743
753
  }
744
754
  function showSources() {
755
+ findingReturn = null;
756
+ reading = { kind: 'sources' };
745
757
  var parent = overviewMode; overviewMode = 'sources'; readerPage(tr("Sources")); root.removeAttribute('data-bauify-source');
746
758
  panel.hidden = detail.hidden = codePane.hidden = true; overview.hidden = false; setFocus([]);
747
759
  overview.innerHTML = '<button type="button" class="back sources-back">← ' + (parent === 'findings' ? tr("Findings") : tr("Overview")) + ("</button>" + "<h3>" + tr("Sources & coverage") + "</h3>" + "<p class=\"ev\">" + tr("Report import, source binding and scan scope are separate facts.") + "</p>") + externalSources().map(function (source) {
@@ -1012,11 +1024,7 @@
1012
1024
  var startCopy = overview.querySelector('.start-copy');
1013
1025
  if (startCopy) startCopy.addEventListener('click', function () { copyText(data.ui.resume.command, overview.querySelector('.start-status'), overview.querySelector('.start-command'), tr('Copied start command.')); });
1014
1026
  var again = overview.querySelector('.bauify-reanalyze');
1015
- if (again) again.addEventListener('click', function () {
1016
- again.disabled = true; again.classList.add('busy'); again.setAttribute('aria-busy', 'true');
1017
- var note = overview.querySelector('.brief-status'); note.classList.remove('reanalyze-error'); note.textContent = tr('Reading the repository — imports, modules, rules.');
1018
- window.__archifyReanalyze().catch(function (error) { again.disabled = false; again.classList.remove('busy'); again.removeAttribute('aria-busy'); note.classList.add('reanalyze-error'); note.textContent = tr('Re-analysis failed: ') + error.message + tr(' The result shown is from the last successful run.'); });
1019
- });
1027
+ if (again) wireRefresh(again, overview.querySelector('.brief-status'));
1020
1028
  overview.querySelectorAll('[data-finding]').forEach(function (el) { el.addEventListener('click', function () { showFinding(el.getAttribute('data-finding')); }); });
1021
1029
  wireTasks(overview);
1022
1030
  }
@@ -1081,9 +1089,15 @@
1081
1089
  var locations = captured ? captured.task.locations.filter(function (l) { return l.startLine; }).slice(0, 2) : [];
1082
1090
  if (!locations.length && f.subject && f.subject.file && f.subject.line) locations = [{ file: f.subject.file, startLine: f.subject.line, endLine: f.subject.endLine }];
1083
1091
  if (!locations.length) locations = (f.evidence && f.evidence.imports || []).slice(0, 2).map(function (v) { return { file: v.file, startLine: v.line, endLine: v.line }; });
1092
+ if (!locations.length) {
1093
+ var file = f.subject && f.subject.file;
1094
+ var sourceNotice = '<p class="ev">' + esc(tr("No line-level source evidence was recorded for this finding.")) + '</p>';
1095
+ return sourceNotice + (file && Object.hasOwn(data.snippets || {}, file) ? '<p>' + fileLink(file) + '</p>' : '');
1096
+ }
1084
1097
  return locations.map(function (loc) {
1085
1098
  var snip = (data.snippets || {})[loc.file], focus = f.code === 'complexity/function' ? f.evidence.deepestLine || loc.startLine : loc.startLine;
1086
1099
  var h = '<div class="inline-evidence">' + ref(loc.file, focus, '', tr("Captured source evidence. Read the complete context before editing."), toneOf(f.severity), loc.startLine, loc.endLine);
1100
+ if (focus !== loc.startLine) h += '<p class="ev">' + esc(tr("The excerpt highlights line {line}, where nesting is deepest. The function starts at line {start}.", { line: focus, start: loc.startLine })) + '</p>';
1087
1101
  if (!snip) return h + ("<div class=\"ev\">" + tr("Source unavailable in this report. Open the file in your editor or re-analyze.") + "</div>" + "</div>");
1088
1102
  var start = Math.max(0, focus - 5), end = Math.min(snip.lines.length, start + 9);
1089
1103
  h += ("<pre aria-label=\"" + tr("Code excerpt from ") + "") + esc(loc.file) + '">';
@@ -1222,12 +1236,14 @@
1222
1236
  });
1223
1237
  });
1224
1238
  }
1225
- function showFinding(id, parent) {
1239
+ function showFinding(id, parent, atlasReturn) {
1226
1240
  var f = findingById[id]; if (!f) return;
1241
+ if (atlasReturn) findingReturn = { parent: 'atlas', atlas: atlasReturn };
1227
1242
  parent = findingReturn ? findingReturn.parent : parent || (!overview.hidden && overviewMode === 'findings' ? 'findings' : 'summary');
1243
+ reading = { kind: 'finding', id: id, parent: parent };
1228
1244
  if (standalone && !findingReturn) {
1229
1245
  var opener = document.activeElement;
1230
- findingReturn = { parent: parent, atlas: window.__archifyAtlas && window.__archifyAtlas.saveSelection(), opener: overview.contains(opener) && opener.getAttribute('data-finding') };
1246
+ findingReturn = { parent: parent, atlas: window.__archifyAtlas && window.__archifyAtlas.saveSelection(true), opener: overview.contains(opener) && opener.getAttribute('data-finding') };
1231
1247
  }
1232
1248
  clearPick(); readerPage(tr("Finding")); detail.classList.remove('reviewing');
1233
1249
  root.removeAttribute('data-bauify-source');
@@ -1237,8 +1253,8 @@
1237
1253
  var scope = findingScope(f), path = findingLocation(f);
1238
1254
  var locationHtml = path ? '<p class="finding-location">' + esc(path) + '</p>' : '';
1239
1255
  setFocus(f.componentIds || []);
1240
- if (standalone && window.__archifyAtlas) window.__archifyAtlas.focusFinding(id);
1241
- var h = ("<button class=\"close\" aria-label=\"" + tr("Close") + "\">" + "×" + "</button>" + "<button class=\"back\" type=\"button\">" + "← ") + (parent === 'findings' ? tr("Findings") : tr("Overview")) + '</button>';
1256
+ if (standalone && !atlasReturn && window.__archifyAtlas) window.__archifyAtlas.focusFinding(id);
1257
+ var h = ("<button class=\"close\" aria-label=\"" + tr("Close") + "\">" + "×" + "</button>" + "<button class=\"back\" type=\"button\">" + "← ") + (parent === 'atlas' ? tr("Atlas") : parent === 'findings' ? tr("Findings") : tr("Overview")) + '</button>';
1242
1258
  if (f.external) {
1243
1259
  h += '<div class="external-origin"><span>' + esc(f.external.tool) + '</span><code>' + esc(f.external.ruleId || tr("review comment")) + '</code><span class="finding-level ' + tone + '">' + esc(tr(f.severity)) + '</span></div><h3>' + esc(findingTitle(f)) + '</h3>';
1244
1260
  if (f.message !== findingTitle(f)) h += '<div class="external-message">' + esc(f.message) + '</div>';
@@ -1269,8 +1285,8 @@
1269
1285
  detail.hidden = false;
1270
1286
  codePane.hidden = true;
1271
1287
  detail.scrollTop = 0;
1272
- detail.querySelector('.close').addEventListener('click', standalone ? leaveFinding : showOverview);
1273
- detail.querySelector('.back').addEventListener('click', standalone ? leaveFinding : function () { if (parent === 'findings') showFindings(); else showOverview(); });
1288
+ detail.querySelector('.close').addEventListener('click', standalone || parent === 'atlas' ? leaveFinding : showOverview);
1289
+ detail.querySelector('.back').addEventListener('click', standalone || parent === 'atlas' ? leaveFinding : function () { if (parent === 'findings') showFindings(); else showOverview(); });
1274
1290
  var locate = detail.querySelector('.locate');
1275
1291
  if (locate) locate.addEventListener('click', function () { locateComponents(f.componentIds, true); });
1276
1292
  detail.querySelectorAll('[data-finding]').forEach(function (el) { el.addEventListener('click', function () { showFinding(el.getAttribute('data-finding')); }); });
@@ -1283,6 +1299,10 @@
1283
1299
  var previous = findingReturn;
1284
1300
  findingReturn = null;
1285
1301
  if (previous && previous.parent === 'findings') showFindings(); else showOverview();
1302
+ if (previous?.parent === 'atlas' && window.__archifyAtlas) {
1303
+ window.__archifyAtlas.returnFromEvidence(previous.atlas);
1304
+ return;
1305
+ }
1286
1306
  if (previous && previous.atlas && window.__archifyAtlas) window.__archifyAtlas.restoreSelection(previous.atlas);
1287
1307
  if (previous && previous.opener) {
1288
1308
  var replacement = Array.from(overview.querySelectorAll('[data-finding]')).find(function (row) { return row.getAttribute('data-finding') === previous.opener && row.getClientRects().length; });
@@ -1305,7 +1325,8 @@
1305
1325
  var link = event.target.closest && event.target.closest('.source-file');
1306
1326
  if (!link || (!panel.contains(link) && !detail.contains(link))) return;
1307
1327
  event.preventDefault();
1308
- showCode(link.getAttribute('data-file'), Number(link.getAttribute('data-line')) || null, '', '');
1328
+ showCode(link.getAttribute('data-file'), Number(link.getAttribute('data-line')) || null, '', '', false, null, null, null, null, null,
1329
+ function () { link.focus({ preventScroll: true }); });
1309
1330
  });
1310
1331
  function sourceLinks(c, file) {
1311
1332
  var lines = [];
@@ -1669,7 +1690,17 @@
1669
1690
  }
1670
1691
  function flyClose(back) { return '<button class="close" aria-label="' + esc(tr("Close")) + '">×</button><button type="button" class="back">← ' + esc(back) + '</button>'; }
1671
1692
  // A dependency between two components: whether the diagram draws it, and the imports behind it.
1693
+ function flySourceLocation(file, line, metadata, target) {
1694
+ var content = '<span>' + esc(file) + '</span><em>' + esc(metadata) + '</em>';
1695
+ if (target) content += '<small>→ ' + esc(target) + '</small>';
1696
+ if (!Object.hasOwn(data.snippets || {}, file)) {
1697
+ return '<div class="fly-ev fly-ev-unavailable">' + content + '<small>' + esc(tr('Source was not captured')) + '</small></div>';
1698
+ }
1699
+ return '<button type="button" class="fly-ev" data-file="' + esc(file) + '" data-line="' + (line || '') + '"' + (target ? ' data-target="' + esc(target) + '"' : '') + '>' + content + '</button>';
1700
+ }
1672
1701
  function showEdge(from, to) {
1702
+ findingReturn = null;
1703
+ reading = { kind: 'edge', from: from, to: to };
1673
1704
  var e = codeEdgeByKey[from + '>' + to], undrawn = !!e && e.declared === false;
1674
1705
  readerPage(tr('Dependency')); root.removeAttribute('data-bauify-source');
1675
1706
  overview.hidden = true; detail.hidden = true; codePane.hidden = true; setFocus([]);
@@ -1682,13 +1713,16 @@
1682
1713
  h += '<div class="fly-nums two"><div><b>' + fmt(e.weight) + '</b><span>' + esc(tr('imports')) + '</span></div><div><b>' + Object.keys(files).length + (e.evidence.length < e.weight ? '+' : '') + '</b><span>' + esc(tr('source files')) + '</span></div></div>';
1683
1714
  h += '<p class="fly-note' + (undrawn ? ' attention' : '') + '">' + esc(undrawn ? tr('{from} imports {to} in the code, but the diagram draws no line between them. Add it to the diagram, or treat it as coupling that should not exist.', { from: compLabel(from), to: compLabel(to) }) : tr('The diagram draws this dependency and the code confirms it.')) + '</p>';
1684
1715
  h += '<h4 class="fly-h">' + esc(tr('Which files cause it')) + '<small>' + esc(e.evidence.length < e.weight ? tr('first {count}', { count: e.evidence.length }) : tr('all')) + '</small></h4>';
1685
- h += e.evidence.map(function (v) { return '<button type="button" class="fly-ev" data-file="' + esc(v.file) + '" data-line="' + (v.line || '') + '"><span>' + esc(v.file) + '</span><em>:' + (v.line || '?') + '</em><small>→ ' + esc(v.to) + '</small></button>'; }).join('');
1716
+ h += e.evidence.map(function (v) { return flySourceLocation(v.file, v.line, ':' + (v.line || '?'), v.to); }).join('');
1686
1717
  h += '<div class="fly-acts"><button type="button" class="fly-copy">' + esc(tr('Copy for AI')) + '</button></div><p class="fly-status ev" role="status" aria-live="polite"></p>';
1687
1718
  } else h += '<p class="fly-note">' + esc(tr('The diagram draws this relationship, but no import between these components was found. It may come from configuration, runtime calls or an external system, or the diagram over-states it.')) + '</p>';
1688
1719
  panel.innerHTML = h; panel.hidden = false; panel.scrollTop = 0;
1689
1720
  panel.querySelector('.close').addEventListener('click', showOverview);
1690
1721
  panel.querySelector('.back').addEventListener('click', function () { if (byId[from]) show(from); else showOverview(); });
1691
- panel.querySelectorAll('.fly-ev').forEach(function (el) { el.addEventListener('click', function () { showCode(el.getAttribute('data-file'), parseInt(el.getAttribute('data-line'), 10), tr('Import from {from} to {to}.', { from: compLabel(from), to: compLabel(to) }), undrawn ? 'red' : 'info'); }); });
1722
+ panel.querySelectorAll('button.fly-ev').forEach(function (el) { el.addEventListener('click', function () {
1723
+ panel.querySelectorAll('.fly-ev.active').forEach(function (item) { item.classList.remove('active'); }); el.classList.add('active');
1724
+ showCode(el.getAttribute('data-file'), parseInt(el.getAttribute('data-line'), 10), tr('Import from {from} to {to}.', { from: compLabel(from), to: compLabel(to) }), undrawn ? 'red' : 'info',
1725
+ false, null, null, null, null, null, function () { el.focus({ preventScroll: true }); }); }); });
1692
1726
  var copy = panel.querySelector('.fly-copy');
1693
1727
  if (copy) copy.addEventListener('click', function () {
1694
1728
  var text = tr('{from} → {to}: {count} imports in the code', { from: compLabel(from), to: compLabel(to), count: e.weight }) + (undrawn ? tr(', not drawn on the architecture diagram') : '') + '.\n' + e.evidence.map(function (v) { return '- ' + v.file + ':' + (v.line || '?') + ' → ' + v.to; }).join('\n');
@@ -1699,7 +1733,9 @@
1699
1733
  }
1700
1734
  // A module no component on the diagram owns.
1701
1735
  function showOff(id) {
1736
+ findingReturn = null;
1702
1737
  var m = moduleInfo[id]; if (!m) return;
1738
+ reading = { kind: 'off', id: id, path: m.path, rootFile: m.path || m.label === '(root)' ? null : m.fileList[0]?.path };
1703
1739
  readerPage(tr('Not on the diagram')); root.removeAttribute('data-bauify-source');
1704
1740
  overview.hidden = true; detail.hidden = true; codePane.hidden = true; clearPick(); setFocus([]);
1705
1741
  var fs = data.findings.filter(function (f) { return (f.moduleIds || []).indexOf(id) !== -1; });
@@ -1709,12 +1745,13 @@
1709
1745
  h += '<div class="fly-nums"><div><b>' + fmt(m.files) + '</b><span>' + esc(tr('files')) + '</span></div><div><b>' + fmtK(m.loc) + '</b><span>' + esc(tr('lines')) + '</span></div><div><b>' + fmt(fs.length) + '</b><span>' + esc(tr('findings')) + '</span></div></div>';
1710
1746
  h += '<p class="fly-note">' + esc(tr('This code is in the repository, but no component on the architecture diagram owns it. If it is part of the product, the diagram needs a node for it; if it is tooling, it can be left out of the analysis.')) + '</p>';
1711
1747
  if (fs.length) h += '<h4 class="fly-h">' + esc(tr('Look at these first')) + '<small>' + esc(tr('by severity and complexity')) + '</small></h4>' + fs.slice().sort(function (a, b) { return sevRank(a) - sevRank(b) || complexityOf(b) - complexityOf(a); }).slice(0, 5).map(flyFinding).join('');
1712
- if (files.length) h += '<h4 class="fly-h">' + esc(tr('Largest files')) + '<small>' + esc(plural(files.length, 'file')) + '</small></h4>' + files.slice(0, 5).map(function (f) { return '<button type="button" class="fly-ev" data-file="' + esc(f.path) + '"><span>' + esc(f.path) + '</span><em>' + esc(plural(f.loc || 0, 'line')) + '</em></button>'; }).join('');
1748
+ if (files.length) h += '<h4 class="fly-h">' + esc(tr('Largest files')) + '<small>' + esc(plural(files.length, 'file')) + '</small></h4>' + files.slice(0, 5).map(function (f) { return flySourceLocation(f.path, null, plural(f.loc || 0, 'line')); }).join('');
1713
1749
  panel.innerHTML = h; panel.hidden = false; panel.scrollTop = 0;
1714
1750
  panel.querySelector('.close').addEventListener('click', showOverview);
1715
1751
  panel.querySelector('.back').addEventListener('click', showOverview);
1716
1752
  wireFlyRows(panel);
1717
- panel.querySelectorAll('.fly-ev').forEach(function (el) { el.addEventListener('click', function () { showCode(el.getAttribute('data-file'), null, '', 'info'); }); });
1753
+ panel.querySelectorAll('button.fly-ev').forEach(function (el) { el.addEventListener('click', function () { showCode(el.getAttribute('data-file'), null, '', 'info',
1754
+ false, null, null, null, null, null, function () { el.focus({ preventScroll: true }); }); }); });
1718
1755
  }
1719
1756
  if (flyMode) {
1720
1757
  var flyFrame = 0;
@@ -1724,6 +1761,12 @@
1724
1761
  if (event.key !== 'Escape' || event.defaultPrevented || !flyOpen) return;
1725
1762
  var t = event.target;
1726
1763
  if (t && (t.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].indexOf(t.tagName || '') !== -1)) return;
1764
+ if (!root.hasAttribute('data-bauify-views') && !detail.hidden && findingReturn && findingReturn.parent === 'atlas') {
1765
+ event.preventDefault();
1766
+ event.stopPropagation();
1767
+ leaveFinding();
1768
+ return;
1769
+ }
1727
1770
  setFly(false);
1728
1771
  });
1729
1772
  }
@@ -1746,16 +1789,133 @@
1746
1789
  setFly(false);
1747
1790
  } else { setFly(false); if (stage) { setBeacon(false); setCodeDeps(false); } clearEdges(); setFocus([]); if (layer) layer.remove(); layer = null; panel.hidden = true; detail.hidden = true; codePane.hidden = true; overview.hidden = true; if (svg) svg.querySelectorAll('.bauify-mapped').forEach(function (g) { g.classList.remove('bauify-mapped'); }); }
1748
1791
  }
1792
+ var refresh, refreshStatus, refreshing = false;
1793
+ if (typeof window.__archifyReanalyze === 'function') {
1794
+ var refreshWrap = document.createElement('span');
1795
+ refreshWrap.className = 'analysis-refresh';
1796
+ refreshWrap.innerHTML = iconButton('refresh', tr('Re-analyze'), ' analysis-refresh-button', ' id="analysis-refresh"')
1797
+ + '<span class="analysis-refresh-status" role="status"></span>';
1798
+ btn.after(refreshWrap);
1799
+ refresh = refreshWrap.firstElementChild;
1800
+ refreshStatus = refreshWrap.lastElementChild;
1801
+ wireRefresh(refresh, refreshStatus);
1802
+ }
1803
+ function visibleReaderPage() {
1804
+ return !codePane.hidden ? codePane : !detail.hidden ? detail : !panel.hidden ? panel : overview;
1805
+ }
1806
+ var readingControls = ['.back', '.locate', '.reader-toggle', '.browse-findings', '.bauify-reanalyze'];
1807
+ var sourceKeys = ['data-file', 'data-line', 'data-range-start', 'data-range-end', 'data-match', 'data-target'];
1808
+ function sourceIdentity(ref) {
1809
+ var owner = ref.closest('[data-evidence-owner]');
1810
+ return { attributes: sourceKeys.map(function (key) { return ref.getAttribute(key); }),
1811
+ role: ref.closest('.inline-evidence') ? 'inline' : ref.closest('.more-evidence') ? 'details' : 'other',
1812
+ owner: owner ? owner.getAttribute('data-evidence-owner') : null };
1813
+ }
1814
+ function captureReading(active) {
1815
+ var pane = visibleReaderPage();
1816
+ return {
1817
+ reading: reading, open: !flyMode || flyOpen, collapsed: readerCollapsed, sourceOpen: pane === codePane,
1818
+ filters: Object.assign({}, filters), listScroll: overviewMode === 'findings' && pane === overview ? overview.scrollTop : listScroll,
1819
+ view: root.getAttribute('data-bauify-views'), scroll: pane.scrollTop,
1820
+ sourceRef: pane === codePane ? (function () {
1821
+ var ref = reading.kind === 'edge' ? panel.querySelector('.fly-ev.active') : detail.querySelector('.ref.active');
1822
+ return ref ? sourceIdentity(ref) : null;
1823
+ })() : null,
1824
+ atlas: window.__archifyAtlas?.saveSelection(true, active), findingReturn: findingReturn,
1825
+ atlas3d: root.getAttribute('data-bauify-views') === 'atlas3d' ? window.__archifyAtlas3d?.view?.saveSelection?.() : null,
1826
+ focus: readingControls.find(function (selector) { return active?.matches(selector); }),
1827
+ focusRefresh: active === refresh
1828
+ };
1829
+ }
1830
+ function wireRefresh(button, note) {
1831
+ // A pointer click in the toolbar moves focus before click fires.
1832
+ var beforePointer;
1833
+ button.addEventListener('pointerdown', function () { beforePointer = captureReading(document.activeElement); });
1834
+ button.addEventListener('pointercancel', function () { beforePointer = null; });
1835
+ button.addEventListener('click', function (event) {
1836
+ if (refreshing) return;
1837
+ var saved = event.detail && beforePointer || captureReading(button);
1838
+ beforePointer = null;
1839
+ refreshing = true;
1840
+ button.disabled = true; button.classList.add('busy'); button.setAttribute('aria-busy', 'true');
1841
+ note.classList.remove('reanalyze-error');
1842
+ note.textContent = tr('Reading the repository — imports, modules, rules.');
1843
+ window.__archifyReanalyze(saved).catch(function (error) {
1844
+ refreshing = false;
1845
+ button.disabled = false; button.classList.remove('busy'); button.removeAttribute('aria-busy');
1846
+ note.classList.add('reanalyze-error');
1847
+ note.textContent = tr('Re-analysis failed: ') + error.message + tr(' The result shown is from the last successful run.');
1848
+ if (beforePointer == null && (document.activeElement === document.body || document.activeElement === button)) button.focus({ preventScroll: true });
1849
+ });
1850
+ });
1851
+ }
1852
+ window.__archifyRestoreReading = function (saved) {
1853
+ if (!saved || !saved.reading) return;
1854
+ var page = saved.reading, missing = false;
1855
+ if (saved.filters) Object.keys(filters).forEach(function (key) { if (typeof saved.filters[key] === typeof filters[key]) filters[key] = saved.filters[key]; });
1856
+ if (typeof saved.listScroll === 'number') listScroll = saved.listScroll;
1857
+ if (saved.open && page.kind === 'component' && Object.hasOwn(byId, page.id)) show(page.id);
1858
+ else if (saved.open && page.kind === 'indicator' && byId[page.id]) {
1859
+ show(page.id);
1860
+ if (byId[page.id].indicators.items.some(function (item) { return item.key === page.key; })) showDetail(byId[page.id], page.key);
1861
+ else missing = true;
1862
+ }
1863
+ else if (saved.open && page.kind === 'finding' && Object.hasOwn(findingById, page.id)) {
1864
+ findingReturn = saved.findingReturn;
1865
+ showFinding(page.id, page.parent);
1866
+ } else if (saved.open && page.kind === 'findings') showFindings();
1867
+ else if (saved.open && page.kind === 'sources') showSources();
1868
+ else if (saved.open && page.kind === 'edge' && Object.hasOwn(byId, page.from) && Object.hasOwn(byId, page.to) && (codeEdgeByKey[page.from + '>' + page.to] || svg && Array.from(svg.querySelectorAll('path[data-edge-from][data-edge-to]')).some(function (edge) { return edge.getAttribute('data-edge-from') === page.from && edge.getAttribute('data-edge-to') === page.to; }))) showEdge(page.from, page.to);
1869
+ else if (saved.open && page.kind === 'off') {
1870
+ var matches = (data.unmapped || []).filter(function (item) { return page.path === undefined ? item.id === page.id : (item.path ?? item.label) === page.path && (page.path || (item.label === '(root)' ? null : item.fileList?.[0]?.path) === page.rootFile); });
1871
+ if (matches.length === 1) showOff(matches[0].id); else { missing = true; showOverview(); }
1872
+ }
1873
+ else if (saved.open) {
1874
+ missing = page.kind !== 'overview';
1875
+ showOverview();
1876
+ }
1877
+ if (saved.sourceOpen && !missing) {
1878
+ // Only reopen the exact captured evidence item. A different block in the
1879
+ // same file is not a safe substitute after a new analysis.
1880
+ var refs = saved.sourceRef ? Array.from((page.kind === 'edge' ? panel : detail).querySelectorAll(page.kind === 'edge' ? '.fly-ev[data-file]' : '.ref[data-file]')).filter(function (link) {
1881
+ var identity = sourceIdentity(link);
1882
+ if (Array.isArray(saved.sourceRef)) return saved.sourceRef.every(function (value, index) { return identity.attributes[index] === value; });
1883
+ return identity.role === saved.sourceRef.role && identity.owner === saved.sourceRef.owner && sourceKeys.every(function (_key, index) { return identity.attributes[index] === saved.sourceRef.attributes[index]; });
1884
+ }) : [];
1885
+ if (refs.length === 1) {
1886
+ // Keep the selected evidence visible when returning from its source.
1887
+ var ancestor = refs[0].parentElement;
1888
+ while (ancestor && ancestor !== detail) { if (ancestor.tagName === 'DETAILS') ancestor.open = true; ancestor = ancestor.parentElement; }
1889
+ refs[0].click();
1890
+ } else missing = true;
1891
+ }
1892
+ if (saved.collapsed) setReaderCollapsed(true);
1893
+ if (saved.view === 'atlas' || saved.view === 'atlas3d') window.__archifyAtlas?.showView(saved.view);
1894
+ if (saved.view === 'atlas3d' && saved.atlas3d) missing = window.__archifyAtlas3d?.view?.restoreSelection?.(saved.atlas3d) !== false || missing;
1895
+ var pane = visibleReaderPage();
1896
+ if (!missing && (!saved.sourceOpen || pane === codePane)) pane.scrollTop = saved.scroll;
1897
+ var target = saved.focusRefresh ? refresh : saved.focus && (pane.querySelector(saved.focus) || reader.querySelector(saved.focus));
1898
+ if (target?.getClientRects().length && !target.closest('[inert]')) target.focus({ preventScroll: true });
1899
+ else if (saved.open && !saved.collapsed && !saved.view && pane.getClientRects().length) {
1900
+ var heading = pane.querySelector('h3') || pane.querySelector('.back');
1901
+ if (heading) { if (heading.tagName === 'H3') heading.tabIndex = -1; heading.focus({ preventScroll: true }); }
1902
+ } else if (!saved.atlas?.focus) refresh?.focus({ preventScroll: true });
1903
+ if (saved.atlas && window.__archifyAtlas) missing = window.__archifyAtlas.restoreSelection(saved.atlas) || missing;
1904
+ if (missing && refreshStatus) refreshStatus.textContent = tr('This selection is no longer available in the latest analysis.');
1905
+ };
1749
1906
  btn.addEventListener('click', function () { setOn(root.getAttribute('data-bauify') !== 'on'); });
1750
1907
  // The Atlas view hands a finding back here to show its source evidence.
1751
1908
  window.__archifyShowSource = function (file, line, snapshot, sourcePair, returnFocus) {
1752
1909
  setOn(true);
1753
1910
  showCode(file, line, tr(data.pullRequest?.local ? 'Captured source from the pinned commits.' : 'Captured PR source; inspect changes against the merge-base.'), 'info', false, null, null, null, snapshot, sourcePair, returnFocus);
1754
1911
  };
1755
- window.__archifyShowFinding = function (id, parent) {
1912
+ window.__archifyShowFinding = function (id, parent, atlasReturn) {
1756
1913
  if (!findingById[id]) return;
1757
1914
  if (root.getAttribute('data-bauify') !== 'on') setOn(true);
1758
- showFinding(id, parent);
1915
+ // Each external Atlas entry owns a new return context; related findings
1916
+ // use showFinding directly and keep the original context.
1917
+ findingReturn = null;
1918
+ showFinding(id, parent, atlasReturn);
1759
1919
  };
1760
1920
  document.addEventListener('keydown', function (e) {
1761
1921
  if (standalone) return;
@@ -5,7 +5,7 @@
5
5
  'invalid-task': 'Invalid task or mismatched task findings.',
6
6
  'wrong-task-findings': 'Invalid task or mismatched task findings.',
7
7
  'wrong-task-id': 'The task ID does not match the selected findings.',
8
- 'wrong-task-snapshot': 'The task does not match the previous analysis.',
8
+ 'wrong-task-snapshot': 'The task does not match a retained analysis capture.',
9
9
  'invalid-checks': 'Invalid project check results.',
10
10
  'wrong-checks-snapshot': 'Check results do not match this task and analysis pair.',
11
11
  };
@@ -151,6 +151,7 @@ const ZH_CN = {
151
151
  "Run project checks separately. This receipt compares captured analyses and records your reported check results.": "请单独运行项目检查。回执对比两次分析,并记录你报告的检查结果。",
152
152
  "Download the task JSON before editing, then re-analyze using the same output directory.": "请先下载任务 JSON,改动后使用同一输出目录重新分析。",
153
153
  "Task JSON from the previous run": "上一轮导出的任务 JSON",
154
+ "The task does not match a retained analysis capture.": "任务与保留的分析快照不匹配。",
154
155
  "Project check results JSON (optional)": "项目检查结果 JSON(可选)",
155
156
  "Preview verification": "预览核验回执",
156
157
  "Download checks template": "下载检查结果模板",
@@ -178,6 +179,7 @@ const ZH_CN = {
178
179
  "Select a JSON file up to 2 MiB.": "请选择不超过 2 MiB 的 JSON 文件。",
179
180
  "Could not read the selected JSON file.": "无法读取选中的 JSON 文件。",
180
181
  "The task does not match the previous analysis.": "任务与上一轮分析不匹配。",
182
+ "This selection is no longer available in the latest analysis.": "最新分析中已无此选中项。",
181
183
  "Invalid task or mismatched task findings.": "任务格式不正确,或发现与上一轮不符。",
182
184
  "The task ID does not match the selected findings.": "任务 ID 与所选发现不匹配。",
183
185
  "Task verification requires a local file or a secure page.": "任务验证需要本地文件或安全页面。",
@@ -194,6 +196,10 @@ const ZH_CN = {
194
196
  "Hide analysis": "收起诊断",
195
197
  "View Atlas": "查看整仓星图",
196
198
  "Open source evidence": "查看源码证据",
199
+ "Open finding details": "查看发现详情",
200
+ "Open finding details in Classic view": "在经典视图中查看发现详情",
201
+ "No line-level source evidence was recorded for this finding.": "这项发现没有记录行级源码证据。",
202
+ "The excerpt highlights line {line}, where nesting is deepest. The function starts at line {start}.": "摘录高亮嵌套最深处(第 {line} 行)。函数从第 {start} 行开始。",
197
203
  "Repository": "代码仓库",
198
204
  "Offline snapshot": "离线快照",
199
205
  "Built from the analysis snapshot; not yet compared with the current working tree.": "基于本次分析快照构建,尚未与当前工作树核对。",
@@ -332,6 +338,9 @@ const ZH_CN = {
332
338
  "Files": "文件",
333
339
  "Functions": "函数",
334
340
  "File dependencies": "文件依赖",
341
+ "No captured dependencies for the selected file": "所选文件暂无已捕获的依赖",
342
+ "① Importing file": "① 导入方",
343
+ "② Imported file": "② 被导入方",
335
344
  "{total}: {branchDeps} in {branches}, {threadDeps} in {threads}, {inside} inside modules (not drawn)": "{total}:{branchDeps} 在{branches}中,{threadDeps} 在{threads}中,{inside} 在模块内部(不画出)",
336
345
  "Findings · {n}": "发现 · {n}",
337
346
  "{n} more, smaller ones in the Atlas.": "另有 {n} 项较小的,见整仓星图。",
@@ -104,7 +104,7 @@ export function alignDiagram({ ir, graph, map = null, facts = null, findings = [
104
104
  // Whether the diagram draws each code-level edge: the analysis page marks the ones it does not.
105
105
  for (const e of edges) e.declared = declared.has(`${e.from}>${e.to}`);
106
106
  const undeclaredEdges = edges.filter((e) => !e.declared);
107
- const unmapped = graph.modules.filter((m) => !claimed.has(m.id)).map((m) => ({ id: m.id, label: m.label, files: m.files, loc: m.loc, fanIn: m.fanIn, fanOut: m.fanOut, fileList: (fileIndex.get(m.id) || []).map((f) => ({ ...f, module: m.id })) }));
107
+ const unmapped = graph.modules.filter((m) => !claimed.has(m.id)).map((m) => ({ id: m.id, label: m.label, path: m.path, files: m.files, loc: m.loc, fanIn: m.fanIn, fanOut: m.fanOut, fileList: (fileIndex.get(m.id) || []).map((f) => ({ ...f, module: m.id })) }));
108
108
  const fileModule = facts
109
109
  ? new Map([...fileIndex].flatMap(([id, list]) => list.map((f) => [f.path, id])))
110
110
  : new Map(Object.entries(graph.fileModules || {}));
@@ -9,7 +9,7 @@ import { fail, receipt } from '../core/index.mjs';
9
9
  import { schemaErrors } from '../schemas/index.mjs';
10
10
  import { buildGraph, evaluateGraph, extractFacts, loadBaseline, loadPrevious, readJsonInput, reviewSummary, stableJson, validateFacts } from '../lib/analysis.mjs';
11
11
  import { reviewFindings } from '../lib/review.mjs';
12
- import { verificationContext } from '../lib/verification-context.mjs';
12
+ import { matchingPreviousPullRequest, retainVerificationBaselines, sameVerificationRepository, verificationContexts } from '../lib/verification-history.mjs';
13
13
  import { buildOverlay } from './inject.mjs';
14
14
  import { driftResolutionInputs } from '../lib/architecture-drift.mjs';
15
15
  import { buildPullRequestView } from './pull-request.mjs';
@@ -31,8 +31,10 @@ export function renderAnalysisSnapshot({ dir, html, root, review }) {
31
31
  const facts = read('raw-facts.json'), graph = read('module-graph.json'), findings = read('findings.json');
32
32
  const context = read('view-context.json');
33
33
  if (context?.schema_version !== 1 || (!context.ir && context.mode !== 'standalone') || !context.run) fail('overlay/context-invalid', 'The captured view context is missing or invalid.', { supportedFixes: ['re-analyze the repository to rebuild its captured view'] });
34
- const previous = loadPrevious(path.join(dir, '..', 'analysis.previous', 'findings.json'));
35
- const run = { ...context.run, rules: findings.rules, duplicates: findings.analysis?.duplicates || null, external: findings.analysis?.external || [], review, verification: verificationContext(previous, findings, review) };
34
+ const previousDir = path.join(dir, '..', 'analysis.previous');
35
+ const previous = context.run.pullRequest ? loadPrevious(path.join(dir, 'base/findings.json')) : sameVerificationRepository(dir, previousDir) ? loadPrevious(path.join(previousDir, 'findings.json')) : null;
36
+ const previousHead = context.run.pullRequest && matchingPreviousPullRequest(previousDir, findings, context.run.pullRequest);
37
+ const run = { ...context.run, rules: findings.rules, duplicates: findings.analysis?.duplicates || null, external: findings.analysis?.external || [], review, verification: verificationContexts(dir, previous, findings, facts, context.run.pullRequest ? [previousHead] : undefined) };
36
38
  return overlayHtml({ html: html ? fs.readFileSync(html, 'utf8') : null, ir: context.ir, graph, facts, findings: findings.diagnostics, findingsDocument: findings, map: context.map, sourceRoot: root, run });
37
39
  }
38
40
 
@@ -53,7 +55,7 @@ export function writeAnalysisView(dir, overlay, review) {
53
55
  // `html` is the page Archify delivered for `ir`; it is read, never modified.
54
56
  // `baseline` (file) marks accepted findings; `previous` (a findings.json from
55
57
  // an earlier run) adds a comparison. Both are recorded in review.json.
56
- export function analyzeRepository({ root, ir = null, html = null, out, locale = null, language = null, config = null, map = null, irSnapshot = null, baseline = null, previous = null, resume = null, openAnalysis = false, source = null, pullRequest = null, captureDriftInputs = false }) {
58
+ export function analyzeRepository({ root, ir = null, html = null, out, locale = null, language = null, config = null, map = null, irSnapshot = null, baseline = null, previous = null, previousHeadDir = null, resume = null, openAnalysis = false, source = null, pullRequest = null, captureDriftInputs = false, retainBaselines = false }, { createOutput = true } = {}) {
57
59
  const absRoot = path.resolve(root);
58
60
  const irPath = ir ? path.resolve(ir) : null;
59
61
  const htmlPath = html ? path.resolve(html) : null;
@@ -62,7 +64,8 @@ export function analyzeRepository({ root, ir = null, html = null, out, locale =
62
64
  if (irPath && (!htmlPath || !fs.existsSync(htmlPath))) fail('cli/input-invalid', `Not a file: ${html}`, { subject: { file: html }, supportedFixes: ['deliver the diagram with `archify deliver` first'] });
63
65
  if (path.resolve(dir, 'repo.analysis.html') === htmlPath) fail('cli/out-invalid', 'The analysis output must not overwrite the delivered HTML.', { supportedFixes: ['use a different --out directory'] });
64
66
  if (map && !irPath) fail('cli/input-invalid', '--map requires --ir.', { supportedFixes: ['provide the authored architecture IR or omit --map'] });
65
- fs.mkdirSync(dir, { recursive: true });
67
+ if (createOutput) fs.mkdirSync(dir, { recursive: true });
68
+ else if (!fs.statSync(dir).isDirectory()) fail('cli/out-invalid', 'The analysis staging path must be a directory.', { subject: { dir } });
66
69
  let resolutionInputs;
67
70
  const onCapture = captureDriftInputs || (pullRequest?.pr.local && irPath && language === 'ts')
68
71
  ? ({ reads }) => { resolutionInputs = driftResolutionInputs(absRoot, reads); } : undefined;
@@ -81,6 +84,7 @@ export function analyzeRepository({ root, ir = null, html = null, out, locale =
81
84
  fs.writeFileSync(path.join(dir, 'findings.json'), stableJson(findings));
82
85
  const prior = loadPrevious(previous);
83
86
  const review = reviewFindings(findings.diagnostics, { baseline: loadBaseline(baseline), previous: prior, analysis: findings.analysis, files: [...facts.files, ...(findings.externalEvidence || [])].map((f) => f.path) });
87
+ const history = retainBaselines ? retainVerificationBaselines(dir, path.dirname(previous), prior, findings, absRoot, resume) : [];
84
88
  const irDoc = irSnapshot ?? (irPath ? readJsonInput(irPath, 'analysis --ir') : null);
85
89
  const mapDoc = map ? readJsonInput(map, 'analysis --map') : null;
86
90
  if (captureDriftInputs && resolutionInputs) fs.writeFileSync(path.join(dir, 'resolution-inputs.json'), stableJson([...resolutionInputs]));
@@ -88,7 +92,8 @@ export function analyzeRepository({ root, ir = null, html = null, out, locale =
88
92
  ir: irDoc, map: mapDoc, resolutionInputs, locale, base: path.join(dir, 'base') });
89
93
  const context = { schema_version: 1, mode: irPath ? 'diagram' : 'standalone', ir: irDoc, map: mapDoc, run: { ...(pullRequest ? { pullRequest } : {}), locale: locale || irDoc?.meta?.locale || 'en', openAnalysis: !irPath || openAnalysis, ...(resume ? { resume } : {}), suppressed: cfg.ignore || [], exclude: cfg.exclude || [], otherLanguages, boundaries: cfg.boundaries || null } };
90
94
  fs.writeFileSync(path.join(dir, 'view-context.json'), stableJson(context));
91
- const run = { ...context.run, rules: findings.rules, duplicates: findings.analysis?.duplicates || null, external: findings.analysis?.external || [], review, verification: verificationContext(prior, findings, review) };
95
+ const previousHead = pullRequest && previousHeadDir && matchingPreviousPullRequest(previousHeadDir, findings, context.run.pullRequest);
96
+ const run = { ...context.run, rules: findings.rules, duplicates: findings.analysis?.duplicates || null, external: findings.analysis?.external || [], review, verification: verificationContexts(dir, pullRequest || !retainBaselines || sameVerificationRepository(dir, path.dirname(previous)) ? prior : null, findings, facts, pullRequest ? [previousHead] : history) };
92
97
  const overlay = overlayHtml({ html: htmlPath ? fs.readFileSync(htmlPath, 'utf8') : null, ir: irDoc, graph, facts, findings: findings.diagnostics, findingsDocument: findings, map: mapDoc, sourceRoot: absRoot, run });
93
98
  const outHtml = path.join(dir, 'repo.analysis.html');
94
99
  writeAnalysisView(dir, overlay, review);
@@ -54,7 +54,7 @@ export function buildPullRequestView({ pr, scope, changedFiles, manifests, sourc
54
54
  if (pr.local && ir && resolutionInputs) {
55
55
  checkDriftMapping(ir, map);
56
56
  const capture = (side, facts, graph, resolutionInputs) => ({ facts, graph, resolutionInputs,
57
- omitted: new Map(manifests[side].skipped.map(entry => [entry.path, entry.mode])) });
57
+ omitted: new Map(manifests[side].skipped.map(entry => [entry.path, `${entry.mode}:${entry.oid}`])) });
58
58
  const { components, summary, coverage, edges } = compareArchitectureDrift({
59
59
  base: capture('base', baseFacts, baseGraph, new Map(read('resolution-inputs'))),
60
60
  head: capture('head', facts, graph, resolutionInputs),
@@ -106,6 +106,7 @@
106
106
  "adapter": { "type": ["string", "null"] },
107
107
  "sourceKind": { "type": ["string", "null"] },
108
108
  "snapshotId": { "type": ["string", "null"] },
109
+ "analysisSha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
109
110
  "configDigest": { "type": ["string", "null"] },
110
111
  "analyzer": { "type": ["object", "null"] },
111
112
  "gitHead": { "type": ["string", "null"], "description": "Contextual HEAD for working-tree; pinned source commit for git-tree." },