@openhands/extensions 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,28 @@
1
1
  # State File Schema
2
2
 
3
3
  The automation maintains a JSON state file that persists across polling runs.
4
- It is the source of truth for which PRs have been reviewed and which
5
- conversations are still active.
4
+ It is the source of truth for which trigger-label events have queued reviews
5
+ and which conversations are still active.
6
6
 
7
7
  ---
8
8
 
9
9
  ## File Location
10
10
 
11
11
  ```
12
- {WORKSPACE_BASE_ROOT}/automation-state/github_pr_reviewer_{automation_id}.json
12
+ {WORKSPACE_BASE_ROOT}/automation-state/github_pr_reviewer_label_event_{automation_id}.json
13
13
  ```
14
14
 
15
15
  `WORKSPACE_BASE_ROOT` is derived by going two levels up from the `WORKSPACE_BASE`
16
- environment variable (stripping `automation-runs/{run_id}`).
16
+ environment variable, stripping `automation-runs/{run_id}`.
17
17
 
18
18
  Example on a local install:
19
19
 
20
20
  ```
21
- ~/.openhands/workspaces/automation-state/github_pr_reviewer_abc12345-….json
21
+ ~/.openhands/workspaces/automation-state/github_pr_reviewer_label_event_abc12345-....json
22
22
  ```
23
23
 
24
24
  The `automation_id` is read from the `AUTOMATION_EVENT_PAYLOAD` environment
25
- variable (field `automation_id`).
25
+ variable, field `automation_id`.
26
26
 
27
27
  ---
28
28
 
@@ -30,69 +30,97 @@ variable (field `automation_id`).
30
30
 
31
31
  ```jsonc
32
32
  {
33
- "version": 1, // schema version (integer)
34
- "repo": "owner/repo", // the monitored repository
35
- "conversations": { } // see ConversationRecord below
33
+ "version": 2,
34
+ "repo": "owner/repo",
35
+ "trigger_label": "openhands-review",
36
+ "updated_at": 1717200000.0,
37
+ "reviews": {},
38
+ "prs": {}
36
39
  }
37
40
  ```
38
41
 
39
42
  ---
40
43
 
41
- ## `conversations` Map
44
+ ## `reviews` Map
42
45
 
43
- Key: `"{pr_number}"` (string) — uniquely identifies a PR in the repo.
46
+ Key: `"{pr_number}:label:{label_event_id}"`. This makes the latest GitHub
47
+ `labeled` event the idempotency key. Re-applying the trigger label creates a new
48
+ GitHub event and therefore a new review request.
44
49
 
45
- Value: **ConversationRecord**
50
+ Value: **ReviewRecord**
46
51
 
47
52
  ```jsonc
48
53
  {
49
- // Always present
50
- "pr_number": 42, // GitHub PR number (integer)
51
- "html_url": "https://github.com/owner/repo/pull/42", // PR URL
52
- "status": "active", // "active" | "closed" | "skipped"
53
- "last_activity": 1717200000.0, // Unix timestamp of last state change
54
-
55
- // Present when status is "active" or "closed"
54
+ "pr_number": 42,
55
+ "head_sha": "0123456789abcdef...",
56
+ "trigger_label_event_id": 123456789,
57
+ "trigger_label_event_created_at": "2026-06-12T00:00:00Z",
58
+ "html_url": "https://github.com/owner/repo/pull/42",
59
+ "status": "active",
56
60
  "conversation_id": "550e8400-e29b-41d4-a716-446655440000",
57
- // OpenHands conversation UUID
61
+ "last_activity": 1717200000.0
62
+ }
63
+ ```
64
+
65
+ `status` values:
66
+
67
+ | Status | Meaning |
68
+ |---|---|
69
+ | `active` | Review conversation is running or waiting to be collected |
70
+ | `closed` | Final result was posted, or the PR closed before collection |
71
+ | `stale` | PR head SHA changed before the review completed, so the result was suppressed |
72
+
73
+ When a review becomes stale, `stale_reason` records the old and new head SHAs.
74
+ When a review closes after posting, `completed_at` records the completion time.
75
+
76
+ ---
58
77
 
59
- // Present when status is "skipped"
60
- "reason": "diff too large (6000 lines)"
78
+ ## `prs` Map
79
+
80
+ Key: `"{pr_number}"`.
81
+
82
+ Value: latest PR snapshot observed during polling:
83
+
84
+ ```jsonc
85
+ {
86
+ "head_sha": "0123456789abcdef...",
87
+ "label_present": true,
88
+ "labels": ["openhands-review", "bug"],
89
+ "last_seen": 1717200000.0
61
90
  }
62
91
  ```
63
92
 
93
+ This snapshot is informational and helps diagnose whether a PR was skipped
94
+ because the trigger label was absent.
95
+
64
96
  ---
65
97
 
66
- ## Conversation Lifecycle
98
+ ## Review Lifecycle
67
99
 
68
100
  ```
69
- PR opened on GitHub
70
- │
71
- ▼
72
- [active] ── conversation created, acknowledgement comment posted
73
- │
74
- ▼ (on a later cron run, when conversation reaches terminal status)
75
- [closed] ── review posted to PR as GitHub comment
76
- │
77
- ▼ (if PR is merged/closed before review is ready)
78
- [closed] ── no comment posted (silently closed)
79
-
80
- ── or ──
81
-
82
- PR diff too large
83
- │
84
- ▼
85
- [skipped] ── explanatory comment posted, PR never re-queued
101
+ Trigger label applied on GitHub
102
+ |
103
+ v
104
+ [active] - conversation created, acknowledgement comment posted
105
+ |
106
+ +-- PR closes/merges before collection --> [closed] without posting
107
+ |
108
+ +-- PR head SHA changes before collection --> [stale] without posting
109
+ |
110
+ v
111
+ [closed] - final review comment posted
86
112
  ```
87
113
 
88
114
  ---
89
115
 
90
116
  ## Resetting State
91
117
 
92
- To force a re-review of all PRs (e.g. after changing the review tone):
118
+ To force the automation to reconsider previous label events, delete the state
119
+ file:
120
+
121
+ ```bash
122
+ rm ~/.openhands/workspaces/automation-state/github_pr_reviewer_label_event_<id>.json
123
+ ```
93
124
 
94
- 1. Delete the state file:
95
- ```bash
96
- rm ~/.openhands/workspaces/automation-state/github_pr_reviewer_<id>.json
97
- ```
98
- 2. The next cron run will treat all open PRs as new and queue reviews for each.
125
+ Usually, prefer removing and re-applying the trigger label. That preserves
126
+ history while creating a new review request.