mastracode 0.26.0-alpha.6 → 0.26.0
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/CHANGELOG.md +104 -0
- package/dist/{acp-7ADCI4VS.js → acp-G5OLW7EV.js} +4 -4
- package/dist/{acp-7ADCI4VS.js.map → acp-G5OLW7EV.js.map} +1 -1
- package/dist/{acp-4KUBWHJK.cjs → acp-YSYEXVBE.cjs} +6 -6
- package/dist/{acp-4KUBWHJK.cjs.map → acp-YSYEXVBE.cjs.map} +1 -1
- package/dist/agents/modes/plan.d.ts.map +1 -1
- package/dist/agents/prompts/plan.d.ts +5 -4
- package/dist/agents/prompts/plan.d.ts.map +1 -1
- package/dist/agents/tool-availability.d.ts +5 -1
- package/dist/agents/tool-availability.d.ts.map +1 -1
- package/dist/{chunk-SHA3DXLU.js → chunk-GT3A3LAA.js} +119 -41
- package/dist/chunk-GT3A3LAA.js.map +1 -0
- package/dist/{chunk-DVBJN36L.cjs → chunk-KGBCGF6C.cjs} +47 -23
- package/dist/chunk-KGBCGF6C.cjs.map +1 -0
- package/dist/{chunk-IXP7JO6S.js → chunk-LUSQ75XP.js} +122 -66
- package/dist/chunk-LUSQ75XP.js.map +1 -0
- package/dist/{chunk-F3TKSK3C.js → chunk-NDCWIAKG.js} +43 -21
- package/dist/chunk-NDCWIAKG.js.map +1 -0
- package/dist/{chunk-EMEAUCQ7.cjs → chunk-NUKVNLFS.cjs} +1046 -990
- package/dist/chunk-NUKVNLFS.cjs.map +1 -0
- package/dist/{chunk-QPIUDTEY.cjs → chunk-Z3HFSXTB.cjs} +153 -75
- package/dist/chunk-Z3HFSXTB.cjs.map +1 -0
- package/dist/cli.cjs +19 -19
- package/dist/cli.js +4 -4
- package/dist/index.cjs +7 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/processors/plan-rejection-abort.d.ts.map +1 -1
- package/dist/tui/components/plan-approval-inline.d.ts.map +1 -1
- package/dist/tui/handlers/agent-lifecycle.d.ts.map +1 -1
- package/dist/tui/handlers/prompts.d.ts +1 -1
- package/dist/tui/handlers/prompts.d.ts.map +1 -1
- package/dist/tui/render-messages.d.ts.map +1 -1
- package/dist/tui/state.d.ts +8 -2
- package/dist/tui/state.d.ts.map +1 -1
- package/dist/tui.cjs +19 -19
- package/dist/tui.js +2 -2
- package/dist/utils/plan-diff.d.ts +25 -0
- package/dist/utils/plan-diff.d.ts.map +1 -0
- package/dist/utils/plans.d.ts +41 -12
- package/dist/utils/plans.d.ts.map +1 -1
- package/package.json +16 -16
- package/dist/chunk-DVBJN36L.cjs.map +0 -1
- package/dist/chunk-EMEAUCQ7.cjs.map +0 -1
- package/dist/chunk-F3TKSK3C.js.map +0 -1
- package/dist/chunk-IXP7JO6S.js.map +0 -1
- package/dist/chunk-QPIUDTEY.cjs.map +0 -1
- package/dist/chunk-SHA3DXLU.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,109 @@
|
|
|
1
1
|
# mastracode
|
|
2
2
|
|
|
3
|
+
## 0.26.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added a live tokens/sec counter to the MastraCode terminal and web status lines. ([#18501](https://github.com/mastra-ai/mastra/pull/18501))
|
|
8
|
+
|
|
9
|
+
The counter shows how fast the model is generating, measured over decode time only — the window from the first streamed token of a step to when that step finishes. This excludes time-to-first-token, tool execution, and scheduling gaps, so the number reflects real generation speed instead of reading artificially low. Reasoning tokens are included, and the rate is smoothed with an exponential moving average for a stable readout.
|
|
10
|
+
|
|
11
|
+
The last reading stays visible while idle so you can read it after a turn finishes, and it clears when the next turn begins.
|
|
12
|
+
|
|
13
|
+
- Add a browser UI for MastraCode. ([#18364](https://github.com/mastra-ai/mastra/pull/18364))
|
|
14
|
+
|
|
15
|
+
The web app boots the real MastraCode Harness, registers it on a Mastra
|
|
16
|
+
instance, mounts the Harness HTTP routes (via `@mastra/server`) on a Hono
|
|
17
|
+
server, and serves a React UI built with Vite. The UI drives a session over the
|
|
18
|
+
`@mastra/client-js` harness resource (SSE event stream + JSON commands) and
|
|
19
|
+
reaches feature parity with the terminal for the core interactive workflows:
|
|
20
|
+
chat streaming, tool execution, tool approvals, interactive suspensions
|
|
21
|
+
(`ask_user` / `submit_plan` / `request_access`), mode/model switching, thread
|
|
22
|
+
lifecycle, task tracking, goals, notifications, steer/abort, follow-ups, a
|
|
23
|
+
TUI-parity status line (message/reflection budgets and active-goal indicator),
|
|
24
|
+
and project-scoped workspaces with a server-driven directory picker.
|
|
25
|
+
|
|
26
|
+
A full Settings surface mirrors the terminal's configuration commands: model
|
|
27
|
+
selection, behavior (`yolo`, thinking level, notifications, smart editing,
|
|
28
|
+
per-category tool permissions), observational-memory models and thresholds,
|
|
29
|
+
model packs, API keys, and custom providers. These are backed by
|
|
30
|
+
`/api/web/config/*` routes that read and write the same global `settings.json`
|
|
31
|
+
the terminal uses, so configuration stays in sync across the terminal and the
|
|
32
|
+
browser.
|
|
33
|
+
|
|
34
|
+
The web server shares its storage with the registered Harness, and projects
|
|
35
|
+
resolve the same `resourceId` as the terminal, so the two share durable threads
|
|
36
|
+
and observations for a given project. Thread lists are scoped by project path so
|
|
37
|
+
worktrees that share a `resourceId` don't bleed each other's threads.
|
|
38
|
+
|
|
39
|
+
Internally, harness startup is shared through a single base factory with small
|
|
40
|
+
per-environment helpers, so the terminal app and the web server build the exact
|
|
41
|
+
same harness without duplicating wiring. The published `mastracode` package
|
|
42
|
+
remains terminal-only — the web UI lives in the repository for local
|
|
43
|
+
development and is excluded from the published package.
|
|
44
|
+
|
|
45
|
+
Includes a scenario test suite that drives the production stack
|
|
46
|
+
(`MastraClient` → Hono → `@mastra/server` routes → Harness → AIMock) end to end.
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Fixed MastraCode queued follow-up E2E tests to wait for stable terminal output. ([#18507](https://github.com/mastra-ai/mastra/pull/18507))
|
|
51
|
+
|
|
52
|
+
- Reworked plan mode to use named plan files. The agent writes its plan to a markdown file under `.mastracode/plans/` and calls `submit_plan` with the `path` to that file, so multiple plans stay on disk for review. The host validates the submitted path is a `.md` file inside `.mastracode/plans/` before reading it, so the tool can't be pointed at arbitrary files. Plan mode can write any `.md` file inside `.mastracode/plans/` (enforced by a tool guard) but nothing else, submitted plan snapshots are persisted for history replay, revision diffs are computed from a real line-ending-normalized LCS diff and only shown when the change is small relative to the plan, "Request Changes" stops the run immediately with no trailing model output, and diffs only compare revisions of the same plan file. ([#18490](https://github.com/mastra-ai/mastra/pull/18490))
|
|
53
|
+
|
|
54
|
+
- Fixed thread auto-resume selecting the wrong thread in git worktrees by scoping startup selection to threads tagged with the current project path. When Mastra Code detects a matching project thread on a different resource after resourceId drift, it now prompts before cloning and resuming that thread under the current resource; accepting the prompt leaves the old thread untouched and loads the clone, while declining starts fresh and leaves the old resource untouched. ([#18333](https://github.com/mastra-ai/mastra/pull/18333))
|
|
55
|
+
|
|
56
|
+
- Switched internal imports to the canonical `@mastra/core/agent-controller` entrypoint, replacing the deprecated `@mastra/core/harness` path and `Harness` types. Updated the web client to call `getAgentController()` and use the new `AgentControllerEvent` type, renamed the `useHarnessSession` hook to `useAgentControllerSession`, and renamed the `handleHarnessEvent` ACP mapper to `handleAgentControllerEvent`. ([#18510](https://github.com/mastra-ai/mastra/pull/18510))
|
|
57
|
+
|
|
58
|
+
- Resolve all Harness models through gateways. The Harness now builds its available-models catalog, model auth status, mode agents, Observational Memory models, and subagents from the gateways you register, instead of the separate `resolveModel`, `customModelCatalogProvider`, and `modelAuthChecker` config hooks. Removed those three options from `HarnessConfig` (and the `ModelAuthChecker` type) — register a gateway via `gateways` instead. ([#18382](https://github.com/mastra-ai/mastra/pull/18382))
|
|
59
|
+
|
|
60
|
+
`listAvailableModels()` and `getCurrentModelAuthStatus()` are now sourced entirely from gateways: model discovery comes from each gateway's `fetchProviders()` (a network call for gateways like models.dev and Netlify), and auth status is resolved through the same gateway chain the model router uses at run time (`resolveAuth()`, falling back to `getApiKey()`). There is no static provider-registry fallback — everything the model picker shows comes from a gateway.
|
|
61
|
+
|
|
62
|
+
The gateway-chain operations shared by `ModelRouterLanguageModel` and the Harness (gateway merging, model→gateway selection, auth resolution, provider/model listing) are now centralized in a new `GatewayManager` class exported from `@mastra/core`. Both consumers delegate to it, eliminating duplicated logic. `defaultGateways` is still re-exported from the same paths for backward compatibility.
|
|
63
|
+
|
|
64
|
+
- Fixed OAuth logins (such as Anthropic and OpenAI sign-in) not being recognized for the selected model. The model status bar no longer shows a false "missing API key" error, and the `/api-keys` command and web settings panel now display a distinct "oauth" status for providers you are signed into instead of treating them as unset. ([#18503](https://github.com/mastra-ai/mastra/pull/18503))
|
|
65
|
+
|
|
66
|
+
- Added support for reading MCP server config from a project root `.mcp.json` (the file Claude Code uses). Projects that already keep their MCP servers there no longer need a duplicate under `.mastracode/`. The root file sits below `.mastracode/mcp.json` in priority, so project-specific config still wins. ([#18494](https://github.com/mastra-ai/mastra/pull/18494))
|
|
67
|
+
|
|
68
|
+
- MastraCode now passes a deterministic session `id` and `ownerId` to the Harness session. The session id is derived from the project resource ID and is stable across restarts for the same project directory. The owner id is derived from the machine hostname and project root path, tying the session to the local machine. ([#18372](https://github.com/mastra-ai/mastra/pull/18372))
|
|
69
|
+
|
|
70
|
+
- Expand `${VAR}`, `${VAR:-default}`, and bare `$VAR` references in MCP server HTTP headers. Header values such as `"x-api-key": "${MY_API_KEY}"` in `mcp.json` are now resolved from the environment when the config is loaded, instead of being sent verbatim. This matches how Claude Code reads `.mcp.json` and lets header-authenticated HTTP servers pull secrets from the environment. ([#18240](https://github.com/mastra-ai/mastra/pull/18240))
|
|
71
|
+
|
|
72
|
+
- Updated plan and explore modes to declare `availableTools` allowlists so tool visibility is gated at LLM-call time instead of workspace construction. Plan mode includes read-only tools plus plan-file editing and delivery tools; explore mode includes only read-only tools. Build mode remains unrestricted. Workspace creation no longer branches on mode for tool visibility — all modes now share the same workspace instance. ([#18463](https://github.com/mastra-ai/mastra/pull/18463))
|
|
73
|
+
|
|
74
|
+
- Improved plan mode UX: "Request changes" stops the agent via processor-based abort and lets you provide revision feedback via chat. Plan resubmissions show a diff of what changed. Plans save to title-derived filenames (e.g. `add-dark-mode.md`) for multi-plan support. Plan filename displayed in TUI header. ([#18323](https://github.com/mastra-ai/mastra/pull/18323))
|
|
75
|
+
|
|
76
|
+
- Add MastraCode browser tool availability scenarios ([#18498](https://github.com/mastra-ai/mastra/pull/18498))
|
|
77
|
+
|
|
78
|
+
- Updated dependencies [[`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`023766f`](https://github.com/mastra-ai/mastra/commit/023766f44d59b30a50f3a381e33eddde8ab56c00), [`0200e75`](https://github.com/mastra-ai/mastra/commit/0200e7552d02d4221cd6040bf4eddf189a97a156), [`7c9dd77`](https://github.com/mastra-ai/mastra/commit/7c9dd77bd18cb8dc72797e25f1a0fbdc71a11347), [`42d74d5`](https://github.com/mastra-ai/mastra/commit/42d74d5671f95aa6076576e32a9b7d11f13dd208), [`7f9ae70`](https://github.com/mastra-ai/mastra/commit/7f9ae70826b047e5a66218f9e92f20e54a2d791f), [`b4e97e6`](https://github.com/mastra-ai/mastra/commit/b4e97e676232a3a398ef32d3e78faa0c91c5fa1c), [`a0509c7`](https://github.com/mastra-ai/mastra/commit/a0509c731a08aa3ed626557c5338126362856f57), [`06e0d63`](https://github.com/mastra-ai/mastra/commit/06e0d63d42bc2a202e18bc091f3781f409f5e6fb), [`bf3fe49`](https://github.com/mastra-ai/mastra/commit/bf3fe49f9467dbbdb8f9eaf74e0f7971ffb19559), [`01caf93`](https://github.com/mastra-ai/mastra/commit/01caf93d71ae2c1e65f49735cafb531975187426), [`438a971`](https://github.com/mastra-ai/mastra/commit/438a9715c8b4398e5eaf8914a1f19dc8a85dc1de), [`9990965`](https://github.com/mastra-ai/mastra/commit/999096571635a83b42ef40841fd7028cfa630779), [`24ceaea`](https://github.com/mastra-ai/mastra/commit/24ceaea0bdd8609cabbab764380608ca6621a194), [`77518cc`](https://github.com/mastra-ai/mastra/commit/77518ccb5bb8cc684875081e64213dc85cffdbee), [`fbeda0c`](https://github.com/mastra-ai/mastra/commit/fbeda0c0f35def07e6837936dd3a003b2b7c5172), [`8a68844`](https://github.com/mastra-ai/mastra/commit/8a688443013816105a09f89c6afa34b5ff13e26d), [`bb2a13b`](https://github.com/mastra-ai/mastra/commit/bb2a13bb4b32e6bb807200fe7b18ae8fa4322118), [`24ceaea`](https://github.com/mastra-ai/mastra/commit/24ceaea0bdd8609cabbab764380608ca6621a194), [`a73cd1a`](https://github.com/mastra-ai/mastra/commit/a73cd1a62a5e4ca023dcc39ba150029f4f1f74c1), [`24ceaea`](https://github.com/mastra-ai/mastra/commit/24ceaea0bdd8609cabbab764380608ca6621a194), [`c0ffa3c`](https://github.com/mastra-ai/mastra/commit/c0ffa3c897ccd326de880df734740a7f0681a18f), [`462a769`](https://github.com/mastra-ai/mastra/commit/462a769da61850862ca1be3d74134d33078ee6a7), [`0504bf5`](https://github.com/mastra-ai/mastra/commit/0504bf5e8cffc571a4b343326178de371e6f859b), [`fbeda0c`](https://github.com/mastra-ai/mastra/commit/fbeda0c0f35def07e6837936dd3a003b2b7c5172), [`9e45902`](https://github.com/mastra-ai/mastra/commit/9e4590208e745055cecca202e2db0e5c65e17d3c), [`0b5cc47`](https://github.com/mastra-ai/mastra/commit/0b5cc4726dc18d9a685a27520db39ff1b36bb89a), [`87f38a3`](https://github.com/mastra-ai/mastra/commit/87f38a3de03e24731f2dd6f8ed6a60b6722b85a1), [`d5fa3cd`](https://github.com/mastra-ai/mastra/commit/d5fa3cda1788c3cb93a361a3c6ec47de6ba21e98), [`fe98ef2`](https://github.com/mastra-ai/mastra/commit/fe98ef2e66dbfcbd7d645c88c9ee1e67b458a136), [`e1f272d`](https://github.com/mastra-ai/mastra/commit/e1f272d2bf1963c0ccb060f34b103b0b780bbff0), [`6ccf67b`](https://github.com/mastra-ai/mastra/commit/6ccf67bf075753754927a57bc2e1734ba2c820c5), [`26f54af`](https://github.com/mastra-ai/mastra/commit/26f54afb5dbfbbb02d4d09bec4bd7c5029751767), [`793ea0f`](https://github.com/mastra-ai/mastra/commit/793ea0f52f831178837f21c83af6af93bf4ce638), [`825d8de`](https://github.com/mastra-ai/mastra/commit/825d8def9fa64c2bcc3d8dd6b49e09342c3ac5c7), [`507a5c4`](https://github.com/mastra-ai/mastra/commit/507a5c461bdc3136ad80744c0efbb55ce1f18f97), [`5afe423`](https://github.com/mastra-ai/mastra/commit/5afe423e4badf040f1b0d4525183a856fcb8146e), [`307573b`](https://github.com/mastra-ai/mastra/commit/307573b9ff3149b70c79540dbc86f1319b180f29), [`79b3626`](https://github.com/mastra-ai/mastra/commit/79b3626f8d647307eb07c8da14c9073c2699719d), [`c2c1d7b`](https://github.com/mastra-ai/mastra/commit/c2c1d7bb61d2602955f14ed3952f807c2d6eb576), [`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`1505c07`](https://github.com/mastra-ai/mastra/commit/1505c07603f6346bae12aa82f140e8b88ffea9ab), [`f328049`](https://github.com/mastra-ai/mastra/commit/f3280498c324afd2a8d36cd828f5b9f94a2dddc1), [`e545228`](https://github.com/mastra-ai/mastra/commit/e54522856934a5dc030b7b6385771e3548020d59), [`74f447a`](https://github.com/mastra-ai/mastra/commit/74f447a6fae171ac3a6ec2d9e61be171ca46d23c), [`3eb852e`](https://github.com/mastra-ai/mastra/commit/3eb852e5435bc908b800193498103dc724f455b0), [`ffa09e7`](https://github.com/mastra-ai/mastra/commit/ffa09e772a5c92270eabe2090fc42d45bd8ec4b7), [`8c9f1c0`](https://github.com/mastra-ai/mastra/commit/8c9f1c0361d89066f9bcd14a2f69e761b01766c8), [`461a7c5`](https://github.com/mastra-ai/mastra/commit/461a7c501449295287f4f0ee4b0b42344f39fcf8), [`4211472`](https://github.com/mastra-ai/mastra/commit/4211472a5a2bd319c60cd2e42d9109c3eef7ac1c), [`9e45902`](https://github.com/mastra-ai/mastra/commit/9e4590208e745055cecca202e2db0e5c65e17d3c), [`5c0df77`](https://github.com/mastra-ai/mastra/commit/5c0df776c40efa420f8c07a2f3ee66010296618e), [`e940f09`](https://github.com/mastra-ai/mastra/commit/e940f099ef5d18b403e6f2b4937e086a4da857b1)]:
|
|
79
|
+
- @mastra/core@1.47.0
|
|
80
|
+
- @mastra/server@1.47.0
|
|
81
|
+
- @mastra/observability@1.15.2
|
|
82
|
+
- @mastra/memory@1.21.2
|
|
83
|
+
- @mastra/pg@1.14.2
|
|
84
|
+
- @mastra/libsql@1.14.2
|
|
85
|
+
- @mastra/github-signals@0.2.2
|
|
86
|
+
- @mastra/schema-compat@1.3.1
|
|
87
|
+
- @mastra/hono@1.5.2
|
|
88
|
+
- @mastra/mcp@1.12.0
|
|
89
|
+
|
|
90
|
+
## 0.26.0-alpha.8
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- Reworked plan mode to use named plan files. The agent writes its plan to a markdown file under `.mastracode/plans/` and calls `submit_plan` with the `path` to that file, so multiple plans stay on disk for review. The host validates the submitted path is a `.md` file inside `.mastracode/plans/` before reading it, so the tool can't be pointed at arbitrary files. Plan mode can write any `.md` file inside `.mastracode/plans/` (enforced by a tool guard) but nothing else, submitted plan snapshots are persisted for history replay, revision diffs are computed from a real line-ending-normalized LCS diff and only shown when the change is small relative to the plan, "Request Changes" stops the run immediately with no trailing model output, and diffs only compare revisions of the same plan file. ([#18490](https://github.com/mastra-ai/mastra/pull/18490))
|
|
95
|
+
|
|
96
|
+
- Updated dependencies [[`8a68844`](https://github.com/mastra-ai/mastra/commit/8a688443013816105a09f89c6afa34b5ff13e26d)]:
|
|
97
|
+
- @mastra/core@1.47.0-alpha.7
|
|
98
|
+
- @mastra/server@1.47.0-alpha.7
|
|
99
|
+
- @mastra/hono@1.5.2-alpha.7
|
|
100
|
+
|
|
101
|
+
## 0.26.0-alpha.7
|
|
102
|
+
|
|
103
|
+
### Patch Changes
|
|
104
|
+
|
|
105
|
+
- Fixed MastraCode queued follow-up E2E tests to wait for stable terminal output. ([#18507](https://github.com/mastra-ai/mastra/pull/18507))
|
|
106
|
+
|
|
3
107
|
## 0.26.0-alpha.6
|
|
4
108
|
|
|
5
109
|
### Minor Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createMastraCode } from './chunk-
|
|
2
|
-
import { releaseAllThreadLocks } from './chunk-
|
|
1
|
+
import { createMastraCode } from './chunk-GT3A3LAA.js';
|
|
2
|
+
import { releaseAllThreadLocks } from './chunk-NDCWIAKG.js';
|
|
3
3
|
import { setAutoApprove, MastraCodeAcpAgent } from './chunk-IFUIWWGJ.js';
|
|
4
4
|
import { randomUUID } from 'crypto';
|
|
5
5
|
import { Readable, Writable } from 'stream';
|
|
@@ -81,5 +81,5 @@ async function acpMain(options) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export { acpMain };
|
|
84
|
-
//# sourceMappingURL=acp-
|
|
85
|
-
//# sourceMappingURL=acp-
|
|
84
|
+
//# sourceMappingURL=acp-G5OLW7EV.js.map
|
|
85
|
+
//# sourceMappingURL=acp-G5OLW7EV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":[],"mappings":";;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQ,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAAS,QAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAM,MAAA,GAAS,YAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,KAAA;AAGJ,E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OAAA,EAAQ;AACd,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,CAAA;AAEA,IAAA,OAAA,CAAQ,EAAA,CAAG,UAAU,YAAY,CAAA;AACjC,IAAA,OAAA,CAAQ,EAAA,CAAG,WAAW,YAAY,CAAA;AAElC,IAAA,MAAM,YAAA,CAAa,UAAA,EAAY,KAAA,EAAO,OAAO,CAAA;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK;AAAA,CAAI,CAAA;AAEpD,IAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-G5OLW7EV.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopHeartbeats(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkZ3HFSXTB_cjs = require('./chunk-Z3HFSXTB.cjs');
|
|
4
|
+
var chunkKGBCGF6C_cjs = require('./chunk-KGBCGF6C.cjs');
|
|
5
5
|
var chunkVBH3L4LD_cjs = require('./chunk-VBH3L4LD.cjs');
|
|
6
6
|
var crypto = require('crypto');
|
|
7
7
|
var stream = require('stream');
|
|
@@ -45,7 +45,7 @@ async function acpMain(options) {
|
|
|
45
45
|
};
|
|
46
46
|
let result;
|
|
47
47
|
try {
|
|
48
|
-
result = await
|
|
48
|
+
result = await chunkZ3HFSXTB_cjs.createMastraCode({
|
|
49
49
|
unixSocketPubSub: false,
|
|
50
50
|
disableMcp: false,
|
|
51
51
|
disableHooks: false
|
|
@@ -57,7 +57,7 @@ async function acpMain(options) {
|
|
|
57
57
|
{ id: "fast", name: "Fast" }
|
|
58
58
|
];
|
|
59
59
|
const cleanup = async () => {
|
|
60
|
-
|
|
60
|
+
chunkKGBCGF6C_cjs.releaseAllThreadLocks();
|
|
61
61
|
const closeSignalsPubSub = signalsPubSub?.close;
|
|
62
62
|
await Promise.allSettled([
|
|
63
63
|
mcpManager?.disconnect(),
|
|
@@ -83,5 +83,5 @@ async function acpMain(options) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
exports.acpMain = acpMain;
|
|
86
|
-
//# sourceMappingURL=acp-
|
|
87
|
-
//# sourceMappingURL=acp-
|
|
86
|
+
//# sourceMappingURL=acp-YSYEXVBE.cjs.map
|
|
87
|
+
//# sourceMappingURL=acp-YSYEXVBE.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":["Readable","Writable","stream","ndJsonStream","randomU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;AACd,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,CAAA;AAEA,IAAA,OAAA,CAAQ,EAAA,CAAG,UAAU,YAAY,CAAA;AACjC,IAAA,OAAA,CAAQ,EAAA,CAAG,WAAW,YAAY,CAAA;AAElC,IAAA,MAAM,YAAA,CAAa,UAAA,EAAY,KAAA,EAAO,OAAO,CAAA;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK;AAAA,CAAI,CAAA;AAEpD,IAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-
|
|
1
|
+
{"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":["Readable","Writable","stream","ndJsonStream","randomUUID","AgentSideConnection","MastraCodeAcpAgent","setAutoApprove","createMastraCode","releaseAllThreadLocks"],"mappings":";;;;;;;;;AAUA,eAAsB,YAAA,CACpB,UAAA,EACA,KAAA,EACA,OAAA,EACe;AAEf,EAAA,MAAM,KAAA,GAAQA,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAC1C,EAAA,MAAM,MAAA,GAASC,eAAA,CAAS,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA;AAC5C,EAAA,MAAMC,QAAA,GAASC,gBAAA,CAAa,MAAA,EAAQ,KAAK,CAAA;AACzC,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,KAAA;AAGJ,EAAA,IAAI;AACF,IAAA,OAAA,GAAU,MAAM,WAAW,aAAA,CAAc;AAAA,MACvC,EAAA,EAAI,CAAA,IAAA,EAAOC,iBAAA,EAAY,CAAA,CAAA;AAAA,MACvB,OAAA,EAAS,CAAA,UAAA,EAAaA,iBAAA,EAAY,CAAA;AAAA,KACnC,CAAA;AACD,IAAA,MAAM,aAAA,GAAgB,OAAA;A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AAA,MAC7B,EAAE,EAAA,EAAI,MAAA,EAAQ,IAAA,EAAM,MAAA,EAAO;AAAA,MAC3B,EAAE,EAAA,EAAI,MAAA,EAAQ,IAAA,EAAM,MAAA;AAAO,KAC7B;AAGA,IAAA,MAAM,UAAU,YAAY;AAC1B,MAAAC,uCAAA,EAAsB;AACtB,MAAA,MAAM,qBAAsB,aAAA,EAAsE,KAAA;AAClG,MAAA,MAAM,QAAQ,UAAA,CAAW;AAAA,QACvB,YAAY,UAAA,EAAW;AAAA,QACvB,UAAA,EAAY,SAAA,EAAU,EAAG,WAAA,EAAY;AAAA,QACrC,YAAY,cAAA,EAAe;AAAA,QAC3B,kBAAA;AAAqB,OACtB,CAAA;AAID,MAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AAAA,IAChB,CAAA;AAGA,IAAA,MAAM,eAAe,YAAY;AAC/B,MAAA,MAAM,OAAA,EAAQ;AACd,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,IAChB,CAAA;AAEA,IAAA,OAAA,CAAQ,EAAA,CAAG,UAAU,YAAY,CAAA;AACjC,IAAA,OAAA,CAAQ,EAAA,CAAG,WAAW,YAAY,CAAA;AAElC,IAAA,MAAM,YAAA,CAAa,UAAA,EAAY,KAAA,EAAO,OAAO,CAAA;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAA,CAAQ,MAAA,CAAO,KAAA,CAAM,CAAA,mBAAA,EAAsB,KAAK;AAAA,CAAI,CAAA;AAEpD,IAAA,OAAA,CAAQ,GAAA,GAAM,kBAAA;AACd,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF","file":"acp-YSYEXVBE.cjs","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { AgentController, AgentControllerMode, Session } from '@mastra/core/agent-controller';\nimport { MastraCodeAcpAgent } from './agent.js';\n\n/**\n * Run the ACP server over stdio.\n * This sets up the JSON-RPC stream and keeps the process alive until the client disconnects.\n */\nexport async function runAcpServer(\n controller: AgentController,\n modes: AgentControllerMode[],\n cleanup?: () => Promise<void>,\n): Promise<void> {\n // Create the ndJSON stream from stdin/stdout\n const input = Readable.toWeb(process.stdin) as ReadableStream<Uint8Array>;\n const output = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>;\n const stream = ndJsonStream(output, input);\n let session: Session | undefined;\n let agent: MastraCodeAcpAgent | undefined;\n\n // Handle cleanup on disconnect (success or error)\n try {\n session = await controller.createSession({\n id: `acp-${randomUUID()}`,\n ownerId: `acp-owner-${randomUUID()}`,\n });\n const activeSession = session;\n\n // Create the agent-side connection\n const connection = new AgentSideConnection(conn => {\n agent = new MastraCodeAcpAgent(conn, controller, activeSession, modes);\n return agent;\n }, stream);\n\n await connection.closed;\n } finally {\n agent?.dispose();\n session?.thread.detachFromCurrent();\n await session?.thread.clearAndReleaseLock();\n if (cleanup) {\n await cleanup();\n }\n }\n}\n","import type { AgentControllerMode } from '@mastra/core/agent-controller';\n\nimport { createMastraCode } from '../index.js';\nimport { releaseAllThreadLocks } from '../utils/thread-lock.js';\nimport { setAutoApprove } from './event-mapper.js';\nimport { runAcpServer } from './server.js';\n\n/**\n * Entry point for ACP server mode.\n * Initializes mastracode and runs the ACP protocol over stdio.\n */\nexport async function acpMain(options?: { dangerousAutoApprove?: boolean }): Promise<void> {\n if (options?.dangerousAutoApprove) {\n setAutoApprove(true);\n }\n // Redirect console.log to stderr to avoid polluting the JSON-RPC stream on stdout.\n // eslint-disable-next-line no-console\n const originalConsoleLog = console.log;\n // eslint-disable-next-line no-console\n console.log = (...args: unknown[]) => {\n process.stderr.write(args.map(String).join(' ') + '\\n');\n };\n\n let result: Awaited<ReturnType<typeof createMastraCode>> | undefined;\n\n try {\n result = await createMastraCode({\n unixSocketPubSub: false,\n disableMcp: false,\n disableHooks: false,\n });\n\n const { controller, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: AgentControllerMode[] = [\n { id: 'build', name: 'Build' },\n { id: 'plan', name: 'Plan' },\n { id: 'fast', name: 'Fast' },\n ];\n\n // Cleanup function (mirrors main.ts asyncCleanup)\n const cleanup = async () => {\n releaseAllThreadLocks();\n const closeSignalsPubSub = (signalsPubSub as { close?: () => Promise<void> | void } | undefined)?.close;\n await Promise.allSettled([\n mcpManager?.disconnect(),\n controller?.getMastra()?.stopWorkers(),\n controller?.stopHeartbeats(),\n closeSignalsPubSub?.(),\n ]);\n\n // Restore console.log\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n };\n\n // Handle signals\n const handleSignal = async () => {\n await cleanup();\n process.exit(0);\n };\n\n process.on('SIGINT', handleSignal);\n process.on('SIGTERM', handleSignal);\n\n await runAcpServer(controller, modes, cleanup);\n } catch (error) {\n process.stderr.write(`[acp] Fatal error: ${error}\\n`);\n // eslint-disable-next-line no-console\n console.log = originalConsoleLog;\n process.exit(1);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/modes/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/modes/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGzE,eAAO,MAAM,QAAQ,EAAE,mBAmCtB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export declare
|
|
1
|
+
interface PlanPromptContext {
|
|
2
|
+
state?: Record<string, unknown>;
|
|
3
|
+
}
|
|
4
|
+
export declare function planModePrompt(_ctx: PlanPromptContext): string;
|
|
5
|
+
export {};
|
|
5
6
|
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/plan.ts"],"names":[],"mappings":"AAKA,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAsG9D"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type { WorkspaceToolsConfig } from '@mastra/core/workspace';
|
|
1
|
+
import type { WorkspaceToolHookContext, WorkspaceToolsConfig } from '@mastra/core/workspace';
|
|
2
|
+
export declare function guardPlanModePlanFileWrites({ workspaceToolName, input, context }: WorkspaceToolHookContext): {
|
|
3
|
+
proceed: false;
|
|
4
|
+
output: string;
|
|
5
|
+
} | undefined;
|
|
2
6
|
export declare const MASTRACODE_WORKSPACE_TOOLS: WorkspaceToolsConfig;
|
|
3
7
|
export declare const PLAN_MODE_AVAILABLE_TOOLS: readonly string[];
|
|
4
8
|
export declare const EXPLORE_MODE_AVAILABLE_TOOLS: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-availability.d.ts","sourceRoot":"","sources":["../../src/agents/tool-availability.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-availability.d.ts","sourceRoot":"","sources":["../../src/agents/tool-availability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAyD7F,wBAAgB,2BAA2B,CAAC,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,wBAAwB;;;cAuB1G;AAED,eAAO,MAAM,0BAA0B,EAAE,oBAKxC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAqBtD,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAOzD,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,SAAS,MAAM,EAMtD,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPlansDir, setAuthStorage, loadSettings, MEMORY_GATEWAY_PROVIDER, getAvailableModePacks, getAvailableOmPacks, resolveModelDefaults, resolveOmRoleModel, releaseThreadLock, acquireThreadLock, saveSettings, OBSERVABILITY_AUTH_PREFIX, mastra, getCustomProviderId, getEffectiveThinkingLevel, createCodexMiddleware, THINKING_LEVEL_TO_REASONING_EFFORT, buildOpenAICodexOAuthFetch, openaiCodexProvider } from './chunk-
|
|
1
|
+
import { getLocalPlansRelativeDir, getPlansDir, setAuthStorage, loadSettings, MEMORY_GATEWAY_PROVIDER, getAvailableModePacks, getAvailableOmPacks, resolveModelDefaults, resolveOmRoleModel, releaseThreadLock, acquireThreadLock, saveSettings, OBSERVABILITY_AUTH_PREFIX, mastra, getCustomProviderId, getEffectiveThinkingLevel, createCodexMiddleware, THINKING_LEVEL_TO_REASONING_EFFORT, buildOpenAICodexOAuthFetch, openaiCodexProvider, isPlanFilePath } from './chunk-NDCWIAKG.js';
|
|
2
2
|
import { AuthStorage, DEFAULT_OM_MODEL_ID, DEFAULT_CONFIG_DIR, validateConfigDirName, detectProject, getResourceIdOverride, getStorageConfig, getObservabilityDatabasePath, getVectorDatabasePath, getCurrentGitBranchAsync, getOmScope, DEFAULT_REF_THRESHOLD, DEFAULT_OBS_THRESHOLD, getGitHubCopilotBaseUrl, fetchCopilotModels, getDatabasePath, COPILOT_HEADERS, getAppDataDir } from './chunk-Z5EMG7I2.js';
|
|
3
3
|
import { getToolCategory, MC_TOOLS, TOOL_NAME_OVERRIDES } from './chunk-UOFNLVKF.js';
|
|
4
4
|
import { createHash } from 'crypto';
|
|
@@ -21,7 +21,7 @@ import { Observability, SensitiveDataFilter, MastraStorageExporter, MastraPlatfo
|
|
|
21
21
|
import { spawn, execFile } from 'child_process';
|
|
22
22
|
import { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily';
|
|
23
23
|
import { estimateTokenCount, sliceByTokens } from 'tokenx';
|
|
24
|
-
import { LocalFilesystem, createWorkspaceTools, Workspace, LocalSandbox } from '@mastra/core/workspace';
|
|
24
|
+
import { LocalFilesystem, createWorkspaceTools, Workspace, LocalSandbox, WORKSPACE_TOOLS } from '@mastra/core/workspace';
|
|
25
25
|
import { z } from 'zod';
|
|
26
26
|
import * as fs from 'fs';
|
|
27
27
|
import fs__default, { readFileSync, existsSync, mkdirSync, writeFileSync, renameSync } from 'fs';
|
|
@@ -316,7 +316,10 @@ When something breaks:
|
|
|
316
316
|
`;
|
|
317
317
|
|
|
318
318
|
// src/agents/prompts/plan.ts
|
|
319
|
-
|
|
319
|
+
function planModePrompt(_ctx) {
|
|
320
|
+
const plansDir = getLocalPlansRelativeDir();
|
|
321
|
+
const examplePath = `${plansDir}/add-dark-mode.md`;
|
|
322
|
+
return `
|
|
320
323
|
# Plan Mode \u2014 READ-ONLY (except plan files)
|
|
321
324
|
|
|
322
325
|
You are in PLAN mode. Your job is to explore the codebase and design an implementation plan \u2014 NOT to make changes to the project.
|
|
@@ -329,7 +332,7 @@ This mode is **read-only for project files**. You must NOT modify the project.
|
|
|
329
332
|
- Do NOT run commands that change state (no git commit, no npm install, no file creation)
|
|
330
333
|
- Do NOT run build commands, tests, or scripts that have side effects
|
|
331
334
|
|
|
332
|
-
The ONE exception is
|
|
335
|
+
The ONE exception is plan files: you CAN create and edit markdown files inside \`${plansDir}/\` (e.g. \`${examplePath}\`). You may NOT write anywhere else.
|
|
333
336
|
|
|
334
337
|
If the user asks you to make changes while in Plan mode, explain that you're in read-only mode and they should switch to Build mode (\`/mode build\`) first.
|
|
335
338
|
|
|
@@ -375,24 +378,25 @@ For each step:
|
|
|
375
378
|
|
|
376
379
|
## Plan File Workflow
|
|
377
380
|
|
|
378
|
-
|
|
381
|
+
Write each plan to its own markdown file under \`${plansDir}/\` (e.g. \`${examplePath}\`). Start the file with a \`# Title\` heading describing the plan.
|
|
379
382
|
|
|
380
|
-
1. **First submission**: Write your plan to
|
|
381
|
-
2. **Reading**: Use \`view\` to read
|
|
383
|
+
1. **First submission**: Write your plan to a file under \`${plansDir}/\` using \`write_file\`, then call \`submit_plan\` with the \`path\` to that file.
|
|
384
|
+
2. **Reading**: Use \`view\` to read a plan file.
|
|
382
385
|
3. **Editing**: Use \`string_replace_lsp\` for targeted edits to specific sections.
|
|
383
386
|
|
|
387
|
+
**Reuse the same file while you keep iterating on the same plan.** Only create a NEW file when you're starting a genuinely different plan \u2014 that keeps each plan available to look back at and keeps revision diffs meaningful.
|
|
388
|
+
|
|
384
389
|
## IMMEDIATE ACTION: Write plan file, then call submit_plan
|
|
385
390
|
|
|
386
391
|
As soon as your plan is complete:
|
|
387
|
-
1. Write it to
|
|
388
|
-
2. Call \`submit_plan\` with the
|
|
392
|
+
1. Write it to a file under \`${plansDir}/\` using \`write_file\`
|
|
393
|
+
2. Call \`submit_plan\` with the \`path\` to that file
|
|
389
394
|
|
|
390
|
-
**CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the file
|
|
395
|
+
**CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the plan file, not in your text output or the \`submit_plan\` arguments.
|
|
391
396
|
|
|
392
397
|
\`\`\`javascript
|
|
393
398
|
submit_plan({
|
|
394
|
-
|
|
395
|
-
plan: "your full plan in markdown"
|
|
399
|
+
path: "${examplePath}"
|
|
396
400
|
})
|
|
397
401
|
\`\`\`
|
|
398
402
|
|
|
@@ -404,17 +408,16 @@ The user will see the plan rendered inline and can:
|
|
|
404
408
|
## Revision Workflow
|
|
405
409
|
|
|
406
410
|
If the user requests changes, you will be stopped immediately. Wait for their next message \u2014 it will contain their revision feedback. When you receive it:
|
|
407
|
-
1. Use \`view\` to read
|
|
411
|
+
1. Use \`view\` to read the SAME plan file
|
|
408
412
|
2. Use \`string_replace_lsp\` to make targeted edits based on feedback
|
|
409
413
|
3. Use \`view\` to re-read the updated file
|
|
410
|
-
4. Call \`submit_plan\` again with the
|
|
411
|
-
|
|
412
|
-
The user will see a diff of what changed between the previous and revised plan. Use \`string_replace_lsp\` for targeted edits so the diff is clear and meaningful \u2014 do NOT rewrite the entire plan from scratch for small changes.
|
|
414
|
+
4. Call \`submit_plan\` again with the same \`path\` \u2014 editing the file alone does NOT resubmit it
|
|
413
415
|
|
|
414
|
-
|
|
416
|
+
The user will see a diff of what changed between the previous and revised plan. Use \`string_replace_lsp\` for targeted edits so the diff is clear and meaningful \u2014 do NOT rewrite the entire plan from scratch for small changes, and do NOT move the plan to a new file for a revision.
|
|
415
417
|
|
|
416
418
|
Do NOT start implementing until the plan is approved.
|
|
417
419
|
`;
|
|
420
|
+
}
|
|
418
421
|
|
|
419
422
|
// src/agents/prompts/fast.ts
|
|
420
423
|
var fastModePrompt = `
|
|
@@ -505,10 +508,62 @@ Error: ${r.error}`);
|
|
|
505
508
|
}
|
|
506
509
|
});
|
|
507
510
|
}
|
|
508
|
-
|
|
509
|
-
|
|
511
|
+
var PLAN_MODE_WRITE_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
512
|
+
WORKSPACE_TOOLS.FILESYSTEM.WRITE_FILE,
|
|
513
|
+
WORKSPACE_TOOLS.FILESYSTEM.EDIT_FILE
|
|
514
|
+
]);
|
|
515
|
+
function getRequestContextValue(requestContext, key) {
|
|
516
|
+
if (!requestContext) return void 0;
|
|
517
|
+
if (typeof requestContext.get === "function") {
|
|
518
|
+
return requestContext.get(key);
|
|
519
|
+
}
|
|
520
|
+
return requestContext[key];
|
|
521
|
+
}
|
|
522
|
+
function getHarnessContext(context) {
|
|
523
|
+
const requestContext = context?.requestContext;
|
|
524
|
+
const harness = getRequestContextValue(requestContext, "harness");
|
|
525
|
+
return harness && typeof harness === "object" ? harness : void 0;
|
|
526
|
+
}
|
|
527
|
+
function getHarnessState(harness) {
|
|
528
|
+
const state = harness?.session?.state?.get?.();
|
|
529
|
+
return state && typeof state === "object" ? state : void 0;
|
|
530
|
+
}
|
|
531
|
+
function getHarnessModeId(harness) {
|
|
532
|
+
const modeId = harness?.session?.modeId ?? getHarnessState(harness)?.modeId;
|
|
533
|
+
return typeof modeId === "string" ? modeId : void 0;
|
|
534
|
+
}
|
|
535
|
+
function getHarnessProjectPath(harness) {
|
|
536
|
+
const projectPath = getHarnessState(harness)?.projectPath;
|
|
537
|
+
return typeof projectPath === "string" ? projectPath : void 0;
|
|
538
|
+
}
|
|
539
|
+
function getToolInputPath(input) {
|
|
540
|
+
const toolPath = input?.path;
|
|
541
|
+
return typeof toolPath === "string" ? toolPath : void 0;
|
|
542
|
+
}
|
|
543
|
+
var PLAN_DIR_HINT = `${getLocalPlansRelativeDir()}/`;
|
|
544
|
+
function guardPlanModePlanFileWrites({ workspaceToolName, input, context }) {
|
|
545
|
+
if (!PLAN_MODE_WRITE_TOOL_NAMES.has(workspaceToolName)) return;
|
|
546
|
+
const harness = getHarnessContext(context);
|
|
547
|
+
if (getHarnessModeId(harness) !== "plan") return;
|
|
548
|
+
const projectPath = getHarnessProjectPath(harness);
|
|
549
|
+
const inputPath = getToolInputPath(input);
|
|
550
|
+
if (!projectPath || !inputPath) {
|
|
551
|
+
return {
|
|
552
|
+
proceed: false,
|
|
553
|
+
output: `Plan mode can only write plan files inside ${PLAN_DIR_HINT}.`
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
if (isPlanFilePath(projectPath, inputPath)) return;
|
|
557
|
+
return {
|
|
558
|
+
proceed: false,
|
|
559
|
+
output: `Plan mode can only write plan files inside ${PLAN_DIR_HINT}. Refusing to edit ${inputPath}.`
|
|
560
|
+
};
|
|
561
|
+
}
|
|
510
562
|
var MASTRACODE_WORKSPACE_TOOLS = {
|
|
511
|
-
...TOOL_NAME_OVERRIDES
|
|
563
|
+
...TOOL_NAME_OVERRIDES,
|
|
564
|
+
hooks: {
|
|
565
|
+
beforeToolCall: guardPlanModePlanFileWrites
|
|
566
|
+
}
|
|
512
567
|
};
|
|
513
568
|
var PLAN_MODE_AVAILABLE_TOOLS = [
|
|
514
569
|
// Read-only exploration tools
|
|
@@ -517,9 +572,8 @@ var PLAN_MODE_AVAILABLE_TOOLS = [
|
|
|
517
572
|
MC_TOOLS.SEARCH_CONTENT,
|
|
518
573
|
MC_TOOLS.FILE_STAT,
|
|
519
574
|
MC_TOOLS.LSP_INSPECT,
|
|
520
|
-
// Plan file writing
|
|
521
|
-
//
|
|
522
|
-
// scope writes to .mastracode/plans/)
|
|
575
|
+
// Plan file writing. Tool hooks enforce that these can only write `.md`
|
|
576
|
+
// files inside `.mastracode/plans/` while the session is in plan mode.
|
|
523
577
|
MC_TOOLS.WRITE_FILE,
|
|
524
578
|
MC_TOOLS.STRING_REPLACE_LSP,
|
|
525
579
|
// Plan delivery tools
|
|
@@ -1033,14 +1087,14 @@ ${patchToolGuidance}
|
|
|
1033
1087
|
- Call this tool when your plan is complete. Do NOT just describe your plan in text \u2014 you MUST call this tool.
|
|
1034
1088
|
- The plan will be rendered as markdown and the user can approve, reject, or request changes.
|
|
1035
1089
|
- On approval, the system automatically switches to the default mode so you can implement.
|
|
1036
|
-
- Takes
|
|
1090
|
+
- Takes one argument: \`path\` (the plan markdown file you wrote under \`.mastracode/plans/\`). Do NOT pass the plan body \u2014 it lives in the file.`);
|
|
1037
1091
|
}
|
|
1038
1092
|
if (modeId === "plan") {
|
|
1039
1093
|
sections.push(`
|
|
1040
|
-
**Plan file access** \u2014 Your plan lives in \`.mastracode/plans/\`
|
|
1094
|
+
**Plan file access** \u2014 Your plan lives in a markdown file under \`.mastracode/plans/\` (e.g. \`add-dark-mode-toggle.md\`)
|
|
1041
1095
|
- Use \`write_file\` to create the plan file, \`view\` to read it, and \`string_replace_lsp\` for targeted edits.
|
|
1042
|
-
- On first submission: write the plan to the file, then call \`submit_plan\`.
|
|
1043
|
-
- On revision: read the existing file, edit specific sections, re-read, then call \`submit_plan\` with
|
|
1096
|
+
- On first submission: write the plan to the file, then call \`submit_plan\` with its \`path\`.
|
|
1097
|
+
- On revision: read the existing file, edit specific sections, re-read, then call \`submit_plan\` with the same \`path\`.
|
|
1044
1098
|
- If a plan file already exists, you previously submitted it \u2014 read it before revising.`);
|
|
1045
1099
|
}
|
|
1046
1100
|
if (!denied.has("subagent")) {
|
|
@@ -2148,7 +2202,7 @@ var planMode = {
|
|
|
2148
2202
|
|
|
2149
2203
|
## Rules
|
|
2150
2204
|
- You have READ-ONLY access to the project. You cannot modify project files or run commands.
|
|
2151
|
-
- The one exception is
|
|
2205
|
+
- The one exception is plan files: you can create and edit markdown files inside \`.mastracode/plans/\` using \`write_file\`, \`view\`, and \`string_replace_lsp\`. You may not write anywhere else.
|
|
2152
2206
|
- First, explore the codebase to understand existing patterns, architecture, and conventions.
|
|
2153
2207
|
- Produce a concrete, actionable plan \u2014 not vague suggestions.
|
|
2154
2208
|
|
|
@@ -2159,11 +2213,13 @@ var planMode = {
|
|
|
2159
2213
|
- **Parallelize**: Make multiple independent tool calls when exploring different areas
|
|
2160
2214
|
|
|
2161
2215
|
## Plan Delivery
|
|
2162
|
-
- Write your plan to \`.mastracode/plans
|
|
2163
|
-
-
|
|
2216
|
+
- Write your plan to a markdown file under \`.mastracode/plans/\` (e.g. \`.mastracode/plans/add-dark-mode.md\`) using \`write_file\`, then call \`submit_plan({ path })\` with the path to that file (never the plan body).
|
|
2217
|
+
- Start the file with a \`# Title\` heading describing the plan.
|
|
2218
|
+
- Reuse the same file while iterating on the same plan; only create a new file for a genuinely different plan so each plan stays available to review.
|
|
2219
|
+
- Do NOT output the plan as text \u2014 it MUST live in the plan file.
|
|
2164
2220
|
- Be concise: reference files by path and line number, don't include raw contents.
|
|
2165
2221
|
- Focus on actionable details, not general observations.
|
|
2166
|
-
-
|
|
2222
|
+
- To revise after "Request changes", edit the same file in place with \`string_replace_lsp\`, and call \`submit_plan\` again with the same path.`,
|
|
2167
2223
|
metadata: {
|
|
2168
2224
|
default: false
|
|
2169
2225
|
},
|
|
@@ -3720,6 +3776,21 @@ function createMcpManager(projectDir, configDirName = DEFAULT_CONFIG_DIR, extraS
|
|
|
3720
3776
|
|
|
3721
3777
|
// src/processors/plan-rejection-abort.ts
|
|
3722
3778
|
var PLAN_REJECTED_PREFIX = "Plan was not approved";
|
|
3779
|
+
function resultText(result) {
|
|
3780
|
+
if (typeof result === "string") return result;
|
|
3781
|
+
if (result && typeof result === "object") {
|
|
3782
|
+
const content = result.content;
|
|
3783
|
+
if (typeof content === "string") return content;
|
|
3784
|
+
}
|
|
3785
|
+
return "";
|
|
3786
|
+
}
|
|
3787
|
+
function isPlanRejection(inv) {
|
|
3788
|
+
if (!inv || inv.state !== "result" || inv.toolName !== "submit_plan") return false;
|
|
3789
|
+
return resultText(inv.result).startsWith(PLAN_REJECTED_PREFIX);
|
|
3790
|
+
}
|
|
3791
|
+
function isPlanRejectionResultPart(part) {
|
|
3792
|
+
return part.type === "tool_result" && part.name === "submit_plan" && resultText(part.result).startsWith(PLAN_REJECTED_PREFIX);
|
|
3793
|
+
}
|
|
3723
3794
|
var PlanRejectionAbortProcessor = class {
|
|
3724
3795
|
id = "plan-rejection-abort";
|
|
3725
3796
|
async processInputStep({ messages, stepNumber, abort }) {
|
|
@@ -3728,18 +3799,24 @@ var PlanRejectionAbortProcessor = class {
|
|
|
3728
3799
|
const msg = messages[i];
|
|
3729
3800
|
if (!msg || msg.role !== "assistant") continue;
|
|
3730
3801
|
const content = msg.content;
|
|
3731
|
-
const parts = content?.parts;
|
|
3732
|
-
if (!Array.isArray(parts)) break;
|
|
3802
|
+
const parts = Array.isArray(content) ? content : Array.isArray(content?.parts) ? content.parts : [];
|
|
3733
3803
|
for (const part of parts) {
|
|
3734
3804
|
if (!part || typeof part !== "object") continue;
|
|
3735
3805
|
const p = part;
|
|
3736
|
-
if (p.type
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3806
|
+
if (p.type === "tool-invocation" && isPlanRejection(p.toolInvocation)) {
|
|
3807
|
+
abort("Plan rejected by user \u2014 no further response needed");
|
|
3808
|
+
return void 0;
|
|
3809
|
+
}
|
|
3810
|
+
if (isPlanRejectionResultPart(p)) {
|
|
3811
|
+
abort("Plan rejected by user \u2014 no further response needed");
|
|
3812
|
+
return void 0;
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
const legacy = !Array.isArray(content) && Array.isArray(content?.toolInvocations) ? content.toolInvocations : [];
|
|
3816
|
+
for (const inv of legacy) {
|
|
3817
|
+
if (isPlanRejection(inv)) {
|
|
3742
3818
|
abort("Plan rejected by user \u2014 no further response needed");
|
|
3819
|
+
return void 0;
|
|
3743
3820
|
}
|
|
3744
3821
|
}
|
|
3745
3822
|
break;
|
|
@@ -4463,6 +4540,7 @@ async function createMastraCodeAgentController(config) {
|
|
|
4463
4540
|
gateways: [mastraCodeGateway],
|
|
4464
4541
|
workspace: config?.workspace ?? ((args) => getDynamicWorkspace(args)),
|
|
4465
4542
|
browser: config?.browser,
|
|
4543
|
+
idGenerator: config?.idGenerator,
|
|
4466
4544
|
toolCategoryResolver: getToolCategory,
|
|
4467
4545
|
initialState: {
|
|
4468
4546
|
projectPath: project.rootPath,
|
|
@@ -4587,5 +4665,5 @@ async function mountAgentControllerOnMastra(config) {
|
|
|
4587
4665
|
var createMastraCode = bootLocalAgentController;
|
|
4588
4666
|
|
|
4589
4667
|
export { bootLocalAgentController, createAuthStorage, createMastraCode, createMastraCodeAgentController, mountAgentControllerOnMastra, wireSessionConcerns };
|
|
4590
|
-
//# sourceMappingURL=chunk-
|
|
4591
|
-
//# sourceMappingURL=chunk-
|
|
4668
|
+
//# sourceMappingURL=chunk-GT3A3LAA.js.map
|
|
4669
|
+
//# sourceMappingURL=chunk-GT3A3LAA.js.map
|