Add project workspace init script
This commit is contained in:
@@ -59,3 +59,8 @@
|
|||||||
- 若 Pixi 失效或不适用,可使用 UV 作为后备方案
|
- 若 Pixi 失效或不适用,可使用 UV 作为后备方案
|
||||||
- 默认应把 Pixi 作为首选项目环境管理器
|
- 默认应把 Pixi 作为首选项目环境管理器
|
||||||
- 已新增长期决策文档:`shared/long-term/decisions/project-workspace-layout.md`
|
- 已新增长期决策文档:`shared/long-term/decisions/project-workspace-layout.md`
|
||||||
|
- 已新增可复用初始化脚本:`scripts/init-project-workspace.sh`
|
||||||
|
- 用于快速创建标准项目容器目录
|
||||||
|
- 会初始化 `repos/`、`worktrees/`、`shared/`、`docs/`、`scripts/`、`tmp/`
|
||||||
|
- 会生成项目级 `docs/PROJECT-RULES.md`
|
||||||
|
- 该规则文档内已包含 Pixi 优先、`.pixi/` 不跟踪、UV 作为后备方案的说明
|
||||||
|
|||||||
136
scripts/init-project-workspace.sh
Executable file
136
scripts/init-project-workspace.sh
Executable file
@@ -0,0 +1,136 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
PROJECT_ROOT_BASE="${PROJECT_ROOT_BASE:-$HOME/project/workspace}"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'EOF'
|
||||||
|
Usage:
|
||||||
|
init-project-workspace.sh <project-name>
|
||||||
|
|
||||||
|
Description:
|
||||||
|
Create a standard project container under ~/project/workspace with:
|
||||||
|
repos/
|
||||||
|
worktrees/
|
||||||
|
shared/
|
||||||
|
docs/
|
||||||
|
scripts/
|
||||||
|
tmp/
|
||||||
|
|
||||||
|
Also creates:
|
||||||
|
- docs/PROJECT-RULES.md
|
||||||
|
- .gitignore at project container root
|
||||||
|
- shared/.gitkeep
|
||||||
|
- tmp/.gitkeep
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- Project repos inside repos/ should prefer Pixi for environment management.
|
||||||
|
- Each repo should include pixi.toml.
|
||||||
|
- .pixi/ must not be tracked by git.
|
||||||
|
- UV may be used only as a fallback when Pixi is not suitable.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" || $# -lt 1 ]]; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROJECT_NAME="$1"
|
||||||
|
PROJECT_DIR="$PROJECT_ROOT_BASE/$PROJECT_NAME"
|
||||||
|
|
||||||
|
mkdir -p \
|
||||||
|
"$PROJECT_DIR/repos" \
|
||||||
|
"$PROJECT_DIR/worktrees" \
|
||||||
|
"$PROJECT_DIR/shared" \
|
||||||
|
"$PROJECT_DIR/docs" \
|
||||||
|
"$PROJECT_DIR/scripts" \
|
||||||
|
"$PROJECT_DIR/tmp"
|
||||||
|
|
||||||
|
cat > "$PROJECT_DIR/.gitignore" <<'EOF'
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Editor / IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Logs / temp
|
||||||
|
*.log
|
||||||
|
*.tmp
|
||||||
|
|
||||||
|
# Local scratch / caches
|
||||||
|
.cache/
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > "$PROJECT_DIR/docs/PROJECT-RULES.md" <<'EOF'
|
||||||
|
# Project Rules
|
||||||
|
|
||||||
|
## Workspace Layout
|
||||||
|
|
||||||
|
This project follows the standard OpenClaw multi-machine project container layout:
|
||||||
|
|
||||||
|
```text
|
||||||
|
<project-root>/
|
||||||
|
├── repos/
|
||||||
|
├── worktrees/
|
||||||
|
├── shared/
|
||||||
|
├── docs/
|
||||||
|
├── scripts/
|
||||||
|
└── tmp/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment Management
|
||||||
|
|
||||||
|
Default rule:
|
||||||
|
|
||||||
|
- Prefer **Pixi** for per-project environment management
|
||||||
|
- Each repo should include `pixi.toml`
|
||||||
|
- If reproducibility is needed, include `pixi.lock`
|
||||||
|
- Do **not** track `.pixi/`
|
||||||
|
- Use **UV** only when Pixi is unsuitable or blocked
|
||||||
|
|
||||||
|
Recommended `.gitignore` entries inside each repo:
|
||||||
|
|
||||||
|
```gitignore
|
||||||
|
.pixi/
|
||||||
|
.venv/
|
||||||
|
__pycache__/
|
||||||
|
node_modules/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Multi-Machine Collaboration
|
||||||
|
|
||||||
|
- `mac-5` = brain → orchestration / review / final integration
|
||||||
|
- `mac-6` = hands → execution / implementation / build
|
||||||
|
- `mac-7` = eyes → browser / verification / acceptance
|
||||||
|
|
||||||
|
Collaboration model:
|
||||||
|
|
||||||
|
- Each machine keeps its own local project copy
|
||||||
|
- Code sync uses git remote
|
||||||
|
- Active `.git` / `git worktree` metadata is not treated as file-sync state
|
||||||
|
- Final integration and merge should usually happen on `mac-5`
|
||||||
|
|
||||||
|
## Worktree Convention
|
||||||
|
|
||||||
|
Recommended layout:
|
||||||
|
|
||||||
|
```text
|
||||||
|
worktrees/<repo-name>/<task-or-branch-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
- `worktrees/backend/feat-auth`
|
||||||
|
- `worktrees/frontend/feat-dashboard`
|
||||||
|
- `worktrees/backend/integration-merge`
|
||||||
|
EOF
|
||||||
|
|
||||||
|
touch "$PROJECT_DIR/shared/.gitkeep" "$PROJECT_DIR/tmp/.gitkeep"
|
||||||
|
|
||||||
|
echo "Created project container: $PROJECT_DIR"
|
||||||
|
echo "Next steps:"
|
||||||
|
echo " 1) Put real repos under: $PROJECT_DIR/repos"
|
||||||
|
echo " 2) Put parallel worktrees under: $PROJECT_DIR/worktrees"
|
||||||
|
echo " 3) For each repo, prefer Pixi with pixi.toml and ignore .pixi/"
|
||||||
Reference in New Issue
Block a user