|
1 | 1 | # AGENTS.md |
2 | 2 |
|
3 | | -Guidance for AI coding agents working in the **SiYuan** repository (思源笔记). |
4 | | -Read this before modifying anything. Source of truth for facts cited here is in |
5 | | -parenthesized file paths — verify before relying on them. |
6 | | - |
7 | | -SiYuan is a privacy-first, block-based note-taking application: a Go HTTP/WebSocket |
8 | | -**kernel** (`kernel/`) plus a TypeScript **frontend** (`app/`) that ships as Electron |
9 | | -desktop, browser-desktop, browser-mobile, and an export-render library |
10 | | -(the `Protyle` global that renders code blocks / math / diagrams inside exported |
11 | | -HTML and the PDF preview window). Module path |
12 | | -`github.com/siyuan-note/siyuan`. License: **AGPL-3.0** (every source file carries the |
13 | | -header — preserve it on edits). Versions (Go, Node, Electron, app version) change |
14 | | -frequently — always read them from source instead of relying on a pinned value: |
15 | | -`kernel/go.mod`, `app/package.json`, `kernel/util/working.go`. |
| 3 | +SiYuan repository guide. Module path `github.com/siyuan-note/siyuan`, license AGPL-3.0. |
| 4 | + |
| 5 | +**Architecture:** Go kernel (`kernel/`) + TypeScript frontend (`app/`), plus a separate `export` bundle (global `Protyle`, entry `src/protyle/method.ts`) for rendering rich content in exported HTML / PDF preview. Read versions from `kernel/go.mod`, `app/package.json`, `kernel/util/working.go`. |
16 | 6 |
|
17 | 7 | --- |
18 | 8 |
|
@@ -137,29 +127,20 @@ and standalone exported HTML files — so rich content renders outside the edito |
137 | 127 |
|
138 | 128 | --- |
139 | 129 |
|
140 | | -## 4. Critical "do not edit" artifacts |
141 | | - |
142 | | -These are generated or checked-in binaries. **Never hand-edit**: |
143 | 130 |
|
144 | | -- `app/stage/protyle/js/lute/lute.min.js` — 3.6 MB **generated** Lute bundle (marked `linguist-vendored` in `.gitattributes:1`). Edit the upstream `github.com/88250/lute` Go project instead and rebuild. |
145 | | -- `app/stage/build/**` — webpack output. |
146 | | -- `app/src/types/dist/**` — generated `.d.ts` (`gen:types`). |
147 | | -- `app/kernel/SiYuan-Kernel*`, `*.syso`, `kernel/kernel.aar` — checked-in build binaries. |
148 | | -- `app/pandoc/*` — bundled third-party binary. |
| 131 | +## 4. Do not hand-edit |
149 | 132 |
|
150 | | -When you change user-visible behavior, also update: `app/appearance/langs/*.json` |
151 | | -(i18n) and the matching `app/changelogs/` entry. |
| 133 | +- `app/stage/protyle/js/lute/lute.min.js` (built from upstream `88250/lute`) |
| 134 | +- `app/stage/build/**`, `app/src/types/dist/**` |
| 135 | +- `app/kernel/SiYuan-Kernel*`, `*.syso`, `kernel/kernel.aar` |
| 136 | +- `app/pandoc/*` |
152 | 137 |
|
153 | 138 | --- |
154 | 139 |
|
155 | | -## 5. Common pitfalls |
156 | | - |
157 | | -1. **Go build fails without `CGO_ENABLED=1`** and a working C compiler (gcc/mingw/musl). This is non-negotiable — sqlite3 is cgo. |
158 | | -2. **The `-tags fts5` flag is required** for every `go build` and `go test`, or the FTS5-dependent code won't compile. |
159 | | -3. **Use `pnpm`, never `npm install` / `yarn`** in `app/` — the lockfile and `packageManager` field are pnpm-specific. |
160 | | -4. **Do not edit `lute.min.js` or anything under `app/stage/`** — they are build outputs (see §4). |
161 | | -5. **Line endings are LF** for `.go`, `.ts`, `.json`, `.scss` (`.gitattributes`); ensure your editor doesn't convert to CRLF on Windows. |
162 | | -6. **i18n: new keys go at the top** of every `app/appearance/langs/*.json` object; add the key to **every** language file (use `en.json` as the reference; report an error when you can't produce a translation rather than silently copying the English). |
163 | | -7. **Windows scripting: prefer not to use PowerShell.** PowerShell isn't forbidden, but it isn't the recommended choice here. When you need to script or automate on Windows, prefer Node.js (`.js`/`.mjs`, runnable via `node`) or Python; reach for PowerShell only if those can't do the job. |
164 | | -8. **Don't run `npx webpack` to "verify" a frontend change.** A successful edit and the existing `pnpm run dev` watch are sufficient; webpack compilation verification is not required. |
165 | | -9. **i18n domain swap: `ld246.com` → `liuyun.io`.** The domain `ld246.com` (the Chinese community) must appear **only in `zh-CN.json`**. In every other language file (`en.json`, `ja.json`, …) use `liuyun.io` instead — do not let `ld246.com` leak into non-Chinese strings. Check this whenever a translated value contains a URL. |
| 140 | +## 5. Project-specific rules |
| 141 | + |
| 142 | +1. **i18n:** New keys go at the **top** of each `langs/*.json` object; add to every language file (reference `en.json`); sync `app/changelogs/` for user-visible changes |
| 143 | +2. **Domains:** `ld246.com` only in `zh-CN.json`; use `liuyun.io` in all other languages |
| 144 | +3. **Line endings:** LF for `.go`, `.ts`, `.json`, `.scss` (`.gitattributes`) |
| 145 | +4. **Windows scripting:** Prefer Node.js / Python; avoid PowerShell unless necessary |
| 146 | +5. **Frontend verification:** Do not use `npx webpack` to verify changes |
0 commit comments