mastracode 0.37.2-alpha.0 → 0.38.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,533 +1,52 @@
1
1
  # Mastra Code
2
2
 
3
- A coding agent that never compacts. Built with [Mastra](https://mastra.ai) and [pi-tui](https://github.com/badlogic/pi-mono).
4
-
5
- Learn more in the [documentation](https://code.mastra.ai/) and [announcement post](https://mastra.ai/blog/announcing-mastra-code).
6
-
7
- ![Screenshot of the Mastra Code TUI. At the top it shows in green letters "Mastra Code". It then displays the version, project, resource ID, and user. The user and assistant message have green borders. At the bottom is a green input field. Below the input is on the left the current mode and model displayed. In the middle the Observational Memory status is shown. On the right is the current directory.](https://res.cloudinary.com/mastra-assets/image/upload/v1778048981/mastracode-init_tny2pb.png)
8
-
9
- ## Features
10
-
11
- - **Observational Memory built-in**: Never deal with compaction again. [Observational Memory](https://mastra.ai/docs/memory/observational-memory) automatically extracts and stores observations from every conversation, then injects relevant context into future requests.
12
- - **Multi-model support**: Use Claude, GPT, Gemini, and thousands of other models via Mastra's unified model router
13
- - **OAuth login**: Authenticate with Anthropic (Claude Max) and OpenAI (ChatGPT Plus/Codex)
14
- - **Persistent conversations**: Threads are saved per-project and resume automatically
15
- - **Coding tools**: View files, edit code, run shell commands
16
- - **Dynamic workflows**: Build workflows through chat, then list, inspect, run, and delete them from the TUI
17
- - **Goals**: Pursue longer-running objectives with configurable judge models and goal-enabled commands/skills
18
- - **Plan persistence**: Approved plans are saved as markdown files for future reference
19
- - **Token tracking**: Monitor usage with persistent token counts per thread
20
- - **Beautiful TUI**: Polished terminal interface with streaming responses
3
+ Mastra Code is a terminal-based AI coding agent distributed as the `mastracode` package. It combines persistent project-scoped conversations, multiple model providers, coding tools, goals, plugins, dynamic workflows, and Observational Memory so long-running work does not depend on context-window compaction.
21
4
 
22
5
  ## Installation
23
6
 
24
- Install `mastracode` globally with your package manager of choice.
7
+ Mastra Code requires Node.js 22.19.0 or later. Install the CLI globally:
25
8
 
26
9
  ```bash
27
10
  npm install -g mastracode
28
11
  ```
29
12
 
30
- If you prefer not to install packages globally, you can use `npx`:
31
-
32
- ```bash
33
- npx mastracode
34
- ```
35
-
36
- On first launch, an interactive onboarding wizard guides you through:
37
-
38
- 1. **Authentication**: Log in with your AI provider (Anthropic, OpenAI, etc.)
39
- 2. **Model packs**: Choose default models for each mode (build / plan / fast)
40
- 3. **Observational Memory**: Pick a model for OM (learns about you over time)
41
- 4. **YOLO mode**: Auto-approve tool calls, or require manual confirmation
42
-
43
- You can re-run setup anytime with `/setup`.
44
-
45
- ## Prerequisites
46
-
47
- ### Optional: `fd` for file autocomplete
48
-
49
- The `@` file autocomplete feature uses [`fd`](https://github.com/sharkdp/fd), a fast file finder that respects `.gitignore`. Without it, `@` autocomplete silently does nothing.
50
-
51
- Install with your package manager:
13
+ To use the programmatic API or build a custom TUI, install it as a project dependency instead:
52
14
 
53
15
  ```bash
54
- # macOS
55
- brew install fd
56
-
57
- # Ubuntu/Debian
58
- sudo apt install fd-find
59
-
60
- # Arch
61
- sudo pacman -S fd
16
+ npm install mastracode
62
17
  ```
63
18
 
64
- On Ubuntu/Debian the binary is called `fdfind` — mastracode detects both `fd` and `fdfind` automatically.
65
-
66
19
  ## Usage
67
20
 
68
- ### Starting a conversation
69
-
70
- Type your message and press Enter. If the agent is already working, Enter queues your next message and sends it after the current run finishes.
71
-
72
- ### `@` file references
73
-
74
- Type `@` followed by a partial filename to fuzzy-search project files and reference them in your message. This requires `fd` to be installed (see [Prerequisites](#prerequisites)).
75
-
76
- - `@setup` — fuzzy-matches files like `setup.ts`, `setup.py`, etc.
77
- - `@src/tui` — scoped search within a directory
78
- - `@"path with spaces"` — quoted form for paths containing spaces
79
-
80
- Select a suggestion with arrow keys and press Tab to insert it.
81
-
82
- ### Slash commands
83
-
84
- | Command | Description |
85
- | ------------------- | --------------------------------------------------------------------------- |
86
- | `/new` | Start a new conversation thread |
87
- | `/threads` | List and switch between threads with freshness-checked cached lazy previews |
88
- | `/models` | Switch/manage model packs (built-in/custom) |
89
- | `/custom-providers` | Manage custom OpenAI-compatible providers/models |
90
- | `/mode` | Switch agent mode |
91
- | `/subagents` | Configure subagent model defaults |
92
- | `/memory` | Configure Observational Memory (`/om` alias) |
93
- | `/think` | Set thinking level (Anthropic) |
94
- | `/judge` | Configure the default judge model and max attempts for goals |
95
- | `/goal` | Start or manage an autonomous goal |
96
- | `/skills` | List available skills |
97
- | `/diff` | Show modified files or git diff |
98
- | `/name` | Rename current thread |
99
- | `/cost` | Show token usage and estimated costs |
100
- | `/context` | Audit what is using the context window (`/ctx` alias) |
101
- | `/profile` | Control process memory diagnostics |
102
- | `/review` | Review a GitHub pull request |
103
- | `/hooks` | Show/reload configured hooks |
104
- | `/mcp` | Show/reload MCP server connections, disable or enable servers |
105
- | `/sandbox` | Manage allowed paths (add/remove dirs) |
106
- | `/permissions` | View/manage tool approval permissions |
107
- | `/plugins` | Install and manage trusted Mastra Code plugins |
108
- | `/workflows` | List, inspect, run, and delete chat-built workflows |
109
- | `/settings` | General settings (notifications, YOLO, etc.) |
110
- | `/yolo` | Toggle YOLO mode (auto-approve all tools) |
111
- | `/resource` | Show/switch resource ID (tag for sharing) |
112
- | `/thread:tag-dir` | Tag current thread with this directory |
113
- | `/connect` | Connect a provider account or API key |
114
- | `/login` | Sign in with a provider account |
115
- | `/logout` | Log out from a provider |
116
- | `/setup` | Re-run the interactive setup wizard |
117
- | `/help` | Show available commands |
118
- | `/exit` | Exit the TUI |
119
-
120
- ### Process memory diagnostics
121
-
122
- Enable process memory diagnostics before startup when you need evidence for memory growth in a long-running TUI or headless process:
21
+ Start Mastra Code from the project you want it to work in:
123
22
 
124
23
  ```bash
125
- MASTRACODE_PROFILE=1 mastracode
24
+ cd your-project
25
+ mastracode
126
26
  ```
127
27
 
128
- > **Warning:** Allocation profiles can contain prompts, credentials, file contents, and tool arguments. Keep the output directory private, don't upload it as telemetry, and delete it after the investigation.
129
-
130
- Use the same process-wide diagnostics instance from the TUI:
131
-
132
- ```text
133
- /profile status
134
- /profile start
135
- /profile capture
136
- /profile stop
137
- ```
138
-
139
- Bare `/profile` is an alias for `/profile status`. Starting an active run preserves its original directory and configuration. `capture` persists a Chrome allocation-sampling profile and starts a new sampling epoch. It doesn't force garbage collection (GC) or write a heap snapshot. `stop` writes a final sample and allocation profile before releasing the profiler.
140
-
141
- #### Configuration
142
-
143
- | Environment variable | Default | Minimum | Description |
144
- | ---------------------------------------------- | --------------------------------- | ------- | ----------------------------------------------------------- |
145
- | `MASTRACODE_PROFILE` | Disabled | N/A | Enables startup profiling for `1`, `true`, `yes`, or `on` |
146
- | `MASTRACODE_PROFILE_DIR` | `<Mastra Code app-data>/profiles` | N/A | Parent directory for private, unique run directories |
147
- | `MASTRACODE_PROFILE_SAMPLE_INTERVAL_MS` | `10000` | `1000` | Process and V8 sample interval in milliseconds |
148
- | `MASTRACODE_PROFILE_CAPTURE_INTERVAL_MS` | `300000` | `10000` | Durable allocation-profile capture interval in milliseconds |
149
- | `MASTRACODE_PROFILE_ALLOCATION_INTERVAL_BYTES` | `524288` | `32768` | V8 allocation-sampling interval in bytes |
150
-
151
- Truthy values are case-insensitive and may contain surrounding whitespace. Other values leave startup profiling disabled. When startup profiling is enabled, invalid numeric values produce an actionable warning and leave Mastra Code running without an active profiler.
152
-
153
- Each run gets a unique directory under the configured parent with these files:
154
-
155
- - `metadata.json`: Immutable runtime and configuration metadata
156
- - `process-samples.jsonl`: Append-only RSS, JavaScript heap, external memory, ArrayBuffer memory, resource usage, and V8 heap-space samples
157
- - `gc-events.jsonl`: Append-only GC kind, flags, duration, and nearby memory values when V8 emits GC performance entries. A run can contain zero events.
158
- - `allocation-<sequence>-<timestamp>.heapprofile`: Atomic Chrome allocation-sampling profiles
159
-
160
- Mastra Code requests mode `0700` for run directories and `0600` for files on POSIX systems. Other platforms may apply permissions differently.
161
-
162
- Compare JavaScript heap growth with resident set size (RSS). Rising heap-space usage points to retained JavaScript objects. Rising RSS with a stable JavaScript heap can point to external buffers, ArrayBuffers, native libraries, memory-mapped files, or allocator behavior. Allocation profiles include objects collected by major and minor GC, which helps distinguish sustained retention from transient allocation pressure.
163
-
164
- Sampling and periodic file writes add overhead. Larger allocation intervals and longer capture intervals reduce it. Manual capture briefly rotates the sampling epoch.
165
-
166
- Atomically completed captures survive later `SIGINT`, `SIGTERM`, `SIGHUP`, `SIGKILL`, or native crashes. The TUI writes a final capture for handled graceful signals and awaited fatal errors. Immediate `SIGKILL`, native crashes, power loss, and other abrupt termination can't guarantee a final capture, so the periodic capture interval protects those cases.
167
-
168
- Delete the run directory when the investigation is complete. Never commit captured profiles.
169
-
170
- ### Dynamic workflows
171
-
172
- Create a workflow by describing it in build-mode chat. For example:
173
-
174
- ```text
175
- Build me a workflow that accepts a topic, researches it, and returns a concise summary.
176
- ```
177
-
178
- Mastra Code discovers the registered agents, tools, and workflows, builds a complete workflow definition, validates it, and saves it for future sessions. Workflow creation is chat-driven; `/workflows` manages workflows that have already been saved.
179
-
180
- ```text
181
- /workflows list
182
- /workflows show research-summary
183
- /workflows run research-summary {"topic":"dynamic workflows"}
184
- /workflows delete research-summary
185
- ```
186
-
187
- Run `/workflows help` for the full command reference.
188
-
189
- ### Plugins
190
-
191
- Use `/plugins` to install and manage trusted local or GitHub plugins. Plugins can add tools, commands, skills, and system instructions. Because plugins execute code inside Mastra Code and their instructions are appended to the agent prompt, only install plugins from sources you trust.
192
-
193
- ### Goals
194
-
195
- Use `/goal <objective>` to have Mastra Code keep working toward an objective across turns. Goals use a judge model to decide whether the goal is complete, should continue, or should wait for an explicit user checkpoint. Configure defaults with `/judge`.
196
-
197
- Goal objectives can span multiple lines:
198
-
199
- ```text
200
- /goal Fix the failing release checks
201
- and open a PR when everything passes.
202
- ```
203
-
204
- When a plan is submitted with `submit_plan`, the inline approval UI also includes **Use as /goal**. That saves/approves the plan and starts a goal using the plan text as the objective.
205
-
206
- Custom slash commands can opt into goal mode with top-level frontmatter:
207
-
208
- ```md
209
- ---
210
- name: pr-triage
211
- description: Triage open PRs
212
- goal: true
213
- ---
214
-
215
- Inspect every open PR before pair-reviewing candidates.
216
- ```
217
-
218
- Run goal-enabled commands with `/goal/<command-name>`. The processed command content becomes the goal objective, so `$ARGUMENTS` and other command template features still apply.
219
-
220
- Skills can opt into goal mode with skill metadata:
221
-
222
- ```md
223
- ---
224
- name: review-prs
225
- description: Review pull requests
226
- metadata:
227
- goal: true
228
- ---
229
-
230
- Review PRs until all relevant candidates have been categorized.
231
- ```
232
-
233
- Run goal-enabled skills with `/goal/<skill-name>`. Skill instructions become the goal objective; any extra arguments are included as context.
234
-
235
- ### Keyboard shortcuts
236
-
237
- | Shortcut | Action |
238
- | ----------- | --------------------------------------------------------------- |
239
- | `Ctrl+C` | Interrupt current operation or clear input |
240
- | `Ctrl+C` ×2 | Exit (double-tap) |
241
- | `Ctrl+D` | Exit (when editor is empty) |
242
- | `Ctrl+Z` | Suspend process (`fg` to resume) |
243
- | `Alt+Z` | Undo last clear |
244
- | `Ctrl+T` | Toggle thinking blocks visibility |
245
- | `Ctrl+E` | Expand/collapse all tool outputs |
246
- | `Enter` | Send a message, or queue a follow-up while the agent is running |
247
- | `Ctrl+Y` | Toggle YOLO mode |
248
-
249
- ## Configuration
250
-
251
- ### Custom config directory
252
-
253
- By default, Mastra Code reads and writes project config from `.mastracode/` and global config from `~/.mastracode/` plus `~/.config/mastracode/`.
254
-
255
- If you embed Mastra Code programmatically, you can override that directory name with `createMastraCode({ configDir: '.your-config-dir' })`.
256
-
257
- This remaps the project-level and global config locations that Mastra Code uses for MCP server configs, hooks, slash commands, agent instructions, skills, and the legacy `database.json` lookup.
258
-
259
- ```ts
260
- import { createMastraCode } from 'mastracode';
261
-
262
- const mastraCode = await createMastraCode({
263
- configDir: '.acme-code',
264
- });
265
- ```
266
-
267
- `configDir` must be a single directory name. Absolute paths, `.` / `..`, and names containing `/` or `\` are rejected.
268
-
269
- ### Project-based threads
270
-
271
- Threads are automatically scoped to your project based on:
272
-
273
- 1. Git remote URL (if available)
274
- 2. Absolute path (fallback)
275
-
276
- This means conversations are shared across clones, worktrees, and SSH/HTTPS URLs of the same repository.
277
-
278
- ### Database location
279
-
280
- The SQLite database is stored in your system's application data directory:
281
-
282
- - **macOS**: `~/Library/Application Support/mastracode/`
283
- - **Linux**: `~/.local/share/mastracode/`
284
- - **Windows**: `%APPDATA%/mastracode/`
285
-
286
- ### Authentication
287
-
288
- For **Anthropic** models, mastracode supports two authentication methods:
289
-
290
- 1. **Claude Max OAuth (primary)**: Use `/connect` to authenticate with a Claude Pro/Max subscription.
291
- 2. **API key (fallback)**: Set the `ANTHROPIC_API_KEY` environment variable for direct API access. This is used when not logged in via OAuth.
292
-
293
- When both are available, Claude Max OAuth takes priority.
294
-
295
- For **other providers** (OpenAI, Google, etc.), set the corresponding environment variable (e.g., `OPENAI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`) or use OAuth where supported.
296
-
297
- For **Amazon Bedrock**, mastracode authenticates with AWS SigV4 through the standard AWS credential chain — environment variables (`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN`), a shared `~/.aws` profile (`AWS_PROFILE`, including SSO), or a container/instance role all work, the same resolution order as the AWS CLI. Set `AWS_REGION` (defaults to `us-east-1`) to choose a region. Select Bedrock models with the `amazon-bedrock/<modelId>` form, where `<modelId>` is any Bedrock model ID surfaced via `/models`. To use Bedrock API-key auth instead of SigV4, set `AWS_BEARER_TOKEN_BEDROCK`.
298
-
299
- Credentials are stored alongside the database in `auth.json`.
300
-
301
- ### Custom providers and models
302
-
303
- Use `/custom-providers` to manage OpenAI-compatible providers with:
304
-
305
- - provider `name`
306
- - provider `url`
307
- - optional provider `apiKey`
308
- - one or more custom model IDs per provider
309
-
310
- Once saved, provider models appear in existing selectors like `/models` and `/subagents` and can be selected like built-in models.
311
-
312
- Custom providers are stored in `settings.json` in the same app data directory. If you save an API key, it is stored locally in plaintext, so use a machine/user profile you trust.
313
-
314
- ### macOS sleep prevention
315
-
316
- On macOS, Mastra Code starts the built-in `caffeinate` utility while the agent is actively running, then stops it as soon as the run completes, errors, aborts, or the TUI exits. Idle sessions do not keep your machine awake.
317
-
318
- To disable this behavior, set `MASTRACODE_DISABLE_CAFFEINATE=1` before launching Mastra Code:
319
-
320
- ```bash
321
- export MASTRACODE_DISABLE_CAFFEINATE=1
322
- ```
323
-
324
- ### Plan persistence
325
-
326
- When you approve a plan (via `submit_plan`) or choose **Use as /goal** from the inline plan approval UI, it is saved as a markdown file in the app data directory:
327
-
328
- - **macOS**: `~/Library/Application Support/mastracode/plans/<resourceId>/`
329
- - **Linux**: `~/.local/share/mastracode/plans/<resourceId>/`
330
- - **Windows**: `%APPDATA%/mastracode/plans/<resourceId>/`
331
-
332
- Files are named `<timestamp>-<slugified-title>.md` and contain the plan title, approval timestamp, and full plan body.
333
-
334
- To save plans to a project-local directory instead, set the `MASTRA_PLANS_DIR` environment variable:
335
-
336
- ```bash
337
- export MASTRA_PLANS_DIR=.mastracode/plans
338
- ```
339
-
340
- ### Web UI: optional auth & GitHub projects
341
-
342
- The web UI (`mastracode web`) supports optional WorkOS authentication and a GitHub App
343
- integration. Both are off by default — when their environment variables are absent the web UI
344
- behaves exactly as before.
345
-
346
- **WorkOS auth** — when `WORKOS_API_KEY` and `WORKOS_CLIENT_ID` are set, every route requires a
347
- signed-in user (hosted login + encrypted session):
348
-
349
- ```bash
350
- export WORKOS_API_KEY=...
351
- export WORKOS_CLIENT_ID=...
352
- export WORKOS_REDIRECT_URI=https://your-host/auth/callback # optional
353
- export WORKOS_COOKIE_PASSWORD=... # optional (recommended in prod)
354
- ```
355
-
356
- On first authenticated use, a user with no WorkOS organization is automatically given a personal
357
- org (the org is created and the user added as a member), so org-scoped features work without
358
- hand-creating an org in the WorkOS dashboard. The WorkOS API key must be allowed to create
359
- organizations and memberships; if it isn't, bootstrap fails soft (logged) and the user keeps the
360
- `organization_required` response.
361
-
362
- **GitHub projects** — when the GitHub App variables are set _and_ WorkOS auth is enabled,
363
- signed-in users can install the GitHub App, pick repositories, and turn each repo into a project.
364
- The tenant boundary is the **WorkOS organization**: the GitHub App installation and the connected
365
- project (repo) are owned by the org, while each user inside the org gets their own isolated
366
- sandbox, worktrees, branches, and PRs against that repo. The **same repo can be connected
367
- independently by different orgs** without ever seeing each other's projects, sandboxes, or state.
368
- Personal accounts are bootstrapped into a personal org on first use (see above), so they can
369
- connect GitHub projects too; users always get isolated agent state regardless. Repo and project
370
- metadata persist in a separate application Postgres (`APP_DATABASE_URL`):
371
-
372
- ```bash
373
- export GITHUB_APP_ID=...
374
- export GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
375
- export GITHUB_APP_CLIENT_ID=...
376
- export GITHUB_APP_CLIENT_SECRET=...
377
- export GITHUB_APP_SLUG=your-app-slug
378
- export APP_DATABASE_URL=postgres://user:pass@host:5432/db
379
- export GITHUB_APP_REDIRECT_URI=https://your-host/auth/github/callback # optional
380
- ```
381
-
382
- GitHub-backed projects are cloned into an isolated cloud sandbox on open, which requires a
383
- sandbox provider. Railway is the first supported backend:
384
-
385
- ```bash
386
- export RAILWAY_API_TOKEN=...
387
- export RAILWAY_ENVIRONMENT_ID=...
388
- export MASTRACODE_SANDBOX_PROVIDER=railway # optional (default when a token is set)
389
- export MASTRACODE_SANDBOX_WORKDIR=/workspace # optional (path inside the sandbox)
390
- export MASTRACODE_SANDBOX_IDLE_MINUTES=30 # optional (idle teardown window; default 30)
391
- ```
392
-
393
- The sandbox template must have `git` and `gh` (the GitHub CLI) installed and outbound network
394
- access to `github.com`. `gh` is only required to open pull requests; clone/open work without it.
395
- Idle sandboxes are stopped by the provider after `MASTRACODE_SANDBOX_IDLE_MINUTES`; the next open
396
- detects the stopped VM and re-provisions automatically.
397
- Without a sandbox provider, users can still connect GitHub and pick repos, but opening a repo
398
- project shows a clear "sandbox not configured" error.
399
-
400
- ### Storage
401
-
402
- All agent state (threads, messages, memory, observational memory, recall vectors) persists in the
403
- single application Postgres (`APP_DATABASE_URL`) alongside the GitHub project metadata — one shared
404
- database, with users separated by `resourceId` scoping. Without `APP_DATABASE_URL` (bare local
405
- dev), agent state falls back to a local libSQL file.
406
-
407
- ### Multi-replica deployment
408
-
409
- The web server serializes per-user git write operations. For hosted, multi-replica deployments a
410
- few settings make this safe and bounded:
411
-
412
- ```bash
413
- # Replica-stable state signing — REQUIRED across replicas. Without an explicit
414
- # GITHUB_APP_WEBHOOK_SECRET (or WORKOS_COOKIE_PASSWORD) the OAuth/install state
415
- # is signed with a per-process random key and callbacks fail on other replicas.
416
- export GITHUB_APP_WEBHOOK_SECRET=...
417
-
418
- # Cross-replica serialization of per-(project,user) git writes via Postgres
419
- # advisory locks (default on, requires APP_DATABASE_URL). Set 0 for local dev.
420
- export MASTRACODE_DISTRIBUTED_LOCK=1
421
-
422
- # Per-replica cap on concurrently live sandboxes (0 / unset = unlimited).
423
- export MASTRACODE_MAX_SANDBOXES=50
424
- ```
425
-
426
- ## Architecture
427
-
428
- ```
429
- ┌─────────────────────────────────────────────────────────────┐
430
- │ TUI │
431
- │ (pi-tui components: Editor, Markdown, Loader, etc.) │
432
- └─────────────────────────────────────────────────────────────┘
433
- │
434
- ▼
435
- ┌─────────────────────────────────────────────────────────────┐
436
- │ Harness │
437
- │ - Mode management (plan, build, review) │
438
- │ - Thread/message persistence │
439
- │ - Event system for TUI updates │
440
- │ - State management with Zod schemas │
441
- └─────────────────────────────────────────────────────────────┘
442
- │
443
- ▼
444
- ┌─────────────────────────────────────────────────────────────┐
445
- │ Mastra Agent │
446
- │ - Dynamic model selection │
447
- │ - Tool execution (view, edit, bash) │
448
- │ - Memory integration │
449
- └─────────────────────────────────────────────────────────────┘
450
- │
451
- ▼
452
- ┌─────────────────────────────────────────────────────────────┐
453
- │ LibSQL Storage │
454
- │ - Thread persistence │
455
- │ - Message history │
456
- │ - Token usage tracking │
457
- └─────────────────────────────────────────────────────────────┘
458
- ```
459
-
460
- ## Development
461
-
462
- Mastra Code lives inside the [mastra monorepo](https://github.com/mastra-ai/mastra). All commands below assume you have cloned the repo and are in the repository root.
463
-
464
- ### Setup
465
-
466
- ```bash
467
- # Install dependencies (from repo root)
468
- pnpm i
469
-
470
- # Build all packages (required before first run)
471
- pnpm build
472
- ```
473
-
474
- ### Running from source
28
+ Or run it without a global installation:
475
29
 
476
30
  ```bash
477
- # Run the TUI directly via tsx (from repo root)
478
- pnpx tsx mastracode/src/main.ts
479
- ```
480
-
481
- ### Building
482
-
483
- ```bash
484
- # Build only the mastracode package (and its dependencies)
485
- pnpm build:mastracode
486
-
487
- # Build the library bundle (from mastracode/)
488
- pnpm --filter ./mastracode run build:lib
489
- ```
490
-
491
- ### Type checking
492
-
493
- ```bash
494
- # Type-check mastracode
495
- pnpm --filter ./mastracode run check
496
- ```
497
-
498
- ### Linting
499
-
500
- ```bash
501
- # Lint mastracode
502
- pnpm --filter ./mastracode run lint
503
- ```
504
-
505
- ### Testing
506
-
507
- ```bash
508
- # Run unit tests
509
- pnpm --filter ./mastracode test
510
-
511
- # Run e2e smoke tests
512
- pnpm --filter ./mastracode run e2e:smoke
31
+ npx mastracode
513
32
  ```
514
33
 
515
- ### Web UI development
34
+ On first launch, the onboarding wizard connects a model provider, configures model packs and Observational Memory, and asks whether tool calls should require approval. Run `/setup` to repeat onboarding later.
516
35
 
517
- ```bash
518
- # Start the web UI dev server (API + Vite)
519
- pnpm --filter ./mastracode run web:dev
36
+ ## Documentation
520
37
 
521
- # With GitHub App integration (starts Postgres first)
522
- pnpm --filter ./mastracode run web:dev:github
523
- ```
38
+ - [Get started with Mastra Code](https://code.mastra.ai/)
39
+ - [Configure providers, storage, hooks, MCP servers, and diagnostics](https://code.mastra.ai/configuration)
40
+ - [Use Build, Plan, and Fast modes](https://code.mastra.ai/modes)
41
+ - [Run persistent goals](https://code.mastra.ai/goals)
42
+ - [Use Mastra Code in headless and CI environments](https://code.mastra.ai/headless)
43
+ - [Customize or embed Mastra Code](https://code.mastra.ai/customization)
44
+ - [Mastra Code API reference](https://code.mastra.ai/reference)
524
45
 
525
- ## Credits
46
+ ## Changelog
526
47
 
527
- - [Mastra](https://mastra.ai): AI agent framework
528
- - [pi-mono](https://github.com/badlogic/pi-mono): TUI primitives and inspiration
529
- - [OpenCode](https://github.com/sst/opencode): OAuth provider patterns
48
+ See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/mastracode/tui/CHANGELOG.md) for version history and release notes.
530
49
 
531
- ## License
50
+ ## Support
532
51
 
533
- Apache-2.0
52
+ We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_tui = require("./tui-6hj9vk8e.cjs");
2
+ const require_tui = require("./tui-DpWB9pec.cjs");
3
3
  let _mastra_code_sdk = require("@mastra/code-sdk");
4
4
  let fs = require("fs");
5
5
  fs = require_tui.__toESM(fs, 1);
@@ -41,7 +41,7 @@ function createShutdownCoordinator(cleanup, exit, timeoutMs = 5e3) {
41
41
  //#endregion
42
42
  //#region src/version.ts
43
43
  function getCurrentVersion() {
44
- return "0.37.2-alpha.0";
44
+ return "0.38.0-alpha.10";
45
45
  }
46
46
  //#endregion
47
47
  //#region src/main.ts
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-BmSN1-9K.js";
2
+ import { d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-DrUt7rlK.js";
3
3
  import { createMastraCode } from "@mastra/code-sdk";
4
4
  import fs from "fs";
5
5
  import { createMastraCodeAnalytics } from "@mastra/code-sdk/analytics";
@@ -40,7 +40,7 @@ function createShutdownCoordinator(cleanup, exit, timeoutMs = 5e3) {
40
40
  //#endregion
41
41
  //#region src/version.ts
42
42
  function getCurrentVersion() {
43
- return "0.37.2-alpha.0";
43
+ return "0.38.0-alpha.10";
44
44
  }
45
45
  //#endregion
46
46
  //#region src/main.ts
@@ -1 +1 @@
1
- {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/github.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAuMtD,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAmFtG"}
1
+ {"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/github.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAiqBtD,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BtG"}
@@ -1 +1 @@
1
- {"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/new.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgC9E"}
1
+ {"version":3,"file":"new.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/new.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,wBAAsB,gBAAgB,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC9E"}
@@ -0,0 +1,70 @@
1
+ import { Box } from '@earendil-works/pi-tui';
2
+ import type { Focusable, TUI } from '@earendil-works/pi-tui';
3
+ export interface GithubPRPickerItem {
4
+ owner?: string;
5
+ repo?: string;
6
+ number: number;
7
+ title?: string;
8
+ author?: string;
9
+ updatedAt?: string;
10
+ url?: string;
11
+ headRefName?: string;
12
+ baseRefName?: string;
13
+ }
14
+ export interface GithubPRPickerOptions {
15
+ tui: TUI;
16
+ pullRequests: GithubPRPickerItem[];
17
+ searchPullRequests?: GithubPRPickerItem[];
18
+ subscribedIds?: Set<string>;
19
+ title?: string;
20
+ loadingMessage?: string;
21
+ errorMessage?: string;
22
+ onConfirm: (pullRequests: GithubPRPickerItem[]) => void;
23
+ onCancel: () => void;
24
+ }
25
+ export declare function githubPRId(pr: {
26
+ owner?: string;
27
+ repo?: string;
28
+ number: number;
29
+ }): string;
30
+ export declare class GithubPRPickerDialog extends Box implements Focusable {
31
+ private searchInput;
32
+ private listContainer;
33
+ private viewTabs;
34
+ private currentView;
35
+ private myPullRequests;
36
+ private searchPullRequests;
37
+ private filteredPullRequests;
38
+ private subscribedIds;
39
+ private selectedIds;
40
+ private highlightedIndex;
41
+ private readonly tui;
42
+ private readonly title;
43
+ private loadingMessage;
44
+ private errorMessage;
45
+ private isLoading;
46
+ private readonly onConfirmCallback;
47
+ private readonly onCancelCallback;
48
+ private _focused;
49
+ get focused(): boolean;
50
+ set focused(value: boolean);
51
+ constructor(options: GithubPRPickerOptions);
52
+ setPullRequests(input: {
53
+ mine: GithubPRPickerItem[];
54
+ search?: GithubPRPickerItem[];
55
+ errorMessage?: string;
56
+ }): void;
57
+ private get allPullRequests();
58
+ private getViewPullRequests;
59
+ private buildUI;
60
+ private renderViewTabs;
61
+ private cycleView;
62
+ private filterPullRequests;
63
+ private hasId;
64
+ private toggleSelection;
65
+ private getSelectedPullRequests;
66
+ private confirmSelection;
67
+ private updateList;
68
+ handleInput(keyData: string): void;
69
+ }
70
+ //# sourceMappingURL=github-pr-picker.d.ts.map