uvs 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,8 +6,8 @@ updates:
6
6
  schedule:
7
7
  interval: "daily"
8
8
 
9
- # Enable version updates for Python dependencies
10
- - package-ecosystem: "pip"
9
+ # Enable version updates for Python dependencies (uv.lock)
10
+ - package-ecosystem: "uv"
11
11
  directory: "/"
12
12
  schedule:
13
13
  interval: "daily"
@@ -2,6 +2,7 @@ name: CI/CD
2
2
 
3
3
  on:
4
4
  push:
5
+ branches: [main]
5
6
  pull_request:
6
7
  release:
7
8
  types: [published] # Only run on published releases
@@ -9,13 +10,20 @@ on:
9
10
  jobs:
10
11
  test:
11
12
  runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python-version: ["3.11", "3.12", "3.13", "3.14"]
17
+ env:
18
+ # Make uv use the matrix interpreter rather than picking its own
19
+ UV_PYTHON: ${{ matrix.python-version }}
12
20
  steps:
13
21
  - uses: actions/checkout@v4
14
22
 
15
23
  - name: Set up Python
16
24
  uses: actions/setup-python@v5
17
25
  with:
18
- python-version: "3.13"
26
+ python-version: ${{ matrix.python-version }}
19
27
 
20
28
  - name: Install uv
21
29
  uses: astral-sh/setup-uv@v5
uvs-0.3.0/CLAUDE.md ADDED
@@ -0,0 +1,51 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ `uvs` (uv scripts) is a CLI tool that manages Python scripts from GitHub Gists or local files. It clones/copies scripts to `~/.uvs/scripts/` and creates wrapper scripts in `~/.uvs/bin/` that execute via `uv run`.
8
+
9
+ ## Common Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ uv sync
14
+
15
+ # Run tests
16
+ uv run pytest tests/ -v
17
+
18
+ # Run a single test
19
+ uv run pytest tests/test_core.py::test_function_name -v
20
+
21
+ # Lint and format
22
+ uv run ruff check src/
23
+ uv run ruff format src/
24
+
25
+ # Run the CLI locally
26
+ uv run uvs --help
27
+ ```
28
+
29
+ ## Architecture
30
+
31
+ ```
32
+ src/uvs/
33
+ ├── main.py # Typer CLI entry point, all commands defined here
34
+ ├── core.py # UVSCore class - orchestrates all operations, manages registry
35
+ ├── git_utils.py # Git operations: URL parsing, clone, pull
36
+ ├── metadata.py # PEP 723 metadata parsing, script detection
37
+ ├── path_manager.py # Wrapper script creation, PATH management
38
+ └── exceptions.py # UVSError hierarchy
39
+ ```
40
+
41
+ **Data flow**: CLI command → `UVSCore` → git_utils/metadata → path_manager → registry update
42
+
43
+ **Registry**: Scripts are tracked in `~/.uvs/registry.json` with metadata including gist_id, entry_file, auth_method, and timestamps.
44
+
45
+ **Script types**: Gist scripts use `gist-{id}` directories; local scripts use `local-{name}` directories.
46
+
47
+ ## Key Behaviors
48
+
49
+ - Scripts with generic entrypoints (`main.py`, `script.py`) require explicit `--name` or `[tool.uvs] name` in metadata
50
+ - PEP 723 metadata block (`# /// script ... # ///`) is parsed for dependencies and custom names
51
+ - Wrapper scripts use `exec uv run --project {script_dir} {script_dir}/{entry_file} "$@"`, so scripts run in the caller's working directory
@@ -1,10 +1,9 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: uvs
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Manage Python scripts using `uv` from GitHub Gists and local files
5
5
  Author-email: Adam McKay <adam@beepboop.digital>
6
6
  Requires-Python: >=3.11
7
- Requires-Dist: gitpython>=3.1.0
8
7
  Requires-Dist: rich>=13.0.0
9
8
  Requires-Dist: tomli-w>=1.0.0
10
9
  Requires-Dist: typer>=0.9.0
@@ -35,8 +34,13 @@ uvs add abc123def456 # Just the Gist ID
35
34
 
36
35
  # Specify a specific file as entrypoint
37
36
  uvs add abc123def456 --file utils.py
