refactor: align project with Go API CLI Playbook SOP#12
Merged
Conversation
…ind --today - Set SilenceUsage and SilenceErrors on root command so errors no longer print the full --help output - Add "Error: " prefix in main.go to preserve standard error formatting - Support today/yesterday/tomorrow in parseDateFlexible, benefiting --daily, --date, and --to-daily-page flags across all commands - Add --today flag to block find as shorthand for --daily today - Unify date flag help text format across journal, save, and block find
- Rename module path from roam-cli to github.com/Leechael/roamresearch-skills - Rename internal/cli -> internal/cmd, internal/roam -> internal/client - Add ExitCode(err) int with 0/1/2/3 mapping (auth, not-found) - Update main.go to use NewRootCmd + ExitCode pattern - Add embedded help system: docs/help/topics/ with HELP TOPICS block - Add help topic routing (file-based topics + example categories) - Update all import paths and package declarations
Move APIError, SearchResult, PageSearchResult, EstimateResult from internal/client into a dedicated model package to match SOP layout.
Implements Formatter struct with Print, PrintJSON, Hint (stderr), and PrintMessage methods. Includes validation and unit tests for all modes.
- Golden snapshot tests for root --help and help exit-codes output - Client unit tests with httptest for Q, Write, BatchActions, error codes - Add exit-codes.md and datalog.md embedded help topics
The remote repository was renamed from roamresearch-skills to roam-cli. Update go.mod module path and all import paths to match.
There was a problem hiding this comment.
1 issue found across 37 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="internal/output/output.go">
<violation number="1" location="internal/output/output.go:55">
P2: Print always falls back to JSON even in plain/default modes. This contradicts the documented behavior and will emit JSON when callers expect to write their own human-readable/plain output.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Print was falling through to printJSON even when neither --json nor --jq was set, producing unexpected JSON output in plain/human-readable modes. Return nil instead so callers handle their own output.
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.
Summary
internal/cli->internal/cmd,internal/roam->internal/clientinternal/modelfor shared types (APIError,SearchResult,PageSearchResult,EstimateResult)internal/outputwithFormatterstruct (JSON/plain/jq modes,Hintto stderr)ExitCode(err) intwith stable exit codes: 0 (OK), 1 (error), 2 (auth 401/403), 3 (not found 404)docs/help/topics/withHELP TOPICSblock in root--help, file-based topic routingexit-codesanddatalog(Clojure dialect reference with regex, string ops, schema attributes)go.modmodule path togithub.com/Leechael/roam-clicitarget to output binary tobin/instead of repo roothttptest-based unit tests for client package (Q, Write, BatchActions, error mapping)Test plan
make cipasses (fmt, vet, unit tests, BDD tests, build)roam-cli --helpshows HELP TOPICS block withdatalogandexit-codesroam-cli help exit-codesprints topic contentroam-cli help datalogprints Datalog query referenceroam-cli help unknown-xyzexits non-zero and lists available topics-updateflagSummary by cubic
Aligned the CLI with the SOP layout, added stable exit codes, and introduced an embedded help system with topic files. Also fixed output formatting so plain/default modes no longer print unexpected JSON.
Refactors
internal/cli->internal/cmd,internal/roam->internal/client; extracted shared types intointernal/model.internal/outputfor consistent JSON/plain/jq formatting.cmd.NewRootCmd()andcmd.ExitCode(); silenced Cobra usage/errors for cleaner stderr.github.com/Leechael/roam-cli; fixed imports;make cinow builds tobin/.New Features
help <topic>reads fromdocs/help/topics/(addeddatalogandexit-codes).block find --today.httptestclient coverage, output formatter tests, and golden snapshots for root/help topics.internal/outputPrint is a no-op in plain/default modes to avoid unexpected JSON output.Written for commit efdf628. Summary will update on new commits.