llms.txt@tools/mobrpg/mobrpg · git:20261012.d4c0b1e · 2026-10-12 · sha256 2f580f5dcc48bcf4

llms.txt@tools/mobrpg/mobrpg git:20261012.d4c0b1eA

Immutable. This exact content never changes and is served at /api/v1/blob/2f580f5dcc48bcf4.

# mobrpg CLI — guide for AI agents

`mobrpg` is a CLI over the mobRPG world-builder REST API (Tim Dennis'
mobrpg.com), used to sync mobRPG worlds with gm-apprentice campaign vaults.
Every verb is a native Python subcommand under mobrpg/commands/; all of them
share one client (mobrpg/client.py) for environment resolution and auth.

## Install

    python3 -m pip install -e path/to/tools/mobrpg
    mobrpg --help

## Environment & auth (read before running anything)

- MOBRPG_ENV=dev|prod   Which server to hit. Default: prod. The resolved
                        target (env + BASE URL) is printed to stderr on every
                        run — never ambiguous.
- MOBRPG_TOKEN          Bearer token. Authenticates as the token owner. Treat
                        like a password. Overrides the managed config below.
- Managed credentials   Preferred: run `mobrpg auth import <credentials.csv>`
                        once to store a token in a user-level config
                        (MOBRPG_CONFIG_DIR override; ~/.config/mobrpg on POSIX,
                        %APPDATA%\mobrpg on Windows). get_access_token precedence:
                        MOBRPG_TOKEN env > managed config > MOBRPG_EMAIL/PASSWORD.
- MOBRPG_EMAIL / MOBRPG_PASSWORD   Alternative to a bearer token (local-password
                        accounts only). Works against either environment.
- Optional per-field overrides: MOBRPG_BASE, MOBRPG_CLIENT_ID, MOBRPG_REDIRECT_URI.

Exit codes: 0 ok; 1 API error; 2 bad args / no auth configured.

## Read-only vs mutating

Three tiers, not two. Read the middle one before calling anything "safe".

Read-only — writes nothing at all: whoami, worlds, whats-new, map check, llms.

Writes locally, never to mobRPG: pull (writes --out), suggestions (with --out),
map init and map sync (write _meta/mobrpg-map.json), images (--execute writes
into _attachments/ and can set portrait:), write, link-orphans, pull-canon,
adopt, relink. These read from mobRPG but only ever write to disk; relink makes
no API calls at all. `map` and `images` as a whole are NOT read-only — only
`map check` is. `images --push --execute` WRITES to mobRPG: it uploads
images straight onto elements (no review queue), and needs write access to
each element. `write` skips
notes that already exist unless given --overwrite, which replaces them
wholesale — hand-authored prose and GM Notes included.

Writes to mobRPG (need write access; dry-run by default, add --execute):
suggest, submit-batch, update, review, sync. sync only submits a suggestion on
a push/tie decision — a pull decision just overwrites the note locally. Nothing
here overwrites a live element directly; every upstream change goes through a
suggestion the world owner accepts or dismisses.

Entity/event IDs live in each note's `mobrpg:` frontmatter node — the single
source of truth. There is NO sidecar crosswalk; never read or write one. A
vault whose entities already exist upstream but carry no node is linked with
`adopt` (match live elements by name → stamp nodes), never by a crosswalk.

