Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 7 additions & 69 deletions AGENT.md
Original file line number Diff line number Diff line change
@@ -1,75 +1,13 @@
# AI Agent Instructions for Countly Server

This file provides guidance for AI coding agents working on the Countly Server codebase.

For comprehensive instructions, see [.github/copilot-instructions.md](.github/copilot-instructions.md).
# Countly Server – AI Agent Hub

## Quick Reference
**Project:** Countly is a product analytics platform (Node.js 22+, MongoDB, Vue 2, plugin-based).

### Tech Stack
- **Backend**: Node.js 22+, MongoDB
- **Frontend**: Vue 2, Element UI
- **Architecture**: Plugin-based (plugins extend core via event hooks)
## Agent Guides

### Key Commands
- [API Agent Guide](api/AGENT.md)
- [Frontend Agent Guide](frontend/AGENT.md)
- [Plugins Agent Guide](plugins/AGENT.md)

```bash
# Development
npm run start:all:dev # Start all services
npx grunt dist-all # Build frontend assets

# Testing
npm run test:unit # Unit tests
npm run test:plugin -- name # Single plugin test

# Linting
countly plugin lint <name> # Lint plugin
countly plugin lintfix <name> # Auto-fix lint issues
```

### Critical Security Rules

1. **Always use validation** in API endpoints:
```javascript
const { validateRead, validateCreate, validateUpdate, validateDelete } = require('../../../api/utils/rights.js');
validateRead(params, FEATURE_NAME, callback);
```

2. **Always include app_id** in database operations:
```javascript
db.collection("items").deleteOne({_id: id, app_id: params.app_id + ""});
```

3. **Never use exec()** with user input:
```javascript
// Use spawn instead
require('child_process').spawn("cmd", [userArg]);
```

### Plugin Structure

```
plugins/<name>/
├── api/api.js # Backend endpoints
├── frontend/app.js # Express middleware
├── frontend/public/ # Static assets
├── install.js # Installation
└── tests.js # Tests
```

### Essential Files

| File | Purpose |
|------|---------|
| `api/utils/common.js` | Utility functions |
| `api/utils/rights.js` | Authorization |
| `plugins/pluginManager.js` | Plugin system |
| `plugins/empty/` | Sample plugin |

## Documentation

- [Coding Guidelines](CODING_GUIDELINES.md) - Full development standards
- [Security Guidelines](docs/SECURITY.md) - Security requirements
- [Vue.js Guidelines](docs/VUEJS_GUIDELINES.md) - Frontend patterns
- [UI Testing](docs/UI_TESTING.md) - Cypress testing guide
- [Test README](test/README.md) - Test suite documentation
For full project conventions, see [.github/copilot-instructions.md](.github/copilot-instructions.md).
28 changes: 28 additions & 0 deletions api/AGENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# API Agent Guide

This guide is for AI agents and developers working in the `api/` backend of Countly Server.

## Essentials
- **Tech:** Node.js 22+, MongoDB
- **Start all services:** `npm run start:all:dev`
- **Unit tests:** `npm run test:unit`
- **Build frontend assets:** `npx grunt dist-all`

## Security
- Always use validation in API endpoints:
```js
const { validateRead, validateCreate, validateUpdate, validateDelete } = require('../../../api/utils/rights.js');
validateRead(params, FEATURE_NAME, callback);
```
- Always include `app_id` in DB operations:
```js
db.collection("items").deleteOne({_id: id, app_id: params.app_id + ""});
```
- Never use `exec()` with user input:
```js
require('child_process').spawn("cmd", [userArg]);
```

## More
- [Full backend checklist](../.github/copilot-instructions.md)
- [Security Guidelines](../docs/SECURITY.md)
17 changes: 17 additions & 0 deletions frontend/AGENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Frontend Agent Guide

This guide is for AI agents and developers working in the `frontend/` dashboard of Countly Server.

## Essentials
- **Tech:** Vue 2, Element UI
- **Build assets:** `npx grunt dist-all`
- **Start dashboard:** `npm run start:all:dev`

## Conventions
- Use PascalCase for component names
- Use `@event` and `:prop` syntax
- Add `data-test-id` for testable elements
- See [Vue.js Guidelines](../docs/VUEJS_GUIDELINES.md)

## UI Testing
- See [UI Testing Guide](../docs/UI_TESTING.md)
23 changes: 23 additions & 0 deletions plugins/AGENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Plugins Agent Guide

This guide is for AI agents and developers working in the `plugins/` folder of Countly Server.

## Plugin Structure
```
plugins/<name>/
├── api/api.js # Backend API endpoints (required)
├── frontend/app.js # Express middleware/routes
├── frontend/public/ # Static assets (JS, CSS, templates)
├── package.json # Plugin metadata
├── install.js # Installation hook
└── tests.js # Plugin tests
```

## Testing
- **Single plugin:** `npm run test:plugin -- <name>`
- **Lint plugin:** `countly plugin lint <name>`
- **Auto-fix lint:** `countly plugin lintfix <name>`

## More
- [Plugin lifecycle & events](../.github/copilot-instructions.md)
- [Sample plugin](empty/)
Loading