Add 4 major features to codetyper-cli:
- Hooks System: Lifecycle hooks (PreToolUse, PostToolUse, SessionStart,
SessionEnd, UserPromptSubmit, Stop) with exit code control flow
- Plugin System: Custom tools, commands, and hooks via plugin manifest
- Session Forking: Snapshots, rewind, fork, and switch between branches
- Vim Motions: Normal/Insert/Command/Visual modes with keyboard navigation
New files:
- src/types/{hooks,plugin,session-fork,vim}.ts
- src/constants/{hooks,plugin,session-fork,vim}.ts
- src/services/{hooks-service,plugin-loader,plugin-service,session-fork-service}.ts
- src/stores/vim-store.ts (vanilla)
- src/tui/hooks/{useVimMode,useVimStore,useTodoStore,useThemeStore}.ts
- src/tui/components/VimStatusLine.tsx
Modified:
- src/services/agent.ts (hook integration)
- src/tools/index.ts (plugin tool registration)
- src/stores/{todo-store,theme-store}.ts (converted to vanilla)
- TUI components (updated hook imports)
5.8 KiB
5.8 KiB
Contributing to CodeTyper CLI
Thank you for your interest in contributing to CodeTyper CLI! This document provides guidelines and instructions for contributing.
Code of Conduct
Please be respectful and constructive in all interactions. We welcome contributors of all experience levels.
Getting Started
Prerequisites
- Node.js >= 18.0.0
- npm or yarn
- Git
Setup
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/codetyper-cli.git cd codetyper-cli - Install dependencies:
npm install - Build the project:
npm run build - Link for local testing:
npm link
Development Workflow
# Start TypeScript watch mode
npm run dev
# Run tests
npm test
# Lint code
npm run lint
# Format code
npm run format
How to Contribute
Reporting Bugs
- Check existing issues to avoid duplicates
- Create a new issue with:
- Clear, descriptive title
- Steps to reproduce
- Expected vs actual behavior
- Environment details (OS, Node version, provider)
- Relevant logs or screenshots
Suggesting Features
- Check existing issues for similar requests
- Create a feature request with:
- Clear description of the feature
- Use cases and motivation
- Proposed implementation (optional)
Submitting Pull Requests
-
Create a branch from
main:git checkout -b feature/your-feature-name -
Make your changes following our coding standards
-
Write/update tests if applicable
-
Ensure all tests pass:
npm test -
Commit with clear messages:
git commit -m "feat: add new feature description" -
Push and create a Pull Request
Commit Message Format
We follow Conventional Commits:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting, etc.)refactor:- Code refactoringtest:- Adding or updating testschore:- Maintenance tasks
Examples:
feat: add permission caching for faster lookups
fix: resolve race condition in agent loop
docs: update README with new CLI options
Coding Standards
TypeScript
- Use TypeScript strict mode
- Define explicit types (avoid
anywhen possible) - Use interfaces for object shapes
- Export types that are part of the public API
Code Style
- Use 2 spaces for indentation
- Use single quotes for strings
- Add trailing commas in multi-line structures
- Keep lines under 100 characters when reasonable
File Organization
src/
├── index.ts # Entry point only
├── commands/ # CLI command implementations
├── constants/ # Centralized constants
├── interfaces/ # Interface definitions
├── providers/ # LLM provider integrations
├── services/ # Business logic services
│ ├── hooks-service.ts # Lifecycle hooks
│ ├── plugin-service.ts # Plugin management
│ ├── plugin-loader.ts # Plugin discovery
│ └── session-fork-service.ts # Session forking
├── stores/ # Zustand state stores
│ └── vim-store.ts # Vim mode state
├── tools/ # Agent tools (bash, read, write, edit)
├── tui/ # Terminal UI components
│ ├── components/ # Reusable UI components
│ └── hooks/ # React hooks (useVimMode, etc.)
└── types/ # Type definitions
Testing
- Write tests for non-UI logic
- Place tests in
tests/directory - Name test files
*.test.ts - Use descriptive test names
describe('PermissionManager', () => {
it('should match wildcard patterns correctly', () => {
// ...
});
});
Documentation
- Add JSDoc comments for public APIs
- Update README for user-facing changes
- Update CHANGELOG for notable changes
Project Structure
Key Files
| File | Purpose |
|---|---|
src/index.ts |
CLI entry point, command registration |
src/services/agent.ts |
Agent loop, tool orchestration |
src/services/permissions.ts |
Permission system |
src/services/hooks-service.ts |
Lifecycle hooks |
src/services/plugin-service.ts |
Plugin management |
src/services/session-fork-service.ts |
Session forking |
src/commands/chat-tui.tsx |
Main TUI command |
src/tui/App.tsx |
Root TUI component |
src/tui/store.ts |
Zustand state management |
src/stores/vim-store.ts |
Vim mode state |
src/tui/hooks/useVimMode.ts |
Vim keyboard handling |
Adding a New Provider
- Create
src/providers/yourprovider.ts - Implement the
Providerinterface - Register in
src/providers/index.ts - Add authentication in
src/commands/login.ts - Update documentation
Adding a New Tool
- Create
src/tools/yourtool.ts - Define parameters with Zod schema
- Implement
executefunction - Register in
src/tools/index.ts - Add permission handling if needed
Adding a Hook Event
- Add event type to
src/types/hooks.ts - Add constants to
src/constants/hooks.ts - Add input type for the event
- Implement execution in
src/services/hooks-service.ts - Call hook from appropriate location
Creating a Plugin
- Create directory in
.codetyper/plugins/{name}/ - Add
plugin.jsonmanifest - Add tools in
tools/*.ts - Add commands in
commands/*.md - Add hooks in
hooks/*.sh
Adding Vim Bindings
- Add binding to
VIM_DEFAULT_BINDINGSinsrc/constants/vim.ts - Add action handler in
src/tui/hooks/useVimMode.ts - Update documentation
Questions?
- Open a GitHub issue for questions
- Tag with
questionlabel
License
By contributing, you agree that your contributions will be licensed under the MIT License.