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 home
  • http://localhost:4321/demo - Demo page with sample documentation
  • http://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

  1. Make changes to the integration source in /src
  2. Run npm run build (or npm run dev for watch mode)
  3. Test changes in the playground
  4. Submit feedback using the widget
  5. 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

  1. Run tests: npm test
  2. Run linter: npm run lint
  3. Test in playground: cd playground && npm run dev
  4. Update documentation if needed