Skip to content

Client discovery#54

Open
tlsim wants to merge 5 commits intomasterfrom
claude/add-plan-md-file-018ndfS16yeoFxPVKX2H4pNV
Open

Client discovery#54
tlsim wants to merge 5 commits intomasterfrom
claude/add-plan-md-file-018ndfS16yeoFxPVKX2H4pNV

Conversation

@tlsim
Copy link
Owner

@tlsim tlsim commented Nov 15, 2025

Replace hardcoded --cli flag with flexible client discovery system.

Breaking Changes:

  • Remove --cli flag (use --client cli instead)

Features:

  • Add client discovery module for automatic client detection
  • Add --client flag to specify client (e.g., --client cli, --client gfxhat)
  • Add --list-clients flag to display available built-in clients
  • Add config-based default client selection via [Client] section
  • Support external custom clients via module:class specification
  • Simplify logging configuration to use client-provided handlers

Implementation:

  • Create src/pi_pianoteq/client/discovery.py with client discovery logic
  • Add get_logging_handler() abstract method to Client base class
  • Implement get_logging_handler() in CliClient and GfxhatClient
  • Update logging_config.py to accept optional handler parameter
  • Add CLIENT config option to pi_pianoteq.conf and Config class
  • Update main.py to use config-based client selection
  • Add comprehensive tests for client discovery and config

Documentation:

  • Update docs/development.md with custom client usage examples
  • Update CHANGELOG.md with breaking change notice

@tlsim tlsim linked an issue Nov 15, 2025 that may be closed by this pull request
@tlsim tlsim force-pushed the claude/add-plan-md-file-018ndfS16yeoFxPVKX2H4pNV branch from 4f66d66 to d9e7d7c Compare November 19, 2025 20:56
Replace hardcoded --cli flag with flexible client discovery system.

Breaking Changes:
- Remove --cli flag (use --client cli instead)

Features:
- Add client discovery module for automatic client detection
- Add --client flag to specify client (e.g., --client cli, --client gfxhat)
- Add --list-clients flag to display available built-in clients
- Add config-based default client selection via [Client] section
- Support external custom clients via module:class specification
- Simplify logging configuration to use client-provided handlers

Implementation:
- Create src/pi_pianoteq/client/discovery.py with client discovery logic
- Add get_logging_handler() abstract method to Client base class
- Implement get_logging_handler() in CliClient and GfxhatClient
- Update logging_config.py to accept optional handler parameter
- Add CLIENT config option to pi_pianoteq.conf and Config class
- Update __main__.py to use config-based client selection
- Add comprehensive tests for client discovery and config

Documentation:
- Update docs/development.md with custom client usage examples
- Update CHANGELOG.md with breaking change notice
Add explanatory note about why some clients may not be visible due to missing hardware dependencies. This clarifies for dev machine users why gfxhat isn't shown without python3-smbus installed.
Track and display clients that exist but can't be imported due to missing dependencies. This provides better visibility into what clients are available but not currently usable.

Example output:
  cli          - CLI client for Pianoteq...
  gfxhat       - [unavailable: missing dependency: python3-smbus]

Changes:
- Add discover_builtin_clients_with_errors() to track import failures
- Update list_clients() to show both available and unavailable clients
- Add tests for error tracking functionality
- Clean up error messages for better readability
Simplify and improve error handling in client discovery:

1. Remove systemd section from development.md (belongs in deployment docs)
2. Remove special case for python3-smbus - handle all errors uniformly
3. Simplify error handling logic:
   - Inner try/except: catches errors importing *_client.py submodule
   - Outer try/except: catches errors importing package itself
   - Both use shared _format_error_message() helper for consistency

Error messages now consistently show first line of actual error,
providing useful context without cluttering the output.
Provide a minimal working example of an external client that users can:
- Test with: pi-pianoteq --client example_client:ExampleClient
- Use as a template for custom client development
- Reference when following the custom client documentation

The example demonstrates all required Client abstract methods with
simple console output, making it easy to understand the client lifecycle.
@tlsim tlsim force-pushed the claude/add-plan-md-file-018ndfS16yeoFxPVKX2H4pNV branch from 8271188 to aa1b2b7 Compare November 21, 2025 22:58
@tlsim
Copy link
Owner Author

tlsim commented Dec 14, 2025

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

Client discovery

2 participants