bin/quak.ts is 436 lines — the single largest file in the repo — and has zero tests. No
test file imports it. The repo's own README says tests are the canonical documentation and
that main is only green when the suite covers what ships, and the README documents a CLI
contract (exit codes, --json output, session file permissions) that nothing verifies.
Untested behaviour includes:
session load and save, including the 0600 file mode and 0700 directory mode;
the "not logged in" exit path;
every command's argument parsing and exit code;
the get / get-thumb search-all-collections loops used when --collection is omitted;
the --exif / --all option handling on backup-metadata;
the non-zero exit code on partial backup failure that the README's Backup layout section
documents.
Definition of done
bin/quak.ts is testable without spawning a subprocess and without calling process.exit
from inside async handlers — refactor the command bodies into functions that return or
throw, with a thin top-level wrapper that maps results to exit codes. The externally
visible CLI behaviour does not change.
Tests cover, at minimum: whoami, logout, collections, files, get, get-thumb, backup, and helper list-missing-thumbnails, each in both human and --json output
modes where the command supports --json.
Tests assert the documented exit codes, including the non-zero exit when a backup has
per-file failures.
Tests assert the session file is created with mode 0600 in a directory with mode 0700,
and that logout removes it.
Tests assert get/get-thumb find a file by ID across collections when --collection is
not supplied, and report a clear error when the ID is not found anywhere.
Tests use mkdtempSync for temporary directories and inject a fake session directory
rather than touching the real one. No test writes to the developer's home directory.
The suite still completes within the 30-second cap enforced by script/test. If it does
not, say so on this issue rather than raising the cap.
make check green.
TODO.md updated in the same commit.
Note
process.exit() is currently called from nine places inside async handlers, which can
truncate pending stdout writes when output is piped. Item 1 fixes that as a side effect; call
it out explicitly in the PR body.
## Problem
`bin/quak.ts` is 436 lines — the single largest file in the repo — and has **zero tests**. No
test file imports it. The repo's own README says tests are the canonical documentation and
that `main` is only green when the suite covers what ships, and the README documents a CLI
contract (exit codes, `--json` output, session file permissions) that nothing verifies.
Untested behaviour includes:
- session load and save, including the `0600` file mode and `0700` directory mode;
- the "not logged in" exit path;
- every command's argument parsing and exit code;
- the `get` / `get-thumb` search-all-collections loops used when `--collection` is omitted;
- the `--exif` / `--all` option handling on `backup-metadata`;
- the non-zero exit code on partial backup failure that the README's Backup layout section
documents.
## Definition of done
1. `bin/quak.ts` is testable without spawning a subprocess and without calling `process.exit`
from inside async handlers — refactor the command bodies into functions that return or
throw, with a thin top-level wrapper that maps results to exit codes. The externally
visible CLI behaviour does not change.
2. Tests cover, at minimum: `whoami`, `logout`, `collections`, `files`, `get`, `get-thumb`,
`backup`, and `helper list-missing-thumbnails`, each in both human and `--json` output
modes where the command supports `--json`.
3. Tests assert the documented exit codes, including the non-zero exit when a backup has
per-file failures.
4. Tests assert the session file is created with mode `0600` in a directory with mode `0700`,
and that `logout` removes it.
5. Tests assert `get`/`get-thumb` find a file by ID across collections when `--collection` is
not supplied, and report a clear error when the ID is not found anywhere.
6. Tests use `mkdtempSync` for temporary directories and inject a fake session directory
rather than touching the real one. No test writes to the developer's home directory.
7. The suite still completes within the 30-second cap enforced by `script/test`. If it does
not, say so on this issue rather than raising the cap.
8. `make check` green.
9. `TODO.md` updated in the same commit.
## Note
`process.exit()` is currently called from nine places inside async handlers, which can
truncate pending stdout writes when output is piped. Item 1 fixes that as a side effect; call
it out explicitly in the PR body.
clawbot
added this to the 1.0.0 milestone 2026-08-09 03:45:27 +02:00
clawbot
self-assigned this 2026-08-09 03:45:27 +02:00
bin/quak.ts is now 502 lines, with 8 process.exit calls. test/cli/ already tests the output helpers and the backup, metadata-backup and read paths (backup.test.ts, metadata-backup.test.ts, output.test.ts, read.test.ts). Build on those; do not duplicate them. Session loading and saving, and the missing-versus-corrupt session report from #10, are now in bin/quak.ts. Keep them as they are and cover them.
Definition of done: as in the issue body, with these points made precise:
Commands become plain functions that take their options, an output stream and a session directory, and return an exit code or throw. One small wrapper maps that result to process.exitCode. Nothing below the wrapper calls process.exit.
Output for every command stays byte-identical. This is the rule written at the top of src/cli-output.ts.
Use a fake API client. Tests make no network calls and never touch the real session directory.
If the suite goes past the 30-second cap, stop and say so on the issue. Do not raise the cap.
Model: opus-5-5
## Implementer brief (branch `next2`)
`bin/quak.ts` is now 502 lines, with 8 `process.exit` calls. `test/cli/` already tests the output helpers and the backup, metadata-backup and read paths (`backup.test.ts`, `metadata-backup.test.ts`, `output.test.ts`, `read.test.ts`). Build on those; do not duplicate them. Session loading and saving, and the missing-versus-corrupt session report from https://git.eeqj.de/sneak/quak/issues/10, are now in `bin/quak.ts`. Keep them as they are and cover them.
Definition of done: as in the issue body, with these points made precise:
- Commands become plain functions that take their options, an output stream and a session directory, and return an exit code or throw. One small wrapper maps that result to `process.exitCode`. Nothing below the wrapper calls `process.exit`.
- Output for every command stays byte-identical. This is the rule written at the top of `src/cli-output.ts`.
- Use a fake API client. Tests make no network calls and never touch the real session directory.
- If the suite goes past the 30-second cap, stop and say so on the issue. Do not raise the cap.
Model: opus-5-5
Implemented in #86. The commands are now plain functions in src/cli-commands.ts, tested in test/cli/commands.test.ts with a fake client. Not covered: login, and the --exif/--all options on backup-metadata.
Model: opus-5-5
Implemented in https://git.eeqj.de/sneak/quak/pulls/86. The commands are now plain functions in `src/cli-commands.ts`, tested in `test/cli/commands.test.ts` with a fake client. Not covered: `login`, and the `--exif`/`--all` options on `backup-metadata`.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Problem
bin/quak.tsis 436 lines — the single largest file in the repo — and has zero tests. Notest file imports it. The repo's own README says tests are the canonical documentation and
that
mainis only green when the suite covers what ships, and the README documents a CLIcontract (exit codes,
--jsonoutput, session file permissions) that nothing verifies.Untested behaviour includes:
0600file mode and0700directory mode;get/get-thumbsearch-all-collections loops used when--collectionis omitted;--exif/--alloption handling onbackup-metadata;documents.
Definition of done
bin/quak.tsis testable without spawning a subprocess and without callingprocess.exitfrom inside async handlers — refactor the command bodies into functions that return or
throw, with a thin top-level wrapper that maps results to exit codes. The externally
visible CLI behaviour does not change.
whoami,logout,collections,files,get,get-thumb,backup, andhelper list-missing-thumbnails, each in both human and--jsonoutputmodes where the command supports
--json.per-file failures.
0600in a directory with mode0700,and that
logoutremoves it.get/get-thumbfind a file by ID across collections when--collectionisnot supplied, and report a clear error when the ID is not found anywhere.
mkdtempSyncfor temporary directories and inject a fake session directoryrather than touching the real one. No test writes to the developer's home directory.
script/test. If it doesnot, say so on this issue rather than raising the cap.
make checkgreen.TODO.mdupdated in the same commit.Note
process.exit()is currently called from nine places inside async handlers, which cantruncate pending stdout writes when output is piped. Item 1 fixes that as a side effect; call
it out explicitly in the PR body.
Implementer brief (branch
next2)bin/quak.tsis now 502 lines, with 8process.exitcalls.test/cli/already tests the output helpers and the backup, metadata-backup and read paths (backup.test.ts,metadata-backup.test.ts,output.test.ts,read.test.ts). Build on those; do not duplicate them. Session loading and saving, and the missing-versus-corrupt session report from #10, are now inbin/quak.ts. Keep them as they are and cover them.Definition of done: as in the issue body, with these points made precise:
process.exitCode. Nothing below the wrapper callsprocess.exit.src/cli-output.ts.Model: opus-5-5
Implemented in #86. The commands are now plain functions in
src/cli-commands.ts, tested intest/cli/commands.test.tswith a fake client. Not covered:login, and the--exif/--alloptions onbackup-metadata.Model: opus-5-5