Skip to content

feat(pose-lib): save_pose_library / load_pose_library MCP + CLI#604

Merged
fernandotonon merged 1 commit into
masterfrom
feat/pose-lib-persistence-mcp-cli
May 18, 2026
Merged

feat(pose-lib): save_pose_library / load_pose_library MCP + CLI#604
fernandotonon merged 1 commit into
masterfrom
feat/pose-lib-persistence-mcp-cli

Conversation

@fernandotonon
Copy link
Copy Markdown
Owner

Closes the GUI / MCP / CLI triad for the pose library now that D-Project (#602) provides the .poselib sidecar format.

What ships

MCP tools (2 new)

  • save_pose_library — required path. Wraps PoseLibrary::savePoseLibraryForSelection. Returns ok + path on success; error on no selection / empty library / unwritable path.
  • load_pose_library — required path. Wraps loadPoseLibraryForSelection. Returns ok + path + count on success; error on no selection / missing file / malformed JSON or schema (in-memory library is preserved on parse failure thanks to the D-Project staging fix).

CLI mode (new branch in cmdPose)

qtmesh pose <library.poselib> --library list [--json] — reads the sidecar JSON directly (no mesh load needed) and prints the pose names. JSON shape mirrors the other CLI tools: { file, count, poses: [name…] }.

Doesn't go through PoseLibrary itself — there's no entity to key against in a standalone CLI invocation; we just parse the JSON. This intentionally bypasses the strict schema-replacement semantics that loadPoseLibrary enforces on a live entity; for read-only listing, schema-checking the file is enough.

--library apply <name> -o out.fbx is deliberately not in this PR — it needs the round-trip exporter to write pose-driven bone states back into the mesh.

3 new MCP tests + manual CLI verification

  • SavePoseLibrary_MissingPathRejected
  • LoadPoseLibrary_MissingPathRejected
  • LoadPoseLibrary_MissingFileRejected

Manual:

  • qtmesh pose test.poselib --library list"Poses (N): …"
  • qtmesh pose test.poselib --library list --json → JSON shape
  • qtmesh pose /nonexistent.poselib --library list → exit 1

#521 status

Sub-slice Status
D1 — Singleton data layer shipped (#592)
D-MCP — 7 tools (list/save/apply/delete/mirror/save_lib/load_lib) shipped (#593, #599, this PR)
D3 — Undo commands shipped (#595)
D4 — Mirror pose shipped (#597)
D-Project — .poselib sidecar shipped (#602)
D-CLI — qtmesh pose --library list shipped (this PR)
D2 — Inspector subgroup follow-up
D5 — Apply-with-mask follow-up
D6 — Time-blended apply follow-up
D-Thumbnail follow-up
D-CLI apply mode follow-up (needs exporter round-trip)

🤖 Generated with Claude Code

Closes the GUI / MCP / CLI triad for the pose library now that
D-Project (#602) provides the .poselib sidecar format.

## What ships

### MCP tools (2 new)

- `save_pose_library` — required `path`. Wraps
  `PoseLibrary::savePoseLibraryForSelection`. Returns ok+path on
  success; error on no selection / empty library / unwritable path.
- `load_pose_library` — required `path`. Wraps
  `loadPoseLibraryForSelection`. Returns ok+path+count on success;
  error on no selection / missing file / malformed JSON or schema
  (in-memory library is preserved on parse failure thanks to the
  D-Project staging fix).

### CLI mode (new branch in `cmdPose`)

`qtmesh pose <library.poselib> --library list [--json]` — reads
the sidecar JSON directly (no mesh load) and prints the pose names.
JSON shape mirrors the other CLI tools:
`{ file, count, poses: [name…] }`.

Doesn't go through `PoseLibrary` itself — there's no entity to
key against in a standalone CLI invocation. Just parses the
JSON. This intentionally bypasses the strict schema-replacement
semantics that `loadPoseLibrary` enforces on a live entity; for
read-only listing, schema-checking the file before walking is
enough.

`--library apply <name> -o out.fbx` is deliberately not in this
PR — it needs the round-trip exporter to write pose-driven bone
states back into the mesh. Documented in the help text as a
follow-up.

## 3 new MCP tests

- `SavePoseLibrary_MissingPathRejected` — empty args → error
  mentions 'path'.
- `LoadPoseLibrary_MissingPathRejected` — same for load.
- `LoadPoseLibrary_MissingFileRejected` — nonexistent file → error.

## Manual CLI verification

- `qtmesh pose test.poselib --library list` → "Poses (N): …"
- `qtmesh pose test.poselib --library list --json` → JSON shape.
- `qtmesh pose /nonexistent.poselib --library list` → exit 1
  with "File not found:".

## #521 status

| Sub-slice | Status |
|-|-|
| D1 — Singleton data layer | shipped (#592) |
| D-MCP — 5 + 2 = 7 tools | shipped (#593, #599, **#604**) |
| D3 — Undo commands | shipped (#595) |
| D4 — Mirror pose | shipped (#597) |
| D-Project — .poselib sidecar | shipped (#602) |
| D-CLI — `qtmesh pose --library list` | shipped (**this PR**) |
| D2 — Inspector subgroup | follow-up |
| D5 — Apply-with-mask | follow-up |
| D6 — Time-blended apply | follow-up |
| D-Thumbnail | follow-up |
| D-CLI apply | follow-up (needs exporter round-trip) |

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@fernandotonon has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 16 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 37ffecc0-3ead-45f3-b67c-a0d76fef51ec

📥 Commits

Reviewing files that changed from the base of the PR and between 9ae1ba0 and cc9b6d9.

📒 Files selected for processing (4)
  • src/CLIPipeline.cpp
  • src/MCPServer.cpp
  • src/MCPServer.h
  • src/MCPServer_test.cpp
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/pose-lib-persistence-mcp-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc9b6d9e38

ℹ️ 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".

Comment thread src/CLIPipeline.cpp
err() << "Error: schema mismatch in " << filePath << Qt::endl;
return 1;
}
const QJsonArray poses = root.value("poses").toArray();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject invalid pose library payload before listing

In --library list mode, the parser only checks the schema string and then does root.value("poses").toArray(), which silently yields an empty array when poses is missing or not an array. That makes malformed .poselib files report success as "No poses in library" instead of failing, which can hide file corruption and produce incorrect automation results when callers rely on a non-zero exit code for invalid libraries.

Useful? React with 👍 / 👎.

@sonarqubecloud
Copy link
Copy Markdown

@fernandotonon fernandotonon merged commit b37eeaa into master May 18, 2026
20 checks passed
@fernandotonon fernandotonon deleted the feat/pose-lib-persistence-mcp-cli branch May 18, 2026 08:03
fernandotonon added a commit that referenced this pull request May 18, 2026
Codex P2 on PR #604 (merged). The CLI's `--library list` path
checked the `schema` string but then did `root.value("poses").toArray()`
unconditionally — same silent-empty-on-bad-type bug class as
loadPoseLibrary had on PR #602 (fixed in #603), just in the
duplicated parse-in-the-CLI path.

A schema-matching `.poselib` file with `poses` missing or
non-array would report "No poses in library" with exit 0 instead
of surfacing the corruption. CI/audit workflows relying on
non-zero exit for invalid libraries would miss the failure.

Fix: explicit `isArray()` check after the schema match, emit
"malformed 'poses' field in <path>" to stderr and return 1.

Manual verification: a `{"schema":"qtmesheditor.poselib.v1","poses":"oops"}`
file now exits 1 with the expected message instead of 0 with a
vacuous result.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
fernandotonon added a commit that referenced this pull request May 18, 2026
…ply <name> -o <out> (#606)

Adds the apply side of `--library` mode (the list side shipped in
#604). Loads a mesh, loads a .poselib sidecar, applies the named
pose to the skeleton, exports the posed mesh.

## CLI shape

  qtmesh pose <mesh.fbx> --library apply
              --lib <library.poselib>
              --apply <name>
              -o <out.fbx>

`filePath` (positional) is the MESH in apply mode, contrasting
with list mode where it's the library file. The library path
arrives via `--lib` so the positional convention stays consistent
across all `pose` modes (positional = primary input).

## Implementation

- Reuses `MeshImporterExporter::importer` + `exportCurrentPose`
  — same path the `--animation --time` mode takes, just with the
  pose source being `PoseLibrary::applyPose` instead of an
  `AnimationState`.
- Strict input validation:
  - mesh file exists
  - library file exists
  - mesh has a skeleton (apply needs one)
  - pose name exists in the library (otherwise lists available
    names on stderr so the user can fix their command line)
- Sentry breadcrumbs `cli.pose` + `file.import` for telemetry.

Help text updated next to the existing `--library list` line.

No new tests in this PR — the existing PoseLibrary + CLI tests
cover the loadPoseLibrary / applyPose paths in isolation, and the
new code is just glue between them.

## #521 status

| Sub-slice | Status |
|-|-|
| D1 — Singleton data layer | shipped (#592) |
| D-MCP — 7 tools | shipped (#593, #599, #604) |
| D3 — Undo commands | shipped (#595) |
| D4 — Mirror pose | shipped (#597) |
| D-Project — .poselib sidecar | shipped (#602) |
| D-CLI — `pose --library list` | shipped (#604) |
| D-CLI — `pose --library apply` | **this PR** |
| D2 — Inspector subgroup | follow-up |
| D5 — Apply-with-mask | follow-up |
| D6 — Time-blended apply | follow-up |
| D-Thumbnail | follow-up |

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant