imhcode 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (986) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.md +41 -0
  2. package/.github/ISSUE_TEMPLATE/feature_request.md +39 -0
  3. package/.github/PULL_REQUEST_TEMPLATE.md +29 -0
  4. package/.github/copilot-instructions.md +43 -0
  5. package/.github/workflows/framework-validator.yml +53 -0
  6. package/.gitignore.template +15 -0
  7. package/AGENTS.md +69 -0
  8. package/CLAUDE.md +27 -0
  9. package/README.md +63 -0
  10. package/SETUP.md +81 -0
  11. package/USER_MANUAL.md +70 -0
  12. package/agents/android-executor/SYSTEM.md +32 -0
  13. package/agents/android-executor/agent.yml +53 -0
  14. package/agents/debugger/SYSTEM.md +32 -0
  15. package/agents/debugger/agent.yml +56 -0
  16. package/agents/designer/SYSTEM.md +32 -0
  17. package/agents/designer/agent.yml +59 -0
  18. package/agents/devops-executor/SYSTEM.md +32 -0
  19. package/agents/devops-executor/agent.yml +56 -0
  20. package/agents/flutter-executor/SYSTEM.md +32 -0
  21. package/agents/flutter-executor/agent.yml +54 -0
  22. package/agents/ios-executor/SYSTEM.md +32 -0
  23. package/agents/ios-executor/agent.yml +53 -0
  24. package/agents/java-executor/SYSTEM.md +32 -0
  25. package/agents/java-executor/agent.yml +57 -0
  26. package/agents/laravel-executor/SYSTEM.md +32 -0
  27. package/agents/laravel-executor/agent.yml +59 -0
  28. package/agents/nextjs-executor/SYSTEM.md +32 -0
  29. package/agents/nextjs-executor/agent.yml +60 -0
  30. package/agents/planner/SYSTEM.md +32 -0
  31. package/agents/planner/agent.yml +56 -0
  32. package/agents/python-executor/SYSTEM.md +32 -0
  33. package/agents/python-executor/agent.yml +58 -0
  34. package/agents/react-executor/SYSTEM.md +32 -0
  35. package/agents/react-executor/agent.yml +58 -0
  36. package/agents/react-native-executor/SYSTEM.md +32 -0
  37. package/agents/react-native-executor/agent.yml +53 -0
  38. package/agents/security-auditor/SYSTEM.md +32 -0
  39. package/agents/security-auditor/agent.yml +56 -0
  40. package/agents/seo-optimizer/SYSTEM.md +32 -0
  41. package/agents/seo-optimizer/agent.yml +54 -0
  42. package/agents/systems-executor/SYSTEM.md +32 -0
  43. package/agents/systems-executor/agent.yml +54 -0
  44. package/agents/tester/SYSTEM.md +32 -0
  45. package/agents/tester/agent.yml +58 -0
  46. package/agents/vue-executor/SYSTEM.md +32 -0
  47. package/agents/vue-executor/agent.yml +58 -0
  48. package/agents/web3-executor/SYSTEM.md +32 -0
  49. package/agents/web3-executor/agent.yml +55 -0
  50. package/bin/imhcode.js +1634 -0
  51. package/dist/orchestrator/builder.d.ts +23 -0
  52. package/dist/orchestrator/builder.d.ts.map +1 -0
  53. package/dist/orchestrator/builder.js +231 -0
  54. package/dist/orchestrator/builder.js.map +1 -0
  55. package/dist/orchestrator/executor.d.ts +43 -0
  56. package/dist/orchestrator/executor.d.ts.map +1 -0
  57. package/dist/orchestrator/executor.js +356 -0
  58. package/dist/orchestrator/executor.js.map +1 -0
  59. package/dist/orchestrator/index.d.ts +35 -0
  60. package/dist/orchestrator/index.d.ts.map +1 -0
  61. package/dist/orchestrator/index.js +490 -0
  62. package/dist/orchestrator/index.js.map +1 -0
  63. package/dist/orchestrator/loader.d.ts +33 -0
  64. package/dist/orchestrator/loader.d.ts.map +1 -0
  65. package/dist/orchestrator/loader.js +203 -0
  66. package/dist/orchestrator/loader.js.map +1 -0
  67. package/dist/orchestrator/registry.d.ts +63 -0
  68. package/dist/orchestrator/registry.d.ts.map +1 -0
  69. package/dist/orchestrator/registry.js +181 -0
  70. package/dist/orchestrator/registry.js.map +1 -0
  71. package/dist/orchestrator/schema.d.ts +132 -0
  72. package/dist/orchestrator/schema.d.ts.map +1 -0
  73. package/dist/orchestrator/schema.js +101 -0
  74. package/dist/orchestrator/schema.js.map +1 -0
  75. package/dist/orchestrator/session.d.ts +25 -0
  76. package/dist/orchestrator/session.d.ts.map +1 -0
  77. package/dist/orchestrator/session.js +80 -0
  78. package/dist/orchestrator/session.js.map +1 -0
  79. package/dist/orchestrator/types.d.ts +91 -0
  80. package/dist/orchestrator/types.d.ts.map +1 -0
  81. package/dist/orchestrator/types.js +7 -0
  82. package/dist/orchestrator/types.js.map +1 -0
  83. package/package.json +95 -0
  84. package/skills/AnimatePresence/SKILL.md +3 -0
  85. package/skills/accessibility/SKILL.md +146 -0
  86. package/skills/agent-architecture-audit/SKILL.md +256 -0
  87. package/skills/agent-eval/SKILL.md +145 -0
  88. package/skills/agent-introspection-debugging/SKILL.md +153 -0
  89. package/skills/agentic-engineering/SKILL.md +63 -0
  90. package/skills/ai-regression-testing/SKILL.md +385 -0
  91. package/skills/android-clean-architecture/SKILL.md +339 -0
  92. package/skills/animated-component-libraries/SKILL.md +8 -0
  93. package/skills/animejs/SKILL.md +8 -0
  94. package/skills/api-connector-builder/SKILL.md +120 -0
  95. package/skills/api-design/SKILL.md +523 -0
  96. package/skills/apple/SKILL.md +158 -0
  97. package/skills/apple/metadata.json +16 -0
  98. package/skills/architecture-decision-records/SKILL.md +179 -0
  99. package/skills/article-writing/SKILL.md +79 -0
  100. package/skills/automation-audit-ops/SKILL.md +142 -0
  101. package/skills/awwwards/SKILL.md +162 -0
  102. package/skills/awwwards/metadata.json +16 -0
  103. package/skills/babylonjs-engine/SKILL.md +8 -0
  104. package/skills/backend-patterns/SKILL.md +561 -0
  105. package/skills/baqir-docs/SKILL.md +3 -0
  106. package/skills/barba-js/SKILL.md +8 -0
  107. package/skills/benchmark/SKILL.md +93 -0
  108. package/skills/best-practice/SKILL.md +7 -0
  109. package/skills/best-practice/assets/claude-memory/claude-memory-monorepo.jpg +0 -0
  110. package/skills/best-practice/assets/claude-power-ups/dial-the-model-1.png +0 -0
  111. package/skills/best-practice/assets/claude-power-ups/dial-the-model-2.png +0 -0
  112. package/skills/best-practice/assets/claude-power-ups/dial-the-model-3.png +0 -0
  113. package/skills/best-practice/assets/claude-power-ups/powerup-menu.png +0 -0
  114. package/skills/best-practice/claude-cli-startup-flags.md +231 -0
  115. package/skills/best-practice/claude-commands.md +132 -0
  116. package/skills/best-practice/claude-mcp.md +132 -0
  117. package/skills/best-practice/claude-memory.md +121 -0
  118. package/skills/best-practice/claude-power-ups.md +66 -0
  119. package/skills/best-practice/claude-settings.md +1170 -0
  120. package/skills/best-practice/claude-skills.md +58 -0
  121. package/skills/best-practice/claude-subagents.md +56 -0
  122. package/skills/blender-motion-state-inspection/SKILL.md +164 -0
  123. package/skills/bootstrap-patterns/SKILL.md +316 -0
  124. package/skills/brand-guidelines/LICENSE.txt +202 -0
  125. package/skills/brand-guidelines/SKILL.md +73 -0
  126. package/skills/brand-voice/SKILL.md +97 -0
  127. package/skills/brand-voice/references/voice-profile-schema.md +55 -0
  128. package/skills/browser-qa/SKILL.md +87 -0
  129. package/skills/canary-watch/SKILL.md +107 -0
  130. package/skills/canvas-design/LICENSE.txt +202 -0
  131. package/skills/canvas-design/SKILL.md +8 -0
  132. package/skills/canvas-design/canvas-fonts/ArsenalSC-OFL.txt +93 -0
  133. package/skills/canvas-design/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
  134. package/skills/canvas-design/canvas-fonts/BigShoulders-Bold.ttf +0 -0
  135. package/skills/canvas-design/canvas-fonts/BigShoulders-OFL.txt +93 -0
  136. package/skills/canvas-design/canvas-fonts/BigShoulders-Regular.ttf +0 -0
  137. package/skills/canvas-design/canvas-fonts/Boldonse-OFL.txt +93 -0
  138. package/skills/canvas-design/canvas-fonts/Boldonse-Regular.ttf +0 -0
  139. package/skills/canvas-design/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  140. package/skills/canvas-design/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
  141. package/skills/canvas-design/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  142. package/skills/canvas-design/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
  143. package/skills/canvas-design/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
  144. package/skills/canvas-design/canvas-fonts/CrimsonPro-OFL.txt +93 -0
  145. package/skills/canvas-design/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
  146. package/skills/canvas-design/canvas-fonts/DMMono-OFL.txt +93 -0
  147. package/skills/canvas-design/canvas-fonts/DMMono-Regular.ttf +0 -0
  148. package/skills/canvas-design/canvas-fonts/EricaOne-OFL.txt +94 -0
  149. package/skills/canvas-design/canvas-fonts/EricaOne-Regular.ttf +0 -0
  150. package/skills/canvas-design/canvas-fonts/GeistMono-Bold.ttf +0 -0
  151. package/skills/canvas-design/canvas-fonts/GeistMono-OFL.txt +93 -0
  152. package/skills/canvas-design/canvas-fonts/GeistMono-Regular.ttf +0 -0
  153. package/skills/canvas-design/canvas-fonts/Gloock-OFL.txt +93 -0
  154. package/skills/canvas-design/canvas-fonts/Gloock-Regular.ttf +0 -0
  155. package/skills/canvas-design/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
  156. package/skills/canvas-design/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
  157. package/skills/canvas-design/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
  158. package/skills/canvas-design/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
  159. package/skills/canvas-design/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
  160. package/skills/canvas-design/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
  161. package/skills/canvas-design/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
  162. package/skills/canvas-design/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  163. package/skills/canvas-design/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  164. package/skills/canvas-design/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  165. package/skills/canvas-design/canvas-fonts/InstrumentSans-OFL.txt +93 -0
  166. package/skills/canvas-design/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  167. package/skills/canvas-design/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  168. package/skills/canvas-design/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
  169. package/skills/canvas-design/canvas-fonts/Italiana-OFL.txt +93 -0
  170. package/skills/canvas-design/canvas-fonts/Italiana-Regular.ttf +0 -0
  171. package/skills/canvas-design/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  172. package/skills/canvas-design/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
  173. package/skills/canvas-design/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
  174. package/skills/canvas-design/canvas-fonts/Jura-Light.ttf +0 -0
  175. package/skills/canvas-design/canvas-fonts/Jura-Medium.ttf +0 -0
  176. package/skills/canvas-design/canvas-fonts/Jura-OFL.txt +93 -0
  177. package/skills/canvas-design/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
  178. package/skills/canvas-design/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
  179. package/skills/canvas-design/canvas-fonts/Lora-Bold.ttf +0 -0
  180. package/skills/canvas-design/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  181. package/skills/canvas-design/canvas-fonts/Lora-Italic.ttf +0 -0
  182. package/skills/canvas-design/canvas-fonts/Lora-OFL.txt +93 -0
  183. package/skills/canvas-design/canvas-fonts/Lora-Regular.ttf +0 -0
  184. package/skills/canvas-design/canvas-fonts/NationalPark-Bold.ttf +0 -0
  185. package/skills/canvas-design/canvas-fonts/NationalPark-OFL.txt +93 -0
  186. package/skills/canvas-design/canvas-fonts/NationalPark-Regular.ttf +0 -0
  187. package/skills/canvas-design/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
  188. package/skills/canvas-design/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
  189. package/skills/canvas-design/canvas-fonts/Outfit-Bold.ttf +0 -0
  190. package/skills/canvas-design/canvas-fonts/Outfit-OFL.txt +93 -0
  191. package/skills/canvas-design/canvas-fonts/Outfit-Regular.ttf +0 -0
  192. package/skills/canvas-design/canvas-fonts/PixelifySans-Medium.ttf +0 -0
  193. package/skills/canvas-design/canvas-fonts/PixelifySans-OFL.txt +93 -0
  194. package/skills/canvas-design/canvas-fonts/PoiretOne-OFL.txt +93 -0
  195. package/skills/canvas-design/canvas-fonts/PoiretOne-Regular.ttf +0 -0
  196. package/skills/canvas-design/canvas-fonts/RedHatMono-Bold.ttf +0 -0
  197. package/skills/canvas-design/canvas-fonts/RedHatMono-OFL.txt +93 -0
  198. package/skills/canvas-design/canvas-fonts/RedHatMono-Regular.ttf +0 -0
  199. package/skills/canvas-design/canvas-fonts/Silkscreen-OFL.txt +93 -0
  200. package/skills/canvas-design/canvas-fonts/Silkscreen-Regular.ttf +0 -0
  201. package/skills/canvas-design/canvas-fonts/SmoochSans-Medium.ttf +0 -0
  202. package/skills/canvas-design/canvas-fonts/SmoochSans-OFL.txt +93 -0
  203. package/skills/canvas-design/canvas-fonts/Tektur-Medium.ttf +0 -0
  204. package/skills/canvas-design/canvas-fonts/Tektur-OFL.txt +93 -0
  205. package/skills/canvas-design/canvas-fonts/Tektur-Regular.ttf +0 -0
  206. package/skills/canvas-design/canvas-fonts/WorkSans-Bold.ttf +0 -0
  207. package/skills/canvas-design/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
  208. package/skills/canvas-design/canvas-fonts/WorkSans-Italic.ttf +0 -0
  209. package/skills/canvas-design/canvas-fonts/WorkSans-OFL.txt +93 -0
  210. package/skills/canvas-design/canvas-fonts/WorkSans-Regular.ttf +0 -0
  211. package/skills/canvas-design/canvas-fonts/YoungSerif-OFL.txt +93 -0
  212. package/skills/canvas-design/canvas-fonts/YoungSerif-Regular.ttf +0 -0
  213. package/skills/caveman/SKILL.md +74 -0
  214. package/skills/changelog-generator/SKILL.md +104 -0
  215. package/skills/cisco-ios-patterns/SKILL.md +163 -0
  216. package/skills/ckm:design-system/SKILL.md +3 -0
  217. package/skills/ckm:slides/SKILL.md +3 -0
  218. package/skills/claude-red/SKILL.md +35 -0
  219. package/skills/click-path-audit/SKILL.md +244 -0
  220. package/skills/clickhouse-io/SKILL.md +439 -0
  221. package/skills/codebase-onboarding/SKILL.md +233 -0
  222. package/skills/coding-standards/SKILL.md +549 -0
  223. package/skills/compose-multiplatform-patterns/SKILL.md +299 -0
  224. package/skills/computational-architecture/SKILL.md +31 -0
  225. package/skills/content-engine/SKILL.md +131 -0
  226. package/skills/content-research-writer/SKILL.md +538 -0
  227. package/skills/continuous-agent-loop/SKILL.md +45 -0
  228. package/skills/cost-aware-llm-pipeline/SKILL.md +183 -0
  229. package/skills/cpp-coding-standards/SKILL.md +723 -0
  230. package/skills/crosspost/SKILL.md +111 -0
  231. package/skills/css-container-queries/SKILL.md +132 -0
  232. package/skills/customer-billing-ops/SKILL.md +140 -0
  233. package/skills/customs-trade-compliance/SKILL.md +263 -0
  234. package/skills/dart-flutter-patterns/SKILL.md +563 -0
  235. package/skills/dashboard-builder/SKILL.md +108 -0
  236. package/skills/data-scraper-agent/SKILL.md +764 -0
  237. package/skills/database-migrations/SKILL.md +429 -0
  238. package/skills/deep-research/SKILL.md +159 -0
  239. package/skills/defi-amm-security/SKILL.md +166 -0
  240. package/skills/deployment-patterns/SKILL.md +427 -0
  241. package/skills/design-auditor/README.md +504 -0
  242. package/skills/design-auditor/README_KR.md +327 -0
  243. package/skills/design-auditor/SKILL.md +8 -0
  244. package/skills/design-auditor/references/animation.md +300 -0
  245. package/skills/design-auditor/references/color.md +241 -0
  246. package/skills/design-auditor/references/corner-radius.md +331 -0
  247. package/skills/design-auditor/references/elevation.md +249 -0
  248. package/skills/design-auditor/references/ethics.md +877 -0
  249. package/skills/design-auditor/references/figma-mcp.md +377 -0
  250. package/skills/design-auditor/references/heuristics.md +730 -0
  251. package/skills/design-auditor/references/i18n.md +254 -0
  252. package/skills/design-auditor/references/iconography.md +201 -0
  253. package/skills/design-auditor/references/microcopy.md +227 -0
  254. package/skills/design-auditor/references/navigation.md +311 -0
  255. package/skills/design-auditor/references/spacing.md +313 -0
  256. package/skills/design-auditor/references/states.md +254 -0
  257. package/skills/design-auditor/references/tokens.md +286 -0
  258. package/skills/design-auditor/references/typography.md +273 -0
  259. package/skills/design-system/SKILL.md +82 -0
  260. package/skills/design-tokens-system/SKILL.md +156 -0
  261. package/skills/development-workflows/SKILL.md +7 -0
  262. package/skills/development-workflows/cross-model-workflow/assets/cross-model-workflow.png +0 -0
  263. package/skills/development-workflows/cross-model-workflow/cross-model-workflow.md +55 -0
  264. package/skills/development-workflows/rpi/.claude/agents/code-reviewer.md +21 -0
  265. package/skills/development-workflows/rpi/.claude/agents/constitutional-validator.md +288 -0
  266. package/skills/development-workflows/rpi/.claude/agents/documentation-analyst-writer.md +64 -0
  267. package/skills/development-workflows/rpi/.claude/agents/product-manager.md +15 -0
  268. package/skills/development-workflows/rpi/.claude/agents/requirement-parser.md +238 -0
  269. package/skills/development-workflows/rpi/.claude/agents/senior-software-engineer.md +15 -0
  270. package/skills/development-workflows/rpi/.claude/agents/technical-cto-advisor.md +201 -0
  271. package/skills/development-workflows/rpi/.claude/agents/ux-designer.md +14 -0
  272. package/skills/development-workflows/rpi/.claude/commands/rpi/implement.md +634 -0
  273. package/skills/development-workflows/rpi/.claude/commands/rpi/plan.md +416 -0
  274. package/skills/development-workflows/rpi/.claude/commands/rpi/research.md +381 -0
  275. package/skills/development-workflows/rpi/rpi-workflow.md +101 -0
  276. package/skills/development-workflows/rpi/rpi-workflow.svg +178 -0
  277. package/skills/django-celery/SKILL.md +457 -0
  278. package/skills/django-patterns/SKILL.md +734 -0
  279. package/skills/django-security/SKILL.md +593 -0
  280. package/skills/django-tdd/SKILL.md +729 -0
  281. package/skills/dmux-workflows/SKILL.md +7 -0
  282. package/skills/docker-patterns/SKILL.md +364 -0
  283. package/skills/documentation-lookup/SKILL.md +90 -0
  284. package/skills/domain-name-brainstormer/SKILL.md +212 -0
  285. package/skills/dribbble/SKILL.md +160 -0
  286. package/skills/dribbble/metadata.json +16 -0
  287. package/skills/e2e-testing/SKILL.md +326 -0
  288. package/skills/empirical-research/SKILL.md +22 -0
  289. package/skills/error-handling/SKILL.md +376 -0
  290. package/skills/eval-harness/SKILL.md +270 -0
  291. package/skills/evm-token-decimals/SKILL.md +130 -0
  292. package/skills/fastapi-patterns/SKILL.md +327 -0
  293. package/skills/finance-billing-ops/SKILL.md +127 -0
  294. package/skills/flox-environments/SKILL.md +496 -0
  295. package/skills/flutter-dart-code-review/SKILL.md +435 -0
  296. package/skills/foundation-models-on-device/SKILL.md +243 -0
  297. package/skills/framer/SKILL.md +159 -0
  298. package/skills/framer/metadata.json +16 -0
  299. package/skills/frontend-design/LICENSE.txt +21 -0
  300. package/skills/frontend-design/README.md +71 -0
  301. package/skills/frontend-design/SKILL.md +115 -0
  302. package/skills/frontend-design-direction/SKILL.md +92 -0
  303. package/skills/frontend-patterns/SKILL.md +7 -0
  304. package/skills/frontend-slides/SKILL.md +184 -0
  305. package/skills/frontend-slides/STYLE_PRESETS.md +330 -0
  306. package/skills/frontend-slides/animation-patterns.md +122 -0
  307. package/skills/frontend-slides/html-template.md +419 -0
  308. package/skills/frontend-slides/scripts/export-pdf.sh +418 -0
  309. package/skills/frontend-slides/scripts/extract-pptx.py +96 -0
  310. package/skills/frontend-slides/viewport-base.css +153 -0
  311. package/skills/gateguard/SKILL.md +125 -0
  312. package/skills/git-workflow/SKILL.md +715 -0
  313. package/skills/github-ops/SKILL.md +144 -0
  314. package/skills/golang-patterns/SKILL.md +674 -0
  315. package/skills/golang-testing/SKILL.md +720 -0
  316. package/skills/graphify/__init__.py +28 -0
  317. package/skills/graphify/__main__.py +2899 -0
  318. package/skills/graphify/analyze.py +608 -0
  319. package/skills/graphify/benchmark.py +152 -0
  320. package/skills/graphify/build.py +366 -0
  321. package/skills/graphify/cache.py +244 -0
  322. package/skills/graphify/callflow_html.py +2014 -0
  323. package/skills/graphify/cluster.py +267 -0
  324. package/skills/graphify/dedup.py +414 -0
  325. package/skills/graphify/detect.py +1018 -0
  326. package/skills/graphify/export.py +1264 -0
  327. package/skills/graphify/extract.py +6646 -0
  328. package/skills/graphify/global_graph.py +155 -0
  329. package/skills/graphify/google_workspace.py +223 -0
  330. package/skills/graphify/hooks.py +304 -0
  331. package/skills/graphify/ingest.py +331 -0
  332. package/skills/graphify/llm.py +1111 -0
  333. package/skills/graphify/manifest.py +4 -0
  334. package/skills/graphify/prs.py +746 -0
  335. package/skills/graphify/report.py +203 -0
  336. package/skills/graphify/security.py +242 -0
  337. package/skills/graphify/serve.py +899 -0
  338. package/skills/graphify/skill-aider.md +1229 -0
  339. package/skills/graphify/skill-claw.md +1229 -0
  340. package/skills/graphify/skill-codex.md +1290 -0
  341. package/skills/graphify/skill-copilot.md +1317 -0
  342. package/skills/graphify/skill-droid.md +1285 -0
  343. package/skills/graphify/skill-kiro.md +1228 -0
  344. package/skills/graphify/skill-opencode.md +1340 -0
  345. package/skills/graphify/skill-pi.md +1228 -0
  346. package/skills/graphify/skill-trae.md +1254 -0
  347. package/skills/graphify/skill-vscode.md +258 -0
  348. package/skills/graphify/skill-windows.md +1434 -0
  349. package/skills/graphify/skill.md +1086 -0
  350. package/skills/graphify/transcribe.py +184 -0
  351. package/skills/graphify/tree_html.py +580 -0
  352. package/skills/graphify/validate.py +72 -0
  353. package/skills/graphify/watch.py +728 -0
  354. package/skills/graphify/wiki.py +259 -0
  355. package/skills/growth-marketing/SKILL.md +26 -0
  356. package/skills/gsap-scrolltrigger/SKILL.md +8 -0
  357. package/skills/healthcare-cdss-patterns/SKILL.md +245 -0
  358. package/skills/healthcare-emr-patterns/SKILL.md +159 -0
  359. package/skills/healthcare-phi-compliance/SKILL.md +145 -0
  360. package/skills/hexagonal-architecture/SKILL.md +276 -0
  361. package/skills/hipaa-compliance/SKILL.md +78 -0
  362. package/skills/homelab-network-setup/SKILL.md +129 -0
  363. package/skills/imhcode/SKILL.md +183 -0
  364. package/skills/imhcode-brainstorm/SKILL.md +37 -0
  365. package/skills/imhcode-codebase-knowledge/SKILL.md +37 -0
  366. package/skills/imhcode-codebase-knowledge/assets/templates/ARCHITECTURE.md +49 -0
  367. package/skills/imhcode-codebase-knowledge/assets/templates/CONCERNS.md +56 -0
  368. package/skills/imhcode-codebase-knowledge/assets/templates/CONVENTIONS.md +52 -0
  369. package/skills/imhcode-codebase-knowledge/assets/templates/INTEGRATIONS.md +48 -0
  370. package/skills/imhcode-codebase-knowledge/assets/templates/STACK.md +56 -0
  371. package/skills/imhcode-codebase-knowledge/assets/templates/STRUCTURE.md +44 -0
  372. package/skills/imhcode-codebase-knowledge/assets/templates/TESTING.md +57 -0
  373. package/skills/imhcode-codebase-knowledge/references/inquiry-checkpoints.md +70 -0
  374. package/skills/imhcode-codebase-knowledge/references/stack-detection.md +131 -0
  375. package/skills/imhcode-codebase-knowledge/scripts/scan.py +712 -0
  376. package/skills/imhcode-dispatch/SKILL.md +31 -0
  377. package/skills/imhcode-saas-architect/SKILL.md +55 -0
  378. package/skills/imhcode-security/SKILL.md +42 -0
  379. package/skills/imhcode-sprint-planner/SKILL.md +42 -0
  380. package/skills/inventory-demand-planning/SKILL.md +247 -0
  381. package/skills/investor-materials/SKILL.md +96 -0
  382. package/skills/investor-outreach/SKILL.md +91 -0
  383. package/skills/ios-icon-gen/SKILL.md +157 -0
  384. package/skills/ios-icon-gen/scripts/generate_icons.swift +258 -0
  385. package/skills/ios-icon-gen/scripts/iconify_gen.sh +235 -0
  386. package/skills/java-coding-standards/SKILL.md +383 -0
  387. package/skills/jpa-patterns/SKILL.md +151 -0
  388. package/skills/kotlin-ktor-patterns/SKILL.md +689 -0
  389. package/skills/kotlin-patterns/SKILL.md +711 -0
  390. package/skills/laravel-patterns/SKILL.md +415 -0
  391. package/skills/laravel-plugin-discovery/SKILL.md +229 -0
  392. package/skills/laravel-security/SKILL.md +285 -0
  393. package/skills/laravel-tdd/SKILL.md +283 -0
  394. package/skills/laravel-verification/SKILL.md +179 -0
  395. package/skills/lightweight-3d-effects/SKILL.md +8 -0
  396. package/skills/linear/SKILL.md +156 -0
  397. package/skills/linear/metadata.json +16 -0
  398. package/skills/liquid-glass-design/SKILL.md +279 -0
  399. package/skills/llm-trading-agent-security/SKILL.md +146 -0
  400. package/skills/locomotive-scroll/SKILL.md +8 -0
  401. package/skills/logistics-exception-management/SKILL.md +222 -0
  402. package/skills/lottie-animations/SKILL.md +8 -0
  403. package/skills/make-interfaces-feel-better/SKILL.md +151 -0
  404. package/skills/mcp-server-patterns/SKILL.md +69 -0
  405. package/skills/meeting-insights-analyzer/SKILL.md +327 -0
  406. package/skills/micro-interactions/SKILL.md +178 -0
  407. package/skills/mle-workflow/SKILL.md +346 -0
  408. package/skills/mobbin/SKILL.md +157 -0
  409. package/skills/mobbin/metadata.json +16 -0
  410. package/skills/mobile-app-design/README.md +302 -0
  411. package/skills/mobile-app-design/SKILL.md +330 -0
  412. package/skills/mobile-app-design/examples/design-system-config.ts +685 -0
  413. package/skills/mobile-app-design/examples/form-validation-example.tsx +501 -0
  414. package/skills/mobile-app-design/examples/optimized-list-example.tsx +384 -0
  415. package/skills/mobile-app-design/examples/profile-screen-example.tsx +450 -0
  416. package/skills/mobile-app-design/references/accessibility-checklist.md +525 -0
  417. package/skills/mobile-app-design/references/android-guidelines.md +582 -0
  418. package/skills/mobile-app-design/references/common-mistakes.md +834 -0
  419. package/skills/mobile-app-design/references/ios-guidelines.md +421 -0
  420. package/skills/mobile-app-design/references/performance-patterns.md +705 -0
  421. package/skills/mobile-app-design/references/platform-differences.md +353 -0
  422. package/skills/mobile-app-design/references/ui-libraries.md +729 -0
  423. package/skills/mobile-app-design/scripts/accessibility-audit.sh +281 -0
  424. package/skills/mobile-app-design/scripts/check-contrast.py +188 -0
  425. package/skills/mobile-app-design/scripts/validate-touch-targets.sh +228 -0
  426. package/skills/mobile-app-ui-design/INDEX.md +131 -0
  427. package/skills/mobile-app-ui-design/README.md +135 -0
  428. package/skills/mobile-app-ui-design/SKILL.md +7 -0
  429. package/skills/mobile-app-ui-design/references/industry-conventions.md +151 -0
  430. package/skills/modern-web-design/SKILL.md +8 -0
  431. package/skills/motion-advanced/SKILL.md +596 -0
  432. package/skills/motion-design/SKILL.md +21 -0
  433. package/skills/motion-foundations/SKILL.md +299 -0
  434. package/skills/motion-framer/SKILL.md +8 -0
  435. package/skills/motion-patterns/SKILL.md +435 -0
  436. package/skills/motion-ui/SKILL.md +575 -0
  437. package/skills/mysql-patterns/SKILL.md +412 -0
  438. package/skills/nestjs-patterns/SKILL.md +230 -0
  439. package/skills/network-config-validation/SKILL.md +210 -0
  440. package/skills/nextjs-turbopack/SKILL.md +44 -0
  441. package/skills/nodejs-keccak256/SKILL.md +102 -0
  442. package/skills/nothing-design/SKILL.md +177 -0
  443. package/skills/nothing-design/references/components.md +153 -0
  444. package/skills/nothing-design/references/platform-mapping.md +64 -0
  445. package/skills/nothing-design/references/tokens.md +142 -0
  446. package/skills/nuxt4-patterns/SKILL.md +100 -0
  447. package/skills/openclaw-persona-forge/SKILL.md +288 -0
  448. package/skills/openclaw-persona-forge/gacha.py +224 -0
  449. package/skills/openclaw-persona-forge/gacha.sh +5 -0
  450. package/skills/openclaw-persona-forge/references/avatar-style.md +124 -0
  451. package/skills/openclaw-persona-forge/references/boundary-rules.md +53 -0
  452. package/skills/openclaw-persona-forge/references/error-handling.md +53 -0
  453. package/skills/openclaw-persona-forge/references/identity-tension.md +48 -0
  454. package/skills/openclaw-persona-forge/references/naming-system.md +39 -0
  455. package/skills/openclaw-persona-forge/references/output-template.md +166 -0
  456. package/skills/orchestration-workflow/SKILL.md +199 -0
  457. package/skills/orchestration-workflow/orchestration-workflow.gif +0 -0
  458. package/skills/orchestration-workflow/orchestration-workflow.md +199 -0
  459. package/skills/orchestration-workflow/orchestration-workflow.svg +78 -0
  460. package/skills/orchestration-workflow/output.md +13 -0
  461. package/skills/orchestration-workflow/weather.svg +6 -0
  462. package/skills/pixijs-2d/SKILL.md +8 -0
  463. package/skills/plan-orchestrate/SKILL.md +262 -0
  464. package/skills/plankton-code-quality/SKILL.md +236 -0
  465. package/skills/postgres-patterns/SKILL.md +147 -0
  466. package/skills/ppt-mckinsey/SKILL.md +27 -0
  467. package/skills/prisma-patterns/SKILL.md +371 -0
  468. package/skills/product-capability/SKILL.md +141 -0
  469. package/skills/product-lens/SKILL.md +92 -0
  470. package/skills/production-audit/SKILL.md +206 -0
  471. package/skills/project-flow-ops/SKILL.md +111 -0
  472. package/skills/prompt-optimizer/SKILL.md +398 -0
  473. package/skills/python-patterns/SKILL.md +750 -0
  474. package/skills/python-testing/SKILL.md +816 -0
  475. package/skills/pytorch-patterns/SKILL.md +396 -0
  476. package/skills/quarkus-patterns/SKILL.md +722 -0
  477. package/skills/radix-ui-primitives/SKILL.md +86 -0
  478. package/skills/react-native-best-practices/SKILL.md +83 -0
  479. package/skills/react-native-brownfield-migration/SKILL.md +115 -0
  480. package/skills/react-spring-physics/SKILL.md +8 -0
  481. package/skills/react-three-fiber/SKILL.md +8 -0
  482. package/skills/recsys-pipeline-architect/SKILL.md +114 -0
  483. package/skills/redis-patterns/SKILL.md +403 -0
  484. package/skills/remotion-video-creation/SKILL.md +43 -0
  485. package/skills/remotion-video-creation/rules/3d.md +86 -0
  486. package/skills/remotion-video-creation/rules/animations.md +29 -0
  487. package/skills/remotion-video-creation/rules/assets/charts-bar-chart.tsx +173 -0
  488. package/skills/remotion-video-creation/rules/assets/text-animations-typewriter.tsx +100 -0
  489. package/skills/remotion-video-creation/rules/assets/text-animations-word-highlight.tsx +108 -0
  490. package/skills/remotion-video-creation/rules/assets.md +78 -0
  491. package/skills/remotion-video-creation/rules/audio.md +172 -0
  492. package/skills/remotion-video-creation/rules/calculate-metadata.md +104 -0
  493. package/skills/remotion-video-creation/rules/can-decode.md +75 -0
  494. package/skills/remotion-video-creation/rules/charts.md +58 -0
  495. package/skills/remotion-video-creation/rules/compositions.md +146 -0
  496. package/skills/remotion-video-creation/rules/display-captions.md +126 -0
  497. package/skills/remotion-video-creation/rules/extract-frames.md +229 -0
  498. package/skills/remotion-video-creation/rules/fonts.md +152 -0
  499. package/skills/remotion-video-creation/rules/get-audio-duration.md +58 -0
  500. package/skills/remotion-video-creation/rules/get-video-dimensions.md +68 -0
  501. package/skills/remotion-video-creation/rules/get-video-duration.md +58 -0
  502. package/skills/remotion-video-creation/rules/gifs.md +138 -0
  503. package/skills/remotion-video-creation/rules/images.md +130 -0
  504. package/skills/remotion-video-creation/rules/import-srt-captions.md +67 -0
  505. package/skills/remotion-video-creation/rules/lottie.md +67 -0
  506. package/skills/remotion-video-creation/rules/measuring-dom-nodes.md +34 -0
  507. package/skills/remotion-video-creation/rules/measuring-text.md +143 -0
  508. package/skills/remotion-video-creation/rules/sequencing.md +106 -0
  509. package/skills/remotion-video-creation/rules/tailwind.md +11 -0
  510. package/skills/remotion-video-creation/rules/text-animations.md +20 -0
  511. package/skills/remotion-video-creation/rules/timing.md +179 -0
  512. package/skills/remotion-video-creation/rules/transcribe-captions.md +19 -0
  513. package/skills/remotion-video-creation/rules/transitions.md +122 -0
  514. package/skills/remotion-video-creation/rules/trimming.md +52 -0
  515. package/skills/remotion-video-creation/rules/videos.md +171 -0
  516. package/skills/repo-scan/SKILL.md +78 -0
  517. package/skills/responsive-email-templates/SKILL.md +110 -0
  518. package/skills/rive-interactive/SKILL.md +8 -0
  519. package/skills/rust-patterns/SKILL.md +499 -0
  520. package/skills/rust-testing/SKILL.md +500 -0
  521. package/skills/scroll-reveal-libraries/SKILL.md +8 -0
  522. package/skills/security-bounty-hunter/SKILL.md +99 -0
  523. package/skills/security-review/SKILL.md +503 -0
  524. package/skills/security-review/cloud-infrastructure-security.md +361 -0
  525. package/skills/security-scan/SKILL.md +165 -0
  526. package/skills/seo/SKILL.md +154 -0
  527. package/skills/seo-growth/SKILL.md +34 -0
  528. package/skills/shadcn-ui-patterns/SKILL.md +123 -0
  529. package/skills/spline-interactive/SKILL.md +8 -0
  530. package/skills/springboot-patterns/SKILL.md +314 -0
  531. package/skills/springboot-security/SKILL.md +272 -0
  532. package/skills/springboot-tdd/SKILL.md +158 -0
  533. package/skills/strategic-compact/SKILL.md +131 -0
  534. package/skills/stripe/SKILL.md +168 -0
  535. package/skills/stripe/metadata.json +16 -0
  536. package/skills/swift-actor-persistence/SKILL.md +143 -0
  537. package/skills/swift-concurrency-6-2/SKILL.md +216 -0
  538. package/skills/swiftui-patterns/SKILL.md +259 -0
  539. package/skills/systematic-debugging/CREATION-LOG.md +119 -0
  540. package/skills/systematic-debugging/SKILL.md +296 -0
  541. package/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  542. package/skills/systematic-debugging/condition-based-waiting.md +115 -0
  543. package/skills/systematic-debugging/defense-in-depth.md +122 -0
  544. package/skills/systematic-debugging/find-polluter.sh +63 -0
  545. package/skills/systematic-debugging/root-cause-tracing.md +169 -0
  546. package/skills/systematic-debugging/test-academic.md +14 -0
  547. package/skills/systematic-debugging/test-pressure-1.md +58 -0
  548. package/skills/systematic-debugging/test-pressure-2.md +68 -0
  549. package/skills/systematic-debugging/test-pressure-3.md +69 -0
  550. package/skills/tailwindcss-v4/SKILL.md +107 -0
  551. package/skills/tdd-workflow/SKILL.md +463 -0
  552. package/skills/team-builder/SKILL.md +168 -0
  553. package/skills/test-driven-development/SKILL.md +371 -0
  554. package/skills/test-driven-development/testing-anti-patterns.md +299 -0
  555. package/skills/theme-factory/LICENSE.txt +202 -0
  556. package/skills/theme-factory/SKILL.md +59 -0
  557. package/skills/theme-factory/theme-showcase.pdf +0 -0
  558. package/skills/theme-factory/themes/arctic-frost.md +19 -0
  559. package/skills/theme-factory/themes/botanical-garden.md +19 -0
  560. package/skills/theme-factory/themes/desert-rose.md +19 -0
  561. package/skills/theme-factory/themes/forest-canopy.md +19 -0
  562. package/skills/theme-factory/themes/golden-hour.md +19 -0
  563. package/skills/theme-factory/themes/midnight-galaxy.md +19 -0
  564. package/skills/theme-factory/themes/modern-minimalist.md +19 -0
  565. package/skills/theme-factory/themes/ocean-depths.md +19 -0
  566. package/skills/theme-factory/themes/sunset-boulevard.md +19 -0
  567. package/skills/theme-factory/themes/tech-innovation.md +19 -0
  568. package/skills/threejs-webgl/SKILL.md +8 -0
  569. package/skills/trailofbits-auditing/SKILL.md +30 -0
  570. package/skills/twitter-algorithm-optimizer/SKILL.md +327 -0
  571. package/skills/typeui-cli/SKILL.md +90 -0
  572. package/skills/typeui-main/DESIGN.md +114 -0
  573. package/skills/typeui-main/LICENSE.md +9 -0
  574. package/skills/typeui-main/README.md +84 -0
  575. package/skills/typeui-main/REGISTRY.md +60 -0
  576. package/skills/typeui-main/SKILL.md +114 -0
  577. package/skills/typeui-main/package-lock.json +2123 -0
  578. package/skills/typeui-main/package.json +56 -0
  579. package/skills/typeui-main/skills/typeui-cli/SKILL.md +90 -0
  580. package/skills/typeui-main/src/cli.ts +282 -0
  581. package/skills/typeui-main/src/config.ts +28 -0
  582. package/skills/typeui-main/src/domain/designSystemSchema.ts +77 -0
  583. package/skills/typeui-main/src/generation/existingDesignSystem.ts +228 -0
  584. package/skills/typeui-main/src/generation/randomDesignSystem.ts +348 -0
  585. package/skills/typeui-main/src/generation/runDesignGeneration.ts +31 -0
  586. package/skills/typeui-main/src/generation/runGeneration.ts +36 -0
  587. package/skills/typeui-main/src/generation/runPull.ts +62 -0
  588. package/skills/typeui-main/src/io/updateSkillFile.ts +118 -0
  589. package/skills/typeui-main/src/prompts/designSystem.ts +755 -0
  590. package/skills/typeui-main/src/prompts/registry.ts +72 -0
  591. package/skills/typeui-main/src/registry/registryClient.ts +246 -0
  592. package/skills/typeui-main/src/renderers/claudeRenderer.ts +10 -0
  593. package/skills/typeui-main/src/renderers/codexRenderer.ts +10 -0
  594. package/skills/typeui-main/src/renderers/cursorRenderer.ts +10 -0
  595. package/skills/typeui-main/src/renderers/index.ts +14 -0
  596. package/skills/typeui-main/src/renderers/openCodeRenderer.ts +10 -0
  597. package/skills/typeui-main/src/renderers/shared.ts +252 -0
  598. package/skills/typeui-main/src/skillMetadata.ts +19 -0
  599. package/skills/typeui-main/src/types.ts +204 -0
  600. package/skills/typeui-main/src/ui/banner.ts +20 -0
  601. package/skills/typeui-main/test/existingDesignSystem.test.ts +67 -0
  602. package/skills/typeui-main/test/orchestrator.test.ts +113 -0
  603. package/skills/typeui-main/test/randomDesignSystem.test.ts +20 -0
  604. package/skills/typeui-main/test/registryClient.test.ts +408 -0
  605. package/skills/typeui-main/test/renderers.test.ts +41 -0
  606. package/skills/typeui-main/test/runDesignGeneration.test.ts +52 -0
  607. package/skills/typeui-main/test/runPull.test.ts +92 -0
  608. package/skills/typeui-main/test/skillMetadata.test.ts +11 -0
  609. package/skills/typeui-main/test/updateSkillFile.test.ts +160 -0
  610. package/skills/typeui-main/tsconfig.json +16 -0
  611. package/skills/ui-demo/SKILL.md +465 -0
  612. package/skills/ui-to-vue/SKILL.md +134 -0
  613. package/skills/ui-ux-pro-max/.claude/skills/banner-design/SKILL.md +192 -0
  614. package/skills/ui-ux-pro-max/.claude/skills/banner-design/references/banner-sizes-and-styles.md +118 -0
  615. package/skills/ui-ux-pro-max/.claude/skills/brand/SKILL.md +97 -0
  616. package/skills/ui-ux-pro-max/.claude/skills/brand/references/approval-checklist.md +169 -0
  617. package/skills/ui-ux-pro-max/.claude/skills/brand/references/asset-organization.md +157 -0
  618. package/skills/ui-ux-pro-max/.claude/skills/brand/references/brand-guideline-template.md +140 -0
  619. package/skills/ui-ux-pro-max/.claude/skills/brand/references/color-palette-management.md +186 -0
  620. package/skills/ui-ux-pro-max/.claude/skills/brand/references/consistency-checklist.md +94 -0
  621. package/skills/ui-ux-pro-max/.claude/skills/brand/references/logo-usage-rules.md +185 -0
  622. package/skills/ui-ux-pro-max/.claude/skills/brand/references/messaging-framework.md +85 -0
  623. package/skills/ui-ux-pro-max/.claude/skills/brand/references/typography-specifications.md +214 -0
  624. package/skills/ui-ux-pro-max/.claude/skills/brand/references/update.md +118 -0
  625. package/skills/ui-ux-pro-max/.claude/skills/brand/references/visual-identity.md +96 -0
  626. package/skills/ui-ux-pro-max/.claude/skills/brand/references/voice-framework.md +88 -0
  627. package/skills/ui-ux-pro-max/.claude/skills/brand/scripts/extract-colors.cjs +341 -0
  628. package/skills/ui-ux-pro-max/.claude/skills/brand/scripts/inject-brand-context.cjs +349 -0
  629. package/skills/ui-ux-pro-max/.claude/skills/brand/scripts/sync-brand-to-tokens.cjs +266 -0
  630. package/skills/ui-ux-pro-max/.claude/skills/brand/scripts/validate-asset.cjs +387 -0
  631. package/skills/ui-ux-pro-max/.claude/skills/brand/templates/brand-guidelines-starter.md +275 -0
  632. package/skills/ui-ux-pro-max/.claude/skills/design/SKILL.md +302 -0
  633. package/skills/ui-ux-pro-max/.claude/skills/design/data/cip/deliverables.csv +51 -0
  634. package/skills/ui-ux-pro-max/.claude/skills/design/data/cip/industries.csv +21 -0
  635. package/skills/ui-ux-pro-max/.claude/skills/design/data/cip/mockup-contexts.csv +21 -0
  636. package/skills/ui-ux-pro-max/.claude/skills/design/data/cip/styles.csv +21 -0
  637. package/skills/ui-ux-pro-max/.claude/skills/design/data/icon/styles.csv +16 -0
  638. package/skills/ui-ux-pro-max/.claude/skills/design/data/logo/colors.csv +56 -0
  639. package/skills/ui-ux-pro-max/.claude/skills/design/data/logo/industries.csv +56 -0
  640. package/skills/ui-ux-pro-max/.claude/skills/design/data/logo/styles.csv +56 -0
  641. package/skills/ui-ux-pro-max/.claude/skills/design/references/banner-sizes-and-styles.md +118 -0
  642. package/skills/ui-ux-pro-max/.claude/skills/design/references/cip-deliverable-guide.md +95 -0
  643. package/skills/ui-ux-pro-max/.claude/skills/design/references/cip-design.md +121 -0
  644. package/skills/ui-ux-pro-max/.claude/skills/design/references/cip-prompt-engineering.md +84 -0
  645. package/skills/ui-ux-pro-max/.claude/skills/design/references/cip-style-guide.md +68 -0
  646. package/skills/ui-ux-pro-max/.claude/skills/design/references/design-routing.md +207 -0
  647. package/skills/ui-ux-pro-max/.claude/skills/design/references/icon-design.md +122 -0
  648. package/skills/ui-ux-pro-max/.claude/skills/design/references/logo-color-psychology.md +101 -0
  649. package/skills/ui-ux-pro-max/.claude/skills/design/references/logo-design.md +92 -0
  650. package/skills/ui-ux-pro-max/.claude/skills/design/references/logo-prompt-engineering.md +158 -0
  651. package/skills/ui-ux-pro-max/.claude/skills/design/references/logo-style-guide.md +109 -0
  652. package/skills/ui-ux-pro-max/.claude/skills/design/references/slides-copywriting-formulas.md +84 -0
  653. package/skills/ui-ux-pro-max/.claude/skills/design/references/slides-create.md +4 -0
  654. package/skills/ui-ux-pro-max/.claude/skills/design/references/slides-html-template.md +295 -0
  655. package/skills/ui-ux-pro-max/.claude/skills/design/references/slides-layout-patterns.md +137 -0
  656. package/skills/ui-ux-pro-max/.claude/skills/design/references/slides-strategies.md +94 -0
  657. package/skills/ui-ux-pro-max/.claude/skills/design/references/slides.md +42 -0
  658. package/skills/ui-ux-pro-max/.claude/skills/design/references/social-photos-design.md +329 -0
  659. package/skills/ui-ux-pro-max/.claude/skills/design/scripts/cip/core.py +215 -0
  660. package/skills/ui-ux-pro-max/.claude/skills/design/scripts/cip/generate.py +484 -0
  661. package/skills/ui-ux-pro-max/.claude/skills/design/scripts/cip/render-html.py +424 -0
  662. package/skills/ui-ux-pro-max/.claude/skills/design/scripts/cip/search.py +127 -0
  663. package/skills/ui-ux-pro-max/.claude/skills/design/scripts/icon/generate.py +487 -0
  664. package/skills/ui-ux-pro-max/.claude/skills/design/scripts/logo/core.py +175 -0
  665. package/skills/ui-ux-pro-max/.claude/skills/design/scripts/logo/generate.py +362 -0
  666. package/skills/ui-ux-pro-max/.claude/skills/design/scripts/logo/search.py +114 -0
  667. package/skills/ui-ux-pro-max/.claude/skills/design-system/SKILL.md +244 -0
  668. package/skills/ui-ux-pro-max/.claude/skills/design-system/data/slide-backgrounds.csv +11 -0
  669. package/skills/ui-ux-pro-max/.claude/skills/design-system/data/slide-charts.csv +26 -0
  670. package/skills/ui-ux-pro-max/.claude/skills/design-system/data/slide-color-logic.csv +14 -0
  671. package/skills/ui-ux-pro-max/.claude/skills/design-system/data/slide-copy.csv +26 -0
  672. package/skills/ui-ux-pro-max/.claude/skills/design-system/data/slide-layout-logic.csv +16 -0
  673. package/skills/ui-ux-pro-max/.claude/skills/design-system/data/slide-layouts.csv +26 -0
  674. package/skills/ui-ux-pro-max/.claude/skills/design-system/data/slide-strategies.csv +16 -0
  675. package/skills/ui-ux-pro-max/.claude/skills/design-system/data/slide-typography.csv +15 -0
  676. package/skills/ui-ux-pro-max/.claude/skills/design-system/references/component-specs.md +236 -0
  677. package/skills/ui-ux-pro-max/.claude/skills/design-system/references/component-tokens.md +214 -0
  678. package/skills/ui-ux-pro-max/.claude/skills/design-system/references/primitive-tokens.md +203 -0
  679. package/skills/ui-ux-pro-max/.claude/skills/design-system/references/semantic-tokens.md +215 -0
  680. package/skills/ui-ux-pro-max/.claude/skills/design-system/references/states-and-variants.md +241 -0
  681. package/skills/ui-ux-pro-max/.claude/skills/design-system/references/tailwind-integration.md +251 -0
  682. package/skills/ui-ux-pro-max/.claude/skills/design-system/references/token-architecture.md +224 -0
  683. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/embed-tokens.cjs +99 -0
  684. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/fetch-background.py +317 -0
  685. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/generate-slide.py +753 -0
  686. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/generate-tokens.cjs +205 -0
  687. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/html-token-validator.py +327 -0
  688. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/search-slides.py +218 -0
  689. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/slide-token-validator.py +35 -0
  690. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/slide_search_core.py +453 -0
  691. package/skills/ui-ux-pro-max/.claude/skills/design-system/scripts/validate-tokens.cjs +251 -0
  692. package/skills/ui-ux-pro-max/.claude/skills/design-system/templates/design-tokens-starter.json +143 -0
  693. package/skills/ui-ux-pro-max/.claude/skills/slides/SKILL.md +42 -0
  694. package/skills/ui-ux-pro-max/.claude/skills/slides/references/copywriting-formulas.md +84 -0
  695. package/skills/ui-ux-pro-max/.claude/skills/slides/references/create.md +4 -0
  696. package/skills/ui-ux-pro-max/.claude/skills/slides/references/html-template.md +295 -0
  697. package/skills/ui-ux-pro-max/.claude/skills/slides/references/layout-patterns.md +137 -0
  698. package/skills/ui-ux-pro-max/.claude/skills/slides/references/slide-strategies.md +94 -0
  699. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/LICENSE.txt +202 -0
  700. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/SKILL.md +324 -0
  701. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/ArsenalSC-OFL.txt +93 -0
  702. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/ArsenalSC-Regular.ttf +0 -0
  703. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/BigShoulders-Bold.ttf +0 -0
  704. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/BigShoulders-OFL.txt +93 -0
  705. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/BigShoulders-Regular.ttf +0 -0
  706. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Boldonse-OFL.txt +93 -0
  707. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Boldonse-Regular.ttf +0 -0
  708. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/BricolageGrotesque-Bold.ttf +0 -0
  709. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/BricolageGrotesque-OFL.txt +93 -0
  710. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/BricolageGrotesque-Regular.ttf +0 -0
  711. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/CrimsonPro-Bold.ttf +0 -0
  712. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/CrimsonPro-Italic.ttf +0 -0
  713. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/CrimsonPro-OFL.txt +93 -0
  714. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/CrimsonPro-Regular.ttf +0 -0
  715. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/DMMono-OFL.txt +93 -0
  716. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/DMMono-Regular.ttf +0 -0
  717. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/EricaOne-OFL.txt +94 -0
  718. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/EricaOne-Regular.ttf +0 -0
  719. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/GeistMono-Bold.ttf +0 -0
  720. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/GeistMono-OFL.txt +93 -0
  721. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/GeistMono-Regular.ttf +0 -0
  722. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Gloock-OFL.txt +93 -0
  723. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Gloock-Regular.ttf +0 -0
  724. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/IBMPlexMono-Bold.ttf +0 -0
  725. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/IBMPlexMono-OFL.txt +93 -0
  726. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/IBMPlexMono-Regular.ttf +0 -0
  727. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/IBMPlexSerif-Bold.ttf +0 -0
  728. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/IBMPlexSerif-BoldItalic.ttf +0 -0
  729. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/IBMPlexSerif-Italic.ttf +0 -0
  730. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/IBMPlexSerif-Regular.ttf +0 -0
  731. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/InstrumentSans-Bold.ttf +0 -0
  732. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/InstrumentSans-BoldItalic.ttf +0 -0
  733. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/InstrumentSans-Italic.ttf +0 -0
  734. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/InstrumentSans-OFL.txt +93 -0
  735. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/InstrumentSans-Regular.ttf +0 -0
  736. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/InstrumentSerif-Italic.ttf +0 -0
  737. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/InstrumentSerif-Regular.ttf +0 -0
  738. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Italiana-OFL.txt +93 -0
  739. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Italiana-Regular.ttf +0 -0
  740. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/JetBrainsMono-Bold.ttf +0 -0
  741. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/JetBrainsMono-OFL.txt +93 -0
  742. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/JetBrainsMono-Regular.ttf +0 -0
  743. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Jura-Light.ttf +0 -0
  744. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Jura-Medium.ttf +0 -0
  745. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Jura-OFL.txt +93 -0
  746. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/LibreBaskerville-OFL.txt +93 -0
  747. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/LibreBaskerville-Regular.ttf +0 -0
  748. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Lora-Bold.ttf +0 -0
  749. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Lora-BoldItalic.ttf +0 -0
  750. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Lora-Italic.ttf +0 -0
  751. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Lora-OFL.txt +93 -0
  752. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Lora-Regular.ttf +0 -0
  753. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/NationalPark-Bold.ttf +0 -0
  754. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/NationalPark-OFL.txt +93 -0
  755. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/NationalPark-Regular.ttf +0 -0
  756. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/NothingYouCouldDo-OFL.txt +93 -0
  757. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/NothingYouCouldDo-Regular.ttf +0 -0
  758. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Outfit-Bold.ttf +0 -0
  759. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Outfit-OFL.txt +93 -0
  760. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Outfit-Regular.ttf +0 -0
  761. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/PixelifySans-Medium.ttf +0 -0
  762. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/PixelifySans-OFL.txt +93 -0
  763. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/PoiretOne-OFL.txt +93 -0
  764. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/PoiretOne-Regular.ttf +0 -0
  765. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/RedHatMono-Bold.ttf +0 -0
  766. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/RedHatMono-OFL.txt +93 -0
  767. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/RedHatMono-Regular.ttf +0 -0
  768. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Silkscreen-OFL.txt +93 -0
  769. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Silkscreen-Regular.ttf +0 -0
  770. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/SmoochSans-Medium.ttf +0 -0
  771. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/SmoochSans-OFL.txt +93 -0
  772. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Tektur-Medium.ttf +0 -0
  773. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Tektur-OFL.txt +93 -0
  774. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/Tektur-Regular.ttf +0 -0
  775. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/WorkSans-Bold.ttf +0 -0
  776. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/WorkSans-BoldItalic.ttf +0 -0
  777. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/WorkSans-Italic.ttf +0 -0
  778. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/WorkSans-OFL.txt +93 -0
  779. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/WorkSans-Regular.ttf +0 -0
  780. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/YoungSerif-OFL.txt +93 -0
  781. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/canvas-fonts/YoungSerif-Regular.ttf +0 -0
  782. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/references/canvas-design-system.md +320 -0
  783. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/references/shadcn-accessibility.md +471 -0
  784. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/references/shadcn-components.md +424 -0
  785. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/references/shadcn-theming.md +373 -0
  786. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/references/tailwind-customization.md +483 -0
  787. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/references/tailwind-responsive.md +382 -0
  788. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/references/tailwind-utilities.md +455 -0
  789. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/scripts/.coverage +0 -0
  790. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/scripts/requirements.txt +17 -0
  791. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/scripts/shadcn_add.py +292 -0
  792. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/scripts/tailwind_config_gen.py +456 -0
  793. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/scripts/tests/coverage-ui.json +1 -0
  794. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/scripts/tests/requirements.txt +3 -0
  795. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/scripts/tests/test_shadcn_add.py +266 -0
  796. package/skills/ui-ux-pro-max/.claude/skills/ui-styling/scripts/tests/test_tailwind_config_gen.py +336 -0
  797. package/skills/ui-ux-pro-max/.claude/skills/ui-ux-pro-max/SKILL.md +659 -0
  798. package/skills/ui-ux-pro-max/.claude-plugin/marketplace.json +35 -0
  799. package/skills/ui-ux-pro-max/.claude-plugin/plugin.json +11 -0
  800. package/skills/ui-ux-pro-max/.github/workflows/claude-code-review.yml +44 -0
  801. package/skills/ui-ux-pro-max/.github/workflows/claude.yml +50 -0
  802. package/skills/ui-ux-pro-max/.github/workflows/python-package-conda.yml +34 -0
  803. package/skills/ui-ux-pro-max/CLAUDE.md +98 -0
  804. package/skills/ui-ux-pro-max/LICENSE +21 -0
  805. package/skills/ui-ux-pro-max/README.md +513 -0
  806. package/skills/ui-ux-pro-max/SKILL.md +292 -0
  807. package/skills/ui-ux-pro-max/cli/README.md +63 -0
  808. package/skills/ui-ux-pro-max/cli/assets/data/_sync_all.py +414 -0
  809. package/skills/ui-ux-pro-max/cli/assets/data/app-interface.csv +31 -0
  810. package/skills/ui-ux-pro-max/cli/assets/data/charts.csv +26 -0
  811. package/skills/ui-ux-pro-max/cli/assets/data/colors.csv +162 -0
  812. package/skills/ui-ux-pro-max/cli/assets/data/design.csv +1776 -0
  813. package/skills/ui-ux-pro-max/cli/assets/data/draft.csv +1779 -0
  814. package/skills/ui-ux-pro-max/cli/assets/data/google-fonts.csv +1924 -0
  815. package/skills/ui-ux-pro-max/cli/assets/data/icons.csv +105 -0
  816. package/skills/ui-ux-pro-max/cli/assets/data/landing.csv +31 -0
  817. package/skills/ui-ux-pro-max/cli/assets/data/products.csv +162 -0
  818. package/skills/ui-ux-pro-max/cli/assets/data/react-performance.csv +45 -0
  819. package/skills/ui-ux-pro-max/cli/assets/data/stacks/angular.csv +51 -0
  820. package/skills/ui-ux-pro-max/cli/assets/data/stacks/astro.csv +54 -0
  821. package/skills/ui-ux-pro-max/cli/assets/data/stacks/flutter.csv +53 -0
  822. package/skills/ui-ux-pro-max/cli/assets/data/stacks/html-tailwind.csv +56 -0
  823. package/skills/ui-ux-pro-max/cli/assets/data/stacks/jetpack-compose.csv +53 -0
  824. package/skills/ui-ux-pro-max/cli/assets/data/stacks/laravel.csv +51 -0
  825. package/skills/ui-ux-pro-max/cli/assets/data/stacks/nextjs.csv +53 -0
  826. package/skills/ui-ux-pro-max/cli/assets/data/stacks/nuxt-ui.csv +51 -0
  827. package/skills/ui-ux-pro-max/cli/assets/data/stacks/nuxtjs.csv +59 -0
  828. package/skills/ui-ux-pro-max/cli/assets/data/stacks/react-native.csv +52 -0
  829. package/skills/ui-ux-pro-max/cli/assets/data/stacks/react.csv +54 -0
  830. package/skills/ui-ux-pro-max/cli/assets/data/stacks/shadcn.csv +61 -0
  831. package/skills/ui-ux-pro-max/cli/assets/data/stacks/svelte.csv +54 -0
  832. package/skills/ui-ux-pro-max/cli/assets/data/stacks/swiftui.csv +51 -0
  833. package/skills/ui-ux-pro-max/cli/assets/data/stacks/threejs.csv +54 -0
  834. package/skills/ui-ux-pro-max/cli/assets/data/stacks/vue.csv +50 -0
  835. package/skills/ui-ux-pro-max/cli/assets/data/styles.csv +85 -0
  836. package/skills/ui-ux-pro-max/cli/assets/data/typography.csv +74 -0
  837. package/skills/ui-ux-pro-max/cli/assets/data/ui-reasoning.csv +162 -0
  838. package/skills/ui-ux-pro-max/cli/assets/data/ux-guidelines.csv +100 -0
  839. package/skills/ui-ux-pro-max/cli/assets/scripts/core.py +247 -0
  840. package/skills/ui-ux-pro-max/cli/assets/scripts/design_system.py +1148 -0
  841. package/skills/ui-ux-pro-max/cli/assets/scripts/search.py +114 -0
  842. package/skills/ui-ux-pro-max/cli/assets/templates/base/quick-reference.md +297 -0
  843. package/skills/ui-ux-pro-max/cli/assets/templates/base/skill-content.md +353 -0
  844. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/agent.json +21 -0
  845. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/augment.json +18 -0
  846. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/claude.json +21 -0
  847. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/codebuddy.json +21 -0
  848. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/codex.json +21 -0
  849. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/continue.json +21 -0
  850. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/copilot.json +21 -0
  851. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/cursor.json +21 -0
  852. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/droid.json +21 -0
  853. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/gemini.json +21 -0
  854. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/kilocode.json +21 -0
  855. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/kiro.json +21 -0
  856. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/opencode.json +21 -0
  857. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/qoder.json +21 -0
  858. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/roocode.json +21 -0
  859. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/trae.json +21 -0
  860. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/warp.json +18 -0
  861. package/skills/ui-ux-pro-max/cli/assets/templates/platforms/windsurf.json +21 -0
  862. package/skills/ui-ux-pro-max/cli/bun.lock +77 -0
  863. package/skills/ui-ux-pro-max/cli/package-lock.json +370 -0
  864. package/skills/ui-ux-pro-max/cli/package.json +48 -0
  865. package/skills/ui-ux-pro-max/cli/src/commands/init.ts +216 -0
  866. package/skills/ui-ux-pro-max/cli/src/commands/uninstall.ts +135 -0
  867. package/skills/ui-ux-pro-max/cli/src/commands/update.ts +36 -0
  868. package/skills/ui-ux-pro-max/cli/src/commands/versions.ts +42 -0
  869. package/skills/ui-ux-pro-max/cli/src/index.ts +83 -0
  870. package/skills/ui-ux-pro-max/cli/src/types/index.ts +68 -0
  871. package/skills/ui-ux-pro-max/cli/src/utils/detect.ts +120 -0
  872. package/skills/ui-ux-pro-max/cli/src/utils/extract.ts +149 -0
  873. package/skills/ui-ux-pro-max/cli/src/utils/github.ts +104 -0
  874. package/skills/ui-ux-pro-max/cli/src/utils/logger.ts +11 -0
  875. package/skills/ui-ux-pro-max/cli/src/utils/template.ts +243 -0
  876. package/skills/ui-ux-pro-max/cli/tsconfig.json +17 -0
  877. package/skills/ui-ux-pro-max/data/charts.csv +26 -0
  878. package/skills/ui-ux-pro-max/data/colors.csv +97 -0
  879. package/skills/ui-ux-pro-max/data/icons.csv +101 -0
  880. package/skills/ui-ux-pro-max/data/landing.csv +31 -0
  881. package/skills/ui-ux-pro-max/data/products.csv +97 -0
  882. package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  883. package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  884. package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  885. package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  886. package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  887. package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  888. package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  889. package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  890. package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  891. package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  892. package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  893. package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  894. package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  895. package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  896. package/skills/ui-ux-pro-max/data/styles.csv +68 -0
  897. package/skills/ui-ux-pro-max/data/typography.csv +58 -0
  898. package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  899. package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  900. package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  901. package/skills/ui-ux-pro-max/docs//344/270/211/344/270/252 data-scripts-templates /347/232/204/345/214/272/345/210/253.md" +30 -0
  902. package/skills/ui-ux-pro-max/preview/xiaomaomi-app.html +411 -0
  903. package/skills/ui-ux-pro-max/screenshots/website.png +0 -0
  904. package/skills/ui-ux-pro-max/scripts/core.py +253 -0
  905. package/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  906. package/skills/ui-ux-pro-max/scripts/search.py +114 -0
  907. package/skills/ui-ux-pro-max/skill.json +41 -0
  908. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/_sync_all.py +414 -0
  909. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/app-interface.csv +31 -0
  910. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/charts.csv +26 -0
  911. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/colors.csv +162 -0
  912. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/design.csv +1776 -0
  913. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/draft.csv +1779 -0
  914. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/google-fonts.csv +1924 -0
  915. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/icons.csv +106 -0
  916. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/landing.csv +35 -0
  917. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/products.csv +162 -0
  918. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/react-performance.csv +45 -0
  919. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  920. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  921. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  922. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  923. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  924. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  925. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  926. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  927. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  928. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  929. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/react.csv +54 -0
  930. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  931. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  932. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  933. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  934. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  935. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/styles.csv +85 -0
  936. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/typography.csv +74 -0
  937. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/ui-reasoning.csv +162 -0
  938. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  939. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/scripts/core.py +262 -0
  940. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/scripts/design_system.py +1148 -0
  941. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/scripts/search.py +114 -0
  942. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/base/quick-reference.md +297 -0
  943. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/base/skill-content.md +358 -0
  944. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/agent.json +21 -0
  945. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/augment.json +18 -0
  946. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/claude.json +21 -0
  947. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/codebuddy.json +21 -0
  948. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/codex.json +21 -0
  949. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/continue.json +21 -0
  950. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/copilot.json +21 -0
  951. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/cursor.json +21 -0
  952. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/droid.json +21 -0
  953. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/gemini.json +21 -0
  954. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/kilocode.json +21 -0
  955. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/kiro.json +21 -0
  956. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/opencode.json +21 -0
  957. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/qoder.json +21 -0
  958. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/roocode.json +21 -0
  959. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/trae.json +21 -0
  960. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/warp.json +18 -0
  961. package/skills/ui-ux-pro-max/src/ui-ux-pro-max/templates/platforms/windsurf.json +21 -0
  962. package/skills/uncloud/SKILL.md +343 -0
  963. package/skills/upgrading-react-native/SKILL.md +58 -0
  964. package/skills/using-git-worktrees/SKILL.md +215 -0
  965. package/skills/vercel/SKILL.md +161 -0
  966. package/skills/vercel/metadata.json +16 -0
  967. package/skills/verification-loop/SKILL.md +126 -0
  968. package/skills/view-transitions-api/SKILL.md +108 -0
  969. package/skills/vite-patterns/SKILL.md +449 -0
  970. package/skills/vue3-composition-patterns/SKILL.md +375 -0
  971. package/skills/waza-habits/SKILL.md +22 -0
  972. package/skills/webapp-testing/LICENSE.txt +202 -0
  973. package/skills/webapp-testing/SKILL.md +96 -0
  974. package/skills/webapp-testing/examples/console_logging.py +35 -0
  975. package/skills/webapp-testing/examples/element_discovery.py +40 -0
  976. package/skills/webapp-testing/examples/static_html_automation.py +33 -0
  977. package/skills/webapp-testing/scripts/with_server.py +106 -0
  978. package/src/orchestrator/builder.ts +234 -0
  979. package/src/orchestrator/executor.ts +386 -0
  980. package/src/orchestrator/index.ts +535 -0
  981. package/src/orchestrator/loader.ts +237 -0
  982. package/src/orchestrator/registry.ts +211 -0
  983. package/src/orchestrator/schema.ts +141 -0
  984. package/src/orchestrator/session.ts +128 -0
  985. package/src/orchestrator/types.ts +109 -0
  986. package/tsconfig.json +21 -0
