Refine knowledge brain workflow

Align the brain prompts, graph view, and startup defaults with the
latest phase 1 flow so local runs and navigation stay consistent.
This commit is contained in:
2026-03-22 22:42:47 +08:00
parent 67ea3d2682
commit 6f594631e9
23 changed files with 1508 additions and 526 deletions

111
start.bat
View File

@@ -1,92 +1,115 @@
@echo off
setlocal
chcp 65001 >nul
title Jarvis 一键启动
title Jarvis Start
set "ROOT=%~dp0"
set "BACKEND_DIR=%ROOT%backend"
set "FRONTEND_DIR=%ROOT%frontend"
set "LOG_DIR=%ROOT%logs"
set "PROJECT_ENV=%ROOT%.env"
if not exist "%LOG_DIR%" mkdir "%LOG_DIR%"
echo ==========================================
echo Jarvis 个人 AI 助理 - 一键启动
echo Jarvis - Quick Start
echo ==========================================
echo.
REM --- 检查 uv ---
where uv >nul 2>&1
if %errorlevel% neq 0 (
echo [错误] 未找到 uv请先安装: https://github.com/astral-sh/uv
echo.
echo 安装命令:
echo [ERROR] uv was not found. Install it first:
echo pip install uv
echo.
pause
exit /b 1
)
REM --- 检查 npm ---
where npm >nul 2>&1
if %errorlevel% neq 0 (
echo [错误] 未找到 npm请先安装 Node.js: https://nodejs.org
echo [ERROR] npm was not found. Install Node.js first.
echo.
pause
exit /b 1
)
REM --- 检查 .env ---
if not exist backend\.env (
echo [提示] 首次运行,需要配置 API Key
echo [提示] 请编辑 backend\.env 文件,填入:
echo ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxxxxxx
if not exist "%PROJECT_ENV%" (
echo [INFO] .env was not found in the project root.
echo [INFO] Create it before first run.
echo.
)
REM --- 安装后端依赖 ---
echo [1/4] 安装后端依赖...
cd /d "%~dp0backend"
echo [1/4] Install backend dependencies...
cd /d "%BACKEND_DIR%"
uv sync --quiet
if %errorlevel% neq 0 (
echo [错误] 后端依赖安装失败
echo [ERROR] Failed to install backend dependencies.
pause
exit /b 1
)
echo [OK] 后端依赖安装完成
echo [OK] Backend dependencies installed.
REM --- 安装前端依赖 ---
echo.
echo [2/4] 安装前端依赖...
cd /d "%~dp0frontend"
echo [2/4] Install frontend dependencies...
cd /d "%FRONTEND_DIR%"
call npm install >nul 2>&1
if %errorlevel% neq 0 (
echo [错误] 前端依赖安装失败
echo [ERROR] Failed to install frontend dependencies.
pause
exit /b 1
)
echo [OK] 前端依赖安装完成
echo [OK] Frontend dependencies installed.
set "BACKEND_HOST=127.0.0.1"
set "BACKEND_PORT="
if exist "%PROJECT_ENV%" (
for /f "usebackq tokens=1,* delims==" %%A in ("%PROJECT_ENV%") do (
if /I "%%A"=="HOST" set "BACKEND_HOST=%%B"
if /I "%%A"=="PORT" set "BACKEND_PORT=%%B"
)
)
if "%BACKEND_PORT%"=="" (
echo [ERROR] PORT was not found in .env.
echo [ERROR] Set PORT in the project root .env and run start.bat again.
pause
exit /b 1
)
set "FRONTEND_API_URL=http://%BACKEND_HOST%:%BACKEND_PORT%"
> "%FRONTEND_DIR%\.env.local" echo VITE_API_URL=%FRONTEND_API_URL%
set "BACKEND_LOG=%LOG_DIR%\backend-start.log"
set "FRONTEND_LOG=%LOG_DIR%\frontend-start.log"
REM --- 启动后端 ---
echo.
echo [3/4] 启动后端服务 (端口 8000)...
cd /d "%~dp0backend"
start "Jarvis-Backend" cmd /c "uv run uvicorn app.main:app --reload --port 8000"
echo [3/4] Start backend in background on %BACKEND_HOST%:%BACKEND_PORT%...
powershell -NoProfile -WindowStyle Hidden -Command "$wd='%BACKEND_DIR%'; $out='%BACKEND_LOG%'; Start-Process powershell -WindowStyle Hidden -WorkingDirectory $wd -ArgumentList '-NoProfile','-Command',('uv run uvicorn app.main:app --reload --host %BACKEND_HOST% --port %BACKEND_PORT% *>> ''{0}''' -f $out)"
if %errorlevel% neq 0 (
echo [ERROR] Failed to start backend.
pause
exit /b 1
)
REM --- 等待后端启动 ---
echo 等待后端启动...
timeout /t 5 /nobreak >nul
echo Waiting for backend...
ping 127.0.0.1 -n 6 >nul
REM --- 启动前端 ---
echo.
echo [4/4] 启动前端服务 (端口 5173)...
cd /d "%~dp0frontend"
start "Jarvis-Frontend" cmd /c "npm run dev"
echo [4/4] Start frontend in background on port 5173...
powershell -NoProfile -WindowStyle Hidden -Command "$wd='%FRONTEND_DIR%'; $out='%FRONTEND_LOG%'; Start-Process powershell -WindowStyle Hidden -WorkingDirectory $wd -ArgumentList '-NoProfile','-Command',('npm run dev *>> ''{0}''' -f $out)"
if %errorlevel% neq 0 (
echo [ERROR] Failed to start frontend.
pause
exit /b 1
)
REM --- 完成 ---
echo.
echo ==========================================
echo 启动完成!
echo Started
echo.
echo 后端: http://localhost:8000
echo 前端: http://localhost:5173
echo API文档: http://localhost:8000/docs
echo Backend: http://%BACKEND_HOST%:%BACKEND_PORT%
echo Frontend: http://localhost:5173
echo API docs: http://%BACKEND_HOST%:%BACKEND_PORT%/docs
echo.
echo Logs:
echo - %BACKEND_LOG%
echo - %FRONTEND_LOG%
echo ==========================================
echo.
echo 提示:
echo - 首次使用请先注册账号
echo - 对话前请在 backend\.env 填入 API Key
echo - 关闭时请关闭两个终端窗口
echo.
pause