37
+
38
+ # Optionally override the script name
39
+ uvs add abc123def456 --name mytool
38
40
  ```
39
41
 
42
+ Private Gists are supported through SSH: use the `git@gist.github.com:<id>.git` form and `git` will authenticate with your SSH key. HTTPS URLs and bare IDs only work for public Gists.
43
+
40
44
  ### Adding Local Scripts (File or Directory)
41
45
 
42
46
  ```bash
@@ -62,7 +66,8 @@ uvs remove <script-name>
62
66
  # List installed scripts (local and Gist scripts are shown separately)
63
67
  uvs list
64
68
 
65
- # Update scripts to latest version
69
+ # Update scripts to latest version (all scripts if no name is given).
70
+ # Gist scripts are pulled; local scripts are re-copied from their original path.
66
71
  uvs update [script-name]
67
72
 
68
73
  # Completely remove all uvs installed scripts
@@ -75,19 +80,6 @@ uvs self version
75
80
  uvs self ensurepath
76
81
  ```
77
82
 
78
- ### Configuration
79
-
80
- ```bash
81
- # Set GitHub token
82
- uvs config set github_token <token>
83
-
84
- # Get current token
85
- uvs config get github_token
86
-
87
- # Remove token
88
- uvs config unset github_token
89
- ```
90
-
91
83
  ## Script Metadata
92
84
 
93
85
  Scripts may include metadata using a PEP 723-style block that specifies the Python version and any dependencies. Any other metadata may be specified inside a `[tool.uvs]` TOML table. For example:
@@ -96,14 +88,15 @@ Scripts may include metadata using a PEP 723-style block that specifies the Pyth
96
88
  # /// script
97
89
  # requires-python = ">=3.8"
98
90
  # dependencies = ["requests", "click>=8.0"]
91
+ #
99
92
  # [tool.uvs]
100
93
  # name = "my-script-name"
101
94
  # description = "A basic example of a script"
102
95
  # ///
103
96
  ```
104
97
 
105
- - `dependencies` can be a comma-separated list.
106
- - `requires-python` specifies the minimum Python version.
98
+ - `dependencies` is a TOML array of requirement strings.
99
+ - `requires-python` specifies the supported Python versions.
107
100
  - `[tool.uvs]` TOML section in comments for advanced options. Use it to specify a custom `name`, and project metadata to carry into the `pyproject.toml` if the script is packaged (`description`, `version`, `license`, `authors`, `maintainers`, `keywords`, `classifiers`, `urls`).
108
101
 
109
102
  ## Packaging Scripts
@@ -138,7 +131,7 @@ This will:
138
131
  │ ├── script # Points to gist-abc123/script.py
139
132
  │ ├── tool # Points to gist-def456/tool.py
140
133
  │ └── mytool # Points to local-mytool/myscript.py
141
- └── config.json # Simple configuration
134
+ └── registry.json # Installed scripts and where they came from
142
135
  ```
143
136
 
144
137
  ## Requirements
@@ -23,8 +23,13 @@ uvs add abc123def456 # Just the Gist ID
23
23
 
24
24
  # Specify a specific file as entrypoint
25
25
  uvs add abc123def456 --file utils.py
26
+
27
+ # Optionally override the script name
28
+ uvs add abc123def456 --name mytool
26
29
  ```
27
30
 
31
+ Private Gists are supported through SSH: use the `git@gist.github.com:<id>.git` form and `git` will authenticate with your SSH key. HTTPS URLs and bare IDs only work for public Gists.
32
+
28
33
  ### Adding Local Scripts (File or Directory)
29
34
 
30
35
  ```bash
@@ -50,7 +55,8 @@ uvs remove <script-name>
50
55
  # List installed scripts (local and Gist scripts are shown separately)
51
56
  uvs list
52
57
 
53
- # Update scripts to latest version
58
+ # Update scripts to latest version (all scripts if no name is given).
59
+ # Gist scripts are pulled; local scripts are re-copied from their original path.
54
60
  uvs update [script-name]
55
61
 
56
62
  # Completely remove all uvs installed scripts
@@ -63,19 +69,6 @@ uvs self version
63
69
  uvs self ensurepath
64
70
  ```
