Эх сурвалжийг харах

Make aidop_init.ps1 path-agnostic for any clone location.

Resolve Web and server paths from script location; update onboarding doc and Cursor skill to run from repo root. Document database connectivity for fresh machines.
sky-guo 2 долоо хоног өмнө
parent
commit
2e7c8eb0e8

+ 4 - 4
ai-dop-platform/.cursor/skills/aidop-project-initialize/SKILL.md

@@ -16,16 +16,16 @@ Apply this skill when user asks:
 
 ## Execution Steps
 
-1. Run initialization script:
+1. Ensure the working directory is the **Ai-DOP 主库根目录**(含 `server/`、`Web/`、`ai-dop-platform/`),然后运行初始化脚本(路径相对仓库,任意磁盘可用):
 
 ```powershell
-powershell -ExecutionPolicy Bypass -File "d:/Projects/Ai-DOP/SourceCode/ai-dop-platform/tools/aidop_init.ps1"
+powershell -ExecutionPolicy Bypass -File ".\ai-dop-platform\tools\aidop_init.ps1"
 ```
 
-2. If user wants services started, run:
+2. 若需要同时拉起前后端:
 
 ```powershell
-powershell -ExecutionPolicy Bypass -File "d:/Projects/Ai-DOP/SourceCode/ai-dop-platform/tools/aidop_init.ps1" -StartServices
+powershell -ExecutionPolicy Bypass -File ".\ai-dop-platform\tools\aidop_init.ps1" -StartServices
 ```
 
 If the exact phrase is `AIDOP项目初始化并启动`, always run the `-StartServices` command by default.

+ 2 - 0
ai-dop-platform/README.md

@@ -24,6 +24,8 @@
 
 更细步骤见 [docs/GETTING_STARTED.md](docs/GETTING_STARTED.md)。
 
+**另一台电脑克隆后**:在主库根目录执行 `powershell -ExecutionPolicy Bypass -File ".\ai-dop-platform\tools\aidop_init.ps1"`(详见 [docs/NEW_MEMBER_ONBOARDING_ZERO_TO_ONE.md](docs/NEW_MEMBER_ONBOARDING_ZERO_TO_ONE.md));并确认 **`server/.../Database.json`** 中的数据库本机可达。
+
 **Cursor 续作**(工作区为 **`ai-dop-platform/`** 时):先 `@docs/PROJECT_HANDOFF.md`,再 `@docs/CURRENT_TASKS.md`。若工作区为主库根目录,路径为 `@ai-dop-platform/docs/...`。
 
 本机若仍使用 **`SourceCode/ai-dop-platform`**,建议改为指向 **`…/references/Admin.NET/ai-dop-platform`** 的 **目录联接(junction)**(见上层 `SourceCode/README.md`)。

+ 28 - 18
ai-dop-platform/docs/NEW_MEMBER_ONBOARDING_ZERO_TO_ONE.md

@@ -47,18 +47,13 @@
 
 ## 2. 拉代码并打开工作区
 
-推荐目录(与团队约定一致):
-
-- `D:/Projects/Ai-DOP/SourceCode`
-
-仓库根为:
-
-- `D:/Projects/Ai-DOP/SourceCode/ai-dop-platform`
+1. 克隆 **Ai-DOP 主库**(示例:`git clone https://gitee.com/sky-guo/ai-dop.git`,检出团队分支如 `v2`)。
+2. 进入克隆目录后,应能看到同级目录:**`server/`**、**`Web/`**、**`ai-dop-platform/`**(这就是**主库根**,下文记为 `$REPO`)。
 
 打开 Cursor 工作区建议:
 
-- 优先打开 `SourceCode/ai-dop-platform`
-- 或打开上层 `SourceCode`(也支持)
+- 打开 **主库根** `$REPO`(可同时改前后端),或
+- 仅打开 **`$REPO/ai-dop-platform`**(以文档与规则为主;跑初始化脚本时请在终端先 `cd` 到 **主库根** 再执行下节命令)。
 
 ---
 
@@ -80,9 +75,16 @@
 - 构建 `Admin.NET.Core`
 - 可选直接启动前后端服务
 
-对应脚本:
+对应脚本(**请在主库根 `$REPO` 下执行**,脚本会自动找到 `Web/`、`server/`):
+
+- `ai-dop-platform/tools/aidop_init.ps1`
+
+手动执行示例:
 
-- `tools/aidop_init.ps1`
+```powershell
+Set-Location $REPO   # 你的克隆根目录
+powershell -ExecutionPolicy Bypass -File ".\ai-dop-platform\tools\aidop_init.ps1"
+```
 
 ---
 
@@ -91,18 +93,20 @@
 ## 4.1 安装 Web 依赖并安装 hooks
 
 ```powershell
-Set-Location "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/Web"
-npm install --legacy-peer-deps
+Set-Location $REPO\Web
+npm install --legacy-peer-deps   # 或 pnpm install
 npm run prepare
 ```
 
 ## 4.2 构建后端核心
 
 ```powershell
-Set-Location "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/server/Admin.NET.Core"
+Set-Location $REPO\server\Admin.NET.Core
 dotnet build --framework net8.0
 ```
 
