skyl / corpora

Corpora is a self-building corpus that can help build other arbitrary corpora
GNU Affero General Public License v3.0
2 stars 0 forks source link

feat(corpora plan update_issue): made with `corpora workon file py/packages/corpora_cli/commands/plan.py` #39

Closed skyl closed 1 week ago

skyl commented 1 week ago

PR Type

enhancement


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
plan.py
Add interactive issue update command to corpora CLI           

py/packages/corpora_cli/commands/plan.py
  • Added a new update_issue command to interactively update existing
    issues.
  • Implemented fetching and displaying of existing issue details.
  • Integrated a REPL loop for user input to modify issue content.
  • Added functionality to confirm and apply updates to the issue tracker.

  • +94/-0   

    ๐Ÿ’ก PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    github-actions[bot] commented 1 week ago

    PR Reviewer Guide ๐Ÿ”

    Here are some key observations to aid the review process:

    โฑ๏ธ Estimated effort to review: 4 ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšช
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ No security concerns identified
    โšก Recommended focus areas for review

    Code Smell
    The code contains multiple `open` statements for reading files. Consider refactoring to handle potential file read errors and ensure files are closed properly, possibly using a context manager. User Experience
    The REPL loop does not provide a clear exit condition or help message for users. Consider adding instructions or an exit command to improve user experience.
    skyl commented 1 week ago

    closes #34 see #17

    github-actions[bot] commented 1 week ago

    PR Code Suggestions โœจ

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add a check to ensure updated_issue is not None before accessing its attributes to prevent errors ___ **Add a check to ensure that updated_issue is not None before attempting to access its
    title and body attributes to avoid potential AttributeError.** [py/packages/corpora_cli/commands/plan.py [172-173]](https://github.com/skyl/corpora/pull/39/files#diff-3a75c37cc4370060d57701a9b0900b27d5c7db9a10716528e30d509a506abf1eR172-R173) ```diff -c.console.print(f"Title: {updated_issue.title}", style="magenta") -c.console.print(f"Body:\n{updated_issue.body}", style="dim") +if updated_issue: + c.console.print(f"Title: {updated_issue.title}", style="magenta") + c.console.print(f"Body:\n{updated_issue.body}", style="dim") +else: + c.console.print("Failed to generate updated issue draft.", style="red") ```
    Suggestion importance[1-10]: 8 Why: This suggestion addresses a potential bug by preventing an `AttributeError` if `updated_issue` is `None`. It enhances the robustness of the code, making it a valuable improvement.
    8
    Maintainability
    Use a utility function to handle repeated file reading operations for better maintainability ___ **Consider using a context manager or a utility function to handle repeated file
    reading operations to improve code maintainability and reduce redundancy.** [py/packages/corpora_cli/commands/plan.py [151-158]](https://github.com/skyl/corpora/pull/39/files#diff-3a75c37cc4370060d57701a9b0900b27d5c7db9a10716528e30d509a506abf1eR151-R158) ```diff -with open(".corpora/VOICE.md", "r") as f: - voice = f.read() if f else "" -with open(".corpora/PURPOSE.md", "r") as f: - purpose = f.read() if f else "" -with open(".corpora/STRUCTURE.md", "r") as f: - structure = f.read() if f else "" -with open(f".corpora/md/DIRECTIONS.md", "r") as f: - directions = f.read() if f else "" +def read_file(file_path): + try: + with open(file_path, "r") as f: + return f.read() + except FileNotFoundError: + return "" +voice = read_file(".corpora/VOICE.md") +purpose = read_file(".corpora/PURPOSE.md") +structure = read_file(".corpora/STRUCTURE.md") +directions = read_file(".corpora/md/DIRECTIONS.md") ```
    Suggestion importance[1-10]: 6 Why: The suggestion reduces code redundancy and improves maintainability by introducing a utility function for file reading. While beneficial, it does not address any critical issues.
    6
    Enhancement
    Improve user guidance by using a more descriptive prompt message when requesting input on issue changes ___ **Consider using a more descriptive prompt message to guide the user more effectively
    when asking for input on issue changes.** [py/packages/corpora_cli/commands/plan.py [130-138]](https://github.com/skyl/corpora/pull/39/files#diff-3a75c37cc4370060d57701a9b0900b27d5c7db9a10716528e30d509a506abf1eR130-R138) ```diff user_input = session.prompt( ( - "Current issue content:\n" + "No previous messages. Please enter the current issue content:\n" if not messages - else "What changes would you like to make to this issue?\n" + else "Please specify the changes you want to make to this issue:\n" ), multiline=True, vi_mode=True, ) ```
    Suggestion importance[1-10]: 5 Why: The suggestion improves user experience by providing clearer instructions, which can help users understand what input is expected. However, it is not critical to the functionality of the code.
    5