65
71
 
66
- ### Configuration
67
-
68
- ```bash
69
- # Set GitHub token
70
- uvs config set github_token <token>
71
-
72
- # Get current token
73
- uvs config get github_token
74
-
75
- # Remove token
76
- uvs config unset github_token
77
- ```
78
-
79
72
  ## Script Metadata
80
73
 
81
74
  Scripts may include metadata using a PEP 723-style block that specifies the Python version and any dependencies. Any other metadata may be specified inside a `[tool.uvs]` TOML table. For example:
@@ -84,14 +77,15 @@ Scripts may include metadata using a PEP 723-style block that specifies the Pyth
84
77
  # /// script
85
78
  # requires-python = ">=3.8"
86
79
  # dependencies = ["requests", "click>=8.0"]
80
+ #
87
81
  # [tool.uvs]
88
82
  # name = "my-script-name"
89
83
  # description = "A basic example of a script"
90
84
  # ///
91
85
  ```
92
86
 
93
- - `dependencies` can be a comma-separated list.
94
- - `requires-python` specifies the minimum Python version.
87
+ - `dependencies` is a TOML array of requirement strings.
88
+ - `requires-python` specifies the supported Python versions.
95
89
  - `[tool.uvs]` TOML section in comments for advanced options. Use it to specify a custom `name`, and project metadata to carry into the `pyproject.toml` if the script is packaged (`description`, `version`, `license`, `authors`, `maintainers`, `keywords`, `classifiers`, `urls`).
96
90
 
97
91
  ## Packaging Scripts
@@ -126,7 +120,7 @@ This will:
126
120
  │ ├── script # Points to gist-abc123/script.py
127
121
  │ ├── tool # Points to gist-def456/tool.py
128
122
  │ └── mytool # Points to local-mytool/myscript.py
129
- └── config.json # Simple configuration
123
+ └── registry.json # Installed scripts and where they came from
130
124
  ```
131
125
 
132
126
  ## Requirements
