feat: scaffold Python project with shared utilities#6
Open
Keramikus-97 wants to merge 1 commit into
Open
Conversation
Add Python package structure with shared utility modules that prevent code duplication across domain modules: - utils/errors: unified exception hierarchy - utils/env: env-var loading & validation - utils/crypto: HMAC-SHA256 helpers - utils/http: GitHub API HTTP helpers - utils/text: regex extraction & input sanitisation Domain modules (config, comment_parser, github_client, webhook_handler) delegate common patterns to utils/ instead of reimplementing them. Includes pyproject.toml, .gitignore, and 44 passing tests. Co-Authored-By: dominicpape <dominicpape@gmx.net>
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
Adds a full Python package structure where every domain module delegates
common patterns to a shared
utils/package, preventing code duplicationfrom the start.
Shared utilities (
src/opencode_github/utils/)errorsOpenCodeError→ConfigError,GitHubAPIError,WebhookValidationError,CommandParseErrorenvget_required_env(name)/get_optional_env(name, default)— typed env-var loading with validationconfigcryptocompute_hmac_sha256(secret, payload)/compare_signatures(a, b)— constant-time HMAC helperswebhook_handlerhttpbuild_headers(token),parse_json_response(resp),create_http_client(token=, base_url=)github_clienttextextract_first_match(pattern, text),sanitize_input(text, max_length=)comment_parser,webhook_handlerDomain modules
config.py—Config.from_env()dataclass, callsutils.envcomment_parser.py—parse_command(body) → ParsedCommand | None, callsutils.textgithub_client.py— async context-managerGitHubClient, callsutils.httpwebhook_handler.py—verify_signature()+parse_event() → WebhookEvent, callsutils.crypto+utils.textTests & tooling
E,F,I,N,W,UP), all passingpyproject.tomlwith[dev]extras,.gitignoreLink to Devin session: https://app.devin.ai/sessions/340db4562f06435694a8a6cb44bbf5e6
Requested by: @Keramikus-97