diff --git a/.serena/memories/scripts/changelog.md b/.serena/memories/scripts/changelog.md index d4a185d210..0b7ccefd04 100644 --- a/.serena/memories/scripts/changelog.md +++ b/.serena/memories/scripts/changelog.md @@ -1,24 +1,7 @@ # Changelog helper -`scripts/changelog.py` holds the checks used by the changelog flow. The rules and the step-by-step live in `mem:workflow/updating-changelog`; this memory documents the subcommands. Calls `scripts/gh.py` via subprocess; never call the GitHub API directly from this script. +Use `python3 scripts/changelog.py --help` for current CLI options. For release policy, eligibility and approval order see `mem:workflow/updating-changelog`. -## Subcommands - -- `collect [--changes CHANGES.md]` — read-only. Prints JSON to stdout with all milestone `issues` and `prs`, `eligible_issues` (issue numbers), `related_issues` and `related_prs` resolved in batches, `breaking_notes` keyed by issue number, `advisories`, `security_prs` keyed by GHSA, `dev_only_bugs` (`auto` and `suggested`), and `comparison` against the current changelog (references, missing and ineligible issues, cross-version duplicates, unlisted merged PRs). A missing version section is valid. Keep the snapshot private; it can contain unpublished advisories and PR text. See `mem:workflow/updating-changelog` for when to refresh it. -- `boom`, `security`, `cross-ref`, `dev-only-bugs` and `report` accept `--snapshot ` to reuse GitHub data from `collect` for the same milestone. `cross-ref` and `report` still read the current changelog; `--write`, `--apply` and `report` retain their existing write behavior. Without a snapshot, commands query GitHub as before. -- `check-merged ` (`--file`, `--stdin` accepted) — warn on any non-merged PR, exit 1 when found; run before writing changelog entries. -- `boom [--changes CHANGES.md --write]` — generate `### :boom: Breaking changes & Deprecations` from the closed, non-excluded milestone issues labelled `breaking change`, sorted by issue number. Each issue becomes a `#### ` block: content = body of the issue's last `## Breaking change note` comment (whole markdown, headings demoted to `#####` outside code fences; fallback = heading plus refs with a stderr warning), refs = issue link plus merged closing PRs on their own line, with `(by @author)` for `community contribution`. `--write` replaces only that subsection of the version, inserts it after the version header when needed, and removes it when there are no entries. Print-only by default. Uses `gh.py comments`. -- `security [--changes CHANGES.md --write]` — generate `### :lock: Security fixes` from the advisories whose `patched_versions` include the version (via `gh.py advisories --patched-version`), sorted by GHSA id. Entry: `- Fix () (PR: [#N](...))`; description = `Fix` + advisory summary, first word decapitalized unless it starts with an acronym; PRs = merged milestone PRs labelled `pr pt` whose body contains the GHSA id, comma-separated, and no PR is legal. Warns on stderr when a `pr pt` PR references an advisory with no matching `patched_versions`. `--write` replaces only that subsection, placed after `:rocket:` (or `:boom:`, or the version header when neither exists); empty entries remove the subsection; idempotent. Print-only by default. -- `cross-ref [--changes CHANGES.md]` — fetch milestone PRs with `--state all` once, report merged PRs missing from the version section plus CLOSED (unmerged) warnings. PR links inside `:lock:` entries count as referenced; advisory URLs never appear here by design. -- `dev-only-bugs [--apply]` — list closed milestone bugs that never reached production, without `no changelog`. Sure: parent issue is a `Feature`/`Enhancement` of the same milestone; `--apply` adds `no changelog` to these only and prints each successful edit to stdout with its issue URL and reason. On failure it exits nonzero and names the failed issue on stderr; earlier confirmations remain visible. Candidates (never labelled automatically): parent is an epic of the milestone, `regression` label, or the "Affected versions" / "Environment" body field names only hourly, develop, staging, PRE or the milestone version itself (`only_unreleased_envs`; any production hint or other version keeps the bug in — versions compare as full semver with missing patch = 0, so for milestone 2.19.2 the released 2.19.0 keeps the bug in). Reads `body` and `parent` from one batched `gh.py issue` lookup. -- `report [--changes CHANGES.md --output CHANGES-ISSUES.md]` — overwrite the anomaly report: A/B milestone mismatches, E `:boom:` entry without the label, F `:rocket:` sync, G `:boom:` sync, plus the C/D `:rocket:` gaps and the `dev-only-bugs` lists (warnings). `:boom:`/`:rocket:` rule violations are fixed by regenerating or relabelling, not by editing entries in place. - -## Conventions - -- Milestone resolution is batched, never per-item: unknown PRs go through `gh.py prs ` and unknown issues through `gh.py issue ` (one GraphQL call per 50 items); a lookup miss resolves to null, never to an extra call. - -- Version-section lookup accepts an optional `(suffix)` after the version header (e.g. `(Unreleased)`); a missing section is an error for `cross-ref` and an empty section for `report`. -- PR/issue reference parsing covers standard `[#N](.../pull/N)` / `[#N](.../issues/N)` links plus legacy `PR:[N]` / `[Github #N]` forms. -- Shared parsing helpers (`extract_version_section`, `extract_subsection`, `collect_changelog_prs/issues`) live at module top so future subcommands reuse them instead of duplicating regexes. -- Report anomaly types: A/B milestone mismatches, E `:boom:` entry whose issue lacks the `breaking change` label (counted, entries preserved — human labels the issue or moves the entry), G `breaking change` issue missing from `:boom:` (counted, same contract as F); C/D are `:rocket:` gaps (warnings, never counted). -- `issue_excluded` (closed, non-Task, non-Rejected, no `no changelog` label) is module-level and shared by `report` and `boom` so the exclusions cannot drift. `release blocker` is not a changelog exclusion. +- `collect` reads GitHub and the local changelog and prints a JSON snapshot; the snapshot can include unpublished release or security material. The consuming commands accept `--snapshot` for the same milestone. `cross-ref` and `report` still read the current changelog; `report` can query GitHub for additional references missing from the snapshot. +- `boom` and `security` print by default. `--write` replaces or removes their named subsection only. `cross-ref` checks the version section without writing; `report` overwrites the report file even without a write flag. `dev-only-bugs --apply` is a GitHub write, not a report option. +- Keep version lookup, reference parsing and eligibility shared across commands. Do not replace link-aware matching with bare issue numbers; legacy links are still supported. Batch unknown references through `scripts/gh.py`; keep queries out of per-entry loops. diff --git a/.serena/memories/scripts/gh.md b/.serena/memories/scripts/gh.md index 22b8aef03a..44e869f97c 100644 --- a/.serena/memories/scripts/gh.md +++ b/.serena/memories/scripts/gh.md @@ -1,167 +1,8 @@ -# GitHub operations helper +# GitHub helper -`scripts/gh.py` is a multi-purpose CLI for querying the penpot/penpot GitHub -repository via GraphQL and REST APIs through the authenticated `gh` CLI. +Use authenticated `gh` with `python3 scripts/gh.py --help` for current options. Structured results go to stdout; progress and errors go to stderr. -## When to use - -- Listing issues in a milestone (for changelog generation). -- Finding issues with no milestone. -- Fetching PR details by number or by milestone. -- Comparing milestone issues against CHANGES.md to find missing entries. -- Explicitly linking a GitHub issue to a pull request. -- Creating an issue with its Issue Type set in a single command. -- Listing or inspecting GitHub Security Advisories (GHSA). -- Fetching issue comments (the `## Breaking change note` markdown for the changelog). - -## Prerequisites - -- `gh` CLI authenticated (`gh auth status`). -- Python 3.8+. - -## Subcommands - -### `issues` - -List issues in a milestone, with filtering by state, labels, and project status. - -```bash -# Closed issues in a milestone (default) -python3 scripts/gh.py issues "2.16.0" - -# All issues in a milestone -python3 scripts/gh.py issues "2.16.0" --state all - -# Issues with no milestone -python3 scripts/gh.py issues none -python3 scripts/gh.py issues none --state open - -# Filter by label (include only) -python3 scripts/gh.py issues "2.16.0" --label "bug" -python3 scripts/gh.py issues "2.16.0" --label "bug,regression" - -# Exclude by label -python3 scripts/gh.py issues "2.16.0" --exclude "no changelog" - -# Show only issues NOT yet in CHANGES.md -python3 scripts/gh.py issues "2.16.0" --compare CHANGES.md -``` - -**Default filters** (override with flags): -- Issues with type "Task" are excluded (`--include-tasks` to keep them). -- Issues with "Rejected" project status are excluded (`--include-rejected` to keep them). - -Every issue entry carries `assignees` (logins) and `projects` (board titles); every PR entry carries `assignees`. - -**Output**: JSON array to stdout; progress to stderr. - -### `prs` - -Fetch PR details by number or by milestone. Every entry includes a `milestone` field (title or null). - -```bash -# Fetch specific PRs -python3 scripts/gh.py prs 9179 9204 9311 - -# Read PR numbers from file -python3 scripts/gh.py prs --file prs.txt - -# Read PR numbers from stdin -cat prs.txt | python3 scripts/gh.py prs --stdin - -# All PRs in a milestone (default: merged only) -python3 scripts/gh.py prs --milestone "2.16.0" - -# All PRs in a milestone (all states) -python3 scripts/gh.py prs --milestone "2.16.0" --state all -``` - -**Output**: JSON array to stdout; progress to stderr. - -### `issue` - -Fetch issue details by number in batches of 50 (same input styles as `prs`: numbers, `--file`, `--stdin`). No filters. A dead number fails its whole batch (unlike PRs, issues error instead of resolving to null), so the batch falls back to one-by-one lookups and reports misses as `{"number", "error": "not_found"}`. Any other failure aborts. - -**Output**: JSON array to stdout; progress to stderr. Each issue carries the shared issue fields plus `body` and `parent` (`number`, `issue_type`, `milestone`, or null); `changelog.py dev-only-bugs` reads both. - -### `comments` - -Fetch every comment of one or more issues via REST (paginated, 100 per page), oldest first. Same input styles as `issue`: numbers, `--file`, `--stdin`. - -```bash -python3 scripts/gh.py comments 11235 11236 -``` - -**Output fields per comment**: `issue`, `id`, `author`, `created_at`, `body`. JSON array to stdout; progress to stderr. `changelog.py boom` reads the `## Breaking change note` comment from this output. - -### `link-issue` - -Explicitly assign a GitHub issue to a pull request: - -```bash -python3 scripts/gh.py link-issue -# Short alias: python3 scripts/gh.py link -``` - -The command resolves both node IDs and calls `addCloseIssueReferences`. It trusts the successful mutation instead of re-querying, because GitHub does not reliably report mutation-created links through `closedByPullRequestsReferences(userLinkedOnly: true)`. It is safe to rerun and works for merged PRs. It does not guarantee the issue stays open: adding `Closes #N` to the body of an already-merged PR closed the issue immediately when tried (#12896 / PR #12067, 2026-11-09). JSON goes to stdout; progress and errors go to stderr; a missing issue/PR or a failed mutation exits non-zero. - -### `create-issue` - -Create an issue and set its Issue Type in one command. `gh issue create` cannot set the type, so the script runs `gh issue create` (always with `--project Main` by default) and then two GraphQL calls: one to get the issue's node ID and one `updateIssue` mutation to set the type. The issue number is parsed from the URL returned by `gh issue create`. - -```bash -python3 scripts/gh.py create-issue \ - --type task \ - --title "Expand backend email tests" \ - --body-file /tmp/issue-body.md - -# Optional label (comma-separated); no --milestone (set it later if needed) -python3 scripts/gh.py create-issue --type bug --title "..." \ - --body-file /tmp/issue-body.md --label "breaking change" -``` - -`--type` is a name from the Issue Type table in `mem:workflow/creating-issues` (`bug`, `enhancement`, `feature`, `task`, `question`, `docs`, `epic`); it is case-insensitive and the ID mapping lives in `ISSUE_TYPE_IDS` in `scripts/gh.py`. The command prints JSON with `number`, `url`, `title` and `issue_type` to stdout, and progress to stderr. If the type assignment fails after creation, the issue is left in place and the error reports its number and URL so it can be fixed by hand. This shortcut does not replace the workflow in `mem:workflow/creating-issues`: title derivation, body templates and verification still follow that memory. - -**Output**: JSON object on stdout; progress and errors on stderr. A bad type, a `gh` failure, or a type that was not applied exits non-zero. - -### `advisories` - -List or inspect GitHub Security Advisories for the repository. - -```bash -# List all advisories (summary view) -python3 scripts/gh.py advisories - -# Filter by severity -python3 scripts/gh.py advisories --severity critical - -# Filter by state -python3 scripts/gh.py advisories --state triage - -# Filter by patched version declared in the advisory -python3 scripts/gh.py advisories --patched-version 2.19.1 - -# Get full detail for a single advisory -python3 scripts/gh.py advisories GHSA-xvj6-fh9w-gjw7 -``` - -**Summary output fields**: ghsa_id, cve_id, severity, cvss_score, state, summary, cwes, published_at, closed_at, url. - -**Detail output** (single advisory) adds: description, vulnerabilities (package, version ranges), credits, timestamps. - -`--patched-version` filters the raw advisories before formatting: the match is an exact token of `vulnerabilities[*].patched_versions` (split on `,`/`;`), so `2.19.1` never matches `2.19.10`. Every state is included (`triage`, `draft`, `published`, `closed`, `withdrawn`). The raw `vulnerabilities` stay internal to the filter: the list output keeps the summary schema. - -The repository security-advisories endpoint uses cursor pagination (`before`/`after`), not numeric `page` pagination. Observed failure: `page=1` and `page=2` both returned the same 100 advisories, so a length-based loop never ended. `fetch_advisories` must use `gh api --paginate --slurp` so the GitHub CLI follows the response `Link` headers and returns page arrays for flattening. Do not hand-increment `page`. - -**Output**: JSON to stdout; progress to stderr. - -## Key principles - -- `issues --compare` collects every `#NNNN` token in the file regardless of its link target, so a same-numbered reference to another tracker (e.g. `[Taiga #12312](...)`) or an inline prose number falsely marks that GitHub issue as already listed; verify against `changelog.py cross-ref` when a number collides. -- Changelog-specific checks (merge-status verification, milestone-vs-changelog cross-reference, anomaly report) live in `scripts/changelog.py`, which calls this script via subprocess — see `mem:scripts/changelog`. - -- All output is JSON — pipe into `jq` or other tools for further processing. -- Transient HTTP 504 responses from `gh` are retried automatically (3 attempts, 5s/15s backoff); any other error fails fast with no retry. -- Milestone lookup is by exact title match. -- `issues` subcommand auto-paginates (100 items per page). -- `prs` subcommand batches PR number lookups (50 per GraphQL query). +- `issues` lists issues by milestone (exact title) or with no milestone; milestone queries default to closed issues. `issue` and `comments` fetch issue details and comments. `prs` fetches specific PRs or lists a milestone (merged only by default); request all states when auditing unmerged PRs. +- `create-issue` creates the issue and then sets its Issue Type; this is not atomic. For authorization, metadata, and recovery after a partial creation, read `mem:workflow/creating-issues`. `link-issue` sets the Development association, not the PR body; follow `mem:workflow/creating-prs`. The helper trusts the successful mutation because GitHub's link readback can omit mutation-created links. +- `advisories` lists or inspects repo advisories. Patched-version matching compares exact tokens, not prefixes, and does not require publication. The endpoint uses cursor pagination: use `gh api --paginate --slurp`, not numeric pages, which can repeat the same data. +- `issues --compare` can mistake a same-numbered Taiga reference or prose token for a GitHub issue. Use the changelog-specific reconciliation in `mem:scripts/changelog` when reference targets matter. diff --git a/.serena/memories/workflow/creating-issues.md b/.serena/memories/workflow/creating-issues.md index 00ce75edd5..5c8e0f120d 100644 --- a/.serena/memories/workflow/creating-issues.md +++ b/.serena/memories/workflow/creating-issues.md @@ -1,432 +1,51 @@ # Creating Issues -Create GitHub issues only on explicit request. Use `gh` CLI authenticated to `penpot/penpot`. +Create or edit issues only when authorized. Follow `AGENTS.md` and use authenticated `gh` for `penpot/penpot`. ## Title Derivation -Derive the title from the source material (bug report, user feedback, feature request, etc.) — not from any pre-existing title which may be auto-generated or stale. - -### Bug titles (descriptive present tense) - -Describe the symptom as it appears to the user. Format: `[Where] [present-tense verb] when [condition]`. - -- *"Plugin API crashes when setting text fills"* -- *"Canvas renders glitches when zooming quickly"* -- *"French Canada locale falls back to French (fr) translations"* - -Do **not** start bug titles with "Fix" or any imperative verb — state what's broken, not command a fix. - -### Feature / Enhancement titles (imperative mood) - -Command what should be built. Format: `[Imperative verb] [what] in/on [where]`. - -- *"Add customizable dash and gap length controls to dashed strokes in the sidebar"* -- *"Show user, timestamp, and hash in the workspace history panel like git commits"* - -### Universal rules - -- **Include the "where"** — specify the UI location or module (e.g. "in the sidebar", "on the stroke options") -- **No prefixes** — strip `bug:`, `feature:`, `feat:`, `:bug:`, `:sparkles:`, `[PENPOT FEEDBACK]`, etc. -- **No emoji** — plain text only -- **Be specific** — prefer concrete detail over generality -- **Two problems → cover both** — if the description has two distinct but related issues, capture both joined by "and" - -## Metadata - -| Field | Rule | -|-------|------| -| **Labels** | `community contribution` (PRs from non-core) · `breaking change` when the change breaks compatibility (see below) · skip workflow labels (`backport candidate`, `team-qa`) · do **not** add `bug` or `enhancement` labels (use Issue Type instead) | -| **Milestone** | Use the current or next planned milestone. Fetch available milestones: `gh api repos/penpot/penpot/milestones --jq '.[].title'`. If unsure, omit. | -| **Project** | Always `Main` (project number 8). Use `--project "Main"` flag. | -| **Issue Type** | See Issue Type section below. Cannot be set via `gh issue create` — use GraphQL after creation. | - -## Breaking changes - -When the issue introduces a breaking change or a deprecation, it is the unit -`mem:workflow/updating-changelog` turns into a block under -`### :boom: Breaking changes & Deprecations`. The section is generated from -the issue (`scripts/changelog.py boom`), so the issue must carry both: - -1. The `breaking change` label. -2. A `## Breaking change note` **comment** (not a body section). Everything - after that marker line is copied to the changelog: paragraphs, bullet - lists, code blocks and headings are kept (headings are demoted to level 5 - in `CHANGES.md`). Write it for self-hosters: what changes, what they must - do, and what breaks if they do nothing. Keep it short: explain the - implications and link the runbook or docs for the detail, never paste the - runbook itself. Links must point to a long-lived branch (`staging` or - `main`), never to a feature branch. - -Post the note as a new comment. Do not add a breaking-change section to the -issue body and do not hand-write the changelog block. When the issue comes -from a PR, reuse the text of the PR's breaking-change section. -Do not hard-wrap the note: one line per paragraph or bullet. - -The full changelog rules (sections, exclusions, `:rocket:`, pre-flight and -anomaly report) live in `mem:workflow/updating-changelog`. +- Derive the title from the source material, not from a copied or auto-generated title. Use plain text, no emoji or prefixes. Name the affected UI or module, and cover both issues if two related symptoms matter. +- Bug: present-tense symptom, not an imperative. Example: `Canvas renders glitches when zooming quickly`, not `Fix canvas glitches`. +- Feature or enhancement: imperative and user-facing. Example: `Add dash and gap controls to stroke options`. ## Issue Body Template -Write the body to a temp file to avoid shell quoting issues: +- Bug: `### Description`, `### Steps to reproduce`, `### Expected behavior`, `### Affected versions`. Describe actual behavior in the description; use numbered steps. +- Feature or enhancement: `### Description`, `### Use case`, `### Affected versions`. Explain what the user can do and why it helps. Don't invent details or versions. +- Keep each paragraph or list item on one line, as for PR bodies. Put the body in a private temporary file to avoid shell quoting and remove your temporary files afterward. -**Bug template:** -```markdown -### Description +## Metadata - +- Project: `Main` (project 8). Use the current or next planned milestone only when clear; issues from PRs inherit the PR milestone, or none. Assign a known milestone on the existing issue with `gh issue edit --milestone`; the creation helper has no milestone option. +- Labels: `community contribution` for non-core contributions; `breaking change` when compatibility breaks. Don't copy workflow labels (e.g. `team-qa`, `backport candidate`) or use `bug`/`enhancement` labels to encode the Issue Type. +- Issue Type: `Bug` for broken behavior, `Enhancement` for improvements and ordinary feature requests, `Feature` for feature-level work, and `EPIC` for an umbrella tracking issue. Use `Question` or `Docs` when appropriate and `Task` for other work. Parentage does not decide type: fixing a bug under an epic is still a Bug. -### Steps to reproduce +## Breaking changes -1. -2. +- Add the `breaking change` label and post a separate comment starting with `## Breaking change note`, not a section in the issue body. Reuse the user-facing note from the PR when available. +- Explain to self-hosters what changes, what they must do, and what breaks if they do nothing. Link the details on `staging` or `main`, not a feature branch; don't paste the runbook or add issue/PR links the generator supplies. Use one line per paragraph or bullet. See `mem:workflow/updating-changelog` for how the note becomes a generated entry. -### Expected behavior +## Create, recover and verify - - -### Affected versions - - -``` - -**Enhancement template:** -```markdown -### Description - - - -### Use case - - - -### Affected versions - - -``` - -Note: do not soft-wrap paragraphs in the body. Each paragraph is a single line in the source; newlines are reserved for structural breaks (section headers, list items, code-block fences, blank-line separators). List items stay on a single line each. GitHub renders single-line paragraphs correctly, and wrapping makes diffs noisy on every small wording change. Same rule applies to PR bodies. - -## Creating the Issue - -```bash -cat > /tmp/issue-body.md << 'ISSUE_BODY' - -ISSUE_BODY - -gh issue create \ - --repo penpot/penpot \ - --title "" \ - --label "