@@ -0,0 +1,175 @@
1
+ # uvs Implementation Guide
2
+
3
+ This guide describes how `uvs` is put together, for anyone changing the code. For what the tool does from the user's point of view, see [tech-spec.md](tech-spec.md).
4
+
5
+ ## Tech Stack
6
+
7
+ - **Project management**: `uv`
8
+ - **CLI framework**: `typer`
9
+ - **Terminal output**: `rich`
10
+ - **TOML writing**: `tomli-w` (reading uses the standard library's `tomllib`)
11
+ - **Testing**: `pytest`, `pytest-cov`
12
+ - **Linting and formatting**: `ruff`
13
+ - **Build backend**: `hatchling`
14
+ - **System requirements**: `git` and `uv`
15
+ - **Python**: 3.11 or higher
16
+
17
+ ## Project Structure
18
+
19
+ ```
20
+ uvs/
21
+ ├── pyproject.toml
22
+ ├── Justfile # format / check / lint / test recipes
23
+ ├── src/
24
+ │ └── uvs/
25
+ │ ├── __init__.py # __version__ and exception exports
26
+ │ ├── main.py # Typer CLI: every command is defined here
27
+ │ ├── core.py # UVSCore: orchestrates operations, owns the registry
28
+ │ ├── git_utils.py # Gist URL parsing, clone, pull
29
+ │ ├── metadata.py # PEP 723 parsing, entry file detection
30
+ │ ├── path_manager.py # Wrapper scripts, PATH check, name validation
31
+ │ └── exceptions.py # UVSError hierarchy
32
+ ├── tests/
33
+ │ ├── test_cli.py # CLI commands against a real UVSCore in a temp home
34
+ │ ├── test_main.py # `uvs package`
35
+ │ ├── test_core.py
36
+ │ ├── test_git_utils.py
37
+ │ ├── test_metadata.py
38
+ │ └── test_path_manager.py
39
+ ├── examples/
40
+ │ └── hello.py
41
+ └── docs/
42
+ ```
43
+
44
+ ## Module Responsibilities
45
+
46
+ ### main.py - CLI entry point
47
+
48
+ Defines the Typer app (`uvs`) and the `self` sub-app. Each command builds a `UVSCore` through `get_core()`, calls one method on it and prints the result. Commands catch exceptions at the top level, print them with `print_error()` and exit with status 1.
49
+
50
+ `print_error()` escapes the message before printing. Without that, Rich treats text such as `[tool.uvs]` as markup and drops it.
51
+
52
+ Tests replace `get_core` (or point `HOME` at a temporary directory) rather than touching the real `~/.uvs`.
53
+
54
+ `uvs package` is implemented here in three helpers: `_find_installed_script()`, `_write_package_project()` and `_build_package()`.
55
+
56
+ ### core.py - UVSCore
57
+
58
+ Owns `~/.uvs` (or `base_dir` when given one, which is how tests isolate it) and is the only code that reads or writes the registry.
59
+
60
+ - `add_script()` / `copy_script()` install from a Gist or a local path
61
+ - `remove_script()`, `list_scripts()`
62
+ - `update_script()` returns `True` if the script changed and `False` if it was already up to date
63
+ - `update_all_scripts()` returns `(updated, failed)`, where `failed` maps each name to the reason
64
+
65
+ Shared helpers keep the two install paths consistent:
66
+
67
+ - `_resolve_script_name()` applies the name precedence (CLI, then metadata, then filename) and validates the result
68
+ - `_ensure_name_available()` refuses a name that is already in the registry
69
+ - `_install()` creates the wrapper and the registry entry, removing the wrapper again if registration fails
70
+ - `_update_local_script()` stages a fresh copy next to the installed one and swaps it in only when complete
71
+
72
+ ### git_utils.py - Git operations
73
+
74
+ - `parse_gist_url()` turns any supported input into `(gist_id, clone_url, auth_method)` and rejects hosts other than `gist.github.com`
75
+ - `clone_gist()` and `update_gist()` shell out to `git` and raise `GitError` with git's own message on failure
76
+ - `update_gist()` compares `HEAD` before and after the pull, so callers can tell "updated" from "already up to date"
77
+ - `check_ssh_available()` tests SSH access to `gist.github.com` by exit code. Nothing calls it at present
78
+
79
+ ### metadata.py - Script metadata
80
+
81
+ - `detect_main_script()` picks the entry file: `--file`, then `main.py`, then `script.py`, then the first non-test `.py` file alphabetically
82
+ - `parse_script_metadata()` finds the PEP 723 block and returns `dependencies`, `requires-python` and the `[tool.uvs]` table. Invalid TOML yields empty metadata rather than an error
83
+ - `get_script_name()` returns the `[tool.uvs]` name, or the file's stem
84
+
85
+ ### path_manager.py - Wrappers and PATH
86
+
87
+ - `validate_script_name()` and `validate_entry_file()` guard everything that is written into a wrapper or used to build a path
88
+ - `PathManager.create_wrapper_script()` writes the Unix or Windows wrapper; `remove_wrapper_script()` deletes it
89
+ - `PathManager.is_path_configured()` checks whether the bin directory is a PATH entry, comparing normalised paths
90
+ - `PathManager.get_path_instruction()` returns the line the user should add
91
+
92
+ ### exceptions.py
93
+
94
+ ```
95
+ UVSError
96
+ ├── GitError # git clone / pull failed
97
+ ├── GistNotFoundError # reserved; not raised at present
98
+ ├── ScriptNotFoundError # name is not in the registry
99
+ ├── InvalidScriptError # no usable Python entry file
100
+ ├── ValidationError # bad script name, entry file or source path
101
+ └── RegistryError # registry.json cannot be read
102
+ ```
103
+
104
+ Some checks still raise plain `ValueError` (invalid Gist URL, name already installed, missing path). The CLI treats every exception the same way, so this only matters to code calling `UVSCore` directly.
105
+
106
+ ## Data Flow
107
+
108
+ CLI command → `UVSCore` → `git_utils` / `metadata` → `path_manager` → registry update
109
+
110
+ ### Installing (`add` and `copy`)
111
+
112
+ The order matters, because anything left on disk by a failed install would block the retry:
113
+
114
+ 1. Parse the URL, or check the local path exists
115
+ 2. If `--name` was given, validate it and check it is free. This happens before any clone or copy
116
+ 3. If a `gist-<id>` or `local-<name>` directory exists but nothing in the registry refers to it, remove it. It is left over from an interrupted install
117
+ 4. Clone or copy
118
+ 5. Detect the entry file, resolve and validate the name, check it is free
119
+ 6. Create the wrapper and write the registry entry
120
+ 7. If any step from 4 onwards fails, including an interrupt, remove the directory and wrapper and re-raise
121
+
122
+ ### Updating
123
+
124
+ - Gist scripts: `git pull`, then compare commits
125
+ - Local scripts: copy the source into a staging directory inside `~/.uvs/scripts/`, compare it with the installed copy by content, and replace the installed copy only if they differ
126
+ - `updated_at` in the registry changes only when the script actually changed
127
+
128
+ ### Packaging
129
+
130
+ 1. `_write_package_project()` writes `pyproject.toml`, `README.md` and `src/<package>/`
131
+ 2. `_build_package()` runs `uv build` in the generated project
132
+ 3. If no output location was requested, `dist/` is copied to `./<name>-dist/` and the temporary project is deleted
133
+
134
+ ## Registry Format
135
+
136
+ `~/.uvs/registry.json` is a JSON object keyed by script name. See [tech-spec.md](tech-spec.md#registry) for the fields.
137
+
138
+ `_load_registry()` raises `RegistryError` for a file that is not valid JSON or is not an object. Do not change it to fall back to an empty registry: the next write would then replace the user's registry and orphan every installed script.
139
+
140
+ ## Testing
141
+
142
+ ```bash
143
+ uv run pytest tests/ -v # everything
144
+ uv run pytest tests/test_core.py::test_add_script -v # one test
145
+ uv run pytest tests/ --cov=uvs --cov-report=term-missing
146
+ ```
147
+
148
+ Conventions:
149
+
150
+ - `UVSCore(base_dir=tmp_path)` isolates core tests from the real `~/.uvs`
151
+ - CLI tests set `HOME` to a temporary directory, so `get_core()` and the shell-config handling in `uvs self ...` run for real
152
+ - `git clone` is replaced with a function that writes files into the destination; `git pull` is patched at `uvs.core.update_gist`
153
+ - `uvs package` tests replace `subprocess.run` with a stub through the `fake_build` fixture
154
+ - Two tests run real tools and are skipped when `uv` is not installed: one executes a generated wrapper to check the working directory, and one builds a wheel and runs its installed command. The wheel test needs network access to fetch `hatchling`
155
+ - Rich wraps long lines at 80 columns under the test runner, so assert on short substrings, or strip whitespace first when a path is involved
156
+
157
+ ## Linting
158
+
159
+ ```bash
160
+ uv run ruff check src/ tests/
161
+ uv run ruff format src/ tests/
162
+ ```
163
+
164
+ `just lint` runs both. CI fails on lint errors or unformatted files.
165
+
166
+ ## CI and Releases
167
+
168
+ `.github/workflows/ci.yml`:
169
+
170
+ - **test** runs lint and the test suite on Python 3.11 to 3.14, for pull requests and pushes to `main`
171
+ - **publish** runs when a GitHub release is published, after the tests pass. It sets the package version from the git tag, builds and publishes to PyPI
172
+
173
+ The `version = "0.0.0"` in `pyproject.toml` is a placeholder that the publish job overwrites. `uvs.__version__` and `uvs self version` read the installed package metadata, so they report the released version.
174
+
175
+ To release: merge to `main`, then publish a GitHub release whose tag is the version number (for example `0.2.0`).
@@ -0,0 +1,268 @@
1
+ # uvs - Simple Script Registry Tool
2
+
3
+ ## Overview
4
+
5
+ `uvs` (uv scripts) is a command-line tool that manages Python scripts stored in GitHub Gists or in local files and directories. It clones Gists (or copies local scripts) into `~/.uvs/scripts/` and creates PATH-accessible wrapper scripts in `~/.uvs/bin/` that execute using `uv run`.
6
+
7
+ ## Core Functionality
8
+
9
+ ```bash
10
+ # Add a script from a Gist, using any Gist URL format
11
+ uvs add https://gist.github.com/username/abc123def456
12
+ uvs add https://gist.github.com/abc123def456
13
+ uvs add git@gist.github.com:abc123def456.git
14
+ uvs add abc123def456 # Just the Gist ID
15
+
16
+ # Choose the entrypoint file and/or the command name
17
+ uvs add abc123def456 --file utils.py --name mytool
18
+
19
+ # Add a script from a local file or directory
20
+ uvs copy /path/to/myscript.py
21
+ uvs copy /path/to/myproject/ --file cli.py --name mytool
22
+
23
+ # Remove a script
24
+ uvs remove <script-name>
25
+
26
+ # List installed scripts
27
+ uvs list
28
+
29
+ # Update one script, or all of them
30
+ uvs update [script-name]
31
+
32
+ # Build a Python package from an installed script
33
+ uvs package <script-name> [--output <dir>] [--keep-project]
34
+
35
+ # Manage uvs itself
36
+ uvs self ensurepath
37
+ uvs self version
38
+ uvs self delete
39
+ ```
40
+
41
+ ## Architecture
42
+
43
+ ```
44
+ ~/.uvs/
45
+ ├── scripts/
46
+ │ ├── gist-abc123/ # Cloned Gist repository
47
+ │ │ ├── script.py
48
+ │ │ └── .git/
49
+ │ └── local-mytool/ # Copy of a local script or directory
50
+ │ └── myscript.py
51
+ ├── bin/ # PATH wrapper scripts
52
+ │ ├── script # Runs gist-abc123/script.py
53
+ │ └── mytool # Runs local-mytool/myscript.py
54
+ └── registry.json # Installed scripts and where they came from
55
+ ```
56
+
57
+ There is no configuration file. Everything `uvs` needs to know about an installed script is in the registry.
58
+
59
+ ### Registry
60
+
61
+ `~/.uvs/registry.json` is a JSON object keyed by script name:
62
+
63
+ ```json
64
+ {
65
+ "my-tool": {
66
+ "name": "my-tool",
67
+ "gist_id": "abc123def456",
68
+ "entry_file": "tool.py",
69
+ "clone_url": "https://gist.github.com/abc123def456.git",
70
+ "auth_method": "https",
71
+ "installed_at": "2025-05-26T10:00:00+00:00",
72
+ "updated_at": "2025-05-26T10:00:00+00:00",
73
+ "is_local": false
74
+ }
75
+ }
76
+ ```
77
+
78
+ For local scripts `is_local` is `true`, `gist_id` is `local-<name>`, `auth_method` is `local` and `clone_url` holds the absolute path the script was copied from.
79
+
80
+ A registry that cannot be parsed is reported as an error and left untouched. It is never treated as empty, because the next write would then replace it.
81
+
82
+ ## Script Metadata (Optional PEP 723)
83
+
84
+ Scripts can include a PEP 723 block for dependencies, with a `[tool.uvs]` table inside it for naming and packaging metadata:
85
+
86
+ ```python
87
+ #!/usr/bin/env python3
88
+ # /// script
89
+ # requires-python = ">=3.11"
90
+ # dependencies = ["requests", "click>=8.0"]
91
+ #
92
+ # [tool.uvs]
93
+ # name = "my-tool"
94
+ # description = "Says hello"
95
+ # ///
96
+
97
+ import click
98
+
99
+ @click.command()
100
+ def main():
101
+ click.echo("Hello from my tool!")
102
+
103
+ if __name__ == "__main__":
104
+ main()
105
+ ```
106
+
107
+ The `[tool.uvs]` table must be inside the `# /// script` ... `# ///` block. Comments after the closing marker are not part of the metadata.
108
+
109
+ `uvs` tolerates trailing whitespace, indentation and CRLF line endings when locating the block. `uv` itself follows PEP 723 strictly, so a block that `uv` should read for dependencies must start at the beginning of the line.
110
+
111
+ ## Wrapper Script Generation
112
+
113
+ Wrappers run the script by absolute path, so the script executes in the directory the user invoked it from and relative path arguments resolve as expected. `--project` anchors `uv`'s project discovery to the script directory rather than the caller's.
114
+
115
+ ### Unix/Linux/macOS (`~/.uvs/bin/script-name`)
116
+ ```bash
117
+ #!/bin/bash
118
+ # Auto-generated wrapper for script-name
119
+ exec uv run --project "$HOME/.uvs/scripts/gist-abc123" "$HOME/.uvs/scripts/gist-abc123/script.py" "$@"
120
+ ```
121
+
122
+ ### Windows (`~/.uvs/bin/script-name.cmd`)
123
+ ```cmd
124
+ @echo off
125
+ REM Auto-generated wrapper for script-name
126
+ uv run --project "%USERPROFILE%\.uvs\scripts\gist-abc123" "%USERPROFILE%\.uvs\scripts\gist-abc123\script.py" %*
127
+ ```
128
+
129
+ Script names and entry file names are validated before they are written into a wrapper, to keep shell metacharacters and path traversal out of it:
130
+
131
+ - **Script name**: starts with a letter; letters, digits, `_` and `-` only; at most 64 characters.
132
+ - **Entry file**: letters, digits, `_`, `-`, `.` and `/` only; ends in `.py`; no `..`.
133
+
134
+ ## URL Formats & Authentication
135
+
136
+ Only `gist.github.com` is supported. Other hosts are rejected.
137
+
138
+ | Input | Cloned from | Auth |
139
+ | --- | --- | --- |
140
+ | `https://gist.github.com/<user>/<id>` | `https://gist.github.com/<id>.git` | none (public Gists) |
141
+ | `https://gist.github.com/<id>` | `https://gist.github.com/<id>.git` | none (public Gists) |
142
+ | `gist.github.com/<user>/<id>` (no scheme) | `https://gist.github.com/<id>.git` | none (public Gists) |
143
+ | `git@gist.github.com:<id>.git` | `git@gist.github.com:<id>.git` | SSH key |
144
+ | `<id>` | `https://gist.github.com/<id>.git` | none (public Gists) |
145
+
146
+ - A Gist ID is 5 to 40 hexadecimal characters.
147
+ - A trailing slash, a `.git` suffix, a `#file-...` fragment and a trailing revision hash (`.../<id>/<40-character sha>`) are all accepted and ignored.
148
+ - **Private Gists are supported through SSH only.** Use the `git@gist.github.com:<id>.git` form; `git` authenticates with the user's SSH key. `uvs` does not store or use tokens.
149
+
150
+ ## CLI Commands
151
+
152
+ ### `uvs add <url-or-id> [--file <file>] [--name <name>]`
153
+ - Validates `--name` and checks it is not already taken before cloning
154
+ - Clones the Gist to `~/.uvs/scripts/gist-<id>/`
155
+ - Selects the entry file and determines the script name
156
+ - Creates the wrapper in `~/.uvs/bin/` and records the script in the registry
157
+ - On any failure, removes the clone and wrapper again so a retry is not blocked
158
+ - Refuses to install a Gist that is already installed, or a script whose name is already in use
159
+ - Warns if `~/.uvs/bin` is not on PATH
160
+
161
+ ### `uvs copy <path> [--file <file>] [--name <name>]`
162
+ - Same flow as `add`, but copies a local file or directory to `~/.uvs/scripts/local-<name>/`
163
+ - Remembers the absolute source path so the script can be updated later
164
+
165
+ ### `uvs remove <script-name>`
166
+ - Removes the wrapper, the script directory and the registry entry
167
+ - Does not ask for confirmation
168
+
169
+ ### `uvs list`
170
+ - Shows Gist scripts and local scripts in separate tables, with entry file and last-updated time
171
+
172
+ ### `uvs update [script-name]`
173
+ - Gist scripts: runs `git pull` and reports an update only if the commit changed
174
+ - Local scripts: re-copies from the original source path and reports an update only if the content changed. The new copy is staged first, so a failed copy leaves the installed script intact
175
+ - With no name, updates every script, lists each failure with its reason and exits with status 1 if any failed
176
+
177
+ ### `uvs package <script-name> [--output <dir>] [--keep-project]`
178
+ - Generates a src-layout project from the installed script: `pyproject.toml`, `README.md` and `src/<package>/` containing every `.py` file from the script directory
179
+ - The installed command calls `main()` in the entry file, so the entry file must define one
180
+ - Copies `dependencies` and `requires-python` from the PEP 723 block, and these `[tool.uvs]` keys into `[project]`: `description`, `version`, `license`, `authors`, `maintainers`, `keywords`, `classifiers`, `urls`
181
+ - Builds the sdist and wheel with `uv build`; a failed build exits with status 1
182
+ - `--output <dir>`: write the project, including `dist/`, to that directory
183
+ - `--keep-project`: write the project to `./<name>-package/`
184
+ - Neither: build in a temporary directory and keep only `./<name>-dist/`
185
+
186
+ ### `uvs self ensurepath`
187
+ - Appends `~/.uvs/bin` to PATH in the shell's config file: `~/.zshrc` for zsh, `~/.bashrc` for bash, `~/.config/fish/config.fish` for fish, otherwise `~/.profile`
188
+ - Does nothing if the line is already present
189
+ - On Windows, prints instructions instead
190
+
191
+ ### `uvs self version`
192
+ - Prints the installed version
193
+
194
+ ### `uvs self delete`
195
+ - After confirmation, removes the PATH line added by `ensurepath` and deletes `~/.uvs`
196
+
197
+ ## Script Name Resolution
198
+
199
+ 1. `--name` on the command line
200
+ 2. `[tool.uvs] name = "custom-name"` in the entry file's metadata
201
+ 3. The entry file's name without its extension
202
+
203
+ If the entry file is `main.py` or `script.py` and the name would be `main` or `script`, installation is refused until a name is given by one of the first two methods.
204
+
205
+ ### Main Script Selection Priority
206
+ 1. **`--file` argument** - explicitly specified file (must exist at the top level and not be a test file)
207
+ 2. **`main.py`** - if present
208
+ 3. **`script.py`** - if present
209
+ 4. **First `.py` file** alphabetically (excluding `test*.py` files)
210
+ 5. **Error** if no Python files found
211
+
212
+ ## PATH Management
213
+
214
+ - `add` and `copy` warn when `~/.uvs/bin` is not on PATH and print the line to add
215
+ - The check compares normalised PATH entries, so a trailing slash still matches and a longer path that merely starts with the bin directory does not
216
+ - `uvs self ensurepath` makes the change permanent (see above)
217
+
218
+ ## Error Handling
219
+
220
+ - All errors are printed as a single `Error: ...` line and the command exits with status 1
221
+ - `uvs`-specific failures derive from `UVSError`: `GitError`, `ScriptNotFoundError`, `InvalidScriptError`, `ValidationError`, `RegistryError`
222
+ - Failed installs are rolled back
223
+ - Name conflicts are refused rather than overwritten
224
+
225
+ ## Dependencies
226
+
227
+ - `git` (system requirement)
228
+ - `uv` (system requirement)
229
+ - Python 3.11 or higher
230
+ - `typer`, `rich` and `tomli-w`
231
+
232
+ ## Example Workflow
233
+
234
+ ```bash
235
+ # Install uvs
236
+ uv tool install uvs
237
+ uvs self ensurepath
238
+
239
+ # Add scripts
240
+ uvs add https://gist.github.com/username/a1b2c3d4e5f6
241
+ uvs add git@gist.github.com:0f9e8d7c6b5a.git # private Gist, via SSH
242
+ uvs copy ./data_processor.py
243
+
244
+ # Run them (now in PATH), from any directory
245
+ my-script --help
246
+ data_processor --input data.csv
247
+
248
+ # Update all scripts
249
+ uvs update
250
+
251
+ # Remove a script
252
+ uvs remove my-script
253
+ ```
254
+
255
+ ## Security Considerations
256
+
257
+ - Scripts run with user permissions
258
+ - No automatic execution during installation
259
+ - `uvs update` runs whatever is upstream; there is no pinning to a commit
260
+ - Git authentication is handled by Git itself; `uvs` stores no credentials
261
+ - Script and entry file names are validated before being written into wrappers
262
+
263
+ ## Future Enhancements (Optional)
264
+
265
+ - `uvs publish <script.py>` - Create and upload to new Gist
266
+ - `uvs search <query>` - Search public Gists (if GitHub API allows)
267
+ - `uvs info <script-name>` - Show script details and dependencies
268
+ - Shell completion for installed scripts