docs: update AGENTS.md and README for new features, add JS tests
Docs: - AGENTS.md: updated toolchain section with js-lint/js-test tasks, expanded web/ui/ directory listing, added event delegation and Web Audio API to key patterns, updated testing section - README: marked issue #9 (Audio Preview Player) as done - .gitignore: added akai-fetch.test and cover.out Tests: - Moved groupWavs and cleanName to util.js (pure functions) - Added 10 new JS tests: 6 groupWavs, 4 cleanName - Total JS tests: 29 (up from 19)
This commit is contained in:
@@ -16,7 +16,9 @@ mise run serve # → starts HTTP server, opens browser
|
||||
mise run electron-deps # installs electron + electron-builder
|
||||
mise run electron-dev # runs electron in dev mode
|
||||
mise run docker-up # docker compose up --build
|
||||
mise run lint # go vet ./...
|
||||
mise run lint # golangci-lint run (Go)
|
||||
mise run js-lint # eslint (JS)
|
||||
mise run js-test # node --test (JS)
|
||||
mise run check-all # verify gcc, brew, mise, go, node, docker, colima
|
||||
```
|
||||
|
||||
@@ -55,7 +57,14 @@ Single binary (`fetch`) with subcommands. No external Go dependencies — pure s
|
||||
```
|
||||
main.go CLI entry, commands (search/list/download/extract/pipeline/serve)
|
||||
serve.go HTTP server + REST API + embedded web UI (embed.FS)
|
||||
web/ui/ Static frontend (index.html, style.css, app.js)
|
||||
web/ui/ Static frontend
|
||||
├── index.html HTML layout
|
||||
├── style.css CSS custom properties theme
|
||||
├── util.js shared utility functions
|
||||
├── app.js application logic, event delegation
|
||||
├── util.test.js JS tests (node --test)
|
||||
├── eslint.config.js ESLint flat config
|
||||
└── package.json ESLint + test scripts
|
||||
electron/ Electron wrapper shell
|
||||
scripts/ Bash helpers called via exec
|
||||
├── extract_wavs.sh batch WAV extraction via akaiutil
|
||||
@@ -70,8 +79,9 @@ third_party/ Vendored akaiutil C binary (GPLv2)
|
||||
- **Flag parsing**: each command creates its own `flag.NewFlagSet` — avoids global flag state
|
||||
- **Concurrency**: semaphore channel pattern (`sem := make(chan struct{}, N)`) for bounded parallelism
|
||||
- **SSE progress**: `serve.go:handleProgress` — 500ms ticker, EventSource stream, auto-closes when all done
|
||||
- **Event delegation**: `app.js` — single click listener on document, dispatches by `[data-action]` attribute (download, list, play)
|
||||
- **akaiutil wrapper**: `extract.go` — persistent stdin/stdout pipes, no bash intermediary
|
||||
- **Zero-deps web UI**: vanilla JS, no bundler, no framework. API calls use `fetch()` + `EventSource`
|
||||
- **Zero-deps web UI**: vanilla JS, no bundler, no framework. API calls use `fetch()` + `EventSource`. Web Audio API for WAV playback.
|
||||
- **Embed directive**: `//go:embed web/ui/*` in `serve.go` — frontend baked into the binary
|
||||
- **Bind address handling**: `serve.go:37` — `--host` flag defaults to `127.0.0.1` for local dev; set `--host 0.0.0.0` for Docker. When binding to `0.0.0.0`, prints both `localhost` and `<host-ip>` URLs for clarity.
|
||||
|
||||
@@ -124,12 +134,15 @@ All akaiutil calls use `-r` (read-only) flag. Write operations (S900 compress, p
|
||||
|
||||
## Testing
|
||||
|
||||
No test framework yet. Manual verification:
|
||||
```bash
|
||||
go build -o /dev/null . # compile check
|
||||
# Go
|
||||
go test -cover # unit tests (extract, serve, http, download, cli, util)
|
||||
go vet ./... # static analysis
|
||||
golangci-lint run # comprehensive lint
|
||||
./akai-fetch serve # manual smoke test
|
||||
golangci-lint run # comprehensive lint (uses .golangci.yml)
|
||||
|
||||
# JavaScript
|
||||
mise run js-test # node --test (19 tests: esc, sanitize, formatBytes, formatTime)
|
||||
mise run js-lint # eslint (flat config)
|
||||
```
|
||||
|
||||
## Secrets & Tokens
|
||||
|
||||
Reference in New Issue
Block a user