$npx -y skills add NatsuFox/Tapestry --skill init-deps-installAutomatically triggered when Tapestry is first launched on a new environment or lacks dependencies. Intelligently detects environment and installs Tapestry dependencies with user confirmation.
| 1 | # 📦 Tapestry Init Deps Install |
| 2 | |
| 3 | **Automatic Dependency Installation with Environment Detection** |
| 4 | |
| 5 | This skill is automatically triggered when Tapestry is first launched on a new environment or when dependencies are missing. It detects the user's Python environment (venv, conda, system Python, etc.) and provides a comprehensive installation plan for all project dependencies, including both Python packages and system-level tools. |
| 6 | |
| 7 | ## When This Skill is Triggered |
| 8 | |
| 9 | This skill is automatically invoked when: |
| 10 | - Tapestry is first launched on a new environment (one-time auto-trigger) |
| 11 | - Required dependencies are missing or cannot be imported |
| 12 | - The user explicitly asks to "install dependencies" or "set up the project" |
| 13 | - After creating a new project that requires dependencies |
| 14 | |
| 15 | **Important**: The automatic trigger only occurs the first time Tapestry runs in a new environment. After successful initialization, the skill will not auto-trigger on subsequent runs to avoid wasting tokens. Manual invocation is always available if needed. |
| 16 | |
| 17 | ## How This Skill Works |
| 18 | |
| 19 | 1. **Configuration Setup**: Checks for user configuration and creates it if missing: |
| 20 | - Detects if `tapestry.config.json` exists |
| 21 | - If not, copies from `tapestry.config.example.json` |
| 22 | - Determines the real project root path |
| 23 | - Updates `paths.project_root` in the config with the actual path |
| 24 | |
| 25 | 2. **Environment Detection**: Analyzes the current environment to determine: |
| 26 | - Python version and location |
| 27 | - Virtual environment status (venv, virtualenv, conda) |
| 28 | - Package manager availability (pip, conda, poetry, uv) |
| 29 | - Existing installed packages |
| 30 | |
| 31 | 3. **Dependency Analysis**: Scans for dependency files: |
| 32 | - `pyproject.toml` (preferred) |
| 33 | - `requirements.txt` |
| 34 | - `setup.py` |
| 35 | - `environment.yml` (conda) |
| 36 | |
| 37 | 4. **Plan Generation**: Creates a comprehensive installation plan including: |
| 38 | - Configuration file setup (if needed) |
| 39 | - Python package installation commands |
| 40 | - System-level dependencies (e.g., `playwright install chromium`) |
| 41 | - Optional dependencies and recommendations |
| 42 | - Environment-specific considerations |
| 43 | |
| 44 | 5. **User Confirmation**: Presents the plan and asks for approval before executing |
| 45 | |
| 46 | 6. **Installation**: Executes the approved plan and reports results |
| 47 | |
| 48 | ## Usage |
| 49 | |
| 50 | This skill is automatically triggered when dependencies are missing. It can also be manually invoked: |
| 51 | |
| 52 | ```bash |
| 53 | # Manually trigger from the project root |
| 54 | /init-deps-install |
| 55 | |
| 56 | # Or specify a project path |
| 57 | /init-deps-install /path/to/project |
| 58 | ``` |
| 59 | |
| 60 | ## Implementation |
| 61 | |
| 62 | When this skill is invoked: |
| 63 | |
| 64 | 1. **Check and setup configuration** if needed |
| 65 | 2. **Detect the environment** by running the detection script |
| 66 | 3. **Analyze dependencies** from project files |
| 67 | 4. **Generate an installation plan** with clear steps |
| 68 | 5. **Present the plan** to the user with AskUserQuestion |
| 69 | 6. **Execute approved steps** and report results |
| 70 | |
| 71 | ### Step 0: Configuration Setup |
| 72 | |
| 73 | Before installing dependencies, check if this is the first run: |
| 74 | |
| 75 | ```bash |
| 76 | # Check if already initialized |
| 77 | python init-deps-install/_scripts/check_initialized.py |
| 78 | # Exit code 0 = already initialized, 1 = needs initialization |
| 79 | |
| 80 | # If not initialized, setup configuration |
| 81 | python init-deps-install/_scripts/setup_config.py [project-root] |
| 82 | ``` |
| 83 | |
| 84 | The setup script will: |
| 85 | 1. Check if `tapestry.config.json` exists |
| 86 | 2. If not, copy from `tapestry.config.example.json` |
| 87 | 3. Determine the project root path (argument or CWD) |
| 88 | 4. Update `paths.project_root` in the config |
| 89 | |
| 90 | **Project Root Detection:** |
| 91 | - If invoked with an argument, use that path as project root |
| 92 | - Otherwise, use the current working directory |
| 93 | - Convert to absolute path |
| 94 | - Update the `paths.project_root` field in `tapestry.config.json` |
| 95 | |
| 96 | **Example Output:** |
| 97 | ```json |
| 98 | { |
| 99 | "config_existed": false, |
| 100 | "config_path": "/path/to/skills/tapestry/config/tapestry.config.json", |
| 101 | "project_root": "/home/user/my-tapestry-project", |
| 102 | "created": true, |
| 103 | "updated": true |
| 104 | } |
| 105 | ``` |
| 106 | |
| 107 | **Initialization Marker:** |
| 108 | After successful setup and installation, create a marker file: |
| 109 | ```bash |
| 110 | # Create .tapestry_initialized marker |
| 111 | python init-deps-install/_scripts/mark_initialized.py |
| 112 | ``` |
| 113 | |
| 114 | This marker file indicates that Tapestry has been successfully initialized and prevents the skill from auto-triggering on future runs, saving tokens. |
| 115 | |
| 116 | ### Step 1: Environment Detection |
| 117 | |
| 118 | Run the environment detection script: |
| 119 | |
| 120 | ```bash |
| 121 | python init-deps-install/_scripts/detect_env.py |
| 122 | ``` |
| 123 | |
| 124 | This outputs JSON with: |
| 125 | - `python_version`: Python version string |
| 126 | - `python_path`: Path to Python executable |
| 127 | - `env_type`: "venv", "conda", "system", or "unknown" |
| 128 | - `env_name`: Name of the environment (if applicable) |
| 129 | - `env_path`: Path to the environment (if applicable) |
| 130 | - |