@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
@@ -1,10 +1,11 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import { createHash } from 'node:crypto';
4
- import { parseMarkdown, validDay } from '../site/templates/project-logs.mjs';
5
- import { statistics } from '../site/templates/model.mjs';
4
+ import { validDay } from '../site/templates/project-logs.mjs';
5
+ import { categories, statistics } from '../site/templates/model.mjs';
6
6
 
7
- const idPattern = /^[a-z0-9][a-z0-9-]*$/u;
7
+ const projectId = value => typeof value === 'string' && /^[a-z0-9][a-z0-9-]*$/u.test(value)
8
+ && !/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/u.test(value);
8
9
  const plain = value => !!value && typeof value === 'object' && !Array.isArray(value);
9
10
  const line = value => typeof value === 'string' && value.trim() && !/[\x00-\x1f\x7f]/u.test(value);
10
11
  const decode = value => new TextDecoder('utf-8', { fatal: true }).decode(value);
@@ -45,32 +46,36 @@ function https(value) {
45
46
  }
46
47
 
47
48
  function config(value) {
48
- checkKeys(value, ['title', 'base', 'scope', 'publicGroups', 'overrides'], 'site.config.json');
49
- const {title, base, scope = 'all', publicGroups = [], overrides = {}} = value;
49
+ checkKeys(value, ['title', 'base', 'scope', 'projectIds', 'publicGroups', 'overrides'], 'site.config.json');
50
+ const {title, base, scope = 'all', projectIds, publicGroups = [], overrides = {}} = value;
50
51
  if (!line(title) || typeof base !== 'string' || !/^\/(?:[a-zA-Z0-9_-][a-zA-Z0-9._-]*\/)*$/u.test(base) || scope !== 'all') {
51
52
  throw Error('设置需要 title、以 / 包围的 base、scope 为 all。');
52
53
  }
53
54
  if (!Array.isArray(publicGroups) || !publicGroups.every(line) || !plain(overrides)) throw Error('publicGroups 或 overrides 格式错误。');
55
+ if (projectIds !== undefined && (!Array.isArray(projectIds) || !projectIds.every(projectId)
56
+ || new Set(projectIds).size !== projectIds.length)) throw Error('projectIds 需要无重复的项目 ID 数组。');
54
57
  const byId = new Map();
55
58
  for (const [id, item] of Object.entries(overrides)) {
56
- if (!idPattern.test(id)) throw Error('overrides 使用登记项目 ID。');
57
- checkKeys(item, ['hidden','showChangelog','displayName','summary','docsUrl','repoUrl'], id);
59
+ if (!projectId(id)) throw Error('overrides 使用登记项目 ID。');
60
+ checkKeys(item, ['hidden','showChangelog','displayName','summary','docsUrl','repoUrl','submoduleOf','submodulePath'], id);
58
61
  for (const key of ['hidden','showChangelog']) {
59
62
  if (Object.hasOwn(item,key) && typeof item[key] !== 'boolean') throw Error(id+' 的 '+key+' 应为布尔值。');
60
63
  }
61
64
  for (const key of ['displayName','summary']) {
62
65
  if (Object.hasOwn(item,key) && !line(item[key])) throw Error(id+' 的 '+key+' 应为单行文字。');
63
66
  }
67
+ if (item.submoduleOf !== undefined && (!projectId(item.submoduleOf) || item.submoduleOf === id)) throw Error(id+' 的父项目 ID 无效。');
68
+ if (item.submodulePath !== undefined && (!item.submoduleOf || !line(item.submodulePath) || !item.submodulePath.split('/').every(part => /^[a-zA-Z0-9_-][a-zA-Z0-9._-]*$/u.test(part)))) throw Error(id+' 的子模块相对路径无效。');
64
69
  byId.set(id, {...item, ...(item.docsUrl !== undefined ? {docsUrl:https(item.docsUrl)} : {}), ...(item.repoUrl !== undefined ? {repoUrl:https(item.repoUrl)} : {})});
65
70
  }
66
- return {title, base, publicGroups, byId};
71
+ return {title, base, projectIds:projectIds === undefined ? null : new Set(projectIds), publicGroups, byId};
67
72
  }
68
73
 
