clapshim 0.1.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.
- clapshim-0.1.0/.github/workflows/ci.yml +26 -0
- clapshim-0.1.0/.github/workflows/release_cli.yml +113 -0
- clapshim-0.1.0/.github/workflows/release_python.yml +158 -0
- clapshim-0.1.0/.gitignore +6 -0
- clapshim-0.1.0/AGENTS.md +36 -0
- clapshim-0.1.0/Cargo.lock +414 -0
- clapshim-0.1.0/Cargo.toml +26 -0
- clapshim-0.1.0/LICENSE +21 -0
- clapshim-0.1.0/PKG-INFO +94 -0
- clapshim-0.1.0/PLAN.md +65 -0
- clapshim-0.1.0/README.md +70 -0
- clapshim-0.1.0/pyproject.toml +33 -0
- clapshim-0.1.0/src/builder.rs +541 -0
- clapshim-0.1.0/src/codegen.rs +83 -0
- clapshim-0.1.0/src/exec.rs +113 -0
- clapshim-0.1.0/src/lib.rs +151 -0
- clapshim-0.1.0/src/main.rs +502 -0
- clapshim-0.1.0/src/manifest.rs +201 -0
- clapshim-0.1.0/src/wrap.rs +524 -0
- clapshim-0.1.0/tests/integration.rs +447 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
env:
|
|
9
|
+
CARGO_TERM_COLOR: always
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
check-and-test:
|
|
13
|
+
name: Linux (fmt, clippy, test)
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v7
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.14"
|
|
20
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
21
|
+
with:
|
|
22
|
+
components: clippy, rustfmt
|
|
23
|
+
- uses: Swatinem/rust-cache@v2
|
|
24
|
+
- run: cargo fmt --all --check
|
|
25
|
+
- run: cargo clippy --all-targets -- -D warnings
|
|
26
|
+
- run: cargo test
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
name: Release CLI binaries
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
|
|
11
|
+
env:
|
|
12
|
+
CARGO_TERM_COLOR: always
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build:
|
|
16
|
+
name: Build (${{ matrix.target }})
|
|
17
|
+
strategy:
|
|
18
|
+
fail-fast: false
|
|
19
|
+
matrix:
|
|
20
|
+
include:
|
|
21
|
+
- target: x86_64-unknown-linux-gnu
|
|
22
|
+
os: ubuntu-24.04
|
|
23
|
+
archive: tar.gz
|
|
24
|
+
bin: clapshim
|
|
25
|
+
- target: aarch64-unknown-linux-gnu
|
|
26
|
+
os: ubuntu-24.04-arm
|
|
27
|
+
archive: tar.gz
|
|
28
|
+
bin: clapshim
|
|
29
|
+
- target: x86_64-apple-darwin
|
|
30
|
+
os: macos-latest
|
|
31
|
+
archive: tar.gz
|
|
32
|
+
bin: clapshim
|
|
33
|
+
- target: aarch64-apple-darwin
|
|
34
|
+
os: macos-latest
|
|
35
|
+
archive: tar.gz
|
|
36
|
+
bin: clapshim
|
|
37
|
+
- target: x86_64-pc-windows-msvc
|
|
38
|
+
os: windows-latest
|
|
39
|
+
archive: zip
|
|
40
|
+
bin: clapshim.exe
|
|
41
|
+
runs-on: ${{ matrix.os }}
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v4
|
|
44
|
+
|
|
45
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
46
|
+
with:
|
|
47
|
+
targets: ${{ matrix.target }}
|
|
48
|
+
|
|
49
|
+
- uses: Swatinem/rust-cache@v2
|
|
50
|
+
with:
|
|
51
|
+
key: cli-${{ matrix.target }}
|
|
52
|
+
|
|
53
|
+
- name: Build release binary
|
|
54
|
+
run: cargo build --release --locked --target ${{ matrix.target }}
|
|
55
|
+
|
|
56
|
+
- name: Package archive (Unix)
|
|
57
|
+
if: matrix.archive == 'tar.gz'
|
|
58
|
+
shell: bash
|
|
59
|
+
run: |
|
|
60
|
+
TAG="${GITHUB_REF_NAME}"
|
|
61
|
+
STAGE="clapshim-${TAG}-${{ matrix.target }}"
|
|
62
|
+
mkdir -p "dist/${STAGE}"
|
|
63
|
+
cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "dist/${STAGE}/"
|
|
64
|
+
cp LICENSE README.md "dist/${STAGE}/"
|
|
65
|
+
tar -C dist -czf "dist/${STAGE}.tar.gz" "${STAGE}"
|
|
66
|
+
|
|
67
|
+
- name: Package archive (Windows)
|
|
68
|
+
if: matrix.archive == 'zip'
|
|
69
|
+
shell: pwsh
|
|
70
|
+
run: |
|
|
71
|
+
$tag = "$env:GITHUB_REF_NAME"
|
|
72
|
+
$stage = "clapshim-$tag-${{ matrix.target }}"
|
|
73
|
+
New-Item -ItemType Directory -Force -Path "dist/$stage" | Out-Null
|
|
74
|
+
Copy-Item "target/${{ matrix.target }}/release/${{ matrix.bin }}" "dist/$stage/"
|
|
75
|
+
Copy-Item "LICENSE", "README.md" "dist/$stage/"
|
|
76
|
+
Compress-Archive -Path "dist/$stage/*" -DestinationPath "dist/$stage.zip"
|
|
77
|
+
|
|
78
|
+
- name: Upload archive
|
|
79
|
+
uses: actions/upload-artifact@v4
|
|
80
|
+
with:
|
|
81
|
+
name: cli-${{ matrix.target }}
|
|
82
|
+
path: |
|
|
83
|
+
dist/*.tar.gz
|
|
84
|
+
dist/*.zip
|
|
85
|
+
|
|
86
|
+
upload-release-assets:
|
|
87
|
+
name: Attach binaries to GitHub Release
|
|
88
|
+
if: github.event_name == 'release'
|
|
89
|
+
needs: [build]
|
|
90
|
+
runs-on: ubuntu-latest
|
|
91
|
+
steps:
|
|
92
|
+
- uses: actions/download-artifact@v4
|
|
93
|
+
with:
|
|
94
|
+
pattern: cli-*
|
|
95
|
+
path: artifacts
|
|
96
|
+
merge-multiple: true
|
|
97
|
+
|
|
98
|
+
- name: Generate SHA256SUMS.txt
|
|
99
|
+
working-directory: artifacts
|
|
100
|
+
run: |
|
|
101
|
+
sha256sum *.tar.gz *.zip > SHA256SUMS.txt
|
|
102
|
+
cat SHA256SUMS.txt
|
|
103
|
+
|
|
104
|
+
- name: Upload assets to GitHub Release
|
|
105
|
+
env:
|
|
106
|
+
GH_TOKEN: ${{ github.token }}
|
|
107
|
+
run: |
|
|
108
|
+
gh release upload "${GITHUB_REF_NAME}" \
|
|
109
|
+
artifacts/*.tar.gz \
|
|
110
|
+
artifacts/*.zip \
|
|
111
|
+
artifacts/SHA256SUMS.txt \
|
|
112
|
+
--repo "${GITHUB_REPOSITORY}" \
|
|
113
|
+
--clobber
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
name: Release Python package
|
|
2
|
+
|
|
3
|
+
# Builds binary wheels (`bindings = "bin"`) for `clapshim` and publishes them to PyPI via
|
|
4
|
+
# Trusted Publishing on a GitHub release. A manual run builds and smoke-tests wheels without publishing.
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
linux:
|
|
16
|
+
strategy:
|
|
17
|
+
fail-fast: false
|
|
18
|
+
matrix:
|
|
19
|
+
include:
|
|
20
|
+
- target: x86_64
|
|
21
|
+
runner: ubuntu-24.04
|
|
22
|
+
- target: aarch64
|
|
23
|
+
runner: ubuntu-24.04-arm
|
|
24
|
+
runs-on: ${{ matrix.runner }}
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
|
|
28
|
+
- name: Build wheel
|
|
29
|
+
uses: PyO3/maturin-action@v1
|
|
30
|
+
with:
|
|
31
|
+
target: ${{ matrix.target }}
|
|
32
|
+
manylinux: "2_28"
|
|
33
|
+
args: --release --out dist
|
|
34
|
+
sccache: "true"
|
|
35
|
+
|
|
36
|
+
- name: Upload wheel
|
|
37
|
+
uses: actions/upload-artifact@v4
|
|
38
|
+
with:
|
|
39
|
+
name: wheels-linux-${{ matrix.target }}
|
|
40
|
+
path: dist
|
|
41
|
+
|
|
42
|
+
macos:
|
|
43
|
+
strategy:
|
|
44
|
+
fail-fast: false
|
|
45
|
+
matrix:
|
|
46
|
+
target: [x86_64, aarch64]
|
|
47
|
+
runs-on: macos-latest
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v4
|
|
50
|
+
|
|
51
|
+
- name: Build wheel
|
|
52
|
+
uses: PyO3/maturin-action@v1
|
|
53
|
+
with:
|
|
54
|
+
target: ${{ matrix.target }}
|
|
55
|
+
args: --release --out dist
|
|
56
|
+
sccache: "true"
|
|
57
|
+
|
|
58
|
+
- name: Upload wheel
|
|
59
|
+
uses: actions/upload-artifact@v4
|
|
60
|
+
with:
|
|
61
|
+
name: wheels-macos-${{ matrix.target }}
|
|
62
|
+
path: dist
|
|
63
|
+
|
|
64
|
+
windows:
|
|
65
|
+
runs-on: windows-latest
|
|
66
|
+
steps:
|
|
67
|
+
- uses: actions/checkout@v4
|
|
68
|
+
|
|
69
|
+
- name: Build wheel
|
|
70
|
+
uses: PyO3/maturin-action@v1
|
|
71
|
+
with:
|
|
72
|
+
target: x64
|
|
73
|
+
args: --release --out dist
|
|
74
|
+
sccache: "false"
|
|
75
|
+
|
|
76
|
+
- name: Upload wheel
|
|
77
|
+
uses: actions/upload-artifact@v4
|
|
78
|
+
with:
|
|
79
|
+
name: wheels-windows-x64
|
|
80
|
+
path: dist
|
|
81
|
+
|
|
82
|
+
sdist:
|
|
83
|
+
runs-on: ubuntu-latest
|
|
84
|
+
steps:
|
|
85
|
+
- uses: actions/checkout@v4
|
|
86
|
+
|
|
87
|
+
- name: Build sdist
|
|
88
|
+
uses: PyO3/maturin-action@v1
|
|
89
|
+
with:
|
|
90
|
+
command: sdist
|
|
91
|
+
args: --out dist
|
|
92
|
+
|
|
93
|
+
- name: Upload sdist
|
|
94
|
+
uses: actions/upload-artifact@v4
|
|
95
|
+
with:
|
|
96
|
+
name: wheels-sdist
|
|
97
|
+
path: dist
|
|
98
|
+
|
|
99
|
+
test-wheels:
|
|
100
|
+
needs: [linux, macos, windows]
|
|
101
|
+
strategy:
|
|
102
|
+
fail-fast: false
|
|
103
|
+
matrix:
|
|
104
|
+
platform: [linux-x86_64, linux-aarch64, macos-aarch64, windows-x64]
|
|
105
|
+
include:
|
|
106
|
+
- platform: linux-x86_64
|
|
107
|
+
os: ubuntu-24.04
|
|
108
|
+
- platform: linux-aarch64
|
|
109
|
+
os: ubuntu-24.04-arm
|
|
110
|
+
- platform: macos-aarch64
|
|
111
|
+
os: macos-latest
|
|
112
|
+
- platform: windows-x64
|
|
113
|
+
os: windows-latest
|
|
114
|
+
runs-on: ${{ matrix.os }}
|
|
115
|
+
steps:
|
|
116
|
+
- uses: actions/setup-python@v7
|
|
117
|
+
with:
|
|
118
|
+
python-version: "3.14"
|
|
119
|
+
|
|
120
|
+
- uses: actions/download-artifact@v4
|
|
121
|
+
with:
|
|
122
|
+
name: wheels-${{ matrix.platform }}
|
|
123
|
+
path: wheelhouse
|
|
124
|
+
|
|
125
|
+
- name: Install wheel and smoke-test binary
|
|
126
|
+
shell: bash
|
|
127
|
+
run: |
|
|
128
|
+
python -m venv .wheel-venv
|
|
129
|
+
if [ -x .wheel-venv/bin/python ]; then
|
|
130
|
+
PY=.wheel-venv/bin/python
|
|
131
|
+
BIN=.wheel-venv/bin/clapshim
|
|
132
|
+
else
|
|
133
|
+
PY=.wheel-venv/Scripts/python.exe
|
|
134
|
+
BIN=.wheel-venv/Scripts/clapshim.exe
|
|
135
|
+
fi
|
|
136
|
+
"$PY" -m pip install --quiet wheelhouse/*.whl
|
|
137
|
+
"$BIN" --version
|
|
138
|
+
"$BIN" --help
|
|
139
|
+
|
|
140
|
+
publish:
|
|
141
|
+
name: Publish to PyPI
|
|
142
|
+
if: github.event_name == 'release'
|
|
143
|
+
needs: [linux, macos, windows, sdist, test-wheels]
|
|
144
|
+
runs-on: ubuntu-latest
|
|
145
|
+
environment: pypi
|
|
146
|
+
permissions:
|
|
147
|
+
id-token: write
|
|
148
|
+
steps:
|
|
149
|
+
- uses: actions/download-artifact@v4
|
|
150
|
+
with:
|
|
151
|
+
pattern: wheels-*
|
|
152
|
+
path: dist
|
|
153
|
+
merge-multiple: true
|
|
154
|
+
|
|
155
|
+
- name: Publish to PyPI
|
|
156
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
157
|
+
with:
|
|
158
|
+
packages-dir: dist/
|
clapshim-0.1.0/AGENTS.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# AGENTS.md (`clapshim`)
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`clapshim` is a single native Rust multicall binary (`clap` + `clap_complete` + `serde_json`) that
|
|
6
|
+
gives any Python CLI (Typer, Click, Cleo, Cappa, Cyclopts, argparse) ~2–4 ms `--help`, `--version`,
|
|
7
|
+
flag validation, native shell completions, and hybrid direct/pass-through Python execution.
|
|
8
|
+
|
|
9
|
+
Manifests (schema v1) are exported by `clinspector.synthesis.synth_clap`.
|
|
10
|
+
|
|
11
|
+
## Layout
|
|
12
|
+
|
|
13
|
+
- `src/manifest.rs` — Schema v1 serde models (`Manifest`, `CommandSpec`, `ParamSpec`, `DispatchSpec`) and `mtime` staleness check.
|
|
14
|
+
- `src/builder.rs` — Dynamic `clap::Command` builder (using `clap`'s `string` feature) and resolved kwargs extractor for direct dispatch.
|
|
15
|
+
- `src/exec.rs` — Unix `execvp` / Windows spawn for direct lazy dispatch and lossless passthrough.
|
|
16
|
+
- `src/wrap.rs` — `wrap` / `unwrap` / `refresh` / `list` / `completions` management commands.
|
|
17
|
+
- `src/codegen.rs` — `compile` standalone Rust project emitter (`include_str!`).
|
|
18
|
+
- `src/main.rs` — `argv[0]` multicall router + management CLI.
|
|
19
|
+
- `tests/integration.rs` — end-to-end tests exercising `--help`, direct dispatch, passthrough, multicall symlinks, staleness fallback, completions, and codegen.
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
Always build through `mbx` (`mr_boxington`):
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
mbx fmt --all --check
|
|
27
|
+
mbx clippy --all-targets -- -D warnings
|
|
28
|
+
mbx test
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Conventions
|
|
32
|
+
|
|
33
|
+
- Rust edition 2024, MSRV 1.95.
|
|
34
|
+
- Keep `clapshim` dependency-light and fast to compile/start (~2 MB release binary, ~2 ms startup).
|
|
35
|
+
- Preserve 100% compatibility: whenever a command cannot safely use direct dispatch (or watched
|
|
36
|
+
source files are stale), always fall back cleanly to passthrough execution.
|