mastracode 0.25.1-alpha.0 → 0.25.1-alpha.2
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 +30 -0
- package/dist/acp/server.d.ts.map +1 -1
- package/dist/{acp-LBM2JPPW.js → acp-LWAMPD4C.js} +9 -5
- package/dist/acp-LWAMPD4C.js.map +1 -0
- package/dist/{acp-QYEYP4OZ.cjs → acp-Z4WJ3XBQ.cjs} +11 -7
- package/dist/acp-Z4WJ3XBQ.cjs.map +1 -0
- package/dist/agents/modes/plan.d.ts.map +1 -1
- package/dist/agents/prompts/plan.d.ts +1 -1
- package/dist/agents/prompts/plan.d.ts.map +1 -1
- package/dist/agents/prompts/tool-guidance.d.ts.map +1 -1
- package/dist/agents/workspace.d.ts.map +1 -1
- package/dist/{chunk-IUWPEYVZ.cjs → chunk-DVBJN36L.cjs} +72 -13
- package/dist/chunk-DVBJN36L.cjs.map +1 -0
- package/dist/{chunk-VZLHNA6F.js → chunk-E2ZS7WOZ.js} +117 -33
- package/dist/chunk-E2ZS7WOZ.js.map +1 -0
- package/dist/{chunk-GSQFGST7.cjs → chunk-EF6YLI3K.cjs} +1264 -1118
- package/dist/chunk-EF6YLI3K.cjs.map +1 -0
- package/dist/{chunk-5FIPMH3Y.js → chunk-F3TKSK3C.js} +63 -9
- package/dist/chunk-F3TKSK3C.js.map +1 -0
- package/dist/{chunk-6C4I2JKA.cjs → chunk-LRQUWUZP.cjs} +150 -66
- package/dist/chunk-LRQUWUZP.cjs.map +1 -0
- package/dist/{chunk-SQGV4BXK.js → chunk-ZN3L5WL7.js} +363 -216
- package/dist/chunk-ZN3L5WL7.js.map +1 -0
- package/dist/cli.cjs +19 -19
- package/dist/cli.js +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/config.d.ts +7 -0
- package/dist/mcp/config.d.ts.map +1 -1
- package/dist/processors/plan-rejection-abort.d.ts +12 -0
- package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
- package/dist/providers/openai-codex.d.ts.map +1 -1
- package/dist/tui/commands/clone.d.ts.map +1 -1
- package/dist/tui/commands/new.d.ts.map +1 -1
- package/dist/tui/commands/threads.d.ts.map +1 -1
- package/dist/tui/components/plan-approval-inline.d.ts +14 -6
- package/dist/tui/components/plan-approval-inline.d.ts.map +1 -1
- package/dist/tui/event-dispatch.d.ts.map +1 -1
- package/dist/tui/handlers/prompts.d.ts.map +1 -1
- package/dist/tui/mastra-tui.d.ts.map +1 -1
- package/dist/tui/render-messages.d.ts.map +1 -1
- package/dist/tui/setup.d.ts.map +1 -1
- package/dist/tui/state.d.ts +5 -0
- package/dist/tui/state.d.ts.map +1 -1
- package/dist/tui.cjs +19 -19
- package/dist/tui.js +2 -2
- package/dist/utils/plans.d.ts +20 -0
- package/dist/utils/plans.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/acp-LBM2JPPW.js.map +0 -1
- package/dist/acp-QYEYP4OZ.cjs.map +0 -1
- package/dist/chunk-5FIPMH3Y.js.map +0 -1
- package/dist/chunk-6C4I2JKA.cjs.map +0 -1
- package/dist/chunk-GSQFGST7.cjs.map +0 -1
- package/dist/chunk-IUWPEYVZ.cjs.map +0 -1
- package/dist/chunk-SQGV4BXK.js.map +0 -1
- package/dist/chunk-VZLHNA6F.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# mastracode
|
|
2
2
|
|
|
3
|
+
## 0.25.1-alpha.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 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))
|
|
8
|
+
|
|
9
|
+
- 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))
|
|
10
|
+
|
|
11
|
+
`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.
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
|
|
15
|
+
- 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))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`7c9dd77`](https://github.com/mastra-ai/mastra/commit/7c9dd77bd18cb8dc72797e25f1a0fbdc71a11347), [`9990965`](https://github.com/mastra-ai/mastra/commit/999096571635a83b42ef40841fd7028cfa630779), [`c0ffa3c`](https://github.com/mastra-ai/mastra/commit/c0ffa3c897ccd326de880df734740a7f0681a18f), [`0504bf5`](https://github.com/mastra-ai/mastra/commit/0504bf5e8cffc571a4b343326178de371e6f859b), [`26f54af`](https://github.com/mastra-ai/mastra/commit/26f54afb5dbfbbb02d4d09bec4bd7c5029751767), [`5afe423`](https://github.com/mastra-ai/mastra/commit/5afe423e4badf040f1b0d4525183a856fcb8146e), [`86623c1`](https://github.com/mastra-ai/mastra/commit/86623c1adf7d22de32cc916dda17f4155184db36), [`8c9f1c0`](https://github.com/mastra-ai/mastra/commit/8c9f1c0361d89066f9bcd14a2f69e761b01766c8)]:
|
|
18
|
+
- @mastra/core@1.47.0-alpha.2
|
|
19
|
+
- @mastra/pg@1.14.2-alpha.0
|
|
20
|
+
|
|
21
|
+
## 0.25.1-alpha.1
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 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))
|
|
26
|
+
|
|
27
|
+
- 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))
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`7f9ae70`](https://github.com/mastra-ai/mastra/commit/7f9ae70826b047e5a66218f9e92f20e54a2d791f), [`1505c07`](https://github.com/mastra-ai/mastra/commit/1505c07603f6346bae12aa82f140e8b88ffea9ab), [`e940f09`](https://github.com/mastra-ai/mastra/commit/e940f099ef5d18b403e6f2b4937e086a4da857b1)]:
|
|
30
|
+
- @mastra/core@1.46.1-alpha.1
|
|
31
|
+
- @mastra/memory@1.21.2-alpha.0
|
|
32
|
+
|
|
3
33
|
## 0.25.1-alpha.0
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/acp/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/acp/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/acp/server.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAW,MAAM,sBAAsB,CAAC;AAG1E;;;GAGG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,WAAW,EAAE,EACpB,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC5B,OAAO,CAAC,IAAI,CAAC,CA+Bf"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { createMastraCode } from './chunk-
|
|
2
|
-
import { releaseAllThreadLocks } from './chunk-
|
|
1
|
+
import { createMastraCode } from './chunk-E2ZS7WOZ.js';
|
|
2
|
+
import { releaseAllThreadLocks } from './chunk-F3TKSK3C.js';
|
|
3
3
|
import { setAutoApprove, MastraCodeAcpAgent } from './chunk-IU477VVQ.js';
|
|
4
|
+
import { randomUUID } from 'crypto';
|
|
4
5
|
import { Readable, Writable } from 'stream';
|
|
5
6
|
import { ndJsonStream, AgentSideConnection } from '@agentclientprotocol/sdk';
|
|
6
7
|
|
|
@@ -11,7 +12,10 @@ async function runAcpServer(harness, modes, cleanup) {
|
|
|
11
12
|
let session;
|
|
12
13
|
let agent;
|
|
13
14
|
try {
|
|
14
|
-
session = await harness.createSession(
|
|
15
|
+
session = await harness.createSession({
|
|
16
|
+
id: `acp-${randomUUID()}`,
|
|
17
|
+
ownerId: `acp-owner-${randomUUID()}`
|
|
18
|
+
});
|
|
15
19
|
const activeSession = session;
|
|
16
20
|
const connection = new AgentSideConnection((conn) => {
|
|
17
21
|
agent = new MastraCodeAcpAgent(conn, harness, activeSession, modes);
|
|
@@ -77,5 +81,5 @@ async function acpMain(options) {
|
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
export { acpMain };
|
|
80
|
-
//# sourceMappingURL=acp-
|
|
81
|
-
//# sourceMappingURL=acp-
|
|
84
|
+
//# sourceMappingURL=acp-LWAMPD4C.js.map
|
|
85
|
+
//# sourceMappingURL=acp-LWAMPD4C.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":[],"mappings":"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","file":"acp-LWAMPD4C.js","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { Harness, HarnessMode, Session } from '@mastra/core/harness';\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 harness: Harness,\n modes: HarnessMode[],\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 harness.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, harness, 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 { HarnessMode } from '@mastra/core/harness';\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 { harness, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: HarnessMode[] = [\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 harness?.getMastra()?.stopWorkers(),\n harness?.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(harness, 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,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkLRQUWUZP_cjs = require('./chunk-LRQUWUZP.cjs');
|
|
4
|
+
var chunkDVBJN36L_cjs = require('./chunk-DVBJN36L.cjs');
|
|
5
5
|
var chunkDPRNPXVC_cjs = require('./chunk-DPRNPXVC.cjs');
|
|
6
|
+
var crypto = require('crypto');
|
|
6
7
|
var stream = require('stream');
|
|
7
8
|
var sdk = require('@agentclientprotocol/sdk');
|
|
8
9
|
|
|
@@ -13,7 +14,10 @@ async function runAcpServer(harness, modes, cleanup) {
|
|
|
13
14
|
let session;
|
|
14
15
|
let agent;
|
|
15
16
|
try {
|
|
16
|
-
session = await harness.createSession(
|
|
17
|
+
session = await harness.createSession({
|
|
18
|
+
id: `acp-${crypto.randomUUID()}`,
|
|
19
|
+
ownerId: `acp-owner-${crypto.randomUUID()}`
|
|
20
|
+
});
|
|
17
21
|
const activeSession = session;
|
|
18
22
|
const connection = new sdk.AgentSideConnection((conn) => {
|
|
19
23
|
agent = new chunkDPRNPXVC_cjs.MastraCodeAcpAgent(conn, harness, activeSession, modes);
|
|
@@ -41,7 +45,7 @@ async function acpMain(options) {
|
|
|
41
45
|
};
|
|
42
46
|
let result;
|
|
43
47
|
try {
|
|
44
|
-
result = await
|
|
48
|
+
result = await chunkLRQUWUZP_cjs.createMastraCode({
|
|
45
49
|
unixSocketPubSub: false,
|
|
46
50
|
disableMcp: false,
|
|
47
51
|
disableHooks: false
|
|
@@ -53,7 +57,7 @@ async function acpMain(options) {
|
|
|
53
57
|
{ id: "fast", name: "Fast" }
|
|
54
58
|
];
|
|
55
59
|
const cleanup = async () => {
|
|
56
|
-
|
|
60
|
+
chunkDVBJN36L_cjs.releaseAllThreadLocks();
|
|
57
61
|
const closeSignalsPubSub = signalsPubSub?.close;
|
|
58
62
|
await Promise.allSettled([
|
|
59
63
|
mcpManager?.disconnect(),
|
|
@@ -79,5 +83,5 @@ async function acpMain(options) {
|
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
exports.acpMain = acpMain;
|
|
82
|
-
//# sourceMappingURL=acp-
|
|
83
|
-
//# sourceMappingURL=acp-
|
|
86
|
+
//# sourceMappingURL=acp-Z4WJ3XBQ.cjs.map
|
|
87
|
+
//# sourceMappingURL=acp-Z4WJ3XBQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/acp/server.ts","../src/acp/index.ts"],"names":["Readable","Writable","stream","ndJsonStream","randomUUID","AgentSideConnection","MastraCodeAcpAgent","setAutoApprove","createMastraCode","releaseAllThreadLocks"],"mappings":"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","file":"acp-Z4WJ3XBQ.cjs","sourcesContent":["import { randomUUID } from 'node:crypto';\nimport { Readable, Writable } from 'node:stream';\nimport { AgentSideConnection, ndJsonStream } from '@agentclientprotocol/sdk';\nimport type { Harness, HarnessMode, Session } from '@mastra/core/harness';\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 harness: Harness,\n modes: HarnessMode[],\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 harness.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, harness, 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 { HarnessMode } from '@mastra/core/harness';\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 { harness, mcpManager, signalsPubSub } = result;\n\n // Default modes (same as createMastraCode defaults)\n const modes: HarnessMode[] = [\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 harness?.getMastra()?.stopWorkers(),\n harness?.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(harness, 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,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,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,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,eAAO,MAAM,QAAQ,EAAE,WA+BtB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Plan mode prompt — read-only exploration and planning.
|
|
3
3
|
*/
|
|
4
|
-
export declare const planModePrompt = "\n# Plan Mode \u2014 READ-ONLY\n\nYou are in PLAN mode. Your job is to explore the codebase and design an implementation plan \u2014 NOT to make changes.\n\n## CRITICAL: Read-Only Mode\n\nThis mode is **
|
|
4
|
+
export declare const planModePrompt = "\n# Plan Mode \u2014 READ-ONLY (except plan files)\n\nYou are in PLAN mode. Your job is to explore the codebase and design an implementation plan \u2014 NOT to make changes to the project.\n\n## CRITICAL: Read-Only Mode (project files)\n\nThis mode is **read-only for project files**. You must NOT modify the project.\n\n- Do NOT modify, create, or delete project files\n- Do NOT run commands that change state (no git commit, no npm install, no file creation)\n- Do NOT run build commands, tests, or scripts that have side effects\n\nThe ONE exception is your plan file: you CAN write to `.mastracode/plans/` to create and edit your plan.\n\nIf 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.\n\n## Exploration Strategy\n\nBefore writing any plan, build a mental model of the codebase:\n1. Start with the directory structure (`view` on the project root or relevant subdirectory).\n2. Find the relevant entry points and core files using `search_content` and `find_files`.\n3. Read the actual code \u2014 don't assume based on file names alone.\n4. Trace data flow: where does input come from, how is it transformed, where does it go?\n5. Identify existing patterns the codebase uses (naming, structure, error handling, testing).\n\n## Goal-Ready Plans\n\nThe submit_plan approval UI can let the user approve the plan normally or start it as a persistent goal. Write plans so they can be carried out as a goal if the user chooses that option:\n- Make the desired outcome explicit and verifiable.\n- Break work into ordered, actionable steps that can be executed autonomously.\n- Include constraints, risks, blockers, and decision points that may require user input.\n- Include concrete verification criteria so the goal judge can tell when the work is done.\n\n## Your Plan Output\n\nProduce a clear, step-by-step plan with this structure:\n\n### Overview\nOne paragraph: what the change does and why.\n\n### Complexity Estimate\n- **Size**: Small (1-2 files) / Medium (3-5 files) / Large (6+ files)\n- **Risk**: Low (additive, no breaking changes) / Medium (modifies existing behavior) / High (architectural, affects many consumers)\n- **Dependencies**: List any new packages, external services, or migration steps needed.\n\n### Steps\nFor each step:\n1. **File**: path to create or modify\n2. **Change**: what to add/modify/remove, with enough specificity to implement directly\n3. **Why**: brief rationale connecting this step to the overall goal\n\n### Verification\n- What tests to run\n- What to check manually\n- What could go wrong\n\n## Plan File Workflow\n\nYour plan lives as a `.md` file in `.mastracode/plans/` \u2014 the filename is derived from your plan title (e.g. `add-dark-mode-toggle.md`). Use regular workspace tools to manage it:\n\n1. **First submission**: Write your plan to `.mastracode/plans/<slug>.md` using `write_file`, then call `submit_plan` with the plan content.\n2. **Reading**: Use `view` to read the plan file.\n3. **Editing**: Use `string_replace_lsp` for targeted edits to specific sections.\n\n## IMMEDIATE ACTION: Write plan file, then call submit_plan\n\nAs soon as your plan is complete:\n1. Write it to `.mastracode/plans/<slug>.md` (slugified from your title) using `write_file`\n2. Call `submit_plan` with the plan content\n\n**CRITICAL:** Do NOT generate a long text response describing your plan. The plan content belongs in the file and the `submit_plan` tool call, not in your text output.\n\n```javascript\nsubmit_plan({\n title: \"short descriptive title\",\n plan: \"your full plan in markdown\"\n})\n```\n\nThe user will see the plan rendered inline and can:\n- **Approve** \u2014 automatically switches to Build mode for implementation\n- **Start as goal** \u2014 approves the plan and enters goal mode so the agent keeps working toward the plan until judged complete, paused, or waiting for user input\n- **Request changes** \u2014 rejects the plan; the agent stops immediately and the user provides revision feedback in their next chat message\n\n## Revision Workflow\n\nIf 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:\n1. Use `view` to read your plan file in `.mastracode/plans/`\n2. Use `string_replace_lsp` to make targeted edits based on feedback\n3. Use `view` to re-read the updated file\n4. Call `submit_plan` again with the full updated plan content\n\nThe 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.\n\n**IMPORTANT**: If a plan file already exists in `.mastracode/plans/`, you previously submitted a plan that was rejected. Read it to see your previous attempt before revising.\n\nDo NOT start implementing until the plan is approved.\n";
|
|
5
5
|
//# sourceMappingURL=plan.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/plan.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,cAAc,84JAkG1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-guidance.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/tool-guidance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,UAAU,mBAAmB;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uEAAuE;IACvE,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"tool-guidance.d.ts","sourceRoot":"","sources":["../../../src/agents/prompts/tool-guidance.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,UAAU,mBAAmB;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uEAAuE;IACvE,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,MAAM,CA+N3F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/agents/workspace.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAwB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/agents/workspace.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAwB,MAAM,wBAAwB,CAAC;AA+ExG,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,SAAe,GAAG,MAAM,EAAE,CAgBxG;AA2BD,wBAAgB,mBAAmB,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE;IAAE,cAAc,EAAE,cAAc,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,uDAmElH;AAiBD;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,cAAc,EACd,MAAM,GACP,EAAE;IACD,cAAc,EAAE,cAAc,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAclC"}
|
|
@@ -4,8 +4,9 @@ var chunkBULVNQ2P_cjs = require('./chunk-BULVNQ2P.cjs');
|
|
|
4
4
|
var openai = require('@ai-sdk/openai');
|
|
5
5
|
var ai = require('ai');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var
|
|
7
|
+
var path2 = require('path');
|
|
8
8
|
var chalk = require('chalk');
|
|
9
|
+
var fs2 = require('fs/promises');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
12
|
|
|
@@ -28,8 +29,9 @@ function _interopNamespace(e) {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
var fs__namespace = /*#__PURE__*/_interopNamespace(fs);
|
|
31
|
-
var
|
|
32
|
+
var path2__namespace = /*#__PURE__*/_interopNamespace(path2);
|
|
32
33
|
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
|
|
34
|
+
var fs2__default = /*#__PURE__*/_interopDefault(fs2);
|
|
33
35
|
|
|
34
36
|
var CODEX_API_ENDPOINT = "https://chatgpt.com/backend-api/codex/responses";
|
|
35
37
|
var CODEX_ORIGINATOR = "mastracode";
|
|
@@ -415,7 +417,7 @@ function getNewInstallDefaults() {
|
|
|
415
417
|
return settings;
|
|
416
418
|
}
|
|
417
419
|
function getSettingsPath() {
|
|
418
|
-
return
|
|
420
|
+
return path2.join(chunkBULVNQ2P_cjs.getAppDataDir(), "settings.json");
|
|
419
421
|
}
|
|
420
422
|
function getCustomProviderId(name) {
|
|
421
423
|
const slug = name.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -523,7 +525,7 @@ function parseObservabilitySettings(raw) {
|
|
|
523
525
|
return { resources, localTracing };
|
|
524
526
|
}
|
|
525
527
|
function migrateFromAuth(settingsPath) {
|
|
526
|
-
const authPath =
|
|
528
|
+
const authPath = path2.join(chunkBULVNQ2P_cjs.getAppDataDir(), "auth.json");
|
|
527
529
|
if (!fs.existsSync(authPath)) return false;
|
|
528
530
|
let authData;
|
|
529
531
|
try {
|
|
@@ -757,7 +759,7 @@ function getSignalSettingsForSave(settings, filePath) {
|
|
|
757
759
|
return settings.signals;
|
|
758
760
|
}
|
|
759
761
|
function saveSettings(settings, filePath = getSettingsPath()) {
|
|
760
|
-
const dir =
|
|
762
|
+
const dir = path2.dirname(filePath);
|
|
761
763
|
if (!fs.existsSync(dir)) {
|
|
762
764
|
fs.mkdirSync(dir, { recursive: true });
|
|
763
765
|
}
|
|
@@ -768,7 +770,7 @@ function saveSettings(settings, filePath = getSettingsPath()) {
|
|
|
768
770
|
}
|
|
769
771
|
var PROFILE_PROVIDER_MARKER = ".mastra-provider";
|
|
770
772
|
function getProfileProvider(profilePath) {
|
|
771
|
-
const markerPath =
|
|
773
|
+
const markerPath = path2.join(profilePath, PROFILE_PROVIDER_MARKER);
|
|
772
774
|
if (!fs.existsSync(markerPath)) {
|
|
773
775
|
return void 0;
|
|
774
776
|
}
|
|
@@ -783,7 +785,7 @@ function getProfileProvider(profilePath) {
|
|
|
783
785
|
}
|
|
784
786
|
}
|
|
785
787
|
function setProfileProvider(profilePath, provider) {
|
|
786
|
-
const markerPath =
|
|
788
|
+
const markerPath = path2.join(profilePath, PROFILE_PROVIDER_MARKER);
|
|
787
789
|
if (!fs.existsSync(profilePath)) {
|
|
788
790
|
fs.mkdirSync(profilePath, { recursive: true });
|
|
789
791
|
}
|
|
@@ -800,7 +802,7 @@ function checkProfileProviderMismatch(profilePath, targetProvider) {
|
|
|
800
802
|
return void 0;
|
|
801
803
|
}
|
|
802
804
|
function browserRecordingOptions() {
|
|
803
|
-
return { outputDir:
|
|
805
|
+
return { outputDir: path2.join(chunkBULVNQ2P_cjs.getAppDataDir(), "browser-recordings") };
|
|
804
806
|
}
|
|
805
807
|
async function createBrowserFromSettings(settings) {
|
|
806
808
|
if (!settings.enabled) {
|
|
@@ -1421,7 +1423,7 @@ var ThreadLockError = class extends Error {
|
|
|
1421
1423
|
ownerPid;
|
|
1422
1424
|
};
|
|
1423
1425
|
function getLocksDir() {
|
|
1424
|
-
const dir =
|
|
1426
|
+
const dir = path2__namespace.join(chunkBULVNQ2P_cjs.getAppDataDir(), "locks");
|
|
1425
1427
|
if (!fs__namespace.existsSync(dir)) {
|
|
1426
1428
|
fs__namespace.mkdirSync(dir, { recursive: true });
|
|
1427
1429
|
}
|
|
@@ -1429,7 +1431,7 @@ function getLocksDir() {
|
|
|
1429
1431
|
}
|
|
1430
1432
|
function getLockPath(threadId) {
|
|
1431
1433
|
const safeId = threadId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1432
|
-
return
|
|
1434
|
+
return path2__namespace.join(getLocksDir(), `${safeId}.lock`);
|
|
1433
1435
|
}
|
|
1434
1436
|
function isProcessAlive(pid) {
|
|
1435
1437
|
try {
|
|
@@ -1475,7 +1477,7 @@ function releaseAllThreadLocks() {
|
|
|
1475
1477
|
const myPid = String(process.pid);
|
|
1476
1478
|
for (const file of files) {
|
|
1477
1479
|
if (!file.endsWith(".lock")) continue;
|
|
1478
|
-
const lockPath =
|
|
1480
|
+
const lockPath = path2__namespace.join(locksDir, file);
|
|
1479
1481
|
try {
|
|
1480
1482
|
const content = fs__namespace.readFileSync(lockPath, "utf-8").trim();
|
|
1481
1483
|
if (content === myPid) {
|
|
@@ -1487,6 +1489,59 @@ function releaseAllThreadLocks() {
|
|
|
1487
1489
|
} catch {
|
|
1488
1490
|
}
|
|
1489
1491
|
}
|
|
1492
|
+
function getPlansDir() {
|
|
1493
|
+
return process.env.MASTRA_PLANS_DIR ?? path2__namespace.default.join(chunkBULVNQ2P_cjs.getAppDataDir(), "plans");
|
|
1494
|
+
}
|
|
1495
|
+
function getLocalPlansDir(projectPath) {
|
|
1496
|
+
return path2__namespace.default.join(projectPath, chunkBULVNQ2P_cjs.DEFAULT_CONFIG_DIR, "plans");
|
|
1497
|
+
}
|
|
1498
|
+
function slugify(str) {
|
|
1499
|
+
const slug = str.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
1500
|
+
return slug || "untitled";
|
|
1501
|
+
}
|
|
1502
|
+
async function savePlanToDisk(opts) {
|
|
1503
|
+
const { title, plan, resourceId } = opts;
|
|
1504
|
+
const plansDir = opts.plansDir ?? getPlansDir();
|
|
1505
|
+
const baseDir = path2__namespace.default.resolve(plansDir);
|
|
1506
|
+
const dir = path2__namespace.default.resolve(baseDir, resourceId);
|
|
1507
|
+
const rel = path2__namespace.default.relative(baseDir, dir);
|
|
1508
|
+
if (rel.startsWith("..") || path2__namespace.default.isAbsolute(rel)) {
|
|
1509
|
+
throw new Error(`Invalid resourceId: ${resourceId}`);
|
|
1510
|
+
}
|
|
1511
|
+
await fs2__default.default.mkdir(dir, { recursive: true });
|
|
1512
|
+
const now = /* @__PURE__ */ new Date();
|
|
1513
|
+
const timestamp = now.toISOString().replace(/:/g, "-");
|
|
1514
|
+
const slug = slugify(title);
|
|
1515
|
+
const filename = `${timestamp}-${slug}.md`;
|
|
1516
|
+
const content = `# ${title}
|
|
1517
|
+
|
|
1518
|
+
Approved: ${now.toISOString()}
|
|
1519
|
+
|
|
1520
|
+
${plan}
|
|
1521
|
+
`;
|
|
1522
|
+
await fs2__default.default.writeFile(path2__namespace.default.join(dir, filename), content, "utf-8");
|
|
1523
|
+
}
|
|
1524
|
+
async function savePlanSnapshot(opts) {
|
|
1525
|
+
const { title, plan, projectPath } = opts;
|
|
1526
|
+
const plansDir = opts.plansDir ?? getLocalPlansDir(projectPath);
|
|
1527
|
+
const baseDir = path2__namespace.default.resolve(plansDir);
|
|
1528
|
+
await fs2__default.default.mkdir(baseDir, { recursive: true });
|
|
1529
|
+
const filename = `${slugify(title)}.md`;
|
|
1530
|
+
const target = path2__namespace.default.resolve(baseDir, filename);
|
|
1531
|
+
const rel = path2__namespace.default.relative(baseDir, target);
|
|
1532
|
+
if (rel.startsWith("..") || path2__namespace.default.isAbsolute(rel)) {
|
|
1533
|
+
throw new Error(`Invalid plan title: ${title}`);
|
|
1534
|
+
}
|
|
1535
|
+
const content = `# ${title}
|
|
1536
|
+
|
|
1537
|
+
${plan}
|
|
1538
|
+
`;
|
|
1539
|
+
await fs2__default.default.writeFile(target, content, "utf-8");
|
|
1540
|
+
return filename;
|
|
1541
|
+
}
|
|
1542
|
+
function getPlanFilename(title) {
|
|
1543
|
+
return `${slugify(title)}.md`;
|
|
1544
|
+
}
|
|
1490
1545
|
|
|
1491
1546
|
exports.BOX_INDENT = BOX_INDENT;
|
|
1492
1547
|
exports.BOX_INDENT_STR = BOX_INDENT_STR;
|
|
@@ -1513,6 +1568,8 @@ exports.getCustomProviderId = getCustomProviderId;
|
|
|
1513
1568
|
exports.getEditorTheme = getEditorTheme;
|
|
1514
1569
|
exports.getEffectiveThinkingLevel = getEffectiveThinkingLevel;
|
|
1515
1570
|
exports.getMarkdownTheme = getMarkdownTheme;
|
|
1571
|
+
exports.getPlanFilename = getPlanFilename;
|
|
1572
|
+
exports.getPlansDir = getPlansDir;
|
|
1516
1573
|
exports.getSelectListTheme = getSelectListTheme;
|
|
1517
1574
|
exports.getSettingsListTheme = getSettingsListTheme;
|
|
1518
1575
|
exports.getTermWidth = getTermWidth;
|
|
@@ -1528,11 +1585,13 @@ exports.resolveModelDefaults = resolveModelDefaults;
|
|
|
1528
1585
|
exports.resolveOmRoleModel = resolveOmRoleModel;
|
|
1529
1586
|
exports.resolveThreadActiveModelPackId = resolveThreadActiveModelPackId;
|
|
1530
1587
|
exports.restoreTerminalForeground = restoreTerminalForeground;
|
|
1588
|
+
exports.savePlanSnapshot = savePlanSnapshot;
|
|
1589
|
+
exports.savePlanToDisk = savePlanToDisk;
|
|
1531
1590
|
exports.saveSettings = saveSettings;
|
|
1532
1591
|
exports.setAuthStorage = setAuthStorage;
|
|
1533
1592
|
exports.setProfileProvider = setProfileProvider;
|
|
1534
1593
|
exports.theme = theme;
|
|
1535
1594
|
exports.tintHex = tintHex;
|
|
1536
1595
|
exports.toCustomProviderModelId = toCustomProviderModelId;
|
|
1537
|
-
//# sourceMappingURL=chunk-
|
|
1538
|
-
//# sourceMappingURL=chunk-
|
|
1596
|
+
//# sourceMappingURL=chunk-DVBJN36L.cjs.map
|
|
1597
|
+
//# sourceMappingURL=chunk-DVBJN36L.cjs.map
|