# Contributing to zCode CLI X Thank you for your interest in contributing to zCode CLI X! This document provides guidelines and instructions for contributing. ## ๐ŸŒŸ How to Contribute ### Types of Contributions We welcome many types of contributions: - **Bug Reports** โ€” Found a bug? Let us know! - **Feature Requests** โ€” Have an idea? Share it! - **Code Changes** โ€” Fix bugs, add features, improve performance - **Documentation** โ€” Improve README, add examples, fix typos - **Tests** โ€” Add test coverage for new features - **Community Support** โ€” Help others in issues and discussions --- ## ๐Ÿš€ Quick Start for Contributors ### 1. Fork & Clone ```bash # Fork the repo on GitHub, then clone: git clone https://github.rommark.dev/admin/zCode-CLI-X.git cd zCode-CLI-X ``` ### 2. Install Dependencies ```bash npm install ``` ### 3. Run Smoke Tests ```bash # Verify everything works node test-ruflo-smoke.mjs # Should show: 53/53 tests passing ``` ### 4. Make Changes Follow the guidelines below, then: ```bash # Test your changes npm test # Commit with descriptive message git commit -m "feat: add new feature" ``` ### 5. Push & Create PR ```bash git push origin main # Create pull request on GitHub ``` --- ## ๐Ÿ“ Development Guidelines ### Code Style - **JavaScript** โ€” Use ES modules (`import`/`export`) - **Naming** โ€” `camelCase` for variables/functions, `PascalCase` for classes - **Comments** โ€” JSDoc for public APIs, inline comments for complex logic - **Error handling** โ€” Always handle errors, never ignore them ### Commit Messages Follow [Conventional Commits](https://www.conventionalcommits.org/): ```bash feat: add new feature fix: bug fix docs: documentation changes style: formatting, missing semicolons (no code change) refactor: code refactoring test: adding or updating tests chore: maintenance tasks (not user-facing) ``` **Examples**: ```bash feat: add multi-agent swarm support fix: resolve memory backend eviction bug docs: update installation instructions refactor: simplify plugin loading logic test: add smoke tests for hook system ``` ### Branch Naming ```bash feat/new-feature fix/bug-fix docs/update-readme refactor/code-improvement test/add-tests ``` --- ## ๐Ÿ—๏ธ Architecture Guidelines ### Plugin System When adding new plugins: 1. **Define extension point** in `src/plugins/ExtensionPoints.js` 2. **Implement plugin** extending `BasePlugin` in `src/plugins/Plugin.js` 3. **Register in PluginManager** โ€” Add to extension point routing 4. **Document** โ€” Add to CREDITS.md or docs **Example**: ```javascript // src/plugins/MyPlugin.js import { BasePlugin } from './Plugin.js'; export class MyPlugin extends BasePlugin { name = 'my-plugin'; async initialize() { console.log('MyPlugin initialized'); } async shutdown() { console.log('MyPlugin shut down'); } } ``` ### Hook System When adding new hooks: 1. **Define hook type** in `src/bot/hooks.js` 2. **Register hook** with priority order 3. **Document** โ€” Add to README.md **Example**: ```javascript // src/bot/hooks.js export const HOOK_TYPES = { TOOL_PRE: 'tool.pre', TOOL_POST: 'tool.post', AI_PRE: 'ai.pre', AI_POST: 'ai.post', // Add your custom hooks here MY_CUSTOM_HOOK: 'my.custom.hook' }; ``` ### Agent System When adding new agent roles: 1. **Add to agents/index.js** โ€” Define agent type 2. **Update system prompt** โ€” Add agent description 3. **Document** โ€” Add to README.md feature comparison table **Example**: ```javascript // src/agents/index.js export const AGENT_TYPES = { coder: { id: 'coder', name: 'Coder', description: 'Implementation, debugging, refactoring' }, // Add your new agent here analyst: { id: 'analyst', name: 'Data Analyst', description: 'Data analysis, visualization, insights' } }; ``` --- ## ๐Ÿงช Testing ### Run Smoke Tests ```bash node test-ruflo-smoke.mjs ``` **Coverage**: - โœ… PluginSystem: 10 tests - โœ… HookSystem: 4 tests - โœ… AgentSystem: 9 tests - โœ… SwarmCoordinator: 12 tests - โœ… AgentOrchestrator: 4 tests - โœ… MemoryBackend: 14 tests - **Total**: 53 tests ### Add New Tests When adding new features, add tests: ```javascript // test-my-feature.mjs import { test } from 'node:test'; import assert from 'node:assert'; test('my feature works', async () => { const result = await myFunction(); assert.strictEqual(result, expected); }); ``` --- ## ๐Ÿ“š Documentation ### README.md Update README when: - Adding new features - Changing configuration options - Updating installation steps - Adding new agents/tools ### Architecture.md Update ARCHITECTURE.md when: - Changing system architecture - Adding new components - Modifying message flows ### CREDITS.md Update CREDITS.md when: - Adding new dependencies - Acknowledging new contributors - Updating third-party licenses --- ## ๐Ÿ”’ Security Guidelines ### Never Commit Secrets **DO**: ```bash # Use environment variables ZAI_API_KEY=${ZAI_API_KEY} TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN} ``` **DON'T**: ```bash # Hardcoded secrets in code const API_KEY = 'abc123'; // NEVER DO THIS ``` ### Validate User Input Always validate and sanitize user input: ```javascript // Validate Telegram user ID if (!/^\d+$/.validate(userId)) { throw new Error('Invalid user ID'); } ``` ### Protect Sensitive Files Never modify these files via self-evolve: - `SelfEvolveTool.js` โ€” The safety system itself - `stt.py` โ€” Voice recognition bridge - `.env` โ€” Environment variables - `package.json` โ€” Dependencies --- ## ๐Ÿ› Bug Reports When reporting a bug: 1. **Search existing issues** โ€” Make sure it's not already reported 2. **Provide reproduction steps** โ€” How to trigger the bug 3. **Include logs** โ€” `journalctl --user -u zcode -f` 4. **Specify environment** โ€” Node version, OS, configuration 5. **Expected vs actual behavior** โ€” What should happen vs what does **Example**: ``` **Bug**: Bot crashes on voice message **Steps to reproduce**: 1. Send voice message to bot 2. Bot crashes with error **Expected**: Bot transcribes voice and responds **Actual**: Bot crashes with "Vosk model not found" **Environment**: - Node.js: v20.10.0 - OS: Ubuntu 24.04 - Vosk model: ~/vosk-models/vosk-model-small-0.15 ``` --- ## ๐Ÿ’ก Feature Requests When requesting a feature: 1. **Describe the use case** โ€” Why do you need this? 2. **Provide examples** โ€” How would you use it? 3. **Consider alternatives** โ€” What existing features could work? 4. **Estimate impact** โ€” How many users would benefit? **Example**: ``` **Feature**: Add support for custom AI models **Use case**: I want to use my own fine-tuned model **Example**: `/model use my-custom-model-v2` **Alternatives**: Currently using Z.AI GLM-5.1 **Impact**: Would help users with specific model requirements ``` --- ## ๐Ÿ“„ Pull Request Process ### Before Submitting 1. โœ… **Run all tests** โ€” `npm test` should pass 2. โœ… **Update documentation** โ€” README, ARCHITECTURE, CREDITS 3. โœ… **Add tests for new features** โ€” Test coverage > 80% 4. โœ… **Follow code style** โ€” Consistent formatting 5. โœ… **Write descriptive commit messages** โ€” Conventional Commits ### PR Template ```markdown ## Description Brief description of changes ## Type of Change - [ ] Bug fix - [ ] New feature - [ ] Documentation update - [ ] Refactoring - [ ] Test addition ## Testing - [ ] Tests added/updated - [ ] Smoke tests passing - [ ] Manual testing done ## Checklist - [ ] Code follows project style - [ ] Documentation updated - [ ] No breaking changes - [ ] Self-review done ``` --- ## ๐ŸŽฏ Code Review ### Reviewers Will Check - **Functionality** โ€” Does it work as expected? - **Security** โ€” Any vulnerabilities? - **Performance** โ€” Any bottlenecks? - **Testing** โ€” Adequate test coverage? - **Documentation** โ€” Is it documented? - **Style** โ€” Follows project conventions? ### Review Process 1. Automated checks (tests, linting) 2. Core team review (1-2 reviewers) 3. Address feedback 4. Merge to main --- ## ๐ŸŒ Community Guidelines ### Be Respectful - Treat everyone with respect - Provide constructive feedback - Accept constructive criticism - Focus on ideas, not people ### Be Helpful - Help new contributors - Share knowledge - Answer questions - Document well ### Be Patient - Code review takes time - Feedback is for improvement - Iteration is normal - Quality over speed --- ## ๐Ÿ“ž Getting Help ### Channels - **Issues**: [GitHub Issues](https://github.rommark.dev/admin/zCode-CLI-X/issues) - **Discussions**: [GitHub Discussions](https://github.rommark.dev/admin/zCode-CLI-X/discussions) - **Telegram**: [@zcode_bot](https://t.me/zcode_bot) (ask questions) ### FAQ **Q: How do I set up the development environment?** A: Follow [INSTALLATION.md](./INSTALLATION.md) **Q: What's the best way to start contributing?** A: Look for "good first issue" labels on GitHub **Q: How long does code review take?** A: Usually 1-3 days, depending on complexity **Q: Can I work on an existing issue?** A: Yes! Comment "I'm working on this" to claim it --- ## ๐Ÿ“œ License By contributing, you agree that your contributions will be licensed under the [MIT License](./LICENSE). --- ## ๐Ÿ™ Thank You! Thank you for contributing to zCode CLI X! Your contributions make this project better for everyone. **Questions?** Open an issue or start a discussion! ---
**Contributions welcome!** ๐Ÿš€ *Let's build the ultimate agentic coding assistant together*