-
-
Notifications
You must be signed in to change notification settings - Fork 23
fix: invoke Python scripts with uv run, drop the Python browser opener #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ You are Paige, the Technical Writer. You transform complex game development conc | |
|
|
||
| ### Step 1: Resolve the Agent Block | ||
|
|
||
| Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key agent` | ||
| Run: `uv run {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key agent` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
command -v uv
uv --version
resolver="_bmad/scripts/resolve_customization.py"
test -f "$resolver"
sed -n '1,100p' "$resolver"
rg -n -i '\buv\b|python 3\.11|python >=?3\.11' README.md
rg -n -P '\buv run\b.*resolve_customization\.py' srcRepository: bmad-code-org/bmad-module-game-dev-studio Length of output: 179 🏁 Script executed: #!/usr/bin/env bash
set -euo pipefail
printf 'Repository files around resolver:\n'
git ls-files | rg '(^|/)((README\.md|pyproject\.toml|uv\.lock|_bmad/scripts/resolve_customization\.py)|SKILL\.md$|steps/)$.|(^|/)SKILL\.md$|(^|/)steps/.*\.md$|(^|/)README\.md$|(^|/)pyproject\.toml$|(^|/)uv\.lock$' || true
printf '\nIf resolver exists, first 120 lines:\n'
if [ -f _bmad/scripts/resolve_customization.py ]; then
sed -n '1,120p' _bmad/scripts/resolve_customization.py
fi
printf '\nuv documentation mentions in repo:\n'
rg -n -i '\buv\b|python 3\.11|python >=?3\.11' README.md pyproject.toml 2>/dev/null || true
printf '\nTarget command occurrences:\n'
rg -n -P 'uv run \{project-root\}/_bmad/scripts/resolve_customization\.py --skill \{skill-root\} --key (agent|workflow(\.on_complete)?)' src || trueRepository: bmad-code-org/bmad-module-game-dev-studio Length of output: 17604 🌐 Web query:
💡 Result: Use Citations:
🌐 Web query:
💡 Result: By design, uv requires a virtual environment for operations that mutate the environment, such as Citations:
🌐 Web query:
💡 Result: The combination of arguments uv run --no-project, inline script execution, and pyproject.toml is not a standard usage pattern because these features serve different purposes within the uv toolchain. 1. Inline Script Execution: uv supports running Python scripts that contain inline dependency metadata (specified in a PEP 723 format) [1][2]. When you run a script, uv automatically manages an isolated, ephemeral environment for those dependencies [1][2]. 2. --no-project: The --no-project flag tells uv to ignore any project configuration (like a pyproject.toml) found in the current directory or parent directories [1][2]. This is used when you want to ensure that uv does not attempt to resolve or use an existing project environment [1][2]. 3. pyproject.toml: This file is typically used to define a project's dependencies and configuration [1][2]. When using --no-project, uv explicitly disables the use of these files [2]. If you are trying to use an inline script, you do not need to provide a pyproject.toml file, as the dependencies are defined inside the Python file itself [1][2]. If you use the --no-project flag, uv will prevent the discovery and use of any pyproject.toml file in your environment [1][2]. Therefore, providing a pyproject.toml file while simultaneously using --no-project is contradictory or simply ignored depending on the specific command context. To run a script with inline metadata, you simply use: uv run your_script.py If you wish to force isolation from any existing project in the directory, you can use: uv run --no-project your_script.py Citations: 🌐 Web query:
💡 Result: uv provides full support for PEP 723 inline script metadata, enabling the creation of self-contained, reproducible Python scripts that manage their own dependencies [1][2][3]. Key features and workflows include: Declaring Dependencies: Scripts can define dependencies and Python version requirements within a TOML block delimited by # /// script and # /// at the top of the file [4][5]. Example: # /// script # requires-python = ">=3.11" # dependencies = ["requests"] # /// Managing Metadata: - Initialize scripts: Use uv init --script to create a new script with template metadata [1][3]. - Manage dependencies: Use uv add --script <script.py> to automatically add dependencies to the script's inline metadata [1][2]. Execution: - Running scripts: Use uv run <script.py>. uv detects the PEP 723 metadata, creates an ephemeral, isolated virtual environment, installs the specified dependencies, and executes the script [1][3][5]. - Isolation: When using inline script metadata, uv runs the script in an isolated environment, ignoring any project-level dependencies (such as those in a local pyproject.toml), even if the script is executed within a project directory [1][6][7]. - Locking: uv supports locking PEP 723 scripts using a uv.lock file [1][7]. Scripts must be explicitly locked using uv lock, after which subsequent runs and tool usage will respect the locked dependencies [1][7]. - Shebang support: For direct execution (e.g.,./script.py), you can add the following shebang to the first line of your script [3]: #!/usr/bin/env -S uv run --script For further details, refer to the official uv documentation on running scripts [1]. Citations:
🌐 Web query:
💡 Result:
# /// script
# requires-python = ">=3.12"
# dependencies = ["requests"]
# ///Then: uv run script.py
uv python install 3.12
uv run --python 3.12 script.pyIf the metadata is missing, uv generally uses its default Python selection rather than a script-specific requirement. Use Citations: 🌐 Web query:
💡 Result: When you run a script using uv, the presence of a pyproject.toml file and the use of the --no-project flag significantly alter how uv manages the execution environment [1][2][3][4]. If you are running a script with PEP 723 inline script metadata, uv automatically treats it as a standalone script [3][4]. In this case, uv ignores the project context entirely, even if a pyproject.toml file exists in the directory [1][2][4]. The script is executed in an isolated environment built specifically for the dependencies declared in its metadata, and you do not need to provide the --no-project flag [1][2][4]. If you are running a standard script (without inline metadata) within a directory that contains a pyproject.toml file, the following behaviors apply: 1. Standard Behavior: By default, uv detects the pyproject.toml, treats the directory as a project, and installs the project and its dependencies before running the script [1][2][3]. The script has access to those project dependencies [1][2]. 2. Using --no-project: The --no-project flag explicitly tells uv to skip project discovery and project environment management [1][2]. In this mode, uv will not install the project, and the project's dependencies will not be automatically included [1][2]. However, note that --no-project only disables project discovery; it does not disable general Python environment discovery (such as an existing.venv folder in the directory) [5]. If you require a truly clean, isolated environment, consider using the --isolated flag alongside --no-project [6][5]. If your pyproject.toml file is incomplete (e.g., missing a [project] table), uv may throw an error unless you use --no-project or use the --script flag to force inline-metadata mode [7][6][8]. Citations:
Ensure the resolver script has the supported runtime metadata. These commands expose every workflow agent to 📍 Affects 12 files
🤖 Prompt for AI Agents |
||
|
|
||
| **If the script fails**, resolve the `agent` block yourself by reading these three files in base → team → user order and applying the same structural merge rules as the resolver: | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,13 +40,13 @@ After the subagent writes findings, the parent fills `{workflow.validation_repor | |
|
|
||
| Grade derivation: *Excellent* = no fails, no high/critical findings · *Good* = no critical findings, at most minor fails · *Fair* = any high finding or several fails · *Poor* = any critical finding. | ||
|
|
||
| For interactive runs, open the HTML: | ||
| For interactive runs, open the HTML with the platform opener — `open` on macOS, `xdg-open` on Linux, `start ""` on Windows — double-quoting the path: | ||
|
|
||
| ```bash | ||
| python3 -c "import webbrowser, pathlib; webbrowser.open(pathlib.Path('{doc_workspace}/validation-report.html').resolve().as_uri())" | ||
| open "{doc_workspace}/validation-report.html" | ||
| ``` | ||
|
|
||
| Skip the open step in headless mode (see `references/headless.md`). Re-running validation overwrites the report in place. | ||
| If the command fails, don't retry with another opener: tell the user the file path and move on. Skip the open step in headless mode (see `references/headless.md`). Re-running validation overwrites the report in place. | ||
|
Comment on lines
+43
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Make every platform command complete and unambiguous. These instructions list platform-specific openers but do not provide a complete command for every platform.
📍 Affects 3 files
🤖 Prompt for AI Agents |
||
|
|
||
| ## Close | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: bmad-code-org/bmad-module-game-dev-studio
Length of output: 12782
🏁 Script executed:
Repository: bmad-code-org/bmad-module-game-dev-studio
Length of output: 12380
🏁 Script executed:
Repository: bmad-code-org/bmad-module-game-dev-studio
Length of output: 240
🏁 Script executed:
Repository: bmad-code-org/bmad-module-game-dev-studio
Length of output: 356
🏁 Script executed:
Repository: bmad-code-org/bmad-module-game-dev-studio
Length of output: 1487
🏁 Script executed:
Repository: bmad-code-org/bmad-module-game-dev-studio
Length of output: 3592
Add Python/
uvenforcement metadata to match the README prerequisites.README now documents Python
>=3.11anduv, but there is no top-levelrequires-python/ package metadata and the CI installs only Node dependencies. Add an install/dependency declaration foruvand Python guard metadata, or remove one prerequisite badge.🤖 Prompt for AI Agents