Download src/openwork/workspace-sync.js from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 1.45 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/openwork/workspace-sync.js
- Command line
-
hf download hf://VanyaJ/bada-terminal/src/openwork/workspace-sync.js
-
curl -L -o workspace-sync.js https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/openwork/workspace-sync.js
1.45 kB
| // ์คํ ์ค์ธ CLI ์ ๋ ฅ์ cd๋ฅผ ๋ฐ์ด ๋ฃ์ง ์๊ณ ๋ค์ ์คํ์ ์์ ํด๋๋ฅผ ์๋ฐฉํฅ ๊ฒฐํฉํ๋ค. | |
| // ์ค๋ช ๋ฌธ์: docs/specs/bada-runtime-integration.md (v1.0.0) | |
| function bindWorkspaceSync(context, service, broadcast) { | |
| let disposed = false; | |
| const onCwd = ({ cwd, source }) => { | |
| const status = service.getStatus(); | |
| if (disposed || source === 'openwork' || context.isRemoteSession || !status.running || status.starting) return; | |
| service.setWorkspace(cwd).catch(error => console.warn('[OpenWork CWD] Sync failed:', error.message)); | |
| }; | |
| // ์๋ฒ ์ค๋น ์ ์ CWD ๋ณ๊ฒฝ์ ๋ง์ง๋ง ์ปจํ ์คํธ๋ฅผ ์ค๋น ์๋ฃ ์ ํ ๋ฒ ๋ฐ์ํ๋ค. | |
| const onReady = () => { | |
| if (disposed || context.isRemoteSession || !service.getStatus().running || !context.currentCwd) return; | |
| service.setWorkspace(context.currentCwd).catch(error => console.warn('[OpenWork CWD] Startup sync failed:', error.message)); | |
| }; | |
| const onWorkspace = data => { | |
| if (disposed) return; | |
| if (data.source === 'openwork' && !context.isRemoteSession) context.setCurrentCwd(data.workspacePath, 'openwork'); | |
| broadcast(data); | |
| }; | |
| context.cwdEvents.on('change', onCwd); | |
| service.on('workspace', onWorkspace); | |
| service.on('ready', onReady); | |
| return () => { disposed = true; context.cwdEvents.off('change', onCwd); service.off('workspace', onWorkspace); service.off('ready', onReady); }; | |
| } | |
| module.exports = { bindWorkspaceSync }; | |