## Commands

    mobrpg auth <import|status|refresh|logout>
                                  Manage mobRPG credentials. `import
                                  <credentials.csv>` verifies via whoami and
                                  stores a user-level token; `status` reports the
                                  configured user; `refresh` renews an expired
                                  token; `logout` removes it. Tokens are never
                                  printed. See skill reference auth-setup.md.
    mobrpg whoami                 Print the authenticated user and their worlds.
    mobrpg worlds                 (same as whoami) list visible worlds.
    mobrpg pull <world> [--out F] Import a mobRPG world into a JSON extract
                                  (default extract.json). Entry of the import
                                  pipeline; feeds `write`. The extract carries
                                  entities/events/counts plus a `types` section
                                  (creature/organization/political classifier
                                  types, bound or not) for "what's new" discovery.
    mobrpg whats-new <world> --vault <path> [--extract F] [--json]
                                  Read-only discovery report diffing mobRPG (a
                                  live pull, or a pre-pulled --extract) against the
                                  vault's mobrpg: nodes + type map: NEW entities
                                  (no linked node → pull candidates), GONE (vault
                                  nodes absent upstream → deleted/zombie notes),
                                  and NEW classifier types (from the extract's
                                  types section, not yet in the map). The pull-side
                                  companion to `sync`/`suggest` (the push side).
    mobrpg suggestions <world> [--state Pending|Accepted|Dismissed] [--correlate]
                       [--vault DIR] [--fetch-elements] [--json] [--out DIR]
                                  List suggestions by review state (the return
                                  leg of `suggest`). --correlate joins each back
                                  to its vault file (externalRef) and shows the
                                  resultElementId an Accepted one produced. Needs
                                  ReadWriteDelete on the world.
    mobrpg catalog <world> <kind> [--size N] [--names-only] [--json]
                                  List the elements of one kind (names + ids),
                                  e.g. political/type, landfeature, person. See
                                  what exists before pushing, to avoid dup Types.
    mobrpg map <init|sync|check> <world> --vault <path> [--map FILE]
                                  Generate/maintain the per-vault type mapping.
                                  init: discover mobRPG types + scan vault vocab ->
                                  propose _meta/mobrpg-map.json. sync: re-discover +
                                  merge non-destructively (preserve confirmed).
                                  check: coverage report. Read-only on mobRPG.
    mobrpg pull-canon <world> --vault <path> [--no-verify] [--execute]
                                  Pull ratified mobRPG canon down into vault
                                  mobrpg: nodes. mobRPG is canon; the vault is
                                  the working surface: accepted fills ids,
                                  accepted-after-edit/drift overwrites
                                  `determined`, dismissed records a note,
                                  deleted flags, pending leaves the vault alone.
                                  Verifies each accepted element to detect drift
                                  and deletion; --no-verify skips that pass.
                                  Scaffolds a note only for a ref that names a
                                  real vault note path under a folder the vault
                                  already has; reserved handles (rel/, desc/) and
                                  unrecognised roots are reported, never created.
    mobrpg pull-canon <world> --vault <path> --reconcile-deletions [--execute]
                                  Flag linked nodes whose element is gone from
                                  mobRPG — the write side of whats-new's GONE
                                  list. The review-queue pass only sees deletions
                                  of elements it reviewed, so an element deleted
                                  directly upstream is otherwise never reconciled.
                                  Aborts rather than act on an unreadable or
                                  empty world. Vault-write only.
    mobrpg adopt <world> --vault <path> [--map F] [--kind K] [--only S] [--execute]
                                  Stamp `mobrpg:` nodes onto vault notes that
                                  already exist upstream but carry no node —
                                  match each to exactly one live element of the
                                  same kind by normalized name (aliases too) and
                                  write an `accepted` node with the real
                                  element_id. Ambiguous (several live matches) or
                                  unmatched notes are reported, never guessed. An
                                  element one note already links, or that several
                                  notes match (a name and another note's alias),
                                  is reported and stamped on none of them. A
                                  location whose exact name exists upstream under
                                  the SIBLING location kind reports as its own
                                  "kind mismatch" outcome (fix locationRouting in
                                  _meta/mobrpg-map.json, then re-run).
                                  The node-establishment path for imported / pushed
                                  vaults and the dup-safe alternative to any
                                  crosswalk. GET-only against mobRPG; dry-run
                                  without --execute.
    mobrpg relink --vault <path> --to <new-rel-path> [--from <old-rel-path>]
                  [--execute]
                                  Re-point a moved/renamed note's mobrpg
                                  external_ref to its current path, keeping
                                  element_id and recording the old ref in
                                  previous_ref. Vault-only (no API); run after
                                  renaming/moving a synced note so a re-push
                                  won't mint a duplicate. Dry-run without
                                  --execute; --from guards against relinking the
                                  wrong note.
    mobrpg update <world> <suggestionId> <update.json> [--execute]
                                  Replace a Pending suggestion's payload (PUT,
                                  whole-payload). Edits inline fields only (name,
                                  description, altNames, data e.g. Person.languages)
                                  — cannot add classifier edges; use submit-batch.
    mobrpg review <world> <suggestionId> <accept|dismiss|reinstate>
                       [--note TEXT] [--execute]
                                  GM review action on one suggestion (needs
                                  ReadWriteDelete). Dry-run without --execute.
                                  accept is irreversible; dismiss keeps the
                                  externalRef claimed (see resubmit note below).
    mobrpg write <extract.json> --out <vault-dir> [--campaign NAME]
                 [--source-doc TEXT] [--name-style plain|space] [--overwrite]
                                  Materialize a mobRPG extract (from `pull`)
                                  into vault markdown — one file per entity,
                                  mapped to the correct folder/template/type.
                                  Culture and race elements become heritage
                                  notes in Heritages/ (mirrors: suggest and sync
                                  don't push them). Each note gets an `accepted`
                                  mobrpg: node with its element_id, so a fresh
                                  import needs no `adopt`. Elements that share a
                                  name each get a file (`Name (2).md`, in
                                  element-id order; a re-run keeps each element
                                  on the note that already links it, and skips
                                  one linked from another folder). mobRPG
                                  element URLs in the prose become wikilinks.
                                  Existing notes are SKIPPED unless --overwrite
                                  is given; with it they are replaced wholesale,
                                  hand-authored prose and GM Notes included.
    mobrpg link-orphans <extract.json> --vault <path> --out <dir>
                        [--systems NAMES] [--execute]
                                  Auto-link obvious orphan entities after an
                                  import, using conservative structural naming
                                  rules (e.g. "<System> <ROMAN>" -> part_of the
                                  system; the rules run for every "<X> System"
                                  note in the vault, and --systems, a
                                  comma-separated list of star system names,
                                  overrides that). The site groups locations
                                  on parent_location, which this fills.
                                  Only links to targets that already exist in
                                  the vault. Writes a report; vault edits
                                  (relationships: frontmatter) gated by
                                  --execute (dry-run default). Writes the edge
                                  and fills an empty parent_location: scalar to
                                  match; no other frontmatter fields are
                                  populated.
    mobrpg sync <world> --vault <path> [--only S] [--skew SECONDS]
                [--batch-label L] [--show-body] [--execute]
                                  Timestamp last-writer-wins sync of every
                                  linked note's description prose against
                                  mtime / node last_synced / server
                                  lastModified. Per-note verdict is one of
                                  skip / pull / push / tie / baseline (a
                                  never-synced note with no LWW baseline —
                                  content decides instead of timestamps). A
                                  pull overwrites the note's canon prose
                                  locally (vault-only tail preserved — GM
                                  Notes plus session-bookkeeping sections by
                                  default, configurable via
                                  "vaultOnlySections" in
                                  _meta/mobrpg-map.json) and stamps
                                  last_synced; a push/tie decision never
                                  writes upstream directly — it files one
                                  reviewable UpdateElement suggestion (raw
                                  Markdown, own upd/<relpath>#<hash>
                                  externalRef) and marks the node
                                  review_state: pending until `review`
                                  adjudicates it. Notes already pending are
                                  skipped. Dry-run by default; --show-body
                                  prints each push's exact outgoing description
                                  markdown (what the suggestion will carry).
    mobrpg suggest <world> --vault <path> [--chapter CH] [--kind K] [--only S]
                  [--limit N] [--out DIR] [--write-back] [--include-pcs]
                  [--execute]
                                  Build the full datatype graph per vault entity
                                  (element + classifier Types via Attribute edges
                                  + reified relationship Events) and submit it as
                                  compound suggestion batches. Only needs Read
                                  access — the owner accepts/dismisses each, so no
                                  live element is created directly. PCs excluded
                                  unless --include-pcs; --write-back also writes a
                                  pending mobrpg: node into each entity's file.
                                  Create descriptions strip the same vault-only
                                  sections `sync` does (see "vaultOnlySections").
    mobrpg submit-batch <world> <batch.json> [--execute]
                                  Submit a pre-built COMPOUND batch (classifier
                                  Types, Attribute edges, reified Event + Link
                                  relationships, in-batch ref/dependsOn wiring).
                                  Dry-run by default.
    mobrpg images <world> --vault <path> [--execute]
                                  Pull entity images into the vault (id->file map
                                  comes from the vault's own mobrpg: nodes).
    mobrpg images <world> --vault <path> --push [--only S] [--execute]
                                  Upload each linked note's portrait: and image
                                  embeds to its element. Skips an image already
                                  there (same bytes); stops at mobRPG's 2-file
                                  limit for non-admins. A direct write: needs
                                  write access, no review queue.
    mobrpg llms                   Print this guide (it ships inside the package).

Dry-run-by-default applies to the verbs that carry an --execute flag — the
mobRPG-mutating ones (suggest, submit-batch, update, review, sync,
images --push) plus the
gated local writers (images, link-orphans, pull-canon, adopt, relink). Add
--execute to actually write.

It does NOT apply to `pull` and `write`, which have no --execute flag and write
their output as soon as they are run: `pull` creates the file named by --out,
and `write` materializes vault notes. Neither is a preview. `write` will not
replace a note that already exists unless given --overwrite; with it, the
replacement is wholesale (hand-authored prose and GM Notes included). Run
`mobrpg <command> --help` for a command's own options.

## Typical workflows

Import a world into a vault:
    export MOBRPG_TOKEN=...            # read-only, prod is fine
    mobrpg pull <worldId> --out extract.json
    mobrpg write extract.json --out /path/to/vault
    mobrpg link-orphans extract.json --vault /path/to/vault --out ./orphan_out

Push a vault chapter to mobRPG (safe: suggestions):
    export MOBRPG_TOKEN=...
    mobrpg suggest <worldId> --vault /path/to/vault --chapter chapter-2            # dry-run
    mobrpg suggest <worldId> --vault /path/to/vault --chapter chapter-2 --execute

Confirm the round-trip after a GM accepts them in mobRPG (read-only):
    mobrpg catalog <worldId> political/type                # see existing Types first
    mobrpg suggestions <worldId> --state Accepted --correlate --vault /path/to/vault
                                                            # externalRef -> vault file -> new element id

Keep a linked note's description prose in sync going forward:
    export MOBRPG_TOKEN=...
    mobrpg sync <worldId> --vault /path/to/vault            # dry-run: shows the decision table
    mobrpg sync <worldId> --vault /path/to/vault --execute  # pulls newer canon, files suggestions for newer vault edits