lastlight-core 0.22.0 → 0.23.1

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.
Files changed (103) hide show
  1. package/config/default.yaml +70 -2
  2. package/dist/config/config.d.ts +35 -0
  3. package/dist/config/config.js +152 -3
  4. package/dist/config/config.js.map +1 -1
  5. package/dist/config/repo-config.d.ts +7 -0
  6. package/dist/config/repo-config.js +15 -0
  7. package/dist/config/repo-config.js.map +1 -1
  8. package/dist/connectors/github-webhook.d.ts +17 -0
  9. package/dist/connectors/github-webhook.js +150 -17
  10. package/dist/connectors/github-webhook.js.map +1 -1
  11. package/dist/connectors/types.d.ts +48 -1
  12. package/dist/cron/dependabot-discovery.d.ts +68 -11
  13. package/dist/cron/dependabot-discovery.js +78 -20
  14. package/dist/cron/dependabot-discovery.js.map +1 -1
  15. package/dist/cron/jobs.d.ts +4 -0
  16. package/dist/cron/jobs.js +38 -4
  17. package/dist/cron/jobs.js.map +1 -1
  18. package/dist/cron/review-discovery.d.ts +33 -20
  19. package/dist/cron/review-discovery.js +23 -30
  20. package/dist/cron/review-discovery.js.map +1 -1
  21. package/dist/engine/agent-executor.d.ts +1 -1
  22. package/dist/engine/agent-executor.js +1 -1
  23. package/dist/engine/agent-executor.js.map +1 -1
  24. package/dist/engine/dispatcher.d.ts +98 -1
  25. package/dist/engine/dispatcher.js +248 -231
  26. package/dist/engine/dispatcher.js.map +1 -1
  27. package/dist/engine/executors/shared.d.ts +43 -0
  28. package/dist/engine/executors/shared.js +65 -0
  29. package/dist/engine/executors/shared.js.map +1 -1
  30. package/dist/engine/fix-harvest.d.ts +169 -0
  31. package/dist/engine/fix-harvest.js +345 -0
  32. package/dist/engine/fix-harvest.js.map +1 -0
  33. package/dist/engine/fix-markers.d.ts +184 -0
  34. package/dist/engine/fix-markers.js +329 -0
  35. package/dist/engine/fix-markers.js.map +1 -0
  36. package/dist/engine/fix-scratch.d.ts +76 -0
  37. package/dist/engine/fix-scratch.js +77 -0
  38. package/dist/engine/fix-scratch.js.map +1 -0
  39. package/dist/engine/github/github.d.ts +212 -5
  40. package/dist/engine/github/github.js +481 -54
  41. package/dist/engine/github/github.js.map +1 -1
  42. package/dist/engine/pr-decisions.d.ts +342 -0
  43. package/dist/engine/pr-decisions.js +721 -0
  44. package/dist/engine/pr-decisions.js.map +1 -0
  45. package/dist/engine/pr-escalation.d.ts +152 -0
  46. package/dist/engine/pr-escalation.js +320 -0
  47. package/dist/engine/pr-escalation.js.map +1 -0
  48. package/dist/engine/pr-notes.d.ts +175 -0
  49. package/dist/engine/pr-notes.js +315 -0
  50. package/dist/engine/pr-notes.js.map +1 -0
  51. package/dist/engine/pr-state.d.ts +313 -0
  52. package/dist/engine/pr-state.js +515 -0
  53. package/dist/engine/pr-state.js.map +1 -0
  54. package/dist/engine/review-check.d.ts +200 -0
  55. package/dist/engine/review-check.js +305 -0
  56. package/dist/engine/review-check.js.map +1 -0
  57. package/dist/engine/router.d.ts +27 -0
  58. package/dist/engine/router.js +156 -22
  59. package/dist/engine/router.js.map +1 -1
  60. package/dist/evals-api.d.ts +7 -0
  61. package/dist/evals-api.js +30 -0
  62. package/dist/evals-api.js.map +1 -1
  63. package/dist/index.js +268 -20
  64. package/dist/index.js.map +1 -1
  65. package/dist/sandbox/index.d.ts +13 -0
  66. package/dist/sandbox/index.js +30 -0
  67. package/dist/sandbox/index.js.map +1 -1
  68. package/dist/sandbox/k8s/init-clone.d.ts +5 -0
  69. package/dist/sandbox/k8s/init-clone.js +27 -0
  70. package/dist/sandbox/k8s/init-clone.js.map +1 -1
  71. package/dist/state/execution-store.d.ts +27 -0
  72. package/dist/state/execution-store.js +45 -0
  73. package/dist/state/execution-store.js.map +1 -1
  74. package/dist/state/workflow-run-store.d.ts +73 -0
  75. package/dist/state/workflow-run-store.js +106 -24
  76. package/dist/state/workflow-run-store.js.map +1 -1
  77. package/dist/workflows/pr-scope.d.ts +63 -0
  78. package/dist/workflows/pr-scope.js +113 -0
  79. package/dist/workflows/pr-scope.js.map +1 -0
  80. package/dist/workflows/resume.js +17 -4
  81. package/dist/workflows/resume.js.map +1 -1
  82. package/dist/workflows/simple.d.ts +94 -1
  83. package/dist/workflows/simple.js +206 -3
  84. package/dist/workflows/simple.js.map +1 -1
  85. package/dist/workflows/target-policy.d.ts +0 -12
  86. package/dist/workflows/target-policy.js +9 -15
  87. package/dist/workflows/target-policy.js.map +1 -1
  88. package/package.json +4 -4
  89. package/skills/README.md +11 -5
  90. package/skills/dependency-impact/SKILL.md +83 -0
  91. package/skills/fixing/SKILL.md +194 -0
  92. package/skills/pr-comment/SKILL.md +4 -1
  93. package/skills/pr-review/SKILL.md +26 -9
  94. package/workflows/cron-dependabot-ci-fix.yaml +8 -5
  95. package/workflows/cron-review.yaml +14 -5
  96. package/workflows/dependabot-ci-fix.yaml +86 -2
  97. package/workflows/dependabot-pr-merge.yaml +13 -1
  98. package/workflows/pr-fix.yaml +84 -1
  99. package/workflows/pr-review.yaml +7 -0
  100. package/workflows/prompts/dependabot-ci-fix.md +70 -17
  101. package/workflows/prompts/dependabot-pr-merge.md +209 -81
  102. package/workflows/prompts/diagnose-ci.md +96 -0
  103. package/workflows/prompts/pr-fix.md +63 -4
