Development Guide
๐งช Development & Testing
This project includes a playground for testing the integration during development.
Clone and Setup
# Clone the repository
git clone https://github.com/altairalabs/astro-ai-coauthor.git
cd astro-ai-coauthor
# Install dependencies
npm install
# Build the integration
npm run build
Testing with the Playground
The /playground directory contains a test Astro site:
# Install playground dependencies
cd playground
npm install
# Start the playground dev server
npm run dev
Then visit:
http://localhost:4321/- Playground homehttp://localhost:4321/demo- Demo page with sample documentationhttp://localhost:4321/_ai-coauthor/dashboard- View collected feedback
The playground imports the integration from ../dist/index.js, so make sure to rebuild the main package (npm run build in the root) after making changes.
Development Workflow
- Make changes to the integration source in
/src - Run
npm run build(ornpm run devfor watch mode) - Test changes in the playground
- Submit feedback using the widget
- View results in the dashboard
Running Tests
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverage
Linting
# Run linter
npm run lint
# Fix linting issues
npm run lint:fix
Project Structure
astro-ai-coauthor/
โโโ src/
โ โโโ index.ts # Main integration entry point
โ โโโ storage/ # Storage adapters
โ โ โโโ FeedbackStorageAdapter.ts
โ โ โโโ FileStorageAdapter.ts
โ โ โโโ index.ts
โ โโโ virtual/ # Virtual API endpoints
โ โ โโโ feedback-endpoint.ts
โ โโโ client/
โ โ โโโ feedback-widget.ts # Feedback widget UI
โ โโโ pages/
โ โ โโโ _ai-coauthor/
โ โ โโโ dashboard.astro # Dashboard page
โ โโโ __tests__/ # Test files
โ โโโ integration.test.ts
โ โโโ storage.test.ts
โ โโโ feedback-endpoint.test.ts
โโโ playground/ # Test site
โโโ docs/ # Documentation
โโโ .github/
โ โโโ workflows/
โ โโโ ci.yml # GitHub Actions CI
โโโ package.json
โโโ tsconfig.json
โโโ vitest.config.ts
โโโ .eslintrc.json
โโโ sonar-project.properties
Debugging
See DEBUGGING.md for detailed debugging instructions.
Contributing
Contributions are welcome! Please test your changes using the playground before submitting a PR.
Before Submitting a PR
- Run tests:
npm test - Run linter:
npm run lint - Test in playground:
cd playground && npm run dev - Update documentation if needed