|
| 1 | +# Contributing to Copilot-Liku CLI |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Copilot-Liku CLI! This guide will help you get started with local development. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- **Node.js** v22 or higher |
| 10 | +- **npm** v10 or higher |
| 11 | +- **Git** |
| 12 | +- (On Windows) **PowerShell** v6 or higher |
| 13 | + |
| 14 | +### Initial Setup |
| 15 | + |
| 16 | +1. **Fork and clone the repository:** |
| 17 | +```bash |
| 18 | +git clone https://github.com/YOUR-USERNAME/copilot-Liku-cli.git |
| 19 | +cd copilot-Liku-cli |
| 20 | +``` |
| 21 | + |
| 22 | +2. **Install dependencies:** |
| 23 | +```bash |
| 24 | +npm install |
| 25 | +``` |
| 26 | + |
| 27 | +3. **Link for global usage (recommended for testing):** |
| 28 | +```bash |
| 29 | +npm link |
| 30 | +``` |
| 31 | + |
| 32 | +This creates a symlink from your global `node_modules` to your local development directory. Any changes you make will be immediately reflected when you run the `liku` command. |
| 33 | + |
| 34 | +4. **Verify the setup:** |
| 35 | +```bash |
| 36 | +liku --version |
| 37 | +liku --help |
| 38 | +``` |
| 39 | + |
| 40 | +### Development Workflow |
| 41 | + |
| 42 | +#### Testing Your Changes |
| 43 | + |
| 44 | +After making changes to the CLI code: |
| 45 | + |
| 46 | +1. **Test the CLI commands:** |
| 47 | +```bash |
| 48 | +liku --help # Test help output |
| 49 | +liku start # Test starting the app |
| 50 | +liku click "Button" # Test automation commands |
| 51 | +``` |
| 52 | + |
| 53 | +2. **Run existing tests:** |
| 54 | +```bash |
| 55 | +npm test # Run test suite |
| 56 | +npm run test:ui # Run UI automation tests |
| 57 | +``` |
| 58 | + |
| 59 | +3. **Manual testing:** |
| 60 | +```bash |
| 61 | +# Start the application |
| 62 | +liku start |
| 63 | + |
| 64 | +# Test specific commands |
| 65 | +liku screenshot |
| 66 | +liku window "VS Code" |
| 67 | +``` |
| 68 | + |
| 69 | +#### Unlinking When Done |
| 70 | + |
| 71 | +If you need to unlink your development version: |
| 72 | +```bash |
| 73 | +npm unlink -g copilot-liku-cli |
| 74 | +``` |
| 75 | + |
| 76 | +Or to install the published version: |
| 77 | +```bash |
| 78 | +npm unlink -g copilot-liku-cli |
| 79 | +npm install -g copilot-liku-cli |
| 80 | +``` |
| 81 | + |
| 82 | +### Project Structure |
| 83 | + |
| 84 | +``` |
| 85 | +copilot-Liku-cli/ |
| 86 | +├── src/ |
| 87 | +│ ├── cli/ # CLI implementation |
| 88 | +│ │ ├── liku.js # Main CLI entry point |
| 89 | +│ │ ├── commands/ # Command implementations |
| 90 | +│ │ └── util/ # CLI utilities |
| 91 | +│ ├── main/ # Electron main process |
| 92 | +│ ├── renderer/ # Electron renderer process |
| 93 | +│ └── shared/ # Shared utilities |
| 94 | +├── scripts/ # Build and test scripts |
| 95 | +├── docs/ # Additional documentation |
| 96 | +└── package.json # Package configuration with bin entry |
| 97 | +``` |
| 98 | + |
| 99 | +### Making Changes |
| 100 | + |
| 101 | +#### Adding a New CLI Command |
| 102 | + |
| 103 | +1. Create a new command file in `src/cli/commands/`: |
| 104 | +```javascript |
| 105 | +// src/cli/commands/mycommand.js |
| 106 | +async function run(args, options) { |
| 107 | + // Command implementation |
| 108 | + console.log('Running my command with args:', args); |
| 109 | + return { success: true }; |
| 110 | +} |
| 111 | + |
| 112 | +module.exports = { run }; |
| 113 | +``` |
| 114 | + |
| 115 | +2. Register the command in `src/cli/liku.js`: |
| 116 | +```javascript |
| 117 | +const COMMANDS = { |
| 118 | + // ... existing commands |
| 119 | + mycommand: { |
| 120 | + desc: 'Description of my command', |
| 121 | + file: 'mycommand', |
| 122 | + args: '[optional-arg]' |
| 123 | + }, |
| 124 | +}; |
| 125 | +``` |
| 126 | + |
| 127 | +3. Test your command: |
| 128 | +```bash |
| 129 | +liku mycommand --help |
| 130 | +``` |
| 131 | + |
| 132 | +#### Modifying the CLI Parser |
| 133 | + |
| 134 | +The main CLI logic is in `src/cli/liku.js`. Key functions: |
| 135 | +- `parseArgs()` - Parses command-line arguments |
| 136 | +- `executeCommand()` - Loads and runs command modules |
| 137 | +- `showHelp()` - Displays help text |
| 138 | + |
| 139 | +### Code Style |
| 140 | + |
| 141 | +- Follow existing code conventions |
| 142 | +- Use meaningful variable names |
| 143 | +- Add comments for complex logic |
| 144 | +- Keep functions focused and small |
| 145 | + |
| 146 | +### Testing Guidelines |
| 147 | + |
| 148 | +1. **Test your changes locally** before submitting a PR |
| 149 | +2. **Ensure existing tests pass**: `npm test` |
| 150 | +3. **Add tests for new features** when applicable |
| 151 | +4. **Test cross-platform** if possible (Windows, macOS, Linux) |
| 152 | + |
| 153 | +### Submitting Changes |
| 154 | + |
| 155 | +1. **Create a feature branch:** |
| 156 | +```bash |
| 157 | +git checkout -b feature/my-feature |
| 158 | +``` |
| 159 | + |
| 160 | +2. **Make your changes and commit:** |
| 161 | +```bash |
| 162 | +git add . |
| 163 | +git commit -m "Add feature: description" |
| 164 | +``` |
| 165 | + |
| 166 | +3. **Push to your fork:** |
| 167 | +```bash |
| 168 | +git push origin feature/my-feature |
| 169 | +``` |
| 170 | + |
| 171 | +4. **Open a Pull Request** on GitHub with: |
| 172 | + - Clear description of changes |
| 173 | + - Reasoning for the changes |
| 174 | + - Any testing performed |
| 175 | + - Screenshots if UI changes |
| 176 | + |
| 177 | +### Troubleshooting |
| 178 | + |
| 179 | +#### `liku` command not found after `npm link` |
| 180 | + |
| 181 | +Make sure npm's global bin directory is in your PATH: |
| 182 | +```bash |
| 183 | +npm bin -g |
| 184 | +``` |
| 185 | + |
| 186 | +Add the output directory to your PATH if needed. |
| 187 | + |
| 188 | +#### Changes not reflected when running `liku` |
| 189 | + |
| 190 | +1. Verify you're linked to the local version: |
| 191 | +```bash |
| 192 | +which liku # Unix/Mac |
| 193 | +where liku # Windows |
| 194 | +``` |
| 195 | + |
| 196 | +2. Re-link if needed: |
| 197 | +```bash |
| 198 | +npm unlink -g copilot-liku-cli |
| 199 | +npm link |
| 200 | +``` |
| 201 | + |
| 202 | +#### Permission errors with `npm link` |
| 203 | + |
| 204 | +On some systems, you may need to configure npm to use a user-local prefix: |
| 205 | +```bash |
| 206 | +mkdir ~/.npm-global |
| 207 | +npm config set prefix '~/.npm-global' |
| 208 | +``` |
| 209 | + |
| 210 | +Then add `~/.npm-global/bin` to your PATH. |
| 211 | + |
| 212 | +### Additional Resources |
| 213 | + |
| 214 | +- [npm link documentation](https://docs.npmjs.com/cli/v10/commands/npm-link) |
| 215 | +- [npm bin configuration](https://docs.npmjs.com/cli/v10/configuring-npm/folders#executables) |
| 216 | +- [Project Architecture](ARCHITECTURE.md) |
| 217 | +- [Testing Guide](TESTING.md) |
| 218 | + |
| 219 | +### Getting Help |
| 220 | + |
| 221 | +- Check existing [GitHub Issues](https://github.com/TayDa64/copilot-Liku-cli/issues) |
| 222 | +- Join discussions in the repository |
| 223 | +- Review documentation files in the repo |
| 224 | + |
| 225 | +Thank you for contributing! 🎉 |
0 commit comments