69
74
  function records(value) {
70
75
  if (!plain(value) || ![1,2].includes(value.formatVersion) || !Array.isArray(value.repos)) throw Error('repos.json 只支持 v1/v2 的 repos 数组。');
71
76
  const seen = new Set();
72
77
  for (const repo of value.repos) {
73
- if (!plain(repo) || typeof repo.id !== 'string' || !idPattern.test(repo.id) || seen.has(repo.id) || !line(repo.purpose)) {
78
+ if (!plain(repo) || !projectId(repo.id) || seen.has(repo.id) || !line(repo.purpose)) {
74
79
  throw Error('repos.json 含无效或重复的项目 ID,或缺少单行用途。');
75
80
  }
76
81
  if (repo.groups !== undefined && (!Array.isArray(repo.groups) || !repo.groups.every(line))) throw Error(repo.id+' 的登记分组格式错误。');
@@ -79,38 +84,6 @@ function records(value) {
79
84
  return value.repos;
80
85
  }
81
86
 
82
- function readState(value) {
83
- if (value === undefined) return {};
84
- if (!plain(value) || value.formatVersion !== 1 || !plain(value.projects)) throw Error('changelogs/state.json 格式错误,请用 home-project-changelog 核对。');
85
- for (const [id, project] of Object.entries(value.projects)) {
86
- if (!idPattern.test(id) || !plain(project) || !plain(project.initialization) || !Array.isArray(project.ranges)
87
- || project.lastSuccessfulRangeId !== (project.ranges.at(-1)?.rangeId ?? null)
88
- || (Object.hasOwn(project,'pending') && !plain(project.pending))
89
- || !project.ranges.length && !project.pending) {
90
- throw Error('changelogs/state.json 中 '+id+' 的记录无效,请用 home-project-changelog 核对。');
91
- }
92
- const ids = new Set();
93
- let previous = null;
94
- for (const range of project.ranges) {
95
- const dates = range?.displayDates;
96
- const commits = range?.stats?.rangeCommitCount;
97
- const head = range?.stats?.totalCommitCountAtHead;
98
- const baseline = ['baseline','rebaseline'].includes(range?.kind);
99
- if (!plain(range) || !line(range.rangeId) || ids.has(range.rangeId) || range.previousRangeId !== previous
100
- || typeof range.savedAt !== 'string' || !Number.isFinite(Date.parse(range.savedAt))
101
- || !['full-history','delta','baseline','rebaseline'].includes(range.kind)
102
- || !plain(dates) || !validDay(dates.to) || (dates.from !== null && (!validDay(dates.from) || dates.from > dates.to))
103
- || !Number.isSafeInteger(commits) || commits < 0 || (baseline && (dates.from !== null || commits !== 0))
104
- || (head != null && (!Number.isSafeInteger(head) || head < commits))) {
105
- throw Error('changelogs/state.json 中 '+id+' 的成功区间无效,请用 home-project-changelog 核对。');
106
- }
107
- ids.add(range.rangeId);
108
- previous = range.rangeId;
109
- }
110
- }
111
- return value.projects;
112
- }
113
-
114
87
  function publicText(value, privateValues) {
115
88
  let text = value
116
89
  .replace(/!?\[([^\]\n]*)\]\([^\n)]*\)/gu, '$1')
@@ -119,80 +92,102 @@ function publicText(value, privateValues) {
119
92
  return text.replace(/(?:https?:\/\/|git:\/\/|ssh:\/\/|file:\/\/|ftp:\/\/|mailto:|www\.)[^\s<>,。;、))]+/giu, '〔链接〕')
120
93
  .replace(/[\w.-]+@[\w.-]+:[^\s<>,。;、]+/gu,'〔链接〕')
121
94
  .replace(/(?:\b[A-Za-z]:[\\/]|(?:\.\.?[\\/])+|(?<![\p{L}\d/])\/(?=[\w.-]+\/)|\\\\(?=[\w.-]+\\))[^\s<>,。;、)]+/gu, '〔本地路径〕')
95
+ .replace(/\b(?:[a-f0-9]{40}|[a-f0-9]{64}|(?=[a-f0-9]*\d)(?=[a-f0-9]*[a-f])[a-f0-9]{7,39})\b/giu, '〔提交标识〕')
122
96
  .replace(/[\u0000-\u0009\u000b-\u001f\u007f]/gu, ' ');
123
97
  }
124
98
 
