daedalus 0.4.0: bash script interface (help() dispatch) + hello_bash

- bash/daedalus_common.sh (new): the shared interface for bash scripts
  (SPEC item 6.10) - a script sources its sibling helper, defines help()
  (usage) and main(), and ends with daedalus_bash_dispatch "$@" which
  routes help/-h/--help to help() and everything else to main()
  unchanged (clear fallback errors when a script forgets either)
- completion for bash scripts (SPEC item 3.13.5.2): after a completed
  script name daedalus offers --help, -h, help, prefix-filtered, written
  itself on the fd-8 argcomplete protocol - no script runs on TAB;
  scripts without the interface get the shell default
- bash/hello_bash.sh (new, category test): sample script through the
  interface, the bash twin of hello, with tests; registry entry, README
  row, CHANGELOG bullet
- tests: bash/tests/test_bash_interface.py (helper behavior, bash -n,
  enforcement of the interface for every registered .sh),
  test_hello_bash.py (direct and daedalus runs, help routing, SPEC 3.1
  pass-through, completion probes including the user's
  daedalus hello_bash<TAB><TAB> case), completions units + e2e harness
- README/INSTALL/SPEC updated (6.10, 3.13.5.2, tree, boilerplate with
  shellcheck directive); autotest green (212 tests)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
2026-11-18 22:35:11 +01:00
parent c210e17661
commit ec9848b169
14 changed files with 433 additions and 20 deletions
+32 -3
View File
@@ -79,7 +79,8 @@ daedalus/
├── python/
│ ├── src/<name>/ # Python scripts, one folder per script
│ └── tests/ # pytest tests for python/src, .ps1, .bat
├── bash/ # *.sh scripts
├── bash/ # *.sh scripts (SPEC item 6.10 interface)
│ ├── daedalus_common.sh # shared helper: daedalus_bash_dispatch, help() routing
│ └── tests/ # pytest tests that run them
├── powershell/ # *.ps1 scripts
├── batch/ # *.bat scripts (CRLF)
@@ -298,8 +299,12 @@ help.
through, and the completion channel (fd 8) inherited. The script
completes its arguments (SPEC item 6.9); quoting in the words is
not preserved in the rewrite.
- **3.13.5.2** bash, PowerShell, and batch scripts get no
candidates: the shell default completion (file names) applies.
- **3.13.5.2** A `.sh` script that implements the interface (SPEC item
6.10) completes the help words `--help`, `-h`, and `help`, filtered
by the word being typed; daedalus writes them itself on the
completion channel — no script runs on TAB. A `.sh` script without
the interface, and `.ps1` / `.bat` scripts, get no candidates: the
shell default (file names) applies.
- **3.13.6** The completion hook re-runs the `daedalus` command on
`PATH`: the program that runs on TAB must import argcomplete
(installed dependency, or the dev venv, or the system package) and
@@ -466,6 +471,30 @@ SCRIPTS: dict[str, Script] = {
shell default, and a TAB can run the script itself (argcomplete
semantics — scripts that must not run on TAB do not opt in or keep
their parser behind a subcommand).
- **6.10** Bash script interface. Every `*.sh` script registered in
`SCRIPTS` implements the shared interface through
`bash/daedalus_common.sh`:
- **6.10.1** Near the top, the script sources the sibling helper
exactly once:
```bash
# shellcheck source=/dev/null
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/daedalus_common.sh"
```
- **6.10.2** The script defines `help()`, which prints its usage and
option list: the words `daedalus <name> <TAB>` completes (SPEC item
3.13.5.2) route to it.
- **6.10.3** The script defines `main()` with the body; `main "$@"`
receives the script arguments unchanged.
- **6.10.4** The last statement is `daedalus_bash_dispatch "$@"`: the
helper routes `help`, `-h`, and `--help` to `help()` (exit status of
`help`), every other invocation to `main() "$@"` (exit status of
`main`). The help words are reserved for the dispatch in every
bash script.
- **6.10.5** `bash/tests/` enforces the interface for every
registered `.sh` script (source line, `help()`, `main()`, the
dispatch call) and tests the helper behavior directly.
## 7. Quality gates