parasor 0.1.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/LICENSE +21 -0
- package/README.md +208 -0
- package/THIRD-PARTY-NOTICES.md +138 -0
- package/bin/parasor.mjs +3 -0
- package/node_modules/@parasor/shared/dist/client.d.ts +8 -0
- package/node_modules/@parasor/shared/dist/client.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/client.js +2 -0
- package/node_modules/@parasor/shared/dist/client.js.map +1 -0
- package/node_modules/@parasor/shared/dist/drops.d.ts +24 -0
- package/node_modules/@parasor/shared/dist/drops.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/drops.js +2 -0
- package/node_modules/@parasor/shared/dist/drops.js.map +1 -0
- package/node_modules/@parasor/shared/dist/file-uploads.d.ts +56 -0
- package/node_modules/@parasor/shared/dist/file-uploads.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/file-uploads.js +13 -0
- package/node_modules/@parasor/shared/dist/file-uploads.js.map +1 -0
- package/node_modules/@parasor/shared/dist/ide-commands.d.ts +8 -0
- package/node_modules/@parasor/shared/dist/ide-commands.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/ide-commands.js +59 -0
- package/node_modules/@parasor/shared/dist/ide-commands.js.map +1 -0
- package/node_modules/@parasor/shared/dist/pane-commands.d.ts +7 -0
- package/node_modules/@parasor/shared/dist/pane-commands.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/pane-commands.js +47 -0
- package/node_modules/@parasor/shared/dist/pane-commands.js.map +1 -0
- package/node_modules/@parasor/shared/dist/pane-model.d.ts +63 -0
- package/node_modules/@parasor/shared/dist/pane-model.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/pane-model.js +89 -0
- package/node_modules/@parasor/shared/dist/pane-model.js.map +1 -0
- package/node_modules/@parasor/shared/dist/panes.d.ts +33 -0
- package/node_modules/@parasor/shared/dist/panes.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/panes.js +2 -0
- package/node_modules/@parasor/shared/dist/panes.js.map +1 -0
- package/node_modules/@parasor/shared/dist/runtime.d.ts +180 -0
- package/node_modules/@parasor/shared/dist/runtime.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/runtime.js +2 -0
- package/node_modules/@parasor/shared/dist/runtime.js.map +1 -0
- package/node_modules/@parasor/shared/dist/state.d.ts +192 -0
- package/node_modules/@parasor/shared/dist/state.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/state.js +10 -0
- package/node_modules/@parasor/shared/dist/state.js.map +1 -0
- package/node_modules/@parasor/shared/dist/terminal.d.ts +191 -0
- package/node_modules/@parasor/shared/dist/terminal.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/terminal.js +174 -0
- package/node_modules/@parasor/shared/dist/terminal.js.map +1 -0
- package/node_modules/@parasor/shared/dist/types.d.ts +13 -0
- package/node_modules/@parasor/shared/dist/types.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/types.js +13 -0
- package/node_modules/@parasor/shared/dist/types.js.map +1 -0
- package/node_modules/@parasor/shared/dist/worktree-local-files.d.ts +14 -0
- package/node_modules/@parasor/shared/dist/worktree-local-files.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/worktree-local-files.js +41 -0
- package/node_modules/@parasor/shared/dist/worktree-local-files.js.map +1 -0
- package/node_modules/@parasor/shared/dist/ws-events.d.ts +152 -0
- package/node_modules/@parasor/shared/dist/ws-events.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/ws-events.js +2 -0
- package/node_modules/@parasor/shared/dist/ws-events.js.map +1 -0
- package/node_modules/@parasor/shared/package.json +13 -0
- package/package.json +61 -0
- package/server/agent-detector/agent-state-store.d.ts +23 -0
- package/server/agent-detector/agent-state-store.d.ts.map +1 -0
- package/server/agent-detector/agent-state-store.js +110 -0
- package/server/agent-detector/agent-state-store.js.map +1 -0
- package/server/agent-detector/detector.d.ts +80 -0
- package/server/agent-detector/detector.d.ts.map +1 -0
- package/server/agent-detector/detector.js +219 -0
- package/server/agent-detector/detector.js.map +1 -0
- package/server/agent-detector/event-map.d.ts +25 -0
- package/server/agent-detector/event-map.d.ts.map +1 -0
- package/server/agent-detector/event-map.js +136 -0
- package/server/agent-detector/event-map.js.map +1 -0
- package/server/agent-detector/manual-agent-tracker.d.ts +19 -0
- package/server/agent-detector/manual-agent-tracker.d.ts.map +1 -0
- package/server/agent-detector/manual-agent-tracker.js +123 -0
- package/server/agent-detector/manual-agent-tracker.js.map +1 -0
- package/server/agent-detector/output-eligibility.d.ts +3 -0
- package/server/agent-detector/output-eligibility.d.ts.map +1 -0
- package/server/agent-detector/output-eligibility.js +39 -0
- package/server/agent-detector/output-eligibility.js.map +1 -0
- package/server/application/files/errors.d.ts +28 -0
- package/server/application/files/errors.d.ts.map +1 -0
- package/server/application/files/errors.js +55 -0
- package/server/application/files/errors.js.map +1 -0
- package/server/application/files/local-filesystem.d.ts +36 -0
- package/server/application/files/local-filesystem.d.ts.map +1 -0
- package/server/application/files/local-filesystem.js +171 -0
- package/server/application/files/local-filesystem.js.map +1 -0
- package/server/application/files/project-file-queries.d.ts +16 -0
- package/server/application/files/project-file-queries.d.ts.map +1 -0
- package/server/application/files/project-file-queries.js +126 -0
- package/server/application/files/project-file-queries.js.map +1 -0
- package/server/application/integrations/errors.d.ts +16 -0
- package/server/application/integrations/errors.d.ts.map +1 -0
- package/server/application/integrations/errors.js +31 -0
- package/server/application/integrations/errors.js.map +1 -0
- package/server/application/integrations/hook-notify.d.ts +32 -0
- package/server/application/integrations/hook-notify.d.ts.map +1 -0
- package/server/application/integrations/hook-notify.js +118 -0
- package/server/application/integrations/hook-notify.js.map +1 -0
- package/server/application/integrations/open-url.d.ts +11 -0
- package/server/application/integrations/open-url.d.ts.map +1 -0
- package/server/application/integrations/open-url.js +23 -0
- package/server/application/integrations/open-url.js.map +1 -0
- package/server/application/ports.d.ts +11 -0
- package/server/application/ports.d.ts.map +1 -0
- package/server/application/ports.js +2 -0
- package/server/application/ports.js.map +1 -0
- package/server/application/workspace/errors.d.ts +21 -0
- package/server/application/workspace/errors.d.ts.map +1 -0
- package/server/application/workspace/errors.js +21 -0
- package/server/application/workspace/errors.js.map +1 -0
- package/server/application/workspace/pane-commands.d.ts +47 -0
- package/server/application/workspace/pane-commands.d.ts.map +1 -0
- package/server/application/workspace/pane-commands.js +193 -0
- package/server/application/workspace/pane-commands.js.map +1 -0
- package/server/application/workspace/project-commands.d.ts +34 -0
- package/server/application/workspace/project-commands.d.ts.map +1 -0
- package/server/application/workspace/project-commands.js +81 -0
- package/server/application/workspace/project-commands.js.map +1 -0
- package/server/application/workspace/project-queries.d.ts +21 -0
- package/server/application/workspace/project-queries.d.ts.map +1 -0
- package/server/application/workspace/project-queries.js +216 -0
- package/server/application/workspace/project-queries.js.map +1 -0
- package/server/application/workspace/session-commands.d.ts +24 -0
- package/server/application/workspace/session-commands.d.ts.map +1 -0
- package/server/application/workspace/session-commands.js +123 -0
- package/server/application/workspace/session-commands.js.map +1 -0
- package/server/application/workspace/session-queries.d.ts +14 -0
- package/server/application/workspace/session-queries.d.ts.map +1 -0
- package/server/application/workspace/session-queries.js +47 -0
- package/server/application/workspace/session-queries.js.map +1 -0
- package/server/application/workspace/worktree-commands.d.ts +98 -0
- package/server/application/workspace/worktree-commands.d.ts.map +1 -0
- package/server/application/workspace/worktree-commands.js +323 -0
- package/server/application/workspace/worktree-commands.js.map +1 -0
- package/server/application/workspace/worktree-local-files.d.ts +11 -0
- package/server/application/workspace/worktree-local-files.d.ts.map +1 -0
- package/server/application/workspace/worktree-local-files.js +223 -0
- package/server/application/workspace/worktree-local-files.js.map +1 -0
- package/server/application/workspace/worktree-reconcile.d.ts +21 -0
- package/server/application/workspace/worktree-reconcile.d.ts.map +1 -0
- package/server/application/workspace/worktree-reconcile.js +49 -0
- package/server/application/workspace/worktree-reconcile.js.map +1 -0
- package/server/auth/origin.d.ts +17 -0
- package/server/auth/origin.d.ts.map +1 -0
- package/server/auth/origin.js +93 -0
- package/server/auth/origin.js.map +1 -0
- package/server/auth/pairing-token.d.ts +28 -0
- package/server/auth/pairing-token.d.ts.map +1 -0
- package/server/auth/pairing-token.js +46 -0
- package/server/auth/pairing-token.js.map +1 -0
- package/server/auth/token-exchange.d.ts +11 -0
- package/server/auth/token-exchange.d.ts.map +1 -0
- package/server/auth/token-exchange.js +27 -0
- package/server/auth/token-exchange.js.map +1 -0
- package/server/auth/token.d.ts +18 -0
- package/server/auth/token.d.ts.map +1 -0
- package/server/auth/token.js +115 -0
- package/server/auth/token.js.map +1 -0
- package/server/bootstrap/create-app-server.d.ts +49 -0
- package/server/bootstrap/create-app-server.d.ts.map +1 -0
- package/server/bootstrap/create-app-server.js +154 -0
- package/server/bootstrap/create-app-server.js.map +1 -0
- package/server/bootstrap/project-runtime.d.ts +29 -0
- package/server/bootstrap/project-runtime.d.ts.map +1 -0
- package/server/bootstrap/project-runtime.js +253 -0
- package/server/bootstrap/project-runtime.js.map +1 -0
- package/server/bootstrap/pty-env.d.ts +3 -0
- package/server/bootstrap/pty-env.d.ts.map +1 -0
- package/server/bootstrap/pty-env.js +15 -0
- package/server/bootstrap/pty-env.js.map +1 -0
- package/server/bootstrap/reconcile-state.d.ts +16 -0
- package/server/bootstrap/reconcile-state.d.ts.map +1 -0
- package/server/bootstrap/reconcile-state.js +73 -0
- package/server/bootstrap/reconcile-state.js.map +1 -0
- package/server/bootstrap/runtime-loops.d.ts +51 -0
- package/server/bootstrap/runtime-loops.d.ts.map +1 -0
- package/server/bootstrap/runtime-loops.js +189 -0
- package/server/bootstrap/runtime-loops.js.map +1 -0
- package/server/bootstrap/runtime-port.d.ts +4 -0
- package/server/bootstrap/runtime-port.d.ts.map +1 -0
- package/server/bootstrap/runtime-port.js +52 -0
- package/server/bootstrap/runtime-port.js.map +1 -0
- package/server/bootstrap/safety-gate.d.ts +22 -0
- package/server/bootstrap/safety-gate.d.ts.map +1 -0
- package/server/bootstrap/safety-gate.js +43 -0
- package/server/bootstrap/safety-gate.js.map +1 -0
- package/server/bootstrap/shutdown-marker.d.ts +35 -0
- package/server/bootstrap/shutdown-marker.d.ts.map +1 -0
- package/server/bootstrap/shutdown-marker.js +100 -0
- package/server/bootstrap/shutdown-marker.js.map +1 -0
- package/server/bootstrap/shutdown-runtime.d.ts +62 -0
- package/server/bootstrap/shutdown-runtime.d.ts.map +1 -0
- package/server/bootstrap/shutdown-runtime.js +66 -0
- package/server/bootstrap/shutdown-runtime.js.map +1 -0
- package/server/bootstrap/startup-banner.d.ts +34 -0
- package/server/bootstrap/startup-banner.d.ts.map +1 -0
- package/server/bootstrap/startup-banner.js +114 -0
- package/server/bootstrap/startup-banner.js.map +1 -0
- package/server/bootstrap/wire-runtime.d.ts +42 -0
- package/server/bootstrap/wire-runtime.d.ts.map +1 -0
- package/server/bootstrap/wire-runtime.js +205 -0
- package/server/bootstrap/wire-runtime.js.map +1 -0
- package/server/cli/help.d.ts +3 -0
- package/server/cli/help.d.ts.map +1 -0
- package/server/cli/help.js +39 -0
- package/server/cli/help.js.map +1 -0
- package/server/cli/hook-client.d.ts +12 -0
- package/server/cli/hook-client.d.ts.map +1 -0
- package/server/cli/hook-client.js +81 -0
- package/server/cli/hook-client.js.map +1 -0
- package/server/cli/hook.d.ts +3 -0
- package/server/cli/hook.d.ts.map +1 -0
- package/server/cli/hook.js +152 -0
- package/server/cli/hook.js.map +1 -0
- package/server/cli/main.d.ts +2 -0
- package/server/cli/main.d.ts.map +1 -0
- package/server/cli/main.js +133 -0
- package/server/cli/main.js.map +1 -0
- package/server/cli/notify.d.ts +19 -0
- package/server/cli/notify.d.ts.map +1 -0
- package/server/cli/notify.js +77 -0
- package/server/cli/notify.js.map +1 -0
- package/server/cli/open.d.ts +2 -0
- package/server/cli/open.d.ts.map +1 -0
- package/server/cli/open.js +47 -0
- package/server/cli/open.js.map +1 -0
- package/server/cli/probe-daemon-version.d.ts +46 -0
- package/server/cli/probe-daemon-version.d.ts.map +1 -0
- package/server/cli/probe-daemon-version.js +167 -0
- package/server/cli/probe-daemon-version.js.map +1 -0
- package/server/cli/pty-host.d.ts +36 -0
- package/server/cli/pty-host.d.ts.map +1 -0
- package/server/cli/pty-host.js +390 -0
- package/server/cli/pty-host.js.map +1 -0
- package/server/cli/qr.d.ts +2 -0
- package/server/cli/qr.d.ts.map +1 -0
- package/server/cli/qr.js +70 -0
- package/server/cli/qr.js.map +1 -0
- package/server/cli/restart-confirm.d.ts +33 -0
- package/server/cli/restart-confirm.d.ts.map +1 -0
- package/server/cli/restart-confirm.js +107 -0
- package/server/cli/restart-confirm.js.map +1 -0
- package/server/cli/restart.d.ts +17 -0
- package/server/cli/restart.d.ts.map +1 -0
- package/server/cli/restart.js +145 -0
- package/server/cli/restart.js.map +1 -0
- package/server/cli/service-darwin.d.ts +70 -0
- package/server/cli/service-darwin.d.ts.map +1 -0
- package/server/cli/service-darwin.js +562 -0
- package/server/cli/service-darwin.js.map +1 -0
- package/server/cli/service-linux.d.ts +81 -0
- package/server/cli/service-linux.d.ts.map +1 -0
- package/server/cli/service-linux.js +412 -0
- package/server/cli/service-linux.js.map +1 -0
- package/server/cli/service.d.ts +33 -0
- package/server/cli/service.d.ts.map +1 -0
- package/server/cli/service.js +133 -0
- package/server/cli/service.js.map +1 -0
- package/server/cli/shim-installer.d.ts +35 -0
- package/server/cli/shim-installer.d.ts.map +1 -0
- package/server/cli/shim-installer.js +662 -0
- package/server/cli/shim-installer.js.map +1 -0
- package/server/cli/shim-open.d.ts +2 -0
- package/server/cli/shim-open.d.ts.map +1 -0
- package/server/cli/shim-open.js +128 -0
- package/server/cli/shim-open.js.map +1 -0
- package/server/cli/shutdown-deps.d.ts +41 -0
- package/server/cli/shutdown-deps.d.ts.map +1 -0
- package/server/cli/shutdown-deps.js +158 -0
- package/server/cli/shutdown-deps.js.map +1 -0
- package/server/cli/stop.d.ts +11 -0
- package/server/cli/stop.d.ts.map +1 -0
- package/server/cli/stop.js +123 -0
- package/server/cli/stop.js.map +1 -0
- package/server/cli/unknown-command.d.ts +8 -0
- package/server/cli/unknown-command.d.ts.map +1 -0
- package/server/cli/unknown-command.js +14 -0
- package/server/cli/unknown-command.js.map +1 -0
- package/server/debug/agent-status-recorder.d.ts +57 -0
- package/server/debug/agent-status-recorder.d.ts.map +1 -0
- package/server/debug/agent-status-recorder.js +209 -0
- package/server/debug/agent-status-recorder.js.map +1 -0
- package/server/debug/terminal-trace-recorder.d.ts +41 -0
- package/server/debug/terminal-trace-recorder.d.ts.map +1 -0
- package/server/debug/terminal-trace-recorder.js +112 -0
- package/server/debug/terminal-trace-recorder.js.map +1 -0
- package/server/fonts/catalog.d.ts +35 -0
- package/server/fonts/catalog.d.ts.map +1 -0
- package/server/fonts/catalog.js +76 -0
- package/server/fonts/catalog.js.map +1 -0
- package/server/fonts/installer.d.ts +45 -0
- package/server/fonts/installer.d.ts.map +1 -0
- package/server/fonts/installer.js +201 -0
- package/server/fonts/installer.js.map +1 -0
- package/server/fonts/routes.d.ts +4 -0
- package/server/fonts/routes.d.ts.map +1 -0
- package/server/fonts/routes.js +91 -0
- package/server/fonts/routes.js.map +1 -0
- package/server/fs/drops.d.ts +50 -0
- package/server/fs/drops.d.ts.map +1 -0
- package/server/fs/drops.js +137 -0
- package/server/fs/drops.js.map +1 -0
- package/server/fs/file-uploads.d.ts +57 -0
- package/server/fs/file-uploads.d.ts.map +1 -0
- package/server/fs/file-uploads.js +214 -0
- package/server/fs/file-uploads.js.map +1 -0
- package/server/fs/file-watcher.d.ts +22 -0
- package/server/fs/file-watcher.d.ts.map +1 -0
- package/server/fs/file-watcher.js +105 -0
- package/server/fs/file-watcher.js.map +1 -0
- package/server/fs/git-watcher.d.ts +76 -0
- package/server/fs/git-watcher.d.ts.map +1 -0
- package/server/fs/git-watcher.js +356 -0
- package/server/fs/git-watcher.js.map +1 -0
- package/server/fs/media.d.ts +35 -0
- package/server/fs/media.d.ts.map +1 -0
- package/server/fs/media.js +271 -0
- package/server/fs/media.js.map +1 -0
- package/server/fs/service.d.ts +97 -0
- package/server/fs/service.d.ts.map +1 -0
- package/server/fs/service.js +306 -0
- package/server/fs/service.js.map +1 -0
- package/server/fs/upload-staging.d.ts +76 -0
- package/server/fs/upload-staging.d.ts.map +1 -0
- package/server/fs/upload-staging.js +283 -0
- package/server/fs/upload-staging.js.map +1 -0
- package/server/fs/watcher-lifecycle.d.ts +24 -0
- package/server/fs/watcher-lifecycle.d.ts.map +1 -0
- package/server/fs/watcher-lifecycle.js +105 -0
- package/server/fs/watcher-lifecycle.js.map +1 -0
- package/server/index.d.ts +17 -0
- package/server/index.d.ts.map +1 -0
- package/server/index.js +510 -0
- package/server/index.js.map +1 -0
- package/server/ipc/socket-server.d.ts +28 -0
- package/server/ipc/socket-server.d.ts.map +1 -0
- package/server/ipc/socket-server.js +206 -0
- package/server/ipc/socket-server.js.map +1 -0
- package/server/lib/git-exec.d.ts +38 -0
- package/server/lib/git-exec.d.ts.map +1 -0
- package/server/lib/git-exec.js +96 -0
- package/server/lib/git-exec.js.map +1 -0
- package/server/lib/open-in-ide.d.ts +22 -0
- package/server/lib/open-in-ide.d.ts.map +1 -0
- package/server/lib/open-in-ide.js +90 -0
- package/server/lib/open-in-ide.js.map +1 -0
- package/server/lib/open-in-os.d.ts +20 -0
- package/server/lib/open-in-os.d.ts.map +1 -0
- package/server/lib/open-in-os.js +51 -0
- package/server/lib/open-in-os.js.map +1 -0
- package/server/lib/path.d.ts +2 -0
- package/server/lib/path.d.ts.map +1 -0
- package/server/lib/path.js +10 -0
- package/server/lib/path.js.map +1 -0
- package/server/lib/promise-mutex.d.ts +7 -0
- package/server/lib/promise-mutex.d.ts.map +1 -0
- package/server/lib/promise-mutex.js +26 -0
- package/server/lib/promise-mutex.js.map +1 -0
- package/server/lib/sd-notify.d.ts +8 -0
- package/server/lib/sd-notify.d.ts.map +1 -0
- package/server/lib/sd-notify.js +27 -0
- package/server/lib/sd-notify.js.map +1 -0
- package/server/net/local-machine.d.ts +7 -0
- package/server/net/local-machine.d.ts.map +1 -0
- package/server/net/local-machine.js +79 -0
- package/server/net/local-machine.js.map +1 -0
- package/server/net/reachable-host.d.ts +12 -0
- package/server/net/reachable-host.d.ts.map +1 -0
- package/server/net/reachable-host.js +25 -0
- package/server/net/reachable-host.js.map +1 -0
- package/server/network/endpoints.d.ts +14 -0
- package/server/network/endpoints.d.ts.map +1 -0
- package/server/network/endpoints.js +104 -0
- package/server/network/endpoints.js.map +1 -0
- package/server/network/qr.d.ts +16 -0
- package/server/network/qr.d.ts.map +1 -0
- package/server/network/qr.js +89 -0
- package/server/network/qr.js.map +1 -0
- package/server/port-forwarder/forwarder.d.ts +47 -0
- package/server/port-forwarder/forwarder.d.ts.map +1 -0
- package/server/port-forwarder/forwarder.js +159 -0
- package/server/port-forwarder/forwarder.js.map +1 -0
- package/server/port-scanner/scanner.d.ts +24 -0
- package/server/port-scanner/scanner.d.ts.map +1 -0
- package/server/port-scanner/scanner.js +193 -0
- package/server/port-scanner/scanner.js.map +1 -0
- package/server/pty/connection-lifecycle.d.ts +50 -0
- package/server/pty/connection-lifecycle.d.ts.map +1 -0
- package/server/pty/connection-lifecycle.js +113 -0
- package/server/pty/connection-lifecycle.js.map +1 -0
- package/server/pty/daemon-connect.d.ts +52 -0
- package/server/pty/daemon-connect.d.ts.map +1 -0
- package/server/pty/daemon-connect.js +62 -0
- package/server/pty/daemon-connect.js.map +1 -0
- package/server/pty/handshake-timeout-race.d.ts +22 -0
- package/server/pty/handshake-timeout-race.d.ts.map +1 -0
- package/server/pty/handshake-timeout-race.js +23 -0
- package/server/pty/handshake-timeout-race.js.map +1 -0
- package/server/pty/headless-replay-snapshot.d.ts +28 -0
- package/server/pty/headless-replay-snapshot.d.ts.map +1 -0
- package/server/pty/headless-replay-snapshot.js +285 -0
- package/server/pty/headless-replay-snapshot.js.map +1 -0
- package/server/pty/headless-terminal-state-cache.d.ts +31 -0
- package/server/pty/headless-terminal-state-cache.d.ts.map +1 -0
- package/server/pty/headless-terminal-state-cache.js +119 -0
- package/server/pty/headless-terminal-state-cache.js.map +1 -0
- package/server/pty/hello-ack-validator.d.ts +15 -0
- package/server/pty/hello-ack-validator.d.ts.map +1 -0
- package/server/pty/hello-ack-validator.js +30 -0
- package/server/pty/hello-ack-validator.js.map +1 -0
- package/server/pty/host-daemon/bootstrap.d.ts +100 -0
- package/server/pty/host-daemon/bootstrap.d.ts.map +1 -0
- package/server/pty/host-daemon/bootstrap.js +611 -0
- package/server/pty/host-daemon/bootstrap.js.map +1 -0
- package/server/pty/host-daemon/daemon.d.ts +111 -0
- package/server/pty/host-daemon/daemon.d.ts.map +1 -0
- package/server/pty/host-daemon/daemon.js +648 -0
- package/server/pty/host-daemon/daemon.js.map +1 -0
- package/server/pty/host-daemon/entry.d.ts +3 -0
- package/server/pty/host-daemon/entry.d.ts.map +1 -0
- package/server/pty/host-daemon/entry.js +72 -0
- package/server/pty/host-daemon/entry.js.map +1 -0
- package/server/pty/host-daemon/lockfile.d.ts +12 -0
- package/server/pty/host-daemon/lockfile.d.ts.map +1 -0
- package/server/pty/host-daemon/lockfile.js +120 -0
- package/server/pty/host-daemon/lockfile.js.map +1 -0
- package/server/pty/host-daemon/mode-marker.d.ts +77 -0
- package/server/pty/host-daemon/mode-marker.d.ts.map +1 -0
- package/server/pty/host-daemon/mode-marker.js +228 -0
- package/server/pty/host-daemon/mode-marker.js.map +1 -0
- package/server/pty/host-daemon/orphan-cleanup.d.ts +42 -0
- package/server/pty/host-daemon/orphan-cleanup.d.ts.map +1 -0
- package/server/pty/host-daemon/orphan-cleanup.js +84 -0
- package/server/pty/host-daemon/orphan-cleanup.js.map +1 -0
- package/server/pty/host-daemon/paths.d.ts +10 -0
- package/server/pty/host-daemon/paths.d.ts.map +1 -0
- package/server/pty/host-daemon/paths.js +56 -0
- package/server/pty/host-daemon/paths.js.map +1 -0
- package/server/pty/host-daemon/server-connection.d.ts +44 -0
- package/server/pty/host-daemon/server-connection.d.ts.map +1 -0
- package/server/pty/host-daemon/server-connection.js +100 -0
- package/server/pty/host-daemon/server-connection.js.map +1 -0
- package/server/pty/host-daemon/service-detection.d.ts +24 -0
- package/server/pty/host-daemon/service-detection.d.ts.map +1 -0
- package/server/pty/host-daemon/service-detection.js +16 -0
- package/server/pty/host-daemon/service-detection.js.map +1 -0
- package/server/pty/host-daemon/socket-ready.d.ts +22 -0
- package/server/pty/host-daemon/socket-ready.d.ts.map +1 -0
- package/server/pty/host-daemon/socket-ready.js +33 -0
- package/server/pty/host-daemon/socket-ready.js.map +1 -0
- package/server/pty/host-daemon/spawn-daemon.d.ts +45 -0
- package/server/pty/host-daemon/spawn-daemon.d.ts.map +1 -0
- package/server/pty/host-daemon/spawn-daemon.js +155 -0
- package/server/pty/host-daemon/spawn-daemon.js.map +1 -0
- package/server/pty/host-daemon/terminate-daemon.d.ts +16 -0
- package/server/pty/host-daemon/terminate-daemon.d.ts.map +1 -0
- package/server/pty/host-daemon/terminate-daemon.js +128 -0
- package/server/pty/host-daemon/terminate-daemon.js.map +1 -0
- package/server/pty/host-protocol/frames.d.ts +110 -0
- package/server/pty/host-protocol/frames.d.ts.map +1 -0
- package/server/pty/host-protocol/frames.js +255 -0
- package/server/pty/host-protocol/frames.js.map +1 -0
- package/server/pty/host-protocol/messages.d.ts +140 -0
- package/server/pty/host-protocol/messages.d.ts.map +1 -0
- package/server/pty/host-protocol/messages.js +117 -0
- package/server/pty/host-protocol/messages.js.map +1 -0
- package/server/pty/host.d.ts +273 -0
- package/server/pty/host.d.ts.map +1 -0
- package/server/pty/host.js +184 -0
- package/server/pty/host.js.map +1 -0
- package/server/pty/in-process-host.d.ts +224 -0
- package/server/pty/in-process-host.d.ts.map +1 -0
- package/server/pty/in-process-host.js +1183 -0
- package/server/pty/in-process-host.js.map +1 -0
- package/server/pty/osc7-lifecycle.d.ts +8 -0
- package/server/pty/osc7-lifecycle.d.ts.map +1 -0
- package/server/pty/osc7-lifecycle.js +22 -0
- package/server/pty/osc7-lifecycle.js.map +1 -0
- package/server/pty/osc7-parser.d.ts +23 -0
- package/server/pty/osc7-parser.d.ts.map +1 -0
- package/server/pty/osc7-parser.js +91 -0
- package/server/pty/osc7-parser.js.map +1 -0
- package/server/pty/remote-host.d.ts +188 -0
- package/server/pty/remote-host.d.ts.map +1 -0
- package/server/pty/remote-host.js +810 -0
- package/server/pty/remote-host.js.map +1 -0
- package/server/pty/request-correlator.d.ts +59 -0
- package/server/pty/request-correlator.d.ts.map +1 -0
- package/server/pty/request-correlator.js +75 -0
- package/server/pty/request-correlator.js.map +1 -0
- package/server/pty/scrollback-log.d.ts +130 -0
- package/server/pty/scrollback-log.d.ts.map +1 -0
- package/server/pty/scrollback-log.js +344 -0
- package/server/pty/scrollback-log.js.map +1 -0
- package/server/pty/scrollback-sanitize.d.ts +2 -0
- package/server/pty/scrollback-sanitize.d.ts.map +1 -0
- package/server/pty/scrollback-sanitize.js +54 -0
- package/server/pty/scrollback-sanitize.js.map +1 -0
- package/server/pty/session-mirror.d.ts +67 -0
- package/server/pty/session-mirror.d.ts.map +1 -0
- package/server/pty/session-mirror.js +112 -0
- package/server/pty/session-mirror.js.map +1 -0
- package/server/pty/session-policy.d.ts +85 -0
- package/server/pty/session-policy.d.ts.map +1 -0
- package/server/pty/session-policy.js +186 -0
- package/server/pty/session-policy.js.map +1 -0
- package/server/pty/version-mismatch-recovery.d.ts +71 -0
- package/server/pty/version-mismatch-recovery.d.ts.map +1 -0
- package/server/pty/version-mismatch-recovery.js +63 -0
- package/server/pty/version-mismatch-recovery.js.map +1 -0
- package/server/routes/debug-agent-status.d.ts +5 -0
- package/server/routes/debug-agent-status.d.ts.map +1 -0
- package/server/routes/debug-agent-status.js +22 -0
- package/server/routes/debug-agent-status.js.map +1 -0
- package/server/routes/debug-diagnostics.d.ts +8 -0
- package/server/routes/debug-diagnostics.d.ts.map +1 -0
- package/server/routes/debug-diagnostics.js +34 -0
- package/server/routes/debug-diagnostics.js.map +1 -0
- package/server/routes/debug-terminal-trace.d.ts +16 -0
- package/server/routes/debug-terminal-trace.d.ts.map +1 -0
- package/server/routes/debug-terminal-trace.js +545 -0
- package/server/routes/debug-terminal-trace.js.map +1 -0
- package/server/routes/drops.d.ts +13 -0
- package/server/routes/drops.d.ts.map +1 -0
- package/server/routes/drops.js +126 -0
- package/server/routes/drops.js.map +1 -0
- package/server/routes/file-uploads.d.ts +9 -0
- package/server/routes/file-uploads.d.ts.map +1 -0
- package/server/routes/file-uploads.js +119 -0
- package/server/routes/file-uploads.js.map +1 -0
- package/server/routes/files.d.ts +9 -0
- package/server/routes/files.d.ts.map +1 -0
- package/server/routes/files.js +441 -0
- package/server/routes/files.js.map +1 -0
- package/server/routes/filesystem.d.ts +6 -0
- package/server/routes/filesystem.d.ts.map +1 -0
- package/server/routes/filesystem.js +76 -0
- package/server/routes/filesystem.js.map +1 -0
- package/server/routes/git.d.ts +38 -0
- package/server/routes/git.d.ts.map +1 -0
- package/server/routes/git.js +585 -0
- package/server/routes/git.js.map +1 -0
- package/server/routes/healthz.d.ts +8 -0
- package/server/routes/healthz.d.ts.map +1 -0
- package/server/routes/healthz.js +24 -0
- package/server/routes/healthz.js.map +1 -0
- package/server/routes/hook.d.ts +14 -0
- package/server/routes/hook.d.ts.map +1 -0
- package/server/routes/hook.js +86 -0
- package/server/routes/hook.js.map +1 -0
- package/server/routes/ide-commands.d.ts +9 -0
- package/server/routes/ide-commands.d.ts.map +1 -0
- package/server/routes/ide-commands.js +23 -0
- package/server/routes/ide-commands.js.map +1 -0
- package/server/routes/lib/resolve-worktree.d.ts +30 -0
- package/server/routes/lib/resolve-worktree.d.ts.map +1 -0
- package/server/routes/lib/resolve-worktree.js +35 -0
- package/server/routes/lib/resolve-worktree.js.map +1 -0
- package/server/routes/open.d.ts +4 -0
- package/server/routes/open.d.ts.map +1 -0
- package/server/routes/open.js +21 -0
- package/server/routes/open.js.map +1 -0
- package/server/routes/pane-commands.d.ts +9 -0
- package/server/routes/pane-commands.d.ts.map +1 -0
- package/server/routes/pane-commands.js +23 -0
- package/server/routes/pane-commands.js.map +1 -0
- package/server/routes/projects.d.ts +15 -0
- package/server/routes/projects.d.ts.map +1 -0
- package/server/routes/projects.js +363 -0
- package/server/routes/projects.js.map +1 -0
- package/server/routes/server-notices.d.ts +4 -0
- package/server/routes/server-notices.d.ts.map +1 -0
- package/server/routes/server-notices.js +29 -0
- package/server/routes/server-notices.js.map +1 -0
- package/server/routes/service-config.d.ts +11 -0
- package/server/routes/service-config.d.ts.map +1 -0
- package/server/routes/service-config.js +64 -0
- package/server/routes/service-config.js.map +1 -0
- package/server/routes/sessions.d.ts +7 -0
- package/server/routes/sessions.d.ts.map +1 -0
- package/server/routes/sessions.js +218 -0
- package/server/routes/sessions.js.map +1 -0
- package/server/service/caffeinate.d.ts +33 -0
- package/server/service/caffeinate.d.ts.map +1 -0
- package/server/service/caffeinate.js +72 -0
- package/server/service/caffeinate.js.map +1 -0
- package/server/state/app-state.d.ts +167 -0
- package/server/state/app-state.d.ts.map +1 -0
- package/server/state/app-state.js +335 -0
- package/server/state/app-state.js.map +1 -0
- package/server/state/project-manager.d.ts +30 -0
- package/server/state/project-manager.d.ts.map +1 -0
- package/server/state/project-manager.js +128 -0
- package/server/state/project-manager.js.map +1 -0
- package/server/state/server-notices.d.ts +12 -0
- package/server/state/server-notices.d.ts.map +1 -0
- package/server/state/server-notices.js +32 -0
- package/server/state/server-notices.js.map +1 -0
- package/server/state/worktree-cache.d.ts +25 -0
- package/server/state/worktree-cache.d.ts.map +1 -0
- package/server/state/worktree-cache.js +53 -0
- package/server/state/worktree-cache.js.map +1 -0
- package/server/ws/events.d.ts +45 -0
- package/server/ws/events.d.ts.map +1 -0
- package/server/ws/events.js +134 -0
- package/server/ws/events.js.map +1 -0
- package/server/ws/keepalive.d.ts +27 -0
- package/server/ws/keepalive.d.ts.map +1 -0
- package/server/ws/keepalive.js +63 -0
- package/server/ws/keepalive.js.map +1 -0
- package/server/ws/terminal-attach.d.ts +13 -0
- package/server/ws/terminal-attach.d.ts.map +1 -0
- package/server/ws/terminal-attach.js +233 -0
- package/server/ws/terminal-attach.js.map +1 -0
- package/server/ws/terminal-flow.d.ts +17 -0
- package/server/ws/terminal-flow.d.ts.map +1 -0
- package/server/ws/terminal-flow.js +64 -0
- package/server/ws/terminal-flow.js.map +1 -0
- package/server/ws/terminal.d.ts +69 -0
- package/server/ws/terminal.d.ts.map +1 -0
- package/server/ws/terminal.js +311 -0
- package/server/ws/terminal.js.map +1 -0
- package/web/assets/EditorPane-CzzT3iYY.js +123 -0
- package/web/assets/SymbolsNerdFontMono-Regular-CwEZqMeU.woff2 +0 -0
- package/web/assets/TerminalPane-CjbYzePr.js +68 -0
- package/web/assets/TerminalPane-DkTCHfhq.css +1 -0
- package/web/assets/file-icons-JBi09j0r.js +6 -0
- package/web/assets/index-CTTkRpnn.css +2 -0
- package/web/assets/index-CmhewzMp.js +34 -0
- package/web/assets/session-resume-7f-tB-ZU.js +2 -0
- package/web/assets/terminal-trace-PuuFRybC.js +2803 -0
- package/web/assets/useVirtualKeyboard-DgJb9u9d.js +1 -0
- package/web/index.html +52 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
const execFileAsync = promisify(execFile);
|
|
4
|
+
const ESCAPE_MAP = {
|
|
5
|
+
"\\": "\\",
|
|
6
|
+
'"': '"',
|
|
7
|
+
n: "\n",
|
|
8
|
+
t: "\t",
|
|
9
|
+
a: "\x07",
|
|
10
|
+
b: "\b",
|
|
11
|
+
f: "\f",
|
|
12
|
+
r: "\r",
|
|
13
|
+
v: "\v",
|
|
14
|
+
};
|
|
15
|
+
function unquoteGitPath(raw) {
|
|
16
|
+
if (raw.length < 2 || raw[0] !== '"' || raw[raw.length - 1] !== '"')
|
|
17
|
+
return raw;
|
|
18
|
+
const inner = raw.slice(1, -1);
|
|
19
|
+
const bytes = [];
|
|
20
|
+
for (let i = 0; i < inner.length; i++) {
|
|
21
|
+
if (inner[i] === "\\" && i + 1 < inner.length) {
|
|
22
|
+
const next = inner[i + 1];
|
|
23
|
+
if (next >= "0" && next <= "3" && i + 3 < inner.length) {
|
|
24
|
+
const octal = inner.slice(i + 1, i + 4);
|
|
25
|
+
if (/^[0-3][0-7]{2}$/.test(octal)) {
|
|
26
|
+
bytes.push(parseInt(octal, 8));
|
|
27
|
+
i += 3;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const mapped = ESCAPE_MAP[next];
|
|
32
|
+
if (mapped !== undefined) {
|
|
33
|
+
for (let j = 0; j < mapped.length; j++)
|
|
34
|
+
bytes.push(mapped.charCodeAt(j));
|
|
35
|
+
i++;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
bytes.push(inner.charCodeAt(i));
|
|
40
|
+
}
|
|
41
|
+
return new TextDecoder().decode(new Uint8Array(bytes));
|
|
42
|
+
}
|
|
43
|
+
function findArrowInPorcelainPath(pathPart) {
|
|
44
|
+
if (pathPart.startsWith('"')) {
|
|
45
|
+
// Old path is quoted -- find closing quote (skip escaped quotes)
|
|
46
|
+
for (let i = 1; i < pathPart.length; i++) {
|
|
47
|
+
if (pathPart[i] === "\\" && i + 1 < pathPart.length) {
|
|
48
|
+
i++;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (pathPart[i] === '"')
|
|
52
|
+
return pathPart.indexOf(" -> ", i + 1);
|
|
53
|
+
}
|
|
54
|
+
return -1;
|
|
55
|
+
}
|
|
56
|
+
return pathPart.indexOf(" -> ");
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parse `git status --porcelain` output into a map of relative paths to status codes.
|
|
60
|
+
* Format per line: "XY path" where X=index status, Y=worktree status.
|
|
61
|
+
* Returns the most relevant single status character per file.
|
|
62
|
+
*/
|
|
63
|
+
export function parseGitPorcelain(raw) {
|
|
64
|
+
const result = {};
|
|
65
|
+
for (const line of raw.split("\n")) {
|
|
66
|
+
if (line.length < 4)
|
|
67
|
+
continue;
|
|
68
|
+
const x = line[0]; // index status
|
|
69
|
+
const y = line[1]; // worktree status
|
|
70
|
+
const pathPart = line.slice(3);
|
|
71
|
+
// Handle renames/copies: "R old -> new" / "C old -> new"
|
|
72
|
+
const isRenameOrCopy = x === "R" || x === "C";
|
|
73
|
+
const arrowIdx = isRenameOrCopy ? findArrowInPorcelainPath(pathPart) : -1;
|
|
74
|
+
const rawPath = arrowIdx >= 0 ? pathPart.slice(arrowIdx + 4) : pathPart;
|
|
75
|
+
const filePath = unquoteGitPath(rawPath);
|
|
76
|
+
// Pick the most visible status: worktree status takes priority over index
|
|
77
|
+
// unless index-only (staged but worktree clean)
|
|
78
|
+
if (x === "?" && y === "?") {
|
|
79
|
+
result[filePath] = "?";
|
|
80
|
+
}
|
|
81
|
+
else if (y !== " " && y !== "?") {
|
|
82
|
+
result[filePath] = y; // worktree change (M, D, etc.)
|
|
83
|
+
}
|
|
84
|
+
else if (x !== " " && x !== "?") {
|
|
85
|
+
result[filePath] = x; // index-only change (staged)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Parse `git status --porcelain=v2 -b` output into ahead/behind/dirtyCount.
|
|
92
|
+
*
|
|
93
|
+
* v2 line shapes (per `git-status(1)`):
|
|
94
|
+
* `# branch.ab +N -M` upstream tracking header (omitted when no upstream)
|
|
95
|
+
* `1 XY ...` ordinary changed entry
|
|
96
|
+
* `2 XY ...` rename/copy entry
|
|
97
|
+
* `u XY ...` unmerged entry
|
|
98
|
+
* `? <path>` untracked
|
|
99
|
+
* `! <path>` ignored (excluded from dirtyCount)
|
|
100
|
+
*
|
|
101
|
+
* `dirtyCount` includes 1/2/u entries plus `?` untracked. Ignored `!` is
|
|
102
|
+
* deliberately excluded so the sidebar counter matches what the user sees as
|
|
103
|
+
* actionable change.
|
|
104
|
+
*/
|
|
105
|
+
export function parseGitStatusV2(raw) {
|
|
106
|
+
let ahead;
|
|
107
|
+
let behind;
|
|
108
|
+
let dirtyCount = 0;
|
|
109
|
+
for (const line of raw.split("\n")) {
|
|
110
|
+
if (line.length === 0)
|
|
111
|
+
continue;
|
|
112
|
+
if (line.startsWith("# branch.ab ")) {
|
|
113
|
+
const m = line.slice(12).match(/^([+-]?\d+)\s+([+-]?\d+)/);
|
|
114
|
+
if (m) {
|
|
115
|
+
// git emits `+N -M` so behind is signed negative; abs flips it.
|
|
116
|
+
ahead = Math.abs(parseInt(m[1], 10));
|
|
117
|
+
behind = Math.abs(parseInt(m[2], 10));
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (line.startsWith("#"))
|
|
122
|
+
continue;
|
|
123
|
+
const head = line[0];
|
|
124
|
+
if (head === "1" || head === "2" || head === "u" || head === "?") {
|
|
125
|
+
dirtyCount += 1;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return { ahead, behind, dirtyCount };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Parse `git status --porcelain=v2 -b -z` output into both the file-status
|
|
132
|
+
* map (used by the filetree diff badges) and the ahead/behind/dirtyCount
|
|
133
|
+
* summary (used by WorktreeTabBar). One pass replaces the earlier
|
|
134
|
+
* v1+v2 dual call so the watcher can refresh the live counters on every
|
|
135
|
+
* tick without an extra `git status` round-trip.
|
|
136
|
+
*
|
|
137
|
+
* v2 entry shapes (`git-status(1)` `--porcelain=v2`):
|
|
138
|
+
* `1 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <path>` ordinary entry
|
|
139
|
+
* `2 <XY> <sub> <mH> <mI> <mW> <hH> <hI> <X><score> <path>\t<orig>` rename
|
|
140
|
+
* `u <XY> ...` unmerged
|
|
141
|
+
* `? <path>` untracked
|
|
142
|
+
* `! <path>` ignored (skipped)
|
|
143
|
+
*
|
|
144
|
+
* `-z` switches to NUL-delimited records and disables the legacy
|
|
145
|
+
* shell-quoted path encoding, so paths with spaces / unicode arrive verbatim
|
|
146
|
+
* without us having to decode escape sequences.
|
|
147
|
+
*/
|
|
148
|
+
export function parseGitStatusV2WithFiles(raw) {
|
|
149
|
+
let branch = "";
|
|
150
|
+
let ahead;
|
|
151
|
+
let behind;
|
|
152
|
+
let dirtyCount = 0;
|
|
153
|
+
const fileStatuses = {};
|
|
154
|
+
// `-z` separates records by NUL. Renames carry an extra NUL between new
|
|
155
|
+
// and old paths; the loop reads the next record on encountering one.
|
|
156
|
+
const records = raw.split("\0");
|
|
157
|
+
for (let i = 0; i < records.length; i++) {
|
|
158
|
+
const line = records[i];
|
|
159
|
+
if (!line)
|
|
160
|
+
continue;
|
|
161
|
+
if (line.startsWith("# branch.head ")) {
|
|
162
|
+
branch = line.slice("# branch.head ".length).trim();
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (line.startsWith("# branch.ab ")) {
|
|
166
|
+
const m = line
|
|
167
|
+
.slice("# branch.ab ".length)
|
|
168
|
+
.match(/^([+-]?\d+)\s+([+-]?\d+)/);
|
|
169
|
+
if (m) {
|
|
170
|
+
ahead = Math.abs(parseInt(m[1], 10));
|
|
171
|
+
behind = Math.abs(parseInt(m[2], 10));
|
|
172
|
+
}
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (line.startsWith("#"))
|
|
176
|
+
continue;
|
|
177
|
+
const head = line[0];
|
|
178
|
+
if (head === "1") {
|
|
179
|
+
// `1 XY ... <path>` -- fields 1..7 are space-delimited; path is the
|
|
180
|
+
// remainder after the 8th space.
|
|
181
|
+
const parts = line.split(" ");
|
|
182
|
+
if (parts.length < 9)
|
|
183
|
+
continue;
|
|
184
|
+
const xy = parts[1];
|
|
185
|
+
const path = parts.slice(8).join(" ");
|
|
186
|
+
const code = pickStatusCode(xy);
|
|
187
|
+
if (code)
|
|
188
|
+
fileStatuses[path] = code;
|
|
189
|
+
dirtyCount += 1;
|
|
190
|
+
}
|
|
191
|
+
else if (head === "2") {
|
|
192
|
+
// Rename/copy. Path = current name (this record's tail), original
|
|
193
|
+
// path = next NUL-delimited record (consumed below).
|
|
194
|
+
const parts = line.split(" ");
|
|
195
|
+
if (parts.length < 10)
|
|
196
|
+
continue;
|
|
197
|
+
const xy = parts[1];
|
|
198
|
+
const newPath = parts.slice(9).join(" ");
|
|
199
|
+
const code = pickStatusCode(xy);
|
|
200
|
+
if (code)
|
|
201
|
+
fileStatuses[newPath] = code;
|
|
202
|
+
dirtyCount += 1;
|
|
203
|
+
i += 1; // skip the original-path record
|
|
204
|
+
}
|
|
205
|
+
else if (head === "u") {
|
|
206
|
+
const parts = line.split(" ");
|
|
207
|
+
if (parts.length < 11)
|
|
208
|
+
continue;
|
|
209
|
+
const path = parts.slice(10).join(" ");
|
|
210
|
+
fileStatuses[path] = "U";
|
|
211
|
+
dirtyCount += 1;
|
|
212
|
+
}
|
|
213
|
+
else if (head === "?") {
|
|
214
|
+
// `? <path>` -- single space, then path.
|
|
215
|
+
const path = line.slice(2);
|
|
216
|
+
fileStatuses[path] = "?";
|
|
217
|
+
dirtyCount += 1;
|
|
218
|
+
}
|
|
219
|
+
// `!` ignored entries are skipped (would only appear with --ignored).
|
|
220
|
+
}
|
|
221
|
+
return { branch, ahead, behind, dirtyCount, fileStatuses };
|
|
222
|
+
}
|
|
223
|
+
function stderrOf(err) {
|
|
224
|
+
if (!err || typeof err !== "object")
|
|
225
|
+
return "";
|
|
226
|
+
const e = err;
|
|
227
|
+
if (typeof e.stderr === "string")
|
|
228
|
+
return e.stderr;
|
|
229
|
+
if (e.stderr instanceof Buffer)
|
|
230
|
+
return e.stderr.toString("utf8");
|
|
231
|
+
return "";
|
|
232
|
+
}
|
|
233
|
+
function pickStatusCode(xy) {
|
|
234
|
+
if (xy.length !== 2)
|
|
235
|
+
return null;
|
|
236
|
+
const x = xy[0];
|
|
237
|
+
const y = xy[1];
|
|
238
|
+
if (y !== "." && y !== " ")
|
|
239
|
+
return y;
|
|
240
|
+
if (x !== "." && x !== " ")
|
|
241
|
+
return x;
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
function cacheKey(projectId, worktreePath) {
|
|
245
|
+
return `${projectId}|${worktreePath}`;
|
|
246
|
+
}
|
|
247
|
+
export class GitWatcher {
|
|
248
|
+
cache = new Map();
|
|
249
|
+
async check(worktreePath) {
|
|
250
|
+
const env = { ...process.env, GIT_OPTIONAL_LOCKS: "0" };
|
|
251
|
+
try {
|
|
252
|
+
const { stdout } = await execFileAsync("git", ["-C", worktreePath, "status", "--porcelain=v2", "-b", "-z"], {
|
|
253
|
+
timeout: 5000,
|
|
254
|
+
env,
|
|
255
|
+
// `--porcelain=v2 -z` on a repo with thousands of dirty entries
|
|
256
|
+
// can blow past Node's 1MiB default. Match project-queries.ts so
|
|
257
|
+
// the watcher and ad-hoc enrichment fail in identical conditions.
|
|
258
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
259
|
+
});
|
|
260
|
+
const snap = parseGitStatusV2WithFiles(stdout);
|
|
261
|
+
const dirty = snap.dirtyCount > 0;
|
|
262
|
+
return {
|
|
263
|
+
branch: snap.branch,
|
|
264
|
+
dirty,
|
|
265
|
+
fileStatuses: dirty ? snap.fileStatuses : undefined,
|
|
266
|
+
ahead: snap.ahead,
|
|
267
|
+
behind: snap.behind,
|
|
268
|
+
dirtyCount: snap.dirtyCount,
|
|
269
|
+
lastChecked: Date.now(),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
catch (err) {
|
|
273
|
+
// Distinguish "not a git repository" from transient errors so the Git
|
|
274
|
+
// pane can offer `git init` instead of a blank "loading…" state.
|
|
275
|
+
// Inspect stderr only -- message text is locale-stable in C/C.UTF-8 git
|
|
276
|
+
// builds (`fatal: not a git repository`).
|
|
277
|
+
const stderr = stderrOf(err).toLowerCase();
|
|
278
|
+
if (stderr.includes("not a git repository")) {
|
|
279
|
+
return {
|
|
280
|
+
branch: "",
|
|
281
|
+
dirty: false,
|
|
282
|
+
isRepo: false,
|
|
283
|
+
lastChecked: Date.now(),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
async checkAndDiff(projectId, worktreePath) {
|
|
290
|
+
const state = await this.check(worktreePath);
|
|
291
|
+
const key = cacheKey(projectId, worktreePath);
|
|
292
|
+
const cached = this.cache.get(key);
|
|
293
|
+
const fileStatusesChanged = !fileStatusesEqual(state?.fileStatuses, cached?.fileStatuses);
|
|
294
|
+
const changed = state?.branch !== cached?.branch ||
|
|
295
|
+
state?.dirty !== cached?.dirty ||
|
|
296
|
+
state?.ahead !== cached?.ahead ||
|
|
297
|
+
state?.behind !== cached?.behind ||
|
|
298
|
+
state?.dirtyCount !== cached?.dirtyCount ||
|
|
299
|
+
// The repo/non-repo transition (`git init` flipping isRepo from false
|
|
300
|
+
// to undefined+populated) usually shows up as a branch change, but the
|
|
301
|
+
// sidebar gates `root` label / folder icon / `Initialize git…` menu
|
|
302
|
+
// strictly on `isRepo === false`. Including it here guarantees the
|
|
303
|
+
// UI re-renders the moment the flag flips, even on degenerate cases
|
|
304
|
+
// where the post-init branch happens to read as `""`.
|
|
305
|
+
state?.isRepo !== cached?.isRepo ||
|
|
306
|
+
fileStatusesChanged;
|
|
307
|
+
if (changed) {
|
|
308
|
+
this.cache.set(key, state);
|
|
309
|
+
}
|
|
310
|
+
return { state, changed };
|
|
311
|
+
}
|
|
312
|
+
getCached(projectId, worktreePath) {
|
|
313
|
+
return this.cache.get(cacheKey(projectId, worktreePath)) ?? null;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Snapshot of every cached state grouped by project. Outer key = projectId,
|
|
317
|
+
* inner key = worktreePath. Hydration payload consumes this shape directly.
|
|
318
|
+
*/
|
|
319
|
+
getAllCached() {
|
|
320
|
+
const result = {};
|
|
321
|
+
for (const [k, v] of this.cache) {
|
|
322
|
+
const idx = k.indexOf("|");
|
|
323
|
+
if (idx < 0)
|
|
324
|
+
continue;
|
|
325
|
+
const projectId = k.slice(0, idx);
|
|
326
|
+
const worktreePath = k.slice(idx + 1);
|
|
327
|
+
const projectCache = result[projectId] ?? {};
|
|
328
|
+
result[projectId] = projectCache;
|
|
329
|
+
projectCache[worktreePath] = v;
|
|
330
|
+
}
|
|
331
|
+
return result;
|
|
332
|
+
}
|
|
333
|
+
/** Clear all worktree entries belonging to a project. */
|
|
334
|
+
clearProject(projectId) {
|
|
335
|
+
const prefix = `${projectId}|`;
|
|
336
|
+
for (const key of this.cache.keys()) {
|
|
337
|
+
if (key.startsWith(prefix))
|
|
338
|
+
this.cache.delete(key);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/** Clear a single worktree entry. */
|
|
342
|
+
clearWorktree(projectId, worktreePath) {
|
|
343
|
+
this.cache.delete(cacheKey(projectId, worktreePath));
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function fileStatusesEqual(a, b) {
|
|
347
|
+
if (a === b)
|
|
348
|
+
return true;
|
|
349
|
+
if (!a || !b)
|
|
350
|
+
return false;
|
|
351
|
+
const keysA = Object.keys(a);
|
|
352
|
+
if (keysA.length !== Object.keys(b).length)
|
|
353
|
+
return false;
|
|
354
|
+
return keysA.every((k) => a[k] === b[k]);
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=git-watcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-watcher.js","sourceRoot":"","sources":["../../src/fs/git-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,UAAU,GAA2B;IACzC,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,GAAG;IACR,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IA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,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACzD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import type { FileHandle } from "node:fs/promises";
|
|
3
|
+
export type MediaKind = "image" | "video" | "audio" | "pdf";
|
|
4
|
+
export interface MediaDetectionResult {
|
|
5
|
+
kind: MediaKind | null;
|
|
6
|
+
contentType: string | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Identify a media file by its first 32 bytes plus extension. Magic-number
|
|
10
|
+
* match wins; if the magic match disagrees with the extension, the magic
|
|
11
|
+
* match is authoritative. SVG sniff is conservative -- only accepted when the
|
|
12
|
+
* extension claims SVG so a plain XML file is not mis-classified.
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectMedia(absPath: string): Promise<MediaDetectionResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Same magic-number + extension pipeline as `detectMedia`, but reads through
|
|
17
|
+
* a caller-owned `FileHandle`. Use this when the route layer has already
|
|
18
|
+
* `O_NOFOLLOW`-opened the file and needs detection, size validation, and
|
|
19
|
+
* streaming all anchored to the same inode (so a leaf swap between checks
|
|
20
|
+
* cannot bypass the size cap or content-type lock). Caller retains ownership
|
|
21
|
+
* of the handle.
|
|
22
|
+
*/
|
|
23
|
+
export declare function detectMediaFromHandle(handle: FileHandle, pathHint: string): Promise<MediaDetectionResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Pure classifier so tests can hand it raw bytes without touching disk.
|
|
26
|
+
* Exposed for unit testing -- `detectMedia` is the production entry point.
|
|
27
|
+
*/
|
|
28
|
+
export declare function classify(buf: Buffer, ext: string): MediaDetectionResult;
|
|
29
|
+
/**
|
|
30
|
+
* Lightweight extension-only check. Used by the route for the cheap
|
|
31
|
+
* pre-filter before opening the file (so we never read an executable just
|
|
32
|
+
* to learn it isn't media).
|
|
33
|
+
*/
|
|
34
|
+
export declare function isMediaExtension(absPath: string): boolean;
|
|
35
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/fs/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAyMD;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC,CAO/B;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,CAAC,CAM/B;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAyCvE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|