@@ -64,6 +64,92 @@ export interface RepoConfigTreeOptions {
64
64
  */
65
65
  includePath?: (path: string) => boolean;
66
66
  }
67
+ /**
68
+ * One failed check run, resolved as far as the App's permissions allow.
69
+ *
70
+ * The optional fields are exactly the ones that need `Actions: read`. They are
71
+ * the difference between "CI is red" and "CI is red *here*, in *this* step of
72
+ * *this* workflow file" — `workflowPath` is what lets a fix agent open the CI
73
+ * definition in its checkout and compare CI's toolchain against the sandbox's.
74
+ */
75
+ export interface CiJobFailure {
76
+ /** Check-run name, e.g. `CI / build (22)`. */
77
+ name: string;
78
+ /** `failure` | `timed_out` — the conclusions {@link GitHubClient.getChecksConclusion} calls red. */
79
+ conclusion: string;
80
+ /** e.g. `.github/workflows/ci.yml`. Undefined for non-Actions checks or when Actions is unreadable. */
81
+ workflowPath?: string;
82
+ /** Name of the step that failed, from the job's `steps[]`. Same availability as `workflowPath`. */
83
+ failingStep?: string;
84
+ /** {@link extractErrorExcerpt} over the real job log, or the annotation fallback. */
85
+ logExcerpt: string;
86
+ /** The check run's `details_url` — where an agent can dig further via `github_get_job_logs`. */
87
+ jobUrl?: string;
88
+ /** True only when `logExcerpt` came from the REAL Actions job log. */
89
+ logsAvailable: boolean;
90
+ /**
91
+ * WHY the real log is missing, when it is. Set only for an Actions job we
92
+ * actually tried to read — see {@link CiLogUnavailableCause}.
93
+ */
94
+ logUnavailableCause?: CiLogUnavailableCause;
95
+ }
96
+ /**
97
+ * Why an Actions job log could not be used as evidence.
98
+ *
99
+ * Every one of these used to collapse into a single `.catch(() => null)`, and
100
+ * the banner then asserted the one cause we had never checked ("the App lacks
101
+ * `Actions: read`"). Telling an operator to grant a permission they already
102
+ * granted is a smaller version of exactly the damage issue #251's Finding 1 was
103
+ * about: a degradation that reads as normal operation. So the cause is
104
+ * CLASSIFIED at the point of failure and rendered verbatim.
105
+ *
106
+ * - `forbidden` — HTTP 403. The genuine missing-permission case, and the
107
+ * only one where "grant Actions: read" is the fix. App-wide,
108
+ * so one job saying it settles it for the whole report.
109
+ * - `expired` — HTTP 410 Gone. Actions retains logs for a bounded window;
110
+ * on an older PR this is the COMMON case, and there is
111
+ * nothing to grant.
112
+ * - `unavailable` — anything else: 429/secondary rate limit, 5xx, the report
113
+ * deadline firing, or a body we could not decode. Transient.
114
+ * - `empty` — the download succeeded and carried nothing usable. Not a
115
+ * fetch problem at all.
116
+ */
117
+ export type CiLogUnavailableCause = "forbidden" | "expired" | "unavailable" | "empty";
118
+ /** Structured result of {@link GitHubClient.getCiFailureReport}. */
119
+ export interface CiFailureReport {
120
+ jobs: CiJobFailure[];
121
+ /** False when NO job could supply a real log — everything below is annotations. */
122
+ logsAvailable: boolean;
123
+ /**
124
+ * The cause the banner speaks with when `logsAvailable` is false — the most
125
+ * actionable one across the jobs (see {@link dominantLogUnavailableCause}).
126
+ * Undefined when logs were available or when no Actions job was even tried.
127
+ */
128
+ logUnavailableCause?: CiLogUnavailableCause;
129
+ }
130
+ /** Options shared by the three settle-aware check queries. */
131
+ export interface ChecksQueryOptions {
132
+ /**
133
+ * Drop check runs produced by this GitHub App slug — in practice always our
134
+ * own `botName`.
135
+ *
136
+ * **This is the self-gating deadlock fix** (07-review-triggers.md §7.2). The
137
+ * aggregate is computed over *every* check run on the head SHA, ours
138
+ * included, so a `last-light/review` check sitting `queued` (waiting for CI,
139
+ * under `review.trigger: after-checks`) or `in_progress` (a review actually
140
+ * running) makes the aggregate permanently `pending`. The settle event then
141
+ * never fires, the review never runs, the check never concludes — and if the
142
+ * repo made it a *required* check, the PR is unmergeable forever. The same
143
+ * loop reaches `pr.checks_passed` on a Dependabot PR whose review check is
144
+ * still open, so the rule is uniform: **exclude our own checks from every
145
+ * TRIGGER-side settle computation**, and let GitHub's required-check gate do
146
+ * the real merge gating.
147
+ *
148
+ * It is deliberately opt-in rather than always-on: a caller reporting check
149
+ * state to a *human* (or to the merge prompt) should show what GitHub shows.
150
+ */
151
+ excludeApp?: string;
152
+ }
67
153
  /**
68
154
  * GitHub client for the harness — uses GitHub App auth.
69
155
  * Used by the orchestrator to post comments, not by agent sessions.
@@ -87,6 +173,24 @@ export declare class GitHubClient {
87
173
  * just post a one-off comment can ignore the return.
88
174
  */
