Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

6.4 KB
Raw Blame

Seed CLI

Used to populate your local environment with sample data.

Please ensure you have read RUNNING_LOCALLY and have your local environment setup.

Usage

You can explore the CLI and it's usage with just seed help. All commands can be run through the just seed base command.

Scenarios

CRM sample data in an existing local team

Enable CRM for your local team in Settings → CRM, then run from the repository root:

nix develop --command bun tooling/seed_cli/seed-crm.ts \
  --origin https://localhost:23209 --email [email protected]

Use your instance's HTTPS proxy port and local account email. The seed adds eight companies, twelve contacts, and three populated pipelines: team-shared Demo Sales and Demo Contacts, plus private Demo Design Partners. Rows include stages, assigned and unassigned owners, revenue, and a custom Notes column. Companies also get legacy CRM Stage, Owner, and Revenue values for testing the overview and board. Existing team stages are reused; the default set spans Lead through Churned.

This uses the running app's APIs and local passwordless authentication. It does not reset the database. Reruns reuse companies by domain, contacts by email, pipelines by name and record type, and rows by their company/contact reference; existing values and sharing choices are preserved. Fixture data is in seed/crm.json.

Channel access test data

Seed an isolated set of channel-testing personas into your running instance:

just seed-scenario apply --file seed/scenarios/channel-access.json
just seed-scenario matrix --file seed/scenarios/channel-access.json
just seed-scenario status --file seed/scenarios/channel-access.json

These commands target the default stack. For a named stack, add --instance <name> before apply, matrix, or status (for example, --instance channel-access). Include --port-base if you started with one. The scenario creates four users with emails ending in @channel-access.seed.macro.local: Alex (owner), Morgan (member), Riley (requester), and Sam (outsider). Alex, Morgan, and Riley share a team; Sam does not.

Alex owns the private request-approve, request-deny, and request-cancel channels, with Morgan as an existing member. Riley and Sam initially have no access. Sign in as Riley or Sam and open public-lobby, which all four personas can read. Follow Alex's private-channel links there to reach the denied-access entry point. These links stay on the current app origin, so they work across stack ports and hostnames. The already-member channel includes Riley; public and team lobbies plus an Alex–Morgan DM provide comparison cases. Messages describe each case. No requests or decisions are pre-created; this fixture prepares membership prerequisites and does not implement channel requests.

The command prints separate persona login links. For remote access, use the stack's HTTPS origin and separate browser profiles for simultaneous accounts. Reapplying resets this scenario's channels and messages; use status when you want to inspect an existing test run.

Permission scenarios

A scenario file describes a complete world — users, teams, channels, and entities (documents, tasks, projects, chats, calls, emails, messages) with the access edges between them — so varied permission patterns are testable locally. Tasks are markdown documents with the task subtype plus status and assignee properties (and an optional share-with-team grant). See seed/scenarios/team-perms.json for the reference example.

# From the repository root (postgres + localstack must be up):
just seed-scenario apply --file seed/scenarios/team-perms.json
just seed-scenario matrix --file seed/scenarios/team-perms.json
just seed-scenario status --file seed/scenarios/team-perms.json  # or no --file
just seed-scenario reset --file seed/scenarios/team-perms.json   # or --all

# Target a named `run_local --instance 2508` stack.
just seed-scenario --instance 2508 apply --file seed/scenarios/team-perms.json
  • apply deletes the scenario's own rows first and re-seeds, so it always converges on the config. Every seeded id is derived from (scenario, kind, key) and starts with the 5eed marker — rows created through the app (random ids) are never touched, though content living inside a seeded container dies with it on re-apply (e.g. messages you sent in a seeded channel, which is recreated).
  • apply --force is the pristine-world variant: it drops the local database entirely, re-runs migrations, and then seeds — everything goes, organic data included. Open the printed persona links afterwards to log back in.
  • matrix computes the expected access level for every (user, entity) pair from the config and verifies it against the live database using the real entity_access service; it exits non-zero on any mismatch.
  • status is read-only: with --file it reports which of the scenario's rows are present (per kind, with missing keys), whether the FusionAuth accounts and sync-service content exist, and re-prints the persona login links. Without --file it discovers every applied scenario by its id marker and reports on the ones matching a file in seed/scenarios/. Scenarios with distinct names (and distinct user emails) coexist in one database — ids are namespaced by a hash of the scenario name.
  • reset deletes exactly the rows carrying the scenario's id marker, plus (with --file) the scenario's user accounts by email. reset --all cannot know emails, so accounts created through the signup webhook survive it.
  • apply creates each user's FusionAuth account first (the signup webhook writes the base rows, which the seeder then adopts), so every seeded user can log in through the real passwordless flow. If FusionAuth is unreachable, apply seeds database rows only and says so.
  • To drive several personas at once in one browser window, open the links apply prints (http://alice.localhost:3000/app/login?email=…) as plain tabs. Hostnames get separate cookie jars (ports don't), the app follows the page hostname to the backend proxy, and locally the login completes itself (the local backend returns the one-time code and dev builds auto-submit it) — so each link logs its persona straight in, one live session per tab against the same stack. For manual logins outside a dev build, the one-time codes land in mailpit (just status_local prints its UI address).