Skip to content

fix(cli): set the party on variants add and variants edit - #11

Merged
akoso merged 1 commit into
mainfrom
fix/variant-participants
Nov 2, 2026
Merged

akoso merged 1 commit into
mainfrom
fix/variant-participants

Conversation

@akoso

@akoso akoso commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

What was broken

mna variants add and mna variants edit had no way to say who is travelling. The API defaults a new variant to one adult when participants is missing, and the budget breakdown is worked out from that, so every family trip created through the CLI was wrong with no error.

The fix

Flag Meaning
--adults <n> Whole number, at least 1.
--child-ages <a,b> One age per child, 0-17. Comma-separated or repeated. Needs --adults on add.
--no-children Adults only. On edit, this is how to remove children.
  • Partial edits are safe. participants replaces the whole structure, so variants edit reads the stored party and merges your change into it. With no party flag it reads nothing and sends no participants.
  • trips show has a Party column, e.g. 2 adults, 2 children (8, 5).
  • Docs: README, SKILL.md and cli-and-schemas.md tell agents to set the party at creation.

API behaviour the merge depends on

All of this was checked against production on the sandbox trip. The first three would each have broken a simple fetch-and-merge:

Behaviour Handling
GET /v1/trips/{id} returns only the selected variant unless includeAllOptions=true The merge read always passes it. Skill docs now say to verify writes with --all-options, because the old advice made a new variant look missing.
Reads carry _id on the party and on each child, and writes reject them with a 400 The merge copies declared fields only.
A PATCH without numberOfRooms erases it The merge keeps it, even when both --adults and --child-ages are given. There is no rooms flag, so the CLI could not restore it otherwise.
Ages are limited to 0-17, enforced by the server but absent from the OpenAPI spec The local check matches the server. 18 and -1 returned 400, and 0 and 17 returned 200.

Decisions worth a look

  • Small additions you didn't ask for:
    • variants add with no party flags prints a one-line note on stderr saying it defaulted to one adult. --json stdout is unchanged.
    • --child-ages 8 5 is an error. citty would otherwise keep 8 and quietly drop 5.
    • An empty --child-ages is an error, so an unset shell variable can't wipe children. Clearing them takes the explicit --no-children.
  • --adults stays optional on add, so existing solo scripts keep working.
  • openapi.json is not refreshed. The committed snapshot predates participants on the create and update DTOs. Variant bodies are already cast as never, so nothing depends on it, and a refresh would pull in unrelated changes. The read DTO already has the field.

Verification

  • bun test: 210 pass, 0 fail (50 new). bun run typecheck and bun run lint are clean.
  • Built bundle on Node (node dist/mna.js):
    • Bad input, run against an unreachable API, printed a clear error and exited 1 before any request.
    • The CI-style skills install smoke test passed, and the installed skill contains the new docs.
  • Live, through the built bundle, on the sandbox trip only:
    • Added variants with and without a party.
    • Edited with --adults, --child-ages (comma-separated and repeated), both together, and --no-children, re-reading the party after each.
    • Confirmed numberOfRooms survived partial and full edits, and that --name alone left the party alone.
    • Confirmed variants duplicate copies the party, and that an unknown variant fails without writing.
    • Deleted every variant I added. The trip's variants, names and parties matched before and after.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R6BF2tkLhdyAHNtHx1mtCK

Neither command could say who was travelling, so every variant created
through the CLI was stored as one adult, and the budget breakdown is
worked out from that. Family trips came out wrong with no error.

- New `--adults`, `--child-ages` (comma-separated or repeated) and
  `--no-children` flags on both commands, validated before any request:
  adults at least 1, ages 0-17, matching the server's validation.
- `variants edit` reads the stored party and merges into it, because the
  API replaces `participants` wholesale. The read needs `includeAllOptions`
  or only the selected variant comes back. The merge keeps `numberOfRooms`
  and strips the `_id`s a read carries, which writes reject.
- `variants add --child-ages` needs `--adults`, and a space-separated
  `--child-ages 8 5` is an error rather than a silently dropped child.
- `variants add` without party flags says on stderr that it defaulted to
  one adult.
- `trips show` gets a Party column.
- The skill now tells agents to set the party at creation, and to verify
  writes with `--all-options`, since a plain read hides unselected variants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R6BF2tkLhdyAHNtHx1mtCK
@akoso
akoso merged commit e291bf2 into main Nov 2, 2026
1 check passed
@akoso
akoso deleted the fix/variant-participants branch November 2, 2026 10:35
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