Files
cowork-local/run.bat
T
f9f6bc01fd
CI / test (push) Canceled after 0s
Feature/delta team/epic r04 (#7)
## Summary

epic r04 - begin refactor

## Change Type

- [x] Cowork feature
- [ ] Bug fix
- [ ] Core AI contribution
- [ ] Test / hardening
- [ ] Performance
- [ ] Documentation

## Related Work

Cowork Task:

Core Repo: http://34.143.229.138/gitea-admin/fsg-ai-core-assets

Core AI Issue:

Core Task:

Related PR:

## Scope

What is intentionally included?

What is intentionally NOT included?

## Validation

- [ ] Unit tests
- [ ] Integration tests
- [ ] Manual verification
- [ ] Regression check

Commands / evidence:

## Security Impact

Permission / credential / network / customer data impact:

## Compatibility

- [ ] No breaking change
- [ ] Breaking change documented

## Reviewer Notes

Anything Cowork reviewers should pay attention to.

---------

Co-authored-by: Anh Tran Nguyen Minh <anhtnm1@fpt.com>
Co-authored-by: Huong Le Thi Thien <huongltt35@fpt.com>
Co-authored-by: Nam Pham Dinh Thanh <nampdt@fpt.com>
Co-authored-by: Vu Dam Tuan <vudt15@fpt.com>
Co-authored-by: Hiep Ha Van <hiephv3@fpt.com>
Co-authored-by: Lam Hoang Van <lamhv7@fpt.com>
Reviewed-on: #7
Co-authored-by: Duy Le Huu <duylh19@fpt.com>
2026-08-31 05:15:13 +00:00

113 lines
3.8 KiB
Batchfile

@echo off
rem ===========================================================================
rem Cowork-Local BamBOO - chay ung dung
rem
rem Bam dup vao file nay la xong.
rem
rem Lan dau tien phai chay install.bat truoc.
rem
rem Tham so truyen vao duoc chuyen thang cho QApplication (xem app.py::run),
rem nen dung duoc cac co cua Qt, vi du: run.bat -style Fusion
rem ===========================================================================
setlocal EnableExtensions EnableDelayedExpansion
chcp 65001 >nul 2>&1
title Cowork-Local BamBOO
set "REPO=%~dp0"
set "REPO=%REPO:~0,-1%"
set "APPHOME=%LOCALAPPDATA%\CoworkLocal"
set "VENV=%APPHOME%\venv"
set "LAUNCHER=%APPHOME%\launcher"
rem --------------------------------------------------------------------------
rem 1. Chon trinh thong dich
rem
rem Uu tien moi truong ao do install.bat dung. Khong co thi quay ve Python cua
rem he thong — nguoi dung co the da chay "install.bat --system".
rem --------------------------------------------------------------------------
rem Duong dan luon duoc boc trong dau nhay: %LOCALAPPDATA% co the chua khoang
rem trang neu ten dang nhap co khoang trang.
if exist "%VENV%\Scripts\python.exe" (
set "RUNPY="%VENV%\Scripts\python.exe""
) else (
set "RUNPY="
for /f "delims=" %%P in ('where py 2^>nul') do if not defined RUNPY set "RUNPY="%%P" -3"
if not defined RUNPY (
for /f "delims=" %%P in ('where python 2^>nul') do if not defined RUNPY set "RUNPY="%%P""
)
)
if not defined RUNPY (
echo.
echo [LỖI] Không tìm thấy Python. Chạy install.bat trước đã.
echo.
pause
exit /b 1
)
rem Chua co moi truong ao thi kiem xem Python he thong co du thu vien khong.
rem Khong kiem thi nguoi dung chi nhan duoc mot ModuleNotFoundError tho, chang
rem biet la phai chay install.bat.
if not exist "%VENV%\Scripts\python.exe" (
!RUNPY! -c "import PySide6" >nul 2>&1
if errorlevel 1 (
echo.
echo [LỖI] Thư viện chưa được cài. Chạy install.bat trước đã.
echo.
pause
exit /b 1
)
)
rem --------------------------------------------------------------------------
rem 2. Duong dan de import duoc goi "cowork_local"
rem
rem Thu muc ma nguon phai mang dung ten "cowork_local" thi Python moi import
rem duoc no. Neu khong, install.bat da tao mot junction; o day chi kiem tra va
rem tu dung lai neu no bi xoa — de nguoi dung khong phai chay lai install.bat
rem chi vi mot thu muc tam bi don.
rem --------------------------------------------------------------------------
for %%I in ("%REPO%") do set "REPO_NAME=%%~nxI"
if /I "%REPO_NAME%"=="cowork_local" (
for %%I in ("%REPO%\..") do set "PKGPATH=%%~fI"
) else (
if not exist "%LAUNCHER%\cowork_local" (
if not exist "%LAUNCHER%" mkdir "%LAUNCHER%" >nul 2>&1
mklink /J "%LAUNCHER%\cowork_local" "%REPO%" >nul 2>&1
if errorlevel 1 (
echo.
echo [LỖI] Không tạo được liên kết thư mục. Chạy install.bat lại.
echo.
pause
exit /b 1
)
)
set "PKGPATH=%LAUNCHER%"
)
rem --------------------------------------------------------------------------
rem 3. Chay
rem
rem Dat thu muc lam viec o goc ma nguon va PYTHONPATH tro toi thu muc CHA cua
rem goi — dung cach CI dang chay (.gitea/workflows/ci.yaml). Tien trinh con
rem (may chu MCP MS365) thua ke PYTHONPATH nay nen cung import duoc.
rem --------------------------------------------------------------------------
if defined PYTHONPATH (
set "PYTHONPATH=!PKGPATH!;%PYTHONPATH%"
) else (
set "PYTHONPATH=!PKGPATH!"
)
set "PYTHONIOENCODING=utf-8"
cd /d "%REPO%"
!RUNPY! -m cowork_local %*
set "RC=%ERRORLEVEL%"
if not "%RC%"=="0" (
echo.
echo Ứng dụng thoát với mã lỗi %RC%. Xem thông báo ở trên.
echo.
pause
)
exit /b %RC%