First off, a huge thank you for considering contributing to this project! I am incredibly grateful for your interest in making this project even better, and allowing developers to build better chat features in their projects.
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, we will reciprocate that respect by addressing your issue and assisting you finalize your pull requests.
Before contributing, ensure you have the following installed:
- Node.js (v18 or higher)
- npm
Familiarity with the following tools is recommended:
- Turborepo
- React and Next.js
- semantic-release
- Monorepo Structure
- Versioning with semantic-release
- How the CLI Package Works
- Development Workflow
- Making Your First Contribution
This is a monorepo powered by turborepo split into the following:
This project uses semantic-release to automate version management and package publishing on npm.
When changes are made to specific paths in the repository on a pull request, a GitHub action determines whether to trigger a patch
, minor
, or major
release.
Paths Monitored for Changes:
'apps/www/public/registry/index.json'
'packages/cli/\*\*'
'packages/ui/**'
To ensure proper versioning, follow the commit message formats when making changes to the chat components. If you're unsure, avoid prefixing your commit message with any of the semantic keywords (e.g., feat:
, fix:
, BREAKING CHANGE:
).
The cli package is a command-line tool that fetches components from a registry. This registry is a JSON file containing metadata about available components, such as their names
, dependencies
, files
, and types
. The registry is hosted on the web app and can be found at here.
Each component in the registry includes the following fields, which are used by the cli tool to install them:
name
: The name of the component.dependencies
: A list of other components it depends on.files
: The files that make up the component (e.g.,.tsx
,.ts
).type
: The type of component (e.g.,components:ui
orhooks
).
All chat components are maintained in the shared UI package (packages/ui/src/components/ui/chat
). Follow these steps to make changes:
- Navigate to the Shared UI Package:
cd packages/ui
- Make your changes:
- Edit the components in the
src/components/ui/chat
directory, or create new ones - For example, update the
ChatBubble
component insrc/components/ui/chat/ChatBubble.tsx
.
- Edit the components in the
- Rebuild the Shared UI Package:
- After making changes, rebuild the package to ensure the updates are reflected:
npm run build
- You can now import the components in the frontend (
www
ordocs
):
import { ChatBubble } from "@shadcn-chat/ui";
- Test Your Changes Locally:
- Start the dev server by changing directory to the root folder and run
npm run dev
- Verify the changes are applied correctly
- Update the registry
- If you’ve added or modified components, regenerate the registry to update the metadata, by changing directory to the root folder and run
npm run generate-registry
To test your newly generated registry changes locally with the npx
command, do the following:
-
Navigate to the CLI Package:
cd packages/cli
-
Run the CLI in Development Mode: Use the
start:dev
script to run the CLI with a local registry:npm run start:dev add
-
Check the file(s): The above will add the files to a
packages/cli/src/components/ui/chat
folder. This is just to test, if the CLI command works as expected.Make sure to check if the files are correct, and then delete them after!
This project uses Prettier to maintain code quality. Before committing, ensure your code passes linting and formatting checks:
npm run format
Following these guidelines ensures a smooth and efficient process for everyone involved. To contribute:
- Create your own fork of the repository
- Do the changes in your fork
- Open a pull request when you feel like the changes are finished.
This lets us review your work and discuss any necessary adjustments.
Make sure to follow a semantic commit message style.
Example of a PR:
feat: add voice input support ^--^ ^------------^ | | | +-> Summary in present tense. | +-------> Type: feat, fix, refactor, style, chore, docs or test.```
First time opening a PR? Check this out.
Thank you again for your contribution! 🎉