Skip to content

Enhance CLI functionality with JSON output and improved help commands#2

Merged
Snider merged 121 commits intomainfrom
dev
Apr 3, 2026
Merged

Enhance CLI functionality with JSON output and improved help commands#2
Snider merged 121 commits intomainfrom
dev

Conversation

@Snider
Copy link
Copy Markdown
Contributor

@Snider Snider commented Apr 3, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Added JSON output format (--format json) for package list, update, and outdated commands
    • Added shorthand package installation syntax (defaults to host-uk org)
    • Added daemon helper for managing background processes with health checks
    • Added Go toolchain verification to system diagnostics
  • Improvements

    • Enhanced CLI output formatting and theme support (ASCII, Unicode, Emoji modes)
    • Improved help system with search results and topic rendering
    • Better output routing and I/O abstraction for testing
  • Documentation

    • Updated package command docs with new format flag examples
    • Added daemon usage and CLI utility documentation

Virgil added 30 commits March 30, 2026 06:15
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Virgil and others added 26 commits April 2, 2026 12:41
…go/cli/RFC.md fully. Find features des...' (#86) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#87) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#88) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#89) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#90) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-authored-by: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#91) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#92) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#93) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#94) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
…go/cli/RFC.md fully. Find features des...' (#95) from agent/read---spec-code-core-go-cli-rfc-md-full into dev
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
Co-Authored-By: Virgil <virgil@lethean.io>
- Remove banned imports (fmt, log, errors, os, strings, path/filepath,
  encoding/json) from all cmd/ packages; replace with core.* primitives
  and cli.* wrappers
- Rename abbreviated variables (cfg→configuration, reg→registry,
  cmd→proc, c→toolCheck/checkBuilder, sb→builder, out→output,
  r→repo/reason, b→branchName) across config, doctor, pkgcmd, help
- Add usage-example comments to all exported functions in pkg/cli
  (strings.go, log.go, i18n.go)
- Add complete Good/Bad/Ugly test triads to all pkg/cli test files:
  new files for command, errors, frame_components, i18n, log, render,
  runtime, strings, utils; updated existing check, daemon, glyph,
  layout, output, ansi, commands, frame, prompt, stream, styles,
  tracker, tree

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Virgil <virgil@lethean.io>
@Snider
Copy link
Copy Markdown
Contributor Author

Snider commented Apr 3, 2026

@CodeRabbit review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Snider Snider merged commit 498e942 into main Apr 3, 2026
1 check passed
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 3, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 82370dd0-f970-4196-aad1-ab6668a5e610

📥 Commits

Reviewing files that changed from the base of the PR and between e177418 and 20a2e77.

