@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,105 @@
1
+ import { useState, useCallback, useRef, useEffect } from 'react';
2
+
3
+ export interface AgentLoadComponent {
4
+ name: string;
5
+ tokens: number;
6
+ source?: string | null;
7
+ }
8
+
9
+ export interface AgentLoadEntry {
10
+ agent: string;
11
+ totalTokens: number | null;
12
+ tokenCounts?: Record<string, number>;
13
+ components?: AgentLoadComponent[];
14
+ error?: string;
15
+ }
16
+
17
+ export interface AgentLoadData {
18
+ agents: AgentLoadEntry[];
19
+ cachedAt: string;
20
+ totalAcrossAllAgents: number;
21
+ }
22
+
23
+ export interface PruneResult {
24
+ success: boolean;
25
+ tokensFreed?: number;
26
+ agent?: string;
27
+ file?: string;
28
+ error?: string;
29
+ }
30
+
31
+ export interface UseAgentLoadReturn {
32
+ data: AgentLoadData | null;
33
+ isLoading: boolean;
34
+ error: Error | null;
35
+ refresh: () => void;
36
+ pruneSidecar: (agent: string, file: string) => Promise<void>;
37
+ pruneResult: PruneResult | null;
38
+ }
39
+
40
+ export function useAgentLoad(): UseAgentLoadReturn {
41
+ const [data, setData] = useState<AgentLoadData | null>(null);
42
+ const [isLoading, setIsLoading] = useState(false);
43
+ const [error, setError] = useState<Error | null>(null);
44
+ const [pruneResult, setPruneResult] = useState<PruneResult | null>(null);
45
+ const abortRef = useRef<AbortController | null>(null);
46
+
47
+ const refresh = useCallback(() => {
48
+ if (abortRef.current) {
49
+ abortRef.current.abort();
50
+ }
51
+
52
+ const controller = new AbortController();
53
+ abortRef.current = controller;
54
+
55
+ setIsLoading(true);
56
+ setError(null);
57
+
58
+ fetch('/api/agent-load', { signal: controller.signal })
59
+ .then((res) => {
60
+ if (!res.ok) {
61
+ throw new Error(`HTTP ${res.status}: ${res.statusText}`);
62
+ }
63
+ return res.json();
64
+ })
65
+ .then((json: AgentLoadData) => {
66
+ setData(json);
67
+ setIsLoading(false);
68
+ })
69
+ .catch((err) => {
70
+ if (err.name === 'AbortError') return;
71
+ setError(err instanceof Error ? err : new Error(String(err)));
72
+ setIsLoading(false);
73
+ });
74
+ }, []);
75
+
76
+ const pruneSidecar = useCallback(async (agent: string, file: string) => {
77
+ const res = await fetch('/api/agent-load/prune-sidecar', {
78
+ method: 'POST',
79
+ headers: { 'Content-Type': 'application/json' },
80
+ body: JSON.stringify({ agent, file }),
81
+ });
82
+
83
+ if (!res.ok) {
84
+ setPruneResult({ success: false, error: `HTTP ${res.status}: ${res.statusText}` });
85
+ return;
86
+ }
87
+
88
+ const result: PruneResult = await res.json();
89
+ setPruneResult(result);
90
+
91
+ if (result.success) {
92
+ refresh();
93
+ }
94
+ }, [refresh]);
95
+
96
+ useEffect(() => {
97
+ return () => {
98
+ if (abortRef.current) {
99
+ abortRef.current.abort();
100
+ }
101
+ };
102
+ }, []);
103
+
104
+ return { data, isLoading, error, refresh, pruneSidecar, pruneResult };
105
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * useBackgroundTasks Hook
3
+ *
4
+ * React hook for subscribing to background task notifications.
5
+ * Story MSSCI-12717 - React Migration
6
+ * Story MSSCI-12784 - Timer accuracy: fetch on mount, IPC for updates
7
+ * Story MSSCI-12860 - IPC to WebSocket Migration (Phase 1)
8
+ *
9
+ * Uses WebSocket /ws/background-tasks for real-time updates.
10
+ */
11
+
12
+ import { useState, useEffect, useCallback, useRef } from 'react';
13
+
14
+ export interface BackgroundTask {
15
+ taskId: string;
16
+ description: string;
17
+ subagentType: string;
18
+ startedAt: number;
19
+ completedAt?: number;
20
+ durationMs?: number;
21
+ status: 'pending' | 'completed';
22
+ success?: boolean;
23
+ output?: string;
24
+ error?: string;
25
+ isBackground?: boolean;
26
+ }
27
+
28
+ interface UseBackgroundTasksResult {
29
+ tasks: BackgroundTask[];
30
+ pendingCount: number;
31
+ completedCount: number;
32
+ clearCompleted: () => void;
33
+ }
34
+
35
+ /** WebSocket message format from /ws/background-tasks */
36
+ interface BackgroundTaskMessage {
37
+ type: 'init' | 'task:started' | 'task:completed';
38
+ tasks?: BackgroundTask[];
39
+ task?: BackgroundTask;
40
+ }
41
+
42
+ export function useBackgroundTasks(): UseBackgroundTasksResult {
43
+ const [tasks, setTasks] = useState<BackgroundTask[]>([]);
44
+ const wsRef = useRef<WebSocket | null>(null);
45
+ const reconnectTimeoutRef = useRef<ReturnType<typeof setTimeout>>();
46
+
47
+ useEffect(() => {
48
+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
49
+ const wsUrl = `${protocol}//${window.location.host}/ws/background-tasks`;
50
+
51
+ const connect = () => {
52
+ try {
53
+ wsRef.current = new WebSocket(wsUrl);
54
+
55
+ wsRef.current.onopen = () => {
56
+ console.debug('[useBackgroundTasks] WebSocket connected');
57
+ };
58
+
59
+ wsRef.current.onmessage = (event) => {
60
+ try {
61
+ const msg = JSON.parse(event.data) as BackgroundTaskMessage;
62
+
63
+ switch (msg.type) {
64
+ case 'init':
65
+ // Initial snapshot of all tasks
66
+ if (msg.tasks) {
67
+ setTasks(msg.tasks);
68
+ }
69
+ break;
70
+
71
+ case 'task:started':
72
+ // New task started
73
+ if (msg.task) {
74
+ setTasks(prev => {
75
+ // Avoid duplicates
76
+ if (prev.some(t => t.taskId === msg.task!.taskId)) {
77
+ return prev;
78
+ }
79
+ return [...prev, msg.task!];
80
+ });
81
+ }
82
+ break;
83
+
84
+ case 'task:completed':
85
+ // Task completed (includes accurate durationMs from backend)
86
+ if (msg.task) {
87
+ setTasks(prev => prev.map(t =>
88
+ t.taskId === msg.task!.taskId ? { ...t, ...msg.task! } : t
89
+ ));
90
+ }
91
+ break;
92
+ }
93
+ } catch (err) {
94
+ console.error('[useBackgroundTasks] Failed to parse message:', err);
95
+ }
96
+ };
97
+
98
+ wsRef.current.onclose = () => {
99
+ console.debug('[useBackgroundTasks] WebSocket closed, reconnecting...');
100
+ reconnectTimeoutRef.current = setTimeout(connect, 2000);
101
+ };
102
+
103
+ wsRef.current.onerror = (err) => {
104
+ console.error('[useBackgroundTasks] WebSocket error:', err);
105
+ };
106
+ } catch (err) {
107
+ console.error('[useBackgroundTasks] WebSocket init failed:', err);
108
+ }
109
+ };
110
+
111
+ connect();
112
+
113
+ return () => {
114
+ if (reconnectTimeoutRef.current) {
115
+ clearTimeout(reconnectTimeoutRef.current);
116
+ }
117
+ if (wsRef.current) {
118
+ wsRef.current.close();
119
+ }
120
+ };
121
+ }, []);
122
+
123
+ const clearCompleted = useCallback(() => {
124
+ setTasks(prev => prev.filter(t => t.status === 'pending'));
125
+ }, []);
126
+
127
+ const pendingCount = tasks.filter(t => t.status === 'pending').length;
128
+ const completedCount = tasks.filter(t => t.status === 'completed').length;
129
+
130
+ return { tasks, pendingCount, completedCount, clearCompleted };
131
+ }
@@ -0,0 +1,234 @@
1
+ /**
2
+ * useClaude Hook
3
+ *
4
+ * WebSocket-based hook for Claude API communication.
5
+ * Part of IPC-to-WebSocket migration (Phase 1).
6
+ *
7
+ * Replaces window.electronAPI.claude with unified WebSocket communication.
8
+ */
9
+
10
+ import { useState, useEffect, useCallback, useRef } from 'react';
11
+
12
+ // =============================================================================
13
+ // Types
14
+ // =============================================================================
15
+
16
+ export type PermissionMode = 'default' | 'plan' | 'acceptEdits' | 'dangerouslySkipPermissions';
17
+
18
+ export interface PastedImage {
19
+ dataUrl: string;
20
+ mimeType: string;
21
+ filename: string;
22
+ }
23
+
24
+ export interface ClaudeMessage {
25
+ type: string;
26
+ message?: unknown;
27
+ content?: string | Array<{ type: string; text?: string }>;
28
+ tool_name?: string;
29
+ tool_id?: string;
30
+ input?: Record<string, unknown>;
31
+ output?: string;
32
+ is_error?: boolean;
33
+ parent_tool_use_id?: string | null;
34
+ subagent_type?: string;
35
+ subagent_name?: string;
36
+ }
37
+
38
+ interface WebSocketClaudeMessage {
39
+ type: 'message' | 'complete' | 'error' | 'init' | 'mode';
40
+ message?: ClaudeMessage;
41
+ error?: string;
42
+ mode?: PermissionMode;
43
+ }
44
+
45
+ export interface UseClaudeResult {
46
+ /** Send a message to Claude */
47
+ send: (prompt: string, images?: PastedImage[]) => void;
48
+ /** Abort the current query */
49
+ abort: () => void;
50
+ /** Clear the session */
51
+ clear: () => void;
52
+ /** Set permission mode */
53
+ setMode: (mode: PermissionMode) => void;
54
+ /** Whether WebSocket is connected */
55
+ isConnected: boolean;
56
+ /** Current permission mode */
57
+ mode: PermissionMode;
58
+ }
59
+
60
+ export interface UseClaudeCallbacks {
61
+ onMessage?: (message: ClaudeMessage) => void;
62
+ onComplete?: () => void;
63
+ onError?: (error: string) => void;
64
+ }
65
+
66
+ // =============================================================================
67
+ // Hook Implementation
68
+ // =============================================================================
69
+
70
+ export function useClaude(callbacks?: UseClaudeCallbacks): UseClaudeResult {
71
+ const [isConnected, setIsConnected] = useState(false);
72
+ const [mode, setModeState] = useState<PermissionMode>('default');
73
+ const wsRef = useRef<WebSocket | null>(null);
74
+ const reconnectTimeoutRef = useRef<ReturnType<typeof setTimeout>>();
75
+ const callbacksRef = useRef(callbacks);
76
+
77
+ // Keep callbacks ref updated
78
+ useEffect(() => {
79
+ callbacksRef.current = callbacks;
80
+ }, [callbacks]);
81
+
82
+ // Connect to WebSocket
83
+ const connect = useCallback(() => {
84
+ // Build WebSocket URL
85
+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
86
+ const host = window.location.host;
87
+ const wsUrl = `${protocol}//${host}/ws/claude`;
88
+
89
+ console.log('[useClaude] Connecting to', wsUrl);
90
+
91
+ const ws = new WebSocket(wsUrl);
92
+ wsRef.current = ws;
93
+
94
+ ws.onopen = () => {
95
+ console.log('[useClaude] Connected');
96
+ setIsConnected(true);
97
+ // Request current mode from server
98
+ ws.send(JSON.stringify({ type: 'getMode' }));
99
+ };
100
+
101
+ ws.onmessage = (event) => {
102
+ try {
103
+ const data = JSON.parse(event.data) as WebSocketClaudeMessage;
104
+
105
+ switch (data.type) {
106
+ case 'message':
107
+ if (data.message && callbacksRef.current?.onMessage) {
108
+ callbacksRef.current.onMessage(data.message);
109
+ }
110
+ break;
111
+
112
+ case 'complete':
113
+ if (callbacksRef.current?.onComplete) {
114
+ callbacksRef.current.onComplete();
115
+ }
116
+ break;
117
+
118
+ case 'error':
119
+ if (data.error && callbacksRef.current?.onError) {
120
+ callbacksRef.current.onError(data.error);
121
+ }
122
+ break;
123
+
124
+ case 'init':
125
+ // Initial connection acknowledgment
126
+ console.log('[useClaude] Init received');
127
+ break;
128
+
129
+ case 'mode':
130
+ // Server responded with current permission mode
131
+ if (data.mode) {
132
+ console.log('[useClaude] Mode received:', data.mode);
133
+ setModeState(data.mode);
134
+ }
135
+ break;
136
+ }
137
+ } catch (err) {
138
+ console.error('[useClaude] Failed to parse message:', err);
139
+ }
140
+ };
141
+
142
+ ws.onclose = () => {
143
+ console.log('[useClaude] Disconnected');
144
+ setIsConnected(false);
145
+ wsRef.current = null;
146
+
147
+ // Attempt reconnection after delay
148
+ reconnectTimeoutRef.current = setTimeout(() => {
149
+ console.log('[useClaude] Attempting reconnect...');
150
+ connect();
151
+ }, 2000);
152
+ };
153
+
154
+ ws.onerror = (error) => {
155
+ console.error('[useClaude] WebSocket error:', error);
156
+ };
157
+ }, []);
158
+
159
+ // Initialize connection
160
+ useEffect(() => {
161
+ connect();
162
+
163
+ return () => {
164
+ if (reconnectTimeoutRef.current) {
165
+ clearTimeout(reconnectTimeoutRef.current);
166
+ }
167
+ if (wsRef.current) {
168
+ wsRef.current.close();
169
+ wsRef.current = null;
170
+ }
171
+ };
172
+ }, [connect]);
173
+
174
+ // Send message
175
+ const send = useCallback((prompt: string, images?: PastedImage[]) => {
176
+ if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) {
177
+ console.error('[useClaude] Cannot send: not connected');
178
+ callbacksRef.current?.onError?.('Not connected to Claude service');
179
+ return;
180
+ }
181
+
182
+ if (images && images.length > 0) {
183
+ console.log(`[useClaude] Sending ${images.length} image(s) with prompt`);
184
+ }
185
+
186
+ wsRef.current.send(JSON.stringify({
187
+ type: 'send',
188
+ prompt,
189
+ images: images || [],
190
+ }));
191
+ }, []);
192
+
193
+ // Abort query
194
+ const abort = useCallback(() => {
195
+ if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) {
196
+ console.warn('[useClaude] Cannot abort: not connected');
197
+ return;
198
+ }
199
+
200
+ wsRef.current.send(JSON.stringify({ type: 'abort' }));
201
+ }, []);
202
+
203
+ // Clear session
204
+ const clear = useCallback(() => {
205
+ if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) {
206
+ console.warn('[useClaude] Cannot clear: not connected');
207
+ return;
208
+ }
209
+
210
+ wsRef.current.send(JSON.stringify({ type: 'clear' }));
211
+ }, []);
212
+
213
+ // Set permission mode
214
+ const setMode = useCallback((newMode: PermissionMode) => {
215
+ if (!wsRef.current || wsRef.current.readyState !== WebSocket.OPEN) {
216
+ console.warn('[useClaude] Cannot set mode: not connected');
217
+ return;
218
+ }
219
+
220
+ wsRef.current.send(JSON.stringify({ type: 'setMode', mode: newMode }));
221
+ setModeState(newMode);
222
+ }, []);
223
+
224
+ return {
225
+ send,
226
+ abort,
227
+ clear,
228
+ setMode,
229
+ isConnected,
230
+ mode,
231
+ };
232
+ }
233
+
234
+ export default useClaude;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * useCodeMarkers React hook — Story 80-3 (MSSCI-14456)
3
+ *
4
+ * Wraps /api/code-markers endpoint with AbortController,
5
+ * loading/error/data state management, and manual refresh.
6
+ */
7
+ import { useState, useCallback, useEffect, useRef } from 'react';
8
+
9
+ export interface CodeMarker {
10
+ path: string;
11
+ line: number;
12
+ marker_type: string;
13
+ text: string;
14
+ author: string;
15
+ date: string;
16
+ age_days: number;
17
+ is_stale: boolean;
18
+ }
19
+
20
+ export interface MarkerSummary {
21
+ total_markers: number;
22
+ stale_markers: number;
23
+ by_type: Record<string, number>;
24
+ }
25
+
26
+ export interface CodeMarkersData {
27
+ success: boolean;
28
+ repo_name: string;
29
+ repo_path: string;
30
+ stale_threshold_days: number;
31
+ markers: CodeMarker[];
32
+ summary: MarkerSummary;
33
+ error: string | null;
34
+ }
35
+
36
+ export interface UseCodeMarkersOptions {
37
+ days: number;
38
+ repo?: string;
39
+ type?: 'all' | 'stale' | 'deprecated';
40
+ }
41
+
42
+ export interface UseCodeMarkersReturn {
43
+ data: CodeMarkersData | null;
44
+ isLoading: boolean;
45
+ error: Error | null;
46
+ refresh: () => void;
47
+ }
48
+
49
+ export function useCodeMarkers(options: UseCodeMarkersOptions): UseCodeMarkersReturn {
50
+ const [data, setData] = useState<CodeMarkersData | null>(null);
51
+ const [isLoading, setIsLoading] = useState(false);
52
+ const [error, setError] = useState<Error | null>(null);
53
+ const abortRef = useRef<AbortController | null>(null);
54
+
55
+ const fetchCodeMarkers = useCallback(() => {
56
+ if (abortRef.current) {
57
+ abortRef.current.abort();
58
+ }
59
+
60
+ const controller = new AbortController();
61
+ abortRef.current = controller;
62
+
63
+ setIsLoading(true);
64
+ setError(null);
65
+
66
+ const params = new URLSearchParams({ days: String(options.days) });
67
+ if (options.repo) {
68
+ params.set('repo', options.repo);
69
+ }
70
+ if (options.type) {
71
+ params.set('type', options.type);
72
+ }
73
+
74
+ fetch(`/api/code-markers?${params}`, { signal: controller.signal })
75
+ .then((res) => {
76
+ if (!res.ok) {
77
+ throw new Error(`HTTP ${res.status}: ${res.statusText}`);
78
+ }
79
+ return res.json();
80
+ })
81
+ .then((json: CodeMarkersData) => {
82
+ setData(json);
83
+ setIsLoading(false);
84
+ })
85
+ .catch((err) => {
86
+ if (err.name === 'AbortError') return;
87
+ setError(err instanceof Error ? err : new Error(String(err)));
88
+ setIsLoading(false);
89
+ });
90
+ }, [options.days, options.repo, options.type]);
91
+
92
+ useEffect(() => {
93
+ return () => {
94
+ if (abortRef.current) {
95
+ abortRef.current.abort();
96
+ }
97
+ };
98
+ }, []);
99
+
100
+ return { data, isLoading, error, refresh: fetchCodeMarkers };
101
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * useColorScheme Hook
3
+ *
4
+ * Tracks the active color scheme (light/dark) from the applied color preset's
5
+ * data-variant attribute on the document root. Falls back to OS preference.
6
+ */
7
+
8
+ import { useState, useEffect } from 'react';
9
+
10
+ export type ColorScheme = 'light' | 'dark';
11
+
12
+ function getVariant(): ColorScheme {
13
+ const variant = document.documentElement.getAttribute('data-variant');
14
+ if (variant === 'light' || variant === 'dark') return variant;
15
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
16
+ }
17
+
18
+ export function useColorScheme(): ColorScheme {
19
+ const [scheme, setScheme] = useState<ColorScheme>(getVariant);
20
+
21
+ useEffect(() => {
22
+ // Watch for preset changes via data-variant attribute
23
+ const observer = new MutationObserver(() => {
24
+ setScheme(getVariant());
25
+ });
26
+ observer.observe(document.documentElement, {
27
+ attributes: true,
28
+ attributeFilter: ['data-variant'],
29
+ });
30
+
31
+ // Also listen to presetChange events from applyPreset()
32
+ const handlePreset = () => setScheme(getVariant());
33
+ window.addEventListener('presetChange', handlePreset);
34
+
35
+ return () => {
36
+ observer.disconnect();
37
+ window.removeEventListener('presetChange', handlePreset);
38
+ };
39
+ }, []);
40
+
41
+ return scheme;
42
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * useCommandHistory Hook
3
+ *
4
+ * React hook for command history navigation (Up/Down arrows).
5
+ * Story MSSCI-12717 - React Migration
6
+ */
7
+
8
+ import { useState, useCallback, useRef } from 'react';
9
+
10
+ const HISTORY_KEY = 'cyclist-command-history';
11
+ const MAX_HISTORY = 100;
12
+
13
+ interface UseCommandHistoryResult {
14
+ addToHistory: (command: string) => void;
15
+ navigateUp: (currentContent: string) => string | null;
16
+ navigateDown: () => string | null;
17
+ resetNavigation: () => void;
18
+ }
19
+
20
+ export function useCommandHistory(): UseCommandHistoryResult {
21
+ const [history, setHistory] = useState<string[]>(() => {
22
+ try {
23
+ const stored = localStorage.getItem(HISTORY_KEY);
24
+ return stored ? JSON.parse(stored) : [];
25
+ } catch {
26
+ return [];
27
+ }
28
+ });
29
+
30
+ const historyIndexRef = useRef(-1);
31
+ const savedInputRef = useRef('');
32
+
33
+ const saveHistory = useCallback((newHistory: string[]) => {
34
+ try {
35
+ localStorage.setItem(HISTORY_KEY, JSON.stringify(newHistory));
36
+ } catch {
37
+ // Ignore localStorage errors
38
+ }
39
+ }, []);
40
+
41
+ const addToHistory = useCallback((command: string) => {
42
+ if (!command.trim()) return;
43
+
44
+ setHistory(prev => {
45
+ // Don't add duplicate of last command
46
+ if (prev.length > 0 && prev[prev.length - 1] === command) {
47
+ return prev;
48
+ }
49
+
50
+ const newHistory = [...prev, command];
51
+ // Trim to max size
52
+ if (newHistory.length > MAX_HISTORY) {
53
+ newHistory.shift();
54
+ }
55
+ saveHistory(newHistory);
56
+ return newHistory;
57
+ });
58
+ }, [saveHistory]);
59
+
60
+ const navigateUp = useCallback((currentContent: string): string | null => {
61
+ if (history.length === 0) return null;
62
+
63
+ // First time pressing up: save current input and start at end
64
+ if (historyIndexRef.current === -1) {
65
+ savedInputRef.current = currentContent;
66
+ historyIndexRef.current = history.length - 1;
67
+ } else if (historyIndexRef.current > 0) {
68
+ historyIndexRef.current--;
69
+ } else {
70
+ // Already at oldest command
71
+ return null;
72
+ }
73
+
74
+ return history[historyIndexRef.current];
75
+ }, [history]);
76
+
77
+ const navigateDown = useCallback((): string | null => {
78
+ if (historyIndexRef.current === -1) return null;
79
+
80
+ historyIndexRef.current++;
81
+
82
+ if (historyIndexRef.current >= history.length) {
83
+ // Back to current input
84
+ historyIndexRef.current = -1;
85
+ const saved = savedInputRef.current;
86
+ savedInputRef.current = '';
87
+ return saved;
88
+ }
89
+
90
+ return history[historyIndexRef.current];
91
+ }, [history]);
92
+
93
+ const resetNavigation = useCallback(() => {
94
+ historyIndexRef.current = -1;
95
+ savedInputRef.current = '';
96
+ }, []);
97
+
98
+ return { addToHistory, navigateUp, navigateDown, resetNavigation };
99
+ }