@aion0/forge 0.5.26 → 0.5.28

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 (255) hide show
  1. package/.forge/worktrees/pipeline-4dd8dc2d/CLAUDE.md +86 -0
  2. package/.forge/worktrees/pipeline-4dd8dc2d/README.md +136 -0
  3. package/.forge/worktrees/pipeline-4dd8dc2d/RELEASE_NOTES.md +36 -0
  4. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/agents/route.ts +17 -0
  5. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/auth/[...nextauth]/route.ts +3 -0
  6. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/auth/verify/route.ts +46 -0
  7. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/claude/[id]/route.ts +31 -0
  8. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/claude/[id]/stream/route.ts +63 -0
  9. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/claude/route.ts +28 -0
  10. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/claude-sessions/[projectName]/entries/route.ts +23 -0
  11. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/claude-sessions/[projectName]/live/route.ts +72 -0
  12. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/claude-sessions/[projectName]/route.ts +37 -0
  13. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/claude-sessions/sync/route.ts +17 -0
  14. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/claude-templates/route.ts +145 -0
  15. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/code/route.ts +299 -0
  16. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/delivery/[id]/route.ts +62 -0
  17. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/delivery/route.ts +40 -0
  18. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/detect-cli/route.ts +46 -0
  19. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/docs/route.ts +176 -0
  20. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/docs/sessions/route.ts +54 -0
  21. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/favorites/route.ts +26 -0
  22. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/flows/route.ts +6 -0
  23. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/flows/run/route.ts +19 -0
  24. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/git/route.ts +149 -0
  25. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/help/route.ts +84 -0
  26. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/issue-scanner/route.ts +116 -0
  27. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/logs/route.ts +100 -0
  28. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/mobile-chat/route.ts +115 -0
  29. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/monitor/route.ts +74 -0
  30. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/notifications/route.ts +42 -0
  31. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/notify/test/route.ts +33 -0
  32. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/online/route.ts +40 -0
  33. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/pipelines/[id]/route.ts +41 -0
  34. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/pipelines/route.ts +90 -0
  35. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/plugins/route.ts +75 -0
  36. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/preview/[...path]/route.ts +64 -0
  37. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/preview/route.ts +156 -0
  38. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/project-pipelines/route.ts +91 -0
  39. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/project-sessions/route.ts +61 -0
  40. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/projects/route.ts +26 -0
  41. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/sessions/[id]/chat/route.ts +64 -0
  42. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/sessions/[id]/messages/route.ts +9 -0
  43. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/sessions/[id]/route.ts +17 -0
  44. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/sessions/route.ts +20 -0
  45. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/settings/route.ts +64 -0
  46. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/skills/local/route.ts +228 -0
  47. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/skills/route.ts +182 -0
  48. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/smith-templates/route.ts +81 -0
  49. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/status/route.ts +12 -0
  50. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/tabs/route.ts +25 -0
  51. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/tasks/[id]/route.ts +51 -0
  52. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/tasks/[id]/stream/route.ts +77 -0
  53. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/tasks/link/route.ts +37 -0
  54. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/tasks/route.ts +44 -0
  55. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/tasks/session/route.ts +14 -0
  56. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/telegram/route.ts +23 -0
  57. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/templates/route.ts +6 -0
  58. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/terminal-bell/route.ts +39 -0
  59. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/terminal-cwd/route.ts +19 -0
  60. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/terminal-state/route.ts +15 -0
  61. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/tunnel/route.ts +26 -0
  62. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/upgrade/route.ts +43 -0
  63. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/usage/route.ts +20 -0
  64. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/version/route.ts +78 -0
  65. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/watchers/route.ts +33 -0
  66. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/workspace/[id]/agents/route.ts +35 -0
  67. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/workspace/[id]/memory/route.ts +23 -0
  68. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/workspace/[id]/smith/route.ts +22 -0
  69. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/workspace/[id]/stream/route.ts +31 -0
  70. package/.forge/worktrees/pipeline-4dd8dc2d/app/api/workspace/route.ts +79 -0
  71. package/.forge/worktrees/pipeline-4dd8dc2d/app/global-error.tsx +21 -0
  72. package/.forge/worktrees/pipeline-4dd8dc2d/app/globals.css +52 -0
  73. package/.forge/worktrees/pipeline-4dd8dc2d/app/icon.ico +0 -0
  74. package/.forge/worktrees/pipeline-4dd8dc2d/app/icon.png +0 -0
  75. package/.forge/worktrees/pipeline-4dd8dc2d/app/icon.svg +106 -0
  76. package/.forge/worktrees/pipeline-4dd8dc2d/app/layout.tsx +17 -0
  77. package/.forge/worktrees/pipeline-4dd8dc2d/app/login/LoginForm.tsx +96 -0
  78. package/.forge/worktrees/pipeline-4dd8dc2d/app/login/page.tsx +10 -0
  79. package/.forge/worktrees/pipeline-4dd8dc2d/app/mobile/page.tsx +10 -0
  80. package/.forge/worktrees/pipeline-4dd8dc2d/app/page.tsx +22 -0
  81. package/.forge/worktrees/pipeline-4dd8dc2d/bin/forge-server.mjs +484 -0
  82. package/.forge/worktrees/pipeline-4dd8dc2d/check-forge-status.sh +71 -0
  83. package/.forge/worktrees/pipeline-4dd8dc2d/cli/mw.ts +579 -0
  84. package/.forge/worktrees/pipeline-4dd8dc2d/components/BrowserPanel.tsx +175 -0
  85. package/.forge/worktrees/pipeline-4dd8dc2d/components/ChatPanel.tsx +191 -0
  86. package/.forge/worktrees/pipeline-4dd8dc2d/components/ClaudeTerminal.tsx +267 -0
  87. package/.forge/worktrees/pipeline-4dd8dc2d/components/CodeViewer.tsx +787 -0
  88. package/.forge/worktrees/pipeline-4dd8dc2d/components/ConversationEditor.tsx +411 -0
  89. package/.forge/worktrees/pipeline-4dd8dc2d/components/ConversationGraphView.tsx +347 -0
  90. package/.forge/worktrees/pipeline-4dd8dc2d/components/ConversationTerminalView.tsx +303 -0
  91. package/.forge/worktrees/pipeline-4dd8dc2d/components/Dashboard.tsx +807 -0
  92. package/.forge/worktrees/pipeline-4dd8dc2d/components/DashboardWrapper.tsx +9 -0
  93. package/.forge/worktrees/pipeline-4dd8dc2d/components/DeliveryFlowEditor.tsx +491 -0
  94. package/.forge/worktrees/pipeline-4dd8dc2d/components/DeliveryList.tsx +230 -0
  95. package/.forge/worktrees/pipeline-4dd8dc2d/components/DeliveryWorkspace.tsx +589 -0
  96. package/.forge/worktrees/pipeline-4dd8dc2d/components/DocTerminal.tsx +187 -0
  97. package/.forge/worktrees/pipeline-4dd8dc2d/components/DocsViewer.tsx +574 -0
  98. package/.forge/worktrees/pipeline-4dd8dc2d/components/HelpDialog.tsx +169 -0
  99. package/.forge/worktrees/pipeline-4dd8dc2d/components/HelpTerminal.tsx +141 -0
  100. package/.forge/worktrees/pipeline-4dd8dc2d/components/InlinePipelineView.tsx +111 -0
  101. package/.forge/worktrees/pipeline-4dd8dc2d/components/LogViewer.tsx +194 -0
  102. package/.forge/worktrees/pipeline-4dd8dc2d/components/MarkdownContent.tsx +73 -0
  103. package/.forge/worktrees/pipeline-4dd8dc2d/components/MobileView.tsx +385 -0
  104. package/.forge/worktrees/pipeline-4dd8dc2d/components/MonitorPanel.tsx +122 -0
  105. package/.forge/worktrees/pipeline-4dd8dc2d/components/NewSessionModal.tsx +93 -0
  106. package/.forge/worktrees/pipeline-4dd8dc2d/components/NewTaskModal.tsx +492 -0
  107. package/.forge/worktrees/pipeline-4dd8dc2d/components/PipelineEditor.tsx +570 -0
  108. package/.forge/worktrees/pipeline-4dd8dc2d/components/PipelineView.tsx +1018 -0
  109. package/.forge/worktrees/pipeline-4dd8dc2d/components/PluginsPanel.tsx +472 -0
  110. package/.forge/worktrees/pipeline-4dd8dc2d/components/ProjectDetail.tsx +1618 -0
  111. package/.forge/worktrees/pipeline-4dd8dc2d/components/ProjectList.tsx +108 -0
  112. package/.forge/worktrees/pipeline-4dd8dc2d/components/ProjectManager.tsx +401 -0
  113. package/.forge/worktrees/pipeline-4dd8dc2d/components/SessionList.tsx +74 -0
  114. package/.forge/worktrees/pipeline-4dd8dc2d/components/SessionView.tsx +726 -0
  115. package/.forge/worktrees/pipeline-4dd8dc2d/components/SettingsModal.tsx +1647 -0
  116. package/.forge/worktrees/pipeline-4dd8dc2d/components/SkillsPanel.tsx +969 -0
  117. package/.forge/worktrees/pipeline-4dd8dc2d/components/StatusBar.tsx +99 -0
  118. package/.forge/worktrees/pipeline-4dd8dc2d/components/TabBar.tsx +46 -0
  119. package/.forge/worktrees/pipeline-4dd8dc2d/components/TaskBoard.tsx +113 -0
  120. package/.forge/worktrees/pipeline-4dd8dc2d/components/TaskDetail.tsx +372 -0
  121. package/.forge/worktrees/pipeline-4dd8dc2d/components/TerminalLauncher.tsx +398 -0
  122. package/.forge/worktrees/pipeline-4dd8dc2d/components/TunnelToggle.tsx +206 -0
  123. package/.forge/worktrees/pipeline-4dd8dc2d/components/UsagePanel.tsx +207 -0
  124. package/.forge/worktrees/pipeline-4dd8dc2d/components/WebTerminal.tsx +1743 -0
  125. package/.forge/worktrees/pipeline-4dd8dc2d/components/WorkspaceTree.tsx +221 -0
  126. package/.forge/worktrees/pipeline-4dd8dc2d/components/WorkspaceView.tsx +4048 -0
  127. package/.forge/worktrees/pipeline-4dd8dc2d/dev-test.sh +5 -0
  128. package/.forge/worktrees/pipeline-4dd8dc2d/docs/Forge_Memory_Layer_Design.docx +0 -0
  129. package/.forge/worktrees/pipeline-4dd8dc2d/docs/Forge_Strategy_Research_2026.docx +0 -0
  130. package/.forge/worktrees/pipeline-4dd8dc2d/docs/LOCAL-DEPLOY.md +144 -0
  131. package/.forge/worktrees/pipeline-4dd8dc2d/docs/roadmap-multi-agent-workflow.md +330 -0
  132. package/.forge/worktrees/pipeline-4dd8dc2d/forge-logo.png +0 -0
  133. package/.forge/worktrees/pipeline-4dd8dc2d/forge-logo.svg +106 -0
  134. package/.forge/worktrees/pipeline-4dd8dc2d/hooks/useSidebarResize.ts +52 -0
  135. package/.forge/worktrees/pipeline-4dd8dc2d/install.sh +29 -0
  136. package/.forge/worktrees/pipeline-4dd8dc2d/instrumentation.ts +35 -0
  137. package/.forge/worktrees/pipeline-4dd8dc2d/lib/agents/claude-adapter.ts +104 -0
  138. package/.forge/worktrees/pipeline-4dd8dc2d/lib/agents/generic-adapter.ts +64 -0
  139. package/.forge/worktrees/pipeline-4dd8dc2d/lib/agents/index.ts +245 -0
  140. package/.forge/worktrees/pipeline-4dd8dc2d/lib/agents/types.ts +70 -0
  141. package/.forge/worktrees/pipeline-4dd8dc2d/lib/artifacts.ts +106 -0
  142. package/.forge/worktrees/pipeline-4dd8dc2d/lib/auth.ts +62 -0
  143. package/.forge/worktrees/pipeline-4dd8dc2d/lib/builtin-plugins/docker.yaml +70 -0
  144. package/.forge/worktrees/pipeline-4dd8dc2d/lib/builtin-plugins/http.yaml +66 -0
  145. package/.forge/worktrees/pipeline-4dd8dc2d/lib/builtin-plugins/jenkins.yaml +92 -0
  146. package/.forge/worktrees/pipeline-4dd8dc2d/lib/builtin-plugins/llm-vision.yaml +85 -0
  147. package/.forge/worktrees/pipeline-4dd8dc2d/lib/builtin-plugins/playwright.yaml +111 -0
  148. package/.forge/worktrees/pipeline-4dd8dc2d/lib/builtin-plugins/shell-command.yaml +60 -0
  149. package/.forge/worktrees/pipeline-4dd8dc2d/lib/builtin-plugins/slack.yaml +48 -0
  150. package/.forge/worktrees/pipeline-4dd8dc2d/lib/builtin-plugins/webhook.yaml +56 -0
  151. package/.forge/worktrees/pipeline-4dd8dc2d/lib/claude-process.ts +361 -0
  152. package/.forge/worktrees/pipeline-4dd8dc2d/lib/claude-sessions.ts +266 -0
  153. package/.forge/worktrees/pipeline-4dd8dc2d/lib/claude-templates.ts +227 -0
  154. package/.forge/worktrees/pipeline-4dd8dc2d/lib/cloudflared.ts +424 -0
  155. package/.forge/worktrees/pipeline-4dd8dc2d/lib/crypto.ts +67 -0
  156. package/.forge/worktrees/pipeline-4dd8dc2d/lib/delivery.ts +787 -0
  157. package/.forge/worktrees/pipeline-4dd8dc2d/lib/dirs.ts +99 -0
  158. package/.forge/worktrees/pipeline-4dd8dc2d/lib/flows.ts +86 -0
  159. package/.forge/worktrees/pipeline-4dd8dc2d/lib/forge-mcp-server.ts +732 -0
  160. package/.forge/worktrees/pipeline-4dd8dc2d/lib/forge-skills/forge-inbox.md +38 -0
  161. package/.forge/worktrees/pipeline-4dd8dc2d/lib/forge-skills/forge-send.md +47 -0
  162. package/.forge/worktrees/pipeline-4dd8dc2d/lib/forge-skills/forge-status.md +32 -0
  163. package/.forge/worktrees/pipeline-4dd8dc2d/lib/forge-skills/forge-workspace-sync.md +37 -0
  164. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/00-overview.md +40 -0
  165. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/01-settings.md +194 -0
  166. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/02-telegram.md +41 -0
  167. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/03-tunnel.md +31 -0
  168. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/04-tasks.md +52 -0
  169. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/05-pipelines.md +460 -0
  170. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/06-skills.md +43 -0
  171. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/07-projects.md +73 -0
  172. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/08-rules.md +53 -0
  173. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/09-issue-autofix.md +55 -0
  174. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/10-troubleshooting.md +89 -0
  175. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/11-workspace.md +810 -0
  176. package/.forge/worktrees/pipeline-4dd8dc2d/lib/help-docs/CLAUDE.md +62 -0
  177. package/.forge/worktrees/pipeline-4dd8dc2d/lib/init.ts +266 -0
  178. package/.forge/worktrees/pipeline-4dd8dc2d/lib/issue-scanner.ts +298 -0
  179. package/.forge/worktrees/pipeline-4dd8dc2d/lib/logger.ts +79 -0
  180. package/.forge/worktrees/pipeline-4dd8dc2d/lib/notifications.ts +75 -0
  181. package/.forge/worktrees/pipeline-4dd8dc2d/lib/notify.ts +108 -0
  182. package/.forge/worktrees/pipeline-4dd8dc2d/lib/password.ts +97 -0
  183. package/.forge/worktrees/pipeline-4dd8dc2d/lib/pipeline-scheduler.ts +373 -0
  184. package/.forge/worktrees/pipeline-4dd8dc2d/lib/pipeline.ts +1565 -0
  185. package/.forge/worktrees/pipeline-4dd8dc2d/lib/plugins/executor.ts +347 -0
  186. package/.forge/worktrees/pipeline-4dd8dc2d/lib/plugins/registry.ts +228 -0
  187. package/.forge/worktrees/pipeline-4dd8dc2d/lib/plugins/types.ts +103 -0
  188. package/.forge/worktrees/pipeline-4dd8dc2d/lib/project-sessions.ts +53 -0
  189. package/.forge/worktrees/pipeline-4dd8dc2d/lib/projects.ts +86 -0
  190. package/.forge/worktrees/pipeline-4dd8dc2d/lib/session-manager.ts +156 -0
  191. package/.forge/worktrees/pipeline-4dd8dc2d/lib/session-utils.ts +53 -0
  192. package/.forge/worktrees/pipeline-4dd8dc2d/lib/session-watcher.ts +345 -0
  193. package/.forge/worktrees/pipeline-4dd8dc2d/lib/settings.ts +195 -0
  194. package/.forge/worktrees/pipeline-4dd8dc2d/lib/skills.ts +458 -0
  195. package/.forge/worktrees/pipeline-4dd8dc2d/lib/task-manager.ts +951 -0
  196. package/.forge/worktrees/pipeline-4dd8dc2d/lib/telegram-bot.ts +1477 -0
  197. package/.forge/worktrees/pipeline-4dd8dc2d/lib/telegram-standalone.ts +83 -0
  198. package/.forge/worktrees/pipeline-4dd8dc2d/lib/terminal-server.ts +70 -0
  199. package/.forge/worktrees/pipeline-4dd8dc2d/lib/terminal-standalone.ts +438 -0
  200. package/.forge/worktrees/pipeline-4dd8dc2d/lib/usage-scanner.ts +249 -0
  201. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/__tests__/state-machine.test.ts +388 -0
  202. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/__tests__/workspace.test.ts +311 -0
  203. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/agent-bus.ts +416 -0
  204. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/agent-worker.ts +655 -0
  205. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/backends/api-backend.ts +262 -0
  206. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/backends/cli-backend.ts +491 -0
  207. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/index.ts +84 -0
  208. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/manager.ts +136 -0
  209. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/orchestrator.ts +3415 -0
  210. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/persistence.ts +309 -0
  211. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/presets.ts +649 -0
  212. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/requests.ts +287 -0
  213. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/session-monitor.ts +240 -0
  214. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/skill-installer.ts +275 -0
  215. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/smith-memory.ts +498 -0
  216. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/types.ts +241 -0
  217. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace/watch-manager.ts +560 -0
  218. package/.forge/worktrees/pipeline-4dd8dc2d/lib/workspace-standalone.ts +978 -0
  219. package/.forge/worktrees/pipeline-4dd8dc2d/middleware.ts +51 -0
  220. package/.forge/worktrees/pipeline-4dd8dc2d/next.config.ts +26 -0
  221. package/.forge/worktrees/pipeline-4dd8dc2d/package.json +74 -0
  222. package/.forge/worktrees/pipeline-4dd8dc2d/pnpm-lock.yaml +3719 -0
  223. package/.forge/worktrees/pipeline-4dd8dc2d/pnpm-workspace.yaml +1 -0
  224. package/.forge/worktrees/pipeline-4dd8dc2d/postcss.config.mjs +7 -0
  225. package/.forge/worktrees/pipeline-4dd8dc2d/publish.sh +133 -0
  226. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/README.md +66 -0
  227. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/results/.gitignore +2 -0
  228. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/run.ts +635 -0
  229. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/tasks/01-text-utils/task.md +26 -0
  230. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/tasks/01-text-utils/validator.sh +46 -0
  231. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/tasks/02-pagination/setup.sh +19 -0
  232. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/tasks/02-pagination/task.md +48 -0
  233. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/tasks/02-pagination/validator.sh +69 -0
  234. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/tasks/03-bug-fix/setup.sh +82 -0
  235. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/tasks/03-bug-fix/task.md +30 -0
  236. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/bench/tasks/03-bug-fix/validator.sh +29 -0
  237. package/.forge/worktrees/pipeline-4dd8dc2d/scripts/verify-usage.ts +178 -0
  238. package/.forge/worktrees/pipeline-4dd8dc2d/src/config/index.ts +129 -0
  239. package/.forge/worktrees/pipeline-4dd8dc2d/src/core/db/database.ts +259 -0
  240. package/.forge/worktrees/pipeline-4dd8dc2d/src/core/memory/strategy.ts +32 -0
  241. package/.forge/worktrees/pipeline-4dd8dc2d/src/core/providers/chat.ts +65 -0
  242. package/.forge/worktrees/pipeline-4dd8dc2d/src/core/providers/registry.ts +60 -0
  243. package/.forge/worktrees/pipeline-4dd8dc2d/src/core/session/manager.ts +190 -0
  244. package/.forge/worktrees/pipeline-4dd8dc2d/src/types/index.ts +129 -0
  245. package/.forge/worktrees/pipeline-4dd8dc2d/start.sh +32 -0
  246. package/.forge/worktrees/pipeline-4dd8dc2d/templates/smith-lead.json +45 -0
  247. package/.forge/worktrees/pipeline-4dd8dc2d/tsconfig.json +42 -0
  248. package/RELEASE_NOTES.md +10 -29
  249. package/app/api/terminal-bell/route.ts +6 -2
  250. package/app/api/terminal-cwd/route.ts +7 -4
  251. package/components/CodeViewer.tsx +3 -31
  252. package/components/Dashboard.tsx +34 -20
  253. package/components/WebTerminal.tsx +36 -2
  254. package/lib/terminal-standalone.ts +19 -2
  255. package/package.json +1 -1
