Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 11, 2025

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:

// Before: Limited to steps/ directory only
const stepsDir = path.join(projectDir, 'steps')
const stepFiles = globSync('**/*.step.{ts,js,py,rb}', { cwd: stepsDir })

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:

// After: Flexible discovery across entire project
const ignorePatterns = [
  '**/node_modules/**',
  '**/.git/**', 
  '**/dist/**',
  '**/build/**',
  '**/.next/**',
  '**/coverage/**',
  '**/.turbo/**'
]

const stepFiles = globSync('**/*.step.{ts,js,py,rb}', { 
  cwd: projectDir, 
  ignore: ignorePatterns 
})

Changes Made

  • Enhanced getStepFiles() function in generate-locked-data.ts to scan entire project directory
  • Updated file watching in dev-watchers.ts to monitor entire project directory
  • Improved type generation in generate-types.ts to discover files project-wide
  • Enhanced stream discovery to use consistent flexible patterns
  • Updated Watcher class with comprehensive ignore patterns for chokidar

Benefits

  • 🚀 Flexible organization: Step files can be organized in any directory structure (e.g., src/handlers/, business-logic/, api/endpoints/)
  • Performance optimized: Intelligent ignore patterns prevent scanning irrelevant directories
  • 🔄 Backward compatible: Existing projects with steps/ folder continue to work unchanged
  • 🛡️ Production ready: All linting passes, builds successfully

Test Results

Verified that the implementation correctly discovers step files in multiple directories:

  • ✅ Files in src/handlers/ directory
  • ✅ Files in business-logic/ directory
  • ✅ Files in traditional steps/ directory
  • ✅ Files in node_modules/ properly ignored

Fixes #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.

Copy link
Author

Copilot AI commented Aug 11, 2025

@rohitg00 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copy link

vercel bot commented Aug 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
motia-docs Ready Preview 💬 Add feedback Aug 11, 2025 10:40pm
motia-ui Ready Preview 💬 Add feedback Aug 11, 2025 10:40pm

@rohitg00 rohitg00 closed this Aug 11, 2025
@Copilot Copilot AI changed the title [WIP] Flexible Step File Discovery Implement flexible step file discovery across entire project directory Aug 11, 2025
@Copilot Copilot AI requested a review from rohitg00 August 11, 2025 22:56
Copilot finished work on behalf of rohitg00 August 11, 2025 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flexible Step File Discovery
2 participants