chore: initial commit of Vorleser kit
This commit is contained in:
commit
cf3f2678e1
62 files changed
+2350
No files matched your search
Executable
+25
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
# Installs developer tools if missing. Safe to re-run.
|
||||
set -euo pipefail
|
||||
|
||||
[[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "arm64" ]] || { echo "Vorleser requires an Apple Silicon Mac." >&2; exit 1; }
|
||||
xcode-select -p >/dev/null 2>&1 || { echo "Install Xcode 16+ and run: xcode-select --install" >&2; exit 1; }
|
||||
|
||||
if ! command -v brew >/dev/null; then
|
||||
echo "Homebrew not found — install from https://brew.sh or install xcodegen/swiftformat/swiftlint manually." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for tool in xcodegen swiftformat swiftlint xcbeautify ripgrep; do
|
||||
bin=$tool; [[ $tool == ripgrep ]] && bin=rg
|
||||
if command -v "$bin" >/dev/null; then echo "✓ $tool"; else echo "→ installing $tool"; brew install "$tool"; fi
|
||||
done
|
||||
|
||||
if command -v ollama >/dev/null; then
|
||||
echo "✓ ollama $(ollama --version 2>/dev/null | awk '{print $NF}')"
|
||||
else
|
||||
echo "! ollama not found — install from https://ollama.com/download (≥ 0.40.9 for speech)"
|
||||
fi
|
||||
|
||||
swift --version | head -1
|
||||
echo "Bootstrap complete. Next: make generate && make verify"
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Records real Ollama responses into test fixtures (T1.1). Requires a running Ollama ≥ 0.40.9.
|
||||
# Usage: scripts/capture-fixtures.sh [base_url]
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
BASE="${1:-http://127.0.0.1:11434}"
|
||||
OUT="Packages/VorleserKit/Tests/VorleserOllamaTests/Fixtures"
|
||||
mkdir -p "$OUT"
|
||||
j() { curl -sS -H 'Content-Type: application/json' "$@"; }
|
||||
|
||||
echo "→ version / tags"
|
||||
j "$BASE/api/version" | tee "$OUT/version.json" | jq -c .
|
||||
j "$BASE/api/tags" > "$OUT/tags.json"
|
||||
|
||||
models=$(jq -r '.models[].name' "$OUT/tags.json" | grep -E '^phonon' || true)
|
||||
[[ -z "$models" ]] && { echo "No phonon models installed. Run: ollama pull phonon" >&2; exit 1; }
|
||||
|
||||
for m in $models; do
|
||||
safe=${m//[:\/]/_}
|
||||
echo "→ show $m"
|
||||
j -X POST "$BASE/api/show" -d "{\"model\":\"$m\"}" \
|
||||
| jq '{capabilities, voices, details, model_info: (.model_info // {} | with_entries(select(.key|test("general\\."))))}' \
|
||||
> "$OUT/show-$safe.json"
|
||||
echo " voices: $(jq -c '.voices' "$OUT/show-$safe.json" | cut -c1-160)"
|
||||
echo "→ speech $m"
|
||||
curl -sS -D "$OUT/speech-$safe-short.headers" -o "$OUT/speech-$safe-short.pcm" \
|
||||
-H 'Content-Type: application/json' "$BASE/v1/audio/speech" \
|
||||
-d "{\"model\":\"$m\",\"input\":\"Ready.\",\"voice\":\"default\",\"response_format\":\"pcm\"}"
|
||||
echo " bytes: $(wc -c < "$OUT/speech-$safe-short.pcm")"
|
||||
done
|
||||
|
||||
first=$(echo "$models" | head -1)
|
||||
echo "→ error cases"
|
||||
status() { curl -sS -o "$2" -w '%{http_code}' -H 'Content-Type: application/json' "$BASE/v1/audio/speech" -d "$1"; }
|
||||
echo " unknown voice: $(status "{\"model\":\"$first\",\"input\":\"x\",\"voice\":\"NoSuchVoice\",\"response_format\":\"pcm\"}" "$OUT/error-unknown-voice.json")"
|
||||
echo " missing model: $(status '{"model":"phonon:does-not-exist","input":"x","voice":"default","response_format":"pcm"}' "$OUT/error-missing-model.json")"
|
||||
echo " unsupported option: $(status "{\"model\":\"$first\",\"input\":\"x\",\"voice\":\"default\",\"speed\":1.5}" "$OUT/error-unsupported-option.json")"
|
||||
echo " unsupported format: $(status "{\"model\":\"$first\",\"input\":\"x\",\"response_format\":\"mp3\"}" "$OUT/error-unsupported-format.json")"
|
||||
|
||||
echo "Done. Review $OUT, then update the VERIFY items in docs/OLLAMA_SPEECH_API.md (status codes printed above)."
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
# Static checks for docs/SECURITY_PRIVACY.md invariants. Extended in T8.5.
|
||||
set -uo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
SRC="Packages/VorleserKit/Sources App"
|
||||
fail=0
|
||||
if ! command -v rg >/dev/null; then echo "warning: ripgrep (rg) not installed — privacy checks skipped (brew install ripgrep)"; exit 0; fi
|
||||
report() { echo "✗ $1"; fail=1; }
|
||||
|
||||
# SP-1: no AX observers on other apps
|
||||
if rg -n 'AXObserverCreate' $SRC >/dev/null 2>&1; then report "SP-1: AXObserverCreate found"; rg -n 'AXObserverCreate' $SRC; fi
|
||||
|
||||
# SP-4: networking only in VorleserOllama
|
||||
hits=$(rg -n 'URLSession|URLRequest\(' $SRC -g '!**/VorleserOllama/**' -g '!**/VorleserTestSupport/**' 2>/dev/null || true)
|
||||
[[ -n "$hits" ]] && { report "SP-4: networking outside VorleserOllama"; echo "$hits"; }
|
||||
|
||||
# SP-2: logger interpolation of text-like values without privacy: .private
|
||||
hits=$(rg -n 'Log(ger)?\.[a-z]+.*\\\((text|selection\.text|segment\.text|input)[^)]*\)' $SRC 2>/dev/null | rg -v 'privacy: *\.private|\.count' || true)
|
||||
[[ -n "$hits" ]] && { report "SP-2: possible text logging without privacy: .private"; echo "$hits"; }
|
||||
|
||||
# AX APIs only in VorleserCapture
|
||||
hits=$(rg -n 'AXUIElement|kAXSelectedText' $SRC -g '!**/VorleserCapture/**' -g '!**/VorleserTestSupport/**' 2>/dev/null || true)
|
||||
[[ -n "$hits" ]] && { report "Boundary: Accessibility APIs outside VorleserCapture"; echo "$hits"; }
|
||||
|
||||
# Ollama contract: never send speed/instructions
|
||||
hits=$(rg -n '"(speed|instructions)"' Packages/VorleserKit/Sources/VorleserOllama 2>/dev/null || true)
|
||||
[[ -n "$hits" ]] && { report "Contract: unsupported speech option in request"; echo "$hits"; }
|
||||
|
||||
# SP-10: no unused permission usage strings
|
||||
if rg -n 'NS(Microphone|Camera|ScreenCapture|AppleEvents)UsageDescription' App/Info.plist >/dev/null 2>&1; then report "SP-10: unexpected usage description in Info.plist"; fi
|
||||
|
||||
# ATS
|
||||
if rg -n 'NSAllowsArbitraryLoads' App/Info.plist >/dev/null 2>&1; then report "SP-5: NSAllowsArbitraryLoads present"; fi
|
||||
|
||||
[[ $fail -eq 0 ]] && echo "✓ privacy checks passed"
|
||||
exit $fail
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# Quick end-to-end check that Ollama speech works on this Mac. Plays one sentence per installed phonon model.
|
||||
set -euo pipefail
|
||||
BASE="${OLLAMA_BASE:-http://127.0.0.1:11434}"
|
||||
ver=$(curl -fsS "$BASE/api/version" | jq -r .version) || { echo "✗ Ollama not reachable at $BASE"; exit 1; }
|
||||
echo "✓ Ollama $ver"
|
||||
models=$(curl -fsS "$BASE/api/tags" | jq -r '.models[].name' | grep -E '^phonon' || true)
|
||||
[[ -z "$models" ]] && { echo "✗ no phonon model — run: ollama pull phonon"; exit 1; }
|
||||
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
|
||||
for m in $models; do
|
||||
case "$m" in
|
||||
*-de*) text="Dies ist ein kurzer Test der deutschen Sprachausgabe." ;;
|
||||
*-fr*) text="Ceci est un court test de synthèse vocale." ;;
|
||||
*-es*) text="Esta es una breve prueba de síntesis de voz." ;;
|
||||
*-pt*) text="Este é um breve teste de síntese de voz." ;;
|
||||
*) text="This is a short test of local speech synthesis." ;;
|
||||
esac
|
||||
start=$(python3 -c 'import time;print(time.time())')
|
||||
curl -fsS "$BASE/v1/audio/speech" -H 'Content-Type: application/json' \
|
||||
-d "$(jq -nc --arg m "$m" --arg t "$text" '{model:$m,input:$t,voice:"default",response_format:"wav"}')" -o "$tmp/out.wav"
|
||||
end=$(python3 -c 'import time;print(time.time())')
|
||||
printf '✓ %-28s %6d bytes %.2fs total\n' "$m" "$(wc -c < "$tmp/out.wav")" "$(python3 -c "print($end-$start)")"
|
||||
afplay "$tmp/out.wav"
|
||||
done
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
# Full verification gate. Must be green before a task is marked done (AGENTS.md).
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
PKG=Packages/VorleserKit
|
||||
|
||||
step() { printf '\n\033[1m▶ %s\033[0m\n' "$*"; }
|
||||
|
||||
step "Format check"
|
||||
if command -v swiftformat >/dev/null; then swiftformat --lint App "$PKG"; else echo "skip: swiftformat not installed"; fi
|
||||
|
||||
step "Lint"
|
||||
if command -v swiftlint >/dev/null; then swiftlint lint --strict --quiet App "$PKG/Sources"; else echo "skip: swiftlint not installed"; fi
|
||||
|
||||
step "Privacy checks"
|
||||
scripts/privacy-check.sh
|
||||
|
||||
step "Package build"
|
||||
swift build --package-path "$PKG"
|
||||
|
||||
step "Package tests"
|
||||
swift test --package-path "$PKG" --skip VorleserLiveTests
|
||||
|
||||
step "App build"
|
||||
if command -v xcodegen >/dev/null; then
|
||||
xcodegen generate --spec project.yml --quiet
|
||||
xcodebuild -project Vorleser.xcodeproj -scheme Vorleser -configuration Debug \
|
||||
-derivedDataPath .build/xcode -destination 'platform=macOS,arch=arm64' -quiet build
|
||||
else
|
||||
echo "skip: xcodegen not installed (make bootstrap)"
|
||||
fi
|
||||
|
||||
printf '\n\033[32m✔ verify passed\033[0m\n'
|
||||
Reference in new issue
Block a user