maestro-flow 0.4.2 → 0.4.4

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 (302) hide show
  1. package/.claude/commands/maestro-analyze.md +1 -1
  2. package/.claude/commands/maestro-brainstorm.md +1 -1
  3. package/.claude/commands/maestro-collab.md +1 -1
  4. package/.claude/commands/maestro-execute.md +10 -1
  5. package/.claude/commands/maestro-guard.md +101 -0
  6. package/.claude/commands/maestro-impeccable.md +1 -1
  7. package/.claude/commands/maestro-plan.md +15 -2
  8. package/.claude/commands/maestro-ralph-execute.md +9 -2
  9. package/.claude/commands/maestro-ralph.md +8 -1
  10. package/.claude/commands/maestro-verify.md +15 -1
  11. package/.claude/commands/quality-auto-test.md +1 -1
  12. package/.claude/commands/quality-debug.md +1 -1
  13. package/.claude/commands/quality-refactor.md +1 -1
  14. package/.claude/commands/quality-retrospective.md +1 -1
  15. package/.claude/commands/quality-review.md +15 -1
  16. package/.claude/commands/quality-test.md +1 -1
  17. package/.claude/commands/security-audit.md +154 -0
  18. package/.claude/skills/maestro-help/index/catalog.json +2 -0
  19. package/.codex/skills/maestro-analyze/SKILL.md +18 -1
  20. package/.codex/skills/maestro-brainstorm/SKILL.md +17 -4
  21. package/.codex/skills/maestro-collab/SKILL.md +7 -1
  22. package/.codex/skills/maestro-execute/SKILL.md +365 -348
  23. package/.codex/skills/maestro-guard/SKILL.md +97 -0
  24. package/.codex/skills/maestro-impeccable/SKILL.md +1 -1
  25. package/.codex/skills/maestro-plan/SKILL.md +66 -7
  26. package/.codex/skills/maestro-ralph/SKILL.md +1 -1
  27. package/.codex/skills/maestro-verify/SKILL.md +18 -1
  28. package/.codex/skills/quality-auto-test/SKILL.md +13 -3
  29. package/.codex/skills/quality-debug/SKILL.md +362 -346
  30. package/.codex/skills/quality-refactor/SKILL.md +1 -1
  31. package/.codex/skills/quality-retrospective/SKILL.md +292 -292
  32. package/.codex/skills/quality-review/SKILL.md +374 -365
  33. package/.codex/skills/quality-test/SKILL.md +1 -1
  34. package/.codex/skills/security-audit/SKILL.md +154 -0
  35. package/bin/maestro-hook-runner.js +21 -1
  36. package/dashboard/dist/assets/{ArtifactsPage-iJZtYsmR.js → ArtifactsPage-CVh0Z2I2.js} +3 -3
  37. package/dashboard/dist/assets/{ChatInput-DNnDLdQF.js → ChatInput-CBI3qHQQ.js} +2 -2
  38. package/dashboard/dist/assets/ChatPage-BjJ9CYox.js +22 -0
  39. package/dashboard/dist/assets/CollabPage-CprGGO9y.js +1 -0
  40. package/dashboard/dist/assets/{ExecutionPanel-BKV3GZ7Q.js → ExecutionPanel-CClxD7cH.js} +1 -1
  41. package/dashboard/dist/assets/KanbanPage-copqjdPg.js +16 -0
  42. package/dashboard/dist/assets/MaestroCoordinatePage-CioZjQ9N.js +4 -0
  43. package/dashboard/dist/assets/{MarkdownRenderer-cYFfe1uX.js → MarkdownRenderer-CtUhoxCT.js} +1 -1
  44. package/dashboard/dist/assets/McpPage-BcPPcJpr.js +21 -0
  45. package/dashboard/dist/assets/{MeetingRoomPage-wnvT7wlB.js → MeetingRoomPage-BgmAKxU-.js} +1 -1
  46. package/dashboard/dist/assets/{OutputPanel-DDL90Idy.js → OutputPanel-DgT3gMyp.js} +1 -1
  47. package/dashboard/dist/assets/{ProblemsPanel-zFN9IIs0.js → ProblemsPanel-BmG7rxoG.js} +1 -1
  48. package/dashboard/dist/assets/{RequirementBoardPage-DOPJoT0I.js → RequirementBoardPage-k8YoeQ0r.js} +1 -1
  49. package/dashboard/dist/assets/{RequirementPage-CEVquRgM.js → RequirementPage-Da2354px.js} +1 -1
  50. package/dashboard/dist/assets/{RoomsPage-D5USEWDh.js → RoomsPage-BtqDiYaU.js} +1 -1
  51. package/dashboard/dist/assets/SpecsPage-ByPVH_M3.js +36 -0
  52. package/dashboard/dist/assets/{TeamsPage-DlcEmr_Q.js → TeamsPage-sFDLN30L.js} +1 -1
  53. package/dashboard/dist/assets/{TreeBrowser-Y48Wz-QY.js → TreeBrowser-oEx8YJXV.js} +1 -1
  54. package/dashboard/dist/assets/WorkflowPage-JrX7CVHh.js +6 -0
  55. package/dashboard/dist/assets/{arrow-left-NCUOENvg.js → arrow-left-DYvgSdIH.js} +1 -1
  56. package/dashboard/dist/assets/{check-o7nfGNHf.js → check-jcgYBWVR.js} +1 -1
  57. package/dashboard/dist/assets/{chevron-right-BXySK2fn.js → chevron-right-DvZ5sMOg.js} +1 -1
  58. package/dashboard/dist/assets/{circle-cooAwnAR.js → circle-DYT-zoRZ.js} +1 -1
  59. package/dashboard/dist/assets/{circle-alert-DcSBokh4.js → circle-alert-Bfbv3gt4.js} +1 -1
  60. package/dashboard/dist/assets/{circle-check-Cd-jce4j.js → circle-check-D82WnpbI.js} +1 -1
  61. package/dashboard/dist/assets/{circle-check-big-BN7Mdp4i.js → circle-check-big-CPVD1GKF.js} +1 -1
  62. package/dashboard/dist/assets/{code-BQa9oL1n.js → code-B3bKFGI4.js} +1 -1
  63. package/dashboard/dist/assets/{columns-3-BzgxelGx.js → columns-3-BeMAQCix.js} +1 -1
  64. package/dashboard/dist/assets/{download-swRJnate.js → download-BCtpoWYB.js} +1 -1
  65. package/dashboard/dist/assets/en-2h6fD0j8.js +1 -0
  66. package/dashboard/dist/assets/{folder-DbGbLNFN.js → folder-CTj6SNNu.js} +1 -1
  67. package/dashboard/dist/assets/index-6-yE5Yl9.css +1 -0
  68. package/dashboard/dist/assets/{index-DIoMBMbv.js → index-BxR_3IbJ.js} +1 -1
  69. package/dashboard/dist/assets/{index-DLBN_7fb.js → index-CWBJLu42.js} +1 -1
  70. package/dashboard/dist/assets/index-DpcPd-UG.js +236 -0
  71. package/dashboard/dist/assets/{list-BTRAIvDq.js → list-BMv8pIQn.js} +1 -1
  72. package/dashboard/dist/assets/{loader-NHtB6Mdn.js → loader-DdM4VOgF.js} +1 -1
  73. package/dashboard/dist/assets/{minus-BjMxRTET.js → minus-D15s2E__.js} +1 -1
  74. package/dashboard/dist/assets/{pen-line-C4_O16H0.js → pen-line-DO6o4xWz.js} +1 -1
  75. package/dashboard/dist/assets/{pencil-DTmKhyDY.js → pencil-qGxg9jOe.js} +1 -1
  76. package/dashboard/dist/assets/{proxy-Dtx5p6IO.js → proxy-DOffTzwA.js} +1 -1
  77. package/dashboard/dist/assets/refresh-cw-C9UNdLCy.js +6 -0
  78. package/dashboard/dist/assets/{rows-2-GR1dZtRu.js → rows-2-CifAA5SL.js} +1 -1
  79. package/dashboard/dist/assets/{search-DVtgy2W7.js → search-pe7pU1YN.js} +1 -1
  80. package/dashboard/dist/assets/{shallow-BOmvDNsv.js → shallow-r7YynQYA.js} +1 -1
  81. package/dashboard/dist/assets/table-Bh772iIw.js +6 -0
  82. package/dashboard/dist/assets/{team-types-BPeOvVdA.js → team-types-C_HqX2p2.js} +1 -1
  83. package/dashboard/dist/assets/{terminal-CzogW4cl.js → terminal-EpmtGBlw.js} +1 -1
  84. package/dashboard/dist/assets/{trash-2-52LATVfW.js → trash-2-Xen46iNQ.js} +1 -1
  85. package/dashboard/dist/assets/{users-DLFE2voE.js → users-BLueDPxF.js} +1 -1
  86. package/dashboard/dist/assets/{zap-DhiYlgyZ.js → zap-DsQCPF61.js} +1 -1
  87. package/dashboard/dist/assets/zh-CN-r3AvxxOL.js +1 -0
  88. package/dashboard/dist/index.html +2 -2
  89. package/dashboard/dist-server/dashboard/src/server/routes/settings.js +70 -1
  90. package/dashboard/dist-server/dashboard/src/server/routes/settings.js.map +1 -1
  91. package/dashboard/dist-server/src/coordinator/output-parser.js +27 -0
  92. package/dashboard/dist-server/src/coordinator/output-parser.js.map +1 -1
  93. package/dashboard/dist-server/src/types/index.d.ts +48 -6
  94. package/dist/src/commands/coordinate.d.ts.map +1 -1
  95. package/dist/src/commands/coordinate.js +4 -0
  96. package/dist/src/commands/coordinate.js.map +1 -1
  97. package/dist/src/commands/hooks.d.ts.map +1 -1
  98. package/dist/src/commands/hooks.js +239 -8
  99. package/dist/src/commands/hooks.js.map +1 -1
  100. package/dist/src/commands/spec.d.ts.map +1 -1
  101. package/dist/src/commands/spec.js +466 -0
  102. package/dist/src/commands/spec.js.map +1 -1
  103. package/dist/src/config/index.d.ts +5 -1
  104. package/dist/src/config/index.d.ts.map +1 -1
  105. package/dist/src/config/index.js +42 -0
  106. package/dist/src/config/index.js.map +1 -1
  107. package/dist/src/coordinator/output-parser.d.ts.map +1 -1
  108. package/dist/src/coordinator/output-parser.js +27 -0
  109. package/dist/src/coordinator/output-parser.js.map +1 -1
  110. package/dist/src/hooks/delegate-monitor.d.ts +1 -0
  111. package/dist/src/hooks/delegate-monitor.d.ts.map +1 -1
  112. package/dist/src/hooks/delegate-monitor.js +1 -1
  113. package/dist/src/hooks/delegate-monitor.js.map +1 -1
  114. package/dist/src/hooks/guards/workflow-guard.d.ts +15 -0
  115. package/dist/src/hooks/guards/workflow-guard.d.ts.map +1 -1
  116. package/dist/src/hooks/guards/workflow-guard.js +61 -1
  117. package/dist/src/hooks/guards/workflow-guard.js.map +1 -1
  118. package/dist/src/hooks/keyword-spec-injector.d.ts.map +1 -1
  119. package/dist/src/hooks/keyword-spec-injector.js +63 -4
  120. package/dist/src/hooks/keyword-spec-injector.js.map +1 -1
  121. package/dist/src/hooks/plugins/decision-log-plugin.d.ts +19 -0
  122. package/dist/src/hooks/plugins/decision-log-plugin.d.ts.map +1 -0
  123. package/dist/src/hooks/plugins/decision-log-plugin.js +28 -0
  124. package/dist/src/hooks/plugins/decision-log-plugin.js.map +1 -0
  125. package/dist/src/hooks/plugins/index.d.ts +2 -0
  126. package/dist/src/hooks/plugins/index.d.ts.map +1 -1
  127. package/dist/src/hooks/plugins/index.js +1 -0
  128. package/dist/src/hooks/plugins/index.js.map +1 -1
  129. package/dist/src/hooks/plugins/spec-analytics-plugin.d.ts +13 -0
  130. package/dist/src/hooks/plugins/spec-analytics-plugin.d.ts.map +1 -0
  131. package/dist/src/hooks/plugins/spec-analytics-plugin.js +92 -0
  132. package/dist/src/hooks/plugins/spec-analytics-plugin.js.map +1 -0
  133. package/dist/src/hooks/plugins/spec-injection-plugin.d.ts.map +1 -1
  134. package/dist/src/hooks/plugins/spec-injection-plugin.js +57 -4
  135. package/dist/src/hooks/plugins/spec-injection-plugin.js.map +1 -1
  136. package/dist/src/hooks/session-context.d.ts +1 -0
  137. package/dist/src/hooks/session-context.d.ts.map +1 -1
  138. package/dist/src/hooks/session-context.js +1 -1
  139. package/dist/src/hooks/session-context.js.map +1 -1
  140. package/dist/src/hooks/skill-context.d.ts +1 -0
  141. package/dist/src/hooks/skill-context.d.ts.map +1 -1
  142. package/dist/src/hooks/skill-context.js +1 -1
  143. package/dist/src/hooks/skill-context.js.map +1 -1
  144. package/dist/src/hooks/spec-analytics.d.ts +128 -0
  145. package/dist/src/hooks/spec-analytics.d.ts.map +1 -0
  146. package/dist/src/hooks/spec-analytics.js +311 -0
  147. package/dist/src/hooks/spec-analytics.js.map +1 -0
  148. package/dist/src/hooks/spec-injector.d.ts.map +1 -1
  149. package/dist/src/hooks/spec-injector.js +129 -5
  150. package/dist/src/hooks/spec-injector.js.map +1 -1
  151. package/dist/src/tools/spec-loader.d.ts +20 -0
  152. package/dist/src/tools/spec-loader.d.ts.map +1 -1
  153. package/dist/src/tools/spec-loader.js +58 -7
  154. package/dist/src/tools/spec-loader.js.map +1 -1
  155. package/dist/src/tui/config-ui/ConfigHub.d.ts +1 -1
  156. package/dist/src/tui/config-ui/ConfigHub.d.ts.map +1 -1
  157. package/dist/src/tui/config-ui/ConfigHub.js +16 -10
  158. package/dist/src/tui/config-ui/ConfigHub.js.map +1 -1
  159. package/dist/src/tui/config-ui/ConfigSourcesView.d.ts.map +1 -1
  160. package/dist/src/tui/config-ui/ConfigSourcesView.js +3 -2
  161. package/dist/src/tui/config-ui/ConfigSourcesView.js.map +1 -1
  162. package/dist/src/tui/config-ui/HooksPanel.d.ts.map +1 -1
  163. package/dist/src/tui/config-ui/HooksPanel.js +15 -19
  164. package/dist/src/tui/config-ui/HooksPanel.js.map +1 -1
  165. package/dist/src/tui/config-ui/SkillConfigDashboard.d.ts.map +1 -1
  166. package/dist/src/tui/config-ui/SkillConfigDashboard.js +5 -9
  167. package/dist/src/tui/config-ui/SkillConfigDashboard.js.map +1 -1
  168. package/dist/src/tui/config-ui/SkillParamEditor.d.ts.map +1 -1
  169. package/dist/src/tui/config-ui/SkillParamEditor.js +1 -3
  170. package/dist/src/tui/config-ui/SkillParamEditor.js.map +1 -1
  171. package/dist/src/tui/config-ui/SkillsList.d.ts.map +1 -1
  172. package/dist/src/tui/config-ui/SkillsList.js +7 -9
  173. package/dist/src/tui/config-ui/SkillsList.js.map +1 -1
  174. package/dist/src/tui/config-ui/SpecAnalyticsPanel.d.ts +6 -0
  175. package/dist/src/tui/config-ui/SpecAnalyticsPanel.d.ts.map +1 -0
  176. package/dist/src/tui/config-ui/SpecAnalyticsPanel.js +164 -0
  177. package/dist/src/tui/config-ui/SpecAnalyticsPanel.js.map +1 -0
  178. package/dist/src/tui/config-ui/SpecPanel.d.ts.map +1 -1
  179. package/dist/src/tui/config-ui/SpecPanel.js +918 -20
  180. package/dist/src/tui/config-ui/SpecPanel.js.map +1 -1
  181. package/dist/src/tui/config-ui/index.d.ts +3 -1
  182. package/dist/src/tui/config-ui/index.d.ts.map +1 -1
  183. package/dist/src/tui/config-ui/index.js +4 -0
  184. package/dist/src/tui/config-ui/index.js.map +1 -1
  185. package/dist/src/tui/install-ui/BackupConfig.d.ts.map +1 -1
  186. package/dist/src/tui/install-ui/BackupConfig.js +3 -2
  187. package/dist/src/tui/install-ui/BackupConfig.js.map +1 -1
  188. package/dist/src/tui/install-ui/BlueprintPreview.d.ts.map +1 -1
  189. package/dist/src/tui/install-ui/BlueprintPreview.js +7 -6
  190. package/dist/src/tui/install-ui/BlueprintPreview.js.map +1 -1
  191. package/dist/src/tui/install-ui/ComponentGrid.d.ts.map +1 -1
  192. package/dist/src/tui/install-ui/ComponentGrid.js +3 -2
  193. package/dist/src/tui/install-ui/ComponentGrid.js.map +1 -1
  194. package/dist/src/tui/install-ui/ConfigPanel.d.ts.map +1 -1
  195. package/dist/src/tui/install-ui/ConfigPanel.js +4 -3
  196. package/dist/src/tui/install-ui/ConfigPanel.js.map +1 -1
  197. package/dist/src/tui/install-ui/CyberItem.d.ts.map +1 -1
  198. package/dist/src/tui/install-ui/CyberItem.js +7 -6
  199. package/dist/src/tui/install-ui/CyberItem.js.map +1 -1
  200. package/dist/src/tui/install-ui/CyberdeckBlueprint.d.ts.map +1 -1
  201. package/dist/src/tui/install-ui/CyberdeckBlueprint.js +2 -1
  202. package/dist/src/tui/install-ui/CyberdeckBlueprint.js.map +1 -1
  203. package/dist/src/tui/install-ui/ExecutionView.d.ts.map +1 -1
  204. package/dist/src/tui/install-ui/ExecutionView.js +3 -2
  205. package/dist/src/tui/install-ui/ExecutionView.js.map +1 -1
  206. package/dist/src/tui/install-ui/GradientHeader.d.ts.map +1 -1
  207. package/dist/src/tui/install-ui/GradientHeader.js +2 -1
  208. package/dist/src/tui/install-ui/GradientHeader.js.map +1 -1
  209. package/dist/src/tui/install-ui/HooksConfig.d.ts.map +1 -1
  210. package/dist/src/tui/install-ui/HooksConfig.js +8 -8
  211. package/dist/src/tui/install-ui/HooksConfig.js.map +1 -1
  212. package/dist/src/tui/install-ui/InstallConfirm.d.ts.map +1 -1
  213. package/dist/src/tui/install-ui/InstallConfirm.js +4 -3
  214. package/dist/src/tui/install-ui/InstallConfirm.js.map +1 -1
  215. package/dist/src/tui/install-ui/InstallExecution.d.ts.map +1 -1
  216. package/dist/src/tui/install-ui/InstallExecution.js +3 -2
  217. package/dist/src/tui/install-ui/InstallExecution.js.map +1 -1
  218. package/dist/src/tui/install-ui/InstallFlow.d.ts.map +1 -1
  219. package/dist/src/tui/install-ui/InstallFlow.js +3 -2
  220. package/dist/src/tui/install-ui/InstallFlow.js.map +1 -1
  221. package/dist/src/tui/install-ui/InstallHub.d.ts.map +1 -1
  222. package/dist/src/tui/install-ui/InstallHub.js +9 -8
  223. package/dist/src/tui/install-ui/InstallHub.js.map +1 -1
  224. package/dist/src/tui/install-ui/InstallResult.d.ts.map +1 -1
  225. package/dist/src/tui/install-ui/InstallResult.js +3 -2
  226. package/dist/src/tui/install-ui/InstallResult.js.map +1 -1
  227. package/dist/src/tui/install-ui/McpConfig.d.ts.map +1 -1
  228. package/dist/src/tui/install-ui/McpConfig.js +4 -3
  229. package/dist/src/tui/install-ui/McpConfig.js.map +1 -1
  230. package/dist/src/tui/install-ui/ResultDashboard.d.ts.map +1 -1
  231. package/dist/src/tui/install-ui/ResultDashboard.js +3 -2
  232. package/dist/src/tui/install-ui/ResultDashboard.js.map +1 -1
  233. package/dist/src/tui/install-ui/ReviewPanel.d.ts.map +1 -1
  234. package/dist/src/tui/install-ui/ReviewPanel.js +2 -1
  235. package/dist/src/tui/install-ui/ReviewPanel.js.map +1 -1
  236. package/dist/src/tui/install-ui/StatuslineConfig.d.ts.map +1 -1
  237. package/dist/src/tui/install-ui/StatuslineConfig.js +3 -2
  238. package/dist/src/tui/install-ui/StatuslineConfig.js.map +1 -1
  239. package/dist/src/tui/install-ui/StepSelector.d.ts.map +1 -1
  240. package/dist/src/tui/install-ui/StepSelector.js +11 -10
  241. package/dist/src/tui/install-ui/StepSelector.js.map +1 -1
  242. package/dist/src/tui/overlay-ui/OverlayList.d.ts.map +1 -1
  243. package/dist/src/tui/overlay-ui/OverlayList.js +8 -12
  244. package/dist/src/tui/overlay-ui/OverlayList.js.map +1 -1
  245. package/dist/src/tui/shared/components.d.ts +56 -0
  246. package/dist/src/tui/shared/components.d.ts.map +1 -0
  247. package/dist/src/tui/shared/components.js +55 -0
  248. package/dist/src/tui/shared/components.js.map +1 -0
  249. package/dist/src/tui/shared/helpers.d.ts +24 -0
  250. package/dist/src/tui/shared/helpers.d.ts.map +1 -0
  251. package/dist/src/tui/shared/helpers.js +49 -0
  252. package/dist/src/tui/shared/helpers.js.map +1 -0
  253. package/dist/src/tui/shared/index.d.ts +4 -0
  254. package/dist/src/tui/shared/index.d.ts.map +1 -0
  255. package/dist/src/tui/shared/index.js +7 -0
  256. package/dist/src/tui/shared/index.js.map +1 -0
  257. package/dist/src/tui/shared/tokens.d.ts +79 -0
  258. package/dist/src/tui/shared/tokens.d.ts.map +1 -0
  259. package/dist/src/tui/shared/tokens.js +81 -0
  260. package/dist/src/tui/shared/tokens.js.map +1 -0
  261. package/dist/src/tui/tools-ui/CommandReference.d.ts.map +1 -1
  262. package/dist/src/tui/tools-ui/CommandReference.js +2 -4
  263. package/dist/src/tui/tools-ui/CommandReference.js.map +1 -1
  264. package/dist/src/tui/tools-ui/ConfigSources.d.ts.map +1 -1
  265. package/dist/src/tui/tools-ui/ConfigSources.js +3 -2
  266. package/dist/src/tui/tools-ui/ConfigSources.js.map +1 -1
  267. package/dist/src/tui/tools-ui/RegisterSettings.d.ts.map +1 -1
  268. package/dist/src/tui/tools-ui/RegisterSettings.js +2 -1
  269. package/dist/src/tui/tools-ui/RegisterSettings.js.map +1 -1
  270. package/dist/src/tui/tools-ui/RoleMappings.d.ts.map +1 -1
  271. package/dist/src/tui/tools-ui/RoleMappings.js +3 -5
  272. package/dist/src/tui/tools-ui/RoleMappings.js.map +1 -1
  273. package/dist/src/tui/tools-ui/ToolsDashboard.d.ts.map +1 -1
  274. package/dist/src/tui/tools-ui/ToolsDashboard.js +3 -5
  275. package/dist/src/tui/tools-ui/ToolsDashboard.js.map +1 -1
  276. package/dist/src/tui/tools-ui/ToolsOverview.d.ts.map +1 -1
  277. package/dist/src/tui/tools-ui/ToolsOverview.js +3 -5
  278. package/dist/src/tui/tools-ui/ToolsOverview.js.map +1 -1
  279. package/dist/src/tui/uninstall-ui/UninstallFlow.d.ts.map +1 -1
  280. package/dist/src/tui/uninstall-ui/UninstallFlow.js +8 -7
  281. package/dist/src/tui/uninstall-ui/UninstallFlow.js.map +1 -1
  282. package/dist/src/types/index.d.ts +48 -6
  283. package/dist/src/types/index.d.ts.map +1 -1
  284. package/package.json +1 -1
  285. package/workflows/debug.md +73 -0
  286. package/workflows/execute.md +27 -0
  287. package/workflows/plan.md +11 -0
  288. package/workflows/review.md +33 -1
  289. package/workflows/tdd.md +257 -0
  290. package/workflows/verify.md +57 -0
  291. package/dashboard/dist/assets/ChatPage-BjBibfE4.js +0 -22
  292. package/dashboard/dist/assets/CollabPage-8lUMUol_.js +0 -1
  293. package/dashboard/dist/assets/KanbanPage-diY3QmGd.js +0 -21
  294. package/dashboard/dist/assets/McpPage-COjuIf7U.js +0 -21
  295. package/dashboard/dist/assets/SpecsPage-BOwBin_o.js +0 -36
  296. package/dashboard/dist/assets/SupervisorPage-5iRyMU5T.js +0 -6
  297. package/dashboard/dist/assets/WorkflowPage-CmQaRVgL.js +0 -6
  298. package/dashboard/dist/assets/en-C_BD3UCD.js +0 -1
  299. package/dashboard/dist/assets/index-BEUaOz_b.css +0 -1
  300. package/dashboard/dist/assets/index-uIqUCT8y.js +0 -236
  301. package/dashboard/dist/assets/table-DCzuJAFh.js +0 -6
  302. package/dashboard/dist/assets/zh-CN-DvQKfow3.js +0 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: quality-test
