Skip to content

Commit 83d00c0

Browse files
Merge pull request #305 from nextcloud/docs/noid/ai-policy
docs: Add AI policy reference and starting point for agents.md
2 parents 4e0888c + b62c940 commit 83d00c0

3 files changed

Lines changed: 177 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
- SPDX-License-Identifier: AGPL-3.0-or-later
4+
-->
5+
6+
# Agent Guidelines for Nextcloud files_mindmap
7+
8+
This file provides instructions for AI coding agents (Claude Code, GitHub Copilot, Cursor, Windsurf, and others) operating on this repository. Read it before generating any code, commits, or pull requests.
9+
10+
---
11+
12+
## Nextcloud Contribution Policy
13+
14+
All contributions generated or assisted by this agent must fully comply with:
15+
16+
- **[AI Contribution Policy](https://github.com/nextcloud/.github/blob/master/AI_POLICY.md)** - the primary reference for AI-specific rules, covering disclosure, author accountability, communication, security, licensing, code quality, and autonomous agent behavior.
17+
- **[Contribution Guidelines](https://github.com/nextcloud/.github/blob/master/CONTRIBUTING.md)** - covering testing requirements, the Developer Certificate of Origin (DCO), license headers, conventional commits, and translations. These apply in full to all contributions regardless of how they were produced.
18+
19+
### What this agent must always do
20+
21+
- Add an `Assisted-by: AGENT_NAME:MODEL_VERSION` git trailer to every commit containing AI-assisted content.
22+
- Ensure every pull request includes a disclosure of AI tool use in the PR description.
23+
- Produce focused, scoped pull requests that address exactly one concern. Do not touch unrelated files or introduce incidental refactors.
24+
- Verify all dependencies against actual package registries before suggesting them. Do not use hallucinated or unverified package names.
25+
- Explicitly inform the contributor when any action they are about to take, or have taken, would violate the AI Contribution Policy or the Contribution Guidelines. Do not silently proceed. State which rule is at risk and what the contributor should do instead.
26+
- Warn the contributor if a pull request is growing too large. A PR approaching several thousand lines of changed code is a signal that it should be split into smaller, focused PRs. Suggest a logical split before the PR is opened, not after.
27+
- Recommend opening a ticket for discussion before starting implementation whenever a feature or change is sufficiently complex - for example when it touches multiple subsystems, requires architectural decisions, or the right approach is not yet clear. A ticket allows maintainers and the contributor to align on direction before code is written, avoiding wasted effort on a PR that may be rejected or require fundamental rework.
28+
29+
### What this agent must never do
30+
31+
- Open issues, submit pull requests, post review comments, or send security reports autonomously. Every contribution must be reviewed and submitted by a human.
32+
- Add `Signed-off-by` tags to commits. Only the human contributor can certify the Developer Certificate of Origin.
33+
- Generate or submit security reports without independent human verification. Report verified vulnerabilities via [HackerOne](https://hackerone.com/nextcloud), not as GitHub issues.
34+
- Write PR descriptions, review comments, or issue reports on behalf of the contributor. These must be in the contributor's own words.
35+
- Fully automate the resolution of issues labeled [`good first issue`](https://github.com/issues?q=org%3Anextcloud+label%3A%22good+first+issue%22) or similar beginner-friendly labels.
36+
- Submit code that has not been reviewed and cleaned up by the contributor. Dead code, redundant logic, excessive comments, and unrelated changes must be removed before submission.
37+
38+
---
39+
40+
## Repository-Specific Requirements
41+
42+
### Commit format
43+
44+
Use [Conventional Commits](https://www.conventionalcommits.org) for all commit messages:
45+
46+
```
47+
<type>(<scope>): <short description>
48+
49+
[optional body]
50+
51+
Assisted-by: AGENT_NAME:MODEL_VERSION
52+
```
53+
54+
Common types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`, `perf`, `build`, `ci`.
55+
The scope should match the affected component or app (e.g. `files_sharing`, `core`, `encryption`).
56+
57+
Example:
58+
```
59+
feat(files_sharing): allow sharing with contacts
60+
61+
Assisted-by: ClaudeCode:claude-sonnet-4-6
62+
```
63+
64+
### Developer Certificate of Origin (DCO)
65+
66+
The project uses the DCO as an additional safeguard. Only the human contributor may add the `Signed-off-by` trailer - agents must not add it:
67+
68+
```
69+
Signed-off-by: Random J Developer <random@developer.example.org>
70+
```
71+
72+
Contributors can sign automatically with `git commit -s` after configuring `user.name` and `user.email`.
73+
74+
### License headers
75+
76+
Every new file must include the correct SPDX license header. For AGPL-3.0-or-later (the default for this repository):
77+
78+
```php
79+
/**
80+
* SPDX-FileCopyrightText: <year> <name>
81+
* SPDX-License-Identifier: AGPL-3.0-or-later
82+
*/
83+
```
84+
85+
See [HowToApplyALicense.md](https://github.com/nextcloud/server/blob/master/contribute/HowToApplyALicense.md) for details on per-language formats. AI-generated code must not include material from sources incompatible with AGPL-3.0-or-later.
86+
87+
### Security
88+
89+
- Do not open GitHub issues for potential vulnerabilities. Report them via [HackerOne](https://hackerone.com/nextcloud) following the [security policy](https://nextcloud.com/security/).
90+
- AI-generated security reports must be independently verified by the human contributor before submission.
91+
- Manually verify all access control logic, authentication patterns, and dependency names - AI tools are known to hallucinate package names and reproduce vulnerable patterns.
92+
93+
## Commands
94+
95+
```bash
96+
# Development
97+
npm run watch # Watch mode (rebuilds on change)
98+
npm run dev # One-time development build
99+
100+
# Production
101+
npm run build # Production build → js/
102+
103+
# Testing
104+
npm run test # Run tests once (Vitest)
105+
npm run test:watch # Watch mode
106+
107+
# Linting
108+
npm run lint # ESLint check
109+
110+
# Packaging
111+
make appstore # Build appstore tarball
112+
make release # Tag + appstore package
113+
```
114+
115+
**Requirements:** Node.js ^24.0.0, npm ^11.3.0
116+
117+
## Architecture
118+
119+
This is a Nextcloud app that allows users to edit mind map files (`.km`, `.xmind`, `.mm`) in the browser.
120+
121+
### Two-Layer Frontend
122+
123+
The frontend has two distinct layers:
124+
125+
1. **Modern Vue 2.7 layer** (`src/mindmap.js`, `src/mindmapviewer.js`) — registers file actions in the Nextcloud Files UI and wraps the viewer using the Viewer API. Entry points are compiled by Vite into `js/`.
126+
127+
2. **Legacy AngularJS + KityMinder layer** (`vendor/kityminder-core/`, `vendor/angular/`) — the actual mind map editor runs inside an `<iframe>` loaded via `DisplayController::showMindmapViewer()`. This layer is served directly from `vendor/` (not Vite-compiled). `src/viewer.js` is the entry point for this iframe.
128+
129+
The Vue component (`src/views/MindMap.js`) renders only the iframe. All real editing happens inside it.
130+
131+
### File Operation Flow
132+
133+
```
134+
File click → Nextcloud Viewer → MindMap.js (Vue) renders iframe
135+
→ iframe loads DisplayController → viewer.php + viewer.js
136+
→ AngularJS/KityMinder editor boots inside iframe
137+
138+
Load: GET /ajax/loadfile → FileHandlingController::load() → base64-encoded content
139+
Save: PUT /ajax/savefile → FileHandlingController::save() → writes to user storage
140+
```
141+
142+
Public share routes mirror authenticated routes under `/public/{token}` and `/share/save`.
143+
144+
### Plugin System for File Formats
145+
146+
`src/plugins/` contains format handlers (`km.js`, `xmind.js`, `freemind.js`). Each plugin handles encoding/decoding for its format. Only `.km` supports both read and write; `.xmind` and `.mm` are read-only imports.
147+
148+
### PHP Backend
149+
150+
`lib/AppInfo/Application.php` registers event listeners for:
151+
- Loading JS into Files (`LoadAdditionalListener`)
152+
- Loading JS into the Viewer app (`LoadViewerListener`, `LoadPublicViewerListener`)
153+
- Registering the "New mind map" template creator (`RegisterTemplateCreatorListener`)
154+
155+
Routes are defined in `appinfo/routes.php` and handled by controllers in `lib/Controller/`.
156+
157+
### Vue Compatibility Note
158+
159+
`src/views/MindMap.js` uses the Options API (not SFC `.vue` files) to maintain Vue 2.7 compatibility with the Nextcloud Viewer app mixin system. This is intentional — do not refactor to SFC.
160+
161+
## Tests
162+
163+
Tests live in `src/__tests__/` and use Vitest with jsdom. The test suite covers format plugins and core utilities — the AngularJS viewer layer is not covered by automated tests.
164+
165+
## Further Reading
166+
167+
- [Nextcloud Contribution Guidelines](https://github.com/nextcloud/.github/blob/master/CONTRIBUTING.md)
168+
- [AI Contribution Policy](https://github.com/nextcloud/.github/blob/master/AI_POLICY.md)
169+
- [How to Apply a License](https://github.com/nextcloud/server/blob/master/contribute/HowToApplyALicense.md)
170+
- [Security Vulnerability Reporting (HackerOne)](https://hackerone.com/nextcloud)

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

REUSE.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ SPDX-PackageName = "files_mindmap"
55
SPDX-PackageSupplier = "Nextcloud <info@nextcloud.com>"
66
SPDX-PackageDownloadLocation = "https://github.com/nextcloud/files_mindmap"
77

8+
[[annotations]]
9+
path = ["CLAUDE.md"]
10+
precedence = "aggregate"
11+
SPDX-FileCopyrightText = "2026 Nextcloud GmbH and Nextcloud contributors"
12+
SPDX-License-Identifier = "AGPL-3.0-or-later"
13+
814
[[annotations]]
915
path = ["l10n/**.js", "l10n/**.json"]
1016
precedence = "aggregate"

0 commit comments

Comments
 (0)