lastlight-core 0.18.3 → 0.18.6
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.
- package/dist/admin/routes.d.ts +7 -0
- package/dist/admin/routes.js +22 -0
- package/dist/admin/routes.js.map +1 -1
- package/dist/cron/dependabot-discovery.d.ts +102 -0
- package/dist/cron/dependabot-discovery.js +155 -0
- package/dist/cron/dependabot-discovery.js.map +1 -0
- package/dist/cron/fanout.d.ts +9 -0
- package/dist/cron/fanout.js +15 -4
- package/dist/cron/fanout.js.map +1 -1
- package/dist/engine/agent-executor.d.ts +1 -1
- package/dist/engine/agent-executor.js +1 -1
- package/dist/engine/agent-executor.js.map +1 -1
- package/dist/engine/dispatcher.js +1 -1
- package/dist/engine/dispatcher.js.map +1 -1
- package/dist/engine/executors/shared.d.ts +26 -0
- package/dist/engine/executors/shared.js +40 -13
- package/dist/engine/executors/shared.js.map +1 -1
- package/dist/engine/github/git-auth.d.ts +2 -1
- package/dist/engine/github/git-auth.js.map +1 -1
- package/dist/engine/github/github.d.ts +41 -0
- package/dist/engine/github/github.js +69 -0
- package/dist/engine/github/github.js.map +1 -1
- package/dist/engine/github/profiles.js +1 -0
- package/dist/engine/github/profiles.js.map +1 -1
- package/dist/engine/router.d.ts +9 -0
- package/dist/engine/router.js +44 -0
- package/dist/engine/router.js.map +1 -1
- package/dist/engine/screen/classifier.d.ts +14 -0
- package/dist/engine/screen/classifier.js +13 -2
- package/dist/engine/screen/classifier.js.map +1 -1
- package/dist/index.js +48 -5
- package/dist/index.js.map +1 -1
- package/dist/workflows/target-policy.js +4 -3
- package/dist/workflows/target-policy.js.map +1 -1
- package/package.json +4 -4
- package/workflows/cron-dependabot-ci-fix.yaml +26 -0
- package/workflows/cron-dependabot-merge.yaml +13 -5
- package/workflows/dependabot-ci-fix.yaml +5 -1
- package/workflows/dependabot-pr-merge.yaml +36 -14
- package/workflows/prompts/dependabot-assess.md +17 -0
- package/workflows/prompts/dependabot-ci-fix.md +9 -0
- package/workflows/prompts/dependabot-pr-merge.md +123 -63
|
@@ -25,9 +25,10 @@ export const PER_TARGET_REUSE_WORKFLOWS = new Set([
|
|
|
25
25
|
"pr-review",
|
|
26
26
|
"pr-fix",
|
|
27
27
|
"dependabot-ci-fix",
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
28
|
+
// dependabot-pr-merge is always single-PR (webhook or the cron's per-PR
|
|
29
|
+
// fan-out), so it keys its (checkout-free) run by (repo, PR): a repeated
|
|
30
|
+
// `pr.checks_passed` and the daily cron backstop for the same PR dedup onto
|
|
31
|
+
// one dir/run rather than stacking.
|
|
31
32
|
"dependabot-pr-merge",
|
|
32
33
|
]);
|
|
33
34
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"target-policy.js","sourceRoot":"","sources":["../../src/workflows/target-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;IAChD,WAAW;IACX,QAAQ;IACR,mBAAmB;IACnB,wEAAwE;IACxE,
|
|
1
|
+
{"version":3,"file":"target-policy.js","sourceRoot":"","sources":["../../src/workflows/target-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;IAChD,WAAW;IACX,QAAQ;IACR,mBAAmB;IACnB,wEAAwE;IACxE,yEAAyE;IACzE,4EAA4E;IAC5E,oCAAoC;IACpC,qBAAqB;CACtB,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC;AAEhF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAEhE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3F;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,MAAM;IACN,SAAS;IACT,QAAQ;CACT,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lastlight-core",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.6",
|
|
4
4
|
"description": "GitHub repository maintenance agent — Agent SDK harness",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"octokit": "^5.0.5",
|
|
64
64
|
"yaml": "^2.8.3",
|
|
65
65
|
"zod": "^4.3.6",
|
|
66
|
-
"lastlight-
|
|
67
|
-
"
|
|
68
|
-
"
|
|
66
|
+
"lastlight-shared": "0.1.1",
|
|
67
|
+
"agentic-pi": "0.2.18",
|
|
68
|
+
"lastlight-workflow-engine": "0.1.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@types/better-sqlite3": "^7.6.0",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
kind: cron
|
|
2
|
+
name: fix-red-dependency-prs
|
|
3
|
+
# Once a day, one hour after the 14:00 green sweep (merge-green-dependency-prs).
|
|
4
|
+
# The pr.checks_failed webhook does the real-time fixing; this sweep is only a
|
|
5
|
+
# backstop for dependency PRs that went red before boot or during a missed
|
|
6
|
+
# delivery. dependabot-ci-fix is the EXPENSIVE dependency path — it pre-clones
|
|
7
|
+
# the PR head and runs the full install + test/lint/typecheck gate per PR — so a
|
|
8
|
+
# daily cadence is plenty, and offsetting it from the green sweep keeps the two
|
|
9
|
+
# bounded (concurrency-3) heavy fan-outs from stacking on the host.
|
|
10
|
+
schedule: "0 15 * * *"
|
|
11
|
+
workflow: dependabot-ci-fix
|
|
12
|
+
context:
|
|
13
|
+
# `discover: red-dependency-prs` makes the cron runner (src/index.ts) find the
|
|
14
|
+
# SETTLED-red dependency PRs across managed repos IN CODE
|
|
15
|
+
# (src/cron/dependabot-discovery.ts → discoverRedDependencyPrs) and fan out one
|
|
16
|
+
# bounded single-PR `dependabot-ci-fix` run per PR — the same shape the
|
|
17
|
+
# pr.checks_failed webhook produces. Each context carries the PR head `branch`
|
|
18
|
+
# so dispatchWorkflow pre-clones the checkout the fix phase needs. "Red" is a
|
|
19
|
+
# settled failing check conclusion (GitHubClient.getChecksConclusion), NOT
|
|
20
|
+
# mergeable_state, so we never fire while checks are still running.
|
|
21
|
+
discover: red-dependency-prs
|
|
22
|
+
# NOTE: like merge-green-dependency-prs, and unlike cron-review, this sweep
|
|
23
|
+
# intentionally has NO `condition.unless: webhooksEnabled`. It's an additive
|
|
24
|
+
# backstop that also runs with webhooks on. Per-PR runs dedup by (repo, PR), and
|
|
25
|
+
# the discovery step skips any PR carrying the `requires-human` label, so it
|
|
26
|
+
# won't re-attempt fixes Last Light already gave up on.
|
|
@@ -7,10 +7,18 @@ name: merge-green-dependency-prs
|
|
|
7
7
|
schedule: "0 14 * * *"
|
|
8
8
|
workflow: dependabot-pr-merge
|
|
9
9
|
context:
|
|
10
|
-
|
|
11
|
-
#
|
|
10
|
+
# `discover: green-dependency-prs` makes the cron runner (src/index.ts) find
|
|
11
|
+
# the green dependency PRs across managed repos IN CODE
|
|
12
|
+
# (src/cron/dependabot-discovery.ts) and fan out one bounded single-PR
|
|
13
|
+
# `dependabot-pr-merge` run per PR — the same shape the pr.checks_passed
|
|
14
|
+
# webhook produces. This replaced the old `mode: scan` run, whose single agent
|
|
15
|
+
# tried to assess every open PR in a repo at once and overflowed its context
|
|
16
|
+
# on busy repos (merging nothing). One PR per run = overflow is impossible and
|
|
17
|
+
# one bad PR can't sink the others.
|
|
18
|
+
discover: green-dependency-prs
|
|
19
|
+
# NOTE: unlike cron-review, this sweep intentionally has NO
|
|
12
20
|
# `condition.unless: webhooksEnabled`. The pr.checks_passed webhook merges
|
|
13
|
-
# newly-green PRs in real time; this cron is an additive
|
|
21
|
+
# newly-green PRs in real time; this cron is an additive backstop that also runs
|
|
14
22
|
# with webhooks on, catching dependency PRs that went green before boot or
|
|
15
|
-
# during a missed delivery. Enabling auto-merge is idempotent,
|
|
16
|
-
# the webhook path is harmless.
|
|
23
|
+
# during a missed delivery. Enabling auto-merge is idempotent, and per-PR runs
|
|
24
|
+
# dedup by (repo, PR), so overlap with the webhook path is harmless.
|
|
@@ -19,10 +19,14 @@ classification:
|
|
|
19
19
|
Renovate, e.g. "Bump <pkg> from X to Y", "chore(deps): update <pkg>") whose
|
|
20
20
|
CI checks have FAILED and needs its build / lockfile / call sites repaired so
|
|
21
21
|
the update can land. Choose this over REVIEW or BUILD when the subject is a
|
|
22
|
-
red dependency-bump PR.
|
|
22
|
+
red dependency-bump PR. Also choose it when a maintainer's comment asks the
|
|
23
|
+
bot to handle/look at/fix such a PR and `PR CHECKS` is `failing` (with a
|
|
24
|
+
`PR AUTHOR` of dependabot[bot]/renovate[bot]) — but keep REVIEW when they
|
|
25
|
+
explicitly ask for a review.
|
|
23
26
|
examples:
|
|
24
27
|
- 'PR "Bump lodash from 4.17.20 to 4.17.21" by dependabot[bot] — its CI checks have failed. → INTENT: DEPENDABOTCIFIX, REPO: NONE, ISSUE: NONE, REASON: NONE'
|
|
25
28
|
- 'PR "chore(deps): bump actions/checkout from 3 to 4" by dependabot[bot] — its CI checks have failed. → INTENT: DEPENDABOTCIFIX, REPO: NONE, ISSUE: NONE, REASON: NONE'
|
|
29
|
+
- 'PR AUTHOR: dependabot[bot], PR CHECKS: failing, COMMENT: "@bot can you take a look at this?" → INTENT: DEPENDABOTCIFIX, REPO: NONE, ISSUE: NONE, REASON: NONE'
|
|
26
30
|
|
|
27
31
|
phases:
|
|
28
32
|
- name: fix
|
|
@@ -3,16 +3,23 @@ name: dependabot-pr-merge
|
|
|
3
3
|
description: |
|
|
4
4
|
Assess an already-GREEN dependency-update PR (Dependabot / Renovate) and, when
|
|
5
5
|
the change is trivial, enable GitHub auto-merge (squash) so it lands once its
|
|
6
|
-
checks pass.
|
|
7
|
-
|
|
6
|
+
checks pass. When a trivial bump is merely behind the base branch or has a
|
|
7
|
+
lockfile conflict, it asks the bot that opened the PR to rebase/recreate its
|
|
8
|
+
own branch (@dependabot rebase|recreate, or Renovate's rebase label) and enables
|
|
9
|
+
auto-merge to land it once green — it never pushes or rebases itself. The
|
|
10
|
+
companion to dependabot-ci-fix: that one repairs a RED bump and pushes a fix;
|
|
11
|
+
this one merges a GREEN one that needs no fix at all.
|
|
8
12
|
|
|
9
|
-
Triggered by:
|
|
13
|
+
Always runs against a SINGLE PR (`{{prNumber}}`). Triggered by:
|
|
10
14
|
- pr.checks_passed webhook (a check_suite completed with a success
|
|
11
15
|
conclusion on a Dependabot/Renovate PR) → routed here by the router's
|
|
12
16
|
deterministic intent lookup (src/engine/router.ts + this file's
|
|
13
|
-
`classification`).
|
|
14
|
-
- the cron-dependabot-merge
|
|
15
|
-
|
|
17
|
+
`classification`).
|
|
18
|
+
- the cron-dependabot-merge backstop: the cron runner finds the green
|
|
19
|
+
dependency PRs across managed repos IN CODE
|
|
20
|
+
(src/cron/dependabot-discovery.ts) and fans out one run per PR — same
|
|
21
|
+
single-PR shape as the webhook. (This replaced an agent `mode: scan`
|
|
22
|
+
sweep that assessed a whole repo at once and overflowed on busy repos.)
|
|
16
23
|
classification:
|
|
17
24
|
intent: dependabot-pr-merge
|
|
18
25
|
description: |
|
|
@@ -21,27 +28,42 @@ classification:
|
|
|
21
28
|
<pkg>") whose CI checks have PASSED and which may be safe to auto-merge with
|
|
22
29
|
no code change. Choose this ONLY for a passing dependency-bump PR that needs
|
|
23
30
|
no fix; prefer DEPENDABOTCIFIX when a dependency PR's checks have FAILED, and
|
|
24
|
-
REVIEW for a normal (non-dependency) PR.
|
|
31
|
+
REVIEW for a normal (non-dependency) PR. Also choose it when a maintainer's
|
|
32
|
+
comment asks the bot to handle/look at/land such a PR and `PR CHECKS` is
|
|
33
|
+
`passing` (with a `PR AUTHOR` of dependabot[bot]/renovate[bot]) — but keep
|
|
34
|
+
REVIEW when they explicitly ask for a review.
|
|
25
35
|
examples:
|
|
26
36
|
- 'PR "Bump lodash from 4.17.20 to 4.17.21" by dependabot[bot] — its CI checks have passed. → INTENT: DEPENDABOTPRMERGE, REPO: NONE, ISSUE: NONE, REASON: NONE'
|
|
27
37
|
- 'PR "chore(deps): bump actions/checkout from 3 to 4" by renovate[bot] — its CI checks have passed. → INTENT: DEPENDABOTPRMERGE, REPO: NONE, ISSUE: NONE, REASON: NONE'
|
|
38
|
+
- 'PR AUTHOR: renovate[bot], PR CHECKS: passing, COMMENT: "@bot can you look at this?" → INTENT: DEPENDABOTPRMERGE, REPO: NONE, ISSUE: NONE, REASON: NONE'
|
|
28
39
|
|
|
29
40
|
phases:
|
|
30
41
|
# Single phase. Runs under this workflow's repo-write profile, so agentic-pi's
|
|
31
|
-
# `github_enable_auto_merge`
|
|
42
|
+
# `github_enable_auto_merge` (+ `github_add_issue_comment` / `github_add_labels`
|
|
43
|
+
# for the rebase nudge) tools are available. Conservative by design: enable
|
|
32
44
|
# auto-merge ONLY for trivial, non-functional dependency bumps; anything with
|
|
33
45
|
# runtime-logic impact is left for a human. No repo checkout — the agent
|
|
34
|
-
# inspects
|
|
46
|
+
# inspects the ONE PR via `github_list_pull_request_files` (file list + line
|
|
35
47
|
# counts) and skips lockfile diffs, only pulling `github_get_pull_request_diff`
|
|
36
|
-
# for a small non-lockfile source change.
|
|
37
|
-
#
|
|
48
|
+
# for a small non-lockfile source change. It never pushes or rebases itself: a
|
|
49
|
+
# trivial PR that is `behind`/`dirty` is nudged to rebase via the bot's own
|
|
50
|
+
# command (@dependabot rebase|recreate) or Renovate's rebase label, with
|
|
51
|
+
# auto-merge enabled to land it once GitHub re-runs the checks green. Because
|
|
52
|
+
# each run assesses a single PR, its context is bounded — the overflow that
|
|
53
|
+
# killed the old whole-repo scan can't happen. See prompts/dependabot-pr-merge.md.
|
|
38
54
|
- name: assess
|
|
39
55
|
label: Assess & maybe auto-merge
|
|
40
56
|
prompt: prompts/dependabot-pr-merge.md
|
|
41
57
|
# `code-review`: the finding-tier / what-to-check rubric for reading a diff.
|
|
42
58
|
skill: code-review
|
|
43
59
|
model: "{{models.review}}"
|
|
60
|
+
# Postcondition: the assess run MUST sign off with this marker (see the
|
|
61
|
+
# prompt's OUTPUT contract). Its absence means the agent inspected files then
|
|
62
|
+
# stopped without reaching a verdict or acting — a silent no-op that used to
|
|
63
|
+
# report a false green (e.g. after a context-overflow retry). Fail loudly.
|
|
64
|
+
on_output:
|
|
65
|
+
requires_marker: "ASSESSMENT_COMPLETE"
|
|
44
66
|
messages:
|
|
45
|
-
on_start: "Assessing dependency PR
|
|
46
|
-
on_success: "Assessed dependency PR
|
|
47
|
-
on_failure: "Couldn't assess the dependency PR
|
|
67
|
+
on_start: "Assessing dependency PR for auto-merge..."
|
|
68
|
+
on_success: "Assessed the dependency PR — auto-merge enabled if it's a trivial, green update; anything functional left for review."
|
|
69
|
+
on_failure: "Couldn't assess the dependency PR — leaving for a human."
|
|
@@ -22,6 +22,23 @@ Call it **TRIVIAL** only if ALL of these hold:
|
|
|
22
22
|
If you are unsure, or the change touches application logic, treat it as
|
|
23
23
|
**FUNCTIONAL**. When in doubt, do NOT auto-merge.
|
|
24
24
|
|
|
25
|
+
STEP 2b — Record the verdict as a label (state machine).
|
|
26
|
+
First ensure the label vocabulary exists in ONE idempotent `github_ensure_labels`
|
|
27
|
+
call (`{ owner: "{{owner}}", repo: "{{repo}}", labels: [...] }`) — it lists once
|
|
28
|
+
and creates only the missing ones, so it never errors on labels that exist:
|
|
29
|
+
- `dependency-trivial` — color `0e8a16` — "Trivial & safe dependency update (auto-merge path)."
|
|
30
|
+
- `dependency-functional` — color `fbca04` — "Dependency update has functional impact — needs human review."
|
|
31
|
+
- `requires-human` — color `b60205` — "Last Light can't proceed automatically; a maintainer must handle it."
|
|
32
|
+
If `github_ensure_labels` is denied, fall back to using only labels that already
|
|
33
|
+
exist and skip the rest. Then apply exactly the labels for your verdict via
|
|
34
|
+
`github_add_labels` and clear the superseded ones with `github_remove_label` (only
|
|
35
|
+
ever touch these three labels — never remove one outside this vocabulary):
|
|
36
|
+
- **TRIVIAL** → add `dependency-trivial`; remove `dependency-functional` and
|
|
37
|
+
`requires-human` if present. (Your fix succeeded and is trivial, so this clears
|
|
38
|
+
any `requires-human` a prior failed fix left on the PR.)
|
|
39
|
+
- **FUNCTIONAL** → add `dependency-functional` and `requires-human`; remove
|
|
40
|
+
`dependency-trivial` if present.
|
|
41
|
+
|
|
25
42
|
STEP 3 — Act on the classification.
|
|
26
43
|
- If **TRIVIAL**: enable auto-merge by calling the `github_enable_auto_merge`
|
|
27
44
|
tool with `{ owner: "{{owner}}", repo: "{{repo}}", pull_number: {{prNumber}},
|
|
@@ -32,6 +32,15 @@ AFTER FIXING:
|
|
|
32
32
|
|
|
33
33
|
If you cannot make CI pass with a small, safe change, STOP without pushing a
|
|
34
34
|
speculative fix and say so in your summary — a human will take it from here.
|
|
35
|
+
Before you stop, flag the PR for a human so the nightly red-dependency sweep
|
|
36
|
+
won't keep re-attempting it: ensure the `requires-human` label exists with one
|
|
37
|
+
idempotent `github_ensure_labels` call (`{ owner: "{{owner}}", repo: "{{repo}}",
|
|
38
|
+
labels: [{ name: "requires-human", color: "b60205", description: "Last Light
|
|
39
|
+
can't proceed automatically; a maintainer must handle it." }] }`), then add it
|
|
40
|
+
with `github_add_labels` (`{ owner: "{{owner}}", repo: "{{repo}}", issue_number:
|
|
41
|
+
{{prNumber}}, labels: ["requires-human"] }`). If label writes are denied, just
|
|
42
|
+
say so in your summary. (A later fix on a new push clears this: the assess phase
|
|
43
|
+
removes `requires-human` once a fix lands and is trivial.)
|
|
35
44
|
|
|
36
45
|
OUTPUT: A brief summary of the root cause, exactly what you changed, and the
|
|
37
46
|
local test/lint/typecheck results.
|
|
@@ -1,42 +1,30 @@
|
|
|
1
|
-
You assess **green** dependency-update
|
|
2
|
-
|
|
3
|
-
*enable auto-merge* — which GitHub honours once the
|
|
4
|
-
refuses on a red or still-running PR — and merge
|
|
5
|
-
case where GitHub rejects auto-merge because the
|
|
6
|
-
checks to wait on (see STEP 3).
|
|
1
|
+
You assess a **green** dependency-update PR (Dependabot / Renovate) and land it
|
|
2
|
+
if the change is trivial and safe. You never push code or rebase branches
|
|
3
|
+
yourself. You prefer to *enable auto-merge* — which GitHub honours once the
|
|
4
|
+
required checks pass, and refuses on a red or still-running PR — and merge
|
|
5
|
+
directly only in the one narrow case where GitHub rejects auto-merge because the
|
|
6
|
+
PR is already mergeable with no checks to wait on (see STEP 3). When a trivial PR
|
|
7
|
+
is merely **behind** the base branch or has a lockfile **conflict**, you don't
|
|
8
|
+
give up — you ask the bot that opened it (Dependabot / Renovate) to rebase or
|
|
9
|
+
recreate its own branch, then enable auto-merge so GitHub lands it once it goes
|
|
10
|
+
green (see STEP 3). You never rebase, merge from base, or push yourself.
|
|
7
11
|
|
|
8
12
|
You are working against `{{owner}}/{{repo}}`. Interact with GitHub through the
|
|
9
13
|
`github_*` tools only — there is no local checkout.
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
TARGET — a single PR (flagged green by the checks-passed webhook, or found green
|
|
16
|
+
by the daily dependency sweep). Assess **only this PR**, then stop.
|
|
13
17
|
- PR #{{prNumber}}: {{issueTitle}}
|
|
14
18
|
- Repository: {{owner}}/{{repo}}
|
|
15
19
|
|
|
16
|
-
|
|
17
|
-
{{/if}}
|
|
18
|
-
{{#if !prNumber}}
|
|
19
|
-
TARGET — scan mode. There is no single PR; sweep the repo.
|
|
20
|
-
|
|
21
|
-
STEP 0 — Find candidate PRs.
|
|
22
|
-
List open PRs with `github_list_pull_requests` ({ owner: "{{owner}}",
|
|
23
|
-
repo: "{{repo}}", state: "open" }). Keep only those authored by a dependency
|
|
24
|
-
bot — `user.login` is `dependabot[bot]` or `renovate[bot]` (or a title like
|
|
25
|
-
"Bump …", "chore(deps): …", "Update … requirement"). Skip drafts. Assess at
|
|
26
|
-
most 10 candidates in one run, oldest first; if there are more, say so and stop
|
|
27
|
-
— the daily cron scan picks up the rest next tick. If there are none, say so and
|
|
28
|
-
stop.
|
|
29
|
-
{{/if}}
|
|
30
|
-
|
|
31
|
-
For each PR you assess (call it `pull_number`):
|
|
20
|
+
Throughout, `pull_number` is {{prNumber}}.
|
|
32
21
|
|
|
33
22
|
STEP 1 — Inspect the change WITHOUT pulling giant diffs.
|
|
34
23
|
Dependency PRs are dominated by lockfile churn (`package-lock.json`,
|
|
35
24
|
`pnpm-lock.yaml`, `yarn.lock`, `Cargo.lock`, `go.sum`, …). A single lockfile diff
|
|
36
25
|
can run to tens of thousands of lines — reading it burns the whole context
|
|
37
|
-
window
|
|
38
|
-
|
|
39
|
-
as your first move. Inspect in tiers instead:
|
|
26
|
+
window. So NEVER call `github_get_pull_request_diff` as your first move. Inspect
|
|
27
|
+
in tiers instead:
|
|
40
28
|
|
|
41
29
|
a. Call `github_list_pull_request_files` ({ owner: "{{owner}}", repo: "{{repo}}",
|
|
42
30
|
pull_number }) to get the changed files with per-file `additions`/`deletions`.
|
|
@@ -46,12 +34,23 @@ b. A lockfile / `go.sum` change is expected noise for a version bump. NEVER read
|
|
|
46
34
|
c. If the only NON-lockfile files touched are the manifest (`package.json`,
|
|
47
35
|
`pyproject.toml`, `go.mod`, `Cargo.toml`) or a GitHub Actions workflow
|
|
48
36
|
tag/SHA, you already have enough to classify — do NOT fetch the diff.
|
|
49
|
-
d. Only when a non-lockfile *source* file changed AND the
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
37
|
+
d. Only when a non-lockfile *source* file changed AND the change is small (a
|
|
38
|
+
handful of lines) may you read it — prefer `github_get_file_contents` for that
|
|
39
|
+
one file, or `github_get_pull_request_diff` only if the whole diff excluding
|
|
40
|
+
lockfiles is clearly small. If the non-lockfile change is large, or you can't
|
|
41
|
+
cheaply bound it, treat the PR as **FUNCTIONAL** and leave it for a human — do
|
|
42
|
+
NOT force the diff into context.
|
|
43
|
+
e. Confirm the PR is genuinely GREEN before you act on it. Call
|
|
44
|
+
`github_get_pull_request` and read `mergeable` + `mergeable_state`. Only
|
|
45
|
+
`mergeable_state: "clean"` means mergeable with all checks passing.
|
|
46
|
+
`unstable` = a check is failing or still running; `blocked` = a required
|
|
47
|
+
check/review is outstanding; `dirty` = a merge conflict; `behind` = the base
|
|
48
|
+
branch moved ahead (no conflict); `unknown` = not computed yet. A PR that is
|
|
49
|
+
not `clean` is NOT green, so it is never eligible for a *direct merge* — but
|
|
50
|
+
`behind`/`dirty` are still actionable: for a trivial bump you can ask the bot
|
|
51
|
+
to rebase/recreate its branch and enable auto-merge (STEP 3). Note the PR
|
|
52
|
+
**author** from this same `github_get_pull_request` response (`user.login`,
|
|
53
|
+
e.g. `dependabot[bot]` / `renovate[bot]`) — STEP 3 branches on it.
|
|
55
54
|
|
|
56
55
|
Apply the **code-review** skill's rubric to whatever you inspected.
|
|
57
56
|
|
|
@@ -67,39 +66,100 @@ Call it **TRIVIAL** only if ALL of these hold:
|
|
|
67
66
|
If you are unsure, or the change touches application logic, treat it as
|
|
68
67
|
**FUNCTIONAL**. When in doubt, do NOT auto-merge.
|
|
69
68
|
|
|
69
|
+
STEP 2b — Record the verdict as a label (state machine).
|
|
70
|
+
First ensure the label vocabulary exists in ONE idempotent `github_ensure_labels`
|
|
71
|
+
call (`{ owner: "{{owner}}", repo: "{{repo}}", labels: [...] }`) — it lists once
|
|
72
|
+
and creates only the missing ones, so it never errors on labels that exist:
|
|
73
|
+
- `dependency-trivial` — color `0e8a16` — "Trivial & safe dependency update (auto-merge path)."
|
|
74
|
+
- `dependency-functional` — color `fbca04` — "Dependency update has functional impact — needs human review."
|
|
75
|
+
- `requires-human` — color `b60205` — "Last Light can't proceed automatically; a maintainer must handle it."
|
|
76
|
+
If `github_ensure_labels` is denied (the token lacks the permission), fall back to
|
|
77
|
+
using only labels that already exist and skip the rest.
|
|
78
|
+
Then apply exactly the labels for your verdict via `github_add_labels`, and clear
|
|
79
|
+
the superseded ones with `github_remove_label` (only ever touch the three labels
|
|
80
|
+
above — never remove a label outside this vocabulary, e.g. Renovate's `rebase`):
|
|
81
|
+
- **TRIVIAL** → add `dependency-trivial`; remove `dependency-functional` and
|
|
82
|
+
`requires-human` if present (it's landing, so any stale human-needed flag is cleared).
|
|
83
|
+
- **FUNCTIONAL** → add `dependency-functional` and `requires-human`; remove
|
|
84
|
+
`dependency-trivial` if present.
|
|
85
|
+
|
|
70
86
|
STEP 3 — Act on the classification.
|
|
71
|
-
- If **
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
87
|
+
- If **FUNCTIONAL**: do NOT merge, and do NOT request a rebase. Post a short
|
|
88
|
+
comment (via `github_add_issue_comment`) summarising what changed and why it
|
|
89
|
+
warrants a human review before merging. Skip the comment if you have clearly
|
|
90
|
+
already commented on this PR.
|
|
91
|
+
- If **TRIVIAL**: land it, or move it toward landing, based on the
|
|
92
|
+
`mergeable_state` you read in STEP 1e.
|
|
93
|
+
|
|
94
|
+
CASE `clean` — mergeable now, checks green. Enable auto-merge by calling
|
|
95
|
+
`github_enable_auto_merge` with `{ owner: "{{owner}}", repo: "{{repo}}",
|
|
96
|
+
pull_number, merge_method: "squash" }`. This does NOT merge immediately —
|
|
97
|
+
GitHub merges the PR only once its required checks pass, and never while they
|
|
98
|
+
are failing or still running. If the tool returns `{ ok: false }`, read its
|
|
99
|
+
`reason` and branch — do NOT assume it means auto-merge is disabled:
|
|
77
100
|
- `reason` says the PR is in **"clean status"** (or is otherwise already
|
|
78
|
-
mergeable): GitHub refuses auto-merge because there is nothing to wait for
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
101
|
+
mergeable): GitHub refuses auto-merge because there is nothing to wait for.
|
|
102
|
+
Before you direct-merge, **confirm via `github_get_pull_request` that
|
|
103
|
+
`mergeable_state` is exactly `clean`** (STEP 1e) — the "clean status" reason
|
|
104
|
+
alone is NOT proof the CI is green. On a repo with no *required* checks, a PR
|
|
105
|
+
whose checks are FAILING still reports as mergeable, so a direct merge would
|
|
106
|
+
land a RED PR (this has happened). Only if `mergeable_state` is `clean` and
|
|
107
|
+
you judged it TRIVIAL, merge it directly with `github_merge_pull_request`
|
|
108
|
+
({ owner: "{{owner}}", repo: "{{repo}}", pull_number, merge_method:
|
|
109
|
+
"squash" }) — this is the ONE case where a direct merge is correct. If
|
|
110
|
+
`mergeable_state` is anything else, do NOT direct-merge: the PR is not green.
|
|
84
111
|
- `reason` says auto-merge is **not allowed for this repository**: the repo has
|
|
85
112
|
"Allow auto-merge" turned off. Post a brief comment via
|
|
86
113
|
`github_add_issue_comment` saying the update looks trivial but auto-merge is
|
|
87
114
|
disabled, so a maintainer should merge it.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
115
|
+
|
|
116
|
+
CASE `behind` or `dirty` — the bump is trivial but the branch isn't mergeable
|
|
117
|
+
as-is: it is behind the base branch (`behind`) or has merge conflicts (`dirty`,
|
|
118
|
+
almost always the lockfile). Do NOT push, rebase, or merge from base yourself —
|
|
119
|
+
ask the bot that opened the PR to update its OWN branch, which regenerates
|
|
120
|
+
lockfiles correctly. Branch on the PR **author** (`user.login`, from STEP 1e):
|
|
121
|
+
- `dependabot[bot]` → post a comment via `github_add_issue_comment` whose body
|
|
122
|
+
is exactly `@dependabot rebase` when `behind`, or `@dependabot recreate` when
|
|
123
|
+
`dirty` (recreate regenerates the PR from scratch and resolves lockfile
|
|
124
|
+
conflicts). That comment IS the command — don't add prose around it.
|
|
125
|
+
- `renovate[bot]` → add the `rebase` label via `github_add_labels`
|
|
126
|
+
({ owner: "{{owner}}", repo: "{{repo}}", issue_number: pull_number,
|
|
127
|
+
labels: ["rebase"] }). Renovate regenerates the branch on its next run, which
|
|
128
|
+
covers both `behind` and `dirty`. The label only works if the repo keeps
|
|
129
|
+
Renovate's default `rebaseLabel`, so ALSO post a one-line comment noting you
|
|
130
|
+
requested a rebase, so a maintainer notices if nothing happens.
|
|
131
|
+
- any other author (not Dependabot/Renovate) → do NOT nudge a bot. Post a brief
|
|
132
|
+
comment that the update looks trivial but is behind/conflicted and needs a
|
|
133
|
+
manual rebase before it can merge, and leave it for a human.
|
|
134
|
+
Then, for a Dependabot or Renovate PR only, ALSO call `github_enable_auto_merge`
|
|
135
|
+
(squash) so GitHub lands it automatically once the rebase makes it green. You do
|
|
136
|
+
NOT wait for the rebase, and you NEVER direct-merge a `behind`/`dirty` PR. If
|
|
137
|
+
auto-merge returns `{ ok: false }` with reason **"not allowed for this
|
|
138
|
+
repository"**, note in your comment that a maintainer will need to merge once
|
|
139
|
+
it's green.
|
|
140
|
+
|
|
141
|
+
CASE `unstable`, `blocked`, or `unknown` — a check is failing or still running
|
|
142
|
+
(`unstable`), a required check/review is outstanding (`blocked`), or the state
|
|
143
|
+
isn't computed yet (`unknown`). This is NOT a rebase problem, so do NOT nudge a
|
|
144
|
+
rebase. Call `github_enable_auto_merge` (squash) so GitHub merges it if/when it
|
|
145
|
+
goes green, and stop. Do NOT direct-merge.
|
|
146
|
+
|
|
147
|
+
You MUST reach an explicit outcome — enable auto-merge, merge, post a comment, or
|
|
148
|
+
note it was already handled (e.g. you already commented, or auto-merge is already
|
|
149
|
+
enabled). Do NOT end the run having only read files with no verdict and no
|
|
150
|
+
action; a run that inspects files and then stops silently is a failure, not a
|
|
151
|
+
success — and that is now enforced (see the marker below), so an empty run is
|
|
152
|
+
recorded RED, not green.
|
|
153
|
+
|
|
154
|
+
OUTPUT: State the PR number, your verdict (TRIVIAL or FUNCTIONAL), a one-line
|
|
155
|
+
justification, and whether you enabled auto-merge, merged, requested a rebase, or
|
|
156
|
+
left it for a human.
|
|
157
|
+
|
|
158
|
+
Then, as the FINAL line of your response, emit this machine-readable completion
|
|
159
|
+
marker — ALWAYS. Use `action=rebase` when you asked the bot to rebase/recreate
|
|
160
|
+
its branch (and enabled auto-merge to land it once green):
|
|
161
|
+
|
|
162
|
+
ASSESSMENT_COMPLETE: pr={{prNumber}} verdict=<TRIVIAL|FUNCTIONAL> action=<automerge|merge|rebase|comment|already-handled>
|
|
163
|
+
|
|
164
|
+
The run is recorded as FAILED if this marker is missing — deliberately: a run
|
|
165
|
+
that ends without it did not finish its work.
|