Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:memo: Allow rebase and default branch fallback

Daniel30fa052dd53f
diff --git a/AGENTS.md b/AGENTS.md
index 1b417e156d..73896a5f15 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -9,7 +9,7 @@ SiYuan repository guide. Module path `github.com/siyuan-note/siyuan`, license AG
### Verify the code baseline before repository tasks
- Before each new repository task, select the baseline source branch using the repository-specific branch policy in section 2's Git rules, fetch the relevant remote refs, and verify the task's code baseline before analysis or other work. Respect explicitly requested commits, tags, or pull requests
-- Follow the repository-specific Git rules for working branches and authorized push destinations. If the user explicitly requests a task branch or the repository's own rules require one, create it from the verified task baseline. Using an isolated worktree does not change the default working branch or authorize pushing to a task branch instead. Automatically fast-forward an existing branch only when its working tree is clean and it is merely behind. If synchronization is blocked, preserve existing work and report the limitation; do not discard changes, automatically stash or rebase, create merge commits, or silently substitute another push destination
+- Follow the repository-specific Git rules for working branches and authorized push destinations. If the user explicitly requests a task branch or the repository's own rules require one, create it from the verified task baseline. Using an isolated worktree does not change the default working branch or authorize pushing to a task branch instead. Automatically fast-forward an existing branch only when its working tree is clean and it is merely behind. Rebase is permitted when synchronizing divergent branches, provided existing work is preserved; this does not authorize force-pushing rewritten history. If synchronization is blocked, preserve existing work and report the limitation; do not discard changes, automatically stash, create merge commits, or silently substitute another push destination
- Reuse the verified baseline for follow-ups in the same task; recheck after a substantial pause, a repository or branch change, or when newer commits could affect the task. Unrelated conversation needs no fetch
### Requirement evaluation
@@ -81,10 +81,10 @@ Unambiguous mechanical edits with no behavioral or compatibility impact need no
- Represent in-app UI navigation paths as segmented `kbd` text marks: use one `NodeTextMark` with `TextMarkType: "kbd"` per navigation level, and place a plain `NodeText` containing ` - ` between adjacent levels
- In every language, separate a `kbd` path from adjacent prose with exactly one ASCII space on each side, except at block boundaries, after full-width punctuation, or before any punctuation. Half-width punctuation before the path still requires a space; keep internal ` - ` separators unchanged
5. **Git:**
- - Branch policy is repository-specific: in `siyuan-note/siyuan`, use `dev` as the baseline source branch, working branch, commit branch, and destination for explicitly authorized pushes by default. Use a task branch based on `dev` only when the user explicitly requests it; do not create or push a task branch merely to isolate changes or because `dev` has uncommitted work or is behind the remote. **NEVER** commit on or push to `master`. If `dev` is unavailable, stop and report the missing branch instead of falling back to `master`
+ - Branch policy is repository-specific: in `siyuan-note/siyuan`, use `dev` as the baseline source branch, working branch, commit branch, and destination for explicitly authorized pushes by default. If `dev` is unavailable, use the repository's verified default branch for these roles. Use a task branch based on the selected baseline only when the user explicitly requests it; do not create or push a task branch merely to isolate changes or because the selected working branch has uncommitted work or is behind the remote. Do not commit on or push to `master` while `dev` is available; when `dev` is unavailable and `master` is the verified default branch, it is permitted
- In other repositories, follow their own branch rules for baseline selection and work; otherwise prefer `dev` when it exists locally or on the remote, and use the repository's actual default branch when `dev` does not exist. Do not extend SiYuan's `master` prohibition to other repositories or assume their default branch is named `master` or `main`
- If the intended branch cannot be determined confidently from the user's instructions, the repository's rules, and local or remote branch information, ask the user which branch to use and wait for their answer before editing, committing, or pushing; do not guess or silently choose a fallback
- - Before editing, verify the repository and current branch. Before every explicitly authorized commit or push, verify the current branch again and, for a push, the destination remote and branch; never rely only on the upstream configuration. If SiYuan is checked out on `master`, switch to `dev` before making changes, or to a task branch based on `dev` if the user explicitly requested one; preserve existing work and do not reset or discard it to switch branches
+ - Before editing, verify the repository and current branch. Before every explicitly authorized commit or push, verify the current branch again and, for a push, the destination remote and branch; never rely only on the upstream configuration. If SiYuan is checked out on a branch other than the selected working branch, switch to the selected working branch before making changes, or to a task branch based on the selected baseline if the user explicitly requested one; preserve existing work and do not reset or discard it to switch branches
- When explicitly asked to commit, follow the style of recent commits (gitmoji prefix + subject, in English)
- Append the full issue/PR URL to the end of the commit title (e.g. `https://github.com/siyuan-note/siyuan/issues/<NNN>`, not the `#NNN` short form — it is clickable) only when a related issue exists; never put the URL in the commit body, and do not fabricate one
6. **GitHub:** Prefer the GitHub CLI (`gh`) for all GitHub operations, including reading issues, comments, pull requests, commits, statuses, and metadata. If `gh` is unavailable or does not support the operation, fall back to the GitHub API or web interface