@pennyfarthing/core 11.3.8 → 11.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/README.md +1 -1
  2. package/package.json +4 -1
  3. package/packages/core/dist/public/css/react.css +1 -1
  4. package/packages/core/dist/public/js/react/react.js +24 -24
  5. package/packages/core/src/public/App.tsx +356 -0
  6. package/packages/core/src/public/components/AgentLoadDialog.tsx +202 -0
  7. package/packages/core/src/public/components/AgentPopup.tsx +308 -0
  8. package/packages/core/src/public/components/ApprovalModal/ApprovalModal.css +35 -0
  9. package/packages/core/src/public/components/ApprovalModal/index.tsx +632 -0
  10. package/packages/core/src/public/components/BikeRackIndex.tsx +53 -0
  11. package/packages/core/src/public/components/BikeRackWorkspace.tsx +217 -0
  12. package/packages/core/src/public/components/CommandPalette.tsx +554 -0
  13. package/packages/core/src/public/components/ConfirmDialog.tsx +168 -0
  14. package/packages/core/src/public/components/ContextIndicator/ContextIndicator.css +85 -0
  15. package/packages/core/src/public/components/ContextIndicator/index.tsx +330 -0
  16. package/packages/core/src/public/components/ContextSparkline.tsx +56 -0
  17. package/packages/core/src/public/components/ControlBar.tsx +636 -0
  18. package/packages/core/src/public/components/DeadCodeDialog.tsx +169 -0
  19. package/packages/core/src/public/components/DiffViewer.tsx +585 -0
  20. package/packages/core/src/public/components/DockviewWorkspace.tsx +749 -0
  21. package/packages/core/src/public/components/Editor.tsx +630 -0
  22. package/packages/core/src/public/components/ErrorBoundary.tsx +67 -0
  23. package/packages/core/src/public/components/FileTree.tsx +379 -0
  24. package/packages/core/src/public/components/FontPicker/FontPicker.css +276 -0
  25. package/packages/core/src/public/components/FontPicker/index.tsx +430 -0
  26. package/packages/core/src/public/components/FullFileTree.tsx +237 -0
  27. package/packages/core/src/public/components/HealthGauge.tsx +181 -0
  28. package/packages/core/src/public/components/Message.tsx +225 -0
  29. package/packages/core/src/public/components/MessageList.tsx +98 -0
  30. package/packages/core/src/public/components/MessageView.tsx +400 -0
  31. package/packages/core/src/public/components/ModeSwitch/ModeSwitch.css +165 -0
  32. package/packages/core/src/public/components/ModeSwitch/index.tsx +372 -0
  33. package/packages/core/src/public/components/PersonaHeader.tsx +242 -0
  34. package/packages/core/src/public/components/ProjectInfoBar.tsx +45 -0
  35. package/packages/core/src/public/components/QuickActions.tsx +267 -0
  36. package/packages/core/src/public/components/SpanTimeline.tsx +352 -0
  37. package/packages/core/src/public/components/StandalonePanel.tsx +82 -0
  38. package/packages/core/src/public/components/StatsStrip.tsx +162 -0
  39. package/packages/core/src/public/components/StreamingContent.tsx +77 -0
  40. package/packages/core/src/public/components/SubagentSpan.tsx +180 -0
  41. package/packages/core/src/public/components/TandemPortrait.tsx +72 -0
  42. package/packages/core/src/public/components/ThemePalette/ThemePalette.css +179 -0
  43. package/packages/core/src/public/components/ThemePalette/index.tsx +326 -0
  44. package/packages/core/src/public/components/ToolCallBlock.tsx +252 -0
  45. package/packages/core/src/public/components/ToolStack.tsx +209 -0
  46. package/packages/core/src/public/components/ToolStatus.tsx +57 -0
  47. package/packages/core/src/public/components/dialogs/CodeMarkersDialog.tsx +169 -0
  48. package/packages/core/src/public/components/dialogs/ComplexityDialog.tsx +163 -0
  49. package/packages/core/src/public/components/dialogs/DependenciesDialog.tsx +120 -0
  50. package/packages/core/src/public/components/dialogs/HotspotsDialog.tsx +451 -0
  51. package/packages/core/src/public/components/dialogs/ToolDialog.tsx +43 -0
  52. package/packages/core/src/public/components/panel-registry.ts +13 -0
  53. package/packages/core/src/public/components/panels/ACPanel.tsx +93 -0
  54. package/packages/core/src/public/components/panels/AcceptanceCriteriaPanel.tsx +104 -0
  55. package/packages/core/src/public/components/panels/AuditLogPanel.tsx +489 -0
  56. package/packages/core/src/public/components/panels/BackgroundPanel.tsx +115 -0
  57. package/packages/core/src/public/components/panels/BikeLanePanel.tsx +214 -0
  58. package/packages/core/src/public/components/panels/DebugPanel.tsx +344 -0
  59. package/packages/core/src/public/components/panels/DiffView.tsx +109 -0
  60. package/packages/core/src/public/components/panels/DiffsPanel.tsx +56 -0
  61. package/packages/core/src/public/components/panels/GitPanel.tsx +260 -0
  62. package/packages/core/src/public/components/panels/HotspotsPanel.tsx +365 -0
  63. package/packages/core/src/public/components/panels/MessageFeed.tsx +39 -0
  64. package/packages/core/src/public/components/panels/MessagePanel.tsx +497 -0
  65. package/packages/core/src/public/components/panels/ProgressPanel.tsx +189 -0
  66. package/packages/core/src/public/components/panels/SettingsPanel.tsx +361 -0
  67. package/packages/core/src/public/components/panels/SprintPanel.tsx +723 -0
  68. package/packages/core/src/public/components/panels/TandemPanel.tsx +104 -0
  69. package/packages/core/src/public/components/panels/TaskTracker.tsx +48 -0
  70. package/packages/core/src/public/components/panels/TeamPanel.tsx +64 -0
  71. package/packages/core/src/public/components/panels/TeamRoster.tsx +67 -0
  72. package/packages/core/src/public/components/panels/TodoPanel.tsx +142 -0
  73. package/packages/core/src/public/components/panels/WorkflowPanel.tsx +224 -0
  74. package/packages/core/src/public/components/panels/index.ts +24 -0
  75. package/packages/core/src/public/components/ui/alert-dialog.tsx +139 -0
  76. package/packages/core/src/public/components/ui/badge.tsx +36 -0
  77. package/packages/core/src/public/components/ui/button.tsx +57 -0
  78. package/packages/core/src/public/components/ui/checkbox.tsx +28 -0
  79. package/packages/core/src/public/components/ui/collapsible.tsx +9 -0
  80. package/packages/core/src/public/components/ui/command.tsx +151 -0
  81. package/packages/core/src/public/components/ui/dialog.tsx +120 -0
  82. package/packages/core/src/public/components/ui/popover.tsx +31 -0
  83. package/packages/core/src/public/components/ui/progress.tsx +28 -0
  84. package/packages/core/src/public/components/ui/scroll-area.tsx +46 -0
  85. package/packages/core/src/public/components/ui/select.tsx +157 -0
  86. package/packages/core/src/public/components/ui/separator.tsx +29 -0
  87. package/packages/core/src/public/components/ui/skeleton.tsx +15 -0
  88. package/packages/core/src/public/components/ui/switch.tsx +27 -0
  89. package/packages/core/src/public/components/ui/toggle-group.tsx +59 -0
  90. package/packages/core/src/public/components/ui/toggle.tsx +43 -0
  91. package/packages/core/src/public/components/ui/tooltip.tsx +30 -0
  92. package/packages/core/src/public/contexts/ClaudeContext.tsx +311 -0
  93. package/packages/core/src/public/contexts/MessageQueueContext.tsx +143 -0
  94. package/packages/core/src/public/css/theme-browser.css +550 -0
  95. package/packages/core/src/public/css/theme-system.css +630 -0
  96. package/packages/core/src/public/hooks/index.ts +49 -0
  97. package/packages/core/src/public/hooks/useAgentLoad.ts +105 -0
  98. package/packages/core/src/public/hooks/useBackgroundTasks.ts +131 -0
  99. package/packages/core/src/public/hooks/useClaude.ts +234 -0
  100. package/packages/core/src/public/hooks/useCodeMarkers.ts +101 -0
  101. package/packages/core/src/public/hooks/useColorScheme.ts +42 -0
  102. package/packages/core/src/public/hooks/useCommandHistory.ts +99 -0
  103. package/packages/core/src/public/hooks/useComplexity.ts +80 -0
  104. package/packages/core/src/public/hooks/useDeadCode.ts +99 -0
  105. package/packages/core/src/public/hooks/useDependencies.ts +82 -0
  106. package/packages/core/src/public/hooks/useDiffs.ts +143 -0
  107. package/packages/core/src/public/hooks/useFileBrowser.ts +73 -0
  108. package/packages/core/src/public/hooks/useFocusPanel.ts +137 -0
  109. package/packages/core/src/public/hooks/useGitStatus.ts +233 -0
  110. package/packages/core/src/public/hooks/useHealthScore.ts +71 -0
  111. package/packages/core/src/public/hooks/useHotspots.ts +123 -0
  112. package/packages/core/src/public/hooks/useLayoutPersistence.ts +141 -0
  113. package/packages/core/src/public/hooks/useMarkdownParser.ts +36 -0
  114. package/packages/core/src/public/hooks/useMarkerActions.ts +234 -0
  115. package/packages/core/src/public/hooks/useMessageQueue.ts +380 -0
  116. package/packages/core/src/public/hooks/useMessageStream.ts +131 -0
  117. package/packages/core/src/public/hooks/usePersona.ts +112 -0
  118. package/packages/core/src/public/hooks/usePlanModeExit.ts +105 -0
  119. package/packages/core/src/public/hooks/useResponsiveLayout.ts +173 -0
  120. package/packages/core/src/public/hooks/useSprint.ts +157 -0
  121. package/packages/core/src/public/hooks/useStatsStrip.ts +204 -0
  122. package/packages/core/src/public/hooks/useStory.ts +135 -0
  123. package/packages/core/src/public/hooks/useSubagentHelper.ts +64 -0
  124. package/packages/core/src/public/hooks/useSyntaxHighlighter.ts +52 -0
  125. package/packages/core/src/public/hooks/useTabCompletion.ts +124 -0
  126. package/packages/core/src/public/hooks/useTandemObservations.ts +165 -0
  127. package/packages/core/src/public/hooks/useTeamMembers.ts +273 -0
  128. package/packages/core/src/public/hooks/useTodos.ts +93 -0
  129. package/packages/core/src/public/hooks/useUserAvatar.ts +54 -0
  130. package/packages/core/src/public/images/cyclist-dark.png +0 -0
  131. package/packages/core/src/public/images/cyclist-light.png +0 -0
  132. package/packages/core/src/public/index.html +14 -0
  133. package/packages/core/src/public/index.tsx +10 -0
  134. package/packages/core/src/public/lib/utils.ts +6 -0
  135. package/packages/core/src/public/styles/dockview-theme.css +376 -0
  136. package/packages/core/src/public/styles/tailwind.css +4454 -0
  137. package/packages/core/src/public/types/message.ts +51 -0
  138. package/packages/core/src/public/utils/avatar-service.ts +73 -0
  139. package/packages/core/src/public/utils/color-presets.ts +940 -0
  140. package/packages/core/src/public/utils/font-presets.ts +362 -0
  141. package/packages/core/src/public/utils/formatDuration.ts +14 -0
  142. package/packages/core/src/public/utils/markdown.ts +249 -0
  143. package/packages/core/src/public/utils/messageFilters.ts +128 -0
  144. package/packages/core/src/public/utils/slash-commands.ts +341 -0
  145. package/packages/core/src/public/utils/subagent-display.ts +146 -0
  146. package/packages/core/src/public/utils/syntax.ts +219 -0
  147. package/packages/core/src/public/utils/toolIntentSummarizer.ts +199 -0
  148. package/packages/core/src/public/utils/toolStackGrouper.ts +106 -0
  149. package/packages/core/src/public/utils/toolTypeColors.ts +45 -0
  150. package/pennyfarthing-dist/pf/__pycache__/__init__.cpython-314.pyc +0 -0
  151. package/pennyfarthing-dist/pf/__pycache__/cli.cpython-314.pyc +0 -0
  152. package/pennyfarthing-dist/pf/__pycache__/context.cpython-314.pyc +0 -0
  153. package/pennyfarthing-dist/pf/bc/__pycache__/__init__.cpython-314.pyc +0 -0
  154. package/pennyfarthing-dist/pf/bc/__pycache__/cli.cpython-314.pyc +0 -0
  155. package/pennyfarthing-dist/pf/bc/__pycache__/focus.cpython-314.pyc +0 -0
  156. package/pennyfarthing-dist/pf/bc/__pycache__/split.cpython-314.pyc +0 -0
  157. package/pennyfarthing-dist/pf/bc/cli.py +0 -1
  158. package/pennyfarthing-dist/pf/bc/focus.py +0 -1
  159. package/pennyfarthing-dist/pf/bikerack/__pycache__/__init__.cpython-314.pyc +0 -0
  160. package/pennyfarthing-dist/pf/bikerack/__pycache__/base_panel.cpython-314.pyc +0 -0
  161. package/pennyfarthing-dist/pf/bikerack/__pycache__/cli.cpython-314.pyc +0 -0
  162. package/pennyfarthing-dist/pf/bikerack/__pycache__/git_panel.cpython-314.pyc +0 -0
  163. package/pennyfarthing-dist/pf/bikerack/__pycache__/launcher.cpython-314.pyc +0 -0
  164. package/pennyfarthing-dist/pf/bikerack/__pycache__/portrait_resolver.cpython-314.pyc +0 -0
  165. package/pennyfarthing-dist/pf/bikerack/__pycache__/sprint_panel.cpython-314.pyc +0 -0
  166. package/pennyfarthing-dist/pf/bikerack/__pycache__/story_detail_data.cpython-314.pyc +0 -0
  167. package/pennyfarthing-dist/pf/bikerack/__pycache__/story_detail_screen.cpython-314.pyc +0 -0
  168. package/pennyfarthing-dist/pf/bikerack/__pycache__/tui.cpython-314.pyc +0 -0
  169. package/pennyfarthing-dist/pf/bikerack/base_panel.py +0 -1
  170. package/pennyfarthing-dist/pf/bikerack/events.py +1 -7
  171. package/pennyfarthing-dist/pf/bikerack/git_panel.py +273 -10
  172. package/pennyfarthing-dist/pf/bikerack/portrait_resolver.py +21 -0
  173. package/pennyfarthing-dist/pf/bikerack/sprint_panel.py +58 -1
  174. package/pennyfarthing-dist/pf/bikerack/tui.py +5 -20
  175. package/pennyfarthing-dist/pf/bmad/__pycache__/__init__.cpython-314.pyc +0 -0
  176. package/pennyfarthing-dist/pf/bmad/__pycache__/cli.cpython-314.pyc +0 -0
  177. package/pennyfarthing-dist/pf/bmad/__pycache__/parser.cpython-314.pyc +0 -0
  178. package/pennyfarthing-dist/pf/bmad/parser.py +15 -9
  179. package/pennyfarthing-dist/pf/codemarkers/__pycache__/__init__.cpython-314.pyc +0 -0
  180. package/pennyfarthing-dist/pf/codemarkers/__pycache__/analyze.cpython-314.pyc +0 -0
  181. package/pennyfarthing-dist/pf/codemarkers/__pycache__/models.cpython-314.pyc +0 -0
  182. package/pennyfarthing-dist/pf/common/__pycache__/__init__.cpython-314.pyc +0 -0
  183. package/pennyfarthing-dist/pf/common/__pycache__/config.cpython-314.pyc +0 -0
  184. package/pennyfarthing-dist/pf/common/__pycache__/output.cpython-314.pyc +0 -0
  185. package/pennyfarthing-dist/pf/common/__pycache__/pr_config.cpython-314.pyc +0 -0
  186. package/pennyfarthing-dist/pf/common/__pycache__/themes.cpython-314.pyc +0 -0
  187. package/pennyfarthing-dist/pf/common/pr_config.py +27 -2
  188. package/pennyfarthing-dist/pf/complexity/__pycache__/__init__.cpython-314.pyc +0 -0
  189. package/pennyfarthing-dist/pf/complexity/__pycache__/analyze.cpython-314.pyc +0 -0
  190. package/pennyfarthing-dist/pf/complexity/__pycache__/models.cpython-314.pyc +0 -0
  191. package/pennyfarthing-dist/pf/consultation/__pycache__/__init__.cpython-314.pyc +0 -0
  192. package/pennyfarthing-dist/pf/consultation/__pycache__/cli.cpython-314.pyc +0 -0
  193. package/pennyfarthing-dist/pf/deadcode/__pycache__/__init__.cpython-314.pyc +0 -0
  194. package/pennyfarthing-dist/pf/deadcode/__pycache__/analyze.cpython-314.pyc +0 -0
  195. package/pennyfarthing-dist/pf/deadcode/__pycache__/cli.cpython-314.pyc +0 -0
  196. package/pennyfarthing-dist/pf/deadcode/__pycache__/models.cpython-314.pyc +0 -0
  197. package/pennyfarthing-dist/pf/dependencies/__pycache__/__init__.cpython-314.pyc +0 -0
  198. package/pennyfarthing-dist/pf/dependencies/__pycache__/analyze.cpython-314.pyc +0 -0
  199. package/pennyfarthing-dist/pf/dependencies/__pycache__/models.cpython-314.pyc +0 -0
  200. package/pennyfarthing-dist/pf/epic/__pycache__/__init__.cpython-314.pyc +0 -0
  201. package/pennyfarthing-dist/pf/epic/__pycache__/cli.cpython-314.pyc +0 -0
  202. package/pennyfarthing-dist/pf/git_group/__pycache__/__init__.cpython-314.pyc +0 -0
  203. package/pennyfarthing-dist/pf/git_group/__pycache__/cli.cpython-314.pyc +0 -0
  204. package/pennyfarthing-dist/pf/handoff/__pycache__/__init__.cpython-314.pyc +0 -0
  205. package/pennyfarthing-dist/pf/handoff/__pycache__/cli.cpython-314.pyc +0 -0
  206. package/pennyfarthing-dist/pf/handoff/__pycache__/complete_phase.cpython-314.pyc +0 -0
  207. package/pennyfarthing-dist/pf/handoff/__pycache__/marker.cpython-314.pyc +0 -0
  208. package/pennyfarthing-dist/pf/handoff/__pycache__/phase_check.cpython-314.pyc +0 -0
  209. package/pennyfarthing-dist/pf/handoff/__pycache__/resolve_gate.cpython-314.pyc +0 -0
  210. package/pennyfarthing-dist/pf/healthscore/__pycache__/__init__.cpython-314.pyc +0 -0
  211. package/pennyfarthing-dist/pf/healthscore/__pycache__/__main__.cpython-314.pyc +0 -0
  212. package/pennyfarthing-dist/pf/healthscore/__pycache__/analyze.cpython-314.pyc +0 -0
  213. package/pennyfarthing-dist/pf/healthscore/__pycache__/cli.cpython-314.pyc +0 -0
  214. package/pennyfarthing-dist/pf/healthscore/__pycache__/formatters.cpython-314.pyc +0 -0
  215. package/pennyfarthing-dist/pf/healthscore/__pycache__/models.cpython-314.pyc +0 -0
  216. package/pennyfarthing-dist/pf/hooks/__pycache__/__init__.cpython-314.pyc +0 -0
  217. package/pennyfarthing-dist/pf/hooks/__pycache__/bell_mode.cpython-314.pyc +0 -0
  218. package/pennyfarthing-dist/pf/hooks/__pycache__/cli.cpython-314.pyc +0 -0
  219. package/pennyfarthing-dist/pf/hooks/__pycache__/context_breaker.cpython-314.pyc +0 -0
  220. package/pennyfarthing-dist/pf/hooks/__pycache__/context_warning.cpython-314.pyc +0 -0
  221. package/pennyfarthing-dist/pf/hooks/__pycache__/cyclist_pretooluse.cpython-314.pyc +0 -0
  222. package/pennyfarthing-dist/pf/hooks/__pycache__/pre_edit_check.cpython-314.pyc +0 -0
  223. package/pennyfarthing-dist/pf/hooks/__pycache__/reflector_check.cpython-314.pyc +0 -0
  224. package/pennyfarthing-dist/pf/hooks/__pycache__/schema_validation.cpython-314.pyc +0 -0
  225. package/pennyfarthing-dist/pf/hooks/__pycache__/session_start.cpython-314.pyc +0 -0
  226. package/pennyfarthing-dist/pf/hooks/__pycache__/session_stop.cpython-314.pyc +0 -0
  227. package/pennyfarthing-dist/pf/hooks/__pycache__/sprint_yaml_validation.cpython-314.pyc +0 -0
  228. package/pennyfarthing-dist/pf/hooks/__pycache__/statusline.cpython-314.pyc +0 -0
  229. package/pennyfarthing-dist/pf/hotspots/__pycache__/__init__.cpython-314.pyc +0 -0
  230. package/pennyfarthing-dist/pf/hotspots/__pycache__/analyze.cpython-314.pyc +0 -0
  231. package/pennyfarthing-dist/pf/hotspots/__pycache__/cli.cpython-314.pyc +0 -0
  232. package/pennyfarthing-dist/pf/hotspots/__pycache__/models.cpython-314.pyc +0 -0
  233. package/pennyfarthing-dist/pf/jira/__pycache__/__init__.cpython-314.pyc +0 -0
  234. package/pennyfarthing-dist/pf/jira/__pycache__/bidirectional.cpython-314.pyc +0 -0
  235. package/pennyfarthing-dist/pf/jira/__pycache__/claim.cpython-314.pyc +0 -0
  236. package/pennyfarthing-dist/pf/jira/__pycache__/cli.cpython-314.pyc +0 -0
  237. package/pennyfarthing-dist/pf/jira/__pycache__/client.cpython-314.pyc +0 -0
  238. package/pennyfarthing-dist/pf/jira/__pycache__/create.cpython-314.pyc +0 -0
  239. package/pennyfarthing-dist/pf/jira/__pycache__/epic.cpython-314.pyc +0 -0
  240. package/pennyfarthing-dist/pf/jira/__pycache__/operations.cpython-314.pyc +0 -0
  241. package/pennyfarthing-dist/pf/jira/__pycache__/reconcile.cpython-314.pyc +0 -0
  242. package/pennyfarthing-dist/pf/jira/__pycache__/story.cpython-314.pyc +0 -0
  243. package/pennyfarthing-dist/pf/jira/__pycache__/sync.cpython-314.pyc +0 -0
  244. package/pennyfarthing-dist/pf/launch/__pycache__/__init__.cpython-314.pyc +0 -0
  245. package/pennyfarthing-dist/pf/launch/__pycache__/cli.cpython-314.pyc +0 -0
  246. package/pennyfarthing-dist/pf/prime/__pycache__/__init__.cpython-314.pyc +0 -0
  247. package/pennyfarthing-dist/pf/prime/__pycache__/cli.cpython-314.pyc +0 -0
  248. package/pennyfarthing-dist/pf/prime/__pycache__/loader.cpython-314.pyc +0 -0
  249. package/pennyfarthing-dist/pf/prime/__pycache__/models.cpython-314.pyc +0 -0
  250. package/pennyfarthing-dist/pf/prime/__pycache__/persona.cpython-314.pyc +0 -0
  251. package/pennyfarthing-dist/pf/prime/__pycache__/session.cpython-314.pyc +0 -0
  252. package/pennyfarthing-dist/pf/prime/__pycache__/tiers.cpython-314.pyc +0 -0
  253. package/pennyfarthing-dist/pf/prime/__pycache__/workflow.cpython-314.pyc +0 -0
  254. package/pennyfarthing-dist/pf/session/__pycache__/__init__.cpython-314.pyc +0 -0
  255. package/pennyfarthing-dist/pf/session/__pycache__/cli.cpython-314.pyc +0 -0
  256. package/pennyfarthing-dist/pf/settings/__pycache__/__init__.cpython-314.pyc +0 -0
  257. package/pennyfarthing-dist/pf/settings/__pycache__/cli.cpython-314.pyc +0 -0
  258. package/pennyfarthing-dist/pf/settings/__pycache__/settings.cpython-314.pyc +0 -0
  259. package/pennyfarthing-dist/pf/settings/settings.py +44 -8
  260. package/pennyfarthing-dist/pf/sprint/__pycache__/__init__.cpython-314.pyc +0 -0
  261. package/pennyfarthing-dist/pf/sprint/__pycache__/archive.cpython-314.pyc +0 -0
  262. package/pennyfarthing-dist/pf/sprint/__pycache__/archive_epic.cpython-314.pyc +0 -0
  263. package/pennyfarthing-dist/pf/sprint/__pycache__/cli.cpython-314.pyc +0 -0
  264. package/pennyfarthing-dist/pf/sprint/__pycache__/epic_add.cpython-314.pyc +0 -0
  265. package/pennyfarthing-dist/pf/sprint/__pycache__/epic_update.cpython-314.pyc +0 -0
  266. package/pennyfarthing-dist/pf/sprint/__pycache__/loader.cpython-314.pyc +0 -0
  267. package/pennyfarthing-dist/pf/sprint/__pycache__/status.cpython-314.pyc +0 -0
  268. package/pennyfarthing-dist/pf/sprint/__pycache__/story_add.cpython-314.pyc +0 -0
  269. package/pennyfarthing-dist/pf/sprint/__pycache__/story_finish.cpython-314.pyc +0 -0
  270. package/pennyfarthing-dist/pf/sprint/__pycache__/story_update.cpython-314.pyc +0 -0
  271. package/pennyfarthing-dist/pf/sprint/__pycache__/validate_cmd.cpython-314.pyc +0 -0
  272. package/pennyfarthing-dist/pf/sprint/__pycache__/validator.cpython-314.pyc +0 -0
  273. package/pennyfarthing-dist/pf/sprint/__pycache__/work.cpython-314.pyc +0 -0
  274. package/pennyfarthing-dist/pf/sprint/__pycache__/yaml_io.cpython-314.pyc +0 -0
  275. package/pennyfarthing-dist/pf/sprint/story_finish.py +14 -2
  276. package/pennyfarthing-dist/pf/sprint/validator.py +7 -7
  277. package/pennyfarthing-dist/pf/tests/__pycache__/__init__.cpython-314.pyc +0 -0
  278. package/pennyfarthing-dist/pf/tests/__pycache__/conftest.cpython-314-pytest-9.0.2.pyc +0 -0
  279. package/pennyfarthing-dist/pf/tests/__pycache__/test_sprint_validator.cpython-314-pytest-9.0.2.pyc +0 -0
  280. package/pennyfarthing-dist/pf/tests/test_sprint_validator.py +44 -0
  281. package/pennyfarthing-dist/pf/theme/__pycache__/__init__.cpython-314.pyc +0 -0
  282. package/pennyfarthing-dist/pf/theme/__pycache__/cli.cpython-314.pyc +0 -0
  283. package/pennyfarthing-dist/pf/validate/__pycache__/__init__.cpython-314.pyc +0 -0
  284. package/pennyfarthing-dist/pf/validate/__pycache__/cli.cpython-314.pyc +0 -0
  285. package/pennyfarthing-dist/pf/workflow/__pycache__/__init__.cpython-314.pyc +0 -0
  286. package/pennyfarthing-dist/pf/workflow/__pycache__/cli.cpython-314.pyc +0 -0
  287. package/pennyfarthing-dist/pf/workflow/__pycache__/helpers.cpython-314.pyc +0 -0
  288. package/pennyfarthing-dist/pf/workflow/__pycache__/scale.cpython-314.pyc +0 -0
  289. package/pennyfarthing-dist/pf/workflow/__pycache__/state.cpython-314.pyc +0 -0
  290. package/pennyfarthing-dist/scripts/lib/find-root.sh +1 -1
  291. package/pennyfarthing-dist/scripts/misc/migrate_bmad_workflow.py +0 -1
  292. package/pennyfarthing-dist/scripts/portraits/generate-portraits.py +13 -13
  293. package/pennyfarthing-dist/scripts/workflow/check.py +4 -6
  294. package/pennyfarthing-dist/scripts/workflow/complete-step.py +2 -2
  295. package/pennyfarthing-dist/skills/skill-registry.yaml +19 -0
  296. package/pennyfarthing-dist/workflows/tdd-tandem.yaml +15 -2
  297. package/packages/core/dist/workflow/__test_context_watch__/.session/.tandem-turn-counter +0 -1
  298. package/packages/core/dist/workflow/__test_context_watch__/.session/95-6-session.md +0 -3
  299. package/packages/core/dist/workflow/__test_context_watch__/.session/95-6-tandem-architect.md +0 -6
  300. package/packages/core/dist/workflow/__test_file_watch__/.session/95-4-tandem-architect.md +0 -6
  301. package/packages/core/dist/workflow/__test_file_watch__/workdir/trigger.ts +0 -1
  302. package/packages/core/dist/workflow/__test_tool_watch__/.session/95-5-tandem-architect.md +0 -6
  303. package/packages/core/dist/workflow/__test_tool_watch__/.session/95-5-tandem-toolcalls.jsonl +0 -1
  304. package/pennyfarthing-dist/pf/bikerack/changed_panel.py +0 -201
