feat: hint at Notecard error and status code meanings#74
Open
Bucknalla wants to merge 1 commit into
Open
Conversation
Print a human-readable hint whenever a Notecard request returns, or a
successful response contains, a recognized {code}.
Definitions come from notecard.codes.json (blues/notecard-schema),
fetched through the same fetch-and-cache pipeline used for schema
validation rather than embedded. The codes URL is derived from the API
schema's own $ref base, so it is pulled from the exact same release the
API schema points at (version-pinned, no drift) and follows any
NOTE_JSON_SCHEMA_URL override. Nothing is committed to this repo.
Hints are written to stderr so JSON on stdout stays clean, color
auto-disables on non-TTY, and unrecognized tokens are skipped silently.
On by default; suppress with -nohints. If the codes file cannot be
fetched (offline, cold cache) hints are simply unavailable.
Note: the upstream codes file omits common error qualifiers
({io}, {timeout}, {not-supported}, {syntax}, ...); tracked in
blues/notecard-schema#305.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ngtas2Zmb7rFBd6y2hV8Y
f0b64b4 to
bf94db0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When you run a request against a Notecard, the CLI now prints a human-readable hint explaining any recognized
{code}in the output, using the definitions fromnotecard.codes.json.It fires in two places:
-reqwhoseerrcontains{template-incompatible}hub.statusreturning{connected}{cell-registered}Source of definitions — fetched, not embedded
notecard.codes.jsonis fetched through the same fetch-and-cache pipeline used for schema validation (loadOrFetchSchema→/tmp/notecard-schema/), not committed to this repo. The codes URL is derived from the API schema's own$refbase, so:notecard.api.jsonpins its$refs to a tagged version, e.g.refs/tags/v1.3.1) — version-pinned, no drift.NOTE_JSON_SCHEMA_URLoverride.If the codes file can't be fetched (offline with a cold cache), hints are simply unavailable — the same network/cache tradeoff the existing validation code already makes.
Behavior
fatih/color, already a dependency).-nohintsflag (grouped under "Communication & Debug" in-h).Known upstream gap
The upstream codes file covers status codes richly but omits several common error qualifiers note-go defines —
{io},{timeout},{not-supported},{syntax}. Tracked in blues/notecard-schema#305; once merged, hints pick them up automatically with no CLI change.Tests
notecard/codes_test.go— hermetic unit tests forparseCodeDescriptions(incl. malformed input) andexplainCodesWith(multi-token, dedup, undocumented-skip, status-in-response, empty).{io}correctly skipped; stdout stays clean JSON.go build/go vet/go testall pass.🤖 Generated with Claude Code
https://claude.ai/code/session_018ngtas2Zmb7rFBd6y2hV8Y