Skip to content

Consider adding dependency on uv, switching from bash to python (or any other scripting language with dependency management) #181

Description

@taminomara

While working on review-skill-or-agent, I've hit some edge cases related to processing and verifying markdown. Specifically, frontmatter is an arbitrary YAML, meaning that parsing it with regexps is inherently lossy. To combat this, guidance already ships python snippets that evaluate frontmatter.

I propose re-evaluating portability guidelines for han. For example, we can require having uv, which can automatically manage python dependencies and run python scripts per PEP723. This will allow writing python scripts that depend on third-party libraries, e.g. PyYAML and python-mdformat. This change will allow offloading more complex work into scripts; it will also guarantee having identical runtime environment.

An example of how this will look. We make a python script and declare its runtime dependencies using special comment syntax:

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = "=~3.14"
# dependencies = [
#     "yuio=~2.3",
#     ...
# ]
# ///

def main():
    ... # Normal python here.

We can then invoke this script as usual; uv will download required python executable and install all dependencies into a temporary virtual environment.

* one note on this example, it uses env's -S flag which is not available on older systems. There are ways to bypass it, if we want to target them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions