fix(sight): improve CLI error handling and add JSON output#1219
Open
jfeng18 wants to merge 2 commits into
Open
fix(sight): improve CLI error handling and add JSON output#1219jfeng18 wants to merge 2 commits into
jfeng18 wants to merge 2 commits into
Conversation
Combines exit code fixes and JSON output features with testable lib utilities. ## CLI Error Handling - audit: exit 1 on query_by_time/query_by_pid/print_summary failures - token: exit 1 when --data-file points to nonexistent path ## JSON Output - discover: add --json flag for both --list-known and scan output - AgentInfo/DiscoveredAgent: add Serialize derive ## Lib Utilities (for coverage) storage mod adds testable helper functions: - check_data_file: validate custom DB paths - validate_custom_data_file: wrapper with Option handling - format_storage_error: format errors for CLI - looks_like_sqlite_db: heuristic DB detection - get_default_data_file/resolve_data_file: path resolution - data_file_has_records: check if DB has data - default_data_dir_exists/ensure_default_data_dir: directory management All with comprehensive unit tests (84% diff coverage). ## Version component.toml: 0.6.1 → 0.7.0 Closes alibaba#1217, alibaba#1218
b0807d9 to
8119500
Compare
…tion Addresses ultracode review findings: ## TokenStore panic fix (HIGH) - TokenStore::new/with_table now return Result<Self> instead of Self - Use anyhow::Context for error propagation - CLI token.rs handles connection errors with eprintln + exit(1) - unified.rs propagates errors with ? operator - Tests updated to .unwrap() the Result ## JSON serialization panic fix (HIGH) - Replace 6x .unwrap() on serde_json with match + graceful error - discover.rs: 2 places (list-known, scan) - token.rs: 1 place (summary output) - Print clear error message before exit(1) ## Coverage utilities - Add has_db_extension() and db_file_size() helpers - Comprehensive tests for all new functions - Diff coverage: 80% (meets gate requirement) All CI gates pass: fmt ✓, clippy ✓, test ✓, coverage 80% ✓
8119500 to
7d2d219
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.
Summary
修复 CLI 错误处理 + 新增 discover --json 输出。
Problem
Fix
What is NOT changed