Skip to content

Commit e4ec54c

Browse files
committed
ai: add guidelines
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent 56ad2a7 commit e4ec54c

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# AGENTS.md — QOwnNotes Script Repository
2+
3+
## What this repository is
4+
5+
This is the official community script repository for [QOwnNotes](https://www.qownnotes.org) — a plain-text Markdown notepad with Nextcloud/ownCloud integration.
6+
Scripts extend the application using **QML (Qt Modeling Language)** and are distributed through the in-app script manager.
7+
8+
Each script lives in its own subdirectory and consists of at minimum:
9+
10+
- A `.qml` file — the script implementation
11+
- An `info.json` file — metadata describing the script
12+
13+
## Repository structure
14+
15+
```
16+
<script-name>/ # One directory per script, kebab-case name
17+
<script-name>.qml # Main QML script file (same name as directory)
18+
info.json # Script metadata
19+
example-script/ # Template/reference for new scripts
20+
.shared/ # Shared just recipes
21+
justfile # Task runner (just)
22+
.github/ # CI workflows and test scripts
23+
```
24+
25+
## Creating a new script
26+
27+
1. **Copy** the `example-script/` directory and rename it to a descriptive kebab-case name (e.g. `my-new-feature/`).
28+
2. **Rename** `example-script.qml` inside the folder to match the folder name (e.g. `my-new-feature.qml`).
29+
3. **Edit** `info.json` to fill in the metadata (see below).
30+
4. **Implement** the script in the `.qml` file.
31+
32+
### info.json fields
33+
34+
```json
35+
{
36+
"name": "Human-readable script name",
37+
"identifier": "script-folder-name",
38+
"script": "script-folder-name.qml",
39+
"authors": ["@github-username"],
40+
"platforms": ["linux", "macos", "windows"],
41+
"version": "0.0.1",
42+
"minAppVersion": "17.06.2",
43+
"description": "What this script does."
44+
}
45+
```
46+
47+
- `identifier` must match the folder name exactly.
48+
- `script` must match the `.qml` filename exactly.
49+
- `minAppVersion`: use the [current QOwnNotes version](https://github.com/pbek/QOwnNotes/blob/main/src/version.h) if unsure.
50+
- `platforms`: include only platforms the script is tested/supported on.
51+
52+
### QML script structure
53+
54+
```qml
55+
import QtQml 2.0
56+
57+
Script {
58+
function init() {
59+
// Called when the script is loaded
60+
}
61+
62+
// Add hook functions here as needed
63+
}
64+
```
65+
66+
See the [QOwnNotes scripting documentation](https://docs.qownnotes.org/en/latest/scripting/) for available hooks and API methods.
67+
68+
## Finding available commands / just recipes
69+
70+
Run `just` (with no arguments) to list all available recipes:
71+
72+
```sh
73+
just
74+
```
75+
76+
Key recipes:
77+
78+
| Recipe | Description |
79+
| ----------------------- | --------------------------------------- |
80+
| `just test` | Run the test suite (PHP-based) |
81+
| `just format` | Format all files using pre-commit hooks |
82+
| `just git-create-patch` | Create a patch from staged changes |
83+
| `just git-apply-patch` | Apply a saved patch |
84+
85+
## Linting and formatting
86+
87+
Pre-commit hooks are configured in `.pre-commit-config.yaml` and run automatically on commit. They cover:
88+
89+
- **QML**: `qmlformat` (auto-formats `.qml` files)
90+
- **JSON/Markdown/YAML/JS**: `prettier`
91+
- **Nix**: `nixfmt`, `deadnix`, `statix`
92+
- **Shell**: `shfmt`, `shellcheck`
93+
- **PHP**: `php-cs-fixer`
94+
95+
To format everything manually: `just format`
96+
97+
## Testing
98+
99+
```sh
100+
just test
101+
```
102+
103+
Tests are run by `.github/workflows/scripts/run-tests.php` and validate `info.json` files and script structure across all script directories.
104+
105+
## Scripting API reference
106+
107+
Full API docs: <https://docs.qownnotes.org/en/latest/scripting/>
108+
109+
The `script` global object exposes methods like:
110+
111+
- `script.log(text)` — log output
112+
- `script.registerCustomAction(identifier, menuText, ...)` — register menu actions
113+
- `script.noteTextEditWrite(text)` — insert text into the editor
114+
- and many more
115+
116+
Look at existing scripts in this repository for real-world usage patterns.

0 commit comments

Comments
 (0)