@@ -0,0 +1,2014 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ callflow_html.py — Generate call-flow architecture HTML from graphify knowledge graph outputs.
4
+
5
+ Reads graph.json plus optional GRAPH_REPORT.md, .graphify_labels.json, and sections JSON,
6
+ then produces a self-contained HTML file with:
7
+ - Dark-themed CSS (fixed template)
8
+ - Navigation bar from section list
9
+ - Architecture overview flowchart LR (aggregated section-level edges)
10
+ - Per-section flowchart LR (auto-generated representative intra-section edges)
11
+ - Call detail table scaffolding (headers + representative node rows)
12
+ - Auto-generated section intros and key-file cards
13
+
14
+ Usage:
15
+ python3 -m graphify export callflow-html
16
+ python3 -m graphify export callflow-html /path/to/project/graphify-out/graph.json
17
+ python3 -m graphify export callflow-html --graph /path/to/graph.json --output docs/architecture.html
18
+ """
19
+
20
+ from __future__ import annotations
21
+
22
+ import json
23
+ import argparse
24
+ import os
25
+ import re
26
+ import sys
27
+ import hashlib
28
+ from pathlib import Path
29
+ from collections import Counter, defaultdict
30
+ from datetime import datetime, timezone
31
+ from html import escape
32
+
33
+
34
+ # ──────────────────────────────────────────────
35
+ # 1. CSS template (fixed, project-agnostic)
36
+ # ──────────────────────────────────────────────
37
+
38
+ CSS = """:root {
39
+ --bg: #0f172a; --surface: #1e293b; --border: #334155;
40
+ --text: #e2e8f0; --muted: #94a3b8; --accent: #38bdf8;
41
+ --warn: #fbbf24; --err: #f87171; --ok: #34d399;
42
+ }
43
+ * { box-sizing: border-box; margin: 0; padding: 0; }
44
+ body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); line-height: 1.7; }
45
+ .container { max-width: 1200px; margin: 0 auto; padding: 40px 24px; }
46
+ h1 { font-size: 2.4rem; margin-bottom: 8px; background: linear-gradient(135deg, var(--accent), #a78bfa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
47
+ h2 { font-size: 1.7rem; margin: 48px 0 16px; padding-bottom: 8px; border-bottom: 2px solid var(--accent); }
48
+ h3 { font-size: 1.25rem; margin: 32px 0 12px; color: var(--accent); }
49
+ h4 { font-size: 1.05rem; margin: 20px 0 8px; color: var(--warn); }
50
+ p { margin: 8px 0; color: var(--muted); }
51
+ .subtitle { color: var(--muted); font-size: 1.1rem; margin-bottom: 32px; }
52
+ .mermaid { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; margin: 20px 0; overflow-x: auto; position: relative; }
53
+ .mermaid.is-enhanced { padding: 0; overflow: hidden; min-height: 260px; }
54
+ .mermaid-viewport { padding: 54px 24px 24px; overflow: hidden; cursor: grab; touch-action: none; min-height: 260px; }
55
+ .mermaid-viewport.is-dragging { cursor: grabbing; }
56
+ .mermaid-viewport svg { max-width: none !important; height: auto; transform-origin: 0 0; transition: transform 120ms ease; }
57
+ .mermaid-toolbar { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; align-items: center; gap: 6px; padding: 6px; background: rgba(15,23,42,0.92); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.28); }
58
+ .mermaid-toolbar button, .mermaid-toolbar .zoom-level { height: 28px; min-width: 32px; border: 1px solid var(--border); border-radius: 6px; background: #1e293b; color: var(--text); font: 600 0.78rem system-ui, sans-serif; display: inline-flex; align-items: center; justify-content: center; }
59
+ .mermaid-toolbar button { cursor: pointer; }
60
+ .mermaid-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
61
+ .mermaid-toolbar .zoom-level { min-width: 52px; color: var(--muted); background: transparent; }
62
+ .call-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.92rem; }
63
+ .call-table th { background: #1a2744; color: var(--accent); text-align: left; padding: 10px 14px; border: 1px solid var(--border); }
64
+ .call-table td { padding: 8px 14px; border: 1px solid var(--border); vertical-align: top; }
65
+ .call-table tr:nth-child(even) { background: rgba(255,255,255,0.02); }
66
+ .tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
67
+ .tag-async { background: #7c3aed33; color: #a78bfa; }
68
+ .tag-class { background: #05966933; color: var(--ok); }
69
+ .tag-func { background: #2563eb33; color: var(--accent); }
70
+ .tag-cmd { background: #d9770633; color: var(--warn); }
71
+ .tag-endpoint { background: #dc262633; color: var(--err); }
72
+ .tag-hook { background: #db277733; color: #f472b6; }
73
+ .card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin: 16px 0; }
74
+ .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; margin: 16px 0; }
75
+ .arrow-chain { font-family: 'Fira Code', monospace; font-size: 0.85rem; color: var(--accent); padding: 10px; background: rgba(56,189,248,0.06); border-radius: 6px; }
76
+ code { font-family: 'Fira Code', 'Cascadia Code', monospace; background: rgba(255,255,255,0.06); padding: 1px 6px; border-radius: 3px; font-size: 0.88em; }
77
+ ul, ol { margin: 8px 0 8px 24px; color: var(--muted); }
78
+ li { margin: 4px 0; }
79
+ a { color: var(--accent); }
80
+ hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }
81
+ .nav { position: sticky; top: 0; background: var(--bg); z-index: 10; padding: 12px 0; border-bottom: 1px solid var(--border); display: flex; gap: 20px; flex-wrap: wrap; font-size: 0.9rem; }
82
+ .nav a { text-decoration: none; }
83
+ .nav a:hover { text-decoration: underline; }
84
+ @media (max-width: 768px) { .container { padding: 16px; } h1 { font-size: 1.8rem; } }
85
+ """
86
+
87
+
88
+ # ──────────────────────────────────────────────
89
+ # 2. Data loading and normalization helpers
90
+ # ──────────────────────────────────────────────
91
+
92
+ def read_json(path: str | Path, default=None):
93
+ """Read JSON with a useful error message."""
94
+ if not path:
95
+ return default
96
+ path = Path(path)
97
+ if not path.exists():
98
+ return default
99
+ try:
100
+ return json.loads(path.read_text(encoding="utf-8"))
101
+ except json.JSONDecodeError as exc:
102
+ raise SystemExit(f"ERROR: invalid JSON in {path}: {exc}") from exc
103
+
104
+
105
+ def first_present(mapping: dict, *keys, default=None):
106
+ """Return the first non-empty value for any candidate key."""
107
+ for key in keys:
108
+ if key in mapping and mapping[key] not in (None, ""):
109
+ return mapping[key]
110
+ return default
111
+
112
+
113
+ def first_list(*values) -> list:
114
+ """Return the first list from a set of possible schema locations."""
115
+ for value in values:
116
+ if isinstance(value, list):
117
+ return value
118
+ return []
119
+
120
+
121
+ def to_float(value, default: float = 0.0) -> float:
122
+ """Convert graph numeric fields that may be serialized as strings."""
123
+ try:
124
+ return float(value)
125
+ except (TypeError, ValueError):
126
+ return default
127
+
128
+
129
+ def endpoint_id(value) -> str:
130
+ """Normalize edge endpoints that may be strings or node-like objects."""
131
+ if isinstance(value, dict):
132
+ value = first_present(value, "id", "node_id", "key", "name", "qualified_name")
133
+ return str(value or "")
134
+
135
+
136
+ def normalize_node(raw: dict, index: int) -> dict:
137
+ """Normalize a graphify node across common graph.json schema variants."""
138
+ node = dict(raw)
139
+ node_id = first_present(
140
+ node,
141
+ "id",
142
+ "node_id",
143
+ "key",
144
+ "uid",
145
+ "name",
146
+ "qualified_name",
147
+ "fqname",
148
+ "symbol",
149
+ default=f"node_{index + 1}",
150
+ )
151
+ source_file = first_present(
152
+ node,
153
+ "source_file",
154
+ "file",
155
+ "file_path",
156
+ "filepath",
157
+ "path",
158
+ "module_path",
159
+ "defined_in",
160
+ default="",
161
+ )
162
+ label = first_present(
163
+ node,
164
+ "label",
165
+ "display_name",
166
+ "title",
167
+ "name",
168
+ "qualified_name",
169
+ "fqname",
170
+ "symbol",
171
+ default=node_id,
172
+ )
173
+ community = first_present(
174
+ node,
175
+ "community",
176
+ "community_id",
177
+ "cluster",
178
+ "cluster_id",
179
+ "group",
180
+ "group_id",
181
+ "modularity_class",
182
+ default="unknown",
183
+ )
184
+ node_type = first_present(node, "node_type", "kind", "type", "category", default="")
185
+ file_type = first_present(node, "file_type", "content_type", "artifact_type", default="")
186
+ if not file_type:
187
+ suffix = Path(str(source_file)).suffix.lower()
188
+ file_type = "document" if suffix in {".md", ".mdx", ".rst", ".txt"} else "code"
189
+
190
+ node["id"] = str(node_id)
191
+ node["label"] = str(label)
192
+ node["community"] = community
193
+ node["source_file"] = str(source_file or "")
194
+ node["node_type"] = str(node_type or "")
195
+ node["file_type"] = str(file_type or "code")
196
+ return node
197
+
198
+
199
+ def normalize_edge(raw: dict, index: int) -> dict | None:
200
+ """Normalize graphify edges while preserving original fields."""
201
+ edge = dict(raw)
202
+ source = endpoint_id(first_present(edge, "source", "src", "from", "from_id", "start", "u"))
203
+ target = endpoint_id(first_present(edge, "target", "dst", "to", "to_id", "end", "v"))
204
+ if not source or not target:
205
+ return None
206
+
207
+ relation = first_present(edge, "relation", "type", "kind", "label", "predicate", default="relates")
208
+ confidence = first_present(edge, "confidence", "evidence", "provenance", default="EXTRACTED")
209
+ score = first_present(edge, "confidence_score", "score", "weight", "probability", default=1.0)
210
+
211
+ edge["id"] = str(first_present(edge, "id", "edge_id", default=f"edge_{index + 1}"))
212
+ edge["source"] = source
213
+ edge["target"] = target
214
+ edge["relation"] = str(relation or "relates").lower()
215
+ edge["confidence"] = str(confidence or "EXTRACTED").upper()
216
+ edge["confidence_score"] = to_float(score, 1.0)
217
+ return edge
218
+
219
+
220
+ def _node_link_payload(data: dict) -> tuple[list, list] | None:
221
+ """Read current graphify graph.json via NetworkX's node-link parser."""
222
+ if not isinstance(data.get("nodes"), list):
223
+ return None
224
+ if not isinstance(data.get("links"), list) and not isinstance(data.get("edges"), list):
225
+ return None
226
+
227
+ try:
228
+ from networkx.readwrite import json_graph
229
+
230
+ try:
231
+ graph = json_graph.node_link_graph(data, edges="links")
232
+ except TypeError:
233
+ graph = json_graph.node_link_graph(data)
234
+ except Exception:
235
+ return None
236
+
237
+ nodes = []
238
+ for node_id, attrs in graph.nodes(data=True):
239
+ node = dict(attrs)
240
+ node["id"] = node_id
241
+ nodes.append(node)
242
+
243
+ edges = []
244
+ for index, (source, target, attrs) in enumerate(graph.edges(data=True), 1):
245
+ edge = dict(attrs)
246
+ edge["source"] = edge.get("_src", edge.get("source", source))
247
+ edge["target"] = edge.get("_tgt", edge.get("target", target))
248
+ edge.setdefault("id", f"edge_{index}")
249
+ edges.append(edge)
250
+ return nodes, edges
251
+
252
+
253
+ def load_graph(path: str | Path) -> tuple:
254
+ """Load graph.json. Returns normalized (nodes, edges, hyperedges, metadata)."""
255
+ data = read_json(path)
256
+ if not isinstance(data, dict):
257
+ raise SystemExit(f"ERROR: graph file must contain a JSON object: {path}")
258
+
259
+ graph_block = data.get("graph") if isinstance(data.get("graph"), dict) else {}
260
+ meta_block = data.get("metadata") if isinstance(data.get("metadata"), dict) else {}
261
+
262
+ node_link = _node_link_payload(data)
263
+ if node_link:
264
+ raw_nodes, raw_edges = node_link
265
+ else:
266
+ raw_nodes = first_list(data.get("nodes"), data.get("vertices"), graph_block.get("nodes"), graph_block.get("vertices"))
267
+ raw_edges = first_list(data.get("links"), data.get("edges"), graph_block.get("links"), graph_block.get("edges"))
268
+ hyperedges = first_list(data.get("hyperedges"), graph_block.get("hyperedges"), data.get("groups"), graph_block.get("groups"))
269
+
270
+ nodes = [normalize_node(n, i) for i, n in enumerate(raw_nodes) if isinstance(n, dict)]
271
+ edges = []
272
+ for i, raw_edge in enumerate(raw_edges):
273
+ if not isinstance(raw_edge, dict):
274
+ continue
275
+ edge = normalize_edge(raw_edge, i)
276
+ if edge:
277
+ edges.append(edge)
278
+
279
+ meta = dict(graph_block)
280
+ meta.update(meta_block)
281
+ for key in ("built_at_commit", "commit", "project_name", "repo", "repository", "language_breakdown"):
282
+ if data.get(key) and not meta.get(key):
283
+ meta[key] = data.get(key)
284
+ if meta.get("commit") and not meta.get("built_at_commit"):
285
+ meta["built_at_commit"] = meta["commit"]
286
+
287
+ return nodes, edges, hyperedges, meta
288
+
289
+
290
+ def load_labels(path: str | Path | None) -> dict:
291
+ """Load community labels from .graphify_labels.json, tolerating wrapper keys."""
292
+ data = read_json(path, default={})
293
+ if not isinstance(data, dict):
294
+ return {}
295
+ if isinstance(data.get("labels"), dict):
296
+ data = data["labels"]
297
+ if isinstance(data.get("communities"), dict):
298
+ data = data["communities"]
299
+ labels = {}
300
+ for key, value in data.items():
301
+ if isinstance(value, dict):
302
+ value = first_present(value, "label", "name", "title", default=key)
303
+ labels[str(key)] = str(value)
304
+ return labels
305
+
306
+
307
+ def load_sections(path: str | Path | None) -> list:
308
+ """Load section definitions from JSON file."""
309
+ data = read_json(path, default=[])
310
+ if isinstance(data, dict) and isinstance(data.get("sections"), list):
311
+ data = data["sections"]
312
+ if not isinstance(data, list):
313
+ raise SystemExit(f"ERROR: sections file must contain a JSON array: {path}")
314
+ return data
315
+
316
+
317
+ def load_report(path: str | Path | None) -> str:
318
+ """Load GRAPH_REPORT.md if it exists."""
319
+ if path and os.path.exists(path):
320
+ return Path(path).read_text(encoding="utf-8")
321
+ return ""
322
+
323
+
324
+ # ──────────────────────────────────────────────
325
+ # 3. Mermaid-safe label helpers
326
+ # ──────────────────────────────────────────────
327
+
328
+ def safe_mermaid_text(text: str) -> str:
329
+ """Sanitize text for use inside a Mermaid node label.
330
+
331
+ Replaces characters that Mermaid interprets as syntax:
332
+ - -> (edge arrow) -> text
333
+ - # (comment) -> removed
334
+ - {} (shape syntax) -> removed
335
+ - backticks -> removed
336
+ - " -> '
337
+ - HTML metacharacters -> entities
338
+ """
339
+ text = str(text or "")
340
+ text = text.replace('"', "'")
341
+ text = text.replace('`', '')
342
+ text = text.replace('#', '')
343
+ text = text.replace('|', ' ')
344
+ text = text.replace('{', '').replace('}', '')
345
+ text = text.replace("->>", " to ").replace("-->", " to ").replace("->", " to ")
346
+ text = " ".join(text.split())
347
+ return escape(text, quote=False)
348
+
349
+
350
+ def html_comment_text(text: str) -> str:
351
+ """Keep generated HTML comments well-formed."""
352
+ return str(text or "").replace("--", "- -").replace("\n", " ")
353
+
354
+
355
+ def stable_ascii_id(raw: str, prefix: str = "node", limit: int = 48) -> str:
356
+ """Build a Mermaid-safe ASCII identifier with a hash suffix to avoid collisions."""
357
+ raw = str(raw or "")
358
+ digest = hashlib.sha1(raw.encode("utf-8")).hexdigest()[:8]
359
+ slug = re.sub(r"[^A-Za-z0-9_]+", "_", raw)
360
+ slug = re.sub(r"_+", "_", slug).strip("_")
361
+ if not slug:
362
+ slug = prefix
363
+ if slug[0].isdigit():
364
+ slug = f"{prefix}_{slug}"
365
+ return f"{slug[:limit].rstrip('_')}_{digest}"
366
+
367
+
368
+ def node_mermaid_id(node: dict) -> str:
369
+ """Generate a safe Mermaid node ID from a graph node.
370
+
371
+ Mermaid IDs must match [a-zA-Z][a-zA-Z0-9_]* — no dots, hyphens, slashes.
372
+ """
373
+ return stable_ascii_id(node.get("id", "unknown"), "node")
374
+
375
+
376
+ def mermaid_section_id(section_id: str) -> str:
377
+ """Convert a section ID (like 'cli-entry') to a safe Mermaid ID (like 'CLI_ENTRY')."""
378
+ return stable_ascii_id(section_id, "section").upper()
379
+
380
+
381
+ def safe_file_path(path: str) -> str:
382
+ """Return a short, safe display path."""
383
+ # Truncate long paths for display
384
+ parts = path.split("/")
385
+ if len(parts) > 3:
386
+ return "/".join(parts[-3:])
387
+ return path
388
+
389
+
390
+ def safe_filename(text: str, fallback: str = "project") -> str:
391
+ """Create a conservative filename stem from a project name."""
392
+ stem = re.sub(r"[^A-Za-z0-9._-]+", "-", str(text or "")).strip("-._")
393
+ return stem or fallback
394
+
395
+
396
+ def infer_project_name(graph_path: str, meta: dict) -> str:
397
+ """Infer a display project name when graph metadata does not include one."""
398
+ if meta.get("project_name"):
399
+ return meta["project_name"]
400
+ path = Path(graph_path).resolve()
401
+ if path.parent.name == "graphify-out" and len(path.parents) > 1:
402
+ return path.parents[1].name
403
+ return path.parent.name or "Project"
404
+
405
+
406
+ def resolve_graphify_paths(args) -> dict:
407
+ """Resolve project root, graphify output dir, and optional files."""
408
+ base = Path(args.project).expanduser() if args.project else Path.cwd()
409
+ if args.graphify_out:
410
+ graphify_out = Path(args.graphify_out).expanduser()
411
+ elif args.graph:
412
+ graphify_out = Path(args.graph).expanduser().parent
413
+ elif (base / "graph.json").exists():
414
+ graphify_out = base
415
+ else:
416
+ graphify_out = base / "graphify-out"
417
+
418
+ project_root = graphify_out.parent if graphify_out.name == "graphify-out" else base
419
+ graph = Path(args.graph).expanduser() if args.graph else graphify_out / "graph.json"
420
+ report = Path(args.report).expanduser() if args.report else graphify_out / "GRAPH_REPORT.md"
421
+ labels = Path(args.labels).expanduser() if args.labels else graphify_out / ".graphify_labels.json"
422
+ sections = Path(args.sections).expanduser() if args.sections else None
423
+ return {
424
+ "base": project_root,
425
+ "graphify_out": graphify_out,
426
+ "graph": graph,
427
+ "report": report,
428
+ "labels": labels,
429
+ "sections": sections,
430
+ }
431
+
432
+
433
+ def is_zh(lang: str) -> bool:
434
+ """Return true when localized strings should be Chinese."""
435
+ return (lang or "").lower().startswith("zh")
436
+
437
+
438
+ def pick_text(lang: str, zh: str, en: str) -> str:
439
+ """Small localization helper for generated copy."""
440
+ return zh if is_zh(lang) else en
441
+
442
+
443
+ def detect_lang(lang: str, nodes: list, labels: dict) -> str:
444
+ """Resolve auto language from labels and node names."""
445
+ if lang and lang.lower() != "auto":
446
+ return lang
447
+ sample = " ".join(
448
+ list(labels.values())[:50]
449
+ + [str(n.get("label", "")) for n in nodes[:200]]
450
+ + [str(n.get("source_file", "")) for n in nodes[:100]]
451
+ )
452
+ return "zh-CN" if re.search(r"[\u4e00-\u9fff]", sample) else "en"
453
+
454
+
455
+ def truncate_text(text: str, limit: int) -> str:
456
+ """Truncate without splitting Mermaid syntax."""
457
+ text = " ".join(str(text or "").split())
458
+ if len(text) <= limit:
459
+ return text
460
+ return text[: max(0, limit - 3)].rstrip() + "..."
461
+
462
+
463
+ def humanize_label(label: str, source_file: str = "") -> str:
464
+ """Convert graph labels into short labels people can scan in a diagram."""
465
+ label = str(label or "").strip()
466
+ if not label:
467
+ return Path(source_file).name if source_file else "Unknown"
468
+ if label.startswith(".") and label.endswith("()"):
469
+ return label[1:]
470
+ if label.endswith((".py", ".ts", ".tsx", ".js", ".jsx", ".go", ".rs", ".java", ".rb")):
471
+ return Path(label).name
472
+ if "_" in label and " " not in label and len(label) > 28:
473
+ parts = [p for p in label.split("_") if p]
474
+ if parts:
475
+ label = " ".join(parts[-3:])
476
+ return truncate_text(label, 42)
477
+
478
+
479
+ def node_kind(node: dict) -> str:
480
+ """Classify a graph node for Mermaid styling and table tags."""
481
+ label = str(node.get("label") or node.get("id") or "").lower()
482
+ source_file = str(node.get("source_file") or "").lower()
483
+ file_type = str(node.get("file_type") or "").lower()
484
+ node_type = str(node.get("node_type") or "").lower()
485
+ if node_type in {"class", "klass", "struct", "interface", "enum", "trait", "model"}:
486
+ return "klass"
487
+ if node_type in {"module", "file", "package", "namespace"}:
488
+ return "module"
489
+ if node_type in {"endpoint", "route", "api", "handler", "controller"}:
490
+ return "api"
491
+ if node_type in {"test", "spec"}:
492
+ return "test"
493
+ if node_type in {"component", "hook", "view", "page"}:
494
+ return "ui"
495
+ if file_type in {"rationale", "document"}:
496
+ return "concept"
497
+ if "test" in source_file or label.startswith("test_") or "spec" in source_file:
498
+ return "test"
499
+ if any(word in label for word in ("endpoint", "router", "api", "route")):
500
+ return "api"
501
+ if any(word in label for word in ("cli", "command", "click", "typer")):
502
+ return "entry"
503
+ if any(word in label for word in ("async", "await", "stream", "sse")):
504
+ return "async"
505
+ raw_label = str(node.get("label") or "")
506
+ hook_like = raw_label.startswith("use") and len(raw_label) > 3 and (raw_label[3].isupper() or raw_label[3] in "_-")
507
+ if any(word in label for word in ("component", "props", "hook", "store")) or hook_like or source_file.endswith((".tsx", ".jsx", ".vue", ".svelte")):
508
+ return "ui"
509
+ raw = raw_label
510
+ if raw[:1].isupper() and not raw.endswith("()"):
511
+ return "klass"
512
+ if raw.endswith((".py", ".ts", ".tsx", ".js", ".jsx", ".go", ".rs", ".java", ".kt", ".rb", ".php", ".cs", ".swift", ".vue", ".svelte")):
513
+ return "module"
514
+ return "function"
515
+
516
+
517
+ def relation_label(relation: str, lang: str) -> str:
518
+ """Map graph edge relation names to short diagram labels."""
519
+ relation = str(relation or "").strip()
520
+ zh = {
521
+ "calls": "调用",
522
+ "uses": "使用",
523
+ "imports": "导入",
524
+ "imports_from": "导入",
525
+ "method": "方法",
526
+ "contains": "包含",
527
+ "rationale_for": "说明",
528
+ "conceptually_related_to": "相关",
529
+ "participate_in": "参与",
530
+ "form": "组成",
531
+ }
532
+ en = {
533
+ "calls": "calls",
534
+ "uses": "uses",
535
+ "imports": "imports",
536
+ "imports_from": "imports",
537
+ "method": "method",
538
+ "contains": "contains",
539
+ "rationale_for": "explains",
540
+ "conceptually_related_to": "relates",
541
+ "participate_in": "joins",
542
+ "form": "forms",
543
+ }
544
+ mapped = (zh if is_zh(lang) else en).get(relation, relation.replace("_", " "))
545
+ return safe_mermaid_text(mapped)
546
+
547
+
548
+ def preferred_edges(edges: list, allow_structure: bool = False) -> list:
549
+ """Filter to edges that make a readable call-flow diagram."""
550
+ primary = {"calls", "uses", "method", "imports", "imports_from"}
551
+ secondary = {"contains", "rationale_for", "conceptually_related_to"}
552
+ selected = []
553
+ for edge in edges:
554
+ if not should_include_edge(edge):
555
+ continue
556
+ relation = edge.get("relation", "")
557
+ if relation in primary or (allow_structure and relation in secondary):
558
+ selected.append(edge)
559
+ if selected:
560
+ return selected
561
+ return [edge for edge in edges if should_include_edge(edge)]
562
+
563
+
564
+ def edge_score(edge: dict) -> float:
565
+ """Rank edges by confidence and usefulness for diagrams."""
566
+ relation = edge.get("relation", "")
567
+ score = to_float(edge.get("confidence_score", 1.0), 1.0)
568
+ if str(edge.get("confidence", "")).upper() == "EXTRACTED":
569
+ score += 2.0
570
+ if relation in {"calls", "uses", "method"}:
571
+ score += 1.0
572
+ elif relation in {"imports", "imports_from"}:
573
+ score += 0.6
574
+ elif relation == "contains":
575
+ score -= 0.2
576
+ elif relation == "rationale_for":
577
+ score -= 0.6
578
+ return score
579
+
580
+
581
+ def mermaid_init(scale: float, direction: str = "LR") -> str:
582
+ """Return a Mermaid init directive that scales diagrams using Mermaid config."""
583
+ scale = max(0.65, min(float(scale or 1.0), 1.8))
584
+ config = {
585
+ "theme": "dark",
586
+ "themeVariables": {
587
+ "fontSize": f"{round(15 * scale, 1)}px",
588
+ "fontFamily": "Segoe UI, system-ui, sans-serif",
589
+ "primaryColor": "#1e293b",
590
+ "primaryTextColor": "#e2e8f0",
591
+ "primaryBorderColor": "#38bdf8",
592
+ "secondaryColor": "#0f172a",
593
+ "tertiaryColor": "#334155",
594
+ "lineColor": "#64748b",
595
+ "textColor": "#e2e8f0",
596
+ },
597
+ "flowchart": {
598
+ "htmlLabels": True,
599
+ "curve": "basis",
600
+ "nodeSpacing": round(48 * scale),
601
+ "rankSpacing": round(64 * scale),
602
+ "padding": round(14 * scale),
603
+ "diagramPadding": round(10 * scale),
604
+ "useMaxWidth": True,
605
+ },
606
+ }
607
+ return f"%%{{init: {json.dumps(config, ensure_ascii=False)}}}%%\nflowchart {direction}"
608
+
609
+
610
+ def mermaid_class_defs() -> list:
611
+ """Shared Mermaid-native styles for readable diagrams."""
612
+ return [
613
+ " classDef entry fill:#422006,stroke:#fbbf24,color:#fde68a,stroke-width:1px;",
614
+ " classDef api fill:#450a0a,stroke:#f87171,color:#fee2e2,stroke-width:1px;",
615
+ " classDef async fill:#2e1065,stroke:#a78bfa,color:#ede9fe,stroke-width:1px;",
616
+ " classDef klass fill:#064e3b,stroke:#34d399,color:#d1fae5,stroke-width:1px;",
617
+ " classDef ui fill:#831843,stroke:#f472b6,color:#fce7f3,stroke-width:1px;",
618
+ " classDef module fill:#172554,stroke:#60a5fa,color:#dbeafe,stroke-width:1px;",
619
+ " classDef test fill:#3f3f46,stroke:#a1a1aa,color:#f4f4f5,stroke-width:1px;",
620
+ " classDef concept fill:#292524,stroke:#a8a29e,color:#fafaf9,stroke-dasharray:4 3;",
621
+ " classDef function fill:#0f172a,stroke:#38bdf8,color:#e0f2fe,stroke-width:1px;",
622
+ ]
623
+
624
+
625
+ # ──────────────────────────────────────────────
626
+ # 4. Community and section indexing
627
+ # ──────────────────────────────────────────────
628
+
629
+ def build_community_index(nodes: list) -> dict:
630
+ """Map community_id (str) -> list of nodes."""
631
+ idx = defaultdict(list)
632
+ for n in nodes:
633
+ cid = str(n.get("community", "unknown"))
634
+ idx[cid].append(n)
635
+ return idx
636
+
637
+
638
+ def html_anchor_id(raw: str, fallback: str, used: set) -> str:
639
+ """Generate a stable, unique HTML anchor ID."""
640
+ raw = str(raw or fallback or "")
641
+ base = re.sub(r"[^a-z0-9]+", "-", raw.lower()).strip("-")
642
+ if not base:
643
+ base = re.sub(r"[^a-z0-9]+", "-", str(fallback or "section").lower()).strip("-")
644
+ if not base:
645
+ base = "section"
646
+ base = base[:48].strip("-") or "section"
647
+ candidate = base
648
+ if candidate in used:
649
+ candidate = f"{base}-{hashlib.sha1(raw.encode('utf-8')).hexdigest()[:6]}"
650
+ suffix = 2
651
+ while candidate in used:
652
+ candidate = f"{base}-{suffix}"
653
+ suffix += 1
654
+ used.add(candidate)
655
+ return candidate
656
+
657
+
658
+ def normalize_communities(value) -> list:
659
+ """Normalize section community lists from JSON or simple strings."""
660
+ if isinstance(value, list):
661
+ return value
662
+ if value in (None, ""):
663
+ return []
664
+ if isinstance(value, str):
665
+ return [part.strip() for part in value.split(",") if part.strip()]
666
+ return [value]
667
+
668
+
669
+ def normalize_sections(sections: list, lang: str) -> list:
670
+ """Ensure sections have safe unique IDs and an overview section first."""
671
+ overview_name = pick_text(lang, "架构总览", "Architecture Overview")
672
+ normalized = [{"id": "overview", "name": overview_name, "communities": []}]
673
+ used = {"overview", "hyperedges", "stats"}
674
+
675
+ for index, raw in enumerate(sections or [], 1):
676
+ if not isinstance(raw, dict):
677
+ continue
678
+ raw_id = str(raw.get("id") or raw.get("key") or raw.get("name") or f"section-{index}")
679
+ raw_name = str(raw.get("name") or raw.get("label") or raw_id)
680
+ if raw_id.lower() == "overview":
681
+ normalized[0]["name"] = raw_name or overview_name
682
+ continue
683
+
684
+ sid = html_anchor_id(raw_id, f"section-{index}", used)
685
+ normalized.append({
686
+ "id": sid,
687
+ "name": raw_name,
688
+ "communities": normalize_communities(raw.get("communities", raw.get("community"))),
689
+ })
690
+ return normalized
691
+
692
+
693
+ def label_for_community(cid: str, labels: dict, nodes: list, lang: str) -> str:
694
+ """Choose a readable section name for a community."""
695
+ if str(cid) in labels and labels[str(cid)]:
696
+ return labels[str(cid)]
697
+ keywords = section_keywords(nodes, 3)
698
+ if keywords:
699
+ return " ".join(word.title() for word in keywords[:3])
700
+ return pick_text(lang, f"社区 {cid}", f"Community {cid}")
701
+
702
+
703
+ SECTION_ARCHETYPES = [
704
+ (
705
+ "extract-pipeline",
706
+ "提取管线",
707
+ "Extraction Pipeline",
708
+ {
709
+ "extract", "extractor", "tree", "sitter", "parser", "language",
710
+ "python", "javascript", "typescript", "rust", "java", "go",
711
+ "ast", "calls", "imports", "multilang",
712
+ },
713
+ ),
714
+ (
715
+ "build-graph",
716
+ "图谱构建",
717
+ "Graph Build",
718
+ {
719
+ "build", "graph", "merge", "dedup", "node", "edge", "hyperedge",
720
+ "json", "schema", "normalize", "confidence",
721
+ },
722
+ ),
723
+ (
724
+ "analysis-clustering",
725
+ "分析聚类",
726
+ "Analysis & Clustering",
727
+ {
728
+ "cluster", "community", "leiden", "cohesion", "analyze", "god",
729
+ "surprise", "question", "query", "path", "explain", "benchmark",
730
+ },
731
+ ),
732
+ (
733
+ "outputs-docs",
734
+ "输出文档",
735
+ "Outputs & Docs",
736
+ {
737
+ "export", "html", "wiki", "obsidian", "canvas", "svg", "graphml",
738
+ "report", "callflow", "mermaid", "tree", "documentation",
739
+ },
740
+ ),
741
+ (
742
+ "cli-skills",
743
+ "CLI 与技能安装",
744
+ "CLI & Skill Installers",
745
+ {
746
+ "main", "install", "uninstall", "skill", "agent", "claude",
747
+ "codex", "opencode", "aider", "copilot", "kiro", "vscode",
748
+ "hook", "command",
749
+ },
750
+ ),
751
+ (
752
+ "ingest-cache-update",
753
+ "摄取与增量更新",
754
+ "Ingestion & Updates",
755
+ {
756
+ "ingest", "fetch", "download", "url", "html", "markdown",
757
+ "cache", "manifest", "watch", "update", "incremental",
758
+ "transcribe", "video", "audio", "google",
759
+ },
760
+ ),
761
+ (
762
+ "serve-api",
763
+ "服务 API",
764
+ "Serving API",
765
+ {
766
+ "serve", "api", "request", "response", "endpoint", "router",
767
+ "handle", "upload", "search", "delete", "enrich",
768
+ },
769
+ ),
770
+ (
771
+ "security-global",
772
+ "安全与全局图",
773
+ "Security & Global Graph",
774
+ {
775
+ "security", "safe", "ssrf", "xss", "path", "traversal",
776
+ "global", "prefix", "prune", "repo", "clone",
777
+ },
778
+ ),
779
+ (
780
+ "tests-fixtures",
781
+ "测试与样例",
782
+ "Tests & Fixtures",
783
+ {
784
+ "test", "tests", "fixture", "fixtures", "sample", "assert",
785
+ "pytest", "mock",
786
+ },
787
+ ),
788
+ ]
789
+
790
+
791
+ def _community_text(nodes: list, label: str = "") -> str:
792
+ parts = [label]
793
+ for node in nodes[:80]:
794
+ parts.append(str(node.get("label", "")))
795
+ parts.append(str(node.get("source_file", "")))
796
+ parts.append(str(node.get("node_type", "")))
797
+ parts.append(str(node.get("file_type", "")))
798
+ return " ".join(parts).lower()
799
+
800
+
801
+ def _keyword_score(text: str, keywords: set[str]) -> int:
802
+ score = 0
803
+ for keyword in keywords:
804
+ score += len(re.findall(rf"(?<![a-z0-9]){re.escape(keyword)}(?![a-z0-9])", text))
805
+ return score
806
+
807
+
808
+ def _rank_grouped_sections(grouped: dict, max_sections: int) -> tuple[list, list]:
809
+ """Return selected grouped sections and overflow communities."""
810
+ ranked = sorted(
811
+ grouped.values(),
812
+ key=lambda sec: (sec["priority"], -sec["node_count"], sec["id"]),
813
+ )
814
+ cap = max(1, int(max_sections or 15))
815
+ selected = ranked[:cap]
816
+ overflow = ranked[cap:]
817
+ overflow_communities = []
818
+ for sec in overflow:
819
+ overflow_communities.extend(sec["communities"])
820
+ return selected, overflow_communities
821
+
822
+
823
+ def derive_sections_from_communities(nodes: list, labels: dict, lang: str, max_sections: int) -> list:
824
+ """Derive architecture-oriented sections when no sections JSON is supplied."""
825
+ comm_idx = build_community_index(nodes)
826
+ sections = [{"id": "overview", "name": pick_text(lang, "架构总览", "Architecture Overview"), "communities": []}]
827
+ grouped = {}
828
+ unassigned = []
829
+
830
+ for cid, community_nodes in sorted(comm_idx.items(), key=lambda item: (-len(item[1]), str(item[0]))):
831
+ label = label_for_community(cid, labels, community_nodes, lang)
832
+ text = _community_text(community_nodes, label)
833
+ best = None
834
+ best_score = 0
835
+ for priority, (sid, zh_name, en_name, keywords) in enumerate(SECTION_ARCHETYPES):
836
+ score = _keyword_score(text, keywords)
837
+ if score > best_score:
838
+ best = (priority, sid, zh_name, en_name)
839
+ best_score = score
840
+
841
+ if best and best_score >= 2:
842
+ priority, sid, zh_name, en_name = best
843
+ sec = grouped.setdefault(
844
+ sid,
845
+ {
846
+ "id": sid,
847
+ "name": pick_text(lang, zh_name, en_name),
848
+ "communities": [],
849
+ "node_count": 0,
850
+ "priority": priority,
851
+ },
852
+ )
853
+ sec["communities"].append(cid)
854
+ sec["node_count"] += len(community_nodes)
855
+ else:
856
+ unassigned.append((cid, community_nodes, label))
857
+
858
+ selected, overflow_communities = _rank_grouped_sections(grouped, max(1, int(max_sections or 15)) - 1)
859
+ sections.extend(
860
+ {"id": sec["id"], "name": sec["name"], "communities": sec["communities"]}
861
+ for sec in selected
862
+ )
863
+
864
+ remaining_slots = max(0, int(max_sections or 15) - (len(sections) - 1) - 1)
865
+ for cid, community_nodes, label in unassigned[:remaining_slots]:
866
+ sections.append({"id": str(label or f"community-{cid}"), "name": label, "communities": [cid]})
867
+
868
+ other_communities = overflow_communities + [cid for cid, _, _ in unassigned[remaining_slots:]]
869
+ if other_communities:
870
+ sections.append({
871
+ "id": "other",
872
+ "name": pick_text(lang, "其他", "Other"),
873
+ "communities": other_communities,
874
+ })
875
+ return sections
876
+
877
+
878
+ def build_section_node_map(sections: list, comm_idx: dict) -> dict:
879
+ """Map section_id -> list of nodes belonging to its communities."""
880
+ section_nodes = {}
881
+ for sec in sections:
882
+ sid = sec["id"]
883
+ if sid == "overview":
884
+ section_nodes[sid] = []
885
+ continue
886
+ nodes = []
887
+ for cid in sec.get("communities", []):
888
+ nodes.extend(comm_idx.get(str(cid), []))
889
+ section_nodes[sid] = nodes
890
+ return section_nodes
891
+
892
+
893
+ def node_in_section(node_id: str, section_node_ids: set) -> bool:
894
+ """Check if a node belongs to a section."""
895
+ return node_id in section_node_ids
896
+
897
+
898
+ # ──────────────────────────────────────────────
899
+ # 5. Edge analysis
900
+ # ──────────────────────────────────────────────
901
+
902
+ def classify_edges(edges: list, section_nodes_map: dict) -> dict:
903
+ """Classify edges as intra-section or inter-section.
904
+
905
+ Returns:
906
+ {
907
+ "intra": {section_id: [edges]},
908
+ "inter": [edges],
909
+ "orphan": [edges] # one endpoint not in any section
910
+ }
911
+ """
912
+ # Build node -> section lookup
913
+ node_section = {}
914
+ for sid, nodes in section_nodes_map.items():
915
+ for n in nodes:
916
+ node_section[n.get("id")] = sid
917
+
918
+ intra = defaultdict(list)
919
+ inter = []
920
+ orphan = []
921
+
922
+ for e in edges:
923
+ src = e.get("source", "")
924
+ tgt = e.get("target", "")
925
+ src_sec = node_section.get(src)
926
+ tgt_sec = node_section.get(tgt)
927
+
928
+ if src_sec is None or tgt_sec is None:
929
+ orphan.append(e)
930
+ elif src_sec == tgt_sec:
931
+ intra[src_sec].append(e)
932
+ else:
933
+ inter.append(e)
934
+
935
+ return {"intra": dict(intra), "inter": inter, "orphan": orphan, "node_section": node_section}
936
+
937
+
938
+ def should_include_edge(edge: dict) -> bool:
939
+ """Decide whether to auto-include an edge in Mermaid output."""
940
+ conf = str(edge.get("confidence", "EXTRACTED")).upper()
941
+ score = to_float(edge.get("confidence_score", 1.0), 1.0)
942
+
943
+ if conf == "EXTRACTED":
944
+ return True
945
+ if conf == "INFERRED" and score >= 0.85:
946
+ return True
947
+ # Low-confidence INFERRED or AMBIGUOUS: comment out for LLM review
948
+ return False
949
+
950
+
951
+ # ──────────────────────────────────────────────
952
+ # 6. Mermaid diagram generators
953
+ # ──────────────────────────────────────────────
954
+
955
+ def node_degree_scores(edges: list) -> Counter:
956
+ """Score nodes by useful edge participation."""
957
+ scores = Counter()
958
+ for edge in edges:
959
+ score = edge_score(edge)
960
+ scores[edge.get("source", "")] += score
961
+ scores[edge.get("target", "")] += score
962
+ return scores
963
+
964
+
965
+ def node_importance(node: dict) -> float:
966
+ """Use graphify centrality fields when available."""
967
+ for key in ("pagerank", "page_rank", "pageRank", "rank", "centrality", "score"):
968
+ if key in node:
969
+ return to_float(node.get(key), 0.0)
970
+ return 0.0
971
+
972
+
973
+ def select_diagram_nodes(nodes: list, edges: list, max_nodes: int) -> list:
974
+ """Select a compact, connected subset of nodes for readable diagrams."""
975
+ node_by_id = {n.get("id"): n for n in nodes}
976
+ usable_edges = preferred_edges(edges, allow_structure=False)
977
+ if not usable_edges:
978
+ usable_edges = preferred_edges(edges, allow_structure=True)
979
+ scores = node_degree_scores(usable_edges)
980
+ outgoing = Counter(edge.get("source", "") for edge in usable_edges)
981
+ incoming = Counter(edge.get("target", "") for edge in usable_edges)
982
+ selected = []
983
+ seen = set()
984
+
985
+ def add_node(nid: str) -> bool:
986
+ node = node_by_id.get(nid)
987
+ if not node or nid in seen:
988
+ return False
989
+ kind = node_kind(node)
990
+ if kind == "concept" and len(selected) >= max(4, max_nodes // 3):
991
+ return False
992
+ selected.append(node)
993
+ seen.add(nid)
994
+ return len(selected) >= max_nodes
995
+
996
+ # Start with likely entry points: nodes that call out more than they are called.
997
+ entry_candidates = sorted(
998
+ node_by_id,
999
+ key=lambda nid: (-(outgoing[nid] - incoming[nid]), -outgoing[nid], str(nid)),
1000
+ )
1001
+ for nid in entry_candidates[: max(3, max_nodes // 3)]:
1002
+ if outgoing[nid] > 0 and add_node(nid):
1003
+ return selected
1004
+
1005
+ # Then pull in the most useful neighbors from the strongest edges.
1006
+ for edge in sorted(usable_edges, key=edge_score, reverse=True):
1007
+ for nid in (edge.get("source"), edge.get("target")):
1008
+ if add_node(nid):
1009
+ return selected
1010
+
1011
+ def fallback_key(node: dict) -> tuple:
1012
+ nid = node.get("id", "")
1013
+ kind_penalty = 1 if node_kind(node) == "concept" else 0
1014
+ return (
1015
+ kind_penalty,
1016
+ -scores.get(nid, 0),
1017
+ -node_importance(node),
1018
+ safe_file_path(node.get("source_file", "")),
1019
+ humanize_label(node.get("label", nid)),
1020
+ )
1021
+
1022
+ for node in sorted(nodes, key=fallback_key):
1023
+ nid = node.get("id")
1024
+ if nid not in seen:
1025
+ selected.append(node)
1026
+ seen.add(nid)
1027
+ if len(selected) >= max_nodes:
1028
+ break
1029
+ return selected
1030
+
1031
+
1032
+ def node_label(node: dict) -> str:
1033
+ """Build a readable Mermaid node label."""
1034
+ label = humanize_label(node.get("label") or node.get("id"), node.get("source_file", ""))
1035
+ source_file = safe_file_path(node.get("source_file", ""))
1036
+ if source_file and not label.endswith(Path(source_file).name):
1037
+ return f"{safe_mermaid_text(label)}<br/><small>{safe_mermaid_text(source_file)}</small>"
1038
+ return safe_mermaid_text(label)
1039
+
1040
+
1041
+ def group_nodes_by_file(nodes: list) -> dict:
1042
+ """Group selected nodes by source file for Mermaid subgraphs."""
1043
+ groups = defaultdict(list)
1044
+ for node in nodes:
1045
+ source_file = safe_file_path(node.get("source_file", "")) or "External / generated"
1046
+ groups[source_file].append(node)
1047
+ return dict(sorted(groups.items(), key=lambda item: (-len(item[1]), item[0])))
1048
+
1049
+
1050
+ def section_edge_summary(classified_edges: dict) -> dict:
1051
+ """Aggregate inter-section edge counts and relation names."""
1052
+ node_section = classified_edges.get("node_section", {})
1053
+ summary = defaultdict(lambda: {"count": 0, "relations": Counter()})
1054
+ for edge in classified_edges.get("inter", []):
1055
+ if not should_include_edge(edge):
1056
+ continue
1057
+ src_sec = node_section.get(edge.get("source"))
1058
+ tgt_sec = node_section.get(edge.get("target"))
1059
+ if not src_sec or not tgt_sec or src_sec == tgt_sec:
1060
+ continue
1061
+ key = (src_sec, tgt_sec)
1062
+ summary[key]["count"] += 1
1063
+ summary[key]["relations"][edge.get("relation", "relates")] += 1
1064
+ return summary
1065
+
1066
+
1067
+ def generate_overview_graph(sections: list, section_nodes_map: dict,
1068
+ classified_edges: dict, labels: dict, lang: str,
1069
+ diagram_scale: float) -> str:
1070
+ """Generate a readable section-level architecture overview."""
1071
+ lines = [mermaid_init(diagram_scale, "LR")]
1072
+ section_defs = [sec for sec in sections if sec["id"] != "overview"]
1073
+
1074
+ for sec in section_defs:
1075
+ sid = mermaid_section_id(sec["id"])
1076
+ node_count = len(section_nodes_map.get(sec["id"], []))
1077
+ label = (
1078
+ f"{safe_mermaid_text(sec.get('name', sec['id']))}"
1079
+ f"<br/><small>{node_count} {safe_mermaid_text('nodes')}</small>"
1080
+ )
1081
+ lines.append(f' {sid}("{label}")')
1082
+ lines.append(f" class {sid} module;")
1083
+
1084
+ aggregated = section_edge_summary(classified_edges)
1085
+ for (src, tgt), data in sorted(aggregated.items(), key=lambda item: item[1]["count"], reverse=True)[:12]:
1086
+ src_id = mermaid_section_id(src)
1087
+ tgt_id = mermaid_section_id(tgt)
1088
+ relation, _ = data["relations"].most_common(1)[0]
1089
+ label = relation_label(relation, lang)
1090
+ if data["count"] > 1:
1091
+ label = f"{label} x{data['count']}"
1092
+ lines.append(f" {src_id} -->|{label}| {tgt_id}")
1093
+
1094
+ if not aggregated and len(section_defs) > 1:
1095
+ for prev, cur in zip(section_defs, section_defs[1:]):
1096
+ lines.append(f" {mermaid_section_id(prev['id'])} -.-> {mermaid_section_id(cur['id'])}")
1097
+
1098
+ lines.extend(mermaid_class_defs())
1099
+ return "\n".join(lines)
1100
+
1101
+
1102
+ def generate_section_flowchart(section_id: str, section_name: str,
1103
+ nodes: list, edges: list, lang: str,
1104
+ diagram_scale: float, max_nodes: int,
1105
+ max_edges: int) -> str:
1106
+ """Generate a compact, human-readable call-flow chart for a section."""
1107
+ lines = [mermaid_init(diagram_scale, "LR")]
1108
+ lines.append(f" %% Section: {safe_mermaid_text(section_name)} ({len(nodes)} nodes, {len(edges)} edges)")
1109
+
1110
+ if not nodes:
1111
+ empty_label = pick_text(lang, f"{section_name} - 无节点", f"{section_name} - no nodes")
1112
+ lines.append(f' empty("{safe_mermaid_text(empty_label)}")')
1113
+ lines.extend(mermaid_class_defs())
1114
+ return "\n".join(lines)
1115
+
1116
+ selected_nodes = select_diagram_nodes(nodes, edges, max_nodes)
1117
+ selected_ids = {node.get("id") for node in selected_nodes}
1118
+ visible_edges = [
1119
+ edge for edge in preferred_edges(edges, allow_structure=False)
1120
+ if edge.get("source") in selected_ids and edge.get("target") in selected_ids
1121
+ ]
1122
+ if not visible_edges:
1123
+ visible_edges = [
1124
+ edge for edge in preferred_edges(edges, allow_structure=True)
1125
+ if edge.get("source") in selected_ids and edge.get("target") in selected_ids
1126
+ ]
1127
+
1128
+ groups = group_nodes_by_file(selected_nodes)
1129
+ class_lines = []
1130
+ for source_file, group in groups.items():
1131
+ group_id = node_mermaid_id({"id": f"{section_id}_{source_file}"})
1132
+ if len(groups) > 1 and len(group) > 1:
1133
+ lines.append(f' subgraph {group_id}["{safe_mermaid_text(source_file)}"]')
1134
+ indent = " "
1135
+ else:
1136
+ indent = " "
1137
+ for node in group:
1138
+ mid = node_mermaid_id(node)
1139
+ lines.append(f'{indent}{mid}("{node_label(node)}")')
1140
+ class_lines.append(f" class {mid} {node_kind(node)};")
1141
+ if len(groups) > 1 and len(group) > 1:
1142
+ lines.append(" end")
1143
+
1144
+ included = 0
1145
+ for edge in sorted(visible_edges, key=edge_score, reverse=True):
1146
+ if included >= max_edges:
1147
+ break
1148
+ src_id = node_mermaid_id({"id": edge.get("source", "")})
1149
+ tgt_id = node_mermaid_id({"id": edge.get("target", "")})
1150
+ rel = relation_label(edge.get("relation", ""), lang)
1151
+ lines.append(f" {src_id} -->|{rel}| {tgt_id}")
1152
+ included += 1
1153
+
1154
+ omitted_nodes = max(0, len(nodes) - len(selected_nodes))
1155
+ omitted_edges = max(0, len(visible_edges) - included)
1156
+ if omitted_nodes or omitted_edges:
1157
+ lines.append(f" %% Omitted for readability: {omitted_nodes} nodes, {omitted_edges} edges")
1158
+ lines.extend(class_lines)
1159
+ lines.extend(mermaid_class_defs())
1160
+ return "\n".join(lines)
1161
+
1162
+
1163
+ # ──────────────────────────────────────────────
1164
+ # 7. HTML generators
1165
+ # ──────────────────────────────────────────────
1166
+
1167
+ def generate_nav(sections: list) -> str:
1168
+ """Generate the sticky navigation bar."""
1169
+ links = []
1170
+ for sec in sections:
1171
+ links.append(f' <a href="#{escape(sec["id"], quote=True)}">{escape(sec["name"])}</a>')
1172
+ return '<div class="nav">\n' + "\n".join(links) + "\n</div>"
1173
+
1174
+
1175
+ def node_display_name(node: dict | None, fallback: str = "") -> str:
1176
+ """Readable node label for tables and summaries."""
1177
+ if not node:
1178
+ return str(fallback or "")
1179
+ label = str(node.get("label") or node.get("id") or fallback or "")
1180
+ return humanize_label(label, node.get("source_file", ""))
1181
+
1182
+
1183
+ def format_node_refs(node_ids: set, node_by_id: dict, lang: str, empty_text: str, limit: int = 3) -> str:
1184
+ """Render node references as readable labels instead of internal IDs."""
1185
+ if not node_ids:
1186
+ return escape(empty_text)
1187
+ parts = []
1188
+ for nid in sorted(node_ids, key=lambda item: node_display_name(node_by_id.get(item), item).lower())[:limit]:
1189
+ node = node_by_id.get(nid)
1190
+ label = node_display_name(node, nid)
1191
+ source = safe_file_path((node or {}).get("source_file", ""))
1192
+ if source:
1193
+ parts.append(f"<code>{escape(label)}</code><br><small style=\"color:var(--muted)\">{escape(source)}</small>")
1194
+ else:
1195
+ parts.append(f"<code>{escape(label)}</code>")
1196
+ if len(node_ids) > limit:
1197
+ parts.append(escape(pick_text(lang, f"+{len(node_ids) - limit} 个更多", f"+{len(node_ids) - limit} more")))
1198
+ return "<br>".join(parts)
1199
+
1200
+
1201
+ def generate_call_table_rows(nodes: list, section_edges: list, lang: str) -> str:
1202
+ """Generate call table row scaffolding for a section's nodes."""
1203
+ if not nodes:
1204
+ return ""
1205
+
1206
+ # Build source/target lookup from edges
1207
+ node_by_id = {n.get("id"): n for n in nodes}
1208
+ callers = defaultdict(set)
1209
+ callees = defaultdict(set)
1210
+ for e in section_edges:
1211
+ src = e.get("source", "")
1212
+ tgt = e.get("target", "")
1213
+ if e.get("relation") in ("calls", "imports", "imports_from", "uses", "method"):
1214
+ callers[tgt].add(src)
1215
+ callees[src].add(tgt)
1216
+
1217
+ rows = []
1218
+ for i, n in enumerate(nodes[:30], 1): # cap at 30 rows
1219
+ nid = n.get("id", "")
1220
+ label = n.get("label", nid)
1221
+ source_file = safe_file_path(n.get("source_file", ""))
1222
+ file_type = n.get("file_type", "code")
1223
+
1224
+ # Suggest a tag type based on file_type and label heuristics
1225
+ tag = _suggest_tag(label, file_type, lang, node_kind(n))
1226
+
1227
+ caller_text = format_node_refs(
1228
+ callers.get(nid, set()),
1229
+ node_by_id,
1230
+ lang,
1231
+ pick_text(lang, "外部入口 / 无直接入边", "External entry / no inbound edge"),
1232
+ )
1233
+ callee_text = format_node_refs(
1234
+ callees.get(nid, set()),
1235
+ node_by_id,
1236
+ lang,
1237
+ pick_text(lang, "无直接出边", "No direct outbound edge"),
1238
+ )
1239
+
1240
+ rows.append(f"""<tr>
1241
+ <td>{i}</td>
1242
+ <td><code>{escape(label)}</code><br><small style="color:var(--muted)">{escape(source_file)}</small></td>
1243
+ <td>{tag}</td>
1244
+ <td>{caller_text}</td>
1245
+ <td>{callee_text}</td>
1246
+ <td>{escape(_describe_node(label, source_file, file_type, lang))}</td>
1247
+ </tr>""")
1248
+
1249
+ return "\n".join(rows)
1250
+
1251
+
1252
+ def _suggest_tag(label: str, file_type: str, lang: str, kind: str = "") -> str:
1253
+ """Heuristic tag suggestion based on label name and file type."""
1254
+ lower = label.lower()
1255
+ names = {
1256
+ "concept": ("概念", "Concept", "tag-func"),
1257
+ "entry": ("入口", "Entry", "tag-cmd"),
1258
+ "api": ("API", "API", "tag-endpoint"),
1259
+ "async": ("异步", "Async", "tag-async"),
1260
+ "klass": ("类", "Class", "tag-class"),
1261
+ "ui": ("UI", "UI", "tag-hook"),
1262
+ "module": ("模块", "Module", "tag-class"),
1263
+ "test": ("测试", "Test", "tag-func"),
1264
+ "function": ("函数", "Function", "tag-func"),
1265
+ }
1266
+ if kind in names:
1267
+ zh, en, cls = names[kind]
1268
+ return f'<span class="tag {cls}">{pick_text(lang, zh, en)}</span>'
1269
+ if file_type == "rationale":
1270
+ return f'<span class="tag tag-func">{pick_text(lang, "概念", "Concept")}</span>'
1271
+ if any(kw in lower for kw in ("cli", "command", "scan", "serve", "chat", "config")):
1272
+ if "group" in lower or "command" in lower:
1273
+ return f'<span class="tag tag-cmd">{pick_text(lang, "CLI命令", "CLI")}</span>'
1274
+ if any(kw in lower for kw in ("router", "endpoint", "api", "/api/")):
1275
+ return f'<span class="tag tag-endpoint">{pick_text(lang, "API端点", "API")}</span>'
1276
+ if any(kw in lower for kw in ("async", "await", "stream")):
1277
+ return f'<span class="tag tag-async">{pick_text(lang, "异步", "Async")}</span>'
1278
+ if any(kw in lower for kw in ("class", "model", "schema", "dataclass", "pydantic")):
1279
+ return f'<span class="tag tag-class">{pick_text(lang, "类", "Class")}</span>'
1280
+ if any(kw in lower for kw in ("hook", "usestate", "useeffect", "store")):
1281
+ return '<span class="tag tag-hook">Hook</span>'
1282
+ if any(kw in lower for kw in ("component", "props", "tsx", "jsx", "render")):
1283
+ return f'<span class="tag tag-class">{pick_text(lang, "组件", "Component")}</span>'
1284
+ return f'<span class="tag tag-func">{pick_text(lang, "函数", "Function")}</span>'
1285
+
1286
+
1287
+ def _describe_node(label: str, source_file: str, file_type: str, lang: str) -> str:
1288
+ """Generate a compact human-readable description for a graph node."""
1289
+ lower = label.lower()
1290
+ source = source_file or pick_text(lang, "项目", "project")
1291
+ if file_type == "rationale":
1292
+ return pick_text(lang, f"设计说明:{label}", f"Design note for {label}.")
1293
+ if file_type == "document":
1294
+ return pick_text(lang, f"文档入口,描述 {label} 相关能力。", f"Documentation node describing {label}.")
1295
+ if label.endswith(".py") or label.endswith(".tsx") or label.endswith(".ts"):
1296
+ return pick_text(lang, f"{source} 中的模块文件,承载该层主要实现。", f"Module file in {source}.")
1297
+ if "config" in lower:
1298
+ return pick_text(lang, "读取、解析或持久化项目配置。", "Reads, resolves, or persists project configuration.")
1299
+ if "scan" in lower:
1300
+ return pick_text(lang, "触发项目扫描或处理扫描状态。", "Starts scanning or handles scan status.")
1301
+ if "ingest" in lower or "clone" in lower or "git" in lower:
1302
+ return pick_text(lang, "把本地目录或远程仓库转换为分析上下文。", "Turns a local path or remote repository into analysis context.")
1303
+ if "prompt" in lower:
1304
+ return pick_text(lang, "构造发送给 LLM 的结构化提示。", "Builds structured prompts for model calls.")
1305
+ if "analy" in lower:
1306
+ return pick_text(lang, "编排分析流程并产出结构化文档数据。", "Orchestrates analysis and returns structured documentation data.")
1307
+ if "graph" in lower or "dependency" in lower:
1308
+ return pick_text(lang, "构建依赖关系并提供排序或图形化数据。", "Builds dependency relationships and graph data.")
1309
+ if "export" in lower or "markdown" in lower or "html" in lower:
1310
+ return pick_text(lang, "将文档数据导出为目标格式。", "Exports documentation data to a target format.")
1311
+ if "chat" in lower or "rag" in lower or "retrieve" in lower:
1312
+ return pick_text(lang, "支撑检索增强问答或流式聊天。", "Supports retrieval-augmented Q&A or streaming chat.")
1313
+ if "wiki" in lower or "page" in lower or "sidebar" in lower:
1314
+ return pick_text(lang, "组织文档页面、侧边栏或内容读取。", "Organizes documentation pages, navigation, or content lookup.")
1315
+ if "cache" in lower or "hash" in lower:
1316
+ return pick_text(lang, "缓存分析结果或生成缓存键。", "Caches analysis results or computes cache keys.")
1317
+ if "test" in lower:
1318
+ return pick_text(lang, "验证导入、入口点或版本等基础行为。", "Verifies imports, entry points, or version behavior.")
1319
+ return pick_text(lang, f"{source} 中的 {label} 节点。", f"{label} node in {source}.")
1320
+
1321
+
1322
+ def generate_header(sections: list, meta: dict, lang: str) -> str:
1323
+ """Generate the HTML header, title, subtitle, and nav."""
1324
+ project_name = str(meta.get("project_name", "Project"))
1325
+ commit = str(meta.get("built_at_commit", "unknown"))[:7]
1326
+
1327
+ if lang.startswith("zh"):
1328
+ title = f"{project_name} — 完整调用流程与架构文档"
1329
+ subtitle = (
1330
+ f"由 graphify 知识图谱生成:{meta.get('node_count', '?')} 个节点、"
1331
+ f"{meta.get('edge_count', '?')} 条边、{meta.get('community_count', '?')} 个社区。"
1332
+ f"Commit: {commit}"
1333
+ )
1334
+ else:
1335
+ title = f"{project_name} — Complete Call Flow & Architecture Documentation"
1336
+ subtitle = (
1337
+ f"Generated from graphify knowledge graph: {meta.get('node_count', '?')} nodes, "
1338
+ f"{meta.get('edge_count', '?')} edges, {meta.get('community_count', '?')} communities. "
1339
+ f"Commit: {commit}"
1340
+ )
1341
+
1342
+ return f"""<h1>{escape(title)}</h1>
1343
+ <p class="subtitle">{escape(subtitle)}</p>
1344
+
1345
+ {generate_nav(sections)}
1346
+ """
1347
+
1348
+
1349
+ def derive_flow_chain(sections: list, classified_edges: dict) -> str:
1350
+ """Derive a readable section flow from inter-section edges."""
1351
+ section_names = {sec["id"]: sec.get("name", sec["id"]) for sec in sections}
1352
+ order = [sec["id"] for sec in sections if sec["id"] != "overview"]
1353
+ if not order:
1354
+ return "Graph nodes -> documentation"
1355
+
1356
+ outgoing = defaultdict(Counter)
1357
+ incoming = Counter()
1358
+ for (src, tgt), data in section_edge_summary(classified_edges).items():
1359
+ outgoing[src][tgt] += data["count"]
1360
+ incoming[tgt] += data["count"]
1361
+
1362
+ start = min(order, key=lambda sid: (incoming.get(sid, 0), order.index(sid)))
1363
+ chain = [start]
1364
+ seen = {start}
1365
+ current = start
1366
+ while len(chain) < min(7, len(order)):
1367
+ candidates = [(count, tgt) for tgt, count in outgoing.get(current, {}).items() if tgt not in seen]
1368
+ if candidates:
1369
+ _, nxt = max(candidates)
1370
+ else:
1371
+ remaining = [sid for sid in order if sid not in seen]
1372
+ if not remaining:
1373
+ break
1374
+ nxt = remaining[0]
1375
+ chain.append(nxt)
1376
+ seen.add(nxt)
1377
+ current = nxt
1378
+ return " -> ".join(section_names.get(sid, sid) for sid in chain)
1379
+
1380
+
1381
+ def generate_overview_cards(meta: dict, report_text: str, sections: list,
1382
+ section_nodes_map: dict, classified_edges: dict,
1383
+ lang: str) -> str:
1384
+ """Generate generic overview cards."""
1385
+ rows = []
1386
+ for sec in sections:
1387
+ if sec["id"] == "overview":
1388
+ continue
1389
+ communities = ", ".join(str(c) for c in sec.get("communities", []))
1390
+ node_count = len(section_nodes_map.get(sec["id"], []))
1391
+ rows.append(
1392
+ f"<tr><td>{escape(sec['name'])}</td><td>{node_count}</td><td><code>{escape(communities)}</code></td></tr>"
1393
+ )
1394
+
1395
+ flow = derive_flow_chain(sections, classified_edges)
1396
+ layer_title = pick_text(lang, "架构层次", "Architecture Layers")
1397
+ layer_cols = pick_text(lang, "<tr><th>层</th><th>节点</th><th>社区</th></tr>", "<tr><th>Layer</th><th>Nodes</th><th>Communities</th></tr>")
1398
+ flow_title = pick_text(lang, "核心数据流", "Core Flow")
1399
+ return f"""<div class="grid">
1400
+ <div class="card">
1401
+ <h4>{layer_title}</h4>
1402
+ <table style="width:100%;font-size:0.85rem;">
1403
+ {layer_cols}
1404
+ {''.join(rows)}
1405
+ </table>
1406
+ </div>
1407
+ <div class="card">
1408
+ <h4>{flow_title}</h4>
1409
+ <div class="arrow-chain">{escape(flow)}</div>
1410
+ </div>
1411
+ </div>"""
1412
+
1413
+
1414
+ def section_keywords(nodes: list, limit: int = 5) -> list:
1415
+ """Pick representative words from labels and file names."""
1416
+ counts = Counter()
1417
+ stopwords = {
1418
+ "the", "and", "for", "with", "from", "this", "that", "class", "function",
1419
+ "method", "file", "src", "lib", "core", "index", "main", "init", "py",
1420
+ "ts", "tsx", "js", "jsx", "go", "rs", "java", "html", "css",
1421
+ }
1422
+ for node in nodes:
1423
+ text = f"{node.get('label', '')} {node.get('source_file', '')}".replace("/", " ").replace("_", " ").replace("-", " ")
1424
+ for raw in text.split():
1425
+ word = "".join(ch for ch in raw.lower() if ch.isalnum())
1426
+ if len(word) < 3 or word in stopwords:
1427
+ continue
1428
+ counts[word] += 1
1429
+ return [word for word, _ in counts.most_common(limit)]
1430
+
1431
+
1432
+ def generate_section_intro(sec: dict, nodes: list, edge_count: int, lang: str) -> str:
1433
+ """Generate the section introductory paragraph."""
1434
+ file_counts = Counter(n.get("source_file") for n in nodes if n.get("source_file"))
1435
+ files = [safe_file_path(path) for path, _ in file_counts.most_common(3)]
1436
+ keywords = section_keywords(nodes, 4)
1437
+ if is_zh(lang):
1438
+ file_text = "、".join(files) if files else "未标注源文件"
1439
+ keyword_text = "、".join(keywords) if keywords else sec.get("name", sec["id"])
1440
+ text = (
1441
+ f"{sec.get('name', sec['id'])} 汇集了与 {keyword_text} 相关的实现,"
1442
+ f"主要分布在 {file_text}。本节覆盖 {len(nodes)} 个节点、{edge_count} 条内部边,"
1443
+ "图中只展示最有代表性的调用关系以保持可读性。"
1444
+ )
1445
+ else:
1446
+ file_text = ", ".join(files) if files else "unmapped files"
1447
+ keyword_text = ", ".join(keywords) if keywords else sec.get("name", sec["id"])
1448
+ text = (
1449
+ f"{sec.get('name', sec['id'])} groups implementation around {keyword_text}, "
1450
+ f"mostly in {file_text}. This section covers {len(nodes)} nodes and {edge_count} internal edges; "
1451
+ "the diagram shows only representative relationships to stay readable."
1452
+ )
1453
+ return f"<p>{escape(text)}</p>"
1454
+
1455
+
1456
+ def generate_section_cards(sec: dict, nodes: list, section_edges: list, lang: str) -> str:
1457
+ """Generate key file and design-note cards for a section."""
1458
+ file_counts = defaultdict(int)
1459
+ for n in nodes:
1460
+ source_file = n.get("source_file") or ""
1461
+ if source_file:
1462
+ file_counts[source_file] += 1
1463
+ top_files = sorted(file_counts.items(), key=lambda item: (-item[1], item[0]))[:8]
1464
+ if top_files:
1465
+ file_rows = "\n".join(
1466
+ f"<tr><td><code>{escape(safe_file_path(path))}</code></td><td>{count} {escape(pick_text(lang, '个节点', 'nodes'))}</td></tr>"
1467
+ for path, count in top_files
1468
+ )
1469
+ else:
1470
+ file_rows = f'<tr><td colspan="2">{escape(pick_text(lang, "无源文件映射", "No source file mapping"))}</td></tr>'
1471
+
1472
+ relation_counts = Counter(edge.get("relation", "relates") for edge in section_edges if should_include_edge(edge))
1473
+ relation_text = ", ".join(f"{relation_label(rel, lang)} x{count}" for rel, count in relation_counts.most_common(4))
1474
+ if not relation_text:
1475
+ relation_text = pick_text(lang, "未检测到高置信调用边", "No high-confidence call edges detected")
1476
+ note = pick_text(
1477
+ lang,
1478
+ f"本节由 graphify 社区聚类生成。关系概况:{relation_text}。图表优先展示高置信、跨节点调用或使用关系,完整节点清单位于表格中。",
1479
+ f"This section comes from graphify community clustering. Relationship summary: {relation_text}. The diagram prioritizes high-confidence calls or usage relationships; the table keeps the broader node inventory.",
1480
+ )
1481
+ key_files = pick_text(lang, "关键文件", "Key Files")
1482
+ role = pick_text(lang, "覆盖节点", "Coverage")
1483
+ design_notes = pick_text(lang, "设计备注", "Design Notes")
1484
+ return f"""<div class="grid">
1485
+ <div class="card">
1486
+ <h4>{key_files}</h4>
1487
+ <table style="width:100%;font-size:0.85rem;">
1488
+ <tr><th>File</th><th>{role}</th></tr>
1489
+ {file_rows}
1490
+ </table>
1491
+ </div>
1492
+ <div class="card">
1493
+ <h4>{design_notes}</h4>
1494
+ <p>{escape(note)}</p>
1495
+ </div>
1496
+ </div>"""
1497
+
1498
+
1499
+ # ──────────────────────────────────────────────
1500
+ # 8. Main entry point
1501
+ # ──────────────────────────────────────────────
1502
+
1503
+ class CallflowOptions:
1504
+ """Options for call-flow architecture HTML generation."""
1505
+
1506
+ def __init__(
1507
+ self,
1508
+ project: str | Path | None = None,
1509
+ *,
1510
+ graphify_out: str | Path | None = None,
1511
+ graph: str | Path | None = None,
1512
+ report: str | Path | None = None,
1513
+ labels: str | Path | None = None,
1514
+ sections: str | Path | None = None,
1515
+ output: str | Path | None = None,
1516
+ lang: str = "auto",
1517
+ max_sections: int = 15,
1518
+ diagram_scale: float = 1.0,
1519
+ max_diagram_nodes: int = 18,
1520
+ max_diagram_edges: int = 24,
1521
+ ):
1522
+ self.project = str(project) if project is not None else None
1523
+ self.graphify_out = str(graphify_out) if graphify_out is not None else None
1524
+ self.graph = str(graph) if graph is not None else None
1525
+ self.report = str(report) if report is not None else None
1526
+ self.labels = str(labels) if labels is not None else None
1527
+ self.sections = str(sections) if sections is not None else None
1528
+ self.output = str(output) if output is not None else None
1529
+ self.lang = lang
1530
+ self.max_sections = max_sections
1531
+ self.diagram_scale = diagram_scale
1532
+ self.max_diagram_nodes = max_diagram_nodes
1533
+ self.max_diagram_edges = max_diagram_edges
1534
+
1535
+
1536
+ def _report_highlights(report_text: str, lang: str) -> str:
1537
+ """Extract a compact highlights card from GRAPH_REPORT.md."""
1538
+ if not report_text.strip():
1539
+ return ""
1540
+
1541
+ lines = report_text.splitlines()
1542
+ keep: list[str] = []
1543
+ in_gods = False
1544
+ in_summary = False
1545
+ for line in lines:
1546
+ stripped = line.strip()
1547
+ if stripped.startswith("## "):
1548
+ in_summary = stripped == "## Summary"
1549
+ in_gods = stripped.startswith("## God Nodes")
1550
+ continue
1551
+ if in_summary and stripped.startswith("- "):
1552
+ keep.append(stripped[2:])
1553
+ elif in_gods and re.match(r"^\d+\.", stripped):
1554
+ keep.append(stripped)
1555
+ if len(keep) >= 6:
1556
+ break
1557
+
1558
+ if not keep:
1559
+ return ""
1560
+
1561
+ title = pick_text(lang, "图谱报告摘要", "Graph Report Highlights")
1562
+ items = "\n".join(f" <li>{escape(item)}</li>" for item in keep)
1563
+ return f"""<div class="card">
1564
+ <h4>{title}</h4>
1565
+ <ul>
1566
+ {items}
1567
+ </ul>
1568
+ </div>"""
1569
+
1570
+
1571
+ def write_callflow_html(
1572
+ project: str | Path | None = None,
1573
+ *,
1574
+ graphify_out: str | Path | None = None,
1575
+ graph: str | Path | None = None,
1576
+ report: str | Path | None = None,
1577
+ labels: str | Path | None = None,
1578
+ sections: str | Path | None = None,
1579
+ output: str | Path | None = None,
1580
+ lang: str = "auto",
1581
+ max_sections: int = 15,
1582
+ diagram_scale: float = 1.0,
1583
+ max_diagram_nodes: int = 18,
1584
+ max_diagram_edges: int = 24,
1585
+ verbose: bool = False,
1586
+ ) -> Path:
1587
+ """Generate call-flow architecture HTML from graphify output files."""
1588
+ args = CallflowOptions(
1589
+ project,
1590
+ graphify_out=graphify_out,
1591
+ graph=graph,
1592
+ report=report,
1593
+ labels=labels,
1594
+ sections=sections,
1595
+ output=output,
1596
+ lang=lang,
1597
+ max_sections=max_sections,
1598
+ diagram_scale=diagram_scale,
1599
+ max_diagram_nodes=max_diagram_nodes,
1600
+ max_diagram_edges=max_diagram_edges,
1601
+ )
1602
+
1603
+ paths = resolve_graphify_paths(args)
1604
+ if not paths["graph"].exists():
1605
+ raise FileNotFoundError(
1606
+ f"graphify output not found: {paths['graph']}. "
1607
+ "Run graphify first or pass --graph /path/to/graph.json."
1608
+ )
1609
+
1610
+ # Load data
1611
+ nodes, edges, hyperedges, meta = load_graph(paths["graph"])
1612
+ labels = load_labels(paths["labels"])
1613
+ lang = detect_lang(args.lang, nodes, labels)
1614
+ if paths["sections"]:
1615
+ sections = load_sections(paths["sections"])
1616
+ else:
1617
+ sections = derive_sections_from_communities(nodes, labels, lang, args.max_sections)
1618
+ sections = normalize_sections(sections, lang)
1619
+ report_text = load_report(paths["report"])
1620
+
1621
+ if not nodes:
1622
+ raise ValueError("graph.json contains 0 nodes")
1623
+ if len(sections) <= 1:
1624
+ raise ValueError("no sections defined")
1625
+
1626
+ if verbose and len(nodes) >= 5000:
1627
+ print("WARNING: Large graph -- Mermaid rendering may be slow. Consider --max-sections 5.", file=sys.stderr)
1628
+
1629
+ node_ids = {node.get("id") for node in nodes}
1630
+ missing_endpoint_edges = [edge for edge in edges if edge.get("source") not in node_ids or edge.get("target") not in node_ids]
1631
+ if verbose and missing_endpoint_edges:
1632
+ print(f"WARNING: {len(missing_endpoint_edges)} edges reference nodes not present in graph.json.", file=sys.stderr)
1633
+
1634
+ meta["project_name"] = infer_project_name(str(paths["graph"]), meta)
1635
+ meta["node_count"] = len(nodes)
1636
+ meta["edge_count"] = len(edges)
1637
+ meta["hyperedge_count"] = len(hyperedges)
1638
+
1639
+ if args.output:
1640
+ output_path = Path(args.output).expanduser()
1641
+ if not output_path.is_absolute():
1642
+ output_path = paths["base"] / output_path
1643
+ else:
1644
+ output_path = paths["graphify_out"] / f"{safe_filename(meta['project_name'])}-callflow.html"
1645
+
1646
+ if verbose:
1647
+ print(f"Loaded: {len(nodes)} nodes, {len(edges)} edges, {len(sections)} sections")
1648
+ print(f"Graph: {paths['graph']}")
1649
+
1650
+ # Build index
1651
+ comm_idx = build_community_index(nodes)
1652
+ meta["community_count"] = len(comm_idx)
1653
+ section_nodes_map = build_section_node_map(sections, comm_idx)
1654
+ classified = classify_edges(edges, section_nodes_map)
1655
+
1656
+ # Build HTML
1657
+ html = []
1658
+ doc_title = (
1659
+ f"{meta.get('project_name', 'Project')} — 完整调用流程与架构文档"
1660
+ if lang.startswith("zh")
1661
+ else f"{meta.get('project_name', 'Project')} — Complete Call Flow & Architecture Documentation"
1662
+ )
1663
+
1664
+ # Doctype and head
1665
+ html.append(f"""<!DOCTYPE html>
1666
+ <html lang="{escape(lang, quote=True)}">
1667
+ <head>
1668
+ <meta charset="UTF-8">
1669
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1670
+ <title>{escape(doc_title)}</title>
1671
+ <script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>
1672
+ <style>
1673
+ {CSS}
1674
+ </style>
1675
+ </head>
1676
+ <body>
1677
+ <div class="container">
1678
+ """)
1679
+
1680
+ # Header + nav
1681
+ html.append(generate_header(sections, meta, lang))
1682
+
1683
+ # ── Architecture Overview (Section "overview") ──
1684
+ overview_name = sections[0].get("name", "Architecture Overview") if sections else "Architecture Overview"
1685
+ html.append(f"""<!-- ====== Architecture Overview ====== -->
1686
+ <h2 id="overview">1. {escape(str(overview_name))}</h2>
1687
+
1688
+ <div class="mermaid">
1689
+ """)
1690
+ html.append(generate_overview_graph(sections, section_nodes_map, classified, labels, lang, args.diagram_scale))
1691
+ html.append("""</div>
1692
+ """)
1693
+ html.append(generate_overview_cards(meta, report_text, sections, section_nodes_map, classified, lang))
1694
+ report_card = _report_highlights(report_text, lang)
1695
+ if report_card:
1696
+ html.append(f'<div class="grid">\n {report_card}\n</div>')
1697
+ html.append("<hr>")
1698
+
1699
+ # ── Per-section content ──
1700
+ section_num = 1 # overview was #1
1701
+ for sec in sections:
1702
+ if sec["id"] == "overview":
1703
+ continue
1704
+ section_num += 1
1705
+ sid = sec["id"]
1706
+ name = sec.get("name", sid)
1707
+ sec_nodes = section_nodes_map.get(sid, [])
1708
+ sec_edges = classified.get("intra", {}).get(sid, [])
1709
+
1710
+ edge_count = len(sec_edges)
1711
+ h3_title = pick_text(lang, "调用明细", "Call Details")
1712
+ number_header = "#"
1713
+ function_header = pick_text(lang, "节点", "Node")
1714
+ type_header = pick_text(lang, "类型", "Type")
1715
+ caller_header = pick_text(lang, "调用方", "Caller")
1716
+ callee_header = pick_text(lang, "被调用/依赖", "Callees")
1717
+ desc_header = pick_text(lang, "说明", "Description")
1718
+
1719
+ html.append(f"""<!-- ====== {section_num}. {html_comment_text(name)} ====== -->
1720
+ <h2 id="{escape(str(sid), quote=True)}">{section_num}. {escape(str(name))}</h2>
1721
+ {generate_section_intro(sec, sec_nodes, edge_count, lang)}
1722
+
1723
+ <div class="mermaid">
1724
+ {generate_section_flowchart(sid, name, sec_nodes, sec_edges, lang, args.diagram_scale, args.max_diagram_nodes, args.max_diagram_edges)}
1725
+ </div>
1726
+
1727
+ <h3>{h3_title}</h3>
1728
+ <table class="call-table">
1729
+ <tr>
1730
+ <th style="width:5%">{number_header}</th>
1731
+ <th style="width:28%">{function_header}</th>
1732
+ <th style="width:10%">{type_header}</th>
1733
+ <th style="width:17%">{caller_header}</th>
1734
+ <th style="width:20%">{callee_header}</th>
1735
+ <th style="width:20%">{desc_header}</th>
1736
+ </tr>
1737
+ {generate_call_table_rows(sec_nodes, sec_edges, lang)}
1738
+ </table>
1739
+
1740
+ {generate_section_cards(sec, sec_nodes, sec_edges, lang)}
1741
+ <hr>
1742
+ """)
1743
+
1744
+ # ── Section: Hyperedges (if any) ──
1745
+ if hyperedges:
1746
+ html.append("""<h2 id="hyperedges">Group Relationships (Hyperedges)</h2>
1747
+ <div class="grid">
1748
+ """)
1749
+ for he in hyperedges[:9]:
1750
+ hid = he.get("id", "?")
1751
+ hlabel = he.get("label", hid)
1752
+ hnodes = he.get("nodes", [])
1753
+ hrel = he.get("relation", "")
1754
+ html.append(f""" <div class="card">
1755
+ <h4>{escape(str(hlabel))}</h4>
1756
+ <p><code>{escape(str(hrel))}</code> — {len(hnodes)} participants</p>
1757
+ <ul>""")
1758
+ for hn in hnodes[:5]:
1759
+ html.append(f" <li><code>{escape(str(hn))}</code></li>")
1760
+ if len(hnodes) > 5:
1761
+ html.append(f" <li>... and {len(hnodes) - 5} more</li>")
1762
+ html.append(" </ul>\n </div>")
1763
+ html.append("</div>\n<hr>")
1764
+
1765
+ # ── Section: Statistics ──
1766
+ total_sections = sum(1 for s in sections if s["id"] != "overview")
1767
+ html.append(f"""<h2 id="stats">Project Statistics</h2>
1768
+
1769
+ <div class="grid">
1770
+ <div class="card">
1771
+ <h4>Graph</h4>
1772
+ <table style="width:100%;font-size:0.85rem;">
1773
+ <tr><td>Nodes</td><td>{len(nodes)}</td></tr>
1774
+ <tr><td>Edges</td><td>{len(edges)}</td></tr>
1775
+ <tr><td>Hyperedges</td><td>{len(hyperedges)}</td></tr>
1776
+ <tr><td>Communities</td><td>{len(comm_idx)}</td></tr>
1777
+ <tr><td>Documented Sections</td><td>{total_sections}</td></tr>
1778
+ </table>
1779
+ </div>
1780
+ <div class="card">
1781
+ <h4>Edge Confidence</h4>
1782
+ <table style="width:100%;font-size:0.85rem;">
1783
+ <tr><td>EXTRACTED</td><td>{sum(1 for e in edges if e.get('confidence') == 'EXTRACTED')}</td></tr>
1784
+ <tr><td>INFERRED</td><td>{sum(1 for e in edges if e.get('confidence') == 'INFERRED')}</td></tr>
1785
+ <tr><td>AMBIGUOUS</td><td>{sum(1 for e in edges if e.get('confidence') == 'AMBIGUOUS')}</td></tr>
1786
+ </table>
1787
+ </div>
1788
+ </div>
1789
+ """)
1790
+
1791
+ # ── Footer ──
1792
+ html.append(f"""<div style="text-align:center; padding:40px 0; color: var(--muted); font-size:0.9rem;">
1793
+ <p>{escape(str(meta.get('project_name', 'Project')))} — Architecture Documentation</p>
1794
+ <p>Generated: {datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M UTC')} · graphify callflow-html</p>
1795
+ </div>
1796
+ """)
1797
+
1798
+ # Close
1799
+ html.append("""</div><!-- .container -->
1800
+
1801
+ <script>
1802
+ (function () {
1803
+ const mermaidConfig = {
1804
+ startOnLoad: false,
1805
+ theme: 'dark',
1806
+ securityLevel: 'loose',
1807
+ flowchart: { htmlLabels: true, useMaxWidth: true },
1808
+ themeVariables: {
1809
+ primaryColor: '#1e293b',
1810
+ primaryTextColor: '#e2e8f0',
1811
+ primaryBorderColor: '#38bdf8',
1812
+ secondaryColor: '#0f172a',
1813
+ tertiaryColor: '#334155',
1814
+ lineColor: '#64748b',
1815
+ textColor: '#e2e8f0',
1816
+ }
1817
+ };
1818
+
1819
+ mermaid.initialize(mermaidConfig);
1820
+
1821
+ function clamp(value, min, max) {
1822
+ return Math.min(max, Math.max(min, value));
1823
+ }
1824
+
1825
+ function enhanceMermaidDiagrams() {
1826
+ document.querySelectorAll('.mermaid').forEach((container) => {
1827
+ if (container.dataset.zoomReady === 'true') return;
1828
+ const svg = container.querySelector('svg');
1829
+ if (!svg) return;
1830
+
1831
+ container.dataset.zoomReady = 'true';
1832
+ container.classList.add('is-enhanced');
1833
+
1834
+ const viewport = document.createElement('div');
1835
+ viewport.className = 'mermaid-viewport';
1836
+ svg.parentNode.insertBefore(viewport, svg);
1837
+ viewport.appendChild(svg);
1838
+
1839
+ const toolbar = document.createElement('div');
1840
+ toolbar.className = 'mermaid-toolbar';
1841
+ toolbar.innerHTML = [
1842
+ '<button type="button" data-action="zoom-out" title="Zoom out">-</button>',
1843
+ '<span class="zoom-level" data-role="level">100%</span>',
1844
+ '<button type="button" data-action="zoom-in" title="Zoom in">+</button>',
1845
+ '<button type="button" data-action="fit" title="Fit width">Fit</button>',
1846
+ '<button type="button" data-action="reset" title="Reset view">Reset</button>'
1847
+ ].join('');
1848
+ container.insertBefore(toolbar, viewport);
1849
+
1850
+ const state = { scale: 1, x: 0, y: 0, dragging: false, startX: 0, startY: 0, originX: 0, originY: 0 };
1851
+ const level = toolbar.querySelector('[data-role="level"]');
1852
+
1853
+ function applyTransform() {
1854
+ svg.style.transform = `translate(${state.x}px, ${state.y}px) scale(${state.scale})`;
1855
+ level.textContent = `${Math.round(state.scale * 100)}%`;
1856
+ }
1857
+
1858
+ function zoomBy(delta) {
1859
+ state.scale = clamp(state.scale + delta, 0.25, 3);
1860
+ applyTransform();
1861
+ }
1862
+
1863
+ function reset() {
1864
+ state.scale = 1;
1865
+ state.x = 0;
1866
+ state.y = 0;
1867
+ applyTransform();
1868
+ }
1869
+
1870
+ function fitWidth() {
1871
+ const rawWidth = svg.viewBox && svg.viewBox.baseVal && svg.viewBox.baseVal.width
1872
+ ? svg.viewBox.baseVal.width
1873
+ : svg.getBoundingClientRect().width / state.scale;
1874
+ if (!rawWidth) {
1875
+ reset();
1876
+ return;
1877
+ }
1878
+ state.scale = clamp((viewport.clientWidth - 48) / rawWidth, 0.25, 1.4);
1879
+ state.x = 0;
1880
+ state.y = 0;
1881
+ applyTransform();
1882
+ }
1883
+
1884
+ toolbar.addEventListener('click', (event) => {
1885
+ const button = event.target.closest('button[data-action]');
1886
+ if (!button) return;
1887
+ const action = button.dataset.action;
1888
+ if (action === 'zoom-in') zoomBy(0.15);
1889
+ if (action === 'zoom-out') zoomBy(-0.15);
1890
+ if (action === 'fit') fitWidth();
1891
+ if (action === 'reset') reset();
1892
+ });
1893
+
1894
+ viewport.addEventListener('wheel', (event) => {
1895
+ if (!event.ctrlKey && !event.metaKey) return;
1896
+ event.preventDefault();
1897
+ zoomBy(event.deltaY < 0 ? 0.1 : -0.1);
1898
+ }, { passive: false });
1899
+
1900
+ viewport.addEventListener('pointerdown', (event) => {
1901
+ if (event.button !== 0) return;
1902
+ state.dragging = true;
1903
+ state.startX = event.clientX;
1904
+ state.startY = event.clientY;
1905
+ state.originX = state.x;
1906
+ state.originY = state.y;
1907
+ viewport.classList.add('is-dragging');
1908
+ viewport.setPointerCapture(event.pointerId);
1909
+ });
1910
+
1911
+ viewport.addEventListener('pointermove', (event) => {
1912
+ if (!state.dragging) return;
1913
+ state.x = state.originX + event.clientX - state.startX;
1914
+ state.y = state.originY + event.clientY - state.startY;
1915
+ applyTransform();
1916
+ });
1917
+
1918
+ function endDrag(event) {
1919
+ if (!state.dragging) return;
1920
+ state.dragging = false;
1921
+ viewport.classList.remove('is-dragging');
1922
+ if (viewport.hasPointerCapture(event.pointerId)) {
1923
+ viewport.releasePointerCapture(event.pointerId);
1924
+ }
1925
+ }
1926
+
1927
+ viewport.addEventListener('pointerup', endDrag);
1928
+ viewport.addEventListener('pointercancel', endDrag);
1929
+ applyTransform();
1930
+ });
1931
+ }
1932
+
1933
+ function renderMermaid() {
1934
+ const result = mermaid.run
1935
+ ? mermaid.run({ querySelector: '.mermaid' })
1936
+ : Promise.resolve();
1937
+ Promise.resolve(result)
1938
+ .then(enhanceMermaidDiagrams)
1939
+ .catch((error) => {
1940
+ console.error('Mermaid render failed:', error);
1941
+ enhanceMermaidDiagrams();
1942
+ });
1943
+ }
1944
+
1945
+ if (document.readyState === 'loading') {
1946
+ document.addEventListener('DOMContentLoaded', renderMermaid);
1947
+ } else {
1948
+ renderMermaid();
1949
+ }
1950
+ })();
1951
+ </script>
1952
+
1953
+ </body>
1954
+ </html>""")
1955
+
1956
+ # Write output
1957
+ output = "\n".join(html)
1958
+ output_path.parent.mkdir(parents=True, exist_ok=True)
1959
+ output_path.write_text(output, encoding="utf-8")
1960
+
1961
+ # Summary
1962
+ mermaid_count = output.count('<div class="mermaid">')
1963
+ table_count = output.count('<table class="call-table">')
1964
+ section_count = output.count('<h2 id=')
1965
+
1966
+ if verbose:
1967
+ print(f"Call-flow HTML written: {output_path}")
1968
+ print(f" Sections: {section_count} | Mermaid diagrams: {mermaid_count} | Call tables: {table_count}")
1969
+ print(" Diagrams use Mermaid init directives plus interactive zoom/pan controls.")
1970
+
1971
+ return output_path
1972
+
1973
+
1974
+ def main():
1975
+ parser = argparse.ArgumentParser(
1976
+ description="Generate call-flow architecture HTML from graphify knowledge graph outputs"
1977
+ )
1978
+ parser.add_argument("project", nargs="?", default=None, help="Project root or graphify output directory")
1979
+ parser.add_argument("--graphify-out", default=None, help="Path to graphify output directory")
1980
+ parser.add_argument("--graph", default=None, help="Path to graph.json")
1981
+ parser.add_argument("--report", default=None, help="Path to GRAPH_REPORT.md")
1982
+ parser.add_argument("--labels", default=None, help="Path to .graphify_labels.json")
1983
+ parser.add_argument("--sections", default=None, help="Path to sections JSON file; auto-derived when omitted")
1984
+ parser.add_argument("--output", default=None, help="Output HTML path")
1985
+ parser.add_argument("--lang", default="auto", help="HTML language: auto, zh-CN, en, etc. (default: auto)")
1986
+ parser.add_argument("--max-sections", type=int, default=15, help="Maximum auto-derived sections, excluding overview")
1987
+ parser.add_argument("--diagram-scale", type=float, default=1.0, help="Mermaid-native diagram scale via init directive (0.65-1.8)")
1988
+ parser.add_argument("--max-diagram-nodes", type=int, default=18, help="Maximum representative nodes per section diagram")
1989
+ parser.add_argument("--max-diagram-edges", type=int, default=24, help="Maximum representative edges per section diagram")
1990
+ args = parser.parse_args()
1991
+
1992
+ try:
1993
+ write_callflow_html(
1994
+ args.project,
1995
+ graphify_out=args.graphify_out,
1996
+ graph=args.graph,
1997
+ report=args.report,
1998
+ labels=args.labels,
1999
+ sections=args.sections,
2000
+ output=args.output,
2001
+ lang=args.lang,
2002
+ max_sections=args.max_sections,
2003
+ diagram_scale=args.diagram_scale,
2004
+ max_diagram_nodes=args.max_diagram_nodes,
2005
+ max_diagram_edges=args.max_diagram_edges,
2006
+ verbose=True,
2007
+ )
2008
+ except (FileNotFoundError, ValueError, SystemExit) as exc:
2009
+ print(f"ERROR: {exc}", file=sys.stderr)
2010
+ sys.exit(1)
2011
+
2012
+
2013
+ if __name__ == "__main__":
2014
+ main()