@@ -0,0 +1,574 @@
1
+ 'use client';
2
+
3
+ import { useState, useEffect, useCallback, useRef, lazy, Suspense } from 'react';
4
+ import { useSidebarResize } from '@/hooks/useSidebarResize';
5
+ import MarkdownContent from './MarkdownContent';
6
+ import TabBar from './TabBar';
7
+
8
+ const DocTerminal = lazy(() => import('./DocTerminal'));
9
+
10
+ interface DocTab {
11
+ id: number;
12
+ filePath: string;
13
+ fileName: string;
14
+ rootIdx: number;
15
+ content: string | null;
16
+ isImage: boolean;
17
+ }
18
+
19
+ function genTabId(): number { return Date.now() + Math.floor(Math.random() * 10000); }
20
+
21
+ interface FileNode {
22
+ name: string;
23
+ path: string;
24
+ type: 'file' | 'dir';
25
+ fileType?: 'md' | 'image' | 'other';
26
+ children?: FileNode[];
27
+ }
28
+
29
+ // ─── File Tree ───────────────────────────────────────────
30
+
31
+ function TreeNode({ node, depth, selected, onSelect }: {
32
+ node: FileNode;
33
+ depth: number;
34
+ selected: string | null;
35
+ onSelect: (path: string) => void;
36
+ }) {
37
+ const [expanded, setExpanded] = useState(depth < 1);
38
+
39
+ if (node.type === 'dir') {
40
+ return (
41
+ <div>
42
+ <button
43
+ onClick={() => setExpanded(v => !v)}
44
+ className="w-full text-left flex items-center gap-1 px-1 py-0.5 hover:bg-[var(--bg-tertiary)] rounded text-xs"
45
+ style={{ paddingLeft: depth * 12 + 4 }}
46
+ >
47
+ <span className="text-[10px] text-[var(--text-secondary)] w-3">{expanded ? '▾' : '▸'}</span>
48
+ <span className="text-[var(--text-primary)]">{node.name}</span>
49
+ </button>
50
+ {expanded && node.children?.map(child => (
51
+ <TreeNode key={child.path} node={child} depth={depth + 1} selected={selected} onSelect={onSelect} />
52
+ ))}
53
+ </div>
54
+ );
55
+ }
56
+
57
+ const isSelected = selected === node.path;
58
+
59
+ return (
60
+ <button
61
+ onClick={() => onSelect(node.path)}
62
+ className={`w-full text-left flex items-center gap-1 px-1 py-0.5 rounded text-xs truncate ${
63
+ isSelected ? 'bg-[var(--accent)]/20 text-[var(--accent)]'
64
+ : 'hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)]'
65
+ }`}
66
+ style={{ paddingLeft: depth * 12 + 16 }}
67
+ title={node.path}
68
+ >
69
+ {node.fileType === 'image' ? '🖼 ' : ''}{node.name}
70
+ </button>
71
+ );
72
+ }
73
+
74
+ // ─── Search ──────────────────────────────────────────────
75
+
76
+ function flattenTree(nodes: FileNode[]): FileNode[] {
77
+ const result: FileNode[] = [];
78
+ for (const node of nodes) {
79
+ if (node.type === 'file') result.push(node);
80
+ if (node.children) result.push(...flattenTree(node.children));
81
+ }
82
+ return result;
83
+ }
84
+
85
+ const BINARY_EXTS = /\.(png|jpg|jpeg|gif|bmp|ico|webp|avif|mp3|mp4|wav|ogg|webm|mov|avi|zip|gz|tar|bz2|xz|7z|rar|pdf|doc|docx|xls|xlsx|ppt|pptx|exe|dll|so|dylib|bin|woff|woff2|ttf|eot|otf|sqlite|db|class|jar|pyc|wasm|o|a)$/i;
86
+
87
+ function filterTree(nodes: FileNode[]): FileNode[] {
88
+ return nodes.reduce<FileNode[]>((acc, node) => {
89
+ if (node.type === 'dir') {
90
+ const children = filterTree(node.children || []);
91
+ if (children.length > 0) acc.push({ ...node, children });
92
+ } else if (!BINARY_EXTS.test(node.name)) {
93
+ acc.push(node);
94
+ }
95
+ return acc;
96
+ }, []);
97
+ }
98
+
99
+ // ─── Main Component ──────────────────────────────────────
100
+
101
+ export default function DocsViewer() {
102
+ const [roots, setRoots] = useState<string[]>([]);
103
+ const [rootPaths, setRootPaths] = useState<string[]>([]);
104
+ const [activeRoot, setActiveRoot] = useState(0);
105
+ const [tree, setTree] = useState<FileNode[]>([]);
106
+ const [selectedFile, setSelectedFile] = useState<string | null>(null);
107
+ const [content, setContent] = useState<string | null>(null);
108
+ const [loading, setLoading] = useState(false);
109
+ const [search, setSearch] = useState('');
110
+ const [terminalHeight, setTerminalHeight] = useState(250);
111
+ const [docsAgent, setDocsAgent] = useState('');
112
+ const [sidebarOpen, setSidebarOpen] = useState(true);
113
+ const [editing, setEditing] = useState(false);
114
+ const [editContent, setEditContent] = useState('');
115
+ const [saving, setSaving] = useState(false);
116
+ const dragRef = useRef<{ startY: number; startH: number } | null>(null);
117
+ const { sidebarWidth, onSidebarDragStart } = useSidebarResize({ defaultWidth: 224, minWidth: 120, maxWidth: 480 });
118
+
119
+ // Doc tabs
120
+ const [docTabs, setDocTabs] = useState<DocTab[]>([]);
121
+ const [activeDocTabId, setActiveDocTabId] = useState(0);
122
+ const saveTimerRef = useRef<any>(null);
123
+
124
+ // Load tabs from DB on mount
125
+ useEffect(() => {
126
+ fetch('/api/tabs?type=docs').then(r => r.json())
127
+ .then(data => {
128
+ if (Array.isArray(data.tabs) && data.tabs.length > 0) {
129
+ setDocTabs(data.tabs);
130
+ setActiveDocTabId(data.activeTabId || data.tabs[0].id);
131
+ // Set selectedFile to active tab's file
132
+ const activeId = data.activeTabId || data.tabs[0].id;
133
+ const active = data.tabs.find((t: any) => t.id === activeId);
134
+ if (active) {
135
+ setSelectedFile(active.filePath);
136
+ // Content not stored in DB, fetch it
137
+ if (!active.isImage) {
138
+ fetch(`/api/docs?root=${active.rootIdx}&file=${encodeURIComponent(active.filePath)}`)
139
+ .then(r => r.json())
140
+ .then(d => { setContent(d.content || null); })
141
+ .catch(() => {});
142
+ }
143
+ }
144
+ }
145
+ }).catch(() => {});
146
+ }, []);
147
+
148
+ // Persist tabs (debounced)
149
+ const persistDocTabs = useCallback((tabs: DocTab[], activeId: number) => {
150
+ if (saveTimerRef.current) clearTimeout(saveTimerRef.current);
151
+ saveTimerRef.current = setTimeout(() => {
152
+ fetch('/api/tabs?type=docs', {
153
+ method: 'POST',
154
+ headers: { 'Content-Type': 'application/json' },
155
+ body: JSON.stringify({
156
+ tabs: tabs.map(t => ({ id: t.id, filePath: t.filePath, fileName: t.fileName, rootIdx: t.rootIdx, isImage: t.isImage })),
157
+ activeTabId: activeId,
158
+ }),
159
+ }).catch(() => {});
160
+ }, 500);
161
+ }, []);
162
+
163
+ // Open file in tab
164
+ const openFileInTab = useCallback(async (path: string) => {
165
+ setSelectedFile(path);
166
+ setEditing(false);
167
+ setFileWarning(null);
168
+
169
+ const isImg = isImageFile(path);
170
+ const fileName = path.split('/').pop() || path;
171
+
172
+ // Check if tab already exists (use functional update to get latest state)
173
+ let found = false;
174
+ setDocTabs(prev => {
175
+ const existing = prev.find(t => t.filePath === path);
176
+ if (existing) {
177
+ found = true;
178
+ setActiveDocTabId(existing.id);
179
+ setContent(existing.content);
180
+ persistDocTabs(prev, existing.id);
181
+ }
182
+ return prev;
183
+ });
184
+ if (found) return;
185
+
186
+ // Fetch content
187
+ let fileContent: string | null = null;
188
+ if (!isImg) {
189
+ setLoading(true);
190
+ const res = await fetch(`/api/docs?root=${activeRoot}&file=${encodeURIComponent(path)}`);
191
+ const data = await res.json();
192
+ if (data.binary) {
193
+ setFileWarning(`${data.fileType?.toUpperCase() || 'Binary'} file — ${data.sizeLabel} — cannot be displayed`);
194
+ } else if (data.tooLarge) {
195
+ setFileWarning(`File too large (${data.sizeLabel})`);
196
+ } else {
197
+ fileContent = data.content || null;
198
+ }
199
+ setLoading(false);
200
+ }
201
+ setContent(fileContent);
202
+
203
+ const MAX_TABS = 8;
204
+ const newTab: DocTab = { id: genTabId(), filePath: path, fileName, rootIdx: activeRoot, isImage: isImg, content: fileContent };
205
+ setDocTabs(prev => {
206
+ if (prev.find(t => t.filePath === path)) return prev;
207
+ let updated = [...prev, newTab];
208
+ // Auto-close oldest tabs if over limit
209
+ while (updated.length > MAX_TABS) {
210
+ updated = updated.slice(1);
211
+ }
212
+ setActiveDocTabId(newTab.id);
213
+ persistDocTabs(updated, newTab.id);
214
+ return updated;
215
+ });
216
+ }, [activeRoot, persistDocTabs]);
217
+
218
+ const closeDocTab = useCallback((tabId: number) => {
219
+ setDocTabs(prev => {
220
+ const updated = prev.filter(t => t.id !== tabId);
221
+ let newActiveId = activeDocTabId;
222
+ if (tabId === activeDocTabId) {
223
+ const idx = prev.findIndex(t => t.id === tabId);
224
+ const next = updated[Math.min(idx, updated.length - 1)];
225
+ newActiveId = next?.id || 0;
226
+ if (next) { setSelectedFile(next.filePath); setContent(next.content); }
227
+ else { setSelectedFile(null); setContent(null); }
228
+ }
229
+ setActiveDocTabId(newActiveId);
230
+ persistDocTabs(updated, newActiveId);
231
+ return updated;
232
+ });
233
+ }, [activeDocTabId, persistDocTabs]);
234
+
235
+ const activateDocTab = useCallback(async (tabId: number) => {
236
+ const tab = docTabs.find(t => t.id === tabId);
237
+ if (tab) {
238
+ setActiveDocTabId(tabId);
239
+ setSelectedFile(tab.filePath);
240
+ setEditing(false);
241
+ if (tab.rootIdx !== activeRoot) setActiveRoot(tab.rootIdx);
242
+ persistDocTabs(docTabs, tabId);
243
+
244
+ // Use cached content or re-fetch
245
+ if (tab.content) {
246
+ setContent(tab.content);
247
+ } else if (!tab.isImage) {
248
+ setLoading(true);
249
+ const res = await fetch(`/api/docs?root=${tab.rootIdx}&file=${encodeURIComponent(tab.filePath)}`);
250
+ const data = await res.json();
251
+ const fetched = data.content || null;
252
+ setContent(fetched);
253
+ // Cache in tab
254
+ setDocTabs(prev => prev.map(t => t.id === tabId ? { ...t, content: fetched } : t));
255
+ setLoading(false);
256
+ }
257
+ }
258
+ }, [docTabs, activeRoot, persistDocTabs]);
259
+
260
+ // Fetch tree
261
+ const fetchTree = useCallback(async (rootIdx: number) => {
262
+ const res = await fetch(`/api/docs?root=${rootIdx}`);
263
+ const data = await res.json();
264
+ setRoots(data.roots || []);
265
+ setRootPaths(data.rootPaths || []);
266
+ setTree(data.tree || []);
267
+ }, []);
268
+
269
+ useEffect(() => { fetchTree(activeRoot); }, [activeRoot, fetchTree]);
270
+
271
+ // Fetch agent config for doc roots
272
+ useEffect(() => {
273
+ fetch('/api/settings').then(r => r.json())
274
+ .then((s: any) => setDocsAgent(s.docsAgent || ''))
275
+ .catch(() => {});
276
+ }, []);
277
+
278
+ // Re-fetch when tab becomes visible (settings may have changed)
279
+ useEffect(() => {
280
+ const handleVisibility = () => {
281
+ if (!document.hidden) fetchTree(activeRoot);
282
+ };
283
+ document.addEventListener('visibilitychange', handleVisibility);
284
+ return () => document.removeEventListener('visibilitychange', handleVisibility);
285
+ }, [activeRoot, fetchTree]);
286
+
287
+ const [fileWarning, setFileWarning] = useState<string | null>(null);
288
+ const [hideUnsupported, setHideUnsupported] = useState(true);
289
+
290
+ // Fetch file content
291
+ const isImageFile = (path: string) => /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|avif)$/i.test(path);
292
+
293
+ const openFile = useCallback(async (path: string) => {
294
+ setSelectedFile(path);
295
+ setFileWarning(null);
296
+
297
+ if (isImageFile(path)) {
298
+ setContent(null);
299
+ setLoading(false);
300
+ return; // images rendered directly via img tag
301
+ }
302
+
303
+ setLoading(true);
304
+ const res = await fetch(`/api/docs?root=${activeRoot}&file=${encodeURIComponent(path)}`);
305
+ const data = await res.json();
306
+ if (data.tooLarge) {
307
+ setContent(null);
308
+ setFileWarning(`File too large (${data.sizeLabel})`);
309
+ } else {
310
+ setContent(data.content || null);
311
+ }
312
+ setLoading(false);
313
+ }, [activeRoot]);
314
+
315
+ // Search filter
316
+ const allFiles = flattenTree(tree);
317
+ const filtered = search
318
+ ? allFiles.filter(f => f.name.toLowerCase().includes(search.toLowerCase()) || f.path.toLowerCase().includes(search.toLowerCase()))
319
+ : null;
320
+
321
+ // Drag to resize terminal
322
+ const onDragStart = (e: React.MouseEvent) => {
323
+ e.preventDefault();
324
+ dragRef.current = { startY: e.clientY, startH: terminalHeight };
325
+ const onMove = (ev: MouseEvent) => {
326
+ if (!dragRef.current) return;
327
+ const delta = dragRef.current.startY - ev.clientY;
328
+ setTerminalHeight(Math.max(100, Math.min(500, dragRef.current.startH + delta)));
329
+ };
330
+ const onUp = () => {
331
+ dragRef.current = null;
332
+ window.removeEventListener('mousemove', onMove);
333
+ window.removeEventListener('mouseup', onUp);
334
+ };
335
+ window.addEventListener('mousemove', onMove);
336
+ window.addEventListener('mouseup', onUp);
337
+ };
338
+
339
+ if (roots.length === 0) {
340
+ return (
341
+ <div className="flex-1 flex items-center justify-center text-[var(--text-secondary)]">
342
+ <div className="text-center space-y-2">
343
+ <p className="text-lg">No document directories configured</p>
344
+ <p className="text-xs">Add directories in Settings → Document Roots</p>
345
+ </div>
346
+ </div>
347
+ );
348
+ }
349
+
350
+ return (
351
+ <div className="flex-1 flex flex-col min-h-0 min-w-0 overflow-hidden">
352
+ {/* Doc content area */}
353
+ <div className="flex-1 flex min-h-0 min-w-0 overflow-hidden">
354
+ {/* Collapsible sidebar — file tree */}
355
+ {sidebarOpen && (
356
+ <aside style={{ width: sidebarWidth }} className="flex flex-col shrink-0 overflow-hidden">
357
+ {/* Root selector */}
358
+ {roots.length > 0 && (
359
+ <div className="p-2 border-b border-[var(--border)]">
360
+ <select
361
+ value={activeRoot}
362
+ onChange={e => { setActiveRoot(Number(e.target.value)); setSelectedFile(null); setContent(null); }}
363
+ className="w-full text-xs bg-[var(--bg-tertiary)] border border-[var(--border)] rounded px-2 py-1 text-[var(--text-primary)]"
364
+ >
365
+ {roots.map((r, i) => <option key={i} value={i}>{r}</option>)}
366
+ </select>
367
+ </div>
368
+ )}
369
+
370
+ {/* Header with refresh */}
371
+ <div className="px-3 py-1.5 border-b border-[var(--border)] flex items-center">
372
+ <span className="text-[10px] text-[var(--text-secondary)] truncate">{roots[activeRoot] || 'Docs'}</span>
373
+ <button
374
+ onClick={() => setHideUnsupported(v => !v)}
375
+ className={`text-[9px] ml-auto shrink-0 px-1 rounded ${hideUnsupported ? 'text-[var(--accent)]' : 'text-[var(--text-secondary)]'} hover:text-[var(--text-primary)]`}
376
+ title={hideUnsupported ? 'Show all files' : 'Hide binary files'}
377
+ >
378
+ {hideUnsupported ? 'Docs' : 'All'}
379
+ </button>
380
+ <button
381
+ onClick={() => { fetchTree(activeRoot); if (selectedFile) openFile(selectedFile); }}
382
+ className="text-[9px] text-[var(--text-secondary)] hover:text-[var(--text-primary)] shrink-0"
383
+ title="Refresh files"
384
+ >
385
+
386
+ </button>
387
+ </div>
388
+
389
+ {/* Search */}
390
+ <div className="p-2 border-b border-[var(--border)]">
391
+ <input
392
+ type="text"
393
+ placeholder="Search..."
394
+ value={search}
395
+ onChange={e => setSearch(e.target.value)}
396
+ className="w-full text-xs bg-[var(--bg-tertiary)] border border-[var(--border)] rounded px-2 py-1 text-[var(--text-primary)] focus:outline-none focus:border-[var(--accent)]"
397
+ />
398
+ </div>
399
+
400
+ {/* Tree / search results */}
401
+ <div className="flex-1 overflow-y-auto p-1">
402
+ {filtered ? (
403
+ filtered.length === 0 ? (
404
+ <div className="text-xs text-[var(--text-secondary)] p-2">No matches</div>
405
+ ) : (
406
+ filtered.map(f => (
407
+ <button
408
+ key={f.path}
409
+ onClick={() => { openFileInTab(f.path); setSearch(''); }}
410
+ className={`w-full text-left px-2 py-1 rounded text-xs truncate ${
411
+ selectedFile === f.path ? 'bg-[var(--accent)]/20 text-[var(--accent)]' : 'hover:bg-[var(--bg-tertiary)] text-[var(--text-secondary)]'
412
+ }`}
413
+ title={f.path}
414
+ >
415
+ <span className="text-[var(--text-primary)]">{f.name.replace(/\.md$/, '')}</span>
416
+ <span className="text-[9px] text-[var(--text-secondary)] ml-1">{f.path.split('/').slice(0, -1).join('/')}</span>
417
+ </button>
418
+ ))
419
+ )
420
+ ) : (
421
+ (hideUnsupported ? filterTree(tree) : tree).map(node => (
422
+ <TreeNode key={node.path} node={node} depth={0} selected={selectedFile} onSelect={openFileInTab} />
423
+ ))
424
+ )}
425
+ </div>
426
+ </aside>
427
+ )}
428
+
429
+ {/* Sidebar resize handle */}
430
+ {sidebarOpen && (
431
+ <div
432
+ onMouseDown={onSidebarDragStart}
433
+ className="w-1 bg-[var(--border)] cursor-col-resize shrink-0 hover:bg-[var(--accent)]/50 transition-colors"
434
+ />
435
+ )}
436
+
437
+ {/* Main content */}
438
+ <main className="flex-1 flex flex-col min-w-0">
439
+ {/* Doc tab bar */}
440
+ {docTabs.length > 0 && (
441
+ <TabBar
442
+ tabs={docTabs.map(t => ({ id: t.id, label: t.fileName.replace(/\.md$/, '') }))}
443
+ activeId={activeDocTabId}
444
+ onActivate={activateDocTab}
445
+ onClose={closeDocTab}
446
+ />
447
+ )}
448
+
449
+ {/* Top bar */}
450
+ <div className="px-3 py-1.5 border-b border-[var(--border)] shrink-0 flex items-center gap-2">
451
+ <button
452
+ onClick={() => setSidebarOpen(v => !v)}
453
+ className="text-[10px] px-1.5 py-0.5 text-gray-400 hover:text-white hover:bg-[var(--bg-tertiary)] rounded"
454
+ title={sidebarOpen ? 'Hide sidebar' : 'Show sidebar'}
455
+ >
456
+ {sidebarOpen ? '◀' : '▶'}
457
+ </button>
458
+ {selectedFile ? (
459
+ <>
460
+ <span className="text-xs font-semibold text-[var(--text-primary)] truncate">{selectedFile.replace(/\.md$/, '')}</span>
461
+ <span className="text-[9px] text-[var(--text-secondary)] ml-auto mr-2">{selectedFile}</span>
462
+ {content && !isImageFile(selectedFile) && !editing && (
463
+ <button
464
+ onClick={() => { setEditing(true); setEditContent(content); }}
465
+ className="text-[9px] px-2 py-0.5 border border-[var(--border)] rounded text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:border-[var(--text-secondary)] shrink-0"
466
+ >
467
+ Edit
468
+ </button>
469
+ )}
470
+ {editing && (
471
+ <>
472
+ <button
473
+ disabled={saving}
474
+ onClick={async () => {
475
+ setSaving(true);
476
+ await fetch('/api/docs', {
477
+ method: 'PUT',
478
+ headers: { 'Content-Type': 'application/json' },
479
+ body: JSON.stringify({ root: activeRoot, file: selectedFile, content: editContent }),
480
+ });
481
+ setContent(editContent);
482
+ setEditing(false);
483
+ setSaving(false);
484
+ }}
485
+ className="text-[9px] px-2 py-0.5 bg-[var(--accent)] text-white rounded hover:opacity-90 disabled:opacity-50 shrink-0"
486
+ >
487
+ {saving ? 'Saving...' : 'Save'}
488
+ </button>
489
+ <button
490
+ onClick={() => setEditing(false)}
491
+ className="text-[9px] px-2 py-0.5 text-[var(--text-secondary)] hover:text-[var(--text-primary)] shrink-0"
492
+ >
493
+ Cancel
494
+ </button>
495
+ </>
496
+ )}
497
+ </>
498
+ ) : (
499
+ <span className="text-xs text-[var(--text-secondary)]">{roots[activeRoot] || 'Docs'}</span>
500
+ )}
501
+ </div>
502
+
503
+ {/* Content */}
504
+ {fileWarning ? (
505
+ <div className="flex-1 flex items-center justify-center text-[var(--text-secondary)]">
506
+ <div className="text-center space-y-2">
507
+ <div className="text-3xl">⚠️</div>
508
+ <p className="text-sm">{fileWarning}</p>
509
+ </div>
510
+ </div>
511
+ ) : selectedFile && isImageFile(selectedFile) ? (
512
+ <div className="flex-1 overflow-auto flex items-center justify-center p-6 bg-[var(--bg-tertiary)]">
513
+ <img
514
+ src={`/api/docs?root=${activeRoot}&image=${encodeURIComponent(selectedFile)}`}
515
+ alt={selectedFile}
516
+ className="max-w-full max-h-full object-contain rounded shadow-lg"
517
+ />
518
+ </div>
519
+ ) : selectedFile && content ? (
520
+ editing ? (
521
+ <div className="flex-1 overflow-hidden flex flex-col">
522
+ <textarea
523
+ value={editContent}
524
+ onChange={e => setEditContent(e.target.value)}
525
+ className="flex-1 w-full p-4 bg-[var(--bg-primary)] text-[var(--text-primary)] text-[13px] font-mono leading-relaxed resize-none focus:outline-none"
526
+ style={{ tabSize: 2 }}
527
+ spellCheck={false}
528
+ />
529
+ </div>
530
+ ) : selectedFile.endsWith('.md') ? (
531
+ <div className="flex-1 overflow-y-auto px-8 py-6">
532
+ {loading ? (
533
+ <div className="text-xs text-[var(--text-secondary)]">Loading...</div>
534
+ ) : (
535
+ <div className="max-w-none">
536
+ <MarkdownContent content={content} />
537
+ </div>
538
+ )}
539
+ </div>
540
+ ) : (
541
+ <div className="flex-1 overflow-y-auto">
542
+ <pre className="p-4 text-[12px] leading-[1.5] font-mono text-[var(--text-primary)] whitespace-pre" style={{ fontFamily: 'Menlo, Monaco, "Courier New", monospace', tabSize: 2 }}>
543
+ {content.split('\n').map((line, i) => (
544
+ <div key={i} className="flex hover:bg-[var(--bg-tertiary)]/50">
545
+ <span className="select-none text-[var(--text-secondary)]/40 text-right pr-4 w-10 shrink-0">{i + 1}</span>
546
+ <span className="flex-1">{line || ' '}</span>
547
+ </div>
548
+ ))}
549
+ </pre>
550
+ </div>
551
+ )
552
+ ) : (
553
+ <div className="flex-1 flex items-center justify-center text-[var(--text-secondary)]">
554
+ <p className="text-xs">Select a document to view</p>
555
+ </div>
556
+ )}
557
+ </main>
558
+ </div>
559
+
560
+ {/* Resize handle */}
561
+ <div
562
+ onMouseDown={onDragStart}
563
+ className="h-1 bg-[var(--border)] cursor-row-resize hover:bg-[var(--accent)]/50 shrink-0"
564
+ />
565
+
566
+ {/* Bottom — Agent console */}
567
+ <div className="shrink-0" style={{ height: terminalHeight }}>
568
+ <Suspense fallback={<div className="h-full flex items-center justify-center text-[var(--text-secondary)] text-xs">Loading...</div>}>
569
+ <DocTerminal docRoot={rootPaths[activeRoot] || ''} agent={docsAgent || undefined} />
570
+ </Suspense>
571
+ </div>
572
+ </div>
573
+ );
574
+ }