Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tsume para parser #1

Merged
merged 2 commits into from
Sep 6, 2024
Merged

feat: add tsume para parser #1

merged 2 commits into from
Sep 6, 2024

Conversation

tkgstrator
Copy link
Contributor

@tkgstrator tkgstrator commented Sep 6, 2024

Type

🤖 Generated by PR Agent at 5784986

['Enhancement', 'Tests', 'Configuration changes']

Description

🤖 Generated by PR Agent at 5784986

  • tsume para parserを追加し、詰将棋パラダイスのデータを解析するためのライブラリを実装しました。
  • devcontainerDockerの設定を追加し、開発環境を整備しました。
  • GitHub Actionsのワークフローを追加し、コードレビュー、デプロイ、継続的インテグレーション、リリースバリデーションを自動化しました。
  • Huskylint-stagedの設定を追加し、コミットメッセージの整合性とコード品質を向上させました。
  • README.mdを追加し、ライブラリの概要と使用方法を記載しました。
  • テストデータとテストケースを追加し、TCSVパーシングの機能を検証しました。

Walkthrough

Relevant files
Configuration changes
22 files
.commitlintrc.yaml
Add commitlint configuration for conventional commits       

.commitlintrc.yaml

  • Added commitlint configuration file.
  • Extended with conventional config.
  • +3/-0     
    Dockerfile
    Add Dockerfile for Bun environment setup                                 

    .devcontainer/Dockerfile

    • Added Dockerfile for devcontainer setup.
    • Set up Bun environment.
    +7/-0     
    devcontainer.json
    Add devcontainer configuration for VSCode                               

    .devcontainer/devcontainer.json

  • Added devcontainer configuration file.
  • Configured VSCode extensions and settings.
  • Defined Docker Compose setup.
  • +83/-0   
    docker-compose.yaml
    Add Docker Compose configuration for devcontainer               

    .devcontainer/docker-compose.yaml

  • Added Docker Compose configuration for devcontainer.
  • Defined service for kif_parser.
  • +17/-0   
    postAttachCommand.sh
    Add post-attach script for Git configuration                         

    .devcontainer/postAttachCommand.sh

  • Added post-attach script for devcontainer.
  • Configured Git settings.
  • +8/-0     
    postCreateCommand.sh
    Add post-create script for dependency setup                           

    .devcontainer/postCreateCommand.sh

  • Added post-create script for devcontainer.
  • Set ownership and installed dependencies.
  • +4/-0     
    .editorconfig
    Add EditorConfig for coding style consistency                       

    .editorconfig

  • Added EditorConfig file for consistent coding styles.
  • Defined indentation and whitespace rules.
  • +21/-0   
    pull_request.closed.develop.json
    Add JSON template for closed PRs on develop                           

    .github/pull_request.closed.develop.json

    • Added JSON template for closed pull requests on develop branch.
    +14/-0   
    pull_request.closed.master.json
    Add JSON template for closed PRs on master                             

    .github/pull_request.closed.master.json

    • Added JSON template for closed pull requests on master branch.
    +14/-0   
    code_review.yaml
    Add GitHub Actions workflow for code review                           

    .github/workflows/code_review.yaml

  • Added workflow for code review using ChatGPT.
  • Configured triggers and permissions.
  • +31/-0   
    deployment.yaml
    Add deployment workflow for GitHub Package Registry           

    .github/workflows/deployment.yaml

  • Added deployment workflow for GitHub Package Registry.
  • Configured steps for build and publish.
  • +34/-0   
    integration.yaml
    Add continuous integration workflow                                           

    .github/workflows/integration.yaml

  • Added continuous integration workflow.
  • Configured commit linting and code checks.
  • +42/-0   
    release_validation.yaml
    Add release validation workflow                                                   

    .github/workflows/release_validation.yaml

  • Added release validation workflow.
  • Configured version comparison and validation.
  • +38/-0   
    commit-msg
    Add Husky hook for commit message linting                               

    .husky/commit-msg

    • Added Husky hook for commit message linting.
    +1/-0     
    pre-commit
    Add Husky pre-commit hook for testing and linting               

    .husky/pre-commit

    • Added Husky pre-commit hook for testing and linting.
    +2/-0     
    prepare-commit-msg
    Add Husky hook for preparing commit messages                         

    .husky/prepare-commit-msg

    • Added Husky hook for preparing commit messages.
    +1/-0     
    .lintstagedrc.yaml
    Add lint-staged configuration for code quality                     

    .lintstagedrc.yaml

    • Added lint-staged configuration for linting and formatting.
    +4/-0     
    .pr_agent.toml
    Add PR agent configuration                                                             

    .pr_agent.toml

  • Added configuration for PR agent.
  • Defined PR actions and commands.
  • +40/-0   
    biome.json
    Add Biome configuration for linting and formatting             

    biome.json

  • Added Biome configuration for linting and formatting.
  • Defined rules and settings for JavaScript and JSON.
  • +45/-0   
    bunfig.toml
    Add Bun configuration file                                                             

    bunfig.toml

  • Added Bun configuration file.
  • Defined build, test, and run settings.
  • +16/-0   
    package.json
    Add package.json for project setup                                             

    package.json

  • Added package.json for project metadata and dependencies.
  • Defined scripts for build, lint, and deploy.
  • +42/-0   
    tsconfig.json
    Add TypeScript configuration file                                               

    tsconfig.json

  • Added TypeScript configuration file.
  • Defined compiler options and paths.
  • +21/-0   
    Documentation
    2 files
    pull_request_template.md
    Add pull request template for consistency                               

    .github/pull_request_template.md

  • Added pull request template.
  • Included sections for type, description, and summary.
  • +11/-0   
    README.md
    Add README for Shogi Kif Parser                                                   

    README.md

  • Added README file for Shogi Kif Parser.
  • Described library purpose and supported data.
  • +15/-0   
    Enhancement
    10 files
    color.ts
    Add Color enum for piece colors                                                   

    src/enums/color.ts

    • Added Color enum for piece colors.
    +4/-0     
    metadata.ts
    Add MetadataKey enum for metadata keys                                     

    src/enums/metadata.ts

    • Added MetadataKey enum for metadata keys.
    +146/-0 
    piece.ts
    Add Piece enum for shogi pieces                                                   

    src/enums/piece.ts

    • Added Piece enum for shogi pieces.
    +16/-0   
    tsca.ts
    Add TCSA format for parsing shogi data                                     

    src/format/tsca.ts

  • Added TCSA format for parsing shogi data.
  • Implemented transformation logic for metadata and records.
  • +97/-0   
    index.ts
    Add main entry point for TCSV data import                               

    src/index.ts

  • Added main entry point for importing TCSV data.
  • Implemented importTCSV function.
  • +35/-0   
    board.dto.ts
    Add Board model with CSA transformation                                   

    src/models/board.dto.ts

    • Added Board model with CSA transformation.
    +20/-0   
    hand.dto.ts
    Add Hand model with CSA transformation                                     

    src/models/hand.dto.ts

  • Added Hand model for shogi pieces in hand.
  • Implemented CSA transformation.
  • +20/-0   
    metadata.dto.ts
    Add Metadata model with CSA transformation                             

    src/models/metadata.dto.ts

  • Added Metadata model for shogi metadata.
  • Implemented CSA transformation.
  • +19/-0   
    record.dto.ts
    Add Record model with CSA transformation                                 

    src/models/record.dto.ts

  • Added Record model for shogi game records.
  • Implemented CSA transformation.
  • +27/-0   
    square.dto.ts
    Add Square model with CSA transformation                                 

    src/models/square.dto.ts

  • Added Square model for shogi board squares.
  • Implemented CSA transformation.
  • +68/-0   
    Tests
    13 files
    100.txt
    Add test data for TCSV parsing                                                     

    src/tests/csv/100.txt

    • Added test data for TCSV parsing.
    +1/-0     
    1000.txt
    Add test data for TCSV parsing                                                     

    src/tests/csv/1000.txt

    • Added test data for TCSV parsing.
    +1/-0     
    index.spec.ts
    Add test suite for TCSV parsing                                                   

    src/tests/index.spec.ts

  • Added test suite for TCSV parsing.
  • Implemented test cases for parsing functionality.
  • +16/-0   
    100.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/100.kif

    • Added KIF test file for shogi game.
    +24/-0   
    1000.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/1000.kif

    • Added KIF test file for shogi game.
    +24/-0   
    200.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/200.kif

    • Added KIF test file for shogi game.
    +24/-0   
    300.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/300.kif

    • Added KIF test file for shogi game.
    +24/-0   
    400.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/400.kif

    • Added KIF test file for shogi game.
    +24/-0   
    500.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/500.kif

    • Added KIF test file for shogi game.
    +24/-0   
    600.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/600.kif

    • Added KIF test file for shogi game.
    +24/-0   
    700.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/700.kif

    • Added KIF test file for shogi game.
    +24/-0   
    800.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/800.kif

    • Added KIF test file for shogi game.
    +24/-0   
    900.kif
    Add KIF test file for shogi game                                                 

    src/tests/kif/900.kif

    • Added KIF test file for shogi game.
    +24/-0   

    Summary


    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @tkgstrator tkgstrator self-assigned this Sep 6, 2024
    @tkgstrator tkgstrator merged commit 5784986 into master Sep 6, 2024
    5 of 8 checks passed
    Copy link

    github-actions bot commented Sep 6, 2024

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Code Smell
    WHITE_SHORT_NAMEの値が文字列として定義されていますが、他の項目はすべて日本語の説明文です。整合性を持たせるために、こちらも日本語にすることを検討してください。

    Copy link

    github-actions bot commented Sep 6, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Bug
    Correct the value for the WHITE_SHORT_NAME to the appropriate Japanese term

    The value for WHITE_SHORT_NAME should be corrected to match the intended name in
    Japanese.

    src/enums/metadata.ts [29]

    -WHITE_SHORT_NAME = 'WHITE_SHORT_NAME',
    +WHITE_SHORT_NAME = '後手省略名',
     
    Suggestion importance[1-10]: 10

    Why: The suggestion corrects a clear bug where the value for WHITE_SHORT_NAME was mistakenly set to its own key name instead of the intended Japanese term, which is crucial for accurate metadata representation.

    10
    Best practice
    Implement error handling for the query string parsing to prevent runtime errors

    Consider handling potential errors when parsing the query string to avoid runtime
    exceptions.

    src/format/tsca.ts [19]

    -return Object.fromEntries(
    +try {
    +  return Object.fromEntries(
    +} catch (error) {
    +  throw new Error("Failed to parse query string");
    +}
     
    Suggestion importance[1-10]: 9

    Why: Implementing error handling for query string parsing is a best practice that prevents runtime exceptions, ensuring the application remains stable even when unexpected input is encountered.

    9
    Possible issue
    Ensure the color value is explicitly converted to a number before comparison

    Ensure that the color value is correctly parsed as a number before using it to
    determine the color.

    src/models/square.dto.ts [26]

    -color: color === 0 ? Color.BLACK : Color.WHITE,
    +color: Number(color) === 0 ? Color.BLACK : Color.WHITE,
     
    Suggestion importance[1-10]: 8

    Why: Explicitly converting color to a number before comparison enhances code robustness by preventing potential type-related issues, which is a good practice for ensuring reliable behavior.

    8
    Adjust the 後手の持駒 to reflect a valid number of pieces

    Ensure that the 後手の持駒 line accurately reflects the pieces available for the player,
    as it currently lists 歩十八, which may not be valid in a standard game.

    src/tests/kif/300.kif [9]

    -+後手の持駒:歩十八 香四 桂二 銀四 金四 飛二
    ++後手の持駒:歩十 香四 桂二 銀四 金四 飛二
     
    Suggestion importance[1-10]: 8

    Why: The suggestion addresses a potential issue with the number of pieces listed, which is crucial for the accuracy of the game record. Ensuring the correct number of pieces is important for maintaining the integrity of the game data.

    8
    Ensure the 手数 reflects the correct number of moves made in the game

    Verify that the 手数 value is consistent with the game state, as it currently
    indicates 11, which may not align with the provided moves.

    src/tests/kif/400.kif [7]

    -+手数:11
    ++手数:10
     
    Suggestion importance[1-10]: 7

    Why: The suggestion highlights a potential inconsistency in the number of moves, which is important for the accuracy of the game record. However, without additional context, it's unclear if the change is necessary.

    7
    Correct the 発表年月 to ensure it accurately reflects the date of the game

    Validate that the 発表年月 is accurate and corresponds to the actual date of the game,
    as it currently states 2011/06/25.

    src/tests/kif/600.kif [1]

    -+発表年月:2011/06/25 00:00:00
    ++発表年月:2011/06/30 00:00:00
     
    Suggestion importance[1-10]: 6

    Why: The suggestion addresses a potential date discrepancy, which is important for historical accuracy. However, without further context, it's uncertain if the proposed date is more accurate.

    6
    Enhancement
    Add validation to ensure all elements in the pieces array are valid Square objects

    Validate that the pieces array contains valid Square objects before proceeding with
    the transformation.

    src/models/record.dto.ts [10]

    -pieces: z.array(Square).min(39).max(40),
    +pieces: z.array(Square).min(39).max(40).refine(pieces => pieces.every(square => square instanceof Square), {
    +  message: "All pieces must be valid Square objects"
    +}),
     
    Suggestion importance[1-10]: 7

    Why: Adding validation to ensure all elements in the pieces array are valid Square objects improves code reliability and helps catch potential errors early, enhancing maintainability.

    7
    Update the 表題 to better reflect the context of the game

    Check the 表題 for any potential inaccuracies or misleading information, as it
    currently states 得意技で決めろ!, which should be relevant to the game context.

    src/tests/kif/500.kif [4]

    -+表題:得意技で決めろ!
    ++表題:戦略的勝利を目指せ!
     
    Suggestion importance[1-10]: 5

    Why: The suggestion proposes a change to the title for better contextual relevance, which is a minor enhancement. It improves the thematic alignment but does not impact the functionality or correctness of the game data.

    5

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant