feat: add auto-run folder support to CLI create-agent#901
Merged
ksylvan merged 2 commits intoRunMaestro:rcfrom Apr 25, 2026
Merged
feat: add auto-run folder support to CLI create-agent#901ksylvan merged 2 commits intoRunMaestro:rcfrom
ksylvan merged 2 commits intoRunMaestro:rcfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
- Add create-agent --auto-run-folder path override for playbooks - Propagate auto-run folder through websocket session creation config - Persist auto-run folder on renderer-created session records - Honor MAESTRO_USER_DATA for CLI storage and discovery - Publish Electron userData path for shared discovery files - Isolate tests from ambient MAESTRO_USER_DATA environment overrides - Document playbooks folder option in CLI references
21618a5 to
0a87f4b
Compare
- Use default Auto Run prompt for remote batches - Align CLI and web launches with GUI behavior - Prevent empty prompts from failing Claude print execution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat: add auto-run folder support to CLI create-agent
Summary
This PR adds support for configuring an agent-specific Auto Run / playbooks folder from the CLI and fixes data-directory discovery so the CLI and Electron app consistently read/write files from the same Maestro user data directory.
The main functional changes are:
--auto-run-folder <path>tomaestro-cli create-agent.autoRunFolderPaththrough CLI session creation, web server handling, and renderer session state.MAESTRO_USER_DATAas an override for CLI storage and CLI server discovery paths.MAESTRO_USER_DATAfrom Electron’s resolvedapp.getPath('userData')so dev/prod data directories do not clobber each other.Files Changed
docs/cli.mdUpdated the
create-agentdocumentation to include the new--auto-run-folderoption.The full config example now includes:
--auto-run-folder ~/playbooks/full-configThe options table now documents:
src/cli/index.tsAdded a new CLI option to
create-agent:This exposes the new agent configuration from the command line.
src/cli/commands/create-agent.tsExtended
CreateAgentOptionswithautoRunFolder:When provided, the path is resolved to an absolute path and sent in the create-session payload:
src/main/web-server/types.tsExtended
CreateSessionConfigto support an optional Auto Run folder path:This allows the value to be passed through the existing session creation config pipeline.
src/main/web-server/WebServer.tsUpdated the
createSessioncallback wiring to accept and forward the optional session config:Previously, the web server callback only forwarded
name,toolType,cwd, andgroupId, which would have dropped additional session configuration.src/main/web-server/handlers/messageHandlers.tsAdded handling for
autoRunFolderPathin create-agent/session messages:The comment explicitly notes that the Auto Run folder may live outside the agent cwd:
// autoRunFolderPath can be set outside of the agent's cwd (no confinement needed)src/renderer/hooks/remote/useAppRemoteEventListeners.tsUpdated remote session creation handling so
autoRunFolderPathis preserved in renderer state:src/main/index.tsSets
MAESTRO_USER_DATAto the Electron app’s resolveduserDatapath:This ensures shared CLI server discovery logic uses the same data directory that the app is actually using, including dev-mode paths such as
maestro-dev.src/cli/services/storage.tsUpdated CLI storage path resolution to honor
MAESTRO_USER_DATA:This allows CLI storage to be redirected to the same configured app data directory instead of always using platform defaults.
src/shared/cli-server-discovery.tsUpdated CLI server discovery path resolution to also honor
MAESTRO_USER_DATA:This keeps discovery file lookup aligned with CLI storage behavior.
src/__tests__/cli/services/storage.test.tsUpdated test setup to delete any inherited
MAESTRO_USER_DATAvalue before each test:This prevents a shell-level environment variable from shadowing mocked platform and homedir values.
src/__tests__/shared/cli-server-discovery.test.tsAdded environment isolation around
MAESTRO_USER_DATAand added tests verifying that:MAESTRO_USER_DATAoverrides the platform-default config path.MAESTRO_USER_DATAvalues are resolved to absolute paths.Example assertion:
src/prompts/_maestro-cli.mdUpdated the embedded Maestro CLI usage prompt to include the new option:
Code Changes
New
--auto-run-folderCLI optionThe CLI now accepts an optional Auto Run / playbooks folder when creating an agent:
The value is normalized to an absolute path before being sent to the app:
Auto Run folder propagation through session creation
The session config type now includes:
The web server message handler reads it from incoming messages:
The renderer stores it on newly-created sessions:
User data directory override via
MAESTRO_USER_DATABoth CLI storage and CLI server discovery now support a shared data directory override:
The Electron main process publishes its resolved user data path to that variable:
This ensures that shared code writes files such as
cli-server.jsoninto the same directory the app is configured to use.Reason for Changes
Agent-specific Auto Run folder support
Before this change, agents created through the CLI used the default Auto Run / playbooks folder derived from the agent cwd. This made it difficult to point an agent at a shared or external playbooks directory.
The new
--auto-run-folderflag allows callers to explicitly configure the playbooks folder during agent creation.Consistent dev/prod CLI server discovery
The shared CLI server discovery logic previously used hardcoded platform defaults. In development mode, the Electron app may use a different user data path such as
maestro-dev, while the CLI discovery code would still look at the default production-like directory.That could cause dev and prod sessions to clobber each other’s
cli-server.json, or cause the CLI to fail to discover the running app server.By setting and honoring
MAESTRO_USER_DATA, the app and CLI now agree on the active data directory.Impact of Changes
--auto-run-foldervalues are resolved to absolute paths by the CLI before being sent to the app.userDatapath.MAESTRO_USER_DATAis set externally.Test Plan
The following areas should be tested:
Create an agent with a custom Auto Run folder
Verify that the created session has the expected
autoRunFolderPath.Create an agent without
--auto-run-foldermaestro-cli create-agent "Default Agent" --cwd /tmp/projectVerify that the default playbooks folder behavior remains unchanged.
Relative Auto Run folder path
maestro-cli create-agent "Relative Playbooks" \ --cwd /tmp/project \ --auto-run-folder ./playbooksVerify that the path is stored as an absolute path.
Development mode CLI discovery
Start the app in development mode and verify that
cli-server.jsonis written under the app’s resolved devuserDatadirectory instead of the production/default directory.Environment override
Run CLI operations with
MAESTRO_USER_DATAexplicitly set and confirm storage and server discovery use that path.Automated tests
Run the affected test suites:
Additional Notes
autoRunFolderPathis intentionally not confined to the agent cwd. This allows shared playbook directories and external automation folders.MAESTRO_USER_DATAis resolved withpath.resolve, so relative overrides become absolute paths.MAESTRO_USER_DATAvalues to avoid nondeterministic behavior in CI or local shells.autoRunFolderPathcan point outside the agent cwd, any code that reads from or writes to that folder should continue to treat it as user-controlled input and avoid unsafe assumptions about path locality.Summary by CodeRabbit
New Features
Behavior Changes
Documentation
Tests