Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ Every command supports `--json` for piping into `jq` or Claude.
| Command | Description |
|---|---|
| `mna trips list [--status=planning\|ready\|finished\|cancelled] [--include-example]` | List trips. |
| `mna trips show <tripId> [--all-options]` | Show one trip in detail, with an accommodation table per variant (cost, guest rating in its source scale, facilities). `--all-options` adds the unselected options. |
| `mna trips show <tripId> [--all-options]` | Show one trip in detail: each variant's party, plus an accommodation table per variant (cost, guest rating in its source scale, facilities). By default only the selected variant and its selected options; `--all-options` adds the unselected variants and options. |
| `mna trips create --name <name> [--cover-photo <url>]` | Create a new trip. |
| `mna trips edit <tripId> [--name=...] [--cover-photo=...] [--status=...]` | Update trip-level fields. |
| `mna trips delete <tripId> [--yes]` | Delete a trip permanently. |
Expand All @@ -215,9 +215,9 @@ Every command supports `--json` for piping into `jq` or Claude.

| Command | Description |
|---|---|
| `mna variants add <tripId> --name <name> <date flags> [--notes=...]` | Add a new variant. Dates are required — see below. |
| `mna variants duplicate <tripId> <variantId>` | Duplicate a variant. |
| `mna variants edit <tripId> <variantId> [--name=...] [--notes=...] [<date flags>]` | Update variant fields. Omitting the date flags leaves the dates alone. |
| `mna variants add <tripId> --name <name> <date flags> [<party flags>] [--notes=...]` | Add a new variant. Dates are required, and the party defaults to one adult — see below. |
| `mna variants duplicate <tripId> <variantId>` | Duplicate a variant, party included. |
| `mna variants edit <tripId> <variantId> [--name=...] [--notes=...] [<date flags>] [<party flags>]` | Update variant fields. Omitting the date or party flags leaves those alone. |
| `mna variants select <tripId> <variantId>` | Set the selected variant. |
| `mna variants delete <tripId> <variantId> [--yes]` | Delete a variant. |

Expand All @@ -235,6 +235,26 @@ mna variants add <tripId> --name "Flexible option" \
--min-nights 7 --max-nights 10
```

A variant also records who is travelling, and the budget breakdown is worked out from it. **Set it
whenever the trip is not solo:** a variant created without it is stored as one adult.

- `--adults=<n>` — at least 1.
- `--child-ages=<a,b>` — one age per child, 0–17, comma-separated or repeated. Requires `--adults` on `add`.
- `--no-children` — an adults-only party; on `edit`, removes any children already set.

```bash
mna variants add <tripId> --name "Family option" --start-date 2026-09-01 --end-date 2026-09-08 \
--adults 2 --child-ages 8,5
mna variants edit <tripId> <variantId> --adults 3 # keeps the children
mna variants edit <tripId> <variantId> --child-ages 8,5,2 # keeps the adults
mna variants edit <tripId> <variantId> --no-children
```

The API replaces the whole party on every write, so `variants edit` reads the current one first and
changes only what you named. Leave the flags off and the party stays untouched. `variants duplicate`
copies the party along with everything else. To see it, `mna trips show` has a Party column for the
selected variant; add `--all-options` to include the other variants.

### Destinations

| Command | Description |
Expand Down Expand Up @@ -311,7 +331,7 @@ mna variants add <tripId> --name "Flexible option" \

All command groups (auth/keys/config, trips, variants, destinations, options, events, access, vote/votes, goals, collections) are wired, CI-tested, and backed by live `/v1/` endpoints in production. Pre-1.0 means the public API contract is still allowed to break under `/v1/`. Once `1.0.0` ships, `/v1/` becomes stable; breaking changes require `/v2/`.

The contract of record is `https://api.mynextadventure.cloud/v1/openapi.json`. If a write seems to "succeed" but a field doesn't stick, re-fetch with `mna trips show <id> --json` to confirm — and check the request body shape against the OpenAPI schema for that endpoint.
The contract of record is `https://api.mynextadventure.cloud/v1/openapi.json`. If a write seems to "succeed" but a field doesn't stick, re-fetch with `mna trips show <id> --all-options --json` to confirm — and check the request body shape against the OpenAPI schema for that endpoint.

## Configuration

