auto-toolkit 0.1.0b1__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.
- auto_toolkit-0.1.0b1/.github/workflows/pypi-publish.yml +25 -0
- auto_toolkit-0.1.0b1/.gitignore +66 -0
- auto_toolkit-0.1.0b1/.python-version +1 -0
- auto_toolkit-0.1.0b1/ARCHITECTURE.md +83 -0
- auto_toolkit-0.1.0b1/CONTRIBUTING.md +127 -0
- auto_toolkit-0.1.0b1/Makefile +30 -0
- auto_toolkit-0.1.0b1/PKG-INFO +409 -0
- auto_toolkit-0.1.0b1/README.md +386 -0
- auto_toolkit-0.1.0b1/RELEASE.md +100 -0
- auto_toolkit-0.1.0b1/bin/auto +17 -0
- auto_toolkit-0.1.0b1/data/apps/auto-toolkit/install.sh +85 -0
- auto_toolkit-0.1.0b1/data/apps/auto-toolkit/update.sh +70 -0
- auto_toolkit-0.1.0b1/data/libs/args.sh +366 -0
- auto_toolkit-0.1.0b1/data/libs/common.sh +122 -0
- auto_toolkit-0.1.0b1/data/libs/download.sh +102 -0
- auto_toolkit-0.1.0b1/data/libs/gpg.sh +122 -0
- auto_toolkit-0.1.0b1/data/libs/pkg.sh +104 -0
- auto_toolkit-0.1.0b1/data/scripts/docker/docker-cleanup.sh +69 -0
- auto_toolkit-0.1.0b1/data/scripts/files/find-large-files.sh +120 -0
- auto_toolkit-0.1.0b1/data/scripts/security/hash-check.sh +177 -0
- auto_toolkit-0.1.0b1/data/scripts/setup/setup-dev-env.sh +104 -0
- auto_toolkit-0.1.0b1/data/scripts/system/install-program.sh +90 -0
- auto_toolkit-0.1.0b1/pyproject.toml +63 -0
- auto_toolkit-0.1.0b1/src/__init__.py +5 -0
- auto_toolkit-0.1.0b1/src/__main__.py +10 -0
- auto_toolkit-0.1.0b1/src/cli.py +687 -0
- auto_toolkit-0.1.0b1/src/colors.py +49 -0
- auto_toolkit-0.1.0b1/src/config.py +116 -0
- auto_toolkit-0.1.0b1/src/constants.py +67 -0
- auto_toolkit-0.1.0b1/src/discovery.py +357 -0
- auto_toolkit-0.1.0b1/src/enums.py +34 -0
- auto_toolkit-0.1.0b1/src/executor.py +103 -0
- auto_toolkit-0.1.0b1/src/installer.py +138 -0
- auto_toolkit-0.1.0b1/src/metadata.py +128 -0
- auto_toolkit-0.1.0b1/src/search.py +122 -0
- auto_toolkit-0.1.0b1/src/trust.py +211 -0
- auto_toolkit-0.1.0b1/src/validator.py +158 -0
- auto_toolkit-0.1.0b1/tests/__init__.py +1 -0
- auto_toolkit-0.1.0b1/tests/test_apps.py +97 -0
- auto_toolkit-0.1.0b1/tests/test_automations.py +33 -0
- auto_toolkit-0.1.0b1/tests/test_cli.py +430 -0
- auto_toolkit-0.1.0b1/tests/test_config.py +98 -0
- auto_toolkit-0.1.0b1/tests/test_discovery.py +206 -0
- auto_toolkit-0.1.0b1/tests/test_enums_and_constants.py +74 -0
- auto_toolkit-0.1.0b1/tests/test_executor.py +148 -0
- auto_toolkit-0.1.0b1/tests/test_installer.py +142 -0
- auto_toolkit-0.1.0b1/tests/test_libs.py +207 -0
- auto_toolkit-0.1.0b1/tests/test_metadata.py +129 -0
- auto_toolkit-0.1.0b1/tests/test_search.py +128 -0
- auto_toolkit-0.1.0b1/tests/test_trust.py +127 -0
- auto_toolkit-0.1.0b1/tests/test_validator.py +139 -0
- auto_toolkit-0.1.0b1/uv.lock +334 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
environment:
|
|
12
|
+
name: release
|
|
13
|
+
url: https://pypi.org/p/auto-toolkit
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v6
|
|
20
|
+
- uses: actions/setup-python@v6
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.x"
|
|
23
|
+
- run: python -m pip install --upgrade pip build
|
|
24
|
+
- run: python -m build
|
|
25
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
|
|
7
|
+
# C extension build artifacts
|
|
8
|
+
build/
|
|
9
|
+
develop-eggs/
|
|
10
|
+
dist/
|
|
11
|
+
downloads/
|
|
12
|
+
eggs/
|
|
13
|
+
.eggs/
|
|
14
|
+
lib/
|
|
15
|
+
lib64/
|
|
16
|
+
parts/
|
|
17
|
+
sdist/
|
|
18
|
+
var/
|
|
19
|
+
wheels/
|
|
20
|
+
*.egg-info/
|
|
21
|
+
.installed.cfg
|
|
22
|
+
*.egg
|
|
23
|
+
|
|
24
|
+
# Virtual environments
|
|
25
|
+
.venv/
|
|
26
|
+
env/
|
|
27
|
+
venv/
|
|
28
|
+
ENV/
|
|
29
|
+
env.bak/
|
|
30
|
+
venv.bak/
|
|
31
|
+
|
|
32
|
+
# UV caches
|
|
33
|
+
.uv/
|
|
34
|
+
|
|
35
|
+
# Testing and linters
|
|
36
|
+
.pytest_cache/
|
|
37
|
+
.ruff_cache/
|
|
38
|
+
.mypy_cache/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
|
|
45
|
+
# Editor and IDE directories
|
|
46
|
+
.vscode/
|
|
47
|
+
.idea/
|
|
48
|
+
*.sublime-project
|
|
49
|
+
*.sublime-workspace
|
|
50
|
+
|
|
51
|
+
# Operating System files
|
|
52
|
+
.DS_Store
|
|
53
|
+
.DS_Store?
|
|
54
|
+
._*
|
|
55
|
+
.Spotlight-V100
|
|
56
|
+
.Trashes
|
|
57
|
+
ehthumbs.db
|
|
58
|
+
Thumbs.db
|
|
59
|
+
|
|
60
|
+
# Backups and temporary files
|
|
61
|
+
*.swp
|
|
62
|
+
*.swo
|
|
63
|
+
*.bak
|
|
64
|
+
*.tmp
|
|
65
|
+
*~
|
|
66
|
+
#*#
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Architecture Overview
|
|
2
|
+
|
|
3
|
+
The **Personal Automation Toolkit (`auto-toolkit`)** is a modular automation engine and CLI designed to discover, document, validate, and execute automation scripts and application lifecycle tasks across single or multiple repositories from any directory.
|
|
4
|
+
|
|
5
|
+
## 1. Core Execution Pipeline
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
User Command: auto <name|app|verb> [args...]
|
|
9
|
+
│
|
|
10
|
+
▼
|
|
11
|
+
1. Configuration & Multi-Repo Resolution (src/config.py)
|
|
12
|
+
Loads registered repositories from AUTO_REPOS env var and ~/.auto-toolkit/config.toml
|
|
13
|
+
│
|
|
14
|
+
▼
|
|
15
|
+
2. Multi-Root Dynamic Discovery (src/discovery.py)
|
|
16
|
+
Scans data/scripts/ & data/apps/ across all repos, strips extensions (.sh, .py), creates aliases
|
|
17
|
+
│
|
|
18
|
+
▼
|
|
19
|
+
3. Metadata Parsing (src/metadata.py)
|
|
20
|
+
Extracts DESCRIPTION, TAGS, DEPENDS, ENV, VERSION, AUTHOR, USAGE from file header comments
|
|
21
|
+
│
|
|
22
|
+
▼
|
|
23
|
+
4. Resolution & Search (src/search.py / src/cli.py)
|
|
24
|
+
Exact match -> Alias match -> Prefix match -> Ranked multi-token search
|
|
25
|
+
│
|
|
26
|
+
▼
|
|
27
|
+
5. Pre-Flight Validation (src/executor.py)
|
|
28
|
+
Verifies executable permissions (+x) and checks $PATH for declared dependencies
|
|
29
|
+
│
|
|
30
|
+
▼
|
|
31
|
+
6. Process Handover (os.execvp)
|
|
32
|
+
Replaces CLI process image directly with target script (zero wrapping overhead)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 2. Directory Layout & Module Roles
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
├── bin/
|
|
39
|
+
│ └── auto # CLI entrypoint executable
|
|
40
|
+
│
|
|
41
|
+
├── src/ # Python Core Engine
|
|
42
|
+
│ ├── cli.py # Command routing, terminal presentation, and subcommand handlers
|
|
43
|
+
│ ├── colors.py # ANSI terminal colors with toggle support
|
|
44
|
+
│ ├── config.py # Multi-repository configuration loader (env vars + TOML)
|
|
45
|
+
│ ├── constants.py # Central paths, extensions, exclusions, and synonyms
|
|
46
|
+
│ ├── discovery.py # Multi-root file scanner, extension stripper, and alias generator
|
|
47
|
+
│ ├── enums.py # HeaderKey and Severity enums
|
|
48
|
+
│ ├── executor.py # Pre-flight checks and os.execvp process replacement
|
|
49
|
+
│ ├── installer.py # PATH management and symlink installer
|
|
50
|
+
│ ├── metadata.py # Header comment parser (Bash, Python, C-style comments)
|
|
51
|
+
│ ├── search.py # Multi-token ranked search scoring engine
|
|
52
|
+
│ └── validator.py # Repository health diagnostics (shebangs, permissions, dependencies)
|
|
53
|
+
│
|
|
54
|
+
├── data/ # Executable Assets & Libraries
|
|
55
|
+
│ ├── apps/ # Multi-action application packages (e.g. auto-toolkit/install.sh)
|
|
56
|
+
│ ├── scripts/ # Category-organized utilities (docker/, files/, setup/, system/, etc.)
|
|
57
|
+
│ └── libs/ # Reusable shell helpers (args.sh, common.sh, download.sh, gpg.sh, pkg.sh)
|
|
58
|
+
│
|
|
59
|
+
├── tests/ # Pytest test suite (100% unit & integration test coverage)
|
|
60
|
+
└── pyproject.toml # Hatchling build configuration & PyPI metadata
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 3. Multi-Repository & Extensibility Architecture
|
|
64
|
+
|
|
65
|
+
To enable users to maintain personal or proprietary scripts without polluting or forking the core engine repository, `auto-toolkit` implements a **Kernel / Userspace** separation:
|
|
66
|
+
|
|
67
|
+
1. **Core Repository (`core`)**: Contains the Python engine (`src/`), base shell libraries (`data/libs/`), and starter scripts.
|
|
68
|
+
2. **User Repositories (`personal`, `work`, etc.)**: Independent Git repositories structured with their own `data/scripts/`, `data/apps/`, and `data/libs/`.
|
|
69
|
+
3. **Repository Resolution Order**:
|
|
70
|
+
- `core`: Root of the installed `auto-toolkit` repository (always first).
|
|
71
|
+
- `AUTO_REPOS`: Environment variable (e.g. `export AUTO_REPOS="personal=~/.auto-toolkit/repos/automations"`).
|
|
72
|
+
- `~/.auto-toolkit/config.toml`: Persistent TOML configuration file (`[repos]` section).
|
|
73
|
+
4. **Source Tagging**: When multiple repositories are active, `auto list` and `auto search` annotate items with their source repository tag (e.g. `[core]`, `[personal]`).
|
|
74
|
+
5. **Update Lifecycle**:
|
|
75
|
+
- `auto self-update`: Orchestrates `git pull` on the core engine repo.
|
|
76
|
+
- `auto repo-update [name]`: Orchestrates `git pull` across user-added repositories.
|
|
77
|
+
|
|
78
|
+
## 4. Key Design Decisions
|
|
79
|
+
|
|
80
|
+
- **Process Handover (`os.execvp`)**: Rather than running scripts inside subshells or pipes, the CLI replaces its own process with the target executable. This preserves standard I/O (interactive prompts), terminal TTY colors, signal handling (`SIGINT`/`Ctrl+C`), and exact exit codes.
|
|
81
|
+
- **Convention Over Configuration**: No central JSON or YAML script registry. Adding a script to `data/scripts/<category>/` or `data/apps/<app>/` automatically makes it discoverable.
|
|
82
|
+
- **Extension-Free CLI**: Scripts retain clear file extensions (`.sh`, `.py`) in the repository for editor tooling and linters, but users invoke them cleanly (`auto docker-cleanup` or `auto install auto-toolkit`).
|
|
83
|
+
- **Zero Third-Party Production Dependencies**: The core CLI is built strictly with the Python standard library.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Contributing Guide
|
|
2
|
+
|
|
3
|
+
Guidelines for contributing to the core **`auto-toolkit`** repository or developing personal automation repositories.
|
|
4
|
+
|
|
5
|
+
## 1. Core Repository vs. Personal Automation Repositories
|
|
6
|
+
|
|
7
|
+
Before adding new scripts, decide whether they belong in the **upstream `auto-toolkit`** or in a **personal repository**:
|
|
8
|
+
|
|
9
|
+
| Type | Destination | Examples |
|
|
10
|
+
| :------------------------------------- | :----------------------------------------------------------------- | :------------------------------------------------------------------------------------------------ |
|
|
11
|
+
| **General Utilities & Core Engine** | `auto-toolkit` (this repository) | Reusable system tools, general docker helpers, CLI enhancements, shared libraries in `data/libs/` |
|
|
12
|
+
| **Personal / Proprietary Automations** | Personal Git repository (e.g. `~/.auto-toolkit/repos/automations`) | Personal dotfiles setups, company deployments, internal API scripts, private credentials |
|
|
13
|
+
|
|
14
|
+
To register your personal repository with `auto`:
|
|
15
|
+
|
|
16
|
+
```toml
|
|
17
|
+
# ~/.auto-toolkit/config.toml
|
|
18
|
+
[repos]
|
|
19
|
+
personal = "~/.auto-toolkit/repos/automations"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 2. Quick Development Setup
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Sync virtual environment and development dependencies
|
|
26
|
+
uv sync
|
|
27
|
+
|
|
28
|
+
# Run the test suite
|
|
29
|
+
uv run pytest -v
|
|
30
|
+
|
|
31
|
+
# Check formatting and lint rules
|
|
32
|
+
uv run ruff check src tests
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 3. Adding a General Script
|
|
36
|
+
|
|
37
|
+
1. Create an executable script under `data/scripts/<category>/<name>.<ext>`:
|
|
38
|
+
```bash
|
|
39
|
+
data/scripts/network/check-port.sh
|
|
40
|
+
```
|
|
41
|
+
2. Add a metadata header near the top of the file:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
#!/usr/bin/env bash
|
|
45
|
+
# DESCRIPTION: Test if a remote host port is open
|
|
46
|
+
# TAGS: network, port, tcp, ping
|
|
47
|
+
# DEPENDS: nc, curl
|
|
48
|
+
# USAGE: auto check-port <host> <port>
|
|
49
|
+
|
|
50
|
+
set -euo pipefail
|
|
51
|
+
HOST="${1:?Missing host}"
|
|
52
|
+
PORT="${2:?Missing port}"
|
|
53
|
+
nc -z -v -w5 "$HOST" "$PORT"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
3. Make it executable:
|
|
57
|
+
```bash
|
|
58
|
+
chmod +x data/scripts/network/check-port.sh
|
|
59
|
+
```
|
|
60
|
+
4. Test discovery and execution:
|
|
61
|
+
```bash
|
|
62
|
+
auto list network
|
|
63
|
+
auto check-port localhost 8080
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 4. Adding a Dedicated Application Package
|
|
67
|
+
|
|
68
|
+
When an application requires multi-stage lifecycles (downloads, PGP signature verification, package updates):
|
|
69
|
+
|
|
70
|
+
1. Create a directory under `data/apps/<app-name>/`.
|
|
71
|
+
2. Create `install.sh` and `update.sh`:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
#!/usr/bin/env bash
|
|
75
|
+
# DESCRIPTION: Install MyTool binary
|
|
76
|
+
# TAGS: app, mytool, install
|
|
77
|
+
# DEPENDS: curl, gpg
|
|
78
|
+
|
|
79
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
80
|
+
LIB_DIR="$(cd "$SCRIPT_DIR/../../libs" && pwd)"
|
|
81
|
+
source "$LIB_DIR/common.sh"
|
|
82
|
+
source "$LIB_DIR/args.sh"
|
|
83
|
+
source "$LIB_DIR/gpg.sh"
|
|
84
|
+
source "$LIB_DIR/download.sh"
|
|
85
|
+
|
|
86
|
+
# Implement verified installation...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
3. Make them executable (`chmod +x data/apps/<app-name>/*.sh`).
|
|
90
|
+
4. Test verb-first routing:
|
|
91
|
+
```bash
|
|
92
|
+
auto apps
|
|
93
|
+
auto install <app-name> --help
|
|
94
|
+
auto update <app-name> --help
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 5. Metadata Header Specification
|
|
98
|
+
|
|
99
|
+
| Field | Format | Description |
|
|
100
|
+
| :------------ | :-------------- | :------------------------------------------------- |
|
|
101
|
+
| `DESCRIPTION` | Text | Short summary shown in `auto list` and `auto info` |
|
|
102
|
+
| `TAGS` | Comma-separated | Search keywords for `auto search` |
|
|
103
|
+
| `DEPENDS` | Comma-separated | Required binaries checked before execution |
|
|
104
|
+
| `ENV` | Comma-separated | Required or optional environment variables |
|
|
105
|
+
| `VERSION` | SemVer | Script version string |
|
|
106
|
+
| `AUTHOR` | Text | Author/maintainer contact |
|
|
107
|
+
| `USAGE` | Text | Custom syntax shown in `auto info` |
|
|
108
|
+
|
|
109
|
+
## 6. Shared Helper Libraries (`data/libs/`)
|
|
110
|
+
|
|
111
|
+
When writing shell automations, reuse standard helpers:
|
|
112
|
+
|
|
113
|
+
- **`data/libs/args.sh`**: Declarative CLI argument parsing and automatic `--help` generation.
|
|
114
|
+
- **`data/libs/common.sh`**: Logging (`log_info`, `log_success`, `log_error`) and isolated temp directories.
|
|
115
|
+
- **`data/libs/download.sh`**: Resilient HTTP downloads with retry logic.
|
|
116
|
+
- **`data/libs/gpg.sh`**: Cryptographic detached signature and hash verification.
|
|
117
|
+
- **`data/libs/pkg.sh`**: Linux package manager detection and installation routines.
|
|
118
|
+
|
|
119
|
+
## 7. Quality & Pre-Commit Checklist
|
|
120
|
+
|
|
121
|
+
Before submitting a PR or commit:
|
|
122
|
+
|
|
123
|
+
- [ ] Script is marked executable (`chmod +x`).
|
|
124
|
+
- [ ] Valid shebang line is present (`#!/usr/bin/env bash` or `#!/usr/bin/env python3`).
|
|
125
|
+
- [ ] `auto validate` passes with 0 errors.
|
|
126
|
+
- [ ] `uv run pytest -v` passes (all unit and integration tests).
|
|
127
|
+
- [ ] `uv run ruff check src tests` passes.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.PHONY: test install uninstall validate check list clean dev
|
|
2
|
+
|
|
3
|
+
test:
|
|
4
|
+
@if command -v uv >/dev/null 2>&1; then \
|
|
5
|
+
uv run pytest; \
|
|
6
|
+
else \
|
|
7
|
+
python3 -m unittest discover -s tests -v; \
|
|
8
|
+
fi
|
|
9
|
+
|
|
10
|
+
dev:
|
|
11
|
+
uv sync
|
|
12
|
+
|
|
13
|
+
install:
|
|
14
|
+
./data/apps/auto-toolkit/install.sh
|
|
15
|
+
|
|
16
|
+
uninstall:
|
|
17
|
+
./bin/auto uninstall
|
|
18
|
+
|
|
19
|
+
validate:
|
|
20
|
+
./bin/auto validate
|
|
21
|
+
|
|
22
|
+
check: validate test
|
|
23
|
+
|
|
24
|
+
list:
|
|
25
|
+
./bin/auto list
|
|
26
|
+
|
|
27
|
+
clean:
|
|
28
|
+
find . -type d -name "__pycache__" -exec rm -rf {} +
|
|
29
|
+
find . -type f -name "*.pyc" -delete
|
|
30
|
+
rm -rf .pytest_cache .ruff_cache
|