claude-mux 0.7.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.
- package/.beads/README.md +81 -0
- package/.beads/config.yaml +62 -0
- package/.beads/interactions.jsonl +0 -0
- package/.beads/issues.jsonl +5 -0
- package/.beads/metadata.json +4 -0
- package/.eslintrc.json +25 -0
- package/.gitattributes +3 -0
- package/.prettierrc +7 -0
- package/CLAUDE.md +123 -0
- package/LICENSE +21 -0
- package/PLAN-beads-integration.md +250 -0
- package/README.md +366 -0
- package/dist/app.d.ts +2 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +147 -0
- package/dist/app.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +65 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +5 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/serve.d.ts +8 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +59 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/setup.d.ts +4 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +12 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/tui.d.ts +9 -0
- package/dist/commands/tui.d.ts.map +1 -0
- package/dist/commands/tui.js +234 -0
- package/dist/commands/tui.js.map +1 -0
- package/dist/commands/uninstall.d.ts +4 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +12 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/components/Header.d.ts +7 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +14 -0
- package/dist/components/Header.js.map +1 -0
- package/dist/components/HelpDialog.d.ts +6 -0
- package/dist/components/HelpDialog.d.ts.map +1 -0
- package/dist/components/HelpDialog.js +14 -0
- package/dist/components/HelpDialog.js.map +1 -0
- package/dist/components/SessionEntry.d.ts +17 -0
- package/dist/components/SessionEntry.d.ts.map +1 -0
- package/dist/components/SessionEntry.js +102 -0
- package/dist/components/SessionEntry.js.map +1 -0
- package/dist/components/SessionList.d.ts +14 -0
- package/dist/components/SessionList.d.ts.map +1 -0
- package/dist/components/SessionList.js +57 -0
- package/dist/components/SessionList.js.map +1 -0
- package/dist/components/StatusBar.d.ts +6 -0
- package/dist/components/StatusBar.d.ts.map +1 -0
- package/dist/components/StatusBar.js +7 -0
- package/dist/components/StatusBar.js.map +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +3 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +4 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +23 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/db/sessions-json.d.ts +85 -0
- package/dist/db/sessions-json.d.ts.map +1 -0
- package/dist/db/sessions-json.js +242 -0
- package/dist/db/sessions-json.js.map +1 -0
- package/dist/db/sessions.d.ts +38 -0
- package/dist/db/sessions.d.ts.map +1 -0
- package/dist/db/sessions.js +87 -0
- package/dist/db/sessions.js.map +1 -0
- package/dist/hooks/claude-mux-hook.d.ts +15 -0
- package/dist/hooks/claude-mux-hook.d.ts.map +1 -0
- package/dist/hooks/claude-mux-hook.js +396 -0
- package/dist/hooks/claude-mux-hook.js.map +1 -0
- package/dist/hooks/claude-watch-hook.d.ts +15 -0
- package/dist/hooks/claude-watch-hook.d.ts.map +1 -0
- package/dist/hooks/claude-watch-hook.js +396 -0
- package/dist/hooks/claude-watch-hook.js.map +1 -0
- package/dist/server/custom-server.d.ts +13 -0
- package/dist/server/custom-server.d.ts.map +1 -0
- package/dist/server/custom-server.js +63 -0
- package/dist/server/custom-server.js.map +1 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +1143 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/middleware/cors.d.ts +2 -0
- package/dist/server/middleware/cors.d.ts.map +1 -0
- package/dist/server/middleware/cors.js +11 -0
- package/dist/server/middleware/cors.js.map +1 -0
- package/dist/server/routes/sessions.d.ts +3 -0
- package/dist/server/routes/sessions.d.ts.map +1 -0
- package/dist/server/routes/sessions.js +78 -0
- package/dist/server/routes/sessions.js.map +1 -0
- package/dist/server/routes/stream.d.ts +3 -0
- package/dist/server/routes/stream.d.ts.map +1 -0
- package/dist/server/routes/stream.js +45 -0
- package/dist/server/routes/stream.js.map +1 -0
- package/dist/server/types.d.ts +28 -0
- package/dist/server/types.d.ts.map +1 -0
- package/dist/server/types.js +2 -0
- package/dist/server/types.js.map +1 -0
- package/dist/server/watcher.d.ts +22 -0
- package/dist/server/watcher.d.ts.map +1 -0
- package/dist/server/watcher.js +119 -0
- package/dist/server/watcher.js.map +1 -0
- package/dist/server/websocket.d.ts +51 -0
- package/dist/server/websocket.d.ts.map +1 -0
- package/dist/server/websocket.js +156 -0
- package/dist/server/websocket.js.map +1 -0
- package/dist/server/ws-handlers.d.ts +174 -0
- package/dist/server/ws-handlers.d.ts.map +1 -0
- package/dist/server/ws-handlers.js +695 -0
- package/dist/server/ws-handlers.js.map +1 -0
- package/dist/setup/hooks.d.ts +44 -0
- package/dist/setup/hooks.d.ts.map +1 -0
- package/dist/setup/hooks.js +267 -0
- package/dist/setup/hooks.js.map +1 -0
- package/dist/setup/index.d.ts +3 -0
- package/dist/setup/index.d.ts.map +1 -0
- package/dist/setup/index.js +3 -0
- package/dist/setup/index.js.map +1 -0
- package/dist/setup/wizard.d.ts +4 -0
- package/dist/setup/wizard.d.ts.map +1 -0
- package/dist/setup/wizard.js +72 -0
- package/dist/setup/wizard.js.map +1 -0
- package/dist/tmux/detect.d.ts +25 -0
- package/dist/tmux/detect.d.ts.map +1 -0
- package/dist/tmux/detect.js +71 -0
- package/dist/tmux/detect.js.map +1 -0
- package/dist/tmux/navigate.d.ts +13 -0
- package/dist/tmux/navigate.d.ts.map +1 -0
- package/dist/tmux/navigate.js +41 -0
- package/dist/tmux/navigate.js.map +1 -0
- package/dist/tmux/pane.d.ts +57 -0
- package/dist/tmux/pane.d.ts.map +1 -0
- package/dist/tmux/pane.js +156 -0
- package/dist/tmux/pane.js.map +1 -0
- package/dist/tmux/resize.d.ts +10 -0
- package/dist/tmux/resize.d.ts.map +1 -0
- package/dist/tmux/resize.js +25 -0
- package/dist/tmux/resize.js.map +1 -0
- package/dist/utils/paths.d.ts +7 -0
- package/dist/utils/paths.d.ts.map +1 -0
- package/dist/utils/paths.js +9 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/pid.d.ts +5 -0
- package/dist/utils/pid.d.ts.map +1 -0
- package/dist/utils/pid.js +14 -0
- package/dist/utils/pid.js.map +1 -0
- package/dist/utils/version.d.ts +6 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +6 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/web/client/_app/immutable/assets/0.WptSHSUl.css +1 -0
- package/dist/web/client/_app/immutable/assets/2.s6Kx4oz1.css +1 -0
- package/dist/web/client/_app/immutable/assets/4.DoNWy7tW.css +1 -0
- package/dist/web/client/_app/immutable/assets/AllSessionsPanel.CGHY3HLy.css +1 -0
- package/dist/web/client/_app/immutable/chunks/-3mUPuLP.js +1 -0
- package/dist/web/client/_app/immutable/chunks/B5U4_V3d.js +1 -0
- package/dist/web/client/_app/immutable/chunks/BHwiZXRv.js +1 -0
- package/dist/web/client/_app/immutable/chunks/C9P-coqM.js +1 -0
- package/dist/web/client/_app/immutable/chunks/Cegv0r8x.js +1 -0
- package/dist/web/client/_app/immutable/chunks/DU91Ml7U.js +3 -0
- package/dist/web/client/_app/immutable/chunks/DmdO6ygw.js +1 -0
- package/dist/web/client/_app/immutable/chunks/HKNo9LID.js +5 -0
- package/dist/web/client/_app/immutable/chunks/U4ip-C0d.js +2 -0
- package/dist/web/client/_app/immutable/chunks/cgUjKIhX.js +2 -0
- package/dist/web/client/_app/immutable/entry/app.CGIBnoln.js +2 -0
- package/dist/web/client/_app/immutable/entry/start.CJk8zB1j.js +1 -0
- package/dist/web/client/_app/immutable/nodes/0.CqlJ9a31.js +1 -0
- package/dist/web/client/_app/immutable/nodes/1.BQUZh2-w.js +1 -0
- package/dist/web/client/_app/immutable/nodes/2.CCV1YdgF.js +1 -0
- package/dist/web/client/_app/immutable/nodes/3.D9tDCdq8.js +1 -0
- package/dist/web/client/_app/immutable/nodes/4.BqPyNkFA.js +6 -0
- package/dist/web/client/_app/version.json +1 -0
- package/dist/web/client/robots.txt +3 -0
- package/dist/web/env.js +32 -0
- package/dist/web/handler.js +744 -0
- package/dist/web/index.js +49 -0
- package/dist/web/server/chunks/0-BHWsmCJv.js +23 -0
- package/dist/web/server/chunks/0-BHWsmCJv.js.map +1 -0
- package/dist/web/server/chunks/1-YRx6A8Tm.js +17 -0
- package/dist/web/server/chunks/1-YRx6A8Tm.js.map +1 -0
- package/dist/web/server/chunks/2-eC6JuGAo.js +22 -0
- package/dist/web/server/chunks/2-eC6JuGAo.js.map +1 -0
- package/dist/web/server/chunks/3-Bk-wV20p.js +32 -0
- package/dist/web/server/chunks/3-Bk-wV20p.js.map +1 -0
- package/dist/web/server/chunks/4-nteBgDrW.js +21 -0
- package/dist/web/server/chunks/4-nteBgDrW.js.map +1 -0
- package/dist/web/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang-Bt4B0-oi.js +35 -0
- package/dist/web/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang-Bt4B0-oi.js.map +1 -0
- package/dist/web/server/chunks/_layout.svelte-BIF9eZCY.js +453 -0
- package/dist/web/server/chunks/_layout.svelte-BIF9eZCY.js.map +1 -0
- package/dist/web/server/chunks/_page.svelte-Be6iabRn.js +34 -0
- package/dist/web/server/chunks/_page.svelte-Be6iabRn.js.map +1 -0
- package/dist/web/server/chunks/_page.svelte-C_fGJVSE.js +576 -0
- package/dist/web/server/chunks/_page.svelte-C_fGJVSE.js.map +1 -0
- package/dist/web/server/chunks/_page.svelte-CnfJk6cu.js +2722 -0
- package/dist/web/server/chunks/_page.svelte-CnfJk6cu.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-3WAmKvn2.js +34 -0
- package/dist/web/server/chunks/_server.ts-3WAmKvn2.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BAWJCSFb.js +29 -0
- package/dist/web/server/chunks/_server.ts-BAWJCSFb.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BPpMOZCm.js +24 -0
- package/dist/web/server/chunks/_server.ts-BPpMOZCm.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BUKgRb6U.js +13 -0
- package/dist/web/server/chunks/_server.ts-BUKgRb6U.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BVHUS8fm.js +41 -0
- package/dist/web/server/chunks/_server.ts-BVHUS8fm.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-BrF3od0O.js +45 -0
- package/dist/web/server/chunks/_server.ts-BrF3od0O.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-C4oPmOJR.js +38 -0
- package/dist/web/server/chunks/_server.ts-C4oPmOJR.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-CDAUUmG_.js +21 -0
- package/dist/web/server/chunks/_server.ts-CDAUUmG_.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-CR0uWvpz.js +24 -0
- package/dist/web/server/chunks/_server.ts-CR0uWvpz.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-CSqdCNGi.js +21 -0
- package/dist/web/server/chunks/_server.ts-CSqdCNGi.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-DI9fzUo9.js +52 -0
- package/dist/web/server/chunks/_server.ts-DI9fzUo9.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-DNjJTClI.js +46 -0
- package/dist/web/server/chunks/_server.ts-DNjJTClI.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-DdbOAkOj.js +22 -0
- package/dist/web/server/chunks/_server.ts-DdbOAkOj.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-Df2isGQc.js +41 -0
- package/dist/web/server/chunks/_server.ts-Df2isGQc.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-Vpw25_-3.js +12 -0
- package/dist/web/server/chunks/_server.ts-Vpw25_-3.js.map +1 -0
- package/dist/web/server/chunks/_server.ts-WldRpSRi.js +26 -0
- package/dist/web/server/chunks/_server.ts-WldRpSRi.js.map +1 -0
- package/dist/web/server/chunks/alert-dialog-description-DDA6u-nS.js +2890 -0
- package/dist/web/server/chunks/alert-dialog-description-DDA6u-nS.js.map +1 -0
- package/dist/web/server/chunks/auth-DrUf-v4J.js +51 -0
- package/dist/web/server/chunks/auth-DrUf-v4J.js.map +1 -0
- package/dist/web/server/chunks/button-D6xS9rHt.js +2335 -0
- package/dist/web/server/chunks/button-D6xS9rHt.js.map +1 -0
- package/dist/web/server/chunks/chunk-EKzHsMy_.js +42 -0
- package/dist/web/server/chunks/chunks-DmdqVYC7.js +58 -0
- package/dist/web/server/chunks/chunks-DmdqVYC7.js.map +1 -0
- package/dist/web/server/chunks/client-CUrSQijh.js +18 -0
- package/dist/web/server/chunks/client-CUrSQijh.js.map +1 -0
- package/dist/web/server/chunks/clsx-FzI4_gi0.js +332 -0
- package/dist/web/server/chunks/clsx-FzI4_gi0.js.map +1 -0
- package/dist/web/server/chunks/error.svelte-D-c-9pTE.js +27 -0
- package/dist/web/server/chunks/error.svelte-D-c-9pTE.js.map +1 -0
- package/dist/web/server/chunks/events-BDBlYddw.js +89 -0
- package/dist/web/server/chunks/events-BDBlYddw.js.map +1 -0
- package/dist/web/server/chunks/exports-CCurQ-Tl.js +131 -0
- package/dist/web/server/chunks/exports-CCurQ-Tl.js.map +1 -0
- package/dist/web/server/chunks/hooks.server-BK1bopsh.js +86 -0
- package/dist/web/server/chunks/hooks.server-BK1bopsh.js.map +1 -0
- package/dist/web/server/chunks/index2-BQnysSj-.js +2588 -0
- package/dist/web/server/chunks/index2-BQnysSj-.js.map +1 -0
- package/dist/web/server/chunks/internal-DLENj6YI.js +61 -0
- package/dist/web/server/chunks/internal-DLENj6YI.js.map +1 -0
- package/dist/web/server/chunks/pane-Dg3pKvsm.js +94 -0
- package/dist/web/server/chunks/pane-Dg3pKvsm.js.map +1 -0
- package/dist/web/server/chunks/sessions-json-DgfkCLO7.js +107 -0
- package/dist/web/server/chunks/sessions-json-DgfkCLO7.js.map +1 -0
- package/dist/web/server/chunks/sessions.svelte-Ds82MvkB.js +178 -0
- package/dist/web/server/chunks/sessions.svelte-Ds82MvkB.js.map +1 -0
- package/dist/web/server/chunks/state.svelte-xeAZvWZ6.js +7 -0
- package/dist/web/server/chunks/state.svelte-xeAZvWZ6.js.map +1 -0
- package/dist/web/server/chunks/ws-handlers-B4r5eSP2.js +733 -0
- package/dist/web/server/chunks/ws-handlers-B4r5eSP2.js.map +1 -0
- package/dist/web/server/index.js +4907 -0
- package/dist/web/server/index.js.map +1 -0
- package/dist/web/server/manifest.js +233 -0
- package/dist/web/server/manifest.js.map +1 -0
- package/docs/images/desktop-dashboard.png +0 -0
- package/docs/images/desktop-session.png +0 -0
- package/docs/images/mobile-dashboard.png +0 -0
- package/docs/images/mobile-session.png +0 -0
- package/docs/release-checklist.md +228 -0
- package/docs/removing-hooks.md +135 -0
- package/docs/state-transitions.md +109 -0
- package/package.json +71 -0
- package/src/app.tsx +188 -0
- package/src/cli.ts +83 -0
- package/src/commands/index.ts +4 -0
- package/src/commands/serve.ts +75 -0
- package/src/commands/setup.ts +13 -0
- package/src/commands/tui.ts +255 -0
- package/src/commands/uninstall.ts +13 -0
- package/src/components/Header.tsx +32 -0
- package/src/components/HelpDialog.tsx +45 -0
- package/src/components/SessionEntry.tsx +202 -0
- package/src/components/SessionList.tsx +98 -0
- package/src/components/StatusBar.tsx +26 -0
- package/src/components/index.ts +5 -0
- package/src/db/index.ts +20 -0
- package/src/db/sessions-json.ts +314 -0
- package/src/hooks/claude-mux-hook.ts +498 -0
- package/src/server/watcher.ts +128 -0
- package/src/server/ws-handlers.ts +922 -0
- package/src/setup/hooks.ts +333 -0
- package/src/setup/index.ts +2 -0
- package/src/setup/wizard.ts +81 -0
- package/src/tmux/detect.ts +87 -0
- package/src/tmux/navigate.ts +42 -0
- package/src/tmux/pane.ts +167 -0
- package/src/tmux/resize.ts +28 -0
- package/src/utils/paths.ts +11 -0
- package/src/utils/pid.ts +12 -0
- package/src/utils/version.ts +5 -0
- package/tests/components/Header.test.tsx +42 -0
- package/tests/components/SessionEntry-extended.test.tsx +165 -0
- package/tests/components/SessionEntry.test.tsx +138 -0
- package/tests/components/SessionList.test.tsx +110 -0
- package/tests/components/StatusBar.test.tsx +31 -0
- package/tests/db/index.test.ts +78 -0
- package/tests/db/sessions.test.ts +230 -0
- package/tests/server/integration.test.ts +319 -0
- package/tests/server/sessions.test.ts +114 -0
- package/tests/setup/hooks-integration.test.ts +148 -0
- package/tests/setup/hooks.test.ts +123 -0
- package/tests/tmux/detect.test.ts +54 -0
- package/tests/tmux/navigate.test.ts +30 -0
- package/tests/utils/pid.test.ts +17 -0
- package/tsconfig.cli.json +9 -0
- package/tsconfig.json +22 -0
- package/vitest.config.ts +29 -0
- package/web/.svelte-kit/adapter-bun/.vite/manifest.json +408 -0
- package/web/.svelte-kit/adapter-bun/_app/immutable/assets/AllSessionsPanel.BKhqOrbV.css +1 -0
- package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_layout.WptSHSUl.css +1 -0
- package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_page.DldLgTc-.css +1 -0
- package/web/.svelte-kit/adapter-bun/_app/immutable/assets/_page.DoNWy7tW.css +1 -0
- package/web/.svelte-kit/adapter-bun/chunks/AllSessionsPanel.svelte_svelte_type_style_lang.js +49 -0
- package/web/.svelte-kit/adapter-bun/chunks/alert-dialog-description.js +2670 -0
- package/web/.svelte-kit/adapter-bun/chunks/auth.js +59 -0
- package/web/.svelte-kit/adapter-bun/chunks/button.js +82 -0
- package/web/.svelte-kit/adapter-bun/chunks/client.js +29 -0
- package/web/.svelte-kit/adapter-bun/chunks/context.js +133 -0
- package/web/.svelte-kit/adapter-bun/chunks/environment.js +34 -0
- package/web/.svelte-kit/adapter-bun/chunks/events.js +121 -0
- package/web/.svelte-kit/adapter-bun/chunks/exports.js +174 -0
- package/web/.svelte-kit/adapter-bun/chunks/false.js +4 -0
- package/web/.svelte-kit/adapter-bun/chunks/index.js +59 -0
- package/web/.svelte-kit/adapter-bun/chunks/index2.js +2828 -0
- package/web/.svelte-kit/adapter-bun/chunks/internal.js +920 -0
- package/web/.svelte-kit/adapter-bun/chunks/pane.js +82 -0
- package/web/.svelte-kit/adapter-bun/chunks/sessions-json.js +124 -0
- package/web/.svelte-kit/adapter-bun/chunks/sessions.svelte.js +229 -0
- package/web/.svelte-kit/adapter-bun/chunks/shared.js +542 -0
- package/web/.svelte-kit/adapter-bun/chunks/state.svelte.js +16 -0
- package/web/.svelte-kit/adapter-bun/chunks/utils.js +43 -0
- package/web/.svelte-kit/adapter-bun/chunks/ws-handlers.js +782 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/auth/login/_server.ts.js +22 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/auth/logout/_server.ts.js +9 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/beads/_server.ts.js +22 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/browse/_server.ts.js +50 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/chrome/_server.ts.js +30 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/files/image/_server.ts.js +53 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/health/_server.ts.js +7 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +36 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/restart/_server.ts.js +40 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/screenshots/_server.ts.js +28 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_id_/send/_server.ts.js +29 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_server.ts.js +49 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
- package/web/.svelte-kit/adapter-bun/entries/endpoints/api/tmux/panes/_server.ts.js +21 -0
- package/web/.svelte-kit/adapter-bun/entries/fallbacks/error.svelte.js +27 -0
- package/web/.svelte-kit/adapter-bun/entries/hooks.server.js +105 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/_layout.svelte.js +499 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/_page.svelte.js +3057 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/login/_page.server.ts.js +15 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/login/_page.svelte.js +37 -0
- package/web/.svelte-kit/adapter-bun/entries/pages/session/_target_/_page.svelte.js +653 -0
- package/web/.svelte-kit/adapter-bun/index.js +3864 -0
- package/web/.svelte-kit/adapter-bun/internal.js +13 -0
- package/web/.svelte-kit/adapter-bun/manifest-full.js +167 -0
- package/web/.svelte-kit/adapter-bun/manifest.js +171 -0
- package/web/.svelte-kit/adapter-bun/nodes/0.js +8 -0
- package/web/.svelte-kit/adapter-bun/nodes/1.js +8 -0
- package/web/.svelte-kit/adapter-bun/nodes/2.js +8 -0
- package/web/.svelte-kit/adapter-bun/nodes/3.js +10 -0
- package/web/.svelte-kit/adapter-bun/nodes/4.js +8 -0
- package/web/.svelte-kit/adapter-bun/remote-entry.js +541 -0
- package/web/.svelte-kit/adapter-node/.vite/manifest.json +223 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_layout.4NiX29PU.css +1 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.BEMzYUGV.css +1 -0
- package/web/.svelte-kit/adapter-node/_app/immutable/assets/_page.DOJn7TG7.css +1 -0
- package/web/.svelte-kit/adapter-node/chunks/context.js +121 -0
- package/web/.svelte-kit/adapter-node/chunks/environment.js +34 -0
- package/web/.svelte-kit/adapter-node/chunks/exports.js +174 -0
- package/web/.svelte-kit/adapter-node/chunks/false.js +4 -0
- package/web/.svelte-kit/adapter-node/chunks/index.js +59 -0
- package/web/.svelte-kit/adapter-node/chunks/index2.js +2710 -0
- package/web/.svelte-kit/adapter-node/chunks/internal.js +1005 -0
- package/web/.svelte-kit/adapter-node/chunks/sessions-json.js +109 -0
- package/web/.svelte-kit/adapter-node/chunks/sessions.svelte.js +67 -0
- package/web/.svelte-kit/adapter-node/chunks/shared.js +542 -0
- package/web/.svelte-kit/adapter-node/chunks/state.svelte.js +16 -0
- package/web/.svelte-kit/adapter-node/chunks/utils.js +43 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/browse/_server.ts.js +50 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/health/_server.ts.js +7 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +30 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_id_/send/_server.ts.js +22 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_server.ts.js +126 -0
- package/web/.svelte-kit/adapter-node/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
- package/web/.svelte-kit/adapter-node/entries/fallbacks/error.svelte.js +44 -0
- package/web/.svelte-kit/adapter-node/entries/pages/_layout.svelte.js +12 -0
- package/web/.svelte-kit/adapter-node/entries/pages/_page.svelte.js +87 -0
- package/web/.svelte-kit/adapter-node/entries/pages/session/_target_/_page.svelte.js +76 -0
- package/web/.svelte-kit/adapter-node/index.js +3864 -0
- package/web/.svelte-kit/adapter-node/internal.js +13 -0
- package/web/.svelte-kit/adapter-node/manifest-full.js +103 -0
- package/web/.svelte-kit/adapter-node/manifest.js +107 -0
- package/web/.svelte-kit/adapter-node/nodes/0.js +8 -0
- package/web/.svelte-kit/adapter-node/nodes/1.js +8 -0
- package/web/.svelte-kit/adapter-node/nodes/2.js +8 -0
- package/web/.svelte-kit/adapter-node/nodes/3.js +8 -0
- package/web/.svelte-kit/adapter-node/remote-entry.js +541 -0
- package/web/.svelte-kit/ambient.d.ts +187 -0
- package/web/.svelte-kit/generated/client/app.js +33 -0
- package/web/.svelte-kit/generated/client/matchers.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/0.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/1.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/2.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/3.js +1 -0
- package/web/.svelte-kit/generated/client/nodes/4.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/app.js +33 -0
- package/web/.svelte-kit/generated/client-optimized/matchers.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/0.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/1.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/2.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/3.js +1 -0
- package/web/.svelte-kit/generated/client-optimized/nodes/4.js +1 -0
- package/web/.svelte-kit/generated/root.js +3 -0
- package/web/.svelte-kit/generated/root.svelte +68 -0
- package/web/.svelte-kit/generated/server/internal.js +53 -0
- package/web/.svelte-kit/non-ambient.d.ts +73 -0
- package/web/.svelte-kit/output/client/.vite/manifest.json +203 -0
- package/web/.svelte-kit/output/client/_app/immutable/assets/0.WptSHSUl.css +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/assets/2.s6Kx4oz1.css +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/assets/4.DoNWy7tW.css +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/assets/AllSessionsPanel.CGHY3HLy.css +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/-3mUPuLP.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/B5U4_V3d.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/BHwiZXRv.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/C9P-coqM.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/Cegv0r8x.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/DU91Ml7U.js +3 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/DmdO6ygw.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/HKNo9LID.js +5 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/U4ip-C0d.js +2 -0
- package/web/.svelte-kit/output/client/_app/immutable/chunks/cgUjKIhX.js +2 -0
- package/web/.svelte-kit/output/client/_app/immutable/entry/app.CGIBnoln.js +2 -0
- package/web/.svelte-kit/output/client/_app/immutable/entry/start.CJk8zB1j.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/0.CqlJ9a31.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/1.BQUZh2-w.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/2.CCV1YdgF.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/3.D9tDCdq8.js +1 -0
- package/web/.svelte-kit/output/client/_app/immutable/nodes/4.BqPyNkFA.js +6 -0
- package/web/.svelte-kit/output/client/_app/version.json +1 -0
- package/web/.svelte-kit/output/client/robots.txt +3 -0
- package/web/.svelte-kit/output/server/.vite/manifest.json +408 -0
- package/web/.svelte-kit/output/server/_app/immutable/assets/AllSessionsPanel.BKhqOrbV.css +1 -0
- package/web/.svelte-kit/output/server/_app/immutable/assets/_layout.WptSHSUl.css +1 -0
- package/web/.svelte-kit/output/server/_app/immutable/assets/_page.DldLgTc-.css +1 -0
- package/web/.svelte-kit/output/server/_app/immutable/assets/_page.DoNWy7tW.css +1 -0
- package/web/.svelte-kit/output/server/chunks/AllSessionsPanel.svelte_svelte_type_style_lang.js +49 -0
- package/web/.svelte-kit/output/server/chunks/alert-dialog-description.js +2670 -0
- package/web/.svelte-kit/output/server/chunks/auth.js +59 -0
- package/web/.svelte-kit/output/server/chunks/button.js +82 -0
- package/web/.svelte-kit/output/server/chunks/client.js +29 -0
- package/web/.svelte-kit/output/server/chunks/context.js +133 -0
- package/web/.svelte-kit/output/server/chunks/environment.js +34 -0
- package/web/.svelte-kit/output/server/chunks/events.js +121 -0
- package/web/.svelte-kit/output/server/chunks/exports.js +174 -0
- package/web/.svelte-kit/output/server/chunks/false.js +4 -0
- package/web/.svelte-kit/output/server/chunks/index.js +59 -0
- package/web/.svelte-kit/output/server/chunks/index2.js +2828 -0
- package/web/.svelte-kit/output/server/chunks/internal.js +920 -0
- package/web/.svelte-kit/output/server/chunks/pane.js +82 -0
- package/web/.svelte-kit/output/server/chunks/sessions-json.js +124 -0
- package/web/.svelte-kit/output/server/chunks/sessions.svelte.js +229 -0
- package/web/.svelte-kit/output/server/chunks/shared.js +542 -0
- package/web/.svelte-kit/output/server/chunks/state.svelte.js +16 -0
- package/web/.svelte-kit/output/server/chunks/utils.js +43 -0
- package/web/.svelte-kit/output/server/chunks/ws-handlers.js +782 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/auth/login/_server.ts.js +22 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/auth/logout/_server.ts.js +9 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/beads/_server.ts.js +22 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/browse/_server.ts.js +50 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/chrome/_server.ts.js +30 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/files/image/_server.ts.js +53 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/health/_server.ts.js +7 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/projects/new-session/_server.ts.js +44 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/_server.ts.js +20 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/kill/_server.ts.js +36 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/restart/_server.ts.js +40 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/screenshots/_server.ts.js +28 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_id_/send/_server.ts.js +29 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_server.ts.js +49 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/sessions/_target_/output/_server.ts.js +14 -0
- package/web/.svelte-kit/output/server/entries/endpoints/api/tmux/panes/_server.ts.js +21 -0
- package/web/.svelte-kit/output/server/entries/fallbacks/error.svelte.js +27 -0
- package/web/.svelte-kit/output/server/entries/hooks.server.js +105 -0
- package/web/.svelte-kit/output/server/entries/pages/_layout.svelte.js +499 -0
- package/web/.svelte-kit/output/server/entries/pages/_page.svelte.js +3057 -0
- package/web/.svelte-kit/output/server/entries/pages/login/_page.server.ts.js +15 -0
- package/web/.svelte-kit/output/server/entries/pages/login/_page.svelte.js +37 -0
- package/web/.svelte-kit/output/server/entries/pages/session/_target_/_page.svelte.js +653 -0
- package/web/.svelte-kit/output/server/index.js +3864 -0
- package/web/.svelte-kit/output/server/internal.js +13 -0
- package/web/.svelte-kit/output/server/manifest-full.js +167 -0
- package/web/.svelte-kit/output/server/manifest.js +167 -0
- package/web/.svelte-kit/output/server/nodes/0.js +8 -0
- package/web/.svelte-kit/output/server/nodes/1.js +8 -0
- package/web/.svelte-kit/output/server/nodes/2.js +8 -0
- package/web/.svelte-kit/output/server/nodes/3.js +10 -0
- package/web/.svelte-kit/output/server/nodes/4.js +8 -0
- package/web/.svelte-kit/output/server/remote-entry.js +541 -0
- package/web/.svelte-kit/tsconfig.json +58 -0
- package/web/.svelte-kit/types/route_meta_data.json +55 -0
- package/web/.svelte-kit/types/src/routes/$types.d.ts +24 -0
- package/web/.svelte-kit/types/src/routes/api/auth/login/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/auth/logout/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/beads/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/browse/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/chrome/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/files/image/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/health/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/projects/new-session/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/kill/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/restart/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/screenshots/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[id]/send/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/sessions/[target]/output/$types.d.ts +11 -0
- package/web/.svelte-kit/types/src/routes/api/tmux/panes/$types.d.ts +10 -0
- package/web/.svelte-kit/types/src/routes/login/$types.d.ts +25 -0
- package/web/.svelte-kit/types/src/routes/login/proxy+page.server.ts +19 -0
- package/web/.svelte-kit/types/src/routes/session/[target]/$types.d.ts +19 -0
- package/web/README.md +42 -0
- package/web/components.json +16 -0
- package/web/package.json +35 -0
- package/web/src/app.css +128 -0
- package/web/src/app.d.ts +13 -0
- package/web/src/app.html +11 -0
- package/web/src/hooks.server.ts +156 -0
- package/web/src/lib/assets/favicon.svg +1 -0
- package/web/src/lib/components/AllSessionsPanel.svelte +789 -0
- package/web/src/lib/components/BeadsPanel.svelte +146 -0
- package/web/src/lib/components/IssueItem.svelte +287 -0
- package/web/src/lib/components/ScreenshotsPanel.svelte +336 -0
- package/web/src/lib/components/SessionsSidebar.svelte +312 -0
- package/web/src/lib/components/TerminalRenderer.svelte +189 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-action.svelte +18 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-cancel.svelte +18 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-content.svelte +29 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-description.svelte +17 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-footer.svelte +20 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-header.svelte +20 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-overlay.svelte +20 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-portal.svelte +7 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-title.svelte +17 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog-trigger.svelte +7 -0
- package/web/src/lib/components/ui/alert-dialog/alert-dialog.svelte +7 -0
- package/web/src/lib/components/ui/alert-dialog/index.ts +37 -0
- package/web/src/lib/components/ui/badge/badge.svelte +50 -0
- package/web/src/lib/components/ui/badge/index.ts +2 -0
- package/web/src/lib/components/ui/button/button.svelte +86 -0
- package/web/src/lib/components/ui/button/index.ts +17 -0
- package/web/src/lib/components/ui/checkbox/checkbox.svelte +36 -0
- package/web/src/lib/components/ui/checkbox/index.ts +6 -0
- package/web/src/lib/components/ui/dialog/dialog-close.svelte +7 -0
- package/web/src/lib/components/ui/dialog/dialog-content.svelte +45 -0
- package/web/src/lib/components/ui/dialog/dialog-description.svelte +17 -0
- package/web/src/lib/components/ui/dialog/dialog-footer.svelte +20 -0
- package/web/src/lib/components/ui/dialog/dialog-header.svelte +20 -0
- package/web/src/lib/components/ui/dialog/dialog-overlay.svelte +20 -0
- package/web/src/lib/components/ui/dialog/dialog-portal.svelte +7 -0
- package/web/src/lib/components/ui/dialog/dialog-title.svelte +17 -0
- package/web/src/lib/components/ui/dialog/dialog-trigger.svelte +7 -0
- package/web/src/lib/components/ui/dialog/dialog.svelte +7 -0
- package/web/src/lib/components/ui/dialog/index.ts +34 -0
- package/web/src/lib/components/ui/scroll-area/index.ts +10 -0
- package/web/src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte +31 -0
- package/web/src/lib/components/ui/scroll-area/scroll-area.svelte +43 -0
- package/web/src/lib/components/ui/textarea/index.ts +7 -0
- package/web/src/lib/components/ui/textarea/textarea.svelte +23 -0
- package/web/src/lib/index.ts +1 -0
- package/web/src/lib/server/auth.ts +90 -0
- package/web/src/lib/stores/beads.svelte.ts +163 -0
- package/web/src/lib/stores/input-injection.svelte.ts +39 -0
- package/web/src/lib/stores/preferences.svelte.ts +55 -0
- package/web/src/lib/stores/sessions.svelte.ts +108 -0
- package/web/src/lib/stores/terminal.svelte.ts +96 -0
- package/web/src/lib/stores/websocket-base.svelte.ts +209 -0
- package/web/src/lib/types/terminal.ts +31 -0
- package/web/src/lib/utils/terminal-parser.ts +239 -0
- package/web/src/lib/utils.ts +13 -0
- package/web/src/routes/+layout.svelte +450 -0
- package/web/src/routes/+page.svelte +19 -0
- package/web/src/routes/api/auth/login/+server.ts +34 -0
- package/web/src/routes/api/auth/logout/+server.ts +10 -0
- package/web/src/routes/api/beads/+server.ts +28 -0
- package/web/src/routes/api/browse/+server.ts +59 -0
- package/web/src/routes/api/chrome/+server.ts +35 -0
- package/web/src/routes/api/files/image/+server.ts +64 -0
- package/web/src/routes/api/health/+server.ts +6 -0
- package/web/src/routes/api/projects/new-session/+server.ts +50 -0
- package/web/src/routes/api/sessions/+server.ts +62 -0
- package/web/src/routes/api/sessions/[id]/+server.ts +19 -0
- package/web/src/routes/api/sessions/[id]/kill/+server.ts +46 -0
- package/web/src/routes/api/sessions/[id]/restart/+server.ts +59 -0
- package/web/src/routes/api/sessions/[id]/screenshots/+server.ts +32 -0
- package/web/src/routes/api/sessions/[id]/send/+server.ts +31 -0
- package/web/src/routes/api/sessions/[target]/output/+server.ts +13 -0
- package/web/src/routes/api/tmux/panes/+server.ts +32 -0
- package/web/src/routes/login/+page.server.ts +18 -0
- package/web/src/routes/login/+page.svelte +69 -0
- package/web/src/routes/session/[target]/+page.svelte +450 -0
- package/web/static/robots.txt +3 -0
- package/web/svelte.config.js +20 -0
- package/web/tsconfig.json +20 -0
- package/web/vite.config.ts +154 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
2
|
+
import { dirname, join } from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { CLAUDE_SETTINGS_PATH, CLAUDE_DIR } from "../utils/paths.js";
|
|
5
|
+
import { VERSION } from "../utils/version.js";
|
|
6
|
+
|
|
7
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
interface Hook {
|
|
10
|
+
type: "command";
|
|
11
|
+
command: string;
|
|
12
|
+
timeout?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface HookMatcher {
|
|
16
|
+
matcher?: string;
|
|
17
|
+
hooks: Hook[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface HooksConfig {
|
|
21
|
+
[eventName: string]: HookMatcher[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ClaudeWatchMetadata {
|
|
25
|
+
version: string;
|
|
26
|
+
installedAt: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ClaudeSettings {
|
|
30
|
+
hooks?: HooksConfig;
|
|
31
|
+
"claude-watch"?: ClaudeWatchMetadata;
|
|
32
|
+
[key: string]: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getHookScriptPath(scriptName: string): string {
|
|
36
|
+
// In production, scripts are in dist/hooks/
|
|
37
|
+
// During development, they might be in src/hooks/
|
|
38
|
+
const distPath = join(__dirname, "..", "hooks", scriptName);
|
|
39
|
+
return distPath;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getClaudeWatchHooks(): HooksConfig {
|
|
43
|
+
const hookScript = getHookScriptPath("claude-mux-hook.js");
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
SessionStart: [
|
|
47
|
+
{
|
|
48
|
+
hooks: [
|
|
49
|
+
{
|
|
50
|
+
type: "command",
|
|
51
|
+
command: `node "${hookScript}" session-start`,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
UserPromptSubmit: [
|
|
57
|
+
{
|
|
58
|
+
hooks: [
|
|
59
|
+
{
|
|
60
|
+
type: "command",
|
|
61
|
+
command: `node "${hookScript}" user-prompt-submit`,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
Stop: [
|
|
67
|
+
{
|
|
68
|
+
hooks: [
|
|
69
|
+
{
|
|
70
|
+
type: "command",
|
|
71
|
+
command: `node "${hookScript}" stop`,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
PermissionRequest: [
|
|
77
|
+
{
|
|
78
|
+
hooks: [
|
|
79
|
+
{
|
|
80
|
+
type: "command",
|
|
81
|
+
command: `node "${hookScript}" permission-request`,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
Notification: [
|
|
87
|
+
{
|
|
88
|
+
matcher: "idle_prompt",
|
|
89
|
+
hooks: [
|
|
90
|
+
{
|
|
91
|
+
type: "command",
|
|
92
|
+
command: `node "${hookScript}" notification-idle`,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
matcher: "permission_prompt",
|
|
98
|
+
hooks: [
|
|
99
|
+
{
|
|
100
|
+
type: "command",
|
|
101
|
+
command: `node "${hookScript}" notification-permission`,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
matcher: "elicitation_dialog",
|
|
107
|
+
hooks: [
|
|
108
|
+
{
|
|
109
|
+
type: "command",
|
|
110
|
+
command: `node "${hookScript}" notification-elicitation`,
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
PreToolUse: [
|
|
116
|
+
{
|
|
117
|
+
hooks: [
|
|
118
|
+
{
|
|
119
|
+
type: "command",
|
|
120
|
+
command: `node "${hookScript}" pre-tool-use`,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
PostToolUse: [
|
|
126
|
+
{
|
|
127
|
+
hooks: [
|
|
128
|
+
{
|
|
129
|
+
type: "command",
|
|
130
|
+
command: `node "${hookScript}" post-tool-use`,
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
PostToolUseFailure: [
|
|
136
|
+
{
|
|
137
|
+
hooks: [
|
|
138
|
+
{
|
|
139
|
+
type: "command",
|
|
140
|
+
command: `node "${hookScript}" post-tool-use-failure`,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
SessionEnd: [
|
|
146
|
+
{
|
|
147
|
+
hooks: [
|
|
148
|
+
{
|
|
149
|
+
type: "command",
|
|
150
|
+
command: `node "${hookScript}" session-end`,
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function loadClaudeSettings(): ClaudeSettings {
|
|
159
|
+
if (!existsSync(CLAUDE_SETTINGS_PATH)) {
|
|
160
|
+
return {};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
const content = readFileSync(CLAUDE_SETTINGS_PATH, "utf-8");
|
|
165
|
+
return JSON.parse(content) as ClaudeSettings;
|
|
166
|
+
} catch {
|
|
167
|
+
return {};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get the version of installed claude-watch hooks.
|
|
173
|
+
* Returns null if hooks are not installed or version is not tracked.
|
|
174
|
+
*/
|
|
175
|
+
export function getInstalledHooksVersion(): string | null {
|
|
176
|
+
const settings = loadClaudeSettings();
|
|
177
|
+
return settings["claude-watch"]?.version ?? null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Check if hooks need to be installed or updated.
|
|
182
|
+
* Returns: 'install' | 'update' | 'current'
|
|
183
|
+
*/
|
|
184
|
+
export function checkHooksStatus(): "install" | "update" | "current" {
|
|
185
|
+
const settings = loadClaudeSettings();
|
|
186
|
+
|
|
187
|
+
// Check if hooks are installed at all
|
|
188
|
+
if (!settings.hooks) {
|
|
189
|
+
return "install";
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Check if any claude-watch hooks exist
|
|
193
|
+
const hasClaudeWatchHooks = Object.values(settings.hooks).some((matchers) =>
|
|
194
|
+
matchers.some((m) => m.hooks.some((h) => h.command.includes("claude-mux-hook")))
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
if (!hasClaudeWatchHooks) {
|
|
198
|
+
return "install";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Check version
|
|
202
|
+
const installedVersion = settings["claude-watch"]?.version;
|
|
203
|
+
if (!installedVersion || installedVersion !== VERSION) {
|
|
204
|
+
return "update";
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return "current";
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function mergeHooks(existing: HooksConfig | undefined, newHooks: HooksConfig): HooksConfig {
|
|
211
|
+
const merged: HooksConfig = { ...existing };
|
|
212
|
+
|
|
213
|
+
for (const [eventName, matchers] of Object.entries(newHooks)) {
|
|
214
|
+
if (!merged[eventName]) {
|
|
215
|
+
merged[eventName] = [];
|
|
216
|
+
} else {
|
|
217
|
+
// Remove any existing claude-watch hooks for this event (so we can replace them)
|
|
218
|
+
merged[eventName] = merged[eventName].filter((existingMatcher) => {
|
|
219
|
+
return !existingMatcher.hooks.some((h) => h.command.includes("claude-mux-hook"));
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Add new claude-watch matchers
|
|
224
|
+
for (const newMatcher of matchers) {
|
|
225
|
+
merged[eventName].push(newMatcher);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return merged;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function removeClaudeWatchHooks(hooks: HooksConfig): HooksConfig {
|
|
233
|
+
const cleaned: HooksConfig = {};
|
|
234
|
+
|
|
235
|
+
for (const [eventName, matchers] of Object.entries(hooks)) {
|
|
236
|
+
const filteredMatchers = matchers.filter((matcher) => {
|
|
237
|
+
// Remove matchers that have claude-mux-hook commands
|
|
238
|
+
return !matcher.hooks.some((h) => h.command.includes("claude-mux-hook"));
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
if (filteredMatchers.length > 0) {
|
|
242
|
+
cleaned[eventName] = filteredMatchers;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return cleaned;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function generateDiff(
|
|
250
|
+
oldSettings: ClaudeSettings,
|
|
251
|
+
newSettings: ClaudeSettings
|
|
252
|
+
): string {
|
|
253
|
+
const oldJson = JSON.stringify(oldSettings, null, 2);
|
|
254
|
+
const newJson = JSON.stringify(newSettings, null, 2);
|
|
255
|
+
|
|
256
|
+
if (oldJson === newJson) {
|
|
257
|
+
return "No changes needed.";
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Simple diff display
|
|
261
|
+
const lines: string[] = [];
|
|
262
|
+
lines.push("Changes to ~/.claude/settings.json:");
|
|
263
|
+
lines.push("");
|
|
264
|
+
|
|
265
|
+
if (!oldSettings.hooks) {
|
|
266
|
+
lines.push("+ Adding hooks configuration");
|
|
267
|
+
} else {
|
|
268
|
+
lines.push("~ Updating hooks configuration");
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
lines.push("");
|
|
272
|
+
lines.push("New hooks to be added:");
|
|
273
|
+
const hookEvents = Object.keys(getClaudeWatchHooks());
|
|
274
|
+
for (const event of hookEvents) {
|
|
275
|
+
lines.push(` + ${event}: claude-mux-hook`);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return lines.join("\n");
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export function saveClaudeSettings(settings: ClaudeSettings): void {
|
|
282
|
+
// Ensure directory exists
|
|
283
|
+
if (!existsSync(CLAUDE_DIR)) {
|
|
284
|
+
mkdirSync(CLAUDE_DIR, { recursive: true });
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const content = JSON.stringify(settings, null, 2);
|
|
288
|
+
writeFileSync(CLAUDE_SETTINGS_PATH, content, "utf-8");
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function installHooks(): { diff: string; newSettings: ClaudeSettings } {
|
|
292
|
+
const currentSettings = loadClaudeSettings();
|
|
293
|
+
const claudeWatchHooks = getClaudeWatchHooks();
|
|
294
|
+
const mergedHooks = mergeHooks(currentSettings.hooks, claudeWatchHooks);
|
|
295
|
+
|
|
296
|
+
const newSettings: ClaudeSettings = {
|
|
297
|
+
...currentSettings,
|
|
298
|
+
hooks: mergedHooks,
|
|
299
|
+
"claude-watch": {
|
|
300
|
+
version: VERSION,
|
|
301
|
+
installedAt: new Date().toISOString(),
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const diff = generateDiff(currentSettings, newSettings);
|
|
306
|
+
|
|
307
|
+
return { diff, newSettings };
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export function uninstallHooks(): void {
|
|
311
|
+
const currentSettings = loadClaudeSettings();
|
|
312
|
+
|
|
313
|
+
if (!currentSettings.hooks) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const cleanedHooks = removeClaudeWatchHooks(currentSettings.hooks);
|
|
318
|
+
|
|
319
|
+
const newSettings: ClaudeSettings = {
|
|
320
|
+
...currentSettings,
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
if (Object.keys(cleanedHooks).length === 0) {
|
|
324
|
+
delete newSettings.hooks;
|
|
325
|
+
} else {
|
|
326
|
+
newSettings.hooks = cleanedHooks;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Remove claude-watch metadata
|
|
330
|
+
delete newSettings["claude-watch"];
|
|
331
|
+
|
|
332
|
+
saveClaudeSettings(newSettings);
|
|
333
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createInterface } from "readline";
|
|
2
|
+
import { mkdirSync, existsSync } from "fs";
|
|
3
|
+
import { CLAUDE_WATCH_DIR, SESSIONS_DIR } from "../utils/paths.js";
|
|
4
|
+
import { installHooks, saveClaudeSettings, uninstallHooks } from "./hooks.js";
|
|
5
|
+
|
|
6
|
+
async function prompt(question: string): Promise<string> {
|
|
7
|
+
const rl = createInterface({
|
|
8
|
+
input: process.stdin,
|
|
9
|
+
output: process.stdout,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
rl.question(question, (answer) => {
|
|
14
|
+
rl.close();
|
|
15
|
+
resolve(answer.trim().toLowerCase());
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function confirm(question: string): Promise<boolean> {
|
|
21
|
+
const answer = await prompt(`${question} [y/N] `);
|
|
22
|
+
return answer === "y" || answer === "yes";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function runSetup(): Promise<void> {
|
|
26
|
+
console.log("\n claude-mux Setup\n");
|
|
27
|
+
|
|
28
|
+
// Step 1: Create data directories
|
|
29
|
+
console.log("Step 1: Creating data directories...");
|
|
30
|
+
if (!existsSync(CLAUDE_WATCH_DIR)) {
|
|
31
|
+
mkdirSync(CLAUDE_WATCH_DIR, { recursive: true });
|
|
32
|
+
console.log(` Created ${CLAUDE_WATCH_DIR}`);
|
|
33
|
+
} else {
|
|
34
|
+
console.log(` ${CLAUDE_WATCH_DIR} already exists`);
|
|
35
|
+
}
|
|
36
|
+
if (!existsSync(SESSIONS_DIR)) {
|
|
37
|
+
mkdirSync(SESSIONS_DIR, { recursive: true });
|
|
38
|
+
console.log(` Created ${SESSIONS_DIR}`);
|
|
39
|
+
} else {
|
|
40
|
+
console.log(` ${SESSIONS_DIR} already exists`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Step 2: Configure Claude hooks
|
|
44
|
+
console.log("\nStep 2: Configuring Claude Code hooks...");
|
|
45
|
+
const { diff, newSettings } = installHooks();
|
|
46
|
+
console.log("");
|
|
47
|
+
console.log(diff);
|
|
48
|
+
console.log("");
|
|
49
|
+
|
|
50
|
+
const confirmHooks = await confirm("Apply these changes to Claude settings?");
|
|
51
|
+
if (confirmHooks) {
|
|
52
|
+
saveClaudeSettings(newSettings);
|
|
53
|
+
console.log(" Hooks installed successfully");
|
|
54
|
+
} else {
|
|
55
|
+
console.log(" Skipped hook installation");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Done
|
|
59
|
+
console.log("\n Setup complete!\n");
|
|
60
|
+
console.log("To start claude-mux, run from any tmux session:");
|
|
61
|
+
console.log(" claude-mux");
|
|
62
|
+
console.log("");
|
|
63
|
+
console.log("This will automatically create a 'watch' session and add");
|
|
64
|
+
console.log("a keybinding (prefix + W) to quickly return to the dashboard.");
|
|
65
|
+
console.log("");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function runCleanup(): Promise<void> {
|
|
69
|
+
console.log("\n claude-mux Cleanup\n");
|
|
70
|
+
|
|
71
|
+
console.log("Removing Claude Code hooks...");
|
|
72
|
+
uninstallHooks();
|
|
73
|
+
console.log(" Hooks removed successfully");
|
|
74
|
+
|
|
75
|
+
console.log("\nData directory: " + CLAUDE_WATCH_DIR);
|
|
76
|
+
console.log(" (Manual removal: rm -rf ~/.claude-mux)");
|
|
77
|
+
|
|
78
|
+
console.log("\n Cleanup complete!\n");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { installHooks, uninstallHooks } from "./hooks.js";
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if we're running inside tmux.
|
|
5
|
+
*/
|
|
6
|
+
export function isInTmux(): boolean {
|
|
7
|
+
return !!process.env.TMUX;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Get the current tmux target in the format session:window.pane.
|
|
12
|
+
* Returns null if not running in tmux.
|
|
13
|
+
*/
|
|
14
|
+
export function getTmuxTarget(): string | null {
|
|
15
|
+
if (!isInTmux()) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const result = execSync(
|
|
21
|
+
'tmux display-message -p "#{session_name}:#{window_index}.#{pane_index}"',
|
|
22
|
+
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
23
|
+
);
|
|
24
|
+
return result.trim();
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get just the tmux session name.
|
|
32
|
+
* Returns null if not running in tmux.
|
|
33
|
+
*/
|
|
34
|
+
export function getTmuxSessionName(): string | null {
|
|
35
|
+
if (!isInTmux()) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const result = execSync('tmux display-message -p "#{session_name}"', {
|
|
41
|
+
encoding: "utf-8",
|
|
42
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
43
|
+
});
|
|
44
|
+
return result.trim();
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface TmuxSession {
|
|
51
|
+
name: string;
|
|
52
|
+
windowCount: number;
|
|
53
|
+
attached: boolean;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get all tmux sessions.
|
|
58
|
+
* Returns empty array if not running in tmux or on error.
|
|
59
|
+
*/
|
|
60
|
+
export function getAllTmuxSessions(): TmuxSession[] {
|
|
61
|
+
if (!isInTmux()) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
try {
|
|
66
|
+
// Format: session_name:window_count:attached_flag
|
|
67
|
+
const result = execSync(
|
|
68
|
+
'tmux list-sessions -F "#{session_name}:#{session_windows}:#{session_attached}"',
|
|
69
|
+
{ encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return result
|
|
73
|
+
.trim()
|
|
74
|
+
.split("\n")
|
|
75
|
+
.filter((line) => line.length > 0)
|
|
76
|
+
.map((line) => {
|
|
77
|
+
const [name, windowCount, attached] = line.split(":");
|
|
78
|
+
return {
|
|
79
|
+
name,
|
|
80
|
+
windowCount: parseInt(windowCount, 10) || 1,
|
|
81
|
+
attached: attached === "1",
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
} catch {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
|
+
import { isInTmux } from "./detect.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Switch to a different tmux session/window/pane.
|
|
6
|
+
* @param target - The target in format "session:window.pane"
|
|
7
|
+
* @returns true if successful, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export function switchToTarget(target: string): boolean {
|
|
10
|
+
if (!isInTmux()) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
execFileSync("tmux", ["switch-client", "-t", target], {
|
|
16
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
17
|
+
});
|
|
18
|
+
return true;
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Switch to a specific session (useful for the dashboard binding).
|
|
26
|
+
* @param sessionName - The tmux session name
|
|
27
|
+
* @returns true if successful, false otherwise
|
|
28
|
+
*/
|
|
29
|
+
export function switchToSession(sessionName: string): boolean {
|
|
30
|
+
if (!isInTmux()) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
execFileSync("tmux", ["switch-client", "-t", sessionName], {
|
|
36
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
37
|
+
});
|
|
38
|
+
return true;
|
|
39
|
+
} catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/tmux/pane.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { execFileSync } from "child_process";
|
|
2
|
+
import { isInTmux } from "./detect.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the title of a tmux pane.
|
|
6
|
+
* @param target - The tmux target in format "session:window.pane"
|
|
7
|
+
* @returns The pane title, or null if failed
|
|
8
|
+
*/
|
|
9
|
+
export function getPaneTitle(target: string): string | null {
|
|
10
|
+
try {
|
|
11
|
+
const result = execFileSync("tmux", ["display-message", "-p", "-t", target, "#{pane_title}"], {
|
|
12
|
+
encoding: "utf-8",
|
|
13
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
14
|
+
timeout: 1000,
|
|
15
|
+
});
|
|
16
|
+
return result.trim() || null;
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Capture the contents of a tmux pane.
|
|
24
|
+
* @param target - The tmux target in format "session:window.pane"
|
|
25
|
+
* @returns The pane contents as a string, or null if capture failed
|
|
26
|
+
*/
|
|
27
|
+
export function capturePaneContent(target: string): string | null {
|
|
28
|
+
if (!isInTmux()) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
const result = execFileSync("tmux", ["capture-pane", "-p", "-t", target], {
|
|
34
|
+
encoding: "utf-8",
|
|
35
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
36
|
+
timeout: 1000,
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Check if the pane content shows Claude is actively working.
|
|
46
|
+
* Looks for interrupt hints which appear when Claude is processing.
|
|
47
|
+
*/
|
|
48
|
+
export function isPaneShowingWorking(content: string): boolean {
|
|
49
|
+
if (!content) return false;
|
|
50
|
+
|
|
51
|
+
// These patterns appear when Claude is actively working
|
|
52
|
+
return (
|
|
53
|
+
content.includes("Esc to interrupt") ||
|
|
54
|
+
content.includes("esc to interrupt") ||
|
|
55
|
+
content.includes("ctrl+c to interrupt")
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Check if the pane content shows Claude is at the prompt (idle).
|
|
61
|
+
* Claude is idle if "Esc to interrupt" is NOT present.
|
|
62
|
+
*/
|
|
63
|
+
export function isPaneShowingPrompt(content: string): boolean {
|
|
64
|
+
if (!content) return false;
|
|
65
|
+
|
|
66
|
+
// If "Esc to interrupt" is present, Claude is still working
|
|
67
|
+
if (isPaneShowingWorking(content)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Detect if the pane shows user interruption or cancellation.
|
|
76
|
+
* Only detects FRESH signals from the most recent interaction.
|
|
77
|
+
*
|
|
78
|
+
* Structure of Claude Code pane:
|
|
79
|
+
* ❯ user command ← interaction start (● or ❯)
|
|
80
|
+
* ⎿ Interrupted... ← signal we're looking for
|
|
81
|
+
* ───────────────────── ← TOP separator
|
|
82
|
+
* ❯ [user input] ← prompt area (may have text)
|
|
83
|
+
* ───────────────────── ← BOTTOM separator
|
|
84
|
+
* status line
|
|
85
|
+
*
|
|
86
|
+
* Algorithm:
|
|
87
|
+
* 1. Find the two separators around the prompt area
|
|
88
|
+
* 2. Scan backwards from TOP separator to find ● or ❯ (interaction start)
|
|
89
|
+
* 3. Check the slice between interaction start and TOP separator for signals
|
|
90
|
+
*
|
|
91
|
+
* @returns 'interrupted' if user pressed Esc during work,
|
|
92
|
+
* 'declined' if user cancelled a prompt,
|
|
93
|
+
* null if no interruption detected
|
|
94
|
+
*/
|
|
95
|
+
export function detectRecentInterruption(content: string): 'interrupted' | 'declined' | null {
|
|
96
|
+
if (!content) return null;
|
|
97
|
+
|
|
98
|
+
const lines = content.split('\n');
|
|
99
|
+
|
|
100
|
+
// If there's active UI (menu or working), don't detect old interruptions
|
|
101
|
+
const bottomLines = lines.slice(-5).join('\n');
|
|
102
|
+
if (
|
|
103
|
+
bottomLines.includes('Esc to cancel') ||
|
|
104
|
+
bottomLines.includes('Esc to interrupt') ||
|
|
105
|
+
bottomLines.includes('ctrl+c to interrupt')
|
|
106
|
+
) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Find the BOTTOM separator (last separator in the pane)
|
|
111
|
+
let bottomSepIdx = -1;
|
|
112
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
113
|
+
if (lines[i].startsWith('─────')) {
|
|
114
|
+
bottomSepIdx = i;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (bottomSepIdx === -1) return null;
|
|
119
|
+
|
|
120
|
+
// Find the TOP separator (second-to-last separator, above the prompt)
|
|
121
|
+
let topSepIdx = -1;
|
|
122
|
+
for (let i = bottomSepIdx - 1; i >= 0; i--) {
|
|
123
|
+
if (lines[i].startsWith('─────')) {
|
|
124
|
+
topSepIdx = i;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (topSepIdx === -1) return null;
|
|
129
|
+
|
|
130
|
+
// Scan backwards from TOP separator to find the interaction start (● or ❯)
|
|
131
|
+
let interactionStartIdx = -1;
|
|
132
|
+
const maxScan = Math.max(0, topSepIdx - 15);
|
|
133
|
+
for (let i = topSepIdx - 1; i >= maxScan; i--) {
|
|
134
|
+
const line = lines[i];
|
|
135
|
+
if (line.startsWith('●') || line.startsWith('❯')) {
|
|
136
|
+
interactionStartIdx = i;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (interactionStartIdx === -1) return null;
|
|
141
|
+
|
|
142
|
+
// Check the slice from interaction start to TOP separator for signals
|
|
143
|
+
const slice = lines.slice(interactionStartIdx, topSepIdx).join('\n');
|
|
144
|
+
|
|
145
|
+
if (slice.includes('Interrupted')) return 'interrupted';
|
|
146
|
+
if (slice.includes('User declined to answer')) return 'declined';
|
|
147
|
+
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Check if a tmux pane shows a recent interruption/cancellation.
|
|
153
|
+
* Returns the session update to apply, or null if no update needed.
|
|
154
|
+
*
|
|
155
|
+
* @param tmuxTarget - The tmux target in format "session:window.pane"
|
|
156
|
+
* @returns Session fields to update if interruption detected, null otherwise
|
|
157
|
+
*/
|
|
158
|
+
export function checkForInterruption(tmuxTarget: string): { state: 'idle'; current_action: null; prompt_text: null } | null {
|
|
159
|
+
const content = capturePaneContent(tmuxTarget);
|
|
160
|
+
if (!content) return null;
|
|
161
|
+
|
|
162
|
+
const interruption = detectRecentInterruption(content);
|
|
163
|
+
if (interruption) {
|
|
164
|
+
return { state: 'idle', current_action: null, prompt_text: null };
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|