Expand Down
6 changes: 3 additions & 3 deletions skills/mna/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Before any research, establish:
- **Anchors** — the fixed points nothing else can move: a booked flight, an event date, a
pickup, a hard return-by date.
- **Party** — who travels, which legs (trips can split), and children's ages, which change room
eligibility and price.
eligibility and price. Every variant stores this party (see step 3).
- **Dates** — exact if known, otherwise a window plus a night count.
- **Budget and home currency** — the ceiling, and the currency every total gets presented in.
Never infer it from the destination or carry it over from a previous trip.
Expand Down Expand Up @@ -89,7 +89,7 @@ Build what the user agreed to, one level at a time:
| Level | Command | Notes |
|---|---|---|
| trip | `mna trips create --name "…"` | the container |
| variant | `mna variants add <trip> --name "…" --start-date <date> --end-date <date>`, or `variants duplicate <trip> <var>` | a whole-trip **strategy** ("single base" vs "stopover + base"), not a tweak. Dates are required — exact, or the six flexible-date flags (see reference). Fork a baseline, then diverge. |
| variant | `mna variants add <trip> --name "…" --start-date <date> --end-date <date> --adults <n> [--child-ages <a,b>]`, or `variants duplicate <trip> <var>` | a whole-trip **strategy** ("single base" vs "stopover + base"), not a tweak. Dates are required — exact, or the six flexible-date flags (see reference). **Always pass the party:** without it the variant is stored as one adult and its budget breakdown comes out wrong, with no error. Fork a baseline, then diverge; a duplicate keeps the party. |
| destination | `mna destinations add <trip> <var> --place "<City, Country>" --start-date <date> --end-date <date>` | in travel order; `--return-to-home` marks the home leg; `destinations reorder … --order=k1,k2,k3` fixes order |
| option | `mna options add <trip> <var> <dest> <kind> --from-json <file>`, then `mna options select …` | `<kind>` = `accommodation` \| `transport` \| `getting-around` |
| event | `mna events add <trip> <var> --from-json <file>` | only if the user wants them — the app is not a day-by-day itinerary planner, and many users don't want one |
Expand All @@ -101,7 +101,7 @@ and break a long drive with a stopover. Attach each transport leg to the destina
Set real data, not placeholders: exact coordinates on each option's `location`, per-destination
dates, check-in/out, `--free-cancellation-until` on accommodation. Replace stale options rather
than piling new ones on top. Write responses are thin — **re-fetch
`mna trips show <tripId> --json`** and confirm the field you set actually persisted.
`mna trips show <tripId> --all-options --json`** and confirm the field you set actually persisted. Without `--all-options` only the selected variant comes back, so a newly added one looks missing.

### 4. Compare end-to-end

Expand Down
39 changes: 35 additions & 4 deletions skills/mna/references/cli-and-schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ the field shapes you can't guess. Examples below use neutral placeholders.