3
- description: Conversational UAT with auto-diagnosis and gap closure
3
+ description: Use when implementation needs user acceptance testing with interactive verification and gap closure
4
4
  argument-hint: "<phase> [-y] [--smoke] [--auto-fix] [--session ID]"
5
5
  allowed-tools: spawn_agents_on_csv, Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
6
  ---
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: security-audit
3
+ description: OWASP Top 10 and STRIDE security auditing with supply chain analysis
4
+ argument-hint: "[quick|standard|deep] [--scope <path>]"
5
+ allowed-tools: spawn_agents_on_csv, Read, Bash, Glob, Grep, request_user_input
6
+ ---
7
+ <purpose>
8
+ Systematic security audit covering OWASP Top 10, dependency supply chain, secrets detection,
9
+ CI/CD pipeline review, and optional STRIDE threat modeling. Three tiers control depth vs speed.
10
+ </purpose>
11
+
12
+ <context>
13
+ $ARGUMENTS -- Parse tier and scope:
14
+ - Tier: `quick` (default) | `standard` | `deep`
15
+ - `--scope <path>`: Limit scan to directory (default: project root)
16
+
17
+ **Tier coverage:**
18
+
19
+ | Tier | OWASP | Dependencies | Secrets | CI/CD | STRIDE | Git History |
20
+ |------|-------|-------------|---------|-------|--------|-------------|
21
+ | quick | Y | Y | -- | -- | -- | -- |
22
+ | standard | Y | Y | Y | Y | -- | -- |
23
+ | deep | Y | Y | Y | Y | Y | Y |
24
+ </context>
25
+
26
+ <execution>
27
+
28
+ **Phase 1: Reconnaissance**
29
+
30
+ 1. Detect tech stack from package.json / go.mod / requirements.txt / Cargo.toml
31
+ 2. Identify entry points: HTTP handlers, API routes, CLI parsers, WebSocket handlers
32
+ 3. List authentication/authorization modules
33
+ 4. Map data flow: user input -> processing -> storage -> output
34
+
35
+ **Phase 2: OWASP Top 10 Scan** (all tiers)
36
+
37
+ For each category, scan relevant source files:
38
+
39
+ | # | Category | What to check |
40
+ |---|----------|--------------|
41
+ | A01 | Broken Access Control | Missing auth middleware, direct object references, path traversal |
42
+ | A02 | Cryptographic Failures | Weak algorithms, hardcoded keys, missing TLS, plaintext storage |
43
+ | A03 | Injection | SQL concatenation, shell exec with user input, template injection |
44
+ | A04 | Insecure Design | Missing rate limits, no CSRF tokens, predictable tokens |
45
+ | A05 | Security Misconfiguration | Debug mode, default credentials, verbose errors, open CORS |
46
+ | A06 | Vulnerable Components | Known CVEs in dependencies |
47
+ | A07 | Auth Failures | Weak password rules, missing brute-force protection, session fixation |
48
+ | A08 | Data Integrity | Deserialization of untrusted data, unsigned updates |
49
+ | A09 | Logging Failures | Missing audit logs, logging sensitive data |
50
+ | A10 | SSRF | Unvalidated URLs in server-side requests |
51
+
52
+ Use `Grep` for pattern matching (e.g., `eval(`, `exec(`, `innerHTML`, `dangerouslySetInnerHTML`,
53
+ `sql.*\+.*req\.`, `process\.env` without validation).
54
+
55
+ For `standard` and `deep` tiers, use `spawn_agents_on_csv` to parallelize OWASP category scans
56
+ across multiple agents, one agent per 2-3 categories.
57
+
58
+ **Phase 3: Dependency Audit** (all tiers)
59
+
60
+ ```bash
61
+ # Node.js
62
+ npm audit --json 2>/dev/null || true
63
+ # Check lockfile integrity
64
+ test -f package-lock.json && echo "lockfile present" || echo "WARNING: no lockfile"
65
+ ```
66
+
67
+ Check for:
68
+ - Known vulnerabilities (CVE references)
69
+ - Lockfile presence and integrity
70
+ - Typosquatting risk on critical dependencies (manually check suspicious names)
71
+
72
+ **Phase 4: Secrets Detection** (standard + deep)
73
+
74
+ ```bash
75
+ # Current codebase
76
+ grep -rn --include="*.ts" --include="*.js" --include="*.json" --include="*.env*" \
77
+ -E "(password|secret|api.?key|token|credential).*=.*['\"][^'\"]{8,}" . || true
78
+ ```
79
+
80
+ Check `.env.example` for leaked values. Check `.gitignore` for missing `.env` patterns.
81
+
82
+ **Phase 5: CI/CD Audit** (standard + deep)
83
+
84
+ Scan `.github/workflows/*.yml` for:
85
+ - Overly permissive `permissions:` (write-all, contents: write)
86
+ - Unpinned action versions (`uses: actions/checkout@main` vs `@v4.1.0`)
87
+ - Secrets in logs (missing `mask` or `add-mask`)
88
+ - Pull request trigger with `pull_request_target` (code injection risk)
89
+
90
+ **Phase 6: STRIDE Threat Modeling** (deep only)
91
+
92
+ For each critical module identified in Phase 1:
93
+
94
+ | Threat | Question |
95
+ |--------|----------|
96
+ | **S**poofing | Can identity be faked? Is auth per-request? |
97
+ | **T**ampering | Can data be modified in transit/storage? Integrity checks? |
98
+ | **R**epudiation | Are actions logged with user identity? |
99
+ | **I**nformation Disclosure | Can unauthorized data be accessed? |
100
+ | **D**enial of Service | Resource limits? Rate limiting? |
101
+ | **E**levation of Privilege | Can roles be escalated? Input validation on role fields? |
102
+
103
+ For `deep` tier, use `spawn_agents_on_csv` to parallelize STRIDE analysis across critical modules,
104
+ one agent per module. Use `request_user_input` to confirm critical module list before spawning.
105
+
106
+ **Phase 7: Git History Archaeology** (deep only)
107
+
108
+ ```bash
109
+ # Search for previously committed secrets
110
+ git log --all --diff-filter=D --name-only --pretty=format: -- "*.env" "*.key" "*.pem" 2>/dev/null | head -20
111
+ git log -p --all -S "password" --since="1 year ago" -- "*.ts" "*.js" 2>/dev/null | head -50
112
+ ```
113
+
114
+ **Phase 8: Report**
115
+
116
+ Output severity matrix:
117
+
118
+ ```
119
+ === Security Audit ({tier}) ===
120
+
121
+ CRITICAL ({count}):
122
+ - [A03] SQL injection in {file}:{line} -- {description}
123
+ Fix: {remediation}
124
+
125
+ HIGH ({count}):
126
+ ...
127
+
128
+ MEDIUM ({count}):
129
+ ...
130
+
131
+ LOW ({count}):
132
+ ...
133
+
134
+ Summary: {total} findings ({critical} critical, {high} high, {medium} medium, {low} low)
135
+ ```
136
+
137
+ Emit completion status:
138
+ ```
139
+ --- COMPLETION STATUS ---
140
+ STATUS: DONE|DONE_WITH_CONCERNS
141
+ CONCERNS: {count} critical findings require immediate action
142
+ NEXT: $quality-review
143
+ --- END STATUS ---
144
+ ```
145
+ </execution>
146
+
147
+ <success_criteria>
148
+ - [ ] Tech stack identified and entry points mapped
149
+ - [ ] OWASP Top 10 categories all checked (tier-appropriate)
150
+ - [ ] Dependency audit completed with CVE listing
151
+ - [ ] Severity matrix produced with file:line references
152
+ - [ ] Each finding includes remediation suggestion
153
+ - [ ] Completion status block emitted
154
+ </success_criteria>
@@ -58,6 +58,26 @@ const HOOKS = {
58
58
  if (config.toggles['specInjector'] === false) return;
59
59
  const { evaluateSpecInjection } = await import('../dist/src/hooks/spec-injector.js');
60
60
  const data = JSON.parse(raw);
61
+ const hookEventName = data.hook_event_name ?? '';
62
+ const isSessionStart = hookEventName === 'SessionStart';
63
+
64
+ // Codex SessionStart: inject specs as additionalContext
65
+ if (isSessionStart) {
66
+ const cwd = data.cwd ?? process.cwd();
67
+ const sessionId = data.session_id ?? '';
68
+ const result = evaluateSpecInjection('general', cwd, sessionId);
69
+ if (result.inject && result.content) {
70
+ process.stdout.write(JSON.stringify({
71
+ hookSpecificOutput: {
72
+ hookEventName: 'SessionStart',
73
+ additionalContext: result.content,
74
+ },
75
+ }));
76
+ }
77
+ return;
78
+ }
79
+
80
+ // Claude Code PreToolUse:Agent — rewrite agent prompt
61
81
  const toolInput = data.tool_input ?? {};
62
82
  const agentType = toolInput.subagent_type ?? '';
63
83
  if (!agentType) return;
@@ -105,7 +125,7 @@ const HOOKS = {
105
125
  if (result.flagged) {
106
126
  process.stdout.write(JSON.stringify({
107
127
  hookSpecificOutput: {
108
- hookEventName: 'UserPromptSubmit',
128
+ hookEventName: data.hook_event_name || 'UserPromptSubmit',
109
129
  additionalContext: result.warning,
110
130
  },
111
131
  }));
@@ -1,4 +1,4 @@
1
- import{d as W,r as d,A as J,j as e,F as C,o as xe,W as j,p as pe,V as ue,X as fe,n as Z,B as he}from"./index-uIqUCT8y.js";import{C as me}from"./code-BQa9oL1n.js";import{S as X}from"./search-DVtgy2W7.js";import{u as Q}from"./shallow-BOmvDNsv.js";import{F as M,T as ge}from"./TreeBrowser-Y48Wz-QY.js";import{M as ve}from"./MarkdownRenderer-cYFfe1uX.js";import{C as ee}from"./chevron-right-BXySK2fn.js";import{D as te}from"./folder-DbGbLNFN.js";import{C as re}from"./circle-cooAwnAR.js";import{C as $}from"./circle-check-Cd-jce4j.js";import{A as be}from"./index-DIoMBMbv.js";import{m as N}from"./proxy-Dtx5p6IO.js";/**
1
+ import{d as W,r as d,A as J,j as e,F as C,o as xe,W as j,p as pe,V as ue,X as fe,n as Z,B as he}from"./index-DpcPd-UG.js";import{C as me}from"./code-B3bKFGI4.js";import{S as X}from"./search-pe7pU1YN.js";import{u as Q}from"./shallow-r7YynQYA.js";import{F as M,T as ge}from"./TreeBrowser-oEx8YJXV.js";import{M as ve}from"./MarkdownRenderer-CtUhoxCT.js";import{C as ee}from"./chevron-right-DvZ5sMOg.js";import{D as te}from"./folder-CTj6SNNu.js";import{C as re}from"./circle-DYT-zoRZ.js";import{C as $}from"./circle-check-D82WnpbI.js";import{A as be}from"./index-BxR_3IbJ.js";import{m as N}from"./proxy-DOffTzwA.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -15,7 +15,7 @@ import{d as W,r as d,A as J,j as e,F as C,o as xe,W as j,p as pe,V as ue,X as fe
15
15
  * See the LICENSE file in the root directory of this source tree.
16
16
  */const ke=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],Ce=W("library",ke);function Se(){const[t,r]=d.useState([]),[a,s]=d.useState(null),[i,o]=d.useState(null),[c,n]=d.useState(!1),[l,x]=d.useState(!0),[p,u]=d.useState(null),f=d.useCallback(async()=>{x(!0);try{const b=await fetch(`${J.ARTIFACTS}/?tree=true`);if(!b.ok){u(`Failed to load tree: ${b.status}`);return}const y=await b.json();r(y),u(null)}catch{u("Failed to connect to server")}finally{x(!1)}},[]);d.useEffect(()=>{f()},[f]);const g=d.useCallback(async b=>{s(b),n(!0),u(null);try{const y=await fetch(`${J.ARTIFACTS}/${b}`);if(!y.ok){u(`Failed to load file: ${y.status}`),o(null);return}const S=await y.text();o(S)}catch{u("Failed to fetch file content"),o(null)}finally{n(!1)}},[]);return{tree:t,selectedPath:a,content:i,loading:c,treeLoading:l,error:p,selectFile:g,refreshTree:f}}function se({data:t}){const[r,a]=d.useState(!1);return e.jsxs("div",{className:"font-mono text-[length:var(--font-size-sm)] leading-[var(--line-height-normal)]",role:"tree","aria-label":"JSON data viewer",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] mb-[var(--spacing-3)] pb-[var(--spacing-2)] border-b border-border bg-bg-secondary px-[var(--spacing-2)] py-[var(--spacing-1-5)] -mx-[var(--spacing-2)] -mt-[var(--spacing-1)]",children:[e.jsx("button",{type:"button",onClick:()=>a(s=>!s),"aria-label":r?"Expand all":"Collapse all",className:["px-[var(--spacing-2)] py-[var(--spacing-1)] text-[length:var(--font-size-xs)] rounded-[var(--radius-default)]","text-text-secondary hover:bg-bg-hover hover:text-text-primary","transition-colors duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]","active:scale-[0.98] active:duration-[var(--duration-fast)]"].join(" "),children:r?"Expand All":"Collapse All"}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-tertiary",children:"Click a value to copy"})]}),e.jsx(_,{value:t,path:"$",depth:0,forceCollapse:r})]})}function _({value:t,path:r,depth:a,keyName:s,forceCollapse:i}){const[o,c]=d.useState(a>2),n=i?!0:o,l=d.useCallback(u=>{navigator.clipboard.writeText(u).catch(()=>{})},[]),x=a*16;if(t===null)return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)] hover:bg-bg-hover rounded-[var(--radius-default)] transition-colors duration-[var(--duration-fast)]",style:{paddingLeft:x},role:"treeitem",children:[s!==void 0&&e.jsx(w,{name:s}),e.jsx("span",{className:"text-text-tertiary cursor-pointer hover:opacity-70",onClick:()=>l("null"),title:`Copy: null | Path: ${r}`,children:"null"})]});if(typeof t!="object"){const{colorVar:u,display:f}=Ie(t);return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)] hover:bg-bg-hover rounded-[var(--radius-default)] transition-colors duration-[var(--duration-fast)]",style:{paddingLeft:x},role:"treeitem",children:[s!==void 0&&e.jsx(w,{name:s}),e.jsx("span",{className:"cursor-pointer hover:opacity-70",style:{color:u},onClick:()=>l(String(t)),title:`Copy value | Path: ${r}`,children:f})]})}if(Array.isArray(t))return t.length===0?e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)]",style:{paddingLeft:x},role:"treeitem",children:[s!==void 0&&e.jsx(w,{name:s}),e.jsx("span",{className:"text-text-tertiary",children:"[]"})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)] cursor-pointer hover:bg-bg-hover rounded-[var(--radius-default)] px-[var(--spacing-1)] transition-colors duration-[var(--duration-fast)]",style:{paddingLeft:x},onClick:()=>c(u=>!u),role:"treeitem","aria-expanded":!n,children:[e.jsx(D,{open:!n}),s!==void 0&&e.jsx(w,{name:s}),e.jsxs("span",{className:"text-text-tertiary",children:["[",n?`${t.length} items`:""]})]}),!n&&e.jsxs(e.Fragment,{children:[t.map((u,f)=>e.jsx(_,{value:u,path:`${r}[${f}]`,depth:a+1,keyName:String(f),forceCollapse:i},f)),e.jsx("div",{style:{paddingLeft:x},children:e.jsx("span",{className:"text-text-tertiary",children:"]"})})]}),n&&e.jsx("span",{className:"text-text-tertiary",style:{paddingLeft:x},children:"]"})]});const p=Object.entries(t);return p.length===0?e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)]",style:{paddingLeft:x},role:"treeitem",children:[s!==void 0&&e.jsx(w,{name:s}),e.jsx("span",{className:"text-text-tertiary",children:"{}"})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)] cursor-pointer hover:bg-bg-hover rounded-[var(--radius-default)] px-[var(--spacing-1)] transition-colors duration-[var(--duration-fast)]",style:{paddingLeft:x},onClick:()=>c(u=>!u),role:"treeitem","aria-expanded":!n,children:[e.jsx(D,{open:!n}),s!==void 0&&e.jsx(w,{name:s}),e.jsxs("span",{className:"text-text-tertiary",children:["{",n?`${p.length} keys`:""]})]}),!n&&e.jsxs(e.Fragment,{children:[p.map(([u,f])=>e.jsx(_,{value:f,path:`${r}.${u}`,depth:a+1,keyName:u,forceCollapse:i},u)),e.jsx("div",{style:{paddingLeft:x},children:e.jsx("span",{className:"text-text-tertiary",children:"}"})})]}),n&&e.jsx("span",{className:"text-text-tertiary",style:{paddingLeft:x},children:"}"})]})}function w({name:t}){return e.jsxs("span",{className:"text-text-primary font-[var(--font-weight-medium)]",children:['"',t,'"',e.jsx("span",{className:"text-text-tertiary",children:": "})]})}function D({open:t}){return e.jsx("span",{className:["text-text-tertiary text-[length:var(--font-size-xs)] w-[var(--size-icon-sm)] inline-flex items-center justify-center select-none","transition-transform duration-[var(--duration-normal)] ease-[var(--ease-notion)]",t?"rotate-90":""].join(" "),children:"▸"})}function Ie(t){return typeof t=="string"?{colorVar:"var(--color-status-completed)",display:`"${t}"`}:typeof t=="number"?{colorVar:"var(--color-accent-blue)",display:String(t)}:typeof t=="boolean"?{colorVar:"var(--color-accent-yellow)",display:String(t)}:{colorVar:"var(--color-text-tertiary)",display:String(t)}}function ae({content:t,path:r,rawOverride:a}){const[s,i]=d.useState(!1),o=Ee(r),c=a!==void 0,n=c?a:s;return c?e.jsx("div",{role:"region","aria-label":"File content",children:n?e.jsx(I,{content:t}):e.jsx(K,{content:t,ext:o})}):e.jsxs("div",{className:"flex flex-col h-full",role:"region","aria-label":"File content",children:[e.jsxs("div",{className:"flex items-center justify-between px-[var(--spacing-3)] py-[var(--spacing-2)] border-b border-border bg-bg-secondary shrink-0 h-9",children:[e.jsx("span",{className:"text-[length:var(--font-size-sm)] text-text-secondary font-mono truncate",children:r}),e.jsx("button",{type:"button",onClick:()=>i(l=>!l),"aria-pressed":n,"aria-label":n?"Show rendered view":"Show raw view",className:["px-[var(--spacing-2)] py-[var(--spacing-1)] text-[length:var(--font-size-xs)] rounded-[var(--radius-default)]","transition-colors duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",n?"bg-bg-active text-accent-blue font-[var(--font-weight-medium)]":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"].join(" "),children:n?"Rendered":"Raw"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-[var(--spacing-4)] bg-bg-primary",children:n?e.jsx(I,{content:t}):e.jsx(K,{content:t,ext:o})})]})}function K({content:t,ext:r}){switch(r){case".md":return e.jsx(ve,{content:t});case".json":return e.jsx(Fe,{content:t});case".ndjson":return e.jsx(Le,{content:t});default:return e.jsx(I,{content:t})}}function Fe({content:t}){try{const r=JSON.parse(t);return e.jsx(se,{data:r})}catch{return e.jsxs("div",{children:[e.jsx("p",{className:"text-status-blocked text-[length:var(--font-size-sm)] mb-[var(--spacing-2)]",children:"Invalid JSON"}),e.jsx(I,{content:t})]})}}function Le({content:t}){const r=t.split(`
17
17
  `).filter(a=>a.trim().length>0);return r.length===0?e.jsx("p",{className:"text-text-secondary text-[length:var(--font-size-sm)] italic",children:"Empty NDJSON file"}):e.jsxs("div",{className:"space-y-[var(--spacing-3)]",children:[e.jsxs("p",{className:"text-[length:var(--font-size-xs)] text-text-secondary mb-[var(--spacing-2)]",children:[r.length," record",r.length!==1?"s":""]}),r.map((a,s)=>{try{const i=JSON.parse(a);return e.jsxs("div",{className:"border border-border rounded-[var(--radius-default)] p-[var(--spacing-2)] bg-bg-secondary",children:[e.jsxs("span",{className:"text-[length:var(--font-size-xs)] text-text-secondary mb-[var(--spacing-1)] block",children:["#",s+1]}),e.jsx(se,{data:i})]},s)}catch{return e.jsxs("div",{className:"border border-border rounded-[var(--radius-default)] p-[var(--spacing-2)] bg-bg-secondary",children:[e.jsxs("span",{className:"text-[length:var(--font-size-xs)] text-text-secondary",children:["#",s+1," (invalid)"]}),e.jsx("pre",{className:"text-[length:var(--font-size-sm)] font-mono text-text-primary whitespace-pre-wrap mt-[var(--spacing-1)]",children:a})]},s)}})]})}function I({content:t}){return e.jsx("pre",{className:"font-mono text-[length:var(--font-size-sm)] text-text-primary whitespace-pre-wrap break-words leading-[var(--line-height-relaxed)]",children:t})}function Ee(t){const r=t.lastIndexOf(".");return r===-1?"":t.slice(r).toLowerCase()}function ze(t){const r=t.lastIndexOf(".");return r===-1?"":t.slice(r).toLowerCase()}function Te(t){const r=[],a=t.split(`
18
- `);for(const s of a){const i=s.match(/^(#{1,4})\s+(.+)/);i&&r.push({level:i[1].length,text:i[2].trim()})}return r}function Oe(t){try{const r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)?[]:Object.entries(r).map(([a,s])=>({key:a,type:Array.isArray(s)?"array":typeof s}))}catch{return[]}}function Ae({path:t,content:r}){if(!t)return e.jsx("div",{className:"w-[240px] bg-bg-primary border-l border-border shrink-0 flex items-center justify-center",children:e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-tertiary",children:"No file selected"})});const a=ze(t),s=t.includes("/")?t.slice(t.lastIndexOf("/")+1):t,i=t.includes("/")?t.slice(0,t.lastIndexOf("/")):"/";return e.jsxs("div",{className:"w-[240px] bg-bg-primary border-l border-border shrink-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"px-[14px] py-[10px] border-b border-border-divider text-[length:var(--font-size-sm)] font-[var(--font-weight-semibold)] text-text-primary shrink-0",children:"Properties"}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-[14px] py-[var(--spacing-3)]",children:[e.jsxs(F,{title:"File Info",defaultOpen:!0,children:[e.jsx(T,{label:"Name",value:s}),e.jsx(T,{label:"Type",value:a.replace(".","").toUpperCase()||"Unknown"}),e.jsx(T,{label:"Directory",value:i,mono:!0})]}),e.jsx(F,{title:"Tags",children:e.jsxs("div",{className:"flex flex-wrap gap-[var(--spacing-1)]",children:[e.jsx(O,{label:a.replace(".","")||"file",color:"blue"}),t.includes("phase")&&e.jsx(O,{label:"phase",color:"purple"}),t.includes("verification")&&e.jsx(O,{label:"verify",color:"green"})]})}),a===".md"&&r&&e.jsx($e,{content:r}),a===".json"&&r&&e.jsx(_e,{content:r})]})]})}function F({title:t,defaultOpen:r=!0,children:a}){const[s,i]=d.useState(r);return e.jsxs("div",{className:"mb-[var(--spacing-4)]",children:[e.jsxs("button",{type:"button",onClick:()=>i(o=>!o),className:["flex items-center gap-[var(--spacing-1)] w-full text-left mb-[var(--spacing-1-5)]","text-[9px] font-[var(--font-weight-semibold)] uppercase tracking-[0.06em] text-text-placeholder","hover:text-text-secondary transition-colors duration-[var(--duration-fast)]"].join(" "),children:[e.jsx(ee,{size:10,strokeWidth:2.5,className:["transition-transform duration-[var(--duration-fast)]",s?"rotate-90":""].join(" ")}),t]}),s&&a]})}function T({label:t,value:r,mono:a}){return e.jsxs("div",{className:"flex items-center justify-between py-[var(--spacing-1)] text-[length:var(--font-size-sm)]",children:[e.jsx("span",{className:"text-text-tertiary",children:t}),e.jsx("span",{className:`text-text-primary font-[var(--font-weight-medium)] ${a?"font-mono text-[11px]":""} truncate max-w-[140px]`,children:r})]})}function O({label:t,color:r}){const s={blue:{bg:"rgba(91,141,184,0.12)",text:"var(--color-accent-blue)"},purple:{bg:"rgba(145,120,181,0.12)",text:"var(--color-accent-purple, #9178B5)"},green:{bg:"rgba(90,158,120,0.12)",text:"var(--color-status-completed)"}}[r];return e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full",style:{background:s.bg,color:s.text},children:t})}function $e({content:t}){const r=d.useMemo(()=>Te(t),[t]);return r.length===0?null:e.jsx(F,{title:"Outline",children:e.jsx("div",{className:"flex flex-col gap-[2px]",children:r.map((a,s)=>e.jsxs("button",{type:"button",className:["flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-2)] py-[3px] rounded-[var(--radius-sm)] text-[11px] w-full text-left","hover:bg-bg-hover hover:text-text-primary transition-colors duration-[var(--duration-fast)] cursor-pointer",s===0?"text-text-primary font-[var(--font-weight-semibold)]":"text-text-tertiary"].join(" "),style:{paddingLeft:(a.level-1)*10+8},children:[e.jsx("span",{className:"w-1 h-1 rounded-full shrink-0",style:{background:s===0?"var(--color-accent-purple)":"var(--color-text-placeholder)"}}),e.jsx("span",{className:"truncate",children:a.text})]},s))})})}function _e({content:t}){const r=d.useMemo(()=>Oe(t),[t]);return r.length===0?null:e.jsx(F,{title:"Structure",children:e.jsx("div",{className:"flex flex-col gap-0",children:r.map(a=>e.jsxs("div",{className:"flex items-center justify-between py-[var(--spacing-1)] text-[length:var(--font-size-sm)]",children:[e.jsx("span",{className:"text-text-primary font-mono text-[11px] truncate max-w-[120px]",children:a.key}),e.jsx("span",{className:"text-text-placeholder text-[10px]",children:a.type})]},a.key))})})}function We(t){switch(t.slice(t.lastIndexOf(".")).toLowerCase()){case".json":return{Icon:M,bg:"rgba(184,149,64,0.10)",color:"var(--color-accent-yellow)"};case".md":return{Icon:C,bg:"rgba(91,141,184,0.10)",color:"var(--color-accent-blue)"};case".ndjson":return{Icon:te,bg:"rgba(200,134,58,0.10)",color:"var(--color-accent-orange, #C8863A)"};default:return{Icon:C,bg:"rgba(160,157,151,0.10)",color:"var(--color-text-tertiary)"}}}function ne({content:t,path:r,onNavigate:a,loading:s,error:i,title:o,subtitle:c}){const[n,l]=d.useState(!1);if(i)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{role:"alert",className:"px-[var(--spacing-3)] py-[var(--spacing-2)] text-[length:var(--font-size-xs)] rounded-[var(--radius-default)]",style:{backgroundColor:"var(--color-status-bg-blocked)",color:"var(--color-status-blocked)",borderColor:"var(--color-status-blocked)"},children:i})});if(s)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-text-secondary text-[length:var(--font-size-sm)] animate-pulse",children:"Loading..."})});if(!r||t===null)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-secondary",children:[e.jsx("p",{className:"text-[length:var(--font-size-lg)] mb-[var(--spacing-2)]",children:"Select a file"}),e.jsx("p",{className:"text-[length:var(--font-size-sm)]",children:"Choose an artifact from the tree to view"})]});const x=r.includes("/")?r.slice(r.lastIndexOf("/")+1):r,{Icon:p,bg:u,color:f}=We(r);return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-3)] px-[24px] py-[10px] border-b border-border-divider shrink-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-[var(--radius-default)] flex items-center justify-center shrink-0",style:{background:u,color:f},children:e.jsx(p,{size:14,strokeWidth:1.8})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[c&&e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-text-tertiary font-medium truncate",children:c}),e.jsx("div",{className:"text-[14px] font-[var(--font-weight-bold)] text-text-primary truncate",children:o??x}),e.jsx("div",{className:"text-[10px] font-mono text-text-tertiary truncate",children:r})]}),e.jsxs("div",{className:"flex gap-[var(--spacing-1)]",children:[e.jsx("button",{type:"button",onClick:()=>l(!1),className:["px-[10px] py-[var(--spacing-1)] rounded-[var(--radius-default)] border text-[10px] font-[var(--font-weight-semibold)]","transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",n?"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary":"bg-text-primary text-bg-primary border-text-primary"].join(" "),children:"Rendered"}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:["px-[10px] py-[var(--spacing-1)] rounded-[var(--radius-default)] border text-[10px] font-[var(--font-weight-semibold)]","transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",n?"bg-text-primary text-bg-primary border-text-primary":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),children:"Source"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-[720px] mx-auto px-[32px] py-[24px]",children:e.jsx(ae,{content:t,path:r,rawOverride:n})})})]}),e.jsx(Ae,{path:r,content:t})]})}function Me(t){const r=t.slice(t.lastIndexOf(".")).toLowerCase();switch(r){case".json":return"json";case".md":return"md";case".ndjson":return"jsonl";default:return r.replace(".","")||"file"}}function Re(t){switch(t){case"json":return{Icon:M,tintBg:"rgba(184,149,64,0.10)",iconColor:"var(--color-accent-yellow)",badgeBg:"rgba(184,149,64,0.12)",badgeColor:"var(--color-accent-yellow)"};case"md":return{Icon:C,tintBg:"rgba(91,141,184,0.10)",iconColor:"var(--color-accent-blue)",badgeBg:"rgba(91,141,184,0.12)",badgeColor:"var(--color-accent-blue)"};case"jsonl":return{Icon:te,tintBg:"rgba(200,134,58,0.10)",iconColor:"var(--color-accent-orange, #C8863A)",badgeBg:"rgba(200,134,58,0.12)",badgeColor:"var(--color-accent-orange, #C8863A)"};default:return{Icon:C,tintBg:"rgba(160,157,151,0.10)",iconColor:"var(--color-text-tertiary)",badgeBg:"rgba(160,157,151,0.12)",badgeColor:"var(--color-text-tertiary)"}}}function Ve({name:t,path:r,isSelected:a,onClick:s}){const i=Me(t),o=Re(i),{Icon:c}=o,n=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"";return e.jsxs("button",{type:"button",onClick:s,className:["bg-bg-card border rounded-[var(--radius-lg)] p-[14px_16px] cursor-pointer text-left w-full","transition-all duration-[180ms] ease-[var(--ease-spring)]","flex flex-col gap-[var(--spacing-2)]","hover:-translate-y-[2px] hover:shadow-[0_6px_20px_rgba(0,0,0,0.06)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",a?"border-accent-purple shadow-[0_0_0_2px_rgba(145,120,181,0.2)]":"border-border-divider hover:border-border"].join(" "),children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)]",children:[e.jsx("div",{className:"w-8 h-8 rounded-[var(--radius-md)] flex items-center justify-center shrink-0",style:{background:o.tintBg,color:o.iconColor},children:e.jsx(c,{size:16,strokeWidth:1.8})}),e.jsx("span",{className:"text-[length:var(--font-size-sm)] font-[var(--font-weight-semibold)] text-text-primary flex-1 truncate",children:t}),e.jsx("span",{className:"text-[9px] font-[var(--font-weight-semibold)] px-[5px] py-[1px] rounded-[var(--radius-sm)] uppercase font-mono shrink-0",style:{background:o.badgeBg,color:o.badgeColor},children:i})]}),e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary leading-[1.5] line-clamp-3 min-h-[48px]",children:r}),n&&e.jsx("div",{className:"flex items-center gap-[var(--spacing-1-5)] pt-[var(--spacing-1)] border-t border-border-divider",children:e.jsx("span",{className:"text-[10px] text-text-placeholder font-mono truncate",children:n})})]})}function ie(t,r=""){const a=[];for(const s of t)s.type==="file"?a.push({name:s.name,path:s.path,group:r||"root"}):s.children&&a.push(...ie(s.children,s.name));return a}function Pe(t){const r=new Map;for(const a of t){const s=r.get(a.group)||[];s.push(a),r.set(a.group,s)}return r}const Be=["All","json","md","jsonl"];function Je(t){if(t==="root"||!t.match(/^\d{2}-/))return{dotColor:"var(--color-text-tertiary)"};const r=t.toLowerCase();return r.includes("setup")||r.includes("complete")||r.includes("init")?{dotColor:"var(--color-status-completed)",statusLabel:"Done",statusBg:"var(--color-status-bg-completed)",statusColor:"var(--color-status-completed)"}:{dotColor:"var(--color-accent-yellow)",statusLabel:"Active",statusBg:"var(--color-status-bg-executing)",statusColor:"var(--color-status-executing)"}}function De({tree:t,onSelectFile:r,selectedPath:a}){const[s,i]=d.useState(""),[o,c]=d.useState("All"),n=d.useMemo(()=>ie(t),[t]),l=d.useMemo(()=>{let p=n;if(s.trim()){const u=s.toLowerCase();p=p.filter(f=>f.name.toLowerCase().includes(u)||f.path.toLowerCase().includes(u))}return o!=="All"&&(p=p.filter(u=>{const f=u.name.slice(u.name.lastIndexOf(".")).toLowerCase();return o==="json"?f===".json":o==="md"?f===".md":o==="jsonl"?f===".ndjson"||f===".jsonl":!0})),p},[n,s,o]),x=d.useMemo(()=>Pe(l),[l]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[24px] py-[10px] border-b border-border-divider shrink-0",children:[e.jsxs("div",{className:["flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-3)] py-[5px] rounded-[var(--radius-md)]","bg-bg-card border border-border w-[200px]","focus-within:border-accent-purple transition-colors duration-[var(--duration-fast)]"].join(" "),children:[e.jsx(X,{size:13,strokeWidth:2,className:"text-text-placeholder shrink-0"}),e.jsx("input",{type:"search",value:s,onChange:p=>i(p.target.value),placeholder:"Search artifacts...","aria-label":"Search artifacts",className:"border-none bg-transparent outline-none text-[12px] text-text-primary placeholder:text-text-placeholder w-full font-[inherit]"})]}),e.jsx("div",{className:"flex-1"}),Be.map(p=>e.jsx("button",{type:"button",onClick:()=>c(p),className:["text-[11px] font-[var(--font-weight-medium)] px-[var(--spacing-3)] py-[var(--spacing-1)] rounded-full","border transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",o===p?"bg-text-primary text-bg-primary border-text-primary":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),children:p==="All"?"All":p.toUpperCase()},p))]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-[24px] py-[var(--spacing-4)]",children:l.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-[length:var(--font-size-sm)]",children:"No artifacts found"}):Array.from(x.entries()).map(([p,u])=>{const f=Je(p);return e.jsxs("div",{className:"mb-[24px]",children:[e.jsxs("div",{className:"flex items-center gap-[10px] mb-[10px] pl-[var(--spacing-1)]",children:[e.jsx("span",{className:"w-[10px] h-[10px] rounded-full shrink-0",style:{background:f.dotColor}}),e.jsx("span",{className:"text-[13px] font-[var(--font-weight-bold)] text-text-primary",children:p==="root"?"Project":p}),f.statusLabel&&e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full",style:{background:f.statusBg,color:f.statusColor},children:f.statusLabel}),e.jsxs("span",{className:"text-[11px] text-text-tertiary",children:[u.length," file",u.length!==1?"s":""]}),e.jsx("div",{className:"flex-1 h-px bg-border-divider ml-[var(--spacing-2)]"})]}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-[10px]",children:u.map(g=>e.jsx(Ve,{name:g.name,path:g.path,type:g.name.slice(g.name.lastIndexOf(".")),isSelected:g.path===a,onClick:()=>r(g.path)},g.path))})]},p)})})]})}function Ke({content:t,path:r}){const[a,s]=d.useState(!1);if(!r||t===null)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-secondary",children:[e.jsx("p",{className:"text-[length:var(--font-size-lg)] mb-[var(--spacing-2)]",children:"Select a file"}),e.jsx("p",{className:"text-[length:var(--font-size-sm)]",children:"Choose a JSON artifact to view its structure"})]});const o=r.slice(r.lastIndexOf(".")).toLowerCase()===".json",c=r.includes("/")?r.slice(r.lastIndexOf("/")+1):r;return o?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx(H,{fileName:c,path:r,isJson:!0,rawMode:a,onToggle:()=>s(n=>!n)}),e.jsx("div",{className:"flex-1 overflow-y-auto px-[24px] py-[20px]",children:e.jsx("div",{className:"max-w-[780px] mx-auto",children:a?e.jsx(le,{content:t}):e.jsx(He,{content:t})})})]}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx(H,{fileName:c,path:r,isJson:!1,rawMode:!1,onToggle:()=>{}}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(ae,{content:t,path:r})})]})}function H({fileName:t,path:r,isJson:a,rawMode:s,onToggle:i}){const o=a?M:C,c=a?"rgba(184,149,64,0.10)":"rgba(91,141,184,0.10)",n=a?"var(--color-accent-yellow)":"var(--color-accent-blue)";return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-3)] px-[24px] py-[10px] border-b border-border-divider shrink-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-[var(--radius-default)] flex items-center justify-center shrink-0",style:{background:c,color:n},children:e.jsx(o,{size:14,strokeWidth:1.8})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14px] font-[var(--font-weight-bold)] text-text-primary truncate",children:t}),e.jsx("div",{className:"text-[10px] font-mono text-text-tertiary truncate",children:r})]}),a&&e.jsxs("div",{className:"flex gap-[var(--spacing-1)]",children:[e.jsx("button",{type:"button",onClick:i,className:["px-[10px] py-[var(--spacing-1)] rounded-[var(--radius-default)] border text-[10px] font-[var(--font-weight-semibold)]","transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",s?"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary":"bg-text-primary text-bg-primary border-text-primary"].join(" "),children:"Structured"}),e.jsx("button",{type:"button",onClick:i,className:["px-[10px] py-[var(--spacing-1)] rounded-[var(--radius-default)] border text-[10px] font-[var(--font-weight-semibold)]","transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",s?"bg-text-primary text-bg-primary border-text-primary":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),children:"Raw"})]})]})}function He({content:t}){const r=d.useMemo(()=>{try{return JSON.parse(t)}catch{return null}},[t]);if(!r||typeof r!="object")return e.jsx(le,{content:t});if(Array.isArray(r))return e.jsx("div",{className:"flex flex-col gap-[var(--spacing-4)]",children:r.map((s,i)=>e.jsx(A,{title:`Item ${i+1}`,data:s},i))});const a=Object.entries(r);return e.jsxs("div",{className:"flex flex-col gap-[var(--spacing-4)]",children:[a.map(([s,i])=>Array.isArray(i)&&i.length>0&&typeof i[0]=="object"?e.jsxs("div",{children:[e.jsx(L,{title:s,badge:`${i.length}`}),e.jsx("div",{className:"flex flex-col gap-[var(--spacing-1-5)]",children:i.map((o,c)=>qe(o)?e.jsx(Ue,{data:o},c):Ye(o)?e.jsx(Ze,{data:o},c):e.jsx(A,{title:`#${c+1}`,data:o},c))})]},s):typeof i=="object"&&i!==null&&!Array.isArray(i)?e.jsx(A,{title:s,data:i},s):null),e.jsx(Ge,{data:r})]})}function L({title:t,badge:r}){return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] mb-[var(--spacing-2)] pb-[var(--spacing-1-5)] border-b border-border-divider",children:[e.jsx("span",{className:"text-[11px] font-[var(--font-weight-bold)] uppercase tracking-[0.06em] text-text-tertiary",children:t}),r&&e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-1-5)] py-[1px] rounded-full",style:{background:"rgba(91,141,184,0.12)",color:"var(--color-accent-blue)"},children:r})]})}function A({title:t,data:r}){if(typeof r!="object"||r===null)return e.jsxs("div",{children:[e.jsx(L,{title:t}),e.jsx("div",{className:"text-[13px] text-text-primary",children:String(r)})]});const a=Object.entries(r);return e.jsxs("div",{children:[e.jsx(L,{title:t}),e.jsx("div",{className:"flex flex-col",children:a.map(([s,i])=>e.jsxs("div",{className:"grid grid-cols-[140px_1fr] gap-[var(--spacing-3)] py-[var(--spacing-1-5)] border-b border-border-divider last:border-b-0 items-start",children:[e.jsx("span",{className:"text-[11px] font-[var(--font-weight-semibold)] text-text-tertiary font-mono pt-[1px]",children:s}),e.jsx(oe,{value:i})]},s))})]})}function oe({value:t}){return t==null?e.jsx("span",{className:"text-[13px] text-text-placeholder italic",children:"null"}):typeof t=="boolean"?e.jsxs("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full inline-flex items-center gap-[var(--spacing-1)]",style:{background:t?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:t?"var(--color-status-completed)":"var(--color-text-tertiary)"},children:[t?e.jsx($,{size:10,strokeWidth:2.5}):e.jsx(re,{size:10,strokeWidth:2.5}),String(t)]}):typeof t=="number"?e.jsx("span",{className:"text-[13px] font-mono text-accent-blue",children:t}):typeof t=="string"?/^(completed|done|passed|active|success)$/i.test(t)?e.jsxs("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full inline-flex items-center gap-[var(--spacing-1)]",style:{background:"rgba(90,158,120,0.12)",color:"var(--color-status-completed)"},children:[e.jsx($,{size:10,strokeWidth:2.5}),t]}):/^(blocked|failed|error)$/i.test(t)?e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full",style:{background:"var(--color-status-bg-blocked)",color:"var(--color-status-blocked)"},children:t}):/^(in.?progress|running|executing)$/i.test(t)?e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full",style:{background:"rgba(91,141,184,0.12)",color:"var(--color-accent-blue)"},children:t}):e.jsx("span",{className:"text-[13px] text-text-primary",children:t}):Array.isArray(t)?t.length===0?e.jsx("span",{className:"text-[13px] text-text-placeholder italic",children:"[]"}):t.every(r=>typeof r=="string")?e.jsx("div",{className:"flex flex-wrap gap-[var(--spacing-1)]",children:t.map((r,a)=>e.jsx("span",{className:"text-[11px] px-[var(--spacing-2)] py-[2px] rounded-[var(--radius-default)] bg-bg-secondary text-text-secondary",children:String(r)},a))}):e.jsxs("span",{className:"text-[13px] font-mono text-text-secondary",children:["[",t.length," items]"]}):typeof t=="object"?e.jsx("span",{className:"text-[13px] font-mono text-text-secondary",children:JSON.stringify(t)}):e.jsx("span",{className:"text-[13px] text-text-primary",children:String(t)})}function Ge({data:t}){const r=Object.entries(t).filter(([,a])=>typeof a!="object"||a===null);return r.length===0?null:e.jsxs("div",{children:[e.jsx(L,{title:"Properties"}),e.jsx("div",{className:"flex flex-col",children:r.map(([a,s])=>e.jsxs("div",{className:"grid grid-cols-[140px_1fr] gap-[var(--spacing-3)] py-[var(--spacing-1-5)] border-b border-border-divider last:border-b-0 items-start",children:[e.jsx("span",{className:"text-[11px] font-[var(--font-weight-semibold)] text-text-tertiary font-mono pt-[1px]",children:a}),e.jsx(oe,{value:s})]},a))})]})}function qe(t){if(typeof t!="object"||t===null)return!1;const r=t;return"severity"in r||"gap_id"in r||"type"in r}function Ue({data:t}){const r=String(t.gap_id||t.id||""),a=String(t.severity||"medium"),s=String(t.type||""),i=String(t.description||t.claim||""),o=String(t.suggested_fix||t.fix||""),c={critical:{bg:"rgba(196,101,85,0.20)",color:"var(--color-status-blocked)"},high:{bg:"rgba(200,134,58,0.20)",color:"var(--color-accent-orange, #C8863A)"},medium:{bg:"rgba(184,149,64,0.20)",color:"var(--color-accent-yellow)"},low:{bg:"rgba(91,141,184,0.20)",color:"var(--color-accent-blue)"}},n=c[a.toLowerCase()]||c.medium;return e.jsxs("div",{className:"p-[10px_14px] rounded-[10px] border-l-[3px] mb-[var(--spacing-1-5)]",style:{borderLeftColor:"var(--color-status-blocked)",background:"var(--color-status-bg-blocked)"},children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] mb-[var(--spacing-1)]",children:[r&&e.jsx("span",{className:"text-[10px] font-[var(--font-weight-bold)] font-mono",style:{color:"var(--color-status-blocked)"},children:r}),e.jsx("span",{className:"text-[9px] font-[var(--font-weight-bold)] px-[5px] py-[1px] rounded-[var(--radius-sm)] uppercase",style:{background:n.bg,color:n.color},children:a}),s&&e.jsx("span",{className:"text-[10px] text-text-tertiary ml-auto font-mono",children:s})]}),i&&e.jsx("p",{className:"text-[13px] text-text-primary mb-[var(--spacing-1)]",children:i}),o&&e.jsxs("p",{className:"text-[length:var(--font-size-sm)] text-text-secondary italic",children:[e.jsx("strong",{className:"font-[var(--font-weight-semibold)] not-italic text-text-tertiary text-[10px] uppercase",children:"Fix: "}),o]})]})}function Ye(t){if(typeof t!="object"||t===null)return!1;const r=t;return("claim"in r||"check"in r)&&!("severity"in r)}function Ze({data:t}){const r=String(t.claim||t.check||t.description||""),a=String(t.evidence||t.detail||""),s=t.passed===!0||t.status==="passed"||t.status==="completed";return e.jsxs("div",{className:"flex items-start gap-[var(--spacing-2)] p-[var(--spacing-2)_var(--spacing-3)] rounded-[var(--radius-md)] bg-bg-card border border-border-divider",children:[s?e.jsx($,{size:16,strokeWidth:2,className:"shrink-0 mt-[1px]",style:{color:"var(--color-status-completed)"}}):e.jsx(re,{size:16,strokeWidth:2,className:"shrink-0 mt-[1px] text-text-placeholder"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-[13px] text-text-primary font-[var(--font-weight-medium)]",children:r}),a&&e.jsx("p",{className:"text-[11px] text-text-tertiary mt-[2px] italic",children:a})]})]})}function le({content:t}){const r=d.useMemo(()=>{try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}},[t]);return e.jsx("pre",{className:["rounded-[10px] p-[16px_20px] font-mono text-[11px] leading-[1.6] overflow-x-auto","bg-[#2C2723] text-[#D9D0C4] border border-[#3D3731]"].join(" "),children:r})}const m=xe((t,r)=>({entries:[],byId:{},loading:!1,error:null,typeFilter:"all",tagFilter:"all",categoryFilter:"all",statusFilter:"all",search:"",selectedId:null,backlinksCache:{},health:null,graph:null,setTypeFilter:a=>t({typeFilter:a}),setTagFilter:a=>t({tagFilter:a}),setCategoryFilter:a=>t({categoryFilter:a}),setStatusFilter:a=>t({statusFilter:a}),setSearch:a=>t({search:a}),setSelected:a=>{t({selectedId:a}),a&&!r().backlinksCache[a]&&r().fetchBacklinks(a)},fetchEntries:async()=>{t({loading:!0,error:null});try{const{search:a}=r(),s=a?`${j.WIKI}?q=${encodeURIComponent(a)}`:j.WIKI,i=await fetch(s);if(!i.ok)throw new Error(`Failed: ${i.status}`);const c=(await i.json()).entries??[],n={};for(const l of c)n[l.id]=l;t({entries:c,byId:n,loading:!1})}catch(a){t({loading:!1,error:String(a)})}},fetchBacklinks:async a=>{try{const s=j.WIKI_BACKLINKS.replace(":id",encodeURIComponent(a)),i=await fetch(s);if(!i.ok)return;const o=await i.json();t(c=>({backlinksCache:{...c.backlinksCache,[a]:o.backlinks??[]}}))}catch{}},fetchHealth:async()=>{try{const a=await fetch(j.WIKI_HEALTH);if(!a.ok)return;const s=await a.json();t({health:s})}catch{}},fetchGraph:async()=>{try{const a=await fetch(j.WIKI_GRAPH);if(!a.ok)return;const s=await a.json();t({graph:s})}catch{}},createEntry:async a=>{const s=await fetch(j.WIKI,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.error??`create failed: ${s.status}`)}const i=await s.json();return await r().fetchEntries(),i.entry},updateEntry:async(a,s)=>{const i=j.WIKI_DETAIL.replace(":id",encodeURIComponent(a)),o=await fetch(i,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!o.ok){const n=await o.json().catch(()=>({}));throw new Error(n.error??`update failed: ${o.status}`)}const c=await o.json();return await r().fetchEntries(),c.entry},removeEntry:async a=>{const s=j.WIKI_DETAIL.replace(":id",encodeURIComponent(a)),i=await fetch(s,{method:"DELETE"});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error??`delete failed: ${i.status}`)}await r().fetchEntries()},filteredEntries:()=>{const{entries:a,typeFilter:s,tagFilter:i,categoryFilter:o,statusFilter:c}=r();return a.filter(n=>!(s!=="all"&&n.type!==s||i!=="all"&&!n.tags.includes(i)||o!=="all"&&n.category!==o||c!=="all"&&n.status!==c))},entriesByType:()=>{const a=r().filteredEntries(),s={project:[],roadmap:[],spec:[],issue:[],lesson:[],knowhow:[],note:[]};for(const i of a)s[i.type].push(i);return s},allTags:()=>{const a=new Set;for(const s of r().entries)for(const i of s.tags)a.add(i);return Array.from(a).sort()}})),Xe={project:"Project",roadmap:"Roadmap",spec:"Specs",issue:"Issues",lesson:"Lessons",knowhow:"KnowHow",note:"Notes"},G={project:"var(--color-accent-blue, #3b82f6)",roadmap:"var(--color-accent-purple, #8b5cf6)",spec:"var(--color-accent-green, #16a34a)",issue:"var(--color-accent-red, #dc2626)",lesson:"var(--color-accent-yellow, #ca8a04)",knowhow:"var(--color-accent-cyan, #0891b2)",note:"var(--color-text-tertiary, #9ca3af)"},Qe=["project","roadmap","spec","issue","lesson","knowhow","note"];function et(t){return t.replace(/^#{1,6}\s+/,"").trim()}function tt(){const t=m(l=>l.entries),r=m(l=>l.typeFilter),a=m(l=>l.tagFilter),s=m(l=>l.categoryFilter),i=m(l=>l.statusFilter),o=m(l=>l.selectedId),c=m(l=>l.setSelected),n=d.useMemo(()=>{const l={project:[],roadmap:[],spec:[],issue:[],lesson:[],knowhow:[],note:[]};for(const x of t)r!=="all"&&x.type!==r||a!=="all"&&!x.tags.includes(a)||s!=="all"&&x.category!==s||i!=="all"&&x.status!==i||l[x.type].push(x);return l},[t,r,a,s,i]);return e.jsx("div",{className:"flex flex-col gap-1 py-1 overflow-y-auto h-full",children:Qe.map(l=>{const x=n[l];return!x||x.length===0?null:e.jsxs("section",{className:"px-2",children:[e.jsxs("h3",{className:"flex items-center gap-1.5 px-1 py-1.5 text-[10px] text-text-tertiary uppercase tracking-wider font-semibold",children:[e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full shrink-0",style:{backgroundColor:G[l]}}),Xe[l],e.jsx("span",{className:"text-text-quaternary font-normal ml-0.5",children:x.length})]}),e.jsx("ul",{className:"flex flex-col gap-px",children:x.map(p=>e.jsx(rt,{entry:p,typeColor:G[p.type],selected:p.id===o,onSelect:()=>c(p.id)},p.id))})]},l)})})}function rt({entry:t,typeColor:r,selected:a,onSelect:s}){return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:s,className:`w-full text-left rounded-[var(--radius-md,6px)] px-2.5 py-2 transition-all ${a?"bg-bg-secondary shadow-[inset_0_0_0_1px_var(--color-border-strong)]":"hover:bg-bg-secondary"}`,style:a?{borderLeft:`2px solid ${r}`,paddingLeft:"8px"}:void 0,children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[!a&&e.jsx("span",{className:"inline-block w-[5px] h-[5px] rounded-full shrink-0 mt-[5px]",style:{backgroundColor:r,opacity:.6}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-text-primary text-[length:var(--font-size-sm)] truncate leading-snug",children:t.title}),t.summary&&e.jsx("div",{className:"text-text-tertiary text-[11px] line-clamp-1 mt-0.5 leading-snug",children:et(t.summary)}),t.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[t.tags.slice(0,3).map(i=>e.jsx("span",{className:"px-1 py-px text-[10px] rounded bg-bg-tertiary text-text-tertiary leading-snug",children:i},i)),t.tags.length>3&&e.jsxs("span",{className:"text-[10px] text-text-quaternary",children:["+",t.tags.length-3]})]})]})]})})})}function st(t){const r=t.split(`
18
+ `);for(const s of a){const i=s.match(/^(#{1,4})\s+(.+)/);i&&r.push({level:i[1].length,text:i[2].trim()})}return r}function Oe(t){try{const r=JSON.parse(t);return typeof r!="object"||r===null||Array.isArray(r)?[]:Object.entries(r).map(([a,s])=>({key:a,type:Array.isArray(s)?"array":typeof s}))}catch{return[]}}function Ae({path:t,content:r}){if(!t)return e.jsx("div",{className:"w-[240px] bg-bg-primary border-l border-border shrink-0 flex items-center justify-center",children:e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-tertiary",children:"No file selected"})});const a=ze(t),s=t.includes("/")?t.slice(t.lastIndexOf("/")+1):t,i=t.includes("/")?t.slice(0,t.lastIndexOf("/")):"/";return e.jsxs("div",{className:"w-[240px] bg-bg-primary border-l border-border shrink-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"px-[14px] py-[10px] border-b border-border-divider text-[length:var(--font-size-sm)] font-[var(--font-weight-semibold)] text-text-primary shrink-0",children:"Properties"}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-[14px] py-[var(--spacing-3)]",children:[e.jsxs(F,{title:"File Info",defaultOpen:!0,children:[e.jsx(T,{label:"Name",value:s}),e.jsx(T,{label:"Type",value:a.replace(".","").toUpperCase()||"Unknown"}),e.jsx(T,{label:"Directory",value:i,mono:!0})]}),e.jsx(F,{title:"Tags",children:e.jsxs("div",{className:"flex flex-wrap gap-[var(--spacing-1)]",children:[e.jsx(O,{label:a.replace(".","")||"file",color:"blue"}),t.includes("phase")&&e.jsx(O,{label:"phase",color:"purple"}),t.includes("verification")&&e.jsx(O,{label:"verify",color:"green"})]})}),a===".md"&&r&&e.jsx($e,{content:r}),a===".json"&&r&&e.jsx(_e,{content:r})]})]})}function F({title:t,defaultOpen:r=!0,children:a}){const[s,i]=d.useState(r);return e.jsxs("div",{className:"mb-[var(--spacing-4)]",children:[e.jsxs("button",{type:"button",onClick:()=>i(o=>!o),className:["flex items-center gap-[var(--spacing-1)] w-full text-left mb-[var(--spacing-1-5)]","text-[9px] font-[var(--font-weight-semibold)] uppercase tracking-[0.06em] text-text-placeholder","hover:text-text-secondary transition-colors duration-[var(--duration-fast)]"].join(" "),children:[e.jsx(ee,{size:10,strokeWidth:2.5,className:["transition-transform duration-[var(--duration-fast)]",s?"rotate-90":""].join(" ")}),t]}),s&&a]})}function T({label:t,value:r,mono:a}){return e.jsxs("div",{className:"flex items-center justify-between py-[var(--spacing-1)] text-[length:var(--font-size-sm)]",children:[e.jsx("span",{className:"text-text-tertiary",children:t}),e.jsx("span",{className:`text-text-primary font-[var(--font-weight-medium)] ${a?"font-mono text-[11px]":""} truncate max-w-[140px]`,children:r})]})}function O({label:t,color:r}){const s={blue:{bg:"rgba(91,141,184,0.12)",text:"var(--color-accent-blue)"},purple:{bg:"rgba(145,120,181,0.12)",text:"var(--color-accent-purple, #9178B5)"},green:{bg:"rgba(90,158,120,0.12)",text:"var(--color-status-completed)"}}[r];return e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full",style:{background:s.bg,color:s.text},children:t})}function $e({content:t}){const r=d.useMemo(()=>Te(t),[t]);return r.length===0?null:e.jsx(F,{title:"Outline",children:e.jsx("div",{className:"flex flex-col gap-[2px]",children:r.map((a,s)=>e.jsxs("button",{type:"button",className:["flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-2)] py-[3px] rounded-[var(--radius-sm)] text-[11px] w-full text-left","hover:bg-bg-hover hover:text-text-primary transition-colors duration-[var(--duration-fast)] cursor-pointer",s===0?"text-text-primary font-[var(--font-weight-semibold)]":"text-text-tertiary"].join(" "),style:{paddingLeft:(a.level-1)*10+8},children:[e.jsx("span",{className:"w-1 h-1 rounded-full shrink-0",style:{background:s===0?"var(--color-accent-purple)":"var(--color-text-placeholder)"}}),e.jsx("span",{className:"truncate",children:a.text})]},s))})})}function _e({content:t}){const r=d.useMemo(()=>Oe(t),[t]);return r.length===0?null:e.jsx(F,{title:"Structure",children:e.jsx("div",{className:"flex flex-col gap-0",children:r.map(a=>e.jsxs("div",{className:"flex items-center justify-between py-[var(--spacing-1)] text-[length:var(--font-size-sm)]",children:[e.jsx("span",{className:"text-text-primary font-mono text-[11px] truncate max-w-[120px]",children:a.key}),e.jsx("span",{className:"text-text-placeholder text-[10px]",children:a.type})]},a.key))})})}function We(t){switch(t.slice(t.lastIndexOf(".")).toLowerCase()){case".json":return{Icon:M,bg:"rgba(184,149,64,0.10)",color:"var(--color-accent-yellow)"};case".md":return{Icon:C,bg:"rgba(91,141,184,0.10)",color:"var(--color-accent-blue)"};case".ndjson":return{Icon:te,bg:"rgba(200,134,58,0.10)",color:"var(--color-accent-orange, #C8863A)"};default:return{Icon:C,bg:"rgba(160,157,151,0.10)",color:"var(--color-text-tertiary)"}}}function ne({content:t,path:r,onNavigate:a,loading:s,error:i,title:o,subtitle:c}){const[n,l]=d.useState(!1);if(i)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{role:"alert",className:"px-[var(--spacing-3)] py-[var(--spacing-2)] text-[length:var(--font-size-xs)] rounded-[var(--radius-default)]",style:{backgroundColor:"var(--color-status-bg-blocked)",color:"var(--color-status-blocked)",borderColor:"var(--color-status-blocked)"},children:i})});if(s)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("p",{className:"text-text-secondary text-[length:var(--font-size-sm)] animate-pulse",children:"Loading..."})});if(!r||t===null)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-secondary",children:[e.jsx("p",{className:"text-[length:var(--font-size-lg)] mb-[var(--spacing-2)]",children:"Select a file"}),e.jsx("p",{className:"text-[length:var(--font-size-sm)]",children:"Choose an artifact from the tree to view"})]});const x=r.includes("/")?r.slice(r.lastIndexOf("/")+1):r,{Icon:p,bg:u,color:f}=We(r);return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-3)] px-[24px] py-[10px] border-b border-border-divider shrink-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-[var(--radius-default)] flex items-center justify-center shrink-0",style:{background:u,color:f},children:e.jsx(p,{size:14,strokeWidth:1.8})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[c&&e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-text-tertiary font-medium truncate",children:c}),e.jsx("div",{className:"text-[14px] font-[var(--font-weight-bold)] text-text-primary truncate",children:o??x}),e.jsx("div",{className:"text-[10px] font-mono text-text-tertiary truncate",children:r})]}),e.jsxs("div",{className:"flex gap-[var(--spacing-1)]",children:[e.jsx("button",{type:"button",onClick:()=>l(!1),className:["px-[10px] py-[var(--spacing-1)] rounded-[var(--radius-default)] border text-[10px] font-[var(--font-weight-semibold)]","transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",n?"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary":"bg-text-primary text-bg-primary border-text-primary"].join(" "),children:"Rendered"}),e.jsx("button",{type:"button",onClick:()=>l(!0),className:["px-[10px] py-[var(--spacing-1)] rounded-[var(--radius-default)] border text-[10px] font-[var(--font-weight-semibold)]","transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",n?"bg-text-primary text-bg-primary border-text-primary":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),children:"Source"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx("div",{className:"max-w-[720px] mx-auto px-[32px] py-[24px]",children:e.jsx(ae,{content:t,path:r,rawOverride:n})})})]}),e.jsx(Ae,{path:r,content:t})]})}function Me(t){const r=t.slice(t.lastIndexOf(".")).toLowerCase();switch(r){case".json":return"json";case".md":return"md";case".ndjson":return"jsonl";default:return r.replace(".","")||"file"}}function Re(t){switch(t){case"json":return{Icon:M,tintBg:"rgba(184,149,64,0.10)",iconColor:"var(--color-accent-yellow)",badgeBg:"rgba(184,149,64,0.12)",badgeColor:"var(--color-accent-yellow)"};case"md":return{Icon:C,tintBg:"rgba(91,141,184,0.10)",iconColor:"var(--color-accent-blue)",badgeBg:"rgba(91,141,184,0.12)",badgeColor:"var(--color-accent-blue)"};case"jsonl":return{Icon:te,tintBg:"rgba(200,134,58,0.10)",iconColor:"var(--color-accent-orange, #C8863A)",badgeBg:"rgba(200,134,58,0.12)",badgeColor:"var(--color-accent-orange, #C8863A)"};default:return{Icon:C,tintBg:"rgba(160,157,151,0.10)",iconColor:"var(--color-text-tertiary)",badgeBg:"rgba(160,157,151,0.12)",badgeColor:"var(--color-text-tertiary)"}}}function Ve({name:t,path:r,isSelected:a,onClick:s}){const i=Me(t),o=Re(i),{Icon:c}=o,n=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"";return e.jsxs("button",{type:"button",onClick:s,className:["bg-bg-card border rounded-[var(--radius-lg)] p-[14px_16px] cursor-pointer text-left w-full","transition-all duration-[180ms] ease-[var(--ease-spring)]","flex flex-col gap-[var(--spacing-2)]","hover:-translate-y-[2px] hover:shadow-[0_6px_20px_rgba(0,0,0,0.06)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",a?"border-accent-purple shadow-[0_0_0_2px_rgba(145,120,181,0.2)]":"border-border-divider hover:border-border"].join(" "),children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)]",children:[e.jsx("div",{className:"w-8 h-8 rounded-[var(--radius-md)] flex items-center justify-center shrink-0",style:{background:o.tintBg,color:o.iconColor},children:e.jsx(c,{size:16,strokeWidth:1.8})}),e.jsx("span",{className:"text-[length:var(--font-size-sm)] font-[var(--font-weight-semibold)] text-text-primary flex-1 truncate",children:t}),e.jsx("span",{className:"text-[9px] font-[var(--font-weight-semibold)] px-[5px] py-[1px] rounded-[var(--radius-sm)] uppercase font-mono shrink-0",style:{background:o.badgeBg,color:o.badgeColor},children:i})]}),e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary leading-[1.5] line-clamp-3 min-h-[48px]",children:r}),n&&e.jsx("div",{className:"flex items-center gap-[var(--spacing-1-5)] pt-[var(--spacing-1)] border-t border-border-divider",children:e.jsx("span",{className:"text-[10px] text-text-placeholder font-mono truncate",children:n})})]})}function ie(t,r=""){const a=[];for(const s of t)s.type==="file"?a.push({name:s.name,path:s.path,group:r||"root"}):s.children&&a.push(...ie(s.children,s.name));return a}function Pe(t){const r=new Map;for(const a of t){const s=r.get(a.group)||[];s.push(a),r.set(a.group,s)}return r}const Be=["All","json","md","jsonl"];function Je(t){if(t==="root"||!t.match(/^\d{2}-/))return{dotColor:"var(--color-text-tertiary)"};const r=t.toLowerCase();return r.includes("setup")||r.includes("complete")||r.includes("init")?{dotColor:"var(--color-status-completed)",statusLabel:"Done",statusBg:"var(--color-status-bg-completed)",statusColor:"var(--color-status-completed)"}:{dotColor:"var(--color-accent-yellow)",statusLabel:"Active",statusBg:"var(--color-status-bg-executing)",statusColor:"var(--color-status-executing)"}}function De({tree:t,onSelectFile:r,selectedPath:a}){const[s,i]=d.useState(""),[o,c]=d.useState("All"),n=d.useMemo(()=>ie(t),[t]),l=d.useMemo(()=>{let p=n;if(s.trim()){const u=s.toLowerCase();p=p.filter(f=>f.name.toLowerCase().includes(u)||f.path.toLowerCase().includes(u))}return o!=="All"&&(p=p.filter(u=>{const f=u.name.slice(u.name.lastIndexOf(".")).toLowerCase();return o==="json"?f===".json":o==="md"?f===".md":o==="jsonl"?f===".ndjson"||f===".jsonl":!0})),p},[n,s,o]),x=d.useMemo(()=>Pe(l),[l]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[24px] py-[10px] border-b border-border-divider shrink-0",children:[e.jsxs("div",{className:["flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-3)] py-[5px] rounded-[var(--radius-md)]","bg-bg-card border border-border w-[200px]","focus-within:border-accent-purple transition-colors duration-[var(--duration-fast)]"].join(" "),children:[e.jsx(X,{size:13,strokeWidth:2,className:"text-text-placeholder shrink-0"}),e.jsx("input",{type:"search",value:s,onChange:p=>i(p.target.value),placeholder:"Search artifacts...","aria-label":"Search artifacts",className:"border-none bg-transparent outline-none text-[12px] text-text-primary placeholder:text-text-placeholder w-full font-[inherit]"})]}),e.jsx("div",{className:"flex-1"}),Be.map(p=>e.jsx("button",{type:"button",onClick:()=>c(p),className:["text-[11px] font-[var(--font-weight-medium)] px-[var(--spacing-3)] py-[var(--spacing-1)] rounded-full","border transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",o===p?"bg-text-primary text-bg-primary border-text-primary":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),children:p==="All"?"All":p.toUpperCase()},p))]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-[24px] py-[var(--spacing-4)]",children:l.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-[length:var(--font-size-sm)]",children:"No artifacts found"}):Array.from(x.entries()).map(([p,u])=>{const f=Je(p);return e.jsxs("div",{className:"mb-[24px]",children:[e.jsxs("div",{className:"flex items-center gap-[10px] mb-[10px] pl-[var(--spacing-1)]",children:[e.jsx("span",{className:"w-[10px] h-[10px] rounded-full shrink-0",style:{background:f.dotColor}}),e.jsx("span",{className:"text-[13px] font-[var(--font-weight-bold)] text-text-primary",children:p==="root"?"Project":p}),f.statusLabel&&e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full",style:{background:f.statusBg,color:f.statusColor},children:f.statusLabel}),e.jsxs("span",{className:"text-[11px] text-text-tertiary",children:[u.length," file",u.length!==1?"s":""]}),e.jsx("div",{className:"flex-1 h-px bg-border-divider ml-[var(--spacing-2)]"})]}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-[10px]",children:u.map(g=>e.jsx(Ve,{name:g.name,path:g.path,type:g.name.slice(g.name.lastIndexOf(".")),isSelected:g.path===a,onClick:()=>r(g.path)},g.path))})]},p)})})]})}function Ke({content:t,path:r}){const[a,s]=d.useState(!1);if(!r||t===null)return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-text-secondary",children:[e.jsx("p",{className:"text-[length:var(--font-size-lg)] mb-[var(--spacing-2)]",children:"Select a file"}),e.jsx("p",{className:"text-[length:var(--font-size-sm)]",children:"Choose a JSON artifact to view its structure"})]});const o=r.slice(r.lastIndexOf(".")).toLowerCase()===".json",c=r.includes("/")?r.slice(r.lastIndexOf("/")+1):r;return o?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx(H,{fileName:c,path:r,isJson:!0,rawMode:a,onToggle:()=>s(n=>!n)}),e.jsx("div",{className:"flex-1 overflow-y-auto px-[24px] py-[20px]",children:e.jsx("div",{className:"max-w-[780px] mx-auto",children:a?e.jsx(le,{content:t}):e.jsx(He,{content:t})})})]}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx(H,{fileName:c,path:r,isJson:!1,rawMode:!1,onToggle:()=>{}}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsx(ae,{content:t,path:r})})]})}function H({fileName:t,path:r,isJson:a,rawMode:s,onToggle:i}){const o=a?M:C,c=a?"rgba(184,149,64,0.10)":"rgba(91,141,184,0.10)",n=a?"var(--color-accent-yellow)":"var(--color-accent-blue)";return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-3)] px-[24px] py-[10px] border-b border-border-divider shrink-0",children:[e.jsx("div",{className:"w-7 h-7 rounded-[var(--radius-default)] flex items-center justify-center shrink-0",style:{background:c,color:n},children:e.jsx(o,{size:14,strokeWidth:1.8})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14px] font-[var(--font-weight-bold)] text-text-primary truncate",children:t}),e.jsx("div",{className:"text-[10px] font-mono text-text-tertiary truncate",children:r})]}),a&&e.jsxs("div",{className:"flex gap-[var(--spacing-1)]",children:[e.jsx("button",{type:"button",onClick:i,className:["px-[10px] py-[var(--spacing-1)] rounded-[var(--radius-default)] border text-[10px] font-[var(--font-weight-semibold)]","transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",s?"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary":"bg-text-primary text-bg-primary border-text-primary"].join(" "),children:"Structured"}),e.jsx("button",{type:"button",onClick:i,className:["px-[10px] py-[var(--spacing-1)] rounded-[var(--radius-default)] border text-[10px] font-[var(--font-weight-semibold)]","transition-all duration-[var(--duration-fast)] ease-[var(--ease-notion)]","focus-visible:outline-none focus-visible:shadow-[var(--shadow-focus-ring)]",s?"bg-text-primary text-bg-primary border-text-primary":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),children:"Raw"})]})]})}function He({content:t}){const r=d.useMemo(()=>{try{return JSON.parse(t)}catch{return null}},[t]);if(!r||typeof r!="object")return e.jsx(le,{content:t});if(Array.isArray(r))return e.jsx("div",{className:"flex flex-col gap-[var(--spacing-4)]",children:r.map((s,i)=>e.jsx(A,{title:`Item ${i+1}`,data:s},i))});const a=Object.entries(r);return e.jsxs("div",{className:"flex flex-col gap-[var(--spacing-4)]",children:[a.map(([s,i])=>Array.isArray(i)&&i.length>0&&typeof i[0]=="object"?e.jsxs("div",{children:[e.jsx(L,{title:s,badge:`${i.length}`}),e.jsx("div",{className:"flex flex-col gap-[var(--spacing-1-5)]",children:i.map((o,c)=>qe(o)?e.jsx(Ue,{data:o},c):Ye(o)?e.jsx(Ze,{data:o},c):e.jsx(A,{title:`#${c+1}`,data:o},c))})]},s):typeof i=="object"&&i!==null&&!Array.isArray(i)?e.jsx(A,{title:s,data:i},s):null),e.jsx(Ge,{data:r})]})}function L({title:t,badge:r}){return e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] mb-[var(--spacing-2)] pb-[var(--spacing-1-5)] border-b border-border-divider",children:[e.jsx("span",{className:"text-[11px] font-[var(--font-weight-bold)] uppercase tracking-[0.06em] text-text-tertiary",children:t}),r&&e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-1-5)] py-[1px] rounded-full",style:{background:"rgba(91,141,184,0.12)",color:"var(--color-accent-blue)"},children:r})]})}function A({title:t,data:r}){if(typeof r!="object"||r===null)return e.jsxs("div",{children:[e.jsx(L,{title:t}),e.jsx("div",{className:"text-[13px] text-text-primary",children:String(r)})]});const a=Object.entries(r);return e.jsxs("div",{children:[e.jsx(L,{title:t}),e.jsx("div",{className:"flex flex-col",children:a.map(([s,i])=>e.jsxs("div",{className:"grid grid-cols-[140px_1fr] gap-[var(--spacing-3)] py-[var(--spacing-1-5)] border-b border-border-divider last:border-b-0 items-start",children:[e.jsx("span",{className:"text-[11px] font-[var(--font-weight-semibold)] text-text-tertiary font-mono pt-[1px]",children:s}),e.jsx(oe,{value:i})]},s))})]})}function oe({value:t}){return t==null?e.jsx("span",{className:"text-[13px] text-text-placeholder italic",children:"null"}):typeof t=="boolean"?e.jsxs("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full inline-flex items-center gap-[var(--spacing-1)]",style:{background:t?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:t?"var(--color-status-completed)":"var(--color-text-tertiary)"},children:[t?e.jsx($,{size:10,strokeWidth:2.5}):e.jsx(re,{size:10,strokeWidth:2.5}),String(t)]}):typeof t=="number"?e.jsx("span",{className:"text-[13px] font-mono text-accent-blue",children:t}):typeof t=="string"?/^(completed|done|passed|active|success)$/i.test(t)?e.jsxs("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full inline-flex items-center gap-[var(--spacing-1)]",style:{background:"rgba(90,158,120,0.12)",color:"var(--color-status-completed)"},children:[e.jsx($,{size:10,strokeWidth:2.5}),t]}):/^(blocked|failed|error)$/i.test(t)?e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full",style:{background:"var(--color-status-bg-blocked)",color:"var(--color-status-blocked)"},children:t}):/^(in.?progress|running|executing)$/i.test(t)?e.jsx("span",{className:"text-[10px] font-[var(--font-weight-semibold)] px-[var(--spacing-2)] py-[2px] rounded-full",style:{background:"rgba(91,141,184,0.12)",color:"var(--color-accent-blue)"},children:t}):e.jsx("span",{className:"text-[13px] text-text-primary",children:t}):Array.isArray(t)?t.length===0?e.jsx("span",{className:"text-[13px] text-text-placeholder italic",children:"[]"}):t.every(r=>typeof r=="string")?e.jsx("div",{className:"flex flex-wrap gap-[var(--spacing-1)]",children:t.map((r,a)=>e.jsx("span",{className:"text-[11px] px-[var(--spacing-2)] py-[2px] rounded-[var(--radius-default)] bg-bg-secondary text-text-secondary",children:String(r)},a))}):e.jsxs("span",{className:"text-[13px] font-mono text-text-secondary",children:["[",t.length," items]"]}):typeof t=="object"?e.jsx("span",{className:"text-[13px] font-mono text-text-secondary",children:JSON.stringify(t)}):e.jsx("span",{className:"text-[13px] text-text-primary",children:String(t)})}function Ge({data:t}){const r=Object.entries(t).filter(([,a])=>typeof a!="object"||a===null);return r.length===0?null:e.jsxs("div",{children:[e.jsx(L,{title:"Properties"}),e.jsx("div",{className:"flex flex-col",children:r.map(([a,s])=>e.jsxs("div",{className:"grid grid-cols-[140px_1fr] gap-[var(--spacing-3)] py-[var(--spacing-1-5)] border-b border-border-divider last:border-b-0 items-start",children:[e.jsx("span",{className:"text-[11px] font-[var(--font-weight-semibold)] text-text-tertiary font-mono pt-[1px]",children:a}),e.jsx(oe,{value:s})]},a))})]})}function qe(t){if(typeof t!="object"||t===null)return!1;const r=t;return"severity"in r||"gap_id"in r||"type"in r}function Ue({data:t}){const r=String(t.gap_id||t.id||""),a=String(t.severity||"medium"),s=String(t.type||""),i=String(t.description||t.claim||""),o=String(t.suggested_fix||t.fix||""),c={critical:{bg:"rgba(196,101,85,0.20)",color:"var(--color-status-blocked)"},high:{bg:"rgba(200,134,58,0.20)",color:"var(--color-accent-orange, #C8863A)"},medium:{bg:"rgba(184,149,64,0.20)",color:"var(--color-accent-yellow)"},low:{bg:"rgba(91,141,184,0.20)",color:"var(--color-accent-blue)"}},n=c[a.toLowerCase()]||c.medium;return e.jsxs("div",{className:"p-[10px_14px] rounded-[10px] border-l-[3px] mb-[var(--spacing-1-5)]",style:{borderLeftColor:"var(--color-status-blocked)",background:"var(--color-status-bg-blocked)"},children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] mb-[var(--spacing-1)]",children:[r&&e.jsx("span",{className:"text-[10px] font-[var(--font-weight-bold)] font-mono",style:{color:"var(--color-status-blocked)"},children:r}),e.jsx("span",{className:"text-[9px] font-[var(--font-weight-bold)] px-[5px] py-[1px] rounded-[var(--radius-sm)] uppercase",style:{background:n.bg,color:n.color},children:a}),s&&e.jsx("span",{className:"text-[10px] text-text-tertiary ml-auto font-mono",children:s})]}),i&&e.jsx("p",{className:"text-[13px] text-text-primary mb-[var(--spacing-1)]",children:i}),o&&e.jsxs("p",{className:"text-[length:var(--font-size-sm)] text-text-secondary italic",children:[e.jsx("strong",{className:"font-[var(--font-weight-semibold)] not-italic text-text-tertiary text-[10px] uppercase",children:"Fix: "}),o]})]})}function Ye(t){if(typeof t!="object"||t===null)return!1;const r=t;return("claim"in r||"check"in r)&&!("severity"in r)}function Ze({data:t}){const r=String(t.claim||t.check||t.description||""),a=String(t.evidence||t.detail||""),s=t.passed===!0||t.status==="passed"||t.status==="completed";return e.jsxs("div",{className:"flex items-start gap-[var(--spacing-2)] p-[var(--spacing-2)_var(--spacing-3)] rounded-[var(--radius-md)] bg-bg-card border border-border-divider",children:[s?e.jsx($,{size:16,strokeWidth:2,className:"shrink-0 mt-[1px]",style:{color:"var(--color-status-completed)"}}):e.jsx(re,{size:16,strokeWidth:2,className:"shrink-0 mt-[1px] text-text-placeholder"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"text-[13px] text-text-primary font-[var(--font-weight-medium)]",children:r}),a&&e.jsx("p",{className:"text-[11px] text-text-tertiary mt-[2px] italic",children:a})]})]})}function le({content:t}){const r=d.useMemo(()=>{try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}},[t]);return e.jsx("pre",{className:["rounded-[10px] p-[16px_20px] font-mono text-[11px] leading-[1.6] overflow-x-auto","bg-[#2C2723] text-[#D9D0C4] border border-[#3D3731]"].join(" "),children:r})}const m=xe((t,r)=>({entries:[],byId:{},loading:!1,error:null,typeFilter:"all",tagFilter:"all",categoryFilter:"all",statusFilter:"all",search:"",selectedId:null,backlinksCache:{},health:null,graph:null,setTypeFilter:a=>t({typeFilter:a}),setTagFilter:a=>t({tagFilter:a}),setCategoryFilter:a=>t({categoryFilter:a}),setStatusFilter:a=>t({statusFilter:a}),setSearch:a=>t({search:a}),setSelected:a=>{t({selectedId:a}),a&&!r().backlinksCache[a]&&r().fetchBacklinks(a)},fetchEntries:async()=>{t({loading:!0,error:null});try{const{search:a}=r(),s=a?`${j.WIKI}?q=${encodeURIComponent(a)}`:j.WIKI,i=await fetch(s);if(!i.ok)throw new Error(`Failed: ${i.status}`);const c=(await i.json()).entries??[],n={};for(const l of c)n[l.id]=l;t({entries:c,byId:n,loading:!1})}catch(a){t({loading:!1,error:String(a)})}},fetchBacklinks:async a=>{try{const s=j.WIKI_BACKLINKS.replace(":id",encodeURIComponent(a)),i=await fetch(s);if(!i.ok)return;const o=await i.json();t(c=>({backlinksCache:{...c.backlinksCache,[a]:o.backlinks??[]}}))}catch{}},fetchHealth:async()=>{try{const a=await fetch(j.WIKI_HEALTH);if(!a.ok)return;const s=await a.json();t({health:s})}catch{}},fetchGraph:async()=>{try{const a=await fetch(j.WIKI_GRAPH);if(!a.ok)return;const s=await a.json();t({graph:s})}catch{}},createEntry:async a=>{const s=await fetch(j.WIKI,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(a)});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.error??`create failed: ${s.status}`)}const i=await s.json();return await r().fetchEntries(),i.entry},updateEntry:async(a,s)=>{const i=j.WIKI_DETAIL.replace(":id",encodeURIComponent(a)),o=await fetch(i,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify(s)});if(!o.ok){const n=await o.json().catch(()=>({}));throw new Error(n.error??`update failed: ${o.status}`)}const c=await o.json();return await r().fetchEntries(),c.entry},removeEntry:async a=>{const s=j.WIKI_DETAIL.replace(":id",encodeURIComponent(a)),i=await fetch(s,{method:"DELETE"});if(!i.ok){const o=await i.json().catch(()=>({}));throw new Error(o.error??`delete failed: ${i.status}`)}await r().fetchEntries()},filteredEntries:()=>{const{entries:a,typeFilter:s,tagFilter:i,categoryFilter:o,statusFilter:c}=r();return a.filter(n=>!(s!=="all"&&n.type!==s||i!=="all"&&!n.tags.includes(i)||o!=="all"&&n.category!==o||c!=="all"&&n.status!==c))},entriesByType:()=>{const a=r().filteredEntries(),s={project:[],roadmap:[],spec:[],issue:[],knowhow:[],note:[]};for(const i of a)s[i.type].push(i);return s},allTags:()=>{const a=new Set;for(const s of r().entries)for(const i of s.tags)a.add(i);return Array.from(a).sort()}})),Xe={project:"Project",roadmap:"Roadmap",spec:"Specs",issue:"Issues",knowhow:"KnowHow",note:"Notes"},G={project:"var(--color-accent-blue, #3b82f6)",roadmap:"var(--color-accent-purple, #8b5cf6)",spec:"var(--color-accent-green, #16a34a)",issue:"var(--color-accent-red, #dc2626)",knowhow:"var(--color-accent-cyan, #0891b2)",note:"var(--color-text-tertiary, #9ca3af)"},Qe=["project","roadmap","spec","issue","knowhow","note"];function et(t){return t.replace(/^#{1,6}\s+/,"").trim()}function tt(){const t=m(l=>l.entries),r=m(l=>l.typeFilter),a=m(l=>l.tagFilter),s=m(l=>l.categoryFilter),i=m(l=>l.statusFilter),o=m(l=>l.selectedId),c=m(l=>l.setSelected),n=d.useMemo(()=>{const l={project:[],roadmap:[],spec:[],issue:[],knowhow:[],note:[]};for(const x of t)r!=="all"&&x.type!==r||a!=="all"&&!x.tags.includes(a)||s!=="all"&&x.category!==s||i!=="all"&&x.status!==i||l[x.type].push(x);return l},[t,r,a,s,i]);return e.jsx("div",{className:"flex flex-col gap-1 py-1 overflow-y-auto h-full",children:Qe.map(l=>{const x=n[l];return!x||x.length===0?null:e.jsxs("section",{className:"px-2",children:[e.jsxs("h3",{className:"flex items-center gap-1.5 px-1 py-1.5 text-[10px] text-text-tertiary uppercase tracking-wider font-semibold",children:[e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full shrink-0",style:{backgroundColor:G[l]}}),Xe[l],e.jsx("span",{className:"text-text-quaternary font-normal ml-0.5",children:x.length})]}),e.jsx("ul",{className:"flex flex-col gap-px",children:x.map(p=>e.jsx(rt,{entry:p,typeColor:G[p.type],selected:p.id===o,onSelect:()=>c(p.id)},p.id))})]},l)})})}function rt({entry:t,typeColor:r,selected:a,onSelect:s}){return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:s,className:`w-full text-left rounded-[var(--radius-md,6px)] px-2.5 py-2 transition-all ${a?"bg-bg-secondary shadow-[inset_0_0_0_1px_var(--color-border-strong)]":"hover:bg-bg-secondary"}`,style:a?{borderLeft:`2px solid ${r}`,paddingLeft:"8px"}:void 0,children:e.jsxs("div",{className:"flex items-start gap-1.5",children:[!a&&e.jsx("span",{className:"inline-block w-[5px] h-[5px] rounded-full shrink-0 mt-[5px]",style:{backgroundColor:r,opacity:.6}}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-medium text-text-primary text-[length:var(--font-size-sm)] truncate leading-snug",children:t.title}),t.summary&&e.jsx("div",{className:"text-text-tertiary text-[11px] line-clamp-1 mt-0.5 leading-snug",children:et(t.summary)}),t.tags.length>0&&e.jsxs("div",{className:"mt-1 flex flex-wrap gap-1",children:[t.tags.slice(0,3).map(i=>e.jsx("span",{className:"px-1 py-px text-[10px] rounded bg-bg-tertiary text-text-tertiary leading-snug",children:i},i)),t.tags.length>3&&e.jsxs("span",{className:"text-[10px] text-text-quaternary",children:["+",t.tags.length-3]})]})]})]})})})}function st(t){const r=t.split(`
19
19
  `);let a=!1;const s=[];for(const i of r){if(/^```/.test(i.trim())){a=!a,s.push(i);continue}if(a){s.push(i);continue}s.push(i.replace(/\[\[([^\]]+)\]\]/g,(o,c)=>`[${c}](wiki:${c})`))}return s.join(`
20
20
  `)}function at(t){return t.replace(/^#{1,6}\s+/,"").trim()}function nt(){const t=m(n=>n.selectedId),r=m(n=>n.byId),a=m(n=>n.backlinksCache);m(n=>n.setSelected);const s=t?r[t]:void 0,i=t?a[t]??[]:[],o=d.useMemo(()=>{if(!s)return null;const n=[];if(s.summary&&(n.push(`> ${at(s.summary)}`),n.push("")),s.tags.length>0&&(n.push(s.tags.map(l=>`\`${l}\``).join(" ")),n.push("")),s.category&&(n.push(`**Category:** ${s.category}`),n.push("")),n.push("---"),n.push(""),s.body&&s.source.kind==="file"&&(n.push(st(s.body)),n.push("")),s.source.kind==="virtual"&&s.raw!==void 0&&(n.push("## Raw"),n.push("```json"),n.push(JSON.stringify(s.raw,null,2)),n.push("```"),n.push("")),Object.keys(s.ext).length>0&&(n.push("## Metadata"),n.push("```json"),n.push(JSON.stringify(s.ext,null,2)),n.push("```"),n.push("")),i.length>0){n.push(`## Backlinks (${i.length})`);for(const l of i)n.push(`- **${l.title}** _${l.type}_`);n.push("")}return n.join(`
21
- `)},[s,i]);if(!t)return e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-[length:var(--font-size-sm)]",children:"Select an entry"});if(!s)return e.jsx("div",{className:"p-4 text-text-tertiary text-[length:var(--font-size-sm)]",children:"Entry not found."});const c=s.source.path+(s.source.line!==void 0?`:${s.source.line}`:"");return e.jsx(ne,{content:o,path:c,onNavigate:()=>{},loading:!1,error:null,title:s.title,subtitle:`${s.type.toUpperCase()} · ${s.status.toUpperCase()}`})}function it(){const{health:t,fetchHealth:r,setSelected:a,byId:s}=m(Q(n=>({health:n.health,fetchHealth:n.fetchHealth,setSelected:n.setSelected,byId:n.byId}))),[i,o]=d.useState(!1);if(d.useEffect(()=>{r()},[r]),!t)return e.jsx("div",{className:"px-3 py-2 text-[length:var(--font-size-xs)] text-text-tertiary border-b border-border",children:"Loading health…"});const c=t.score>=80?"var(--color-accent-green, #16a34a)":t.score>=50?"var(--color-accent-yellow, #ca8a04)":"var(--color-accent-red, #dc2626)";return e.jsxs("div",{className:"border-b border-border",children:[e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-bg-secondary transition-colors",children:[e.jsx(ee,{size:12,strokeWidth:2,className:"text-text-tertiary transition-transform shrink-0",style:{transform:i?"rotate(90deg)":void 0}}),e.jsx(pe,{size:12,strokeWidth:2,className:"text-text-tertiary shrink-0"}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-secondary font-medium",children:"Health"}),e.jsx("span",{className:"text-[length:var(--font-size-sm)] font-semibold ml-auto",style:{color:c},children:t.score}),e.jsxs("div",{className:"flex gap-2 text-[length:var(--font-size-xs)] text-text-tertiary",children:[e.jsxs("span",{children:[t.totals.entries," entries"]}),t.totals.orphans>0&&e.jsxs("span",{children:["· ",t.totals.orphans," orphans"]}),t.totals.brokenLinks>0&&e.jsxs("span",{className:"text-accent-red",children:["· ",t.totals.brokenLinks," broken"]})]})]}),i&&e.jsxs("div",{className:"px-3 pb-2 flex flex-col gap-2 text-[length:var(--font-size-xs)]",children:[t.hubs.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"uppercase tracking-wider text-text-tertiary mb-1 text-[10px]",children:"Top hubs"}),e.jsx("ul",{className:"flex flex-col gap-0.5",children:t.hubs.slice(0,5).map(n=>{var l;return e.jsxs("li",{className:"flex justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>a(n.id),className:"truncate text-accent-blue hover:underline text-left",children:((l=s[n.id])==null?void 0:l.title)??n.id}),e.jsx("span",{className:"text-text-tertiary shrink-0",children:n.inDegree})]},n.id)})})]}),t.orphans.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"uppercase tracking-wider text-text-tertiary mb-1 text-[10px]",children:["Orphans (",t.orphans.length,")"]}),e.jsx("ul",{className:"flex flex-wrap gap-1 max-h-16 overflow-y-auto",children:t.orphans.slice(0,10).map(n=>{var l;return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>a(n),className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:text-accent-blue hover:underline transition-colors",children:((l=s[n])==null?void 0:l.title)??n})},n)})})]}),t.brokenLinks.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"uppercase tracking-wider text-text-tertiary mb-1 text-[10px]",children:["Broken (",t.brokenLinks.length,")"]}),e.jsx("ul",{className:"flex flex-col gap-0.5 max-h-16 overflow-y-auto text-text-secondary",children:t.brokenLinks.slice(0,5).map((n,l)=>e.jsxs("li",{className:"truncate",children:[e.jsx("span",{className:"text-text-tertiary",children:n.sourceId})," → ",e.jsx("span",{className:"line-through",children:n.target})]},`${n.sourceId}-${l}`))})]})]})]})}const ot={project:"var(--color-accent-blue, #3b82f6)",roadmap:"var(--color-accent-purple, #8b5cf6)",spec:"var(--color-accent-green, #16a34a)",issue:"var(--color-accent-red, #dc2626)",lesson:"var(--color-accent-yellow, #ca8a04)",knowhow:"var(--color-accent-cyan, #0891b2)",note:"var(--color-text-tertiary, #9ca3af)"};function lt(t){return t.replace(/^#{1,6}\s+/,"").trim()}function ct(){const t=m(l=>l.entries),r=m(l=>l.typeFilter),a=m(l=>l.tagFilter),s=m(l=>l.categoryFilter),i=m(l=>l.statusFilter),o=m(l=>l.setSelected),c=m(l=>l.selectedId),n=d.useMemo(()=>t.filter(l=>!(r!=="all"&&l.type!==r||a!=="all"&&!l.tags.includes(a)||s!=="all"&&l.category!==s||i!=="all"&&l.status!==i)),[t,r,a,s,i]);return n.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-[length:var(--font-size-sm)]",children:"No entries match the current filters"}):e.jsx("div",{className:"p-4 overflow-y-auto h-full",children:e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3",children:n.map(l=>e.jsx(dt,{entry:l,selected:l.id===c,onSelect:()=>o(l.id)},l.id))})})}function dt({entry:t,selected:r,onSelect:a}){const s=ot[t.type];return e.jsxs("button",{type:"button",onClick:a,className:`text-left rounded-[var(--radius-md,6px)] border p-3 transition-all flex flex-col gap-1.5 ${r?"border-border-strong bg-bg-secondary shadow-sm":"border-border bg-bg-primary hover:bg-bg-secondary hover:border-border-strong"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full shrink-0",style:{backgroundColor:s}}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-tertiary font-medium",children:t.type}),e.jsx("span",{className:"text-[10px] text-text-quaternary ml-auto",children:t.status})]}),e.jsx("div",{className:"font-medium text-text-primary text-[length:var(--font-size-sm)] leading-snug line-clamp-2",children:t.title}),t.summary&&e.jsx("div",{className:"text-text-tertiary text-[11px] line-clamp-2 leading-snug",children:lt(t.summary)}),t.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-0.5",children:[t.tags.slice(0,4).map(i=>e.jsx("span",{className:"px-1 py-px text-[10px] rounded bg-bg-tertiary text-text-tertiary",children:i},i)),t.tags.length>4&&e.jsxs("span",{className:"text-[10px] text-text-quaternary",children:["+",t.tags.length-4]})]}),e.jsx("div",{className:"text-[10px] text-text-quaternary font-mono truncate mt-auto pt-1",children:t.source.path})]})}const xt={project:"#3b82f6",roadmap:"#8b5cf6",spec:"#16a34a",issue:"#dc2626",lesson:"#ca8a04",knowhow:"#0891b2",note:"#9ca3af"};function pt(){const t=m(o=>o.fetchGraph),r=m(o=>o.graph),a=m(o=>o.byId),s=m(o=>o.setSelected);d.useEffect(()=>{t()},[t]);const i=d.useMemo(()=>{if(!r)return[];const o=new Map;for(const[c,n]of Object.entries(r.forwardLinks)){o.has(c)||o.set(c,{out:0,in:0}),o.get(c).out=n.length;for(const l of n)o.has(l)||o.set(l,{out:0,in:0}),o.get(l).in+=1}return Array.from(o.entries()).map(([c,n])=>{var l,x;return{id:c,title:((l=a[c])==null?void 0:l.title)??c,type:(x=a[c])==null?void 0:x.type,outDegree:n.out,inDegree:n.in,total:n.out+n.in}}).sort((c,n)=>n.total-c.total)},[r,a]);return r?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 border-b border-border text-[length:var(--font-size-xs)] text-text-secondary",children:[e.jsxs("span",{children:[i.length," connected nodes"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[Object.values(r.forwardLinks).reduce((o,c)=>o+c.length,0)," links"]}),r.brokenLinks.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{className:"text-accent-red",children:[r.brokenLinks.length," broken"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("table",{className:"w-full text-[length:var(--font-size-sm)]",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-primary z-10",children:e.jsxs("tr",{className:"border-b border-border text-[10px] uppercase tracking-wider text-text-tertiary",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Entry"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium w-16",children:"Type"}),e.jsx("th",{className:"text-center px-3 py-2 font-medium w-16",children:"Out"}),e.jsx("th",{className:"text-center px-3 py-2 font-medium w-16",children:"In"})]})}),e.jsx("tbody",{children:i.map(o=>e.jsxs("tr",{className:"border-b border-border hover:bg-bg-secondary transition-colors cursor-pointer",onClick:()=>s(o.id),children:[e.jsx("td",{className:"px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[o.type&&e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full shrink-0",style:{backgroundColor:xt[o.type]??"#9ca3af"}}),e.jsx("span",{className:"text-text-primary truncate",children:o.title})]})}),e.jsx("td",{className:"px-3 py-2 text-text-tertiary text-[length:var(--font-size-xs)]",children:o.type??"—"}),e.jsx("td",{className:"px-3 py-2 text-center",children:o.outDegree>0?e.jsx("span",{className:"text-accent-blue font-medium",children:o.outDegree}):e.jsx("span",{className:"text-text-quaternary",children:"0"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:o.inDegree>0?e.jsx("span",{className:"text-accent-green font-medium",children:o.inDegree}):e.jsx("span",{className:"text-text-quaternary",children:"0"})})]},o.id))})]}),r.brokenLinks.length>0&&e.jsxs("div",{className:"p-4 border-t border-border",children:[e.jsxs("h3",{className:"text-[10px] uppercase tracking-wider text-text-tertiary font-medium mb-2",children:["Broken Links (",r.brokenLinks.length,")"]}),e.jsx("ul",{className:"flex flex-col gap-1 text-[length:var(--font-size-xs)]",children:r.brokenLinks.map((o,c)=>{var n;return e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>s(o.sourceId),className:"text-accent-blue hover:underline truncate",children:((n=a[o.sourceId])==null?void 0:n.title)??o.sourceId}),e.jsx("span",{className:"text-text-quaternary",children:"→"}),e.jsx("span",{className:"text-text-tertiary line-through",children:o.target})]},`${o.sourceId}-${c}`)})})]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-[length:var(--font-size-sm)]",children:"Loading graph data…"})}const ut=[{label:"Reader",icon:e.jsx(C,{size:14,strokeWidth:2}),shortcut:"1"},{label:"Gallery",icon:e.jsx(Z,{size:14,strokeWidth:2}),shortcut:"2"},{label:"Structured",icon:e.jsx(me,{size:14,strokeWidth:2}),shortcut:"3"}],q=["reader","gallery","structured"],ft=[{label:"Reader",icon:e.jsx(he,{size:14,strokeWidth:2}),shortcut:"1"},{label:"Gallery",icon:e.jsx(Z,{size:14,strokeWidth:2}),shortcut:"2"},{label:"Graph",icon:e.jsx(we,{size:14,strokeWidth:2}),shortcut:"3"}],U=["reader","gallery","graph"],ht=[{value:"all",label:"All"},{value:"project",label:"Project"},{value:"roadmap",label:"Roadmap"},{value:"spec",label:"Specs"},{value:"issue",label:"Issues"},{value:"lesson",label:"Lessons"},{value:"knowhow",label:"KnowHow"},{value:"note",label:"Notes"}],k={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8}};function Ft(){const[t,r]=d.useState("files"),[a,s]=d.useState("reader"),[i,o]=d.useState("reader"),{tree:c,selectedPath:n,content:l,loading:x,treeLoading:p,error:u,selectFile:f}=Se(),{fetchEntries:g,loading:b,error:y,entries:S,search:E,setSearch:R,typeFilter:ce,setTypeFilter:de}=m(Q(h=>({fetchEntries:h.fetchEntries,loading:h.loading,error:h.error,entries:h.entries,search:h.search,setSearch:h.setSearch,typeFilter:h.typeFilter,setTypeFilter:h.setTypeFilter})));d.useEffect(()=>{t==="wiki"&&g()},[t,g]),d.useEffect(()=>{if(t!=="wiki")return;const h=setTimeout(()=>void g(),200);return()=>clearTimeout(h)},[E,g,t]);const{register:V,unregister:P}=d.useContext(ue),B=d.useCallback(h=>{t==="files"?s(q[h]):o(U[h])},[t]);return d.useEffect(()=>{const h=t==="files"?ut:ft,v=t==="files"?q.indexOf(a):U.indexOf(i);V({items:h.map(z=>({label:z.label,icon:z.icon,shortcut:z.shortcut})),activeIndex:v,onSwitch:B})},[t,a,i,V,B]),d.useEffect(()=>()=>P(),[P]),d.useEffect(()=>{function h(v){v.target instanceof HTMLInputElement||v.target instanceof HTMLTextAreaElement||(t==="files"?v.key==="1"?s("reader"):v.key==="2"?s("gallery"):v.key==="3"&&s("structured"):v.key==="1"?o("reader"):v.key==="2"?o("gallery"):v.key==="3"&&o("graph"))}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t]),e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{className:"w-[272px] shrink-0 border-r border-border overflow-hidden flex flex-col bg-bg-primary",children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-border shrink-0",children:[e.jsx(Y,{mode:"files",active:t==="files",icon:e.jsx(je,{size:13,strokeWidth:2}),label:"Files",onClick:()=>r("files")}),e.jsx(Y,{mode:"wiki",active:t==="wiki",icon:e.jsx(Ce,{size:13,strokeWidth:2}),label:"Wiki",onClick:()=>r("wiki")})]}),t==="files"?e.jsx(ge,{tree:c,selectedPath:n,onSelectFile:f,loading:p}):e.jsxs(e.Fragment,{children:[e.jsx(it,{}),e.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border",children:[e.jsxs("div",{className:"relative",children:[e.jsx(X,{size:13,strokeWidth:2,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-tertiary pointer-events-none"}),e.jsx("input",{type:"text",value:E,placeholder:"Search…",onChange:h=>R(h.target.value),className:"w-full pl-7 pr-7 py-1.5 bg-bg-secondary border border-border rounded-[var(--radius-md,6px)] text-[length:var(--font-size-sm)] text-text-primary placeholder:text-text-quaternary focus:outline-none focus:border-border-strong transition-colors"}),E&&e.jsx("button",{type:"button",onClick:()=>R(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-tertiary hover:text-text-secondary transition-colors",children:e.jsx(fe,{size:12,strokeWidth:2})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:ht.map(h=>e.jsx("button",{type:"button",onClick:()=>de(h.value),className:`px-2 py-0.5 rounded-[var(--radius-full,999px)] text-[10px] font-medium transition-all ${ce===h.value?"bg-text-primary text-bg-primary":"text-text-tertiary hover:text-text-secondary hover:bg-bg-secondary"}`,children:h.label},h.value))}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-text-quaternary",children:[e.jsxs("span",{children:[S.length," entr",S.length===1?"y":"ies"]}),b&&e.jsx("span",{className:"animate-pulse",children:"· loading…"}),y&&e.jsx("span",{className:"text-accent-red ml-1",children:y})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(tt,{})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden relative min-w-0",children:e.jsx(be,{mode:"wait",children:t==="files"?e.jsxs(e.Fragment,{children:[a==="reader"&&e.jsx(N.div,{className:"absolute inset-0 flex flex-col",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.25,ease:[.34,1.56,.64,1]},children:e.jsx(ne,{content:l,path:n,onNavigate:f,loading:x,error:u})},"file-reader"),a==="gallery"&&e.jsx(N.div,{className:"absolute inset-0 flex flex-col",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.25,ease:[.34,1.56,.64,1]},children:e.jsx(De,{tree:c,onSelectFile:f,selectedPath:n})},"file-gallery"),a==="structured"&&e.jsx(N.div,{className:"absolute inset-0 flex flex-col",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.25,ease:[.34,1.56,.64,1]},children:e.jsx(Ke,{content:l,path:n})},"file-structured")]}):e.jsxs(e.Fragment,{children:[i==="reader"&&e.jsx(N.div,{className:"absolute inset-0",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.2},children:e.jsx(nt,{})},"wiki-reader"),i==="gallery"&&e.jsx(N.div,{className:"absolute inset-0",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.2},children:e.jsx(ct,{})},"wiki-gallery"),i==="graph"&&e.jsx(N.div,{className:"absolute inset-0",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.2},children:e.jsx(pt,{})},"wiki-graph")]})})})]})}function Y({active:t,icon:r,label:a,onClick:s}){return e.jsxs("button",{type:"button",onClick:s,className:["flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 rounded-[var(--radius-md,6px)]","text-[length:var(--font-size-sm)] font-medium transition-all duration-150",t?"bg-bg-active text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary hover:bg-bg-hover"].join(" "),children:[r,e.jsx("span",{children:a})]})}export{Ft as ArtifactsPage};
21
+ `)},[s,i]);if(!t)return e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-[length:var(--font-size-sm)]",children:"Select an entry"});if(!s)return e.jsx("div",{className:"p-4 text-text-tertiary text-[length:var(--font-size-sm)]",children:"Entry not found."});const c=s.source.path+(s.source.line!==void 0?`:${s.source.line}`:"");return e.jsx(ne,{content:o,path:c,onNavigate:()=>{},loading:!1,error:null,title:s.title,subtitle:`${s.type.toUpperCase()} · ${s.status.toUpperCase()}`})}function it(){const{health:t,fetchHealth:r,setSelected:a,byId:s}=m(Q(n=>({health:n.health,fetchHealth:n.fetchHealth,setSelected:n.setSelected,byId:n.byId}))),[i,o]=d.useState(!1);if(d.useEffect(()=>{r()},[r]),!t)return e.jsx("div",{className:"px-3 py-2 text-[length:var(--font-size-xs)] text-text-tertiary border-b border-border",children:"Loading health…"});const c=t.score>=80?"var(--color-accent-green, #16a34a)":t.score>=50?"var(--color-accent-yellow, #ca8a04)":"var(--color-accent-red, #dc2626)";return e.jsxs("div",{className:"border-b border-border",children:[e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-bg-secondary transition-colors",children:[e.jsx(ee,{size:12,strokeWidth:2,className:"text-text-tertiary transition-transform shrink-0",style:{transform:i?"rotate(90deg)":void 0}}),e.jsx(pe,{size:12,strokeWidth:2,className:"text-text-tertiary shrink-0"}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-secondary font-medium",children:"Health"}),e.jsx("span",{className:"text-[length:var(--font-size-sm)] font-semibold ml-auto",style:{color:c},children:t.score}),e.jsxs("div",{className:"flex gap-2 text-[length:var(--font-size-xs)] text-text-tertiary",children:[e.jsxs("span",{children:[t.totals.entries," entries"]}),t.totals.orphans>0&&e.jsxs("span",{children:["· ",t.totals.orphans," orphans"]}),t.totals.brokenLinks>0&&e.jsxs("span",{className:"text-accent-red",children:["· ",t.totals.brokenLinks," broken"]})]})]}),i&&e.jsxs("div",{className:"px-3 pb-2 flex flex-col gap-2 text-[length:var(--font-size-xs)]",children:[t.hubs.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"uppercase tracking-wider text-text-tertiary mb-1 text-[10px]",children:"Top hubs"}),e.jsx("ul",{className:"flex flex-col gap-0.5",children:t.hubs.slice(0,5).map(n=>{var l;return e.jsxs("li",{className:"flex justify-between gap-2",children:[e.jsx("button",{type:"button",onClick:()=>a(n.id),className:"truncate text-accent-blue hover:underline text-left",children:((l=s[n.id])==null?void 0:l.title)??n.id}),e.jsx("span",{className:"text-text-tertiary shrink-0",children:n.inDegree})]},n.id)})})]}),t.orphans.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"uppercase tracking-wider text-text-tertiary mb-1 text-[10px]",children:["Orphans (",t.orphans.length,")"]}),e.jsx("ul",{className:"flex flex-wrap gap-1 max-h-16 overflow-y-auto",children:t.orphans.slice(0,10).map(n=>{var l;return e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>a(n),className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:text-accent-blue hover:underline transition-colors",children:((l=s[n])==null?void 0:l.title)??n})},n)})})]}),t.brokenLinks.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"uppercase tracking-wider text-text-tertiary mb-1 text-[10px]",children:["Broken (",t.brokenLinks.length,")"]}),e.jsx("ul",{className:"flex flex-col gap-0.5 max-h-16 overflow-y-auto text-text-secondary",children:t.brokenLinks.slice(0,5).map((n,l)=>e.jsxs("li",{className:"truncate",children:[e.jsx("span",{className:"text-text-tertiary",children:n.sourceId})," → ",e.jsx("span",{className:"line-through",children:n.target})]},`${n.sourceId}-${l}`))})]})]})]})}const ot={project:"var(--color-accent-blue, #3b82f6)",roadmap:"var(--color-accent-purple, #8b5cf6)",spec:"var(--color-accent-green, #16a34a)",issue:"var(--color-accent-red, #dc2626)",knowhow:"var(--color-accent-cyan, #0891b2)",note:"var(--color-text-tertiary, #9ca3af)"};function lt(t){return t.replace(/^#{1,6}\s+/,"").trim()}function ct(){const t=m(l=>l.entries),r=m(l=>l.typeFilter),a=m(l=>l.tagFilter),s=m(l=>l.categoryFilter),i=m(l=>l.statusFilter),o=m(l=>l.setSelected),c=m(l=>l.selectedId),n=d.useMemo(()=>t.filter(l=>!(r!=="all"&&l.type!==r||a!=="all"&&!l.tags.includes(a)||s!=="all"&&l.category!==s||i!=="all"&&l.status!==i)),[t,r,a,s,i]);return n.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-[length:var(--font-size-sm)]",children:"No entries match the current filters"}):e.jsx("div",{className:"p-4 overflow-y-auto h-full",children:e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(260px,1fr))] gap-3",children:n.map(l=>e.jsx(dt,{entry:l,selected:l.id===c,onSelect:()=>o(l.id)},l.id))})})}function dt({entry:t,selected:r,onSelect:a}){const s=ot[t.type];return e.jsxs("button",{type:"button",onClick:a,className:`text-left rounded-[var(--radius-md,6px)] border p-3 transition-all flex flex-col gap-1.5 ${r?"border-border-strong bg-bg-secondary shadow-sm":"border-border bg-bg-primary hover:bg-bg-secondary hover:border-border-strong"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full shrink-0",style:{backgroundColor:s}}),e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-tertiary font-medium",children:t.type}),e.jsx("span",{className:"text-[10px] text-text-quaternary ml-auto",children:t.status})]}),e.jsx("div",{className:"font-medium text-text-primary text-[length:var(--font-size-sm)] leading-snug line-clamp-2",children:t.title}),t.summary&&e.jsx("div",{className:"text-text-tertiary text-[11px] line-clamp-2 leading-snug",children:lt(t.summary)}),t.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-0.5",children:[t.tags.slice(0,4).map(i=>e.jsx("span",{className:"px-1 py-px text-[10px] rounded bg-bg-tertiary text-text-tertiary",children:i},i)),t.tags.length>4&&e.jsxs("span",{className:"text-[10px] text-text-quaternary",children:["+",t.tags.length-4]})]}),e.jsx("div",{className:"text-[10px] text-text-quaternary font-mono truncate mt-auto pt-1",children:t.source.path})]})}const xt={project:"#3b82f6",roadmap:"#8b5cf6",spec:"#16a34a",issue:"#dc2626",knowhow:"#0891b2",note:"#9ca3af"};function pt(){const t=m(o=>o.fetchGraph),r=m(o=>o.graph),a=m(o=>o.byId),s=m(o=>o.setSelected);d.useEffect(()=>{t()},[t]);const i=d.useMemo(()=>{if(!r)return[];const o=new Map;for(const[c,n]of Object.entries(r.forwardLinks)){o.has(c)||o.set(c,{out:0,in:0}),o.get(c).out=n.length;for(const l of n)o.has(l)||o.set(l,{out:0,in:0}),o.get(l).in+=1}return Array.from(o.entries()).map(([c,n])=>{var l,x;return{id:c,title:((l=a[c])==null?void 0:l.title)??c,type:(x=a[c])==null?void 0:x.type,outDegree:n.out,inDegree:n.in,total:n.out+n.in}}).sort((c,n)=>n.total-c.total)},[r,a]);return r?e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 border-b border-border text-[length:var(--font-size-xs)] text-text-secondary",children:[e.jsxs("span",{children:[i.length," connected nodes"]}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[Object.values(r.forwardLinks).reduce((o,c)=>o+c.length,0)," links"]}),r.brokenLinks.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{className:"text-accent-red",children:[r.brokenLinks.length," broken"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsxs("table",{className:"w-full text-[length:var(--font-size-sm)]",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-primary z-10",children:e.jsxs("tr",{className:"border-b border-border text-[10px] uppercase tracking-wider text-text-tertiary",children:[e.jsx("th",{className:"text-left px-4 py-2 font-medium",children:"Entry"}),e.jsx("th",{className:"text-left px-3 py-2 font-medium w-16",children:"Type"}),e.jsx("th",{className:"text-center px-3 py-2 font-medium w-16",children:"Out"}),e.jsx("th",{className:"text-center px-3 py-2 font-medium w-16",children:"In"})]})}),e.jsx("tbody",{children:i.map(o=>e.jsxs("tr",{className:"border-b border-border hover:bg-bg-secondary transition-colors cursor-pointer",onClick:()=>s(o.id),children:[e.jsx("td",{className:"px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[o.type&&e.jsx("span",{className:"inline-block w-[6px] h-[6px] rounded-full shrink-0",style:{backgroundColor:xt[o.type]??"#9ca3af"}}),e.jsx("span",{className:"text-text-primary truncate",children:o.title})]})}),e.jsx("td",{className:"px-3 py-2 text-text-tertiary text-[length:var(--font-size-xs)]",children:o.type??"—"}),e.jsx("td",{className:"px-3 py-2 text-center",children:o.outDegree>0?e.jsx("span",{className:"text-accent-blue font-medium",children:o.outDegree}):e.jsx("span",{className:"text-text-quaternary",children:"0"})}),e.jsx("td",{className:"px-3 py-2 text-center",children:o.inDegree>0?e.jsx("span",{className:"text-accent-green font-medium",children:o.inDegree}):e.jsx("span",{className:"text-text-quaternary",children:"0"})})]},o.id))})]}),r.brokenLinks.length>0&&e.jsxs("div",{className:"p-4 border-t border-border",children:[e.jsxs("h3",{className:"text-[10px] uppercase tracking-wider text-text-tertiary font-medium mb-2",children:["Broken Links (",r.brokenLinks.length,")"]}),e.jsx("ul",{className:"flex flex-col gap-1 text-[length:var(--font-size-xs)]",children:r.brokenLinks.map((o,c)=>{var n;return e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>s(o.sourceId),className:"text-accent-blue hover:underline truncate",children:((n=a[o.sourceId])==null?void 0:n.title)??o.sourceId}),e.jsx("span",{className:"text-text-quaternary",children:"→"}),e.jsx("span",{className:"text-text-tertiary line-through",children:o.target})]},`${o.sourceId}-${c}`)})})]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full text-text-tertiary text-[length:var(--font-size-sm)]",children:"Loading graph data…"})}const ut=[{label:"Reader",icon:e.jsx(C,{size:14,strokeWidth:2}),shortcut:"1"},{label:"Gallery",icon:e.jsx(Z,{size:14,strokeWidth:2}),shortcut:"2"},{label:"Structured",icon:e.jsx(me,{size:14,strokeWidth:2}),shortcut:"3"}],q=["reader","gallery","structured"],ft=[{label:"Reader",icon:e.jsx(he,{size:14,strokeWidth:2}),shortcut:"1"},{label:"Gallery",icon:e.jsx(Z,{size:14,strokeWidth:2}),shortcut:"2"},{label:"Graph",icon:e.jsx(we,{size:14,strokeWidth:2}),shortcut:"3"}],U=["reader","gallery","graph"],ht=[{value:"all",label:"All"},{value:"project",label:"Project"},{value:"roadmap",label:"Roadmap"},{value:"spec",label:"Specs"},{value:"issue",label:"Issues"},{value:"knowhow",label:"KnowHow"},{value:"note",label:"Notes"}],k={initial:{opacity:0,y:8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8}};function Ft(){const[t,r]=d.useState("files"),[a,s]=d.useState("reader"),[i,o]=d.useState("reader"),{tree:c,selectedPath:n,content:l,loading:x,treeLoading:p,error:u,selectFile:f}=Se(),{fetchEntries:g,loading:b,error:y,entries:S,search:E,setSearch:R,typeFilter:ce,setTypeFilter:de}=m(Q(h=>({fetchEntries:h.fetchEntries,loading:h.loading,error:h.error,entries:h.entries,search:h.search,setSearch:h.setSearch,typeFilter:h.typeFilter,setTypeFilter:h.setTypeFilter})));d.useEffect(()=>{t==="wiki"&&g()},[t,g]),d.useEffect(()=>{if(t!=="wiki")return;const h=setTimeout(()=>void g(),200);return()=>clearTimeout(h)},[E,g,t]);const{register:V,unregister:P}=d.useContext(ue),B=d.useCallback(h=>{t==="files"?s(q[h]):o(U[h])},[t]);return d.useEffect(()=>{const h=t==="files"?ut:ft,v=t==="files"?q.indexOf(a):U.indexOf(i);V({items:h.map(z=>({label:z.label,icon:z.icon,shortcut:z.shortcut})),activeIndex:v,onSwitch:B})},[t,a,i,V,B]),d.useEffect(()=>()=>P(),[P]),d.useEffect(()=>{function h(v){v.target instanceof HTMLInputElement||v.target instanceof HTMLTextAreaElement||(t==="files"?v.key==="1"?s("reader"):v.key==="2"?s("gallery"):v.key==="3"&&s("structured"):v.key==="1"?o("reader"):v.key==="2"?o("gallery"):v.key==="3"&&o("graph"))}return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t]),e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{className:"w-[272px] shrink-0 border-r border-border overflow-hidden flex flex-col bg-bg-primary",children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-2 border-b border-border shrink-0",children:[e.jsx(Y,{mode:"files",active:t==="files",icon:e.jsx(je,{size:13,strokeWidth:2}),label:"Files",onClick:()=>r("files")}),e.jsx(Y,{mode:"wiki",active:t==="wiki",icon:e.jsx(Ce,{size:13,strokeWidth:2}),label:"Wiki",onClick:()=>r("wiki")})]}),t==="files"?e.jsx(ge,{tree:c,selectedPath:n,onSelectFile:f,loading:p}):e.jsxs(e.Fragment,{children:[e.jsx(it,{}),e.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2 border-b border-border",children:[e.jsxs("div",{className:"relative",children:[e.jsx(X,{size:13,strokeWidth:2,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-tertiary pointer-events-none"}),e.jsx("input",{type:"text",value:E,placeholder:"Search…",onChange:h=>R(h.target.value),className:"w-full pl-7 pr-7 py-1.5 bg-bg-secondary border border-border rounded-[var(--radius-md,6px)] text-[length:var(--font-size-sm)] text-text-primary placeholder:text-text-quaternary focus:outline-none focus:border-border-strong transition-colors"}),E&&e.jsx("button",{type:"button",onClick:()=>R(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-tertiary hover:text-text-secondary transition-colors",children:e.jsx(fe,{size:12,strokeWidth:2})})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:ht.map(h=>e.jsx("button",{type:"button",onClick:()=>de(h.value),className:`px-2 py-0.5 rounded-[var(--radius-full,999px)] text-[10px] font-medium transition-all ${ce===h.value?"bg-text-primary text-bg-primary":"text-text-tertiary hover:text-text-secondary hover:bg-bg-secondary"}`,children:h.label},h.value))}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-text-quaternary",children:[e.jsxs("span",{children:[S.length," entr",S.length===1?"y":"ies"]}),b&&e.jsx("span",{className:"animate-pulse",children:"· loading…"}),y&&e.jsx("span",{className:"text-accent-red ml-1",children:y})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:e.jsx(tt,{})})]})]}),e.jsx("div",{className:"flex-1 overflow-hidden relative min-w-0",children:e.jsx(be,{mode:"wait",children:t==="files"?e.jsxs(e.Fragment,{children:[a==="reader"&&e.jsx(N.div,{className:"absolute inset-0 flex flex-col",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.25,ease:[.34,1.56,.64,1]},children:e.jsx(ne,{content:l,path:n,onNavigate:f,loading:x,error:u})},"file-reader"),a==="gallery"&&e.jsx(N.div,{className:"absolute inset-0 flex flex-col",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.25,ease:[.34,1.56,.64,1]},children:e.jsx(De,{tree:c,onSelectFile:f,selectedPath:n})},"file-gallery"),a==="structured"&&e.jsx(N.div,{className:"absolute inset-0 flex flex-col",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.25,ease:[.34,1.56,.64,1]},children:e.jsx(Ke,{content:l,path:n})},"file-structured")]}):e.jsxs(e.Fragment,{children:[i==="reader"&&e.jsx(N.div,{className:"absolute inset-0",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.2},children:e.jsx(nt,{})},"wiki-reader"),i==="gallery"&&e.jsx(N.div,{className:"absolute inset-0",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.2},children:e.jsx(ct,{})},"wiki-gallery"),i==="graph"&&e.jsx(N.div,{className:"absolute inset-0",variants:k,initial:"initial",animate:"animate",exit:"exit",transition:{duration:.2},children:e.jsx(pt,{})},"wiki-graph")]})})})]})}function Y({active:t,icon:r,label:a,onClick:s}){return e.jsxs("button",{type:"button",onClick:s,className:["flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 rounded-[var(--radius-md,6px)]","text-[length:var(--font-size-sm)] font-medium transition-all duration-150",t?"bg-bg-active text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary hover:bg-bg-hover"].join(" "),children:[r,e.jsx("span",{children:a})]})}export{Ft as ArtifactsPage};