89
175
  postComment(owner: string, repo: string, issueNumber: number, body: string): Promise<number>;
176
+ /**
177
+ * Add labels to an issue/PR, leaving existing labels alone.
178
+ *
179
+ * The only harness-side label WRITE. Every other label mutation in the system
180
+ * happens INSIDE the sandbox, through agentic-pi's `github_*` tools driven
181
+ * from a prompt — which is the right place for a label whose value is an
182
+ * agent's judgement (`dependency-trivial`, the triage vocabulary). This one
183
+ * is different in kind: the dispatch-time escalation
184
+ * (`../pr-escalation.ts`) fires precisely when we have decided NOT to
185
+ * provision a sandbox, so there is no agent to ask.
186
+ *
187
+ * GitHub's own endpoint creates a label that does not exist yet (with an
188
+ * arbitrary colour), so there is no `ensureLabels` companion to write.
189
+ * Idempotent by construction — re-adding a present label is a no-op — but
190
+ * that is NOT what makes the escalation post one comment; see
191
+ * `../pr-escalation.ts` for the record that does.
192
+ */
193
+ addLabels(owner: string, repo: string, issueNumber: number, labels: string[]): Promise<void>;
90
194
  /**
91
195
  * List every repository the App installation can access, as `owner/repo`
92
196
  * full names. Used at boot to seed the managed-repo list from the App grant
@@ -1244,8 +1348,16 @@ export declare class GitHubClient {
1244
1348
  * `name` in their list will gate merges on the eventual conclusion.
1245
1349
  *
1246
1350
  * Requires the GitHub App to have `Checks: Read and write` permission.
1351
+ *
1352
+ * `status` defaults to `in_progress` (the historical behaviour). The other
1353
+ * two exist for the review PLACEHOLDERS: `queued` says "waiting for CI"
1354
+ * under `review.trigger: after-checks`, and `completed` + `conclusion:
1355
+ * neutral` says "available on request" under `on-request` — see
1356
+ * `reviewCheckPlacement` in ../pr-decisions.ts.
1247
1357
  */