⛔ Files ignored due to path filters (2)
  • cmd/core/go.sum is excluded by !**/*.sum
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (82)
  • cmd/core/config/cmd.go
  • cmd/core/config/cmd_get.go
  • cmd/core/config/cmd_list.go
  • cmd/core/config/cmd_path.go
  • cmd/core/config/cmd_set.go
  • cmd/core/doctor/cmd_checks.go
  • cmd/core/doctor/cmd_checks_test.go
  • cmd/core/doctor/cmd_commands.go
  • cmd/core/doctor/cmd_doctor.go
  • cmd/core/doctor/cmd_environment.go
  • cmd/core/doctor/cmd_install.go
  • cmd/core/help/cmd.go
  • cmd/core/help/cmd_test.go
  • cmd/core/pkgcmd/cmd_install.go
  • cmd/core/pkgcmd/cmd_install_test.go
  • cmd/core/pkgcmd/cmd_manage.go
  • cmd/core/pkgcmd/cmd_manage_test.go
  • cmd/core/pkgcmd/cmd_pkg.go
  • cmd/core/pkgcmd/cmd_remove.go
  • cmd/core/pkgcmd/cmd_remove_test.go
  • cmd/core/pkgcmd/cmd_search.go
  • cmd/core/pkgcmd/cmd_search_test.go
  • docs/cmd/pkg/example.md
  • docs/cmd/pkg/index.md
  • docs/cmd/pkg/search/index.md
  • docs/pkg/cli/commands.md
  • docs/pkg/cli/daemon.md
  • docs/pkg/cli/index.md
  • docs/pkg/cli/output.md
  • docs/pkg/cli/prompts.md
  • docs/pkg/cli/streaming.md
  • go.mod
  • pkg/cli/ansi.go
  • pkg/cli/ansi_test.go
  • pkg/cli/app.go
  • pkg/cli/check.go
  • pkg/cli/check_test.go
  • pkg/cli/command.go
  • pkg/cli/command_test.go
  • pkg/cli/commands.go
  • pkg/cli/commands_test.go
  • pkg/cli/daemon.go
  • pkg/cli/daemon_process.go
  • pkg/cli/daemon_process_test.go
  • pkg/cli/daemon_test.go
  • pkg/cli/errors.go
  • pkg/cli/errors_test.go
  • pkg/cli/frame.go
  • pkg/cli/frame_components.go
  • pkg/cli/frame_components_test.go
  • pkg/cli/frame_test.go
  • pkg/cli/glyph.go
  • pkg/cli/glyph_test.go
  • pkg/cli/i18n.go
  • pkg/cli/i18n_test.go
  • pkg/cli/io.go
  • pkg/cli/layout.go
  • pkg/cli/layout_test.go
  • pkg/cli/locales/en.json
  • pkg/cli/log.go
  • pkg/cli/log_test.go
  • pkg/cli/output.go
  • pkg/cli/output_test.go
  • pkg/cli/prompt.go
  • pkg/cli/prompt_test.go
  • pkg/cli/render.go
  • pkg/cli/render_test.go
  • pkg/cli/runtime.go
  • pkg/cli/runtime_run_test.go
  • pkg/cli/runtime_test.go
  • pkg/cli/stream.go
  • pkg/cli/stream_test.go
  • pkg/cli/strings.go
  • pkg/cli/strings_test.go
  • pkg/cli/styles.go
  • pkg/cli/styles_test.go
  • pkg/cli/tracker.go
  • pkg/cli/tracker_test.go
  • pkg/cli/tree.go
  • pkg/cli/tree_test.go
  • pkg/cli/utils.go
  • pkg/cli/utils_test.go

📝 Walkthrough

Walkthrough

This PR refactors the CLI infrastructure extensively by replacing direct standard library I/O with CLI abstractions, introducing I/O indirection for testing, implementing daemon process management capabilities, enhancing glyph and ANSI rendering, adding new flag helper functions, reorganizing command implementations with consistent variable naming, and introducing comprehensive test coverage across affected modules.

Changes

Cohort / File(s) Summary
Config Commands Refactoring
cmd/core/config/cmd.go, cmd/core/config/cmd_*.go
Renamed local variable cfg to configuration for consistency across all config subcommands (get, list, path, set) and replaced fmt output calls with cli.Println wrappers. Updated loadConfig to use consistent naming.
Doctor Command Enhancement
cmd/core/doctor/cmd_*.go
Added required Go toolchain check, replaced strings utilities with dappco.re/go/core helpers (core.Trim, core.Split), switched all output from fmt to cli wrappers, renamed iteration variables (ctoolCheck), and refactored error handling from errors.New to cli.Err.
Doctor Command Tests
cmd/core/doctor/cmd_checks_test.go
Added new test file validating Go toolchain check is included in required checks.
Package Management Commands
cmd/core/pkgcmd/cmd_install.go, cmd/core/pkgcmd/cmd_manage.go, cmd/core/pkgcmd/cmd_remove.go, cmd/core/pkgcmd/cmd_search.go
Replaced strings and filepath utilities with dappco.re/go/core equivalents, updated function signatures (e.g., targetDirtargetDirectory), switched output from fmt to cli wrappers, refactored error handling to use cli.Err and cli.Wrap, and added glyph compilation for output strings.
Package Management Tests
cmd/core/pkgcmd/cmd_install_test.go, cmd/core/pkgcmd/cmd_manage_test.go, cmd/core/pkgcmd/cmd_remove_test.go, cmd/core/pkgcmd/cmd_search_test.go
Added comprehensive test suites covering repo parsing, installation, update/outdated reporting, removal safety checks, search filtering, and output formatting with JSON/table format validation.
Package Command Support
cmd/core/pkgcmd/cmd_pkg.go
Added gitCloneRef alias for internal reference and Git clone-with-ref support.
Help Command Refactoring
cmd/core/help/cmd.go
Replaced fmt output with cli wrappers, applied glyph compilation to rendered content, renamed variables for clarity (resresult, ttopic), and introduced styled title rendering via cli.TitleStyle.
Help Command Tests
cmd/core/help/cmd_test.go
Added extensive test suite covering help topics listing, search results, rendering, error handling, and navigation links.
Documentation Updates
docs/cmd/pkg/*, docs/cmd/help/*, docs/pkg/cli/*
Added documentation for new --format flag in package commands (table/json output), daemon helper, security logging, filter-based selection, and streaming capture API updates.
CLI I/O Abstraction
pkg/cli/io.go
Introduced new I/O indirection layer with SetStdin, SetStdout, SetStderr functions and internal helpers stdinReader(), stdoutWriter(), stderrWriter() for testing and writer override support.
CLI Output Refactoring
pkg/cli/output.go, pkg/cli/prompt.go, pkg/cli/utils.go, pkg/cli/errors.go, pkg/cli/stream.go
Unified output routing to use stdoutWriter() and stderrWriter() instead of direct os.Stdout/os.Stderr, applied compileGlyphs to all user-visible strings, refactored prompt/input handling with reader abstraction, and improved error formatting.
Glyph and ANSI Handling
pkg/cli/ansi.go, pkg/cli/glyph.go, pkg/cli/check.go, pkg/cli/frame_components.go, pkg/cli/layout.go, pkg/cli/styles.go, pkg/cli/tree.go, pkg/cli/tracker.go
Added glyph compilation throughout rendering pipeline via compileGlyphs, implemented ASCII mode theme support with separate border/spinner glyphs, added color-restoration logic after ASCII mode changes, improved terminal width calculations using runewidth, and replaced hardcoded box-drawing characters with glyph abstractions.
Daemon Process Management
pkg/cli/daemon_process.go
Introduced DaemonOptions, Daemon type, and StopPIDFile function for PID file management and HTTP health/readiness probes with graceful shutdown and signal escalation.
CLI Command Helpers
pkg/cli/command.go
Added new flag registration helpers for persistent and non-persistent flags: StringArrayFlag, StringToStringFlag, PersistentIntFlag, PersistentInt64Flag, PersistentFloat64Flag, PersistentDurationFlag, PersistentStringSliceFlag, PersistentStringArrayFlag, PersistentStringToStringFlag.
CLI Runtime and Initialization
pkg/cli/runtime.go, pkg/cli/app.go, pkg/cli/commands.go
Added Run(ctx) and RunWithTimeout(timeout) for context-aware CLI execution, updated locale source loading, reorganized command registration with snapshot-based synchronization, and expanded documentation with usage examples.
CLI String and Style Utilities
pkg/cli/strings.go, pkg/cli/render.go, pkg/cli/frame.go
Updated style rendering to handle nil styles with glyph compilation, changed frame output to stderrWriter(), added WithOutput() method for customizable writers, and unified glyph compilation across all string formatting functions.
Logging Enhancements
pkg/cli/log.go
Added LogSecurity and LogSecurityf functions for security event logging.
Comprehensive Test Coverage
pkg/cli/*_test.go (25+ test files)
Added extensive test suites across CLI infrastructure covering output formatting, theme/color state, daemon lifecycle, runtime initialization, flag registration, error handling, stream behavior, prompt/selection logic, and edge case robustness.
Locale Data
pkg/cli/locales/en.json
Added English translations for Go toolchain installation instructions and updated package command format flag descriptions.
Dependency Updates
go.mod
Updated forge.lthn.ai/core/go from v0.3.2 to v0.3.3 and added direct dependencies for github.com/charmbracelet/x/ansi v0.11.6 and github.com/mattn/go-runewidth v0.0.21.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • [sync] cli: 16 commits from Forge #1: Modifies CLI command and locale wiring (pkg/cli/commands.go, RegisterCommands, locale loading) with overlapping responsibilities in command registration and I18n integration.

Poem

A rabbit hops through the CLI with glee,
Now glyphs compile, and output flows free,
With I/O abstraction and daemon's might,
Daemons take flight, and tests shine bright! 🐰✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant