Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ jobs:
run: ./scripts/check-doc-pointers.sh
- name: The site's numbers match the docs
run: ./scripts/check-site-numbers.sh
- name: CLAUDE.md names scripts and pladder-cli commands that exist
run: ./scripts/check-doc-commands.sh
38 changes: 38 additions & 0 deletions .github/workflows/scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,43 @@ jobs:
run: |
# Commands only: a comment may name what not to do.
if grep -rnE '^[^#]*(pkill -x Pladder|killall Pladder)' scripts; then exit 1; fi
- name: Every script answers --help and does nothing else
# One that builds, launches or records before reading --help fails
# here: on the 5 s timeout, on a missing say or screencapture, or on
# the files it leaves behind.
run: |
for file in scripts/*; do
if [[ -x "$file" && "$file" != *.sh ]]; then
echo "::error file=$file::$file is executable but not a .sh, so no --help check covers it"
exit 1
fi
done
count=0
for script in scripts/*.sh; do
count=$((count + 1))
if [[ ! -x "$script" ]]; then
echo "::error file=$script::$script is not executable"
exit 1
fi
for args in "--help" "-h" "x --help"; do
read -r -a argv <<<"$args"
if ! out=$(timeout 5 "$script" "${argv[@]}" 2>&1); then
echo "::error file=$script::$script $args did not exit 0"
echo "$out"
exit 1
fi
if ! grep -q "^Usage: $script" <<<"$out"; then
echo "::error file=$script::$script $args printed no \"Usage: $script\" line"
echo "$out"
exit 1
fi
done
done
if [[ -n "$(git status --porcelain --ignored)" ]]; then
echo "::error::a --help run left files behind"
git status --porcelain --ignored
exit 1
fi
echo "$count scripts answer --help"
- name: ShellCheck
run: shellcheck scripts/*.sh
46 changes: 45 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ swift run -c release pladder-cli bench bench/fixtures --engine parakeet-tdt-v3-i
swift run -c release pladder-cli bench-coordinator [--polish] [--live] # the coordinator's own share of release-to-paste, stand-ins of fixed latency
swift run -c release pladder-cli polish <text file> [--model apple|s1-mini|s1-mini-8bit] # one transcript, cold and warm
swift run -c release pladder-cli polish-set docs/polish-set.json --model s1-mini-8bit # a polish model over the test set: error rate, exact matches, timings
./scripts/overlay-demo.sh [dir] [--style …] [--speed …] # play every overlay path with stand-ins, record the screen, cut contact sheets
./scripts/overlay-demo.sh [dir] [--style …] [--reduce-motion] # play every overlay path with stand-ins, record the screen, cut contact sheets
./scripts/make-screenshots.sh [dir] [--settings | --settings-scene [--accessibility | --get-started] | --menu] [--managed] # the app's own views as pictures: the README's by default, into docs/images
./scripts/check-site-numbers.sh # the site's figures against docs/BENCHMARKS.md, and no pinned release on it
./scripts/make-site-media.sh <recording> # a screen recording of a dictation as the site's MP4, WebM and poster
```
Expand Down Expand Up @@ -125,3 +126,46 @@ The developer dictates with a running Pladder all day, often into Claude session
- Do not edit `~/Library/Application Support/Pladder/settings.json`; it is the live configuration.
- A copy launched for testing gets its own settings file with `PLADDER_SETTINGS_PATH=/tmp/<branch>/settings.json "$PWD/dist/Pladder.app/Contents/MacOS/Pladder"`, and a different chord from the copy in use, so the two never fire together. Launched as the bare binary so the environment reaches it; its command line still contains `$PWD/dist/Pladder.app`, so the `pkill -f` above stops it.
- To test an update, the copy needs a bundle ID of its own (Sparkle's defaults and the grants are per bundle ID), `LSEnvironment` in its Info.plist for `PLADDER_SETTINGS_PATH` (Sparkle relaunches it through LaunchServices, without your shell's environment), a feed on `http://127.0.0.1` and a throwaway key, signed with `appcast.sh` and `SPARKLE_ED_KEY`; never the real key.

## Verify

Proof is what you saw in this session: a command's output, a picture, a contact sheet. Every `scripts/*.sh` answers `-h` and `--help` with its usage and does nothing else, so ask it first. The rules in "Working on this Mac while Pladder is in use" hold for every line here.

| Change | Run | Where it lands |
|---|---|---|
| Any Swift | `swift build`, with no new warning, and `swift test` | the terminal |
| Core logic: the coordinator, a tracker, the settings | a test that fails without the change | the terminal |
| A processor, the dictionary | `swift run -c release pladder-cli <audio file> --process --verbose` | `RAW:` and `TEXT:` on stdout |
| Between `recordingStopped` and `inserted`, a processor, the engine | the critical-path rule: `pladder-cli bench`, `pladder-cli bench --paced`, `pladder-cli bench-coordinator`, `pladder-cli bench-release` or `pladder-cli bench-process`, before and after | tables on stdout, both in the pull request |
| Polish, a model or its prompt | `pladder-cli polish-set docs/polish-set.json --model …` | error rate, exact matches and timings on stdout |
| The pill, the coordinator's states | `scripts/overlay-demo.sh <dir>`, then with `--style minimal`, `--style liveTranscript` and `--reduce-motion` | `<dir>/sheet-*.png`, `demo.mov`, `demo.log` |
| Settings | `scripts/make-screenshots.sh <dir> --settings-scene`, then `--settings-scene --get-started`, `--settings-scene --accessibility`, and any of them with `--managed`; `--settings` for each tab alone | `<dir>/scene-<tab>-light.png` and `-dark.png`, `accessibility-<tab>.txt`, `settings-<tab>-light.png` and `-dark.png` |
| The menu | `scripts/make-screenshots.sh <dir> --menu` | `<dir>/menu.png`, in the system's appearance |
| The README's pictures | `scripts/make-screenshots.sh` with no `<dir>` | `docs/images/styles-light.png` and `-dark.png`, committed |
| The bundle, signing, the icon, the catalogs in the app | `scripts/bundle.sh`, then your own copy with its own settings file | `dist/Pladder.app` |
| A script | `shellcheck scripts/*.sh`, and its `--help` | the terminal |
| Docs, the site | `scripts/check-doc-pointers.sh`, `scripts/check-doc-commands.sh`, `scripts/check-site-numbers.sh`; `site/index.html` at phone and desktop widths | the terminal |

`<dir>` is yours, `/tmp/<branch>/…`, one per run, and comes first: each run of the same mode replaces the last one's pictures. Without it `make-screenshots.sh` writes into `docs/images`, which is committed, and `overlay-demo.sh` into one directory every worktree shares. `scripts/overlay-demo.sh` and `scripts/make-screenshots.sh` build their own copy with the developer modes in (`-DPLADDER_DEV_MODES`, in `.build/dev-modes`); a plain `swift build` or `scripts/bundle.sh` build, and every release, has no `--overlay-demo` or `--screenshots`. Both put windows or the pill on the screen while they run and need Screen Recording for the terminal that runs them, so look at the pictures before quoting them. `pladder-cli --process` reads the live settings file and never writes it; `PLADDER_SETTINGS_PATH` names another. The fixtures come from `scripts/make-fixtures.sh`, once per worktree, into `bench/fixtures`.

One at a time. Anything that records the screen (`scripts/overlay-demo.sh`, `scripts/make-screenshots.sh`) runs under `/tmp/pladder-screen.lock`: take it with `mkdir /tmp/pladder-screen.lock`, write an owner file inside (the worktree and the time), `rm -r` it when the run ends, and never remove a lock someone else took; wait instead. A benchmark has no lock, but one that ran beside another build or benchmark is not a result; `pladder-cli bench`, `pladder-cli bench-coordinator` and `pladder-cli bench-release` print the load average, and docs/BENCHMARKS.md, "Procedure", says what counts.

The hard states: light and dark; every pill style and Reduce Motion; every path the demo plays, the clipboard hint and the two polish paths among them; the General tab at its tallest; every managed control; what VoiceOver is given; a recording longer than one 15 s window, which `bench --paced` checks byte for byte.

Only a human can check: a real dictation into other apps, since no agent posts a hotkey event; the Accessibility and Microphone prompts and a first grant; German on a Mac set to German; Sparkle against the real key and feed; the notarised DMG and Gatekeeper's first open. Say in the report which of these the change needs.

## Ship

- **Verify:** `## Verify` for the kind of change, and what CI runs: `swift build` with no new warning, `swift test`, `shellcheck scripts/*.sh`, every script's `--help`, the three `check-*.sh`. A change on the release-to-paste path carries its benchmark, before and after. The pull request follows `.github/pull_request_template.md` and says what was not checked and who has to check it.
- **Merge:** Rebase only, so every commit lands as it is: the subject an area, a colon and a sentence, the body the reason, `Closes #<issue>.` at the end of the last one, fixups squashed. `build-and-test`, `scripts` and `doc-pointers` green on the last commit and every review thread resolved, then `gh pr merge --rebase --match-head-commit <sha>`. GitHub keeps the branch; delete it.
- **After merge:** Pull `main` in the root checkout. A change the build reads (`Sources`, `Package.swift`, `Package.resolved`, `Assets`, `scripts/bundle.sh`, `scripts/Pladder.entitlements`) is installed from there, on the Mac, with `./scripts/bundle.sh --install --run`. That stops `/Applications/Pladder.app`, the copy in use, and drops a recording in progress, so an agent runs it without asking only while the developer is not dictating: build first with a plain `./scripts/bundle.sh`, run the check below, and start the install as soon as it prints `idle`, so the install's own build has nothing left to do. When it prints nothing, ask first. A change under `site/` is published by `pages.yml`; wait for its run on the merge commit. Anything else needs nothing. A release is never part of shipping a change: `release.yml` is dispatched by hand.

```sh
p='subsystem == "de.dinooo13.pladder" AND category == "capture" AND processImagePath == "/Applications/Pladder.app/Contents/MacOS/Pladder"'
/usr/bin/log show --last 20s --style compact --predicate "$p" | awk '/^Timestamp/{ok=1} /capture /{n++} END{exit !ok || n>0}' &&
/usr/bin/log show --last 61m --style compact --predicate "$p" | awk '/^Timestamp/{ok=1} /capture started/{s=1} /capture stop called/{s=0} END{exit !ok || s}' &&
echo idle
```

The installed copy logs `capture started` when the microphone opens and `capture stop called` on every release, cancel, cap and quit, and `log show` sees each within a second. `idle` means the last start in the past 61 minutes (the latched cap, and a minute) was followed by a stop, and nothing started or stopped in the past 20 s, long enough for a polish and the clipboard's return. A `log show` that fails prints no `Timestamp` header, so it never reads as `idle`.
- **Live check:** After an install, `/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Applications/Pladder.app/Contents/Info.plist` prints what `git rev-list --count HEAD` prints on `main`, and `pgrep -f /Applications/Pladder.app/Contents/MacOS/Pladder` finds the copy. The first real dictation is the developer's; its release-to-paste line shows with the `log show` command under "Critical-path rule". For the site, load https://dinooo13.github.io/pladder/ and look at what changed. For anything else, the checks on the merge commit: `gh run list --commit <sha>`.
2 changes: 2 additions & 0 deletions Sources/PladderAudio/AVAudioEngineCapture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public actor AVAudioEngineCapture: AudioCapture {
}

private static func startMarker() {
// CLAUDE.md, "Ship", matches this text to tell whether the user is dictating.
log.log("capture started")
}

Expand All @@ -79,6 +80,7 @@ public actor AVAudioEngineCapture: AudioCapture {
}

public func stop() async -> CapturedAudio {
// CLAUDE.md, "Ship", matches this text to tell whether the user is dictating.
Self.log.log("capture stop called, isRecording=\(self.isRecording)")
guard isRecording else { return CapturedAudio(samples: []) }
isRecording = false
Expand Down
16 changes: 12 additions & 4 deletions Sources/PladderCLI/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import PladderEngines
// Developer tool. Commands and flags: docs/ARCHITECTURE.md, "pladder-cli". Each
// command lives in a file of its own; shared helpers are in Support.swift.

func usage() -> Never {
eprint("""
func usageText() -> String {
"""
usage: pladder-cli <audio file> [--process] [--verbose] [--engine <id>]
pladder-cli bench <fixtures dir> [--runs N] [--pause S] [--engine <id>]
pladder-cli bench <fixtures dir> --paced [--runs N] [--pause S] [--all] [--live] [--engine <id>]
Expand All @@ -16,13 +16,21 @@ func usage() -> Never {
pladder-cli polish <text file | -> [--model \(PolishModel.cliNames) | --gguf <file>] [--control <line>] [--instructions <file>]
pladder-cli polish-set <set.json> [--model \(PolishModel.cliNames) | --gguf <file>] [--control <line>]
engines: \(StandardEngines.entries.map(\.id.rawValue).joined(separator: ", ")); the first is the default
""")
"""
}

func usage() -> Never {
eprint(usageText())
exit(2)
}

// MARK: - Entry

var arguments = Array(CommandLine.arguments.dropFirst())
if arguments.contains(where: { $0 == "-h" || $0 == "--help" }) {
print(usageText())
exit(0)
}
if let flag = arguments.firstIndex(of: "--engine") {
guard flag + 1 < arguments.count,
let entry = StandardEngines.entries.first(where: { $0.id.rawValue == arguments[flag + 1] })
Expand All @@ -31,7 +39,7 @@ if let flag = arguments.firstIndex(of: "--engine") {
arguments.removeSubrange(flag...(flag + 1))
}
switch arguments.first {
case nil, "-h", "--help":
case nil:
usage()
case "bench":
arguments.removeFirst()
Expand Down
3 changes: 3 additions & 0 deletions scripts/appcast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
# DMG_URL default: the DMG of the tag v<version>; a local test
# feed points it elsewhere
set -euo pipefail
for arg in "$@"; do
case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac
done

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

Expand Down
3 changes: 3 additions & 0 deletions scripts/bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# BUILD_NUMBER CFBundleVersion of the bundled Info.plist; default: the
# commit count
set -euo pipefail
for arg in "$@"; do
case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac
done

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
Expand Down
6 changes: 5 additions & 1 deletion scripts/cask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
# Pladder.dmg. Without a SHA-256 it reads the release's Pladder.dmg.sha256.
# See INSTALL.md, "Homebrew".
#
# ./scripts/cask.sh 0.1.2 > ../homebrew-tap/Casks/pladder.rb
# Usage: scripts/cask.sh <version> [<sha256>]
# scripts/cask.sh 0.1.2 > ../homebrew-tap/Casks/pladder.rb

set -euo pipefail
for arg in "$@"; do
case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac
done
cd "$(dirname "$0")/.."

version=${1:?usage: cask.sh <version> [<sha256>]}
Expand Down
3 changes: 3 additions & 0 deletions scripts/changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#
# Plain bash 3.2 and POSIX awk, so it runs the same on macOS and ubuntu.
set -euo pipefail
for arg in "$@"; do
case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac
done

ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT"
Expand Down
101 changes: 101 additions & 0 deletions scripts/check-doc-commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/bin/bash
# Fails when a document names a script or a pladder-cli command that does not
# exist. A script is `scripts/<name>.<ext>`, also as `./scripts/…`, or a bare
# `<name>.sh`, anywhere in the text, and must be in scripts/. A command is the
# word after `pladder-cli ` in backticks or a code fence, when it is lowercase
# letters and hyphens (not a path, placeholder or flag), and must be a
# top-level `case "…":` label in Sources/PladderCLI/main.swift. Those labels
# must be the commands the CLI's usage text lists, so neither can change alone.
#
# Usage: scripts/check-doc-commands.sh [file …] default: CLAUDE.md
#
# Plain bash 3.2 and POSIX awk, so it runs the same on macOS and ubuntu.

set -eo pipefail
for arg in "$@"; do
case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac
done

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
MAIN="$ROOT/Sources/PladderCLI/main.swift"
if [[ $# -eq 0 ]]; then cd "$ROOT" && set -- CLAUDE.md; fi

labels=$(awk '/^case "/ {
line = $0
while (match(line, /"[^"]*"/)) {
print substr(line, RSTART + 1, RLENGTH - 2)
line = substr(line, RSTART + RLENGTH)
}
}' "$MAIN" | sort -u)
listed=$(awk '!/^[ \t]*\/\// {
line = $0
while (match(line, /pladder-cli [a-z][a-z-]*/)) {
print substr(line, RSTART + 12, RLENGTH - 12)
line = substr(line, RSTART + RLENGTH)
}
}' "$MAIN" | sort -u)
if [[ -z "$labels" || "$labels" != "$listed" ]]; then
echo "$MAIN: the case labels ($(paste -s -d " " - <<<"$labels")) are not the commands the usage text lists ($(paste -s -d " " - <<<"$listed"))" >&2
exit 1
fi

