Open
Description
Overview
This issue analyzes the feasibility and implications of refactoring the entire MyCoder codebase from TypeScript to Clojure with Babashka runtime.
Current Codebase Assessment
-
MyCoder is a TypeScript/JavaScript monorepo with three main packages:
cli
: Command-line interface for MyCoderagent
: Core AI agent systemdocs
: Documentation website
-
The codebase consists of approximately 108 TypeScript files
-
Uses modern JavaScript/TypeScript features and ecosystem tools
-
Has a well-structured architecture with clear separation of concerns
-
Relies on npm/pnpm for package management
-
Has an established testing framework (Vitest)
Key Dependencies
- LLM integrations (Anthropic Claude, OpenAI)
- Browser automation via Playwright
- Various Node.js utilities and libraries
- Semantic release for versioning
Clojure/Babashka Capabilities
- Clojure is a dynamic, functional programming language that runs on the JVM
- Babashka is a native Clojure scripting runtime with fast startup time
- Babashka includes many built-in libraries for scripting tasks
- Supports multi-threading and has good interop capabilities
Refactoring Implications
Potential Benefits
- Functional programming paradigm may align well with AI agent workflows
- Immutable data structures could simplify state management
- Clojure's macro system could provide powerful abstractions
- Babashka offers fast startup times for CLI applications
- Potential for more concise code in some areas
Challenges and Considerations
-
Ecosystem Compatibility:
- Need to find/create Clojure equivalents for all current dependencies
- LLM client libraries would need to be rewritten or wrapped
- Browser automation would require interop with Playwright or alternative solutions
-
Development Infrastructure:
- Complete rewrite of build system, testing framework, and CI/CD pipeline
- New deployment processes for all components
- Developer experience changes requiring team retraining
-
Maintenance Burden:
- Parallel maintenance during transition period
- Documentation updates across the entire codebase
- Potential for regressions during rewrite
-
Community Impact:
- Smaller ecosystem and community compared to TypeScript/JavaScript
- Fewer available libraries and integrations
- Steeper learning curve for new contributors
-
Time and Resource Investment:
- Complete rewrite would require significant developer time
- Extensive testing to ensure feature parity
- Potential delays in roadmap for new features
Recommendation
Before proceeding with a full refactoring effort, consider:
- Creating a proof-of-concept for a limited component to evaluate feasibility
- Starting with a smaller, non-critical package to test the approach
- Evaluating specific pain points in the current TypeScript implementation that Clojure might address
- Considering a gradual approach where new features are written in Clojure while maintaining existing TypeScript code
Next Steps
- Gather input from team members on this analysis
- Create a small proof-of-concept implementation of a core component
- Benchmark TypeScript vs Clojure implementations for key workflows
- Develop a more detailed migration plan if the team decides to proceed