feat: unify CLI error surface with cause-unwrapping helper
Add a shared error formatter that unwraps cause chains for both text and
JSON output, route the CLI command catches through it, tighten the login
failure path with a SIGINT cancel helper and common-issues footer, make
network errors name the exact URL they failed against, replace the
approved hidden catches with warnings, and document login troubleshooting
in the getting-started guide.
Files touched:
- helpers: src/lib/error-format.js, src/lib/json-output.js
- commands: src/cmd/adopt.js, src/cmd/beacon.js, src/cmd/config.js,
src/cmd/doctor.js, src/cmd/explore.js, src/cmd/firehose.js,
src/cmd/follow.js, src/cmd/hack.js, src/cmd/inbox.js,
src/cmd/init.js, src/cmd/learn.js, src/cmd/link.js,
src/cmd/login.js, src/cmd/remix.js, src/cmd/scan.js,
src/cmd/ship.js, src/cmd/skim.js, src/cmd/vet.js,
src/cmd/vouch.js
- libs: src/lib/config.js, src/lib/oauth.js, src/lib/pds.js,
src/lib/vit-dir.js
- docs/tests: docs/start/index.html, test/error-format.test.js,
test/explore.test.js, test/json-output.test.js,
test/login.test.js, test/pds.test.js
Silent-catch ledger:
- src/lib/config.js: warn on unreadable vit.json; warn on unreadable
local .vit/login.json.
- src/lib/vit-dir.js: warn on unreadable .vit/config.json; warn on
malformed JSONL lines; warn on unreadable JSONL logs; warn on
unreadable following.json.
- src/lib/oauth.js: warn on unreadable session.json in the session
store, checkSession, and restoreAgent paths; warn on unreadable local
app-password sessions in checkSession and restoreAgent.
- src/lib/pds.js: warn when DID-document handle resolution fails, then
fall back to the DID.
- src/cmd/doctor.js: warn on unreadable SKILL.md files, unreadable
skill directories, install-path inspect failure, unreadable
local/global session files, and unexpected Bluesky session validation
failures.
- src/cmd/beacon.js: warn on invalid target .vit/config.json content.
- src/cmd/hack.js: warn when git remote add upstream fails.
- src/cmd/learn.js: warn when temp-dir cleanup fails.
- src/cmd/login.js: keep the .gitignore probe silent; warn on
unreadable local/global session files during login probes.
- src/cmd/firehose.js: warn and skip malformed JSON messages.
- src/cmd/scan.js: warn and skip malformed Jetstream events.
- src/cmd/init.js: keep the git work-tree probe and optional remote URL
probe chain silent; warn on git remote failure and unreadable remote
URLs.
- src/lib/compat.js: keep the executable lookup probe silent.
Test changes:
- added test/error-format.test.js for flat errors, nested causes,
non-Error throwables, non-Error causes, circular causes, the 10-level
cap, and verbose stack indentation
- added login coverage for cancelLogin() and printLoginFailure()
- added json-output throwable-input coverage for nested and flat errors
- updated explore and pds expectations for URL-specific error messages
Not done / founder steps:
- make ship BUMP=patch (-> 0.4.3): founder's step.
- make deploy-site: founder's step. Required because
docs/start/index.html changed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>