failed=0
scripts=0
commands=0
for doc in "$@"; do
found=$(awk '
function scripts_in(text, rest, before, name) {
rest = text
while (match(rest, /scripts\/[A-Za-z0-9_-]+\.[A-Za-z0-9]+/)) {
before = substr(rest, 1, RSTART - 1)
name = substr(rest, RSTART, RLENGTH)
rest = substr(rest, RSTART + RLENGTH)
sub(/\.\/$/, "", before)
if (before !~ /[A-Za-z0-9_.\/-]$/) print NR "\tscript\t" name
}
rest = text
while (match(rest, /[A-Za-z0-9_-]+\.sh/)) {
before = substr(rest, 1, RSTART - 1)
name = substr(rest, RSTART, RLENGTH)
rest = substr(rest, RSTART + RLENGTH)
if (before !~ /[A-Za-z0-9_.\/-]$/ && rest !~ /^[A-Za-z0-9_]/) print NR "\tscript\tscripts/" name
}
}
function commands_in(code, rest, word) {
rest = code
while (match(rest, /pladder-cli +[^ \t`]+/)) {
word = substr(rest, RSTART, RLENGTH)
rest = substr(rest, RSTART + RLENGTH)
sub(/^pladder-cli +/, "", word)
if (word ~ /^[a-z][a-z-]*$/) print NR "\tcommand\t" word
}
}
{ sub(/\r$/, "") }
/^[ \t]*(```|~~~)/ { fenced = !fenced; next }
{ scripts_in($0) }
fenced { commands_in($0); next }
{
n = split($0, part, "`")
for (i = 2; i <= n; i += 2) commands_in(part[i])
}
' "$doc")
while IFS="$(printf '\t')" read -r line kind name; do
[[ -n "$kind" ]] || continue
if [[ "$kind" == script ]]; then
scripts=$((scripts + 1))
if [[ ! -e "$ROOT/$name" ]]; then
echo "$doc:$line: $name does not exist" >&2
failed=1
fi
else
commands=$((commands + 1))
if ! grep -qxF -- "$name" <<<"$labels"; then
echo "$doc:$line: pladder-cli $name is not a command; there are $(paste -s -d " " - <<<"$labels")" >&2
failed=1
fi
fi
done <<<"$found"
done

if [[ "$failed" -ne 0 ]]; then exit 1; fi
echo "$scripts script names and $commands pladder-cli commands, all of them there"
5 changes: 5 additions & 0 deletions scripts/check-doc-pointers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
# outside code fences, with backticks removed. A bare `docs/X.md` is fine as
# long as the file exists.
#
# Usage: scripts/check-doc-pointers.sh
#
# Plain bash 3.2 and POSIX awk, so it runs the same on macOS and ubuntu.

set -eo pipefail
for arg in "$@"; do
case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac
done
cd "$(dirname "$0")/.."

headings=$(mktemp)
Expand Down
5 changes: 5 additions & 0 deletions scripts/check-site-numbers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
# It also fails when a page names a release, a version or a SHA-256: the
# download is always the latest release, so a pinned one would go stale.
#
# Usage: scripts/check-site-numbers.sh
#
# Plain bash 3.2 and POSIX awk, so it runs the same on macOS and ubuntu.

set -eo pipefail
for arg in "$@"; do
case "$arg" in -h | --help) sed -n '2,${/^#/!q;s/^# \{0,1\}//;p;}' "$0"; exit 0 ;; esac
done
cd "$(dirname "$0")/.."

sections=$(mktemp)
Expand Down
Loading
Loading