```
trips list | show <id> [--all-options] | create --name | edit <id> | delete <id> | share | unshare
variants add <trip> --name <dates…> [--notes] | duplicate <trip> <var>
edit <trip> <var> [--name --notes <dates…>] | select <trip> <var> | delete
variants add <trip> --name <dates…> [--adults --child-ages --no-children --notes] | duplicate <trip> <var>
edit <trip> <var> [--name --notes <dates…> --adults --child-ages --no-children] | select <trip> <var> | delete
destinations add <trip> <var> --place [--start-date --end-date --notes --return-to-home]
edit <trip> <var> <destKey> [--place --notes --start-date --end-date --return-to-home/--no-…]
reorder <trip> <var> --order=k1,k2,k3 | delete <trip> <var> <destKey>
Expand Down Expand Up @@ -143,11 +143,42 @@ mna variants add <trip> --name "Flexible option" \
`variants edit` takes the same flags; leave them off and the existing dates stay untouched.
Switching a variant between the two shapes is just an edit with the other flag set.

## Variant party — set it on create

Each variant stores who is travelling, and its budget breakdown is worked out from that. Omit it
on `variants add` and the variant is silently stored as **one adult**, so always pass the party the
user gave you:

```bash
mna variants add <trip> --name "Family option" --start-date 2026-09-01 --end-date 2026-09-08 \
--adults 2 --child-ages 8,5
mna variants add <trip> --name "Couple option" --start-date 2026-09-01 --end-date 2026-09-08 --adults 2
```

- `--adults` — whole number, at least 1.
- `--child-ages` — one age per child, a whole number from 0 to 17 at the time of the trip; anyone
older counts as an adult. Comma-separated (`8,5`) or repeated. Needs `--adults` on `add`.
- `--no-children` — adults only. On `edit`, this is how to remove children.

To correct a variant, use `variants edit` with only the flags that changed:

```bash
mna variants edit <trip> <var> --adults 3
mna variants edit <trip> <var> --child-ages 8,5,2
mna variants edit <trip> <var> --no-children
```

The API's `participants` field replaces the whole party, so the CLI reads the current one and merges
your change; children, adults and any stored room count you didn't name survive. With no party flag
it isn't sent at all. `variants duplicate` copies the party. If a raw API body is ever needed, send
the complete `{ adults, children: [{ age }], numberOfRooms? }`, without the `_id`s a read returns.

## Verify-after-write

Mutation responses are intentionally thin (often just the new key). Confirm the state with
`mna trips show <tripId> --json` and parse the field you changed. This is the reliable way to
catch a silently-dropped field or an accidental duplicate create.
`mna trips show <tripId> --all-options --json` and parse the field you changed. This is the reliable way to
catch a silently-dropped field or an accidental duplicate create. Without `--all-options` the read
returns only the selected variant, so a newly added or unselected one looks missing.

## Auth / config

Expand Down
48 changes: 48 additions & 0 deletions src/commands/trips/show.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { afterEach, beforeEach, describe, expect, spyOn, test } from 'bun:test'
import { tripsShowCommand } from './show'

type RunFn = (ctx: { args: Record<string, unknown> }) => Promise<void>
const run = (args: Record<string, unknown>) => (tripsShowCommand.run as unknown as RunFn)({ args })

let originalFetch: typeof fetch
let originalKey: string | undefined

beforeEach(() => {
originalFetch = global.fetch
originalKey = process.env.MNA_API_KEY
process.env.MNA_API_KEY = 'mna_test'
global.fetch = (async () =>
Response.json({
id: 't',
name: 'Trip',
status: 'planning',
variants: [
{
id: 'v',
name: 'Family',
participants: { adults: 2, children: [{ age: 10 }, { age: 7 }] },
destinations: [],
eventsToAttend: [],
},
],
})) as unknown as typeof fetch
})

afterEach(() => {
global.fetch = originalFetch
process.env.MNA_API_KEY = originalKey
if (originalKey === undefined) Reflect.deleteProperty(process.env, 'MNA_API_KEY')
})

describe('trips show', () => {
test("prints each variant's party", async () => {
const stdout = spyOn(process.stdout, 'write').mockImplementation(() => true)

await run({ tripId: 't', 'all-options': false, json: false })

const printed = stdout.mock.calls.map(([chunk]) => String(chunk)).join('')
stdout.mockRestore()
expect(printed).toContain('Party')
expect(printed).toContain('2 adults, 2 children (10, 7)')
})
})
3 changes: 3 additions & 0 deletions src/commands/trips/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { renderJson } from '../../render/json'
import { renderTable } from '../../render/table'
import { accommodationRows } from '../../render/accommodation'
import { colors } from '../../render/colors'
import { formatParty } from '../../render/party'
import { reportAndExit, requireApiKey } from '../../util/errors'

export const tripsShowCommand = defineCommand({
Expand Down Expand Up @@ -61,12 +62,14 @@ export const tripsShowCommand = defineCommand({
renderTable({
columns: [
{ header: 'Variant', key: 'name', maxWidth: 30 },
{ header: 'Party', key: 'party' },
{ header: 'Destinations', key: 'destinationsCount' },
{ header: 'Events', key: 'eventsCount' },
],
rows:
data.variants?.map((v) => ({
name: v.name,
party: formatParty(v.participants),
destinationsCount: v.destinations?.length ?? 0,
eventsCount: v.eventsToAttend?.length ?? 0,
})) ?? [],
Expand Down
13 changes: 13 additions & 0 deletions src/commands/variants/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import { createApiClient } from '../../api/client'
import { loadCredentials, resolveApiKey, resolveBaseUrl } from '../../auth/credentials-store'
import { renderJson } from '../../render/json'
import { colors } from '../../render/colors'
import { formatParty } from '../../render/party'
import { reportAndExit, requireApiKey } from '../../util/errors'
import { requireVariantDates, variantDateArgs } from './dates'
import { parsePartyChange, participantsForNewVariant, variantPartyArgs } from './party'

const POSITIONAL_COUNT = 1

export const variantsAddCommand = defineCommand({
meta: { name: 'add', description: 'Add a new variant to a trip.' },
Expand All @@ -13,11 +17,13 @@ export const variantsAddCommand = defineCommand({
name: { type: 'string', required: true, description: 'Variant name.' },
notes: { type: 'string', description: 'Free-form variant notes.' },
...variantDateArgs,
...variantPartyArgs,
json: { type: 'boolean', default: false, description: 'Output as JSON.' },
},
async run({ args }) {
try {
const dates = requireVariantDates(args)
const participants = participantsForNewVariant(parsePartyChange(args, POSITIONAL_COUNT))

const creds = await loadCredentials()
const apiKey = resolveApiKey(creds)
Expand All @@ -26,6 +32,7 @@ export const variantsAddCommand = defineCommand({

const body: Record<string, unknown> = { name: args.name, dates }
if (args.notes !== undefined) body.notes = args.notes
if (participants !== undefined) body.participants = participants

const { data, error } = await client.POST('/v1/trips/{id}/variants', {
params: { path: { id: args.tripId } },
Expand All @@ -35,12 +42,18 @@ export const variantsAddCommand = defineCommand({

const created = data as unknown as { id?: string; name?: string } | undefined

if (participants === undefined) {
process.stderr.write(
colors.dim('No party given, so this variant is for 1 adult. Use --adults and --child-ages to change it.\n'),
)
}
if (args.json) {
renderJson(created)
} else {
process.stdout.write(
`${colors.green('✓')} Added variant ${colors.bold(created?.name ?? args.name)} (${created?.id ?? ''})\n`,
)
if (participants !== undefined) process.stdout.write(` Party: ${formatParty(participants)}\n`)
}
} catch (err) {
reportAndExit(err)
Expand Down
Loading
Loading