feat(doctor): add tsk doctor diagnostic command#8
Merged
Conversation
`tsk doctor` runs a one-shot health check against the active .tsk.md and tsk configuration. Designed for pre-commit hooks, CI gates, and fast triage when "something's weird." Checks: - File exists, is readable, parses cleanly - No duplicate task IDs - All IDs non-negative - No empty/whitespace-only titles (warning) - Timestamp sanity: completed >= created, due not 100+ years out (warnings) - Reports active timezone (env override or system default) Output: - Default: human-friendly text summary with ERRORS: / WARNINGS: - --json: machine-readable DoctorReport (stable schema) Exit codes: 0 all checks passed (warnings don't flip exit code) 1 at least one error 2 bad invocation To avoid noisy "error: <msg>" prefix on the legit failure path, this PR introduces a SilentExitCoder interface — errors that carry an exit code AND tell main.go not to add the prefix. doctor uses it for the "issues found" return path, since its own report is the message. Tests: 5 cases — clean store, JSON parse, duplicate IDs, missing file, SilentExitCoder shape. All green with -race + gofmt clean.
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.
tsk doctoris a one-shot health check against the active.tsk.mdand tsk configuration. Designed for pre-commit hooks, CI gates, and fast triage when "something's weird."Example
Checks
.tsk.mdexists and is readableTSK_TZ/TZ/system defaultFlags
--json— machine-readableDoctorReportfor scripts and CIExit Codes
0— all checks passed (warnings don't flip exit code)1— at least one error2— bad invocationNew:
SilentExitCoderTo avoid the noisy
error: <msg>prefix on the legit failure path (doctor already prints its own report), this PR introduces aSilentExitCoderinterface — an error that carries an exit code AND tellsmain.goto skip the default prefix. Doctor uses it for the "issues found" return path.Cobra commands that need this pattern in the future can implement
SilentExitCoderin their command file (the interface is exported,silentExititself is package-private).Tests
5 cases in
doctor_test.go:--jsonemits parseableDoctorReportunique_idserrorfile_presenterrorSilentExitCodershape: empty.Error(), code 1All green with
-race, gofmt-clean.Part 4/10 of the v0.3.0 improvement series.