@@ -0,0 +1,209 @@
1
+ /**
2
+ * ToolStack Component
3
+ *
4
+ * Collapsible container for consecutive tool use groups.
5
+ * Story MSSCI-13400 - Tool use stack between messages
6
+ */
7
+
8
+ import React, { useState, useCallback, useEffect, useRef, useMemo } from 'react';
9
+ import { Badge } from '@/components/ui/badge';
10
+ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
11
+ import ToolCallBlock, { getToolBadgeLabel } from './ToolCallBlock';
12
+ import type { ToolStackData } from '../utils/toolStackGrouper';
13
+ import { generateToolIntentSummary } from '../utils/toolIntentSummarizer';
14
+ import { formatDuration } from '../utils/formatDuration';
15
+
16
+ interface ToolResultMessage {
17
+ type: 'tool_result';
18
+ tool_id: string;
19
+ content: string;
20
+ timestamp: number;
21
+ durationMs?: number;
22
+ }
23
+
24
+ interface ToolStackProps {
25
+ stack: ToolStackData;
26
+ toolResults: Map<string, ToolResultMessage>;
27
+ }
28
+
29
+ export default function ToolStack({ stack, toolResults }: ToolStackProps): React.ReactElement {
30
+ // AC4: Expand automatically when stack has active (pending) tool
31
+ const [isCollapsed, setIsCollapsed] = useState(!stack.isActive);
32
+
33
+ // Track previous isActive to detect transitions
34
+ const prevIsActiveRef = useRef(stack.isActive);
35
+
36
+ // When stack transitions from active to inactive, keep it expanded
37
+ // This ensures completed tools remain visible for user review
38
+ useEffect(() => {
39
+ if (prevIsActiveRef.current && !stack.isActive) {
40
+ // Stack just completed - keep expanded for review
41
+ setIsCollapsed(false);
42
+ }
43
+ prevIsActiveRef.current = stack.isActive;
44
+ }, [stack.isActive]);
45
+
46
+ // Count display - just the number
47
+ const countText = `${stack.count}`;
48
+
49
+ // Active tool summary - show what's happening RIGHT NOW
50
+ const activeSummary = useMemo(() => {
51
+ if (stack.isActive && stack.tools.length > 0) {
52
+ // Show the most recent (last) tool's summary
53
+ const lastTool = stack.tools[stack.tools.length - 1];
54
+ return generateToolIntentSummary(lastTool.tool_name, lastTool.input);
55
+ }
56
+ return null;
57
+ }, [stack.tools, stack.isActive]);
58
+
59
+ // Generate summary of tool intents for collapsed view
60
+ const collapsedSummary = useMemo(() => {
61
+ // Show last tool's summary as the main description
62
+ if (stack.tools.length === 0) return '';
63
+ const lastTool = stack.tools[stack.tools.length - 1];
64
+ return generateToolIntentSummary(lastTool.tool_name, lastTool.input);
65
+ }, [stack.tools]);
66
+
67
+ // Compute tool type counts for mini badges
68
+ const toolTypeCounts = useMemo(() => {
69
+ const counts = new Map<string, number>();
70
+ stack.tools.forEach(tool => {
71
+ const count = counts.get(tool.tool_name) || 0;
72
+ counts.set(tool.tool_name, count + 1);
73
+ });
74
+ return counts;
75
+ }, [stack.tools]);
76
+
77
+ // Total duration across all tools in stack
78
+ const totalDuration = useMemo(() => {
79
+ return stack.tools.reduce((sum, tool) => {
80
+ const result = toolResults.get(tool.tool_id);
81
+ return sum + (result?.durationMs || 0);
82
+ }, 0);
83
+ }, [stack.tools, toolResults]);
84
+
85
+ // AC4: Determine which tool is current (pending)
86
+ const getToolClass = (toolIndex: number): string => {
87
+ const tool = stack.tools[toolIndex];
88
+ const result = toolResults.get(tool.tool_id);
89
+
90
+ // If stack is active, last tool without result is current
91
+ if (stack.isActive) {
92
+ const isLastTool = toolIndex === stack.tools.length - 1;
93
+ const hasPendingResult = !result;
94
+
95
+ if (isLastTool && hasPendingResult) {
96
+ return 'tool-current';
97
+ }
98
+ return 'tool-historical';
99
+ }
100
+
101
+ // If stack is not active, all tools are historical
102
+ return 'tool-historical';
103
+ };
104
+
105
+ // Toggle collapse state
106
+ const handleToggle = useCallback(() => {
107
+ setIsCollapsed(prev => !prev);
108
+ }, []);
109
+
110
+ // Keyboard navigation
111
+ const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
112
+ if (e.key === 'Enter' || e.key === ' ') {
113
+ e.preventDefault();
114
+ handleToggle();
115
+ }
116
+ }, [handleToggle]);
117
+
118
+ // AC4: When active and user tries to collapse, still show current tool
119
+ const shouldShowTools = !isCollapsed || stack.isActive;
120
+
121
+ return (
122
+ <div
123
+ data-testid="tool-stack"
124
+ data-collapsible="true"
125
+ className={`tool-stack ${isCollapsed && !stack.isActive ? 'collapsed' : ''}`}
126
+ >
127
+ <div
128
+ data-testid="tool-stack-header"
129
+ className="tool-stack-header"
130
+ onClick={handleToggle}
131
+ onKeyDown={handleKeyDown}
132
+ role="button"
133
+ tabIndex={0}
134
+ aria-expanded={!isCollapsed || stack.isActive}
135
+ aria-label={`Tool stack with ${countText}: ${collapsedSummary}`}
136
+ >
137
+ <span className="tool-stack-toggle">
138
+ {isCollapsed && !stack.isActive ? '▶' : '▼'}
139
+ </span>
140
+ <span
141
+ data-testid="tool-stack-count"
142
+ className="tool-stack-count-badge"
143
+ >
144
+ {countText}
145
+ </span>
146
+ {stack.isActive && activeSummary ? (
147
+ <span className="tool-stack-active-summary">
148
+ {activeSummary}
149
+ </span>
150
+ ) : (
151
+ <>
152
+ <span className="tool-stack-badges">
153
+ <TooltipProvider delayDuration={300}>
154
+ {Array.from(toolTypeCounts.entries()).slice(0, 4).map(([type, count]) => (
155
+ <Tooltip key={type}>
156
+ <TooltipTrigger asChild>
157
+ <Badge
158
+ variant="outline"
159
+ className={`tool-mini-badge badge-${type.toLowerCase()}`}
160
+ >
161
+ {getToolBadgeLabel(type)}
162
+ </Badge>
163
+ </TooltipTrigger>
164
+ <TooltipContent>{`${count} ${type} call${count > 1 ? 's' : ''}`}</TooltipContent>
165
+ </Tooltip>
166
+ ))}
167
+ </TooltipProvider>
168
+ </span>
169
+ <span className="tool-stack-summary">
170
+ {collapsedSummary}
171
+ </span>
172
+ </>
173
+ )}
174
+ <span className="tool-stack-duration">
175
+ {totalDuration > 0 ? formatDuration(totalDuration) : ''}
176
+ </span>
177
+ </div>
178
+
179
+ {shouldShowTools && (
180
+ <div className="tool-stack-content">
181
+ {stack.tools.map((tool, index) => {
182
+ const result = toolResults.get(tool.tool_id);
183
+ const toolClass = getToolClass(index);
184
+
185
+ return (
186
+ <ToolCallBlock
187
+ key={tool.tool_id || `tool-${index}`}
188
+ toolUse={{
189
+ type: 'tool_use',
190
+ tool_name: tool.tool_name,
191
+ tool_id: tool.tool_id,
192
+ input: tool.input,
193
+ timestamp: tool.timestamp,
194
+ }}
195
+ result={result ? {
196
+ type: 'tool_result',
197
+ tool_id: result.tool_id,
198
+ content: result.content,
199
+ timestamp: result.timestamp,
200
+ } : undefined}
201
+ className={toolClass}
202
+ />
203
+ );
204
+ })}
205
+ </div>
206
+ )}
207
+ </div>
208
+ );
209
+ }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * ToolStatus Component
3
+ *
4
+ * Displays status indicator for tool execution state.
5
+ * Story MSSCI-13402 - Tool use visual design polish
6
+ */
7
+
8
+ import React from 'react';
9
+
10
+ export type ToolStatusType = 'pending' | 'success' | 'error';
11
+
12
+ export interface ToolStatusProps {
13
+ status: ToolStatusType;
14
+ }
15
+
16
+ /**
17
+ * Status indicator component showing pending/success/error state
18
+ */
19
+ export function ToolStatus({ status }: ToolStatusProps): React.ReactElement {
20
+ const getAriaLabel = (): string => {
21
+ switch (status) {
22
+ case 'pending':
23
+ return 'Tool running';
24
+ case 'success':
25
+ return 'Tool completed successfully';
26
+ case 'error':
27
+ return 'Tool failed with error';
28
+ default:
29
+ return 'Tool status unknown';
30
+ }
31
+ };
32
+
33
+ const getContent = (): React.ReactNode => {
34
+ switch (status) {
35
+ case 'pending':
36
+ return <span className="spinner" data-loading="true" />;
37
+ case 'success':
38
+ return '✓';
39
+ case 'error':
40
+ return '✗';
41
+ default:
42
+ return '?';
43
+ }
44
+ };
45
+
46
+ return (
47
+ <span
48
+ data-testid="tool-status-indicator"
49
+ className={`tool-status-indicator status-${status}`}
50
+ aria-label={getAriaLabel()}
51
+ >
52
+ {getContent()}
53
+ </span>
54
+ );
55
+ }
56
+
57
+ export default ToolStatus;
@@ -0,0 +1,169 @@
1
+ /**
2
+ * CodeMarkersDialog — Story 80-3 (MSSCI-14456)
3
+ *
4
+ * Dialog displaying code markers (TODO, FIXME, HACK, XXX) with tabs,
5
+ * sortable table, staleness badges, and summary stats.
6
+ */
7
+ import React, { useState, useMemo, useEffect } from 'react';
8
+ import { Badge } from '@/components/ui/badge';
9
+ import { Skeleton } from '@/components/ui/skeleton';
10
+ import { ToolDialog } from './ToolDialog';
11
+ import { useCodeMarkers } from '../../hooks/useCodeMarkers';
12
+
13
+ export interface CodeMarkersDialogProps {
14
+ open: boolean;
15
+ onOpenChange: (open: boolean) => void;
16
+ }
17
+
18
+ type TabId = 'all' | 'stale' | 'deprecated';
19
+ type SortField = 'marker_type' | 'path' | 'line' | 'author' | 'age_days';
20
+ type SortDirection = 'asc' | 'desc';
21
+
22
+ export function CodeMarkersDialog({ open, onOpenChange }: CodeMarkersDialogProps): React.ReactElement {
23
+ const { data, isLoading, error, refresh } = useCodeMarkers({ days: 90, repo: 'pennyfarthing' });
24
+
25
+ useEffect(() => {
26
+ if (open) refresh();
27
+ }, [open, refresh]);
28
+
29
+ const [activeTab, setActiveTab] = useState<TabId>('all');
30
+ const [sortField, setSortField] = useState<SortField>('age_days');
31
+ const [sortDirection, setSortDirection] = useState<SortDirection>('desc');
32
+
33
+ const filteredMarkers = useMemo(() => {
34
+ if (!data?.markers) return [];
35
+ switch (activeTab) {
36
+ case 'stale':
37
+ return data.markers.filter((m) => m.is_stale);
38
+ case 'deprecated':
39
+ return [];
40
+ default:
41
+ return data.markers;
42
+ }
43
+ }, [data, activeTab]);
44
+
45
+ const sortedMarkers = useMemo(() => {
46
+ const sorted = [...filteredMarkers];
47
+ sorted.sort((a, b) => {
48
+ const aVal = a[sortField];
49
+ const bVal = b[sortField];
50
+ if (typeof aVal === 'string' && typeof bVal === 'string') {
51
+ return sortDirection === 'asc' ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal);
52
+ }
53
+ const aNum = Number(aVal);
54
+ const bNum = Number(bVal);
55
+ return sortDirection === 'asc' ? aNum - bNum : bNum - aNum;
56
+ });
57
+ return sorted;
58
+ }, [filteredMarkers, sortField, sortDirection]);
59
+
60
+ const handleSort = (field: SortField) => {
61
+ if (sortField === field) {
62
+ setSortDirection((d) => (d === 'asc' ? 'desc' : 'asc'));
63
+ } else {
64
+ setSortField(field);
65
+ setSortDirection('desc');
66
+ }
67
+ };
68
+
69
+ const sortArrow = (field: SortField) => {
70
+ if (sortField !== field) return '';
71
+ return sortDirection === 'desc' ? ' v' : ' ^';
72
+ };
73
+
74
+ return (
75
+ <ToolDialog
76
+ open={open}
77
+ onOpenChange={onOpenChange}
78
+ title="Code Markers"
79
+ description="TODO, FIXME, HACK, and XXX markers across the codebase"
80
+ >
81
+ {isLoading && (
82
+ <div className="space-y-2">
83
+ <Skeleton className="h-4 w-full" />
84
+ <Skeleton className="h-4 w-3/4" />
85
+ <Skeleton className="h-4 w-1/2" />
86
+ </div>
87
+ )}
88
+
89
+ {error && (
90
+ <div className="p-4 rounded border border-[var(--status-error)]/20 bg-[var(--status-error)]/5 text-[var(--status-error)] text-sm">
91
+ {error.message}
92
+ </div>
93
+ )}
94
+
95
+ {!isLoading && !error && data && (
96
+ <>
97
+ {/* Summary stats */}
98
+ <div className="flex gap-4 text-xs text-[var(--text-muted)]" data-testid="code-markers-summary">
99
+ <span data-testid="summary-total">Total: <span className="tabular-nums font-mono">{data.summary.total_markers}</span></span>
100
+ <span data-testid="summary-stale">Stale: <span className="tabular-nums font-mono">{data.summary.stale_markers}</span></span>
101
+ {Object.entries(data.summary.by_type).map(([type, count]) => (
102
+ <span key={type} data-testid={`summary-type-${type.toLowerCase()}`}>{type}: <span className="tabular-nums font-mono">{count}</span></span>
103
+ ))}
104
+ </div>
105
+
106
+ {/* Tabs */}
107
+ <div role="tablist" className="flex gap-4 border-b border-[var(--border)] mb-3">
108
+ {(['all', 'stale', 'deprecated'] as const).map((tab) => (
109
+ <button
110
+ key={tab}
111
+ role="tab"
112
+ aria-selected={activeTab === tab}
113
+ onClick={() => setActiveTab(tab)}
114
+ className={`pb-2 text-sm capitalize ${activeTab === tab ? 'border-b-2 border-[var(--accent)] text-[var(--text-primary)] font-medium' : 'text-[var(--text-muted)]'}`}
115
+ >
116
+ {tab}
117
+ </button>
118
+ ))}
119
+ </div>
120
+
121
+ {/* Table or empty state */}
122
+ {sortedMarkers.length === 0 ? (
123
+ <div className="text-center py-12 text-[var(--text-muted)]">No markers found</div>
124
+ ) : (
125
+ <table role="table" className="w-full text-sm">
126
+ <thead>
127
+ <tr className="border-b border-[var(--border)]">
128
+ <th className="cursor-pointer select-none text-left text-xs font-medium uppercase tracking-wider text-[var(--text-muted)] pb-2" onClick={() => handleSort('marker_type')}>
129
+ Type{sortArrow('marker_type')}
130
+ </th>
131
+ <th className="cursor-pointer select-none text-left text-xs font-medium uppercase tracking-wider text-[var(--text-muted)] pb-2" onClick={() => handleSort('path')}>
132
+ File{sortArrow('path')}
133
+ </th>
134
+ <th className="cursor-pointer select-none text-right text-xs font-medium uppercase tracking-wider text-[var(--text-muted)] pb-2" onClick={() => handleSort('line')}>
135
+ Line{sortArrow('line')}
136
+ </th>
137
+ <th className="text-left text-xs font-medium uppercase tracking-wider text-[var(--text-muted)] pb-2">Text</th>
138
+ <th className="cursor-pointer select-none text-left text-xs font-medium uppercase tracking-wider text-[var(--text-muted)] pb-2" onClick={() => handleSort('author')}>
139
+ Author{sortArrow('author')}
140
+ </th>
141
+ <th className="cursor-pointer select-none text-right text-xs font-medium uppercase tracking-wider text-[var(--text-muted)] pb-2" onClick={() => handleSort('age_days')}>
142
+ Age{sortArrow('age_days')}
143
+ </th>
144
+ </tr>
145
+ </thead>
146
+ <tbody>
147
+ {sortedMarkers.map((marker, i) => (
148
+ <tr key={`${marker.path}:${marker.line}:${i}`} className="text-[var(--text-primary)]">
149
+ <td className="py-1.5">
150
+ <Badge variant={marker.is_stale ? 'destructive' : 'secondary'}>
151
+ {marker.marker_type}
152
+ </Badge>
153
+ </td>
154
+ <td className="py-1.5 font-mono text-xs">{marker.path}</td>
155
+ <td className="text-right py-1.5 tabular-nums font-mono">{marker.line}</td>
156
+ <td className="py-1.5 truncate max-w-xs">{marker.text}</td>
157
+ <td className="py-1.5">{marker.author}</td>
158
+ <td className="text-right py-1.5 tabular-nums font-mono">{marker.age_days}d</td>
159
+ </tr>
160
+ ))}
161
+ </tbody>
162
+ </table>
163
+ )}
164
+ </>
165
+ )}
166
+
167
+ </ToolDialog>
168
+ );
169
+ }
@@ -0,0 +1,163 @@
1
+ import React, { useState, useMemo, useCallback, useEffect } from 'react';
2
+ import { Badge } from '@/components/ui/badge';
3
+ import { Button } from '@/components/ui/button';
4
+ import { Skeleton } from '@/components/ui/skeleton';
5
+ import { ToolDialog } from './ToolDialog';
6
+ import { useComplexity, FileComplexity } from '../../hooks/useComplexity';
7
+
8
+ export interface ComplexityDialogProps {
9
+ open: boolean;
10
+ onOpenChange: (open: boolean) => void;
11
+ }
12
+
13
+ type SortField = 'avg_cyclomatic_complexity' | 'max_nesting_depth' | 'longest_function' | 'total_lines' | 'function_count' | 'path';
14
+ type SortDirection = 'asc' | 'desc';
15
+
16
+ function SortableHeader({
17
+ label,
18
+ field,
19
+ currentSort,
20
+ currentDirection,
21
+ onSort,
22
+ align = 'right',
23
+ }: {
24
+ label: string;
25
+ field: SortField;
26
+ currentSort: SortField;
27
+ currentDirection: SortDirection;
28
+ onSort: (field: SortField) => void;
29
+ align?: 'left' | 'right';
30
+ }) {
31
+ const isActive = currentSort === field;
32
+ const arrow = isActive ? (currentDirection === 'desc' ? ' v' : ' ^') : '';
33
+
34
+ return (
35
+ <th
36
+ className={`text-${align} ${isActive ? 'active' : ''}`}
37
+ onClick={() => onSort(field)}
38
+ role="columnheader"
39
+ aria-sort={isActive ? (currentDirection === 'desc' ? 'descending' : 'ascending') : 'none'}
40
+ style={{ cursor: 'pointer', userSelect: 'none', padding: '4px 8px' }}
41
+ >
42
+ {label}{arrow}
43
+ </th>
44
+ );
45
+ }
46
+
47
+ export function ComplexityDialog({ open, onOpenChange }: ComplexityDialogProps): React.ReactElement {
48
+ const [sortField, setSortField] = useState<SortField>('avg_cyclomatic_complexity');
49
+ const [sortDirection, setSortDirection] = useState<SortDirection>('desc');
50
+
51
+ const { data, isLoading, error, refresh } = useComplexity({});
52
+
53
+ useEffect(() => {
54
+ if (open) refresh();
55
+ }, [open, refresh]);
56
+
57
+ const handleSort = useCallback((field: SortField) => {
58
+ setSortField((prev) => {
59
+ if (prev === field) {
60
+ setSortDirection((d) => (d === 'desc' ? 'asc' : 'desc'));
61
+ return prev;
62
+ }
63
+ setSortDirection('desc');
64
+ return field;
65
+ });
66
+ }, []);
67
+
68
+ const sorted = useMemo(() => {
69
+ if (!data?.files) return [];
70
+ const items = [...data.files];
71
+ items.sort((a, b) => {
72
+ const aVal = a[sortField as keyof FileComplexity];
73
+ const bVal = b[sortField as keyof FileComplexity];
74
+ if (typeof aVal === 'number' && typeof bVal === 'number') {
75
+ return sortDirection === 'desc' ? bVal - aVal : aVal - bVal;
76
+ }
77
+ return sortDirection === 'desc'
78
+ ? String(bVal).localeCompare(String(aVal))
79
+ : String(aVal).localeCompare(String(bVal));
80
+ });
81
+ return items;
82
+ }, [data, sortField, sortDirection]);
83
+
84
+ const renderContent = () => {
85
+ if (isLoading) {
86
+ return (
87
+ <div className="complexity-panel loading" data-testid="complexity-panel">
88
+ <div className="space-y-3 p-2">
89
+ <Skeleton className="h-4 w-40" />
90
+ <Skeleton className="h-3 w-full" />
91
+ <Skeleton className="h-3 w-full" />
92
+ <Skeleton className="h-3 w-3/4" />
93
+ </div>
94
+ </div>
95
+ );
96
+ }
97
+
98
+ if (error) {
99
+ return (
100
+ <div className="complexity-panel error" data-testid="complexity-panel">
101
+ <div className="error-message">Error: {error.message}</div>
102
+ <Button variant="outline" size="sm" onClick={refresh}>Retry</Button>
103
+ </div>
104
+ );
105
+ }
106
+
107
+ if (!data) {
108
+ return (
109
+ <div className="complexity-panel" data-testid="complexity-panel">
110
+ <p>Click <strong>Analyze</strong> to run complexity analysis</p>
111
+ </div>
112
+ );
113
+ }
114
+
115
+ return (
116
+ <div className="complexity-panel" data-testid="complexity-panel">
117
+ <div className="complexity-summary" style={{ marginBottom: '8px' }}>
118
+ <span>{data.file_count} files analyzed</span>
119
+ </div>
120
+
121
+ <table className="complexity-table" role="table" style={{ width: '100%', borderCollapse: 'collapse' }}>
122
+ <thead>
123
+ <tr>
124
+ <SortableHeader label="Complexity" field="avg_cyclomatic_complexity" currentSort={sortField} currentDirection={sortDirection} onSort={handleSort} />
125
+ <SortableHeader label="Nesting" field="max_nesting_depth" currentSort={sortField} currentDirection={sortDirection} onSort={handleSort} />
126
+ <SortableHeader label="Longest Fn" field="longest_function" currentSort={sortField} currentDirection={sortDirection} onSort={handleSort} />
127
+ <SortableHeader label="Lines" field="total_lines" currentSort={sortField} currentDirection={sortDirection} onSort={handleSort} />
128
+ <SortableHeader label="Functions" field="function_count" currentSort={sortField} currentDirection={sortDirection} onSort={handleSort} />
129
+ <SortableHeader label="File" field="path" currentSort={sortField} currentDirection={sortDirection} onSort={handleSort} align="left" />
130
+ </tr>
131
+ </thead>
132
+ <tbody>
133
+ {sorted.map((f) => (
134
+ <tr key={f.path}>
135
+ <td className="text-right" style={{ padding: '4px 8px' }}>
136
+ <Badge variant={f.avg_cyclomatic_complexity >= 7 ? 'destructive' : f.avg_cyclomatic_complexity >= 4 ? 'outline' : 'secondary'}>
137
+ {Number(f.avg_cyclomatic_complexity).toFixed(1)}
138
+ </Badge>
139
+ </td>
140
+ <td className="text-right" style={{ padding: '4px 8px' }}>{f.max_nesting_depth}</td>
141
+ <td className="text-right" style={{ padding: '4px 8px' }}>{f.longest_function}</td>
142
+ <td className="text-right" style={{ padding: '4px 8px' }}>{f.total_lines}</td>
143
+ <td className="text-right" style={{ padding: '4px 8px' }}>{f.function_count}</td>
144
+ <td className="text-left" style={{ padding: '4px 8px' }}>{f.path}</td>
145
+ </tr>
146
+ ))}
147
+ </tbody>
148
+ </table>
149
+ </div>
150
+ );
151
+ };
152
+
153
+ return (
154
+ <ToolDialog
155
+ open={open}
156
+ onOpenChange={onOpenChange}
157
+ title="Complexity"
158
+ description="Cyclomatic complexity analysis"
159
+ >
160
+ {renderContent()}
161
+ </ToolDialog>
162
+ );
163
+ }