Add hyperai CLI and fix console_scripts entry point#10
Conversation
Hướng dẫn cho người reviewThêm một giao diện dòng lệnh (CLI) tối giản cho package hyperai, nối nó với entry point Biểu đồ tuần tự cho luồng gọi hyperai CLIsequenceDiagram
actor User
participant Shell
participant ConsoleScriptsEntryPoint as console_scripts_entry_point
participant HyperaiCli as hyperai_cli_main
participant Argparse
participant ImportlibMetadata as importlib_metadata
User->>Shell: hyperai --info
Shell->>ConsoleScriptsEntryPoint: invoke hyperai
ConsoleScriptsEntryPoint->>HyperaiCli: main(argv)
HyperaiCli->>Argparse: ArgumentParser.parse_args(argv)
Argparse-->>HyperaiCli: args
alt args.version requested
HyperaiCli->>ImportlibMetadata: version(hyperai-framework)
ImportlibMetadata-->>HyperaiCli: version string or PackageNotFoundError
HyperaiCli-->>User: prints version
else args.info is True
HyperaiCli-->>User: prints framework information
else no flags
HyperaiCli->>Argparse: print_help()
Argparse-->>User: help text
end
HyperaiCli-->>ConsoleScriptsEntryPoint: return 0
ConsoleScriptsEntryPoint-->>Shell: process exit 0
Biểu đồ lớp đã cập nhật cho việc expose hyperai CLI và entry pointclassDiagram
class hyperai {
<<module>>
+main(argv list[str] or None) int
}
class hyperai_cli {
<<module>>
+main(argv list[str] or None) int
-_get_version() str
}
class setup_py {
<<build_config>>
+console_script_hyperai : hyperai.cli:main
}
hyperai ..> hyperai_cli : reexports main
setup_py ..> hyperai_cli : console_scripts entry point
Thay đổi ở cấp độ file
Mẹo và câu lệnhTương tác với Sourcery
Tùy chỉnh trải nghiệm của bạnTruy cập dashboard để:
Nhận hỗ trợ
Original review guide in EnglishReviewer's GuideAdds a minimal command-line interface for the hyperai package, wires it up as the console_scripts entry point, and exposes the CLI main() function via the package’s public API. Sequence diagram for hyperai CLI invocation flowsequenceDiagram
actor User
participant Shell
participant ConsoleScriptsEntryPoint as console_scripts_entry_point
participant HyperaiCli as hyperai_cli_main
participant Argparse
participant ImportlibMetadata as importlib_metadata
User->>Shell: hyperai --info
Shell->>ConsoleScriptsEntryPoint: invoke hyperai
ConsoleScriptsEntryPoint->>HyperaiCli: main(argv)
HyperaiCli->>Argparse: ArgumentParser.parse_args(argv)
Argparse-->>HyperaiCli: args
alt args.version requested
HyperaiCli->>ImportlibMetadata: version(hyperai-framework)
ImportlibMetadata-->>HyperaiCli: version string or PackageNotFoundError
HyperaiCli-->>User: prints version
else args.info is True
HyperaiCli-->>User: prints framework information
else no flags
HyperaiCli->>Argparse: print_help()
Argparse-->>User: help text
end
HyperaiCli-->>ConsoleScriptsEntryPoint: return 0
ConsoleScriptsEntryPoint-->>Shell: process exit 0
Updated class diagram for hyperai CLI exposure and entry pointclassDiagram
class hyperai {
<<module>>
+main(argv list[str] or None) int
}
class hyperai_cli {
<<module>>
+main(argv list[str] or None) int
-_get_version() str
}
class setup_py {
<<build_config>>
+console_script_hyperai : hyperai.cli:main
}
hyperai ..> hyperai_cli : reexports main
setup_py ..> hyperai_cli : console_scripts entry point
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
There was a problem hiding this comment.
Hey - tôi đã tìm thấy 1 vấn đề và để lại một số phản hồi tổng quan:
- Helper
_get_version()đang hard-code tên distribution"hyperai-framework"; hãy cân nhắc lấy giá trị này từ metadata của gói đã cài đặt (ví dụ: dùng cùng tên như trongsetup.pyhoặc qua__package__) để đảm bảo phiên bản CLI luôn đồng bộ nếu tên project thay đổi. - Việc export
maintừ package cấp cao nhấthyperaithông qua__all__có thể làm "ô nhiễm" API public một cách không cần thiết và tiềm ẩn nguy cơ xung đột tên; bạn có thể chỉ giữ entry point làhyperai.cli:mainvà tránh re-export nó từ__init__.py.
Prompt dành cho AI Agents
Please address the comments from this code review:
## Overall Comments
- The `_get_version()` helper hardcodes the distribution name `"hyperai-framework"`; consider deriving this from the installed package metadata (e.g., using the same name as in `setup.py` or via `__package__`) so the CLI version stays in sync if the project name changes.
- Exporting `main` from the top-level `hyperai` package via `__all__` may unnecessarily pollute the public API and risk name clashes; you could leave the entry point as `hyperai.cli:main` only and avoid re-exporting it from `__init__.py`.
## Individual Comments
### Comment 1
<location> `src/hyperai/cli.py:11-13` </location>
<code_context>
+from importlib import metadata
+
+
+def _get_version() -> str:
+ try:
+ return metadata.version("hyperai-framework")
+ except metadata.PackageNotFoundError:
+ return "0.0.0"
</code_context>
<issue_to_address>
**issue (bug_risk):** The hard-coded distribution name in _get_version may not match the actual installed package.
`metadata.version("hyperai-framework")` assumes the distribution name is exactly `hyperai-framework`. If the published package name differs (e.g. `hyperai`), `--version` will always return `0.0.0` even when installed. Consider deriving this from the actual distribution name (e.g. shared constant or setup/pyproject metadata) so they can’t diverge.
</issue_to_address>Sourcery miễn phí cho mã nguồn mở - nếu bạn thấy review này hữu ích, hãy cân nhắc chia sẻ ✨
Original comment in English
Hey - I've found 1 issue, and left some high level feedback:
- The
_get_version()helper hardcodes the distribution name"hyperai-framework"; consider deriving this from the installed package metadata (e.g., using the same name as insetup.pyor via__package__) so the CLI version stays in sync if the project name changes. - Exporting
mainfrom the top-levelhyperaipackage via__all__may unnecessarily pollute the public API and risk name clashes; you could leave the entry point ashyperai.cli:mainonly and avoid re-exporting it from__init__.py.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `_get_version()` helper hardcodes the distribution name `"hyperai-framework"`; consider deriving this from the installed package metadata (e.g., using the same name as in `setup.py` or via `__package__`) so the CLI version stays in sync if the project name changes.
- Exporting `main` from the top-level `hyperai` package via `__all__` may unnecessarily pollute the public API and risk name clashes; you could leave the entry point as `hyperai.cli:main` only and avoid re-exporting it from `__init__.py`.
## Individual Comments
### Comment 1
<location> `src/hyperai/cli.py:11-13` </location>
<code_context>
+from importlib import metadata
+
+
+def _get_version() -> str:
+ try:
+ return metadata.version("hyperai-framework")
+ except metadata.PackageNotFoundError:
+ return "0.0.0"
</code_context>
<issue_to_address>
**issue (bug_risk):** The hard-coded distribution name in _get_version may not match the actual installed package.
`metadata.version("hyperai-framework")` assumes the distribution name is exactly `hyperai-framework`. If the published package name differs (e.g. `hyperai`), `--version` will always return `0.0.0` even when installed. Consider deriving this from the actual distribution name (e.g. shared constant or setup/pyproject metadata) so they can’t diverge.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||||
|
👋 This pull request has been automatically marked as stale because it has not had recent activity. What happens next:
Tips to get your PR merged:
Thank you for your contribution! 🙏 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3fad632f48
ℹ️ 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".
| @@ -1,4 +1,6 @@ | |||
| """Command-line interface for the HYPERAI framework.""" | |||
| q""" | |||
There was a problem hiding this comment.
Remove invalid docstring prefix that breaks module import
The new leading q before the triple-quoted docstring makes src/hyperai/cli.py invalid Python syntax, so importing hyperai.cli raises a SyntaxError immediately. Because src/hyperai/__init__.py now imports main from this module, this also breaks import hyperai and the hyperai console entry point in all environments.
Useful? React with 👍 / 👎.
|
👋 This pull request has been automatically marked as stale because it has not had recent activity. What happens next:
Tips to get your PR merged:
Thank you for your contribution! 🙏 |
User description
Motivation
hyperaiinvokes the correct module instead of referencingsrc.inentry_points.main()entry point forhyperai.hyperai.cli:maincan be referenced and tested.Description
setup.pyto set the console script tohyperai=hyperai.cli:maininstead ofhyperai=src.hyperai:main.src/hyperai/cli.pycontaining a basicmain(argv: list[str] | None = None) -> intwith--versionand--infohandling and a helper_get_version()usingimportlib.metadata.from .cli import mainand adding"main"to__all__insrc/hyperai/__init__.py.Testing
Codex Task
Tóm tắt bởi Sourcery
Thêm một giao diện dòng lệnh tối thiểu cho package hyperai và kết nối nó làm entry point console script của package.
Tính năng mới:
main()hỗ trợ các lệnh--versionvà--info.main()của CLI thông qua public API của package hyperai.Cải tiến:
console_scriptsđể gọihyperai.cli:mainthay vì modulesrc.hyperai.Original summary in English
Tóm tắt bởi Sourcery
Giới thiệu một giao diện dòng lệnh tối giản cho package hyperai và cấu hình nó làm entry point console của package.
Tính năng mới:
hyperaicung cấp entry pointmain()với các lệnh cơ bản--versionvà--info.main()của CLI thông qua public API của packagehyperai.Cải tiến:
console_scriptsđể gọihyperai.cli:mainthay vì modulesrc.hyperai.Original summary in English
Summary by Sourcery
Introduce a minimal command-line interface for the hyperai package and wire it up as the package’s console entry point.
New Features:
Enhancements:
PR Type
Enhancement
Description
Add minimal CLI with
--versionand--infoflagsFix console_scripts entry point to reference
hyperai.cli:mainExport CLI
main()function via public package APIDiagram Walkthrough
File Walkthrough
setup.py
Fix console_scripts entry point referencesetup.py
hyperai=src.hyperai:maintohyperai=hyperai.cli:maininstalled
cli.py
Create CLI module with argument parsingsrc/hyperai/cli.py
main(argv)function with argparse supporting--versionand--infoflags
_get_version()helper usingimportlib.metadatato fetch packageversion
if __name__ == "__main__"block for direct execution__init__.py
Export CLI main function in public APIsrc/hyperai/init.py
mainfunction from newclimodule"main"to__all__list to expose CLI via public APIhyperai.cli:mainto be referenced and tested