#!/usr/bin/env bash set -euo pipefail PROJECT_ROOT_BASE="${PROJECT_ROOT_BASE:-$HOME/project/workspace}" usage() { cat <<'EOF' Usage: init-project-workspace.sh 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 / ├── 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// ``` 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/"