Skip to content

Commit 2c0543c

Browse files
Copilottyler-dane
andcommitted
feat(ai-tools): add AI tooling directory with documentation generators and workflows
Co-authored-by: tyler-dane <30163055+tyler-dane@users.noreply.github.com>
1 parent bedac74 commit 2c0543c

9 files changed

Lines changed: 1745 additions & 1 deletion

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ playwright-report/
3333
test-results/
3434
blob-report/
3535

36+
# AI tools generated files
37+
ai-tools/api-documentation.md
38+
ai-tools/type-reference.md
39+
ai-tools/code-index.json
40+
3641
#core
3742
packages/core/build/
3843

CONTRIBUTING.md

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,261 @@
22

33
The Compass Contribution Guide is available on the official doc site:
44
[https://docs.compasscalendar.com/docs/how-to-contribute/contribute](https://docs.compasscalendar.com/docs/how-to-contribute/contribute)
5+
6+
## For AI Agents
7+
8+
This section provides specific guidelines for AI coding agents working on Compass.
9+
10+
### Getting Started
11+
12+
1. **Read the Documentation First**
13+
- Start with [AGENTS.md](./AGENTS.md) for complete development instructions
14+
- Review [README.md](./README.md) for project overview
15+
- Check existing issues and PRs for context
16+
17+
2. **Environment Setup**
18+
19+
```bash
20+
yarn install --frozen-lockfile --network-timeout 300000
21+
cp packages/backend/.env.local.example packages/backend/.env
22+
yarn dev:web # Verify frontend works
23+
```
24+
25+
3. **Understand the Codebase**
26+
- Use `yarn ai:index` to generate semantic search index
27+
- Explore `ai-tools/` directory for helpful scripts
28+
- Review architecture in [AGENTS.md](./AGENTS.md)
29+
30+
### Coding Standards for AI Agents
31+
32+
#### 1. Module Imports
33+
34+
**ALWAYS** use module aliases instead of relative paths:
35+
36+
```typescript
37+
// ✅ Correct
38+
import { foo } from '@compass/core'
39+
import { bar } from '@web/common/utils'
40+
import { baz } from '@core/types'
41+
42+
// ❌ Wrong
43+
import { foo } from '../../../core/src'
44+
import { bar } from '../../common/utils'
45+
```
46+
47+
#### 2. Type Safety and Validation
48+
49+
**ALWAYS** use Zod for validation:
50+
51+
```typescript
52+
import { z } from "zod";
53+
54+
// Define schema
55+
export const UserSchema = z.object({
56+
id: z.string(),
57+
email: z.string().email(),
58+
name: z.string().min(1),
59+
});
60+
61+
// Export type from schema
62+
export type User = z.infer<typeof UserSchema>;
63+
64+
// Use for validation
65+
export const validateUser = (data: unknown): User => UserSchema.parse(data);
66+
```
67+
68+
#### 3. Testing Requirements
69+
70+
Write tests following user behavior patterns:
71+
72+
```typescript
73+
// ✅ Correct - Using semantic queries
74+
const button = screen.getByRole('button', { name: /save/i });
75+
await user.click(button);
76+
77+
// ❌ Wrong - Using implementation details
78+
const button = container.querySelector('.save-button');
79+
button.click();
80+
```
81+
82+
#### 4. API Route Documentation
83+
84+
Document all backend routes with JSDoc:
85+
86+
```typescript
87+
/**
88+
* Get user profile information
89+
* @route GET /api/user/profile
90+
* @auth Required - Supertokens session
91+
* @returns {UserProfile} User profile data
92+
* @throws {401} Unauthorized - Invalid or missing session
93+
* @throws {404} Not Found - User not found
94+
*/
95+
.get(userController.getProfile);
96+
```
97+
98+
#### 5. Error Handling
99+
100+
Always include proper error handling:
101+
102+
```typescript
103+
try {
104+
const result = await apiCall();
105+
return { success: true, data: result };
106+
} catch (error) {
107+
logger.error('Operation failed', { error, context });
108+
throw new ApiError('User-friendly message', 500);
109+
}
110+
```
111+
112+
### Git Workflow for AI Agents
113+
114+
#### Branch Naming
115+
116+
Follow semantic branch naming:
117+
118+
```bash
119+
# Format: type/action[-issue-number]
120+
feature/add-calendar-sync
121+
bug/fix-auth-timeout
122+
docs/update-api-docs
123+
refactor/simplify-event-handler
124+
```
125+
126+
#### Commit Messages
127+
128+
Use conventional commit format:
129+
130+
```bash
131+
# Format: type(scope): description
132+
feat(web): add calendar event creation modal
133+
fix(backend): resolve authentication timeout issue
134+
docs(readme): update installation instructions
135+
refactor(core): simplify date utility functions
136+
test(web): add unit tests for login component
137+
```
138+
139+
**Commit Types:**
140+
141+
- `feat` - New features
142+
- `fix` - Bug fixes
143+
- `docs` - Documentation changes
144+
- `style` - Code style changes (formatting, semicolons)
145+
- `refactor` - Code refactoring
146+
- `test` - Adding or updating tests
147+
- `chore` - Maintenance tasks, dependency updates
148+
149+
**Scope Examples:**
150+
151+
- `web` - Frontend/React changes
152+
- `backend` - Server/API changes
153+
- `core` - Shared utilities/types
154+
- `scripts` - CLI tools and build scripts
155+
- `config` - Configuration files
156+
157+
### Code Review Process
158+
159+
#### Before Submitting PR
160+
161+
1. **Run Type Checking**
162+
163+
```bash
164+
yarn type-check
165+
```
166+
167+
2. **Run Tests**
168+
169+
```bash
170+
yarn test:core
171+
yarn test:web
172+
yarn test:backend
173+
```
174+
175+
3. **Check Code Health**
176+
177+
```bash
178+
yarn audit:code-health
179+
```
180+
181+
4. **Format Code**
182+
183+
```bash
184+
yarn prettier . --write
185+
```
186+
187+
5. **Generate Documentation** (if you added/modified APIs)
188+
```bash
189+
yarn docs:generate
190+
```
191+
192+
#### PR Description Template
193+
194+
```markdown
195+
## Description
196+
197+
Brief description of changes
198+
199+
## Type of Change
200+
201+
- [ ] Bug fix (non-breaking change fixing an issue)
202+
- [ ] New feature (non-breaking change adding functionality)
203+
- [ ] Breaking change (fix or feature causing existing functionality to change)
204+
- [ ] Documentation update
205+
206+
## Testing
207+
208+
- [ ] Unit tests pass (`yarn test:core`, `yarn test:web`, `yarn test:backend`)
209+
- [ ] E2E tests pass (if applicable)
210+
- [ ] Manual testing completed
211+
212+
## Checklist
213+
214+
- [ ] Code follows project style guidelines
215+
- [ ] Self-review completed
216+
- [ ] Comments added for complex logic
217+
- [ ] Documentation updated
218+
- [ ] No new warnings introduced
219+
- [ ] Tests added/updated as needed
220+
```
221+
222+
### Common Pitfalls to Avoid
223+
224+
1. **Don't use barrel files (`index.ts`)** - Use named exports directly
225+
2. **Don't use raw Tailwind colors** - Use semantic theme colors (`bg-bg-primary` not `bg-blue-300`)
226+
3. **Don't test login without backend** - Frontend tests should work standalone
227+
4. **Don't modify unrelated code** - Keep changes surgical and focused
228+
5. **Don't skip type checking** - Always run `yarn type-check` before submitting
229+
6. **Don't ignore linter warnings** - Fix all warnings in your code
230+
7. **Don't use relative imports** - Always use module aliases
231+
232+
### AI Tools Reference
233+
234+
The `ai-tools/` directory contains helper scripts:
235+
236+
- **`generate-api-docs.ts`** - Extract and document all API endpoints
237+
- **`extract-types.ts`** - Generate type documentation
238+
- **`code-health-audit.ts`** - Analyze code quality metrics
239+
- **`semantic-index.ts`** - Build search index for code navigation
240+
- **`test-harness.ts`** - Template for automated testing workflows
241+
242+
Run any tool with:
243+
244+
```bash
245+
yarn ts-node ai-tools/<script-name>.ts
246+
```
247+
248+
### Resources for AI Agents
249+
250+
- **OpenAI Harness Engineering**: [https://openai.com/index/harness-engineering/](https://openai.com/index/harness-engineering/)
251+
- **Loop Methodology**: [https://ghuntley.com/loop/](https://ghuntley.com/loop/)
252+
- **Testing Library**: Best practices for user-centric testing
253+
- **Zod Documentation**: Type-safe validation patterns
254+
255+
### Questions?
256+
257+
For issues or questions:
258+
259+
1. Check existing GitHub issues
260+
2. Review [AGENTS.md](./AGENTS.md) and docs
261+
3. Join GitHub Discussions
262+
4. Create a new issue with detailed context

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,59 @@ Want to poke around or run it self-hosted?
6969
- **Testing**: Jest, React Testing Library
7070
- **Other**: Yarn workspaces for monorepo management
7171

72+
## For AI Agents
73+
74+
Compass is designed to be AI-friendly with comprehensive tooling and documentation for automated development.
75+
76+
### Quick Reference for AI Agents
77+
78+
- **Primary Guide**: See [AGENTS.md](./AGENTS.md) for complete development instructions
79+
- **Architecture**: Monorepo with 4 packages: `@compass/web` (React frontend), `@compass/backend` (Express API), `@compass/core` (shared utilities), `@compass/scripts` (CLI tools)
80+
- **API Boundaries**: All backend routes in `packages/backend/src/*/routes.config.ts`, authenticated via Supertokens sessions
81+
- **State Management**: Redux store in `packages/web/src/store/`, organized by domain (calendar, draft, schema, settings, sidebar, task, view)
82+
- **Type System**: Zod schemas for validation, TypeScript for type safety - see `packages/core/src/types/`
83+
- **Module Aliases**: Use `@compass/*`, `@web/*`, `@core/*` instead of relative paths
84+
- **Testing**: Unit tests with Jest, E2E with Playwright - test commands: `yarn test:core`, `yarn test:web`, `yarn test:backend`
85+
- **AI Tools**: See `ai-tools/` directory for endpoint docs, type extraction, code health audits, and workflow harnesses
86+
87+
### Key Entry Points
88+
89+
- **Backend API**: `packages/backend/src/app.ts` - Express server initialization
90+
- **Frontend**: `packages/web/src/index.tsx` - React app entry point
91+
- **Routing**: Backend routes in `*routes.config.ts`, frontend routes in `packages/web/src/views/Root.tsx`
92+
- **Database**: MongoDB models in `packages/backend/src/*/dao/*.dao.ts`
93+
- **Sync Logic**: Calendar sync in `packages/backend/src/sync/`
94+
95+
### Development Workflow
96+
97+
```bash
98+
# Quick start
99+
yarn install --frozen-lockfile --network-timeout 300000
100+
cp packages/backend/.env.local.example packages/backend/.env
101+
yarn dev:web # Frontend on http://localhost:9080
102+
103+
# Testing
104+
yarn test:core && yarn test:web && yarn test:backend
105+
106+
# Type checking and linting
107+
yarn type-check
108+
yarn prettier . --write
109+
110+
# AI tooling
111+
yarn ai:index # Semantic code search
112+
yarn docs:generate # Generate API docs
113+
yarn audit:code-health # Code quality metrics
114+
```
115+
116+
### AI-Specific Guidelines
117+
118+
1. **Read First**: Always check `AGENTS.md` and `CONTRIBUTING.md` before making changes
119+
2. **Module Aliases**: Use aliased imports (`@compass/*`, `@web/*`) not relative paths
120+
3. **Validation**: Use Zod schemas for all new types and validation
121+
4. **Testing**: Write tests using Testing Library patterns (semantic queries, user interactions)
122+
5. **Commits**: Follow semantic commit format: `type(scope): description`
123+
6. **Safety**: Run `yarn audit:code-health` before submitting PRs
124+
72125
## Contributing
73126

74127
We love contributions! Whether it's bug fixes, new features, or documentation improvements, your help makes Compass better for everyone.

0 commit comments

Comments
 (0)