+若 `dotnet restore` / `build` 报 **NETSDK1045**(缺少 net10.0),请再安装 **.NET 10 SDK**(见 [CURRENT_TASKS.md](CURRENT_TASKS.md))。
+
 ---
 
 ## 5. 启动项目
@@ -110,7 +114,7 @@ dotnet build --framework net8.0
 ## 5.1 启动后端
 
 ```powershell
-Set-Location "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/server/Admin.NET.Web.Entry"
+Set-Location $REPO\server\Admin.NET.Web.Entry
 dotnet run --framework net8.0
 ```
 
@@ -121,14 +125,20 @@ dotnet run --framework net8.0
 ## 5.2 启动前端
 
 ```powershell
-Set-Location "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/Web"
-npm run dev
+Set-Location $REPO\Web
+pnpm dev    # 或 npm run dev
 ```
 
 默认地址:
 
 - `http://localhost:8888`
 
+## 5.3 数据库(必看)
+
+- 连接串在 **`server/Admin.NET.Application/Configuration/Database.json`**(已随仓库提交)。
+- 若你本机**无法访问**当前配置中的数据库(网络、账号、防火墙),请改为本机 **MySQL** 或团队提供的可达实例,否则 **`dotnet run` 会在启动时失败**。
+- 本地可改用注释中的 **SQLite** 示例快速起服务(需按文件内说明改 `DbType` 与连接串);生产环境勿用默认演示库。
+
 ---
 
 ## 6. 首次联调检查清单(3 分钟)
@@ -161,7 +171,7 @@ Invoke-WebRequest -UseBasicParsing "http://127.0.0.1:5005/api/sysTenant/page" -M
 
 - `pnpm` 不存在:本项目支持自动回落到 `npm`
 - `npm install` 依赖冲突:使用 `npm install --legacy-peer-deps`
-- 后端连不上数据库:先确认 `Database.json` 里的远端库账号配置是否最新
+- 后端连不上数据库:检查 **`Database.json`** 是否指向你本机可达的库;团队共用库需 VPN/白名单;仅本地试跑可改用 SQLite 示例
 - 前端 404:确认后端是否运行在 `5005`,再看 `Web` 的 API 配置
 
 ---

+ 17 - 10
ai-dop-platform/tools/aidop_init.ps1

@@ -19,10 +19,23 @@ function Invoke-Checked($command, [string[]]$arguments) {
     }
 }
 
-Write-Step "Workspace: $(Get-Location)"
+$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
+$platformRoot = Split-Path -Parent $scriptDir
+$repoRoot = Split-Path -Parent $platformRoot
+
+$webDir = Join-Path $repoRoot "Web"
+$entryDir = Join-Path $repoRoot "server/Admin.NET.Web.Entry"
+$coreCsproj = Join-Path $repoRoot "server/Admin.NET.Core/Admin.NET.Core.csproj"
+
+Write-Step "Repo root: $repoRoot"
+Write-Step "Current directory: $(Get-Location)"
+
+if (-not (Test-Path $webDir)) { throw "Web directory not found: $webDir (expected next to ai-dop-platform/)" }
+if (-not (Test-Path $entryDir)) { throw "Web.Entry directory not found: $entryDir" }
+if (-not (Test-Path $coreCsproj)) { throw "Core csproj not found: $coreCsproj" }
 
 if (-not (Test-Command "dotnet")) {
-    throw "dotnet not found. Please install .NET SDK 8.x first."
+    throw "dotnet not found. Please install .NET SDK 8.x (and 10.x if restore reports NETSDK1045)."
 }
 
 $dotnetVersion = (dotnet --version)
@@ -35,12 +48,6 @@ if (-not (Test-Command "node")) {
 $nodeVersion = (node --version)
 Write-Step "node version: $nodeVersion"
 
-$webDir = "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/Web"
-$entryDir = "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/server/Admin.NET.Web.Entry"
-
-if (-not (Test-Path $webDir)) { throw "Web directory not found: $webDir" }
-if (-not (Test-Path $entryDir)) { throw "Web.Entry directory not found: $entryDir" }
-
 Write-Step "Install frontend dependencies + hooks"
 Push-Location $webDir
 try {
@@ -56,12 +63,12 @@ try {
 }
 
 Write-Step "Build backend core (net8.0)"
-Invoke-Checked "dotnet" @("build", "d:/Projects/Ai-DOP/SourceCode/references/Admin.NET/server/Admin.NET.Core/Admin.NET.Core.csproj", "--framework", "net8.0")
+Invoke-Checked "dotnet" @("build", $coreCsproj, "--framework", "net8.0")
 
 if ($StartServices) {
     Write-Step "Starting backend and frontend services"
     Start-Process powershell -ArgumentList "-NoExit", "-Command", "Set-Location '$entryDir'; dotnet run --framework net8.0"
-    Start-Process powershell -ArgumentList "-NoExit", "-Command", "Set-Location '$webDir'; npm run dev"
+    Start-Process powershell -ArgumentList "-NoExit", "-Command", "Set-Location '$webDir'; if (Get-Command pnpm -ErrorAction SilentlyContinue) { pnpm dev } else { npm run dev }"
     Write-Step "Services started. Backend: http://localhost:5005  Frontend: http://localhost:8888"
 }