|
| 1 | +# Relay CLI workflows |
| 2 | + |
| 3 | +Use JSON mode for deterministic agent work. Keep request and preview files temporary and avoid displaying them unless troubleshooting. |
| 4 | + |
| 5 | +## Resolve only the needed contract |
| 6 | + |
| 7 | +Run: |
| 8 | + |
| 9 | +```text |
| 10 | +mex relay contract --action <command-id> --json |
| 11 | +``` |
| 12 | + |
| 13 | +Use one of these command IDs: |
| 14 | + |
| 15 | +- `relay.draft.save` |
| 16 | +- `relay.draft.delete` |
| 17 | +- `relay.publish` |
| 18 | +- `relay.acknowledge` |
| 19 | +- `relay.close` |
| 20 | + |
| 21 | +Treat this bounded action result as the exact runtime source for the request shape, available examples, constraints, preview command, and apply command. Do not dump `mex capabilities --json` or the full Relay contract during ordinary execution. Write request and preview JSON only to ordinary regular files inside the checkout or an approved temporary directory; do not use symlinks. |
| 22 | + |
| 23 | +## Resolve recipients and optional context |
| 24 | + |
| 25 | +1. Run `mex member list --active --limit 100 --json`, following bounded cursors when present, and match the user's names or team intent to active Members. |
| 26 | +2. Use `mex member show <member-id> --json` when a candidate needs disambiguation or a current artifact revision is required. |
| 27 | +3. Stop and ask for recipient clarification when multiple active Members remain plausible, no active Member matches, or bounded results cannot prove uniqueness. Relay stores individual Members, so never fabricate a group for “the backend team.” |
| 28 | +4. Default to no Workstream lookup. If the user named a Workstream or the handoff clearly belongs to an existing one, run `mex workstream list --json` and `mex workstream show <workstream-id> --json` to resolve it exactly. |
| 29 | +5. In Relay v3, preserve a relevant Workstream as typed entity evidence when the selected contract supports it; do not author the legacy top-level Workstream field. |
| 30 | + |
| 31 | +Never fabricate recipient IDs, entity IDs, revisions, commits, code fingerprints, paths, URLs, or provenance. |
| 32 | + |
| 33 | +## Save a checkout-local draft |
| 34 | + |
| 35 | +1. Resolve `relay.draft.save`. |
| 36 | +2. Create a unique operation ID and a standalone draft with active recipient references and a concise summary. |
| 37 | +3. Include only useful non-empty context sections. Prefer accurate omissions over invented completeness. |
| 38 | +4. For a new draft, provide no unrelated expectations. For an existing draft update, read it with `mex relay draft show <draft-id> --json` and use its exact local revision. |
| 39 | +5. Preview with `mex relay draft save <request-file> --json` and capture the complete successful JSON wrapper unchanged. Require `ok: true`, `mode: "preview"`, and `data.preview.valid: true`. |
| 40 | +6. Summarize recipients and continuation state. If the user asked to create/save/draft, apply with `mex relay draft save --apply <preview-envelope> --json` without another confirmation. |
| 41 | +7. Read the returned draft ID and respond with `/relays?view=drafts&draft=<id>`. |
| 42 | + |
| 43 | +The apply writes only checkout-local draft state in `.mex/local/team.db`. It does not create a canonical Relay or Activity record, deliver a handoff, commit, push, or notify anyone. Apply before the preview expires; if anything changes or the preview becomes stale, preview again instead of reconstructing it. |
| 44 | + |
| 45 | +## Delete a local draft |
| 46 | + |
| 47 | +1. Read the exact draft and current local revision. |
| 48 | +2. Resolve and preview `relay.draft.delete`. |
| 49 | +3. Explain that the checkout-local draft will be deleted and wait for fresh confirmation. |
| 50 | +4. Apply the captured preview unchanged with `mex relay draft delete --apply <preview-envelope> --json`. |
| 51 | + |
| 52 | +## Publish a Relay |
| 53 | + |
| 54 | +1. Read the exact draft and every active recipient Member required by the selected contract. |
| 55 | +2. Resolve `relay.publish`, build exact draft/member expectations, and preview with `mex relay publish <request-file> --json`. |
| 56 | +3. Explain that applying replaces the private local draft with canonical Git-tracked Relay and Activity records in the working tree, records the service-observed branch/HEAD/dirty repository state without copying dirty source contents, and does not deliver through a notification service or share before Git commit/push and teammate pull/refresh. |
| 57 | +4. Wait for fresh explicit confirmation. |
| 58 | +5. Apply the exact preview with `mex relay publish --apply <preview-envelope> --json`. |
| 59 | +6. Return `/relays?view=sent&state=open&relay=<relay-id>`. |
| 60 | + |
| 61 | +## Take a Relay |
| 62 | + |
| 63 | +1. Resolve the exact published Relay with `mex relay show <relay-id> --json` and verify that the current actor is an intended active recipient. |
| 64 | +2. Resolve `relay.acknowledge` and preview with `mex relay acknowledge <request-file> --json`. |
| 65 | +3. Explain that applying makes the current recipient the sole claimant, prevents another recipient from taking it, and writes canonical Relay/Activity state in the working tree. There is no unclaim or reassignment action, and it does not assign or start a task elsewhere. |
| 66 | +4. Wait for fresh explicit confirmation, then apply the exact preview with `mex relay acknowledge --apply <preview-envelope> --json`. |
| 67 | +5. Return `/relays?view=mine&state=open&relay=<relay-id>`. |
| 68 | + |
| 69 | +## Close a Relay |
| 70 | + |
| 71 | +1. Resolve the exact acknowledged Relay and its current revision. |
| 72 | +2. Resolve `relay.close` and preview with `mex relay close <request-file> --json`. |
| 73 | +3. Explain that applying irreversibly marks only the handoff as no longer needing attention and writes canonical Relay/Activity state in the working tree. |
| 74 | +4. Wait for fresh explicit confirmation, then apply the exact preview with `mex relay close --apply <preview-envelope> --json`. |
| 75 | +5. Return `/relays?view=all&state=closed&relay=<relay-id>`. |
| 76 | + |
| 77 | +Closing does not complete a linked task, issue, pull request, or Workstream. No lifecycle command stages, commits, pushes, pulls, or sends a notification. |
0 commit comments