1248
1358
  createCheckRun(owner: string, repo: string, headSha: string, name: string, options?: {
1359
+ status?: "queued" | "in_progress" | "completed";
1360
+ conclusion?: "success" | "failure" | "neutral" | "cancelled" | "timed_out" | "action_required" | "skipped";
1249
1361
  detailsUrl?: string;
1250
1362
  output?: {
1251
1363
  title: string;
@@ -1323,12 +1435,86 @@ export declare class GitHubClient {
1323
1435
  * discovery and the fix prompt agree on what "red" means.
1324
1436
  * "passing" — there ARE checks/statuses and none are failing or pending.
1325
1437
  */
1326
- getChecksConclusion(owner: string, repo: string, ref: string): Promise<"passing" | "failing" | "pending" | "none">;
1438
+ getChecksConclusion(owner: string, repo: string, ref: string, opts?: ChecksQueryOptions): Promise<"passing" | "failing" | "pending" | "none">;
1327
1439
  /**
1328
- * Get failed check runs for a PR's head SHA.
1329
- * Fetches the actual job logs (not just annotations) to show real errors.
1440
+ * {@link getChecksConclusion} plus the COUNT of checks behind the verdict, in
1441
+ * the same two API calls.
1442
+ *
1443
+ * `settledCount` exists because "passing" alone is not evidence of anything:
1444
+ * on a repo with no CI at all, `getChecksConclusion` returns `"none"` and a
1445
+ * repo with one trivial check returns `"passing"` — and the auto-merge
1446
+ * decision needs to tell "CI approved this" from "nothing looked at it"
1447
+ * (`dependencies.minSettledChecks`; see `mayMerge` in ../pr-decisions.ts and
1448
+ * 09-state-machine.md → D10). Deriving it in the client rather than at the
1449
+ * call site keeps it to ONE round trip: recomputing the count from a second
1450
+ * `listForRef` would double the cost of every PR-state resolution.
1451
+ *
1452
+ * A check run counts as settled when it has left queued/in_progress —
1453
+ * whatever it concluded. Status contexts are settled unless the combined
1454
+ * state is `pending`.
1455
+ */
1456
+ getChecksSummary(owner: string, repo: string, ref: string, opts?: ChecksQueryOptions): Promise<{
1457
+ state: "passing" | "failing" | "pending" | "none";
1458
+ settledCount: number;
1459
+ pendingCount: number;
1460
+ }>;
1461
+ /**
1462
+ * The git AUTHOR NAME on a commit — not a GitHub login.
1463
+ *
1464
+ * This is the discriminator the fix state machine uses to answer "did WE push
1465
+ * this head, or did the world move?" (09-state-machine.md → S1, the attempt
1466
+ * table). It has to be the git author name because that is what
1467
+ * `git-auth.ts` stamps on the agent's own commits (`user.name = botLogin`),
1468
+ * and it is the same field `check_suite.head_commit.author.name` carries on
1469
+ * the webhook path — so the webhook and the cron agree by construction.
1470
+ *
1471
+ * Returns `""` when GitHub reports no author name, so callers get a value
1472
+ * that simply never equals `botLogin` rather than a null to branch on.
1473
+ */
1474
+ getCommitAuthorName(owner: string, repo: string, ref: string): Promise<string>;
1475
+ /**
1476
+ * Check state of a PR's BASE branch head — a branch name is a valid `ref` for
1477
+ * the checks API, so this is {@link getChecksConclusion} pointed at the base
1478
+ * tip.
1479
+ *
1480
+ * It has its own name because the *question* is different: "is the PR at
1481
+ * fault, or was `main` already red?". A red base makes retrying the PR
1482
+ * pointless, and call sites asking that shouldn't have to know it's the same
1483
+ * query as "is this PR red".
1484
+ */
1485
+ getBaseChecksState(owner: string, repo: string, baseRef: string, opts?: ChecksQueryOptions): Promise<"passing" | "failing" | "pending" | "none">;
1486
+ /**
1487
+ * Structured CI failure evidence for a ref — the HEAVY counterpart to
1488
+ * {@link getChecksConclusion}: one Actions job-log download per failed check
1489
+ * run, plus the job and workflow-run metadata that says *where* it failed.
1490
+ *
1491
+ * Every Actions read here needs the App's optional `Actions: read`
1492
+ * permission. None of them is required: each degrades independently to
1493
+ * `undefined` / the annotation fallback, and the per-job + report-level
1494
+ * `logsAvailable` flags are what let the renderer say so out loud instead of
1495
+ * passing annotations off as job logs (issue #251).
1496
+ *
1497
+ * Throws if the check-run listing itself fails — a report cannot represent
1498
+ * "I couldn't look". {@link getFailedChecks} catches that for prompt callers.
1499
+ *
1500
+ * **Bounded on purpose.** `resolvePrState` awaits this synchronously on the
1501
+ * dispatch path a webhook handler takes, BEFORE any disposition is taken — so
1502
+ * it is paid in full even on dispatches that go on to skip as
1503
+ * `already-reviewed` / `human-hold` / `run-in-flight`. `checks.listForRef`
1504
+ * returns up to 30 runs, and the first cut of this method downloaded every
1505
+ * failed one's FULL log concurrently, uncapped and with no deadline: thirty
1506
+ * multi-megabyte strings resident at once, on a host with a 2 GB agent cap and
1507
+ * no swap. Hence {@link CI_LOG_FETCH_CONCURRENCY},
1508
+ * {@link CI_REPORT_DEADLINE_MS} and the byte cap inside
1509
+ * {@link extractErrorExcerpt}.
1330
1510
  */
1331
- getFailedChecks(owner: string, repo: string, ref: string): Promise<string>;
1511
+ getCiFailureReport(owner: string, repo: string, ref: string, opts?: ChecksQueryOptions): Promise<CiFailureReport>;
1512
+ /**
1513
+ * Get failed check runs for a PR's head SHA as the markdown blob
1514
+ * `{{ciSection}}` has always carried — a thin renderer over
1515
+ * {@link getCiFailureReport}, kept so prompt-only callers are unchanged.
1516
+ */
1517
+ getFailedChecks(owner: string, repo: string, ref: string, opts?: ChecksQueryOptions): Promise<string>;
1332
1518
  }
1333
1519
  /**
1334
1520
  * Parse the Actions job id from a check-run's `details_url`.
@@ -1336,9 +1522,30 @@ export declare class GitHubClient {
1336
1522
  * Returns `null` for non-Actions checks or unparseable URLs.
1337
1523
  */
1338
1524
  export declare function actionsJobIdFromDetailsUrl(url: string | null | undefined): number | null;
1525
+ /**
1526
+ * Parse the Actions *run* id out of the same `details_url`. The run — not the
1527
+ * job — is what knows the workflow file's `path`, and the URL already carries
1528
+ * it, so resolving `workflowPath` costs no extra lookup to discover the id.
1529
+ * Returns `null` for non-Actions checks or unparseable URLs.
1530
+ */
1531
+ export declare function actionsRunIdFromDetailsUrl(url: string | null | undefined): number | null;
1532
+ /**
1533
+ * Render a {@link CiFailureReport} as the markdown `{{ciSection}}` carries.
1534
+ *
1535
+ * The "No failed checks found." sentinel is load-bearing: `dispatchWorkflow`
1536
+ * tests the rendered string for `"No failed checks"` to decide whether to
1537
+ * populate `ciSection` at all.
1538
+ */
1539
+ export declare function renderCiFailureReport(report: CiFailureReport): string;
1339
1540
  /**
1340
1541
  * Given the full text of an Actions job log, return a compact excerpt
1341
1542
  * highlighting the real error lines with surrounding context.
1342
1543
  * Timestamps are stripped; pure noise lines are deprioritised.
1544
+ *
1545
+ * Bounded in BYTES as well as lines ({@link MAX_CI_LOG_EXCERPT_BYTES}), because
1546
+ * the line bounds below are no bound at all on a log whose failure is one
1547
+ * 8 MB minified line — and this excerpt is held on `PrState.ciReport` and
1548
+ * rendered into a prompt. The cap is applied here rather than at the call site
1549
+ * so every caller is bounded by construction.
1343
1550
  */
1344
- export declare function extractErrorExcerpt(fullLog: string): string;
1551
+ export declare function extractErrorExcerpt(fullLog: string, maxBytes?: number): string;