125
- function savedPeriods(id, parsed, dated, saved, warnings) {
126
- const blocks = parsed.periods.map((legacy,index) => ({legacy, dated:dated?.periods[index]}));
127
- const oldest = [...blocks].reverse();
128
- const bodyFor = (block, range) => range.ledger ? block.dated : block.legacy;
129
- function matches(block, range) {
130
- const period = bodyFor(block,range);
131
- const {from,to} = range.displayDates;
132
- const legacyStart = range.kind === 'full-history' && from === null;
133
- const baseline = range.kind === 'baseline' || range.kind === 'rebaseline';
134
- return period.verified && period.to === to && (legacyStart || period.from === from)
135
- && period.commits === range.stats.rangeCommitCount && period.baseline === baseline;
136
- }
137
- function ordered(ranges, periods) {
138
- const found = [];
139
- let index = 0;
140
- for (const range of ranges) {
141
- while (index < periods.length && !matches(periods[index],range)) index += 1;
142
- if (index === periods.length) throw Error(id+' 的成功区间无法核对 Markdown 日期、提交数或统计:'+range.displayDates.to+'。');
143
- found.push(periods[index++]);
99
+ const publicMarkers = ['破坏性', '安全', '弃用', '移除', '回退'];
100
+ const oid = value => typeof value === 'string' && /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/u.test(value);
101
+ const oidList = values => Array.isArray(values) && values.every(oid) && new Set(values).size === values.length;
102
+ const lineCount = value => value == null || Number.isSafeInteger(value) && value >= 0;
103
+ const collectionTime = value => typeof value === 'string' && Number.isFinite(Date.parse(value))
104
+ && new Date(value).toISOString() === value;
105
+ const notesList = value => Array.isArray(value) && value.every(note => typeof note === 'string' && note.trim());
106
+ const validEntry = entry => plain(entry) && categories.includes(entry.category) && line(entry.text)
107
+ && Array.isArray(entry.markers) && entry.markers.every(marker => publicMarkers.includes(marker));
108
+
109
+ function readProject(id, saved) {
110
+ const fail = label => { throw Error(id+' 的 '+label+' 无效,请用 home-project-changelog 核对。'); };
111
+ if (!plain(saved) || saved.schemaVersion !== 1 || saved.repoId !== id || !plain(saved.initialization) || !Array.isArray(saved.ranges)
112
+ || !saved.ranges.length
113
+ || saved.lastSuccessfulRangeId !== (saved.ranges.at(-1)?.rangeId ?? null)
114
+ || saved.notes !== undefined && !notesList(saved.notes)
115
+ || saved.displayName !== undefined && !line(saved.displayName)) fail('项目 JSON');
116
+ if (Object.hasOwn(saved,'pending')) throw Error(id+' 的日志有待确认写入,请先用 home-project-changelog 恢复。');
117
+ let previous = null;
118
+ const rangeIds = new Set();
119
+ const taskIds = new Set();
120
+ for (const range of saved.ranges) {
121
+ const dates = range?.displayDates;
122
+ const count = range?.stats?.rangeCommitCount;
123
+ const head = range?.stats?.totalCommitCountAtHead;
124
+ const baseline = ['baseline','rebaseline'].includes(range?.kind);
125
+ if (!plain(range) || !line(range.rangeId) || rangeIds.has(range.rangeId) || range.previousRangeId !== previous
126
+ || typeof range.savedAt !== 'string' || !Number.isFinite(Date.parse(range.savedAt))
127
+ || !['full-history','delta','baseline','rebaseline'].includes(range.kind)
128
+ || range.coverage !== (baseline ? 'not-backfilled' : 'complete')
129
+ || !plain(dates) || !validDay(dates.to) || (dates.from !== null && (!validDay(dates.from) || dates.from > dates.to))
130
+ || !Number.isSafeInteger(count) || (baseline ? (dates.from !== null || count !== 0) : count <= 0)
131
+ || (head !== null && (!Number.isSafeInteger(head) || head < count))
132
+ || (range.collectionAt !== undefined && !collectionTime(range.collectionAt))
133
+ || !lineCount(range.stats.linesAdded) || !lineCount(range.stats.linesDeleted)
134
+ || range.notes !== undefined && !notesList(range.notes)
135
+ || Object.hasOwn(range,'ledger') === Object.hasOwn(range,'legacy')) fail('成功区间');
136
+ rangeIds.add(range.rangeId);
137
+ previous = range.rangeId;
138
+
139
+ if (Object.hasOwn(range,'legacy')) {
140
+ const {legacy} = range;
141
+ if (!plain(legacy) || !Array.isArray(legacy.entries) || !legacy.entries.every(validEntry)
142
+ || baseline && legacy.entries.length
143
+ || legacy.added != null && (!Number.isSafeInteger(legacy.added) || legacy.added < 0
144
+ || legacy.added > legacy.entries.filter(entry => entry.category === '功能').length)) fail('历史补记');
145
+ continue;
146
+ }
147
+ const {ledger} = range;
148
+ if (!plain(ledger) || ledger.version !== 1 || !plain(ledger.commitMonths) || !Array.isArray(ledger.tasks)) fail('任务明细');
149
+ const months = Object.entries(ledger.commitMonths);
150
+ if (!months.every(([month,amount]) => validDay(month+'-01') && Number.isSafeInteger(amount) && amount > 0)
151
+ || months.reduce((total,[,amount]) => total + amount,0) !== count
152
+ || baseline && ledger.tasks.length) fail('任务明细');
153
+ for (const task of ledger.tasks) {
154
+ if (!validEntry(task) || typeof task.id !== 'string' || !/^task-[0-9a-f]{16}$/u.test(task.id) || taskIds.has(task.id)
155
+ || !validDay(task.date) || !Object.hasOwn(ledger.commitMonths,task.date.slice(0,7))
156
+ || task.area !== null && !line(task.area) || !oidList(task.commits) || !task.commits.includes(task.deliveredBy)
157
+ || task.relatedCommits !== undefined && !oidList(task.relatedCommits)
158
+ || task.added !== undefined && (task.category !== '功能' || typeof task.added !== 'boolean')) fail('任务明细');
159
+ taskIds.add(task.id);
144
160
  }
145
- return found;
146
- }
147
- // 两个方向分别找最早和最晚的配对。两者都相同时,已保存区间的有序配对才唯一。
148
- const forward = ordered(saved.ranges,oldest);
149
- const backward = ordered([...saved.ranges].reverse(),blocks).reverse();
150
- if (forward.some((period,index) => period !== backward[index])) throw Error(id+' 的成功区间与 Markdown 有多种配对,请先核对原文。');
151
- if (forward.length !== parsed.periods.length) warnings.push(id+' 有未匹配的日期段,保留在 Home。');
152
- if (parsed.legacy) warnings.push(id+' 含历史补记,保留在单仓页。');
153
- const paired = forward.map((block,index) => ({period:bodyFor(block,saved.ranges[index]),range:saved.ranges[index]}));
154
- for (const {period} of paired) {
155
- if (period.notes.some(note => /^### |^[-*+] /u.test(note))) warnings.push(id+' '+period.key+' 含额外正文,保留在区间说明。');
156
161
  }
157
- return paired.reverse();
162
+ return saved;
158
163
  }
159
164
 
160
- function publicPeriod(id, period, range, text) {
161
- const { ledger } = range;
162
- let items, commitMonths;
163
- if (ledger === undefined) {
164
- items = period.items.map(([category, value, markers]) => [category, text(value), markers]);
165
- } else {
166
- const fail = () => { throw Error(id+' 的任务明细与成功记录不一致,请用 home-project-changelog 修订该区间。'); };
167
- if (ledger?.version !== 1 || !plain(ledger.commitMonths) || !Array.isArray(ledger.tasks)
168
- || ledger.tasks.length !== period.items.length) fail();
169
- commitMonths = {};
170
- let total = 0;
171
- for (const [month,count] of Object.entries(ledger.commitMonths)) {
172
- if (!validDay(month+'-01') || !Number.isSafeInteger(count) || count <= 0) fail();
173
- total += count;
174
- commitMonths[month] = count;
175
- }
176
- if (total !== period.commits) fail();
177
- const ids = new Set();
178
- items = period.items.map(([category,value,markers,meta],index) => {
179
- const task = ledger.tasks[index];
180
- if (!plain(task) || typeof task.id !== 'string' || !/^task-[0-9a-f]{16}$/u.test(task.id) || ids.has(task.id)
181
- || !validDay(task.date) || !commitMonths[task.date.slice(0,7)] || task.date !== meta?.date
182
- || task.area !== meta.area || (task.area !== null && !line(task.area))
183
- || task.category !== category || task.text !== value || JSON.stringify(task.markers) !== JSON.stringify(markers)) fail();
184
- ids.add(task.id);
185
- return [category,text(value),markers,{id:task.id,date:task.date,area:task.area && text(task.area)}];
186
- });
187
- const features = ledger.tasks.filter(task => task.category === '功能');
188
- const added = features.every(task => typeof task.added === 'boolean') ? features.filter(task => task.added).length : null;
189
- if (period.added !== added) fail();
190
- }
191
- const notes = period.notes.map(text);
192
- return {...period,items,notes,note:notes.join('\n'),commitMonths};
165
+ function publicPeriods(project, text) {
166
+ const occurrences = new Map();
167
+ return project.ranges.map(range => {
168
+ const { from, to } = range.displayDates;
169
+ const pair = (from ?? 'single')+'_'+to;
170
+ const occurrence = (occurrences.get(pair) ?? 0) + 1;
171
+ occurrences.set(pair,occurrence);
172
+ const notes = (range.notes ?? []).map(text);
173
+ const entries = range.ledger?.tasks ?? range.legacy.entries;
174
+ const items = entries.map(({id,category,text:body,markers,date,area}) => range.ledger
175
+ ? [category,text(body),markers,{id,date,area:area === null ? null : text(area)}]
176
+ : [category,text(body),markers]);
177
+ const features = entries.filter(entry => entry.category === '功能');
178
+ const added = range.ledger
179
+ ? (features.every(entry => typeof entry.added === 'boolean') ? features.filter(entry => entry.added).length : null)
180
+ : (Object.hasOwn(range.legacy,'added') ? range.legacy.added : features.length ? null : 0);
181
+ return {
182
+ key:pair+'-'+occurrence,from,to,items,notes,note:notes.join('\n'),commits:range.stats.rangeCommitCount,added,
183
+ collectionAt:range.collectionAt, timezone:range.displayDates.timezone,
184
+ linesAdded:range.stats.linesAdded ?? null, linesDeleted:range.stats.linesDeleted ?? null,
185
+ coverage:range.coverage,baseline:range.coverage === 'not-backfilled',commitMonths:range.ledger?.commitMonths,
186
+ };
187
+ }).reverse();
193
188
  }
194
189
 
195
- export function inputs(website) {
190
+ export function inputs(website, {checkOnly = false} = {}) {
196
191
  const home = path.dirname(website);
197
192
  const sources = [];
198
193
  function take(filename, required = false) {
@@ -208,44 +203,64 @@ export function inputs(website) {
208
203
  try { return JSON.parse(decode(bytes)); } catch { throw Error(name+' 无法读取为 UTF-8 JSON。'); }
209
204
  };
210
205
  const settings = config(parse(take(path.join(website,'site.config.json'),true),'site.config.json'));
211
- const registered = records(parse(take(path.join(home,'repos.json'),true),'repos.json'));
212
- const logs = path.join(home,'changelogs');
206
+ const registry = parse(take(path.join(home,'repos.json'),true),'repos.json');
207
+ const registered = records(registry);
208
+ if (registry.projectNames !== undefined && (!plain(registry.projectNames) || Object.entries(registry.projectNames)
209
+ .some(([id, name]) => !/^[a-z0-9][a-z0-9-]*$/u.test(id) || !line(name) || name.trim() !== name))) throw Error('repos.json 的 projectNames 需要稳定 ID 与单行首选名称。');
210
+ const names = new Map(Object.entries(registry.projectNames ?? {}));
211
+ const logs = path.join(website,'changelogs');
213
212
  directory(logs);
214
- const stateBytes = take(path.join(logs,'state.json'));
215
- const state = readState(stateBytes ? parse(stateBytes,'state.json') : undefined);
216
- const warnings = [], excluded = [];
213
+ const warnings = [], excluded = [], eligible = [], needsGeneration = [];
217
214
  const privateValues = [...new Set(registered.flatMap(repo => [
218
215
  repo.localPath, repo.remote, repo.backgroundRef,
219
216
  ...(Array.isArray(repo.remotes) ? repo.remotes.flatMap(remote => [...(remote?.urls ?? []), ...(remote?.pushUrls ?? [])]) : []),
220
217
  ]).filter(value => typeof value === 'string' && value.length >= 3))].sort((a,b) => b.length-a.length);
221
218
  const text = value => publicText(value, privateValues);
222
219
  const projects = [];
223
- for (const repo of registered) {
220
+ const registeredIds = new Set(registered.map(repo => repo.id));
221
+ const candidates = [...registered];
222
+ for (const [id, item] of settings.byId) {
223
+ if (!item.submoduleOf) continue;
224
+ if (!registeredIds.has(item.submoduleOf) || settings.byId.get(item.submoduleOf)?.submoduleOf) throw Error(id+' 需要已登记的顶层父项目。');
225
+ if (!registeredIds.has(id)) candidates.push({id,purpose:item.summary ?? item.submoduleOf+' 的 Git 子模块'});
226
+ }
227
+ for (const id of settings.projectIds ?? []) {
228
+ if (!registeredIds.has(id) && !settings.byId.get(id)?.submoduleOf) candidates.push({id,purpose:'',sourceOnly:true});
229
+ }
230
+ for (const repo of candidates) {
224
231
  const {id} = repo;
232
+ const parent = settings.byId.get(id)?.submoduleOf;
233
+ const parentSettings = settings.byId.get(parent);
234
+ if (parentSettings?.hidden || parentSettings?.showChangelog === false) { excluded.push({id,reason:'parent-hidden'}); continue; }
235
+ if (settings.projectIds && !settings.projectIds.has(id) && !settings.projectIds.has(parent)) { excluded.push({id,reason:'outside-scope'}); continue; }
225
236
  const override = settings.byId.get(id) ?? {};
226
- if (override.hidden) { excluded.push({id, reason:'hidden'}); continue; }
237
+ if (override.hidden) { excluded.push({id,reason:'hidden'}); continue; }
227
238
  if (override.showChangelog === false) { excluded.push({id,reason:'changelog-disabled'}); continue; }
228
- const saved = Object.hasOwn(state,id) ? state[id] : undefined;
229
- if (!saved) { excluded.push({id,reason:'no-state'}); continue; }
230
- if (saved.pending) throw Error(id+' 的日志有待确认写入,请先用 home-project-changelog 恢复。');
231
- const bytes = take(path.join(logs,id+'.md'));
232
- if (!bytes) throw Error(id+' 的日志正文缺失,请先恢复 Markdown。');
233
- let body;
234
- try { body = decode(bytes); } catch { throw Error(id+' 的日志正文需要可读的 UTF-8 Markdown。'); }
235
- const dated = saved.ranges.some(range=>range.ledger) ? parseMarkdown(body,{datedOnly:true}) : null;
236
- const parsed = saved.ranges.some(range=>!range.ledger) ? parseMarkdown(body) : dated;
237
- const periods = savedPeriods(id,parsed,dated,saved,warnings).map(({period,range}) => publicPeriod(id,period,range,text));
239
+ const filename = id+'.json';
240
+ const source = '.agents/home/website/changelogs/'+filename;
241
+ const bytes = take(path.join(logs,filename));
242
+ const saved = bytes && readProject(id,parse(bytes,filename));
243
+ const status = saved ? 'saved' : 'missing';
244
+ eligible.push({id,source,status,...(repo.sourceOnly && {sourceOnly:true}),...(parent && {parent,submodulePath:override.submodulePath ?? id})});
245
+ if (status !== 'saved') {
246
+ needsGeneration.push({id,source,reason:status});
247
+ excluded.push({id,reason:'no-changelog'});
248
+ continue;
249
+ }
250
+ if (checkOnly) continue;
251
+ const periods = publicPeriods(saved,text);
252
+ if (saved.ranges.some(range => range.legacy)) warnings.push(id+' 含缺少任务证据的历史区间,保留原统计。');
238
253
  const index = projects.length;
239
254
  projects.push({
240
- id, name:text(override.displayName ?? id), purpose:text(override.summary ?? repo.purpose),
255
+ id, parent, name:text(names.get(id) ?? override.displayName ?? saved.displayName ?? id),purpose:text(override.summary ?? repo.purpose),
241
256
  groups:(repo.groups ?? []).filter(group => settings.publicGroups.includes(group)).map(text),
242
- color:colors[index % colors.length], mark:marks[index % marks.length], repoUrl:override.repoUrl, docsUrl:override.docsUrl,
243
- periods, stats:statistics(periods), headCommits:saved.ranges.at(-1).stats.totalCommitCountAtHead ?? null,
244
- legacy:text(parsed.legacy),
257
+ color:colors[index % colors.length],mark:marks[index % marks.length],repoUrl:override.repoUrl,docsUrl:override.docsUrl,
258
+ periods,stats:statistics(periods),headCommits:saved.ranges.at(-1).stats.totalCommitCountAtHead,
259
+ legacy:(saved.notes ?? []).map(text).join('\n'),
245
260
  });
246
261
  }
247
262
  return {
248
263
  model:{title:text(settings.title),base:settings.base,projects},
249
- inputRevision:JSON.stringify(sources), hasState:Boolean(stateBytes), warnings, excluded
264
+ inputRevision:JSON.stringify(sources),eligible,needsGeneration,warnings,excluded,
250
265
  };
251
266
  }
@@ -21,6 +21,7 @@ export function render(website, run, model) {
21
21
  const {title,base,projects} = model;
22
22
  const windows = observationWindows(projects);
23
23
  const stats = statistics(projects.flatMap(project => project.periods));
24
+ const favicon = fs.readFileSync(path.join(website,'site/templates/favicon.png')).toString('base64');
24
25
  const source = path.join(run,'src');
25
26
  const dist = path.join(run,'dist');
26
27
  fs.cpSync(path.join(website,'site/.vitepress'),path.join(source,'.vitepress'),{recursive:true});
@@ -28,7 +29,7 @@ export function render(website, run, model) {
28
29
  const shape = {
29
30
  title, base, outDir:dist, lang:'zh-CN', cleanUrls:true, appearance:false, lastUpdated:false, mpa:true,
30
31
  head:[
31
- ['link',{rel:'icon',href:'data:,'}],
32
+ ['link',{rel:'icon',type:'image/png',href:'data:image/png;base64,'+favicon}],
32
33
  ['link',{rel:'stylesheet',href:base+'home-assets/site.css'}],
33
34
  ['script',{src:base+'home-assets/start.js'}],
34
35
  ['script',{defer:'',src:base+'home-assets/search-index.js'}],
@@ -58,7 +59,7 @@ export function render(website, run, model) {
58
59
  +'<script setup>\nimport page from "./'+name+'.content.json";\n</script>\n\n<div v-html="page.markup"></div>\n');
59
60
  urls.push(stem+'.html');
60
61
  }
61
- page('',title,'home',overview(base,projects,windows,stats));
62
+ page('',title,'home',overview(base,projects,stats));
62
63
  page('projects/','项目目录','projects',catalog(base,projects));
63
64
  page('changelog/','变更时间线','changelog',changelog(base,projects,windows,stats));
64
65
  urls.push('404.html');
@@ -66,20 +67,21 @@ export function render(website, run, model) {
66
67
  const catalogData = {schemaVersion:2,stats,projects:[],months:activityMonths(projects).map(({key,changes,commits,groups}) => ({
67
68
  month:key === 'undated' ? null : key,changes,commits,
68
69
  projects:groups.map(({project,commits,rows}) => ({id:project.id,commits,changes:rows.filter(row=>row.index >= 0).length})),
69
- })),windows:windows.map(({from,to,groups,rangeCount,stats}) => ({
70
- from, to, projects:groups.map(({project}) => project.id), rangeCount, stats,
70
+ })),windows:windows.map(({key,from,to,at,fromAt,groups,rangeCount,stats}) => ({
71
+ key, from, to, collectionAt:at ?? null, previousCollectionAt:fromAt ?? null,
72
+ projects:groups.map(({project}) => project.id), rangeCount, stats,
71
73
  }))};
72
74
  const expectedData = new Map();
73
75
  for (const project of projects) {
74
76
  const {id,name,purpose,groups,periods,legacy} = project;
75
77
  const data = 'projects/'+id+'.json';
76
78
  const projected = publicProject(project);
77
- page(projectPath(project),name,'projects',detail(base,project,projected.stats));
79
+ page(projectPath(project),name,'projects',detail(base,project,projected.stats,projects));
78
80
  index.push({kind:'项目',name,id,title:name,text:purpose,group:groups.join(' '),url:projectPath(project)});
79
81
  page(logPath(project),name+' 变更日志','projects',repositoryLog(base,project,projected.stats));
80
82
  for (const period of periods) {
81
83
  const date = rangeLabel(period);
82
- if (!period.items.length) index.push({kind:'区间',name,id,title:periodTitle(period),text:period.note,date,url:logPath(project,period)});
84
+ if (!period.items.length || period.note) index.push({kind:'区间',name,id,title:periodTitle(period),text:period.note,date,url:logPath(project,period)});
83
85
  period.items.forEach(([category,text,markers,meta],i) => {
84
86
  index.push({kind:'变更',name,id,title:text,text:[category,meta?.area,...markers].filter(Boolean).join(' · '),
85
87
  date:meta?.date ?? date,url:logPath(project)+'#'+itemId(period,i)});
@@ -62,11 +62,18 @@ function artifactMatches(fingerprintValue, record) {
62
62
  if (record?.fingerprint !== fingerprintValue || !Array.isArray(record.files) || !directory(dist)) return false;
63
63
  return JSON.stringify(manifest(dist)) === JSON.stringify(record.files);
64
64
  }
65
- function hadSavedLogs(record) {
66
- if (record?.hasState !== undefined) return record.hasState;
67
- if (!directory(dist)) return false;
68
- const catalog = read(path.join(dist,'data','catalog.json'));
69
- return catalog && JSON.parse(catalog).projects.some(project => project.ranges > 0);
65
+ function guardSources(record, needsGeneration) {
66
+ if (!needsGeneration.length) return;
67
+ let projectIds = record?.projects;
68
+ if (!Array.isArray(projectIds)) {
69
+ const catalog = directory(dist) && directory(path.join(dist,'data')) && read(path.join(dist,'data','catalog.json'));
70
+ projectIds = catalog ? JSON.parse(catalog).projects.filter(project => project.ranges > 0).map(project => project.id) : [];
71
+ }
72
+ const published = new Set(projectIds);
73
+ const missing = needsGeneration.filter(({id}) => published.has(id));
74
+ if (missing.length) {
75
+ throw Error('已构建的项目缺少成功日志,请先恢复或用 home-project-changelog 生成:'+missing.map(({source}) => source).join('、')+'。');
76
+ }
70
77
  }
71
78
  function publish(candidate, record, run) {
72
79
  const tempMeta = path.join(run,'current.json');
@@ -102,13 +109,13 @@ function refresh(force) {
102
109
  try {
103
110
  restoreDist();
104
111
  const snapshot = inputs(website);
105
- const {model,warnings,excluded} = snapshot;
112
+ const {model,warnings,excluded,needsGeneration} = snapshot;
106
113
  const before = current();
107
- if (!snapshot.hasState && hadSavedLogs(before)) throw Error('已构建的网站缺少 changelogs/state.json,请先核对 Home 或恢复状态文件。');
114
+ guardSources(before,needsGeneration);
108
115
  const key = fingerprint(website,model);
109
116
  const projectIds = model.projects.map(project=>project.id);
110
117
  const stats = statistics(model.projects.flatMap(project=>project.periods));
111
- const summary = {base:model.base,projects:projectIds.length,entries:stats.changes,stats,warnings,excluded,dist};
118
+ const summary = {base:model.base,projects:projectIds.length,entries:stats.changes,stats,warnings,excluded,needsGeneration,dist};
112
119
  if (!force && artifactMatches(key,before)) return {status:'unchanged', ...summary};
113
120
  const cli = path.join(website,'node_modules','vitepress','bin','vitepress.js');
114
121
  if (!fs.existsSync(cli)) throw Error('网站尚未安装依赖,请在网站目录运行 npm ci,再重试。');
@@ -127,7 +134,7 @@ function refresh(force) {
127
134
  if (after.inputRevision !== snapshot.inputRevision || fingerprint(website,after.model) !== key) {
128
135
  throw Error('构建时 Home 或网站源文件已变化,保留上次版本,请重试。');
129
136
  }
130
- publish(candidate.dist,{fingerprint:key,base:model.base,projects:projectIds,hasState:snapshot.hasState,files:publishedFiles},run);
137
+ publish(candidate.dist,{fingerprint:key,base:model.base,projects:projectIds,files:publishedFiles},run);
131
138
  return {status:'built', ...summary,
132
139
  added:projectIds.filter(id=>!before?.projects?.includes(id)),
133
140
  removed:(before?.projects ?? []).filter(id=>!projectIds.includes(id)),
@@ -157,7 +164,11 @@ function recover() {
157
164
  const [command = 'refresh', ...args] = process.argv.slice(2);
158
165
  try {
159
166
  const {values} = parseArgs({args,options:{force:{type:'boolean'},port:{type:'string'},help:{type:'boolean'}}});
160
- if (values.help) console.log('用法:node scripts/site.mjs refresh [--force] | preview [--port 4173] | recover');
167
+ if (values.help) console.log('用法:node scripts/site.mjs sources | refresh [--force] | preview [--port 4173] | recover');
168
+ else if (command === 'sources' && values.port === undefined && !values.force) {
169
+ const {eligible,needsGeneration,excluded} = inputs(website,{checkOnly:true});
170
+ console.log(JSON.stringify({status:'ready',eligible,needsGeneration,excluded},null,2));
171
+ }
161
172
  else if (command === 'refresh' && values.port === undefined) console.log(JSON.stringify(refresh(values.force),null,2));
162
173
  else if (command === 'recover' && values.port === undefined && !values.force) {
163
174
  mkdir(cache);