Metadata-Version: 2.4
Name: daedalus-tools
Version: 0.34.0
Summary: daedalus: loose scripts in one repo plus installable script sources, run with: daedalus <name> [args...]
License-Expression: GPL-3.0-only
Requires-Python: >=3.11.4
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: argcomplete<4,>=3.3
Requires-Dist: packaging<27,>=24
Requires-Dist: filelock<5,>=3.12
Requires-Dist: pymarkdownlnt<1,>=0.9
Requires-Dist: ruff<1,>=0.16.8
Requires-Dist: pyyaml<7,>=6.0.3
Requires-Dist: html5lib<2,>=1.1
Requires-Dist: esprima<5,>=4.0
Requires-Dist: shellcheck-py<0.12,>=0.11
Requires-Dist: uv<0.12,>=0.11
Dynamic: license-file

---
name: readme
version: 0.27.2
---

# daedalus (template)

Starter repository for daedalus:
one CLI, many small scripts, each with tests.

```bash
daedalus NAME ARGS...              # run a script
daedalus CATEGORY ...              # list scripts in the categories (AND)
daedalus --list                  # list everything
```

**[Install, usage, and development](https://gitea.nolivaldeziii.com/nvaldez/daedalus/src/branch/main/INSTALL.md)**
· [SPEC](https://gitea.nolivaldeziii.com/nvaldez/daedalus/src/branch/main/SPEC.md)
(how the repo is maintained) ·
[CHANGELOG](https://gitea.nolivaldeziii.com/nvaldez/daedalus/src/branch/main/CHANGELOG.md)

## Available scripts

| Script | Type | Version | Categories | What it does |
| --- | --- | --- | --- | --- |
| `git-tools` | Python | 1.0.0 | git | Git helper subcommands: `dir-status` - repository status table over a directory, recursive and read-only (local refs only): `branch`, upstream sync, staged/modified/untracked counts; default target `~/repositories`, falls back to the current directory, prints `no repo found` when neither holds a repository; `--fetch` syncs every repo first; ported from `repos.sh` |
| `gpgtools` | Python | 1.1.0 | gpg | YubiKey GPG/SSH helpers on Linux and Windows (Windows OpenSSH in PowerShell): initialize (gnupg readiness check + install), initialize_yubikey (fresh machine, steps 1-4), send_pubkey (resolve key, verify possession, append to a server), store_publickey (install the key from the machine being granted access), configure_ssh (marker-managed per-host ssh block) |
| `linter` | Python | 1.3.1 | dev, lint | Lint markdown (pymarkdown `MD*` rules plus dead links `MDL001`/`MDL002`), frontmatter (`FML*`), Python (ruff plus custom `PYC*` rules), JSON (`JSN*`) files, Python and shell fences in markdown (`fences`), HTML and JavaScript files (`htmljs`), and shell scripts (`shellcheck`); `--fix`, `--json`, `--settings`, `--exclude`, `-q`, `--no-color`, `-n` |

Run a few of the builtins:

```bash
daedalus --init                # register tab completion in bash (once)
daedalus git-tools dir-status  # repository status over a directory
daedalus linter markdown docs/ # lint the markdown under docs/
daedalus dev                   # list the scripts in the 'dev' category
```

`daedalus --list` prints the version and a `script` / `type` / `categories`
table. Each description is hidden by default to keep the listing clean;
add `-d`/`--desc` (`daedalus --desc --list`, `daedalus --desc <category>`)
to see each description wrapped under its row.

### git-tools

Git helper subcommands, category `git`; the first is `dir-status`:
one row per git repository found under a directory — recursive, but a
found repository is not descended into — with the branch, the upstream
sync (`N ahead, N behind`, `up to date`, `no upstream`), and the
working-tree counts (`N staged`, `N modified`, `N untracked`, or
`clean`). Every probe reads local refs; nothing touches the network or
changes the repositories.

```bash
daedalus git-tools                      # overview of the subcommands
daedalus git-tools dir-status           # scan ~/repositories (default)
daedalus git-tools dir-status ~/src      # scan that directory instead
daedalus git-tools dir-status --fetch   # git fetch in every repo first
daedalus git                             # list the scripts in 'git'
```

`dir-status` with no `DIRECTORY`: the default target is
`~/repositories`; when that folder is missing or holds no repository,
the current working directory is checked (a notice line goes to
stderr); when neither holds one, the script prints `no repo found`
and exits 1. A given `DIRECTORY` that does not exist is a usage
error (exit 2), and an unknown subcommand is an argparse error
(exit 2). `--fetch` runs `git fetch` in every discovered repository
before the probes — sync counts then include this run's fetch (this
is the only flag that touches the network); a repo with no remote or
a failed fetch is silently probed as without it.

When color is enabled (`NO_COLOR` unset/empty and `FORCE_COLOR` or a
terminal — the same gate as `daedalus --list`), yellow highlights what
wants attention: a branch other than `main`/`master`, a sync other
than `up to date`, and a working tree other than `clean`. Repo names
and headers stay plain; padding is applied before coloring, so a
redirected run is byte-identical to the no-color output.

| Argument | Default | Meaning |
| --- | --- | --- |
| `dir-status DIRECTORY` | `~/repositories`, else the current directory | Directory to scan recursively for git repositories |
| `--fetch` | off | `git fetch` in every repository before the status probes |

### gpgtools

`initialize` checks that gnupg is ready on this machine and installs
what is missing — the gnupg-only half of `initialize_yubikey`, with no
card expectations. Its use is on-site: on a bare server where you are
about to run `store_publickey --fingerprint`, this is the command that
makes the gpg-dependent sources work.

```bash
daedalus gpgtools initialize             # check gnupg, install when missing
daedalus gpgtools initialize --dry-run   # already ready, or the install command
```

| Argument | Default | Meaning |
| --- | --- | --- |
| `--dry-run` | off | Print what would happen (already ready or the install command); change nothing |

Exit codes: `0` gnupg ready (installed or already present), `2` package
install failed or gpg still unusable after it, `3` gpg missing and no
known package manager.

`initialize_yubikey` runs the fresh-machine flow for YubiKey-backed
GPG and SSH (steps 1-4 of the wiki guide): install gnupg when missing,
check the card, fetch the public key from the card's URL field, and
write the gpg-agent SSH config. Steps 5-7 are per-server and covered
by the subcommands below.

```bash
daedalus gpgtools                         # overview of the subcommands
daedalus gpgtools initialize_yubikey      # prepare this machine
daedalus gpgtools initialize_yubikey --dry-run   # print the plan only
```

| Argument | Default | Meaning |
| --- | --- | --- |
| `--dry-run` | off | Print the plan, write nothing |
| `--gnupg-home DIR` | `GNUPGHOME` or `~/.gnupg` | Which GnuPG home to configure |

Exit codes: `0` ready, `2` package install failed, `3` gpg missing and
no known package manager, `4` no card found, `5` public-key fetch did
not pair the keyring, `6` keyring unpaired and the card carries no URL.

`send_pubkey` covers guide steps 5-6 for one server: resolve the SSH
public key from one of five sources, prove possession of the private
half with a challenge signature (the YubiKey itself signs; PIN prompts
go to the user), then append the line to the target's
`authorized_keys` — idempotent, fingerprint-checked against stores,
and nothing is sent when verification fails.

```bash
daedalus gpgtools send_pubkey --yubikey you@server
daedalus gpgtools send_pubkey --fingerprint <FP> you@server
daedalus gpgtools send_pubkey --url https://keys.openpgp.org/vks/v1/by-fingerprint/<FP> you@server
daedalus gpgtools send_pubkey --pubkey "ssh-ed25519 AAAA... comment" you@server
daedalus gpgtools send_pubkey --file /media/usb/yubikey_auth.pub you@server
daedalus gpgtools send_pubkey --yubikey --dry-run you@server   # resolve only
```

| Argument | Default | Meaning |
| --- | --- | --- |
| `--yubikey` | — | Key from the plugged YubiKey via gpg-agent (must be the only agent key) |
| `--url URL` | — | Armored OpenPGP public key at a URL ([A] subkey is exported) |
| `--fingerprint FP` | — | Searched: local keyring → keys.openpgp.org → keyserver.ubuntu.com |
| `--pubkey LINE` | — | The literal SSH public key line |
| `--file PATH` | — | File holding the key line, e.g. a `.pub` from a USB stick (no network, no gpg) |
| `--no-verify` | verification on | Skip the proof-of-possession signature (explicit risk acceptance) |
| `--dry-run` | off | Resolve and print the key; verify and send nothing |

Additional exit codes: `7` ssh to the target failed, `8` no source
resolved a key, `10` proof-of-possession verification failed (nothing
was sent).

`store_publickey` is the mirror for the on-site bootstrap: run it on
the machine that access is being granted *to* — a server with ssh
password authentication disabled that no key authorizes yet, where
you are logged in at the console. It resolves the same five sources
and appends the key into this machine's `authorized_keys`, so the
machine holding the YubiKey can ssh in afterwards. There is no
proof-of-possession (the private half is, by design, elsewhere);
instead both resolve-and-store subcommands print an identity block —
line, source, and the key material's SHA-256 — to compare across
machines. Existing entries are preserved, nothing is duplicated, and
directory/file modes are forced to 700/600.

```bash
daedalus gpgtools store_publickey --file /media/usb/yubikey_auth.pub
daedalus gpgtools store_publickey --fingerprint FP
daedalus gpgtools store_publickey --pubkey "ssh-ed25519 AAAA... comment"
daedalus gpgtools store_publickey --file /media/usb/yubikey_auth.pub --dry-run  # print only
```

| Argument | Default | Meaning |
| --- | --- | --- |
| sources | — | Same five sources as `send_pubkey` (exactly one required) |
| `--authorized-keys FILE` | `~/.ssh/authorized_keys` | Where to install the key |
| `--dry-run` | off | Resolve and print the key; write nothing |

Additional exit codes: `8` no source resolved a key.

`configure_ssh` covers guide step 7 for one host: it writes a
marker-managed `Host <alias>` block into the ssh client config.
Outside the markers your config is preserved byte-for-byte; re-runs
replace the block (idempotent), and an unmanaged `Host` with the same
alias is refused rather than shadowed. It never connects anywhere.

```bash
daedalus gpgtools configure_ssh --alias vault1 --hostname 203.0.113.10 --user admin
daedalus gpgtools configure_ssh --alias vault1 --dry-run   # print only
daedalus gpgtools configure_ssh --alias vault1 --no-fallback  # YubiKey only
```

| Argument | Default | Meaning |
| --- | --- | --- |
| `--alias NAME` | required | The ssh Host alias to configure |
| `--hostname HOST` | the alias | HostName value |
| `--user USER` | ssh's default | User value |
| `--pubkey FILE` | `~/.ssh/yubikey_auth.pub` | Primary IdentityFile (must exist) |
| `--fallback FILE` | `~/.ssh/id_ed25519` | Fallback IdentityFile, included only when it exists |
| `--no-fallback` | off | Never add a fallback IdentityFile |
| `--config PATH` | `~/.ssh/config` | Which ssh client config to edit |

Additional exit code: `11` an unmanaged `Host` with the same alias exists in the
config (move it into the managed markers or rename the alias).

`ssh-config-summary` prints what is enabled where, read-only: one row per
managed block — alias, hostname, user, the key id (first 8 chars of the
identity's SHA256 fingerprint, material-digest fallback), and the fallback
identity. Same id on two rows means the same gpg key guards both hosts.

```bash
daedalus gpgtools ssh-config-summary
daedalus gpgtools ssh-config-summary --config FILE
```

| Argument | Default | Meaning |
| --- | --- | --- |
| `--config FILE` | `~/.ssh/config` | Which ssh client config to read |

### gpgtools on Windows

gpgtools runs on Windows with the Windows OpenSSH client, from PowerShell.
It does not work with WSL, Git Bash, or Cygwin ssh, which do not use the
Windows gpg-agent pipe. `initialize` installs gnupg with
`winget install gpg --source winget` when gpg is missing, writes
`%APPDATA%\gnupg\gpg-agent.conf` and `sshcontrol`, restarts gpg-agent, and
checks that `ssh-add -l` lists the card's key. `configure_ssh` and
`ssh-config-summary` use `%USERPROFILE%\.ssh\config`. gpgtools does not change
the Windows `ssh-agent` service; stop it yourself when it answers in
gpg-agent's place.

`store_publickey` run from an administrator account warns that Windows sshd
reads `%ProgramData%\ssh\administrators_authorized_keys`; pass
`--authorized-keys` to target it. That file gets its ACL from `icacls`.

Exit codes changed in 1.1.0: `9` a `configure_ssh` pubkey file is missing (was
`8`); `12` on Windows, `ssh-add -l` does not list the card's key after setup;
`14` an existing config, `authorized_keys`, or gpg-agent file is not text
(nothing written); `64` a usage error (was `2`, which means install failed).
`--url` accepts `https://` only.

## Shell completion

Bash (and other shells argcomplete supports) completes script names and
category labels: `daedalus lin` + TAB completes `linter`, `daedalus dev l` +
TAB completes `linter` inside the category, and options complete after `-`.
Run `daedalus --init` once to register the hook in `~/.bashrc` (below); see
also [INSTALL](https://gitea.nolivaldeziii.com/nvaldez/daedalus/src/branch/main/INSTALL.md#tab-completion).

### --init

`daedalus --init` is the one-time shell-side setup: it finds the
`register-python-argcomplete` that belongs to this exact daedalus
interpreter (so a pipx install wires its own venv, not some other
python), appends the hook to `~/.bashrc` between managed markers, and
tells you how to activate it now. Installing daedalus never touches your
shell — this command does. It is idempotent: re-running on an already
registered `~/.bashrc` writes nothing.

```bash
daedalus --init                # register completion in ~/.bashrc
daedalus --init --dry-run     # print the block and the target, change nothing
daedalus --init --bashrc FILE # a different bashrc
```

| Argument | Default | Meaning |
| --- | --- | --- |
| `--bashrc FILE` | `~/.bashrc` | Target file for the managed hook block |
| `--dry-run` | off | Print the block and the target, change nothing |

Exit code: `3` when `register-python-argcomplete` is nowhere to be
found (reinstall daedalus — argcomplete is a declared dependency).

### Releasing daedalus (maintainers)

`publish.py` at the repository root releases the package itself. It is
not a builtin script: end users never see it. Guards first (clean
working tree, HEAD exactly tagged `v<version>`, the version not yet on
PyPI, `uv` and `twine` available), then a chained `uv build`, then
`twine check`. Without `--upload` it stops there and prints the
artifacts; with `--upload` it uploads exactly this version's sdist and
wheel. Credentials never touch the script: twine prompts or reads
`~/.pypirc`.

```bash
uv run python publish.py             # build + check, print next step
uv run python publish.py --upload    # ... and upload to PyPI
```

Exit codes: `2` not run from a checkout, `3` dirty tree, `4` not
exactly tagged `v<version>`, `5` build/twine missing, `6` version
already on PyPI (or PyPI unreachable), `7` build failed, `8` twine
check failed, `9` upload failed.

### Moved to daedalus-scripts

`linux-security-audit` is no longer a builtin. It ships in the
`daedalus-scripts` source, which you add once and install:

```bash
daedalus source add https://gitea.nolivaldeziii.com/nvaldez/daedalus-scripts.git
daedalus install daedalus.linux-security-audit
```

After the install, `daedalus linux-security-audit` runs it as before, and
`daedalus daedalus.linux-security-audit` always works. If you had the builtin
installed, `daedalus linux-security-audit` exits 2 with these two commands
until you install the new one. The audit's checks, output, and exit codes are
unchanged; its reference is `spec.md` in the `daedalus-scripts` repository.

### linter

Lints files without touching them (unless `--fix`). The check is `all`,
or one of `markdown`, `frontmatter`, `ruff`, `pycustom`, `json`, `fences`, `htmljs`, `shellcheck`.

```bash
daedalus builtin.linter all ~/wiki          # every check
daedalus linter markdown notes/             # one check, one folder
daedalus linter json config.json            # one file
daedalus linter fences notes/              # ruff on the Python fences of .md files
daedalus linter htmljs web/                # HTML and JavaScript syntax
daedalus linter shellcheck scripts/        # runs the shellcheck check on the .sh files
daedalus linter ruff . --fix                # apply the ruff fixes, then lint again
daedalus linter all . --json > lint.json    # one JSON document
daedalus linter all . -q                    # failing reports and the verdict only
daedalus linter all . -n                    # for scripts and AI: no progress bars, no color
```

On a terminal the text report is colored (red for failures, green for passes)
and a progress line per running check goes to stderr, so a long run shows it is
working. Color follows `NO_COLOR` and `FORCE_COLOR` (SPEC item 3.3.6). `--no-color`
turns color off; `-n` / `--non-interactive` turns off color and progress, and
`--json` never has either.

| Argument or flag | Default | Meaning |
| --- | --- | --- |
| `<check>` | required | `all`, `markdown`, `frontmatter`, `ruff`, `pycustom`, `json`, `fences`, `htmljs`, or `shellcheck` |
| `<path>...` | `.` | Files or folders to lint |
| `--fix` | off | Apply the fixes the check supports (markdown, ruff, json); then lint again |
| `--json` | off | Print one JSON document and nothing else |
| `--settings FILE` | lookup | Use this settings file instead of the lookup |
| `--exclude GLOB` | none | Skip paths matching the glob (repeatable), relative to the target |
| `-q`, `--quiet` | off | Print only the verdict line and the reports of failing checks |
| `--no-color` | off | Print the text report without ANSI color |
| `-n`, `--non-interactive` | off | No progress bars and no color (for scripts and AI agents) |

Exit codes: `0` clean, `1` at least one error violation (warnings do not
fail), `2` usage error, missing path, unreadable settings, or a tool failure.
Settings come from `daedalus-lint.json`, then `fiona-settings.json`, searched
from the target folder up (SPEC item 13.23.4). The read-only folders `personal/`
and `raw/` are never linted or fixed.

`htmljs` reads two settings sections: `html` (`extensions`, default `["html", "htm"]`;
`ignore_patterns`; `lint_inline_js`, default `false`, which also checks inline
`<script>` bodies) and `javascript` (`extensions`, default `["js", "javascript"]`;
`ignore_patterns`). Its findings print as `[FAIL]`, because they carry no rule code.
HTML is parsed with html5lib and JavaScript with esprima (pure Python, so the check
runs the same on Windows and Linux). `fences` checks fences tagged `python` or `py`
with ruff's default rules and not the project's ruff config, and fences tagged `bash`
or `sh` with shellcheck (`--shell` set to the tag).
`shellcheck` runs the `shellcheck` binary from PATH on each `.sh` file; the binary is
not a Python dependency, and a missing one exits 2 with an install hint. Its `info`
and `style` findings are warnings and do not fail the run.

## Sources

Scripts reach daedalus through sources (SPEC section 13). The builtin
scripts above are the `builtin` source. Other people can publish a
source, a feed of scripts, and you can install from it:

```bash
daedalus source add https://git.acme.example/daedalus-scripts.git   # register a feed
daedalus search backup                    # what the feeds offer
daedalus show acme.backup                 # the feed entry and its installed state
daedalus install acme.backup              # draft, then yes or no
daedalus acme.backup --help               # runs once installed
daedalus outdated                         # installed scripts with a newer offer
daedalus update                           # draft and update, one script at a time
daedalus verify                           # re-hash installed files; exit 1 on a mismatch
daedalus uninstall acme.backup
daedalus source remove acme               # the installed scripts stay
```

Installing shows a draft: the origin, the commit or sha256, the files,
the Python dependencies, and the required commands. The default answer is
**No**.

Every installed script runs by its bare name, `daedalus backup`, while no
other installed script has that name. When two or more do, the bare name
exits 2 as ambiguous, and you type the full id instead, for example
`daedalus acme.backup` or `daedalus builtin.git-tools`. The full id always
works. The listing shows the id in place of the name for a shared name.
External scripts never see daedalus's own environment.

Aliases give a long command a short name, and lockfiles reproduce an
installation elsewhere:

```bash
daedalus alias bk acme.backup             # daedalus bk ... runs acme.backup
daedalus alias                            # list aliases and their status
daedalus alias --remove bk
daedalus alias --clear                    # delete every alias
daedalus export --output daedalus.lock.json
daedalus import daedalus.lock.json        # on another machine
```

`daedalus --list` shows installed scripts only, with their versions.
`-d` adds descriptions. Publishing a source is covered in
[PUBLISHING.md](./PUBLISHING.md).

## Getting started

1. Clone or copy this template and name the Git remote for your team.
2. Add a script under `python/src/`, `bash/`, `powershell/`, or `batch/`
   (see [SPEC layout](https://gitea.nolivaldeziii.com/nvaldez/daedalus/src/branch/main/SPEC.md#2-layout));
   bash scripts implement the shared `help()` interface (SPEC item 6.10).
3. Add its entry to `daedalus/builtin_feed.json` and a manifest
   `<name>.script.json` with its `version`, add a row to the table above,
   write tests, bump `version` in `pyproject.toml`, and run
   `python autotest.py`.

`git-tools` is a small example: copy its file, feed entry, manifest, README row, and
tests to add your own. Unknown names exit with code 2 and suggest
close matches.
