Implement flexible step file discovery across entire project directory #576
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.
This PR implements flexible step file discovery that allows Motia to find step files anywhere in the project directory structure, not just in the hardcoded
steps/
folder.Problem
Previously, Motia's step discovery was limited to a single hardcoded directory:
This prevented developers from organizing their step files in a more flexible directory structure based on their project needs.
Solution
The implementation now scans the entire project directory while intelligently excluding common build and dependency directories:
Changes Made
getStepFiles()
function ingenerate-locked-data.ts
to scan entire project directorydev-watchers.ts
to monitor entire project directorygenerate-types.ts
to discover files project-wideBenefits
src/handlers/
,business-logic/
,api/endpoints/
)steps/
folder continue to work unchangedTest Results
Verified that the implementation correctly discovers step files in multiple directories:
src/handlers/
directorybusiness-logic/
directorysteps/
directorynode_modules/
properly ignoredFixes #575.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.