Skip to content

feat: add pcm_update_cyclist_ratings tool - #16

Merged
mpicciolli merged 8 commits into
mainfrom
feat/add-update-cyclist-tool
Jul 5, 2026
Merged

feat: add pcm_update_cyclist_ratings tool#16
mpicciolli merged 8 commits into
mainfrom
feat/add-update-cyclist-tool

Conversation

@mpicciolli

@mpicciolli mpicciolli commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds pcm_update_cyclist_ratings, a targeted write tool to edit a cyclist's ability ratings without hand-writing SQL, plus a few refactors that fell out of it.

New tool

  • Takes savePath, outputPath, cyclistId (find it with pcm_search_cyclist) and a partial ratings object — only the fields provided are changed (plain, mountain, mediumMountain, downhilling, cobble, timeTrial, prologue, sprint, acceleration, endurance, resistance, recuperation, hill, baroudeur).
  • Values are validated as integers in the 55–85 in-game range.
  • Same safety model as pcm_update_save: the source .cdb is never touched — changes are serialized to a new file via writeSaveDb, which refuses to overwrite anything.
  • Returns the cyclist's full ratings after the update.
  • Setting mediumMountain is rejected with an explicit error on saves that pre-date the charac_i_medium_mountain column.
  • Column names come from a trusted field→column map (ratingColumns in schemas/cyclist.ts); values and IDs are bound as SQL parameters.

Refactors

  • New getTableColumnNames(db, tableName) helper in save-db.ts — replaces the PRAGMA table_infoSet.has() block that was duplicated across search-cyclist, get-team-roster and the new tool.
  • Save fixtures now carry a hasMediumMountain flag, so tests assert each schema branch explicitly instead of detecting the column at runtime (only the 2025 fixture has it).
  • AGENTS.md layout comments now describe each file's purpose instead of listing functions, and the docs (README + AGENTS.md) reflect the two write tools.

Copilot AI review requested due to automatic review settings July 4, 2026 20:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new write-capable MCP tool, pcm_update_cyclist_ratings, to update a cyclist’s DYN_cyclist.charac_i_* ability ratings while preserving the project’s “never modify the source save” guarantee by writing edits to a new .cdb.

Changes:

  • Introduces pcm_update_cyclist_ratings with per-field rating validation and schema-compat handling for mediumMountain.
  • Refactors repeated PRAGMA table_info logic into getTableColumnNames() and adopts it in existing tools.
  • Extends tests/fixtures and updates documentation to reflect the additional write tool.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/tools/update-cyclist-ratings.test.ts Adds tool-level tests for updating ratings and schema-branch behavior.
test/save-db.test.ts Adds unit tests for new getTableColumnNames() helper.
test/fixtures/save.fixture.ts Extends fixtures with hasMediumMountain flag for explicit schema branching in tests.
src/tools/update-cyclist-ratings.ts Implements the new pcm_update_cyclist_ratings write tool.
src/tools/search-cyclist.ts Replaces duplicated PRAGMA table_info logic with getTableColumnNames().
src/tools/index.ts Registers the new tool in the server tool registry.
src/tools/get-team-roster.ts Replaces duplicated PRAGMA table_info logic with getTableColumnNames().
src/schemas/cyclist.ts Adds ratingColumns mapping + RatingField type to support safe rating writes.
src/save-db.ts Adds getTableColumnNames() helper; existing read/write DB helpers unchanged in intent.
README.md Documents the new write tool alongside pcm_update_save.
AGENTS.md Updates repository guidance/docs to reflect two write tools and file purpose descriptions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/tools/update-cyclist-ratings.test.ts
Comment thread test/tools/update-cyclist-ratings.test.ts Outdated
Comment thread src/tools/update-cyclist-ratings.ts
Comment thread AGENTS.md Outdated
mpicciolli and others added 2 commits July 4, 2026 16:06
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Comment thread README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mpicciolli
mpicciolli merged commit d2275f8 into main Jul 5, 2026
2 checks passed
@mpicciolli
mpicciolli deleted the feat/add-update-cyclist-tool branch July 5, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants