Skip to content

Commit dba3b19

Browse files
committed
add AGENTS.md
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
1 parent 02babb6 commit dba3b19

1 file changed

Lines changed: 143 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
- SPDX-License-Identifier: AGPL-3.0-or-later
4+
-->
5+
6+
# Assistant agent guide
7+
8+
This is the starting point for working with the **`assistant`** Nextcloud app.
9+
10+
## Table of contents
11+
12+
1. [What Assistant is](#1-what-assistant-is)
13+
2. [Architecture](#2-architecture)
14+
3. [Building the app](#3-building-the-app)
15+
4. [Testing](#4-testing)
16+
5. [UI entry points](#5-ui-entry-points)
17+
6. [Key files](#6-key-files)
18+
7. [Contributing conventions](#7-contributing-conventions)
19+
20+
## 1. What Assistant is
21+
22+
Assistant is the Nextcloud app that provides a unified UI and API for AI-powered task processing. It acts as the central hub for users to interact with AI features such as text generation, image generation, audio transcription, translation, context chat, and more.
23+
24+
Assistant relies heavily on **TaskProcessing providers** registered by other apps to actually perform AI tasks. Without providers, most features are non-functional. See [Testing](#4-testing) for details on setting up providers for development.
25+
26+
## 2. Architecture
27+
28+
The app follows the standard Nextcloud app structure:
29+
30+
- **`appinfo/`**: App metadata (`info.xml`) and HTTP route definitions (`routes.php`).
31+
- **`lib/`**: PHP backend.
32+
- `lib/Controller/`: HTTP controllers. `AssistantController` and `AssistantApiController` serve the main UI and REST API. `ChattyLLMController` handles the conversational interface. `ConfigController` manages admin/personal settings. `AgentSkillsApiController` and `AssignmentsApiController` expose agent-related endpoints.
33+
- `lib/TaskProcessing/`: Custom TaskProcessing task types and providers shipped by the app itself (e.g. audio-to-audio chat, text-to-sticker, image-to-text translation).
34+
- `lib/Service/`: Business logic services.
35+
- `lib/Settings/`: Admin and personal settings page registration (`Admin.php`, `Personal.php`).
36+
- `lib/Db/`: Database entities and mappers.
37+
- `lib/Listener/` and `lib/Event/`: Event listeners and event classes.
38+
- `lib/BackgroundJob/`: Background job definitions.
39+
- `lib/Migration/`: Database schema migrations.
40+
- `lib/Reference/`: Reference provider for link previews (e.g. text generation results, speech-to-text results).
41+
- `lib/Notification/`: Notification handling.
42+
- **`src/`**: Vue 3 frontend (built with Vite into `js/`).
43+
- Entry points: `src/assistant.js` (top-menu modal), `src/assistantPage.js` (dedicated page), `src/adminSettings.js`, `src/personalSettings.js`, `src/filesNewMenu.js` (files app "new" menu), `src/imageGenerationReference.js`, `src/speechToTextReference.js`, `src/textGenerationReference.js`, `src/taskOutputFileReference.js`, `src/stickerGeneration.js`.
44+
- `src/components/`: Vue components including `ChattyLLM/` (conversational UI), `ContextChat/`, `Translate/`, `FilesNewMenu/`, settings forms, task list, and the main assistant form.
45+
- `src/views/`: Top-level views (`AssistantPage.vue`, custom picker elements for image/text results, file reference widget).
46+
- **`templates/`**: PHP templates for server-rendered pages.
47+
- **`tests/`**: PHPUnit test suite.
48+
49+
## 3. Building the app
50+
51+
Install PHP and Node.js dependencies, then build:
52+
53+
```bash
54+
# PHP backend
55+
composer install
56+
57+
# Frontend
58+
npm ci
59+
npm run build # production build (outputs to js/)
60+
npm run watch # dev build with file watcher
61+
npm run dev # one-shot dev build
62+
```
63+
64+
### Lint and static analysis
65+
66+
```bash
67+
composer lint # PHP syntax check
68+
composer cs:check # php-cs-fixer dry-run
69+
composer cs:fix # php-cs-fixer auto-fix
70+
composer psalm # static analysis
71+
composer openapi # regenerate OpenAPI specs
72+
73+
npm run lint # eslint
74+
npm run stylelint # stylelint
75+
```
76+
77+
## 4. Testing
78+
79+
### Backend tests
80+
81+
There are **no UI tests** in this repository. Backend tests run in CI automatically.
82+
83+
Running them locally **requires a running Nextcloud test instance**. The exact setup depends on how your test Nextcloud is deployed (Docker, bare metal, nextcloud-docker-dev, etc.). Once the instance is available:
84+
85+
```bash
86+
composer run test:unit
87+
```
88+
89+
The PHPUnit configuration lives in `tests/phpunit.xml`.
90+
91+
### TaskProcessing providers
92+
93+
Many Assistant features depend on TaskProcessing providers registered by other apps. Without providers, the assistant UI will show empty or disabled states.
94+
95+
Nextcloud ships a `testing` app that includes some test providers useful during development. It is up to the developer or agent to deploy additional providers as needed for the features being tested.
96+
97+
For a list of apps that implement TaskProcessing providers, see the Nextcloud admin documentation:
98+
https://docs.nextcloud.com/server/latest/admin_manual/ai/app_assistant.html#related-apps
99+
100+
### UI testing with Playwright
101+
102+
There is no built-in Playwright test suite, but the app can be tested manually or with custom Playwright scripts against a running Nextcloud instance. See [UI entry points](#5-ui-entry-points) below for the pages and interactions to target.
103+
104+
## 5. UI entry points
105+
106+
These are the places where the Assistant surfaces in the Nextcloud UI:
107+
108+
1. **Dedicated page**: `/index.php/apps/assistant` — the full assistant interface.
109+
2. **Top menu**: a menu entry in the Nextcloud header opens the assistant in a modal.
110+
3. **File actions** in the Files app (`/index.php/apps/files`): context menu entries for `text/markdown` and audio files trigger assistant tasks.
111+
4. **"New file" menu** in the Files app: a "Generate image using AI" entry.
112+
5. **Settings pages**: both admin and personal settings have an "Assistant" category at `/index.php/settings/admin/ai` and `/index.php/settings/user/ai`.
113+
114+
## 6. Key files
115+
116+
| Area | File(s) |
117+
|------|---------|
118+
| HTTP routes | `appinfo/routes.php` |
119+
| Main UI controller | `lib/Controller/AssistantController.php` |
120+
| REST API controller | `lib/Controller/AssistantApiController.php` |
121+
| ChattyLLM controller | `lib/Controller/ChattyLLMController.php` |
122+
| Config controller | `lib/Controller/ConfigController.php` |
123+
| Custom task types & providers | `lib/TaskProcessing/` |
124+
| Admin settings | `lib/Settings/Admin.php` |
125+
| Personal settings | `lib/Settings/Personal.php`, `lib/Settings/PersonalSection.php` |
126+
| Services | `lib/Service/` |
127+
| DB layer | `lib/Db/` |
128+
| Migrations | `lib/Migration/` |
129+
| Reference providers | `lib/Reference/` |
130+
| Frontend entry points | `src/assistant.js`, `src/assistantPage.js`, `src/adminSettings.js`, `src/personalSettings.js`, `src/filesNewMenu.js` |
131+
| Main Vue components | `src/components/` |
132+
| Top-level views | `src/views/` |
133+
| App metadata | `appinfo/info.xml` |
134+
| PHPUnit config | `tests/phpunit.xml` |
135+
| OpenAPI spec | `openapi.json` |
136+
137+
## 7. Contributing conventions
138+
139+
- **Sign off every commit (DCO)**: `git commit -s`. The sign-off name/email must match the commit author.
140+
- **PHP floor 8.3**: do not use syntax requiring newer PHP versions. The minimum PHP version is determined by the `min-version` of Nextcloud declared in `appinfo/info.xml` (currently 35). The supported PHP versions for a given Nextcloud release are listed in the "PHP Runtime" row of the requirements table at `https://docs.nextcloud.com/server/NC_VERSION/admin_manual/installation/system_requirements.html`, where `NC_VERSION` can be a major version number (e.g. `33`, `34`) or `latest` for the current development version.
141+
- **Node 24, npm 11.3+** for frontend builds.
142+
- Before pushing: run `composer cs:fix && composer psalm`; if you touched the frontend, `npm run lint && npm run build`; if you touched controllers/routes, `composer openapi`. If a test Nextcloud instance is available, also run `composer run test:unit` inside it.
143+
- New files need an SPDX license header.

0 commit comments

Comments
 (0)