Skip to content

Commit eee9f81

Browse files
authored
docs: streamline guides updated since v4.29.4 (#11154)
* docs: streamline guides updated since v4.29.4 * docs: retain original import compatibility notes * docs: simplify structured decision guidance * docs: clarify agent API usage scenarios * docs: clarify agent runtime events heading * docs: nest agent events and remove custom runtime guide * docs: group conversation migration notes in versioned tips * docs: remove outdated LLM introduction note * docs: remove obsolete model API version tips * docs: remove conversation method reference lists * docs: remove narrow-window provider section and screenshots * docs: split AI guide into focused topic pages * docs: add Agent guides using an unambiguous file name * docs: clarify legacy miscellaneous API guidance * docs: remove outdated architecture overview * docs: remove expired plugin reward event * docs: explain plugin configuration with control examples and screenshots * docs: collapse AI sidebar groups by default * docs: refine sidebar spacing and typography * docs: add breathing room after expanded sidebar groups * docs: space expanded sidebar headings from child items
1 parent 863e675 commit eee9f81

86 files changed

Lines changed: 2688 additions & 2907 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/PROJECT_SYNC.md‎

Lines changed: 65 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,35 @@
11
# GitHub Project synchronization
22

3-
## Behavior
4-
5-
Each run builds a read-only plan first. Issue/PR events reconcile only their direct
6-
associations; six-hour schedule and manual dispatch run full scans. Manual dispatch
7-
and local runs preview by default; manual `apply` must be selected. Sync never edits
8-
or deletes source Issues/PRs.
9-
10-
- Required single-select `Status`: `Todo`, `In progress`, `Needs verification`,
11-
`Done`, `Cancelled`, `Closed unmerged`. Required single-select `交付进度`:
12-
`未关联实现`, `尚未合入`, `已合入待发布`, `已发布`. Required text fields:
13-
`实现关联`, `发布版本`, `发布说明`.
14-
- Open issues start Todo. Linked active PRs mean In progress; merge alone means
15-
Needs verification, not acceptance. Closed issues are Done unless GitHub close
16-
reason is NOT_PLANNED (Cancelled). Closed unmerged PRs are not Done. Reopened
17-
terminal items return to Todo. Preserve manually selected nonterminal status
18-
without implementation. Optional labels `status:needs-info` and
19-
`status:needs-verification` override inferred open-issue progress. `needs-info`
20-
intentionally wins in Status even with a merged PR (Todo + 已合入待发布); the
21-
fields represent acceptance and delivery separately.
22-
- Associate same-repository issues using closing references or standalone
23-
`Ref(s)`, `Fix(es/ed)`, `Close(d)`, or `Resolve(s/d)` lines. Incidental mentions,
24-
code fences, and cross-repository references do not establish a link. A reference
25-
line containing `Fixes #12, and see #99 for context` links both same-repo issues;
26-
keep unrelated numbers off reference lines to avoid unintended associations.
27-
- Delivery requires every associated implementation PR to be merged, every merge
28-
commit to be reachable from the trusted default branch, and every such commit
29-
to be contained in the earliest published stable release. Drafts/prereleases do
30-
not count. Populate PR links and actual release tag/URL, never guess a version.
31-
- Issue/PR lifecycle events read only their subject and bounded linked issues/PRs,
32-
including old/new body references and previously stored implementation links.
33-
Fork-origin PR events are skipped to avoid spending an Actions run per fork event;
34-
the scheduled reconciliation still observes their final repository-visible state.
35-
They do not scan repository Issues, PRs, Project items, or releases. Six-hour
36-
scheduled and manual runs do full reconciliation; changes discovered only by
37-
broad push/release scans wait until the next scheduled or manual run.
38-
- Full scans include open issues/all PRs, tracked and linked closed issues, and
39-
all items closed on or after Project creation. This durable boundary recovers
40-
replaced/failed events without unrelated older closed history. For an older
41-
Project, preview catch-up before writes. Skip archived items and draft issues.
42-
- Release version verification runs only during full scans. Event runs defer it to
43-
the next full scan, while preserving an existing published result when its
44-
implementation links are unchanged.
45-
- Validate the Project schema/options and calculate all changes before writing;
46-
skip unchanged values and clear stale text. Paginate every GraphQL connection,
47-
reject stalled cursors, and serialize runs. Apply mode prints the plan first;
48-
on failure it reports confirmed, outcome-unknown and unattempted mutation counts,
49-
with affected item/field, so partial writes can be reconciled. Apply uses four
50-
workers across distinct Project items; mutations within each item stay ordered.
51-
This is bounded concurrency, not a guarantee against GitHub rate limits.
52-
The synchronization job has a 120-minute total execution budget, including
53-
checkout, scanning and writes; advancing to another step does not reset it.
54-
- Full scans log phase/page and candidate progress to the Actions log. Stable
55-
release membership is determined with one `git tag --contains` graph walk per
56-
distinct merge commit instead of one `git merge-base` process per commit/tag
57-
pair; missing fetched tags fail closed.
58-
- Local microbenchmark against the full checkout: 237 version tags and 20 sampled
59-
tag commits (version order used as a proxy for publication order). Pairwise
60-
`merge-base` checks ran 2,110 processes in 31.67 s; `tag --contains` ran 20 in
61-
0.35 s (90x on this sample). This measures Git ancestry only, not GraphQL or
62-
full-workflow wall time.
63-
- Privileged jobs run trusted default-branch code only, use full Git history/tags,
64-
and never execute PR code. PR tests use no Project secret.
65-
66-
Run offline tests and checks:
3+
The `Sync GitHub Project` workflow updates Project status and release tracking from repository issues and pull requests. It does not edit or delete source issues or PRs. Manual dispatch and local runs preview changes by default.
674

68-
```sh
69-
python -I tests/test_sync_github_project.py -v
70-
python -I tests/test_project_delivery.py -v
71-
python -I tests/test_project_events.py -v
72-
uv run ruff format --check scripts/sync_github_project.py tests/test_sync_github_project.py tests/test_project_delivery.py
73-
uv run ruff check scripts/sync_github_project.py
74-
```
5+
## Configure the integration
756

76-
## Configuration
7+
1. Create these fields in the destination Projects v2 project:
778

78-
Set these repository Actions variables:
9+
| Field | Type | Required options |
10+
| --- | --- | --- |
11+
| `Status` | Single select | `Todo`, `In progress`, `Needs verification`, `Done`, `Cancelled`, `Closed unmerged` |
12+
| `交付进度` | Single select | `未关联实现`, `尚未合入`, `已合入待发布`, `已发布` |
13+
| `实现关联`, `发布版本`, `发布说明` | Text | — |
7914

80-
| Variable | Value |
81-
| --- | --- |
82-
| `ASTRBOT_PROJECT_ID` | Destination Projects v2 node ID (`PVT_...`); required to enable |
83-
| `ASTRBOT_PROJECT_STATUS_OPEN` | Open-state option name; default `Todo` |
84-
| `ASTRBOT_PROJECT_STATUS_DONE` | Closed/merged-state option name; default `Done` |
85-
| `ASTRBOT_PROJECT_STATUS_MAP` | Optional JSON object mapping remaining canonical Status values to existing option labels |
15+
2. Under **Settings → Environments**, create `project-sync`. Choose **Selected branches and tags** and allow exactly the default branch (`master`), using a branch rule. Do not allow tags or wildcard branches. Use required reviewers where available and restrict changes to these rules. If environment protection is unavailable, leave synchronization disabled.
16+
3. After configuring protection, add the **environment secret** `ASTRBOT_PROJECT_ENV_TOKEN` with Project write and repository Issue/PR read access. For example, use a classic personal access token with `project` scope from an account that can edit the Project, subject to organization SSO and token policies. Do not store it as a repository or organization secret; remove any old `ASTRBOT_PROJECT_TOKEN` secret at those scopes.
17+
4. Set the repository Actions variables below. Setting `ASTRBOT_PROJECT_ID` enables the workflow.
8618

87-
Example map when an existing Project uses translated Status labels:
19+
| Variable | Value |
20+
| --- | --- |
21+
| `ASTRBOT_PROJECT_ID` | Destination Project node ID (`PVT_...`) |
22+
| `ASTRBOT_PROJECT_STATUS_OPEN` | Open-state label; defaults to `Todo` |
23+
| `ASTRBOT_PROJECT_STATUS_DONE` | Closed/merged-state label; defaults to `Done` |
24+
| `ASTRBOT_PROJECT_STATUS_MAP` | Optional JSON map from other canonical Status values to existing labels |
25+
26+
For translated labels, a status map can be:
8827

8928
```json
9029
{"In progress":"进行中","Needs verification":"待验证","Cancelled":"已取消","Closed unmerged":"已关闭未合入"}
9130
```
9231

93-
Before enabling synchronization, create the `project-sync` GitHub Environment
94-
under repository Settings → Environments. Select **Selected branches and tags**
95-
and add exactly one **branch** rule for the default branch (`master` currently).
96-
Do not allow tags, wildcard branches, or all protected branches. Use required
97-
reviewers where available and limit who can change environment protection rules.
98-
The workflow's inline branch check is defense in depth, not the credential boundary.
99-
100-
Only after those rules are configured, add the **environment secret**
101-
`ASTRBOT_PROJECT_ENV_TOKEN` with project write access and repository Issue/PR read
102-
access. Never define this secret at repository or organization scope; remove any
103-
old repository/organization `ASTRBOT_PROJECT_TOKEN` used for this integration.
104-
The workflow maps the environment secret to the script's `ASTRBOT_PROJECT_TOKEN`
105-
process variable; local runs continue using that process variable. No fallback to
106-
the old secret exists. YAML cannot create or enforce these server-side rules.
107-
If environment protection is unavailable, leave synchronization disabled.
108-
109-
For example, use a classic personal access token with the `project` scope,
110-
owned by an account that can edit the destination project. Honor any organization
111-
SSO authorization and token restrictions. The repository `GITHUB_TOKEN` is not
112-
used for project mutations.
113-
The Project must contain all five fields and options listed above. Do not use this
114-
credential in ordinary pull request test jobs.
115-
116-
Branch protection evaluates the triggering workflow ref, not the checked-out ref.
117-
Release events use tag refs, and PR-target events against non-default branches may
118-
therefore be rejected by this default-branch-only Environment. Do not add tag or
119-
branch exceptions to bypass that restriction: the next default-branch push,
120-
six-hour scheduled run, or default-branch manual dispatch reconciles their state.
121-
Test that a non-default dispatch is denied before using a live credential.
122-
123-
Both workflows pin checkout/setup-python to full commit SHAs verified against
124-
their official repositories. Existing weekly Dependabot updates propose SHA
125-
changes for review; keep the immutable pins when updating Actions.
126-
127-
To resolve an organization project's node ID, replace `PROJECT_NUMBER` with the
128-
number from its GitHub URL (not its node ID):
32+
To look up an organization Project's node ID, replace `PROJECT_NUMBER` with the number in its URL:
12933

13034
```sh
13135
gh auth refresh -s project
@@ -134,27 +38,53 @@ gh api graphql -f query='query($owner: String!, $number: Int!) {
13438
}' -f owner=AstrBotDevs -F number=PROJECT_NUMBER --jq '.data.organization.projectV2.id'
13539
```
13640

137-
Merge to the default branch, configure the fields and secret, then preview with
138-
manual dispatch before selecting `apply`. Verify an Issue→PR→merge→stable release
139-
path plus a fork PR. A mutation can partially apply; rerunning or waiting for the
140-
next schedule reconciles current state. Remove `ASTRBOT_PROJECT_ID` to disable.
41+
The workflow maps the environment secret to the script's `ASTRBOT_PROJECT_TOKEN` process variable. Local runs use that variable too. The repository `GITHUB_TOKEN` is not used for Project writes.
42+
43+
## Preview and apply
44+
45+
After merging the workflow to the default branch, run it manually on that branch with `apply` unchecked. Review the plan, then run with `apply` selected. Verify an issue → PR → merge → stable release sequence and a fork PR.
46+
47+
Before using a live credential, verify that dispatch from a non-default branch is denied. Environment protection checks the triggering workflow ref, not the checked-out ref. Do not add branch exceptions for rejected PR-target events; the next scheduled or default-branch manual run reconciles them.
48+
49+
Remove `ASTRBOT_PROJECT_ID` to disable synchronization. Coordinate any native Project automation that writes the same fields.
50+
51+
## Synchronization rules
14152

142-
## Boundaries
53+
| Situation | Result |
54+
| --- | --- |
55+
| Open issue without an implementation | `Todo`; preserve a manually selected nonterminal status |
56+
| Linked active PR | `In progress` |
57+
| Linked merged PR | `Needs verification`; merging does not imply acceptance |
58+
| Closed issue | `Done`, or `Cancelled` for `NOT_PLANNED` |
59+
| Closed unmerged PR | `Closed unmerged` |
60+
| Reopened terminal item | `Todo` |
61+
62+
For open issues, `status:needs-info` and `status:needs-verification` override inferred progress. `needs-info` takes precedence even with a merged PR; acceptance status and delivery progress are separate fields.
63+
64+
Issues are linked through closing references or standalone `Ref(s)`, `Fix(es/ed)`, `Close(d)`, or `Resolve(s/d)` lines. Keep unrelated issue numbers off those lines: `Fixes #12, and see #99 for context` links both. Incidental mentions, code fences, and cross-repository references do not establish links.
65+
66+
A delivery is released only when all associated implementation PRs are merged, their commits are reachable from the default branch, and a published stable release contains all those commits. The earliest qualifying release supplies the version and URL; drafts and prereleases do not count.
67+
68+
## Schedule and recovery
69+
70+
- Issue and same-repository PR events reconcile the changed item and its linked items. Fork PR events are skipped; full scans include their repository-visible state.
71+
- Scheduled runs every six hours and manual runs perform full reconciliation, including release verification. Event runs preserve an existing release result while implementation links are unchanged.
72+
- Full scans include open issues, all PRs, tracked or linked closed issues, and items closed since Project creation. Archived items and draft issues are skipped. Preview catch-up before applying to an older Project.
73+
- Each run validates the schema and prints its plan before writing. Runs are serialized and have a 120-minute total timeout. API errors or missing fetched tags stop the run.
74+
- A failed apply reports confirmed, outcome-unknown, and unattempted writes. Rerun or wait for the next scheduled scan to reconcile partial changes. The Actions log shows scan progress.
75+
76+
Privileged runs use default-branch code and full Git history and tags. Never check out PR code or expose the Project token in PR test jobs. Keep Actions pinned to immutable commit SHAs when updating them.
14377

144-
- Always: pass GraphQL variables separately, paginate connections, fail on API
145-
errors, use timeouts, preview before manual writes, test without credentials.
146-
- Ask first: cross-repository links, legacy backfill, additional tracking fields,
147-
changing automatic Status rules, creating credentials or a Project.
148-
- Never: commit secrets, check out PR head code in the privileged workflow,
149-
modify issue/PR state, delete project items, commit or push without permission.
78+
## Local validation
15079

151-
Unrelated items closed before Project creation are intentionally not imported. Coordinate any
152-
native Project automation that writes these same fields. GitHub Actions and live
153-
API validation require maintainer configuration after merge.
80+
Run the offline checks without credentials:
15481

155-
## API reference
82+
```sh
83+
python -I tests/test_sync_github_project.py -v
84+
python -I tests/test_project_delivery.py -v
85+
python -I tests/test_project_events.py -v
86+
uv run ruff format --check scripts/sync_github_project.py tests/test_sync_github_project.py tests/test_project_delivery.py tests/test_project_events.py
87+
uv run ruff check scripts/sync_github_project.py
88+
```
15689

157-
GitHub's official "Using the API to manage Projects" documentation describes
158-
ProjectV2 field lookup, `addProjectV2ItemById` (including existing-item reuse),
159-
and `updateProjectV2ItemFieldValue`:
160-
https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects
90+
See GitHub's [Projects API guide](https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/using-the-api-to-manage-projects) for field lookup and item mutations.

0 commit comments

Comments
 (0)