Thank you for your interest in contributing to Duso! This document explains how the project is organized and where to make different types of changes.
We welcome your contributions! Before you open a PR, please:
- pick something small and see if there is a need/interest first
- don't pass us slop! test and re-test and review your code
- we may not want your contribution, and that should be ok
- don't be discouraged! sometimes it takes time to match the mindset and pace of a new open source project
Duso is organized around two core audiences: Go developers embedding Duso and script writers using the CLI.
cmd/duso/ - CLI application (entry point)
pkg/
├── script/ - Core language (lexer, parser, evaluator, builtins)
├── runtime/ - Runtime orchestration (HTTP, datastore, concurrency)
├── cli/ - CLI-specific functions (file I/O, Claude, module resolution)
├── anthropic/ - Claude API client (internal)
└── markdown/ - Markdown rendering (internal)
go-embedding/ - Go embedding examples (not embedded in binary)
examples/
├── core/ - Language feature examples (work everywhere)
└── cli/ - CLI-specific examples (file I/O, Claude)
docs/
├── embedding/ - Documentation for Go developers
└── cli/ - Documentation for script writers
vscode/ - VSCode syntax highlighting extension
Three-Layer Architecture:
-
pkg/script/- Language Core (Embeddable)- Lexer, parser, evaluator
- Type system and value representation
- Core built-in functions
- Environment and scope management
- No I/O, no HTTP, no external dependencies
-
pkg/runtime/- Orchestration Layer (Embeddable)- HTTP server (
HTTPServerValue) - HTTP client (
HTTPClientValue) - Internal, used by fetch() - Datastore coordination (
DatastoreValue) - Goroutine context management
- Request/concurrency primitives
- Can be used in embedded apps or CLI
- HTTP server (
-
pkg/cli/- CLI Features (CLI-only)- File I/O (load, save, include, require)
- Claude integration (claude, conversation)
- Module resolution and circular dependency detection
- Script function wrappers for runtime features
- Documentation lookup
- Environment variable access
You want to add: Operators, syntax, control flow, new built-in functions
Files to modify:
pkg/script/token.go- Add token type if neededpkg/script/lexer.go- Add tokenization if neededpkg/script/parser.go- Add parsing logicpkg/script/evaluator.go- Add evaluation logicpkg/script/builtins.go- If it's a built-in functiondocs/learning-duso.md- Document the featureexamples/core/- Add example demonstrating the feature
Process:
- Make language changes in
pkg/script/ - Add example to
examples/core/ - Update
docs/learning-duso.md - Test in both embedded and CLI contexts
You want to add: HTTP server enhancements, datastore features, concurrency primitives, goroutine management
Files to modify:
pkg/runtime/- Implement the core featurepkg/cli/- Create wrapper function(s) if needed for script usedocs/internals.md- Document the runtime architectureexamples/core/- Add example (works in embedded and CLI contexts)
Process:
- Implement in
pkg/runtime/ - If needed for scripts, create wrapper in
pkg/cli/to expose it - Register wrapper in
pkg/cli/register.go(for CLI usage) - Update documentation
- Add examples showing embedded and CLI usage
- Test in both contexts
Examples of runtime features:
pkg/runtime/http_server.go+pkg/cli/http_server.gowrapperpkg/runtime/datastore.go+pkg/cli/datastore.gowrapperpkg/runtime/goroutine_context.go+pkg/cli/run.goandpkg/cli/spawn.gowrappers
You want to add: File I/O enhancements, new Claude API patterns, module resolution improvements
Files to modify:
pkg/cli/- Implement the featurecmd/duso/main.go- Register if neededdocs/cli/- Document the featureexamples/cli/- Add example (CLI-only)
Process:
- Implement in
pkg/cli/ - Register in
pkg/cli/register.go - Add example to
examples/cli/ - Update relevant docs in
docs/cli/ - Document that this feature is CLI-only (not embeddable)
Examples of CLI-only features:
- File I/O (
load,save,include) - Module resolution (
require) - Claude integration (
claude,conversation) - Environment variable access (
env)
You want embedders to: Use a pre-built function in their apps
Files to modify:
pkg/script/builtins.go- Add the function- Provide registration code (or build it into core)
docs/embedding/CUSTOM_FUNCTIONS.md- Document patternsdocs/learning-duso.md- If it's a core built-in
Process:
- Implement in
pkg/script/builtins.go - Add to appropriate test file
- Document in learning guide
- Provide example
You want to: Share a Duso module that gets included in Duso binary distributions
What you provide: Pure Duso code - no Go required
Files to modify:
- Create a repository:
duso-<modulename>on GitHub - Add your module as
.dufiles with Apache 2.0 license - Include documentation and examples
- Submit for review
Process:
-
Create your module in a separate repository
- Follow the naming convention:
duso-postgres,duso-helpers, etc. - License under Apache 2.0 (copy from Duso's LICENSE file)
- Include clear documentation and examples
- Follow the naming convention:
-
Open an issue on the Duso repository requesting review
- Include: repo URL, module description, use case
- Duso team reviews for quality and standards
-
Once approved, module is added to
contrib/- Module becomes available in all future Duso distributions
- Code is baked into the binary at build time
-
Your module is frozen in time with each release
- Duso can preserve working versions indefinitely
- Users get a reliable, dependency-free way to use your module
For more details: See contrib/README.md
Context: See custom distributions to understand how modules are included in binary distributions.
Files to modify:
docs/learning-duso.md- Language syntax and semanticsdocs/embedding/- Guides for Go developersdocs/cli/- Guides for script writersREADME.md- Project overview- In-code comments - Implementation details
Process:
- Identify unclear or missing documentation
- Improve clarity, add examples
- Test that examples actually work
- Update related documentation files
Process:
- Identify which package contains the bug
- Add test case demonstrating the bug
- Fix the bug
- Verify test passes
- Check if documentation needs updating
- Update examples if behavior changed
- Follow Go conventions
- Use
camelCasefor functions/variables - Use
snake_casefor Duso language functions - Comment exported functions and complex logic
- Add test cases for new features
- Test in both embedded and CLI contexts
- If you add a language feature, ensure it works when embedded
- If you add a CLI feature, ensure it doesn't break embedding
- Document all exported Go functions
- Add examples in
/examples/for user-facing features - Update relevant documentation files
- Comment complex algorithms
- Fork the repository
- Create a branch with a descriptive name:
feature/add-xyz,fix/issue-123 - Make your changes following the guidelines above
- Write/update tests for your changes
- Update documentation - Both code comments and user docs
- Add examples if applicable
- Test thoroughly - Both embedded and CLI usage
- Submit PR with description of changes
Label: feature: language
These go in pkg/script/ and may affect both embedding and CLI.
Example: "Add switch/case syntax"
Label: feature: runtime
These go in pkg/runtime/ and can be used in embedded and CLI contexts.
Example: "Add request caching to fetch()", "Add timeout to datastore operations"
Label: feature: cli
These go in pkg/cli/ and only affect CLI usage.
Example: "Add ability to set environment variables from script", "Improve module resolution for monorepos"
Label: docs
Unclear, missing, or outdated documentation.
Example: "The file I/O guide doesn't explain path resolution"
Label: bug
Something doesn't work as documented.
Provide:
- What you tried
- What you expected
- What happened instead
- Minimal reproduction case
git clone https://github.com/duso-org/duso
cd duso
# For maintainers only: install git hooks for automatic versioning
./git-setup.sh
# Build the CLI
./build.sh
# Run a test script
duso examples/core/basic.duFor maintainers: After cloning, run ./git-setup.sh to install git hooks for automatic versioning based on commit messages (feat:, fix:, major: prefixes).
Symlink for convenience (so you can run duso from anywhere):
ln -s $(pwd)/bin/duso /usr/local/bin/duso# Run tests
go test ./...
# Run a specific example
duso examples/core/functions.du
# Test with verbose output
duso -v examples/core/basic.du# Test a Go embedding example
cd go-embedding
go run ./hello-world- Backward Compatibility - Don't break existing scripts
- Core is Minimal - Keep
pkg/script/focused on language - CLI is Optional - Core features should work without CLI
- Clear Separation - Embedded vs CLI concerns should be obvious
- Documentation - Every user-facing feature needs good docs
- Examples - Show, don't just tell
- Check Documentation for documentation navigation
- Look at existing code for patterns
- Review related issues and pull requests
- Ask in a discussion or new issue
Be respectful, inclusive, and constructive. Welcome contributors and help them succeed.
Thank you for contributing to Duso!