lastlight-core 0.16.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.
- package/LICENSE +21 -0
- package/README.md +10 -0
- package/agent-context/rules.md +80 -0
- package/agent-context/security.md +69 -0
- package/agent-context/soul.md +21 -0
- package/config/default.yaml +119 -0
- package/deploy/.env.production.example +100 -0
- package/deploy/entrypoint.sh +82 -0
- package/deploy/native/README.md +160 -0
- package/deploy/native/install.sh +110 -0
- package/deploy/native/lastlight.env.example +95 -0
- package/deploy/native/lastlight.service +50 -0
- package/deploy/sandbox-entrypoint.sh +93 -0
- package/deploy/slack/README.md +92 -0
- package/deploy/slack/slack-manifest.json +55 -0
- package/dist/admin/auth.d.ts +51 -0
- package/dist/admin/auth.js +121 -0
- package/dist/admin/auth.js.map +1 -0
- package/dist/admin/chat-session-reader.d.ts +39 -0
- package/dist/admin/chat-session-reader.js +84 -0
- package/dist/admin/chat-session-reader.js.map +1 -0
- package/dist/admin/docker.d.ts +61 -0
- package/dist/admin/docker.js +187 -0
- package/dist/admin/docker.js.map +1 -0
- package/dist/admin/index.d.ts +9 -0
- package/dist/admin/index.js +59 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/admin/routes.d.ts +81 -0
- package/dist/admin/routes.js +1381 -0
- package/dist/admin/routes.js.map +1 -0
- package/dist/admin/sessions.d.ts +89 -0
- package/dist/admin/sessions.js +204 -0
- package/dist/admin/sessions.js.map +1 -0
- package/dist/admin/tail.d.ts +12 -0
- package/dist/admin/tail.js +145 -0
- package/dist/admin/tail.js.map +1 -0
- package/dist/admin/version.d.ts +22 -0
- package/dist/admin/version.js +92 -0
- package/dist/admin/version.js.map +1 -0
- package/dist/config/config-resolve.d.ts +28 -0
- package/dist/config/config-resolve.js +47 -0
- package/dist/config/config-resolve.js.map +1 -0
- package/dist/config/config.d.ts +140 -0
- package/dist/config/config.js +581 -0
- package/dist/config/config.js.map +1 -0
- package/dist/connectors/github-webhook.d.ts +45 -0
- package/dist/connectors/github-webhook.js +321 -0
- package/dist/connectors/github-webhook.js.map +1 -0
- package/dist/connectors/index.d.ts +18 -0
- package/dist/connectors/index.js +41 -0
- package/dist/connectors/index.js.map +1 -0
- package/dist/connectors/messaging/base.d.ts +42 -0
- package/dist/connectors/messaging/base.js +139 -0
- package/dist/connectors/messaging/base.js.map +1 -0
- package/dist/connectors/messaging/delivery.d.ts +14 -0
- package/dist/connectors/messaging/delivery.js +38 -0
- package/dist/connectors/messaging/delivery.js.map +1 -0
- package/dist/connectors/messaging/index.d.ts +4 -0
- package/dist/connectors/messaging/index.js +4 -0
- package/dist/connectors/messaging/index.js.map +1 -0
- package/dist/connectors/messaging/session-manager.d.ts +53 -0
- package/dist/connectors/messaging/session-manager.js +255 -0
- package/dist/connectors/messaging/session-manager.js.map +1 -0
- package/dist/connectors/messaging/types.d.ts +58 -0
- package/dist/connectors/messaging/types.js +7 -0
- package/dist/connectors/messaging/types.js.map +1 -0
- package/dist/connectors/slack/connector.d.ts +142 -0
- package/dist/connectors/slack/connector.js +494 -0
- package/dist/connectors/slack/connector.js.map +1 -0
- package/dist/connectors/slack/index.d.ts +2 -0
- package/dist/connectors/slack/index.js +3 -0
- package/dist/connectors/slack/index.js.map +1 -0
- package/dist/connectors/slack/mrkdwn.d.ts +19 -0
- package/dist/connectors/slack/mrkdwn.js +240 -0
- package/dist/connectors/slack/mrkdwn.js.map +1 -0
- package/dist/connectors/types.d.ts +61 -0
- package/dist/connectors/types.js +2 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/cron/fanout.d.ts +33 -0
- package/dist/cron/fanout.js +55 -0
- package/dist/cron/fanout.js.map +1 -0
- package/dist/cron/jobs.d.ts +18 -0
- package/dist/cron/jobs.js +37 -0
- package/dist/cron/jobs.js.map +1 -0
- package/dist/cron/scheduler.d.ts +45 -0
- package/dist/cron/scheduler.js +105 -0
- package/dist/cron/scheduler.js.map +1 -0
- package/dist/engine/agent-executor.d.ts +34 -0
- package/dist/engine/agent-executor.js +246 -0
- package/dist/engine/agent-executor.js.map +1 -0
- package/dist/engine/chat/chat-runner.d.ts +132 -0
- package/dist/engine/chat/chat-runner.js +424 -0
- package/dist/engine/chat/chat-runner.js.map +1 -0
- package/dist/engine/chat/chat-skills.d.ts +45 -0
- package/dist/engine/chat/chat-skills.js +184 -0
- package/dist/engine/chat/chat-skills.js.map +1 -0
- package/dist/engine/chat/chat.d.ts +54 -0
- package/dist/engine/chat/chat.js +316 -0
- package/dist/engine/chat/chat.js.map +1 -0
- package/dist/engine/chat/message-batcher.d.ts +32 -0
- package/dist/engine/chat/message-batcher.js +109 -0
- package/dist/engine/chat/message-batcher.js.map +1 -0
- package/dist/engine/dispatcher.d.ts +73 -0
- package/dist/engine/dispatcher.js +663 -0
- package/dist/engine/dispatcher.js.map +1 -0
- package/dist/engine/event-shim.d.ts +117 -0
- package/dist/engine/event-shim.js +435 -0
- package/dist/engine/event-shim.js.map +1 -0
- package/dist/engine/executors/orchestrator.d.ts +74 -0
- package/dist/engine/executors/orchestrator.js +365 -0
- package/dist/engine/executors/orchestrator.js.map +1 -0
- package/dist/engine/executors/shared.d.ts +189 -0
- package/dist/engine/executors/shared.js +616 -0
- package/dist/engine/executors/shared.js.map +1 -0
- package/dist/engine/github/git-auth.d.ts +62 -0
- package/dist/engine/github/git-auth.js +161 -0
- package/dist/engine/github/git-auth.js.map +1 -0
- package/dist/engine/github/github-app-client.d.ts +23 -0
- package/dist/engine/github/github-app-client.js +33 -0
- package/dist/engine/github/github-app-client.js.map +1 -0
- package/dist/engine/github/github-tools.d.ts +18 -0
- package/dist/engine/github/github-tools.js +263 -0
- package/dist/engine/github/github-tools.js.map +1 -0
- package/dist/engine/github/github.d.ts +1193 -0
- package/dist/engine/github/github.js +357 -0
- package/dist/engine/github/github.js.map +1 -0
- package/dist/engine/github/profiles.d.ts +11 -0
- package/dist/engine/github/profiles.js +42 -0
- package/dist/engine/github/profiles.js.map +1 -0
- package/dist/engine/github/review-poster.d.ts +98 -0
- package/dist/engine/github/review-poster.js +177 -0
- package/dist/engine/github/review-poster.js.map +1 -0
- package/dist/engine/llm.d.ts +79 -0
- package/dist/engine/llm.js +269 -0
- package/dist/engine/llm.js.map +1 -0
- package/dist/engine/oauth.d.ts +8 -0
- package/dist/engine/oauth.js +9 -0
- package/dist/engine/oauth.js.map +1 -0
- package/dist/engine/router.d.ts +29 -0
- package/dist/engine/router.js +680 -0
- package/dist/engine/router.js.map +1 -0
- package/dist/engine/screen/classifier.d.ts +93 -0
- package/dist/engine/screen/classifier.js +215 -0
- package/dist/engine/screen/classifier.js.map +1 -0
- package/dist/engine/screen/screen.d.ts +41 -0
- package/dist/engine/screen/screen.js +93 -0
- package/dist/engine/screen/screen.js.map +1 -0
- package/dist/evals-api.d.ts +24 -0
- package/dist/evals-api.js +22 -0
- package/dist/evals-api.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +940 -0
- package/dist/index.js.map +1 -0
- package/dist/managed-repos.d.ts +30 -0
- package/dist/managed-repos.js +72 -0
- package/dist/managed-repos.js.map +1 -0
- package/dist/notify/blocks.d.ts +23 -0
- package/dist/notify/blocks.js +118 -0
- package/dist/notify/blocks.js.map +1 -0
- package/dist/notify/index.d.ts +17 -0
- package/dist/notify/index.js +7 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/model.d.ts +57 -0
- package/dist/notify/model.js +89 -0
- package/dist/notify/model.js.map +1 -0
- package/dist/notify/notifier.d.ts +18 -0
- package/dist/notify/notifier.js +100 -0
- package/dist/notify/notifier.js.map +1 -0
- package/dist/notify/render.d.ts +21 -0
- package/dist/notify/render.js +59 -0
- package/dist/notify/render.js.map +1 -0
- package/dist/notify/transports/github.d.ts +26 -0
- package/dist/notify/transports/github.js +27 -0
- package/dist/notify/transports/github.js.map +1 -0
- package/dist/notify/transports/slack.d.ts +27 -0
- package/dist/notify/transports/slack.js +37 -0
- package/dist/notify/transports/slack.js.map +1 -0
- package/dist/notify/types.d.ts +111 -0
- package/dist/notify/types.js +16 -0
- package/dist/notify/types.js.map +1 -0
- package/dist/sandbox/docker.d.ts +180 -0
- package/dist/sandbox/docker.js +517 -0
- package/dist/sandbox/docker.js.map +1 -0
- package/dist/sandbox/egress-allowlist.d.ts +74 -0
- package/dist/sandbox/egress-allowlist.js +164 -0
- package/dist/sandbox/egress-allowlist.js.map +1 -0
- package/dist/sandbox/egress-firewall-config.d.ts +127 -0
- package/dist/sandbox/egress-firewall-config.js +434 -0
- package/dist/sandbox/egress-firewall-config.js.map +1 -0
- package/dist/sandbox/images.d.ts +23 -0
- package/dist/sandbox/images.js +55 -0
- package/dist/sandbox/images.js.map +1 -0
- package/dist/sandbox/index.d.ts +112 -0
- package/dist/sandbox/index.js +332 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/sandbox.d.ts +214 -0
- package/dist/sandbox/sandbox.js +453 -0
- package/dist/sandbox/sandbox.js.map +1 -0
- package/dist/sandbox/smol.d.ts +162 -0
- package/dist/sandbox/smol.js +485 -0
- package/dist/sandbox/smol.js.map +1 -0
- package/dist/session-log.d.ts +63 -0
- package/dist/session-log.js +290 -0
- package/dist/session-log.js.map +1 -0
- package/dist/state/approval-store.d.ts +88 -0
- package/dist/state/approval-store.js +149 -0
- package/dist/state/approval-store.js.map +1 -0
- package/dist/state/build-assets.d.ts +50 -0
- package/dist/state/build-assets.js +154 -0
- package/dist/state/build-assets.js.map +1 -0
- package/dist/state/db.d.ts +81 -0
- package/dist/state/db.js +155 -0
- package/dist/state/db.js.map +1 -0
- package/dist/state/execution-store.d.ts +257 -0
- package/dist/state/execution-store.js +527 -0
- package/dist/state/execution-store.js.map +1 -0
- package/dist/state/migrate.d.ts +15 -0
- package/dist/state/migrate.js +175 -0
- package/dist/state/migrate.js.map +1 -0
- package/dist/state/workflow-run-store.d.ts +216 -0
- package/dist/state/workflow-run-store.js +403 -0
- package/dist/state/workflow-run-store.js.map +1 -0
- package/dist/telemetry/index.d.ts +38 -0
- package/dist/telemetry/index.js +253 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/pi-events.d.ts +12 -0
- package/dist/telemetry/pi-events.js +134 -0
- package/dist/telemetry/pi-events.js.map +1 -0
- package/dist/workflows/dag.d.ts +1 -0
- package/dist/workflows/dag.js +2 -0
- package/dist/workflows/dag.js.map +1 -0
- package/dist/workflows/handlers/post-review.d.ts +45 -0
- package/dist/workflows/handlers/post-review.js +220 -0
- package/dist/workflows/handlers/post-review.js.map +1 -0
- package/dist/workflows/handlers/verdict-reader.d.ts +14 -0
- package/dist/workflows/handlers/verdict-reader.js +55 -0
- package/dist/workflows/handlers/verdict-reader.js.map +1 -0
- package/dist/workflows/loader.d.ts +9 -0
- package/dist/workflows/loader.js +10 -0
- package/dist/workflows/loader.js.map +1 -0
- package/dist/workflows/loop-eval.d.ts +1 -0
- package/dist/workflows/loop-eval.js +2 -0
- package/dist/workflows/loop-eval.js.map +1 -0
- package/dist/workflows/phase-executor.d.ts +1 -0
- package/dist/workflows/phase-executor.js +6 -0
- package/dist/workflows/phase-executor.js.map +1 -0
- package/dist/workflows/phase-ref.d.ts +1 -0
- package/dist/workflows/phase-ref.js +2 -0
- package/dist/workflows/phase-ref.js.map +1 -0
- package/dist/workflows/resume.d.ts +58 -0
- package/dist/workflows/resume.js +313 -0
- package/dist/workflows/resume.js.map +1 -0
- package/dist/workflows/runner.d.ts +47 -0
- package/dist/workflows/runner.js +278 -0
- package/dist/workflows/runner.js.map +1 -0
- package/dist/workflows/schema.d.ts +1 -0
- package/dist/workflows/schema.js +2 -0
- package/dist/workflows/schema.js.map +1 -0
- package/dist/workflows/simple.d.ts +90 -0
- package/dist/workflows/simple.js +393 -0
- package/dist/workflows/simple.js.map +1 -0
- package/dist/workflows/target-policy.d.ts +74 -0
- package/dist/workflows/target-policy.js +80 -0
- package/dist/workflows/target-policy.js.map +1 -0
- package/dist/workflows/templates.d.ts +1 -0
- package/dist/workflows/templates.js +2 -0
- package/dist/workflows/templates.js.map +1 -0
- package/dist/workflows/triggers.d.ts +21 -0
- package/dist/workflows/triggers.js +45 -0
- package/dist/workflows/triggers.js.map +1 -0
- package/dist/workflows/verdict.d.ts +1 -0
- package/dist/workflows/verdict.js +2 -0
- package/dist/workflows/verdict.js.map +1 -0
- package/dist/worktree/manager.d.ts +43 -0
- package/dist/worktree/manager.js +127 -0
- package/dist/worktree/manager.js.map +1 -0
- package/docker-compose.yml +280 -0
- package/package.json +93 -0
- package/sandbox.Dockerfile +68 -0
- package/skills/README.md +42 -0
- package/skills/browser-qa/SKILL.md +208 -0
- package/skills/browser-qa/scripts/agent-browser.mjs +531 -0
- package/skills/building/SKILL.md +95 -0
- package/skills/chat/SKILL.md +36 -0
- package/skills/code-review/SKILL.md +82 -0
- package/skills/debug-production/SKILL.md +108 -0
- package/skills/demo/SKILL.md +228 -0
- package/skills/demo/scripts/compose-demo.sh +243 -0
- package/skills/issue-answer/SKILL.md +91 -0
- package/skills/issue-comment/SKILL.md +49 -0
- package/skills/issue-triage/SKILL.md +149 -0
- package/skills/issue-triage/references/AGENT-BRIEF.md +65 -0
- package/skills/pr-comment/SKILL.md +64 -0
- package/skills/pr-review/SKILL.md +148 -0
- package/skills/pr-review/references/findings-schema.md +89 -0
- package/skills/qa-test/SKILL.md +97 -0
- package/skills/repo-health/SKILL.md +67 -0
- package/skills/security-feedback/SKILL.md +173 -0
- package/skills/security-feedback/references/templates.md +77 -0
- package/skills/security-review/SKILL.md +215 -0
- package/skills/security-review/references/issue-format.md +302 -0
- package/skills/verify/SKILL.md +118 -0
- package/workflows/answer.yaml +44 -0
- package/workflows/build.yaml +129 -0
- package/workflows/cron-health.yaml +6 -0
- package/workflows/cron-review.yaml +8 -0
- package/workflows/cron-security.yaml +6 -0
- package/workflows/cron-triage.yaml +8 -0
- package/workflows/demo.yaml +62 -0
- package/workflows/examples/bash-smoke.yaml +41 -0
- package/workflows/examples/parallel-review.yaml +36 -0
- package/workflows/examples/tdd-loop.yaml +17 -0
- package/workflows/explore.yaml +80 -0
- package/workflows/issue-comment.yaml +15 -0
- package/workflows/issue-triage.yaml +22 -0
- package/workflows/pr-comment.yaml +16 -0
- package/workflows/pr-fix.yaml +17 -0
- package/workflows/pr-review.yaml +50 -0
- package/workflows/prompts/answer.md +68 -0
- package/workflows/prompts/architect.md +44 -0
- package/workflows/prompts/classifier.md +60 -0
- package/workflows/prompts/classify-adds-info.md +17 -0
- package/workflows/prompts/demo.md +125 -0
- package/workflows/prompts/executor.md +42 -0
- package/workflows/prompts/explore-ask.md +99 -0
- package/workflows/prompts/explore-publish.md +31 -0
- package/workflows/prompts/explore-read.md +120 -0
- package/workflows/prompts/explore-synthesize.md +88 -0
- package/workflows/prompts/fix.md +18 -0
- package/workflows/prompts/guardrails.md +96 -0
- package/workflows/prompts/pr-fix.md +26 -0
- package/workflows/prompts/pr.md +39 -0
- package/workflows/prompts/qa-browser.md +95 -0
- package/workflows/prompts/qa-synth.md +44 -0
- package/workflows/prompts/qa-test.md +60 -0
- package/workflows/prompts/re-reviewer.md +33 -0
- package/workflows/prompts/reviewer.md +60 -0
- package/workflows/prompts/verify-browser.md +93 -0
- package/workflows/prompts/verify-synth.md +44 -0
- package/workflows/prompts/verify.md +63 -0
- package/workflows/qa-test.yaml +94 -0
- package/workflows/repo-health.yaml +15 -0
- package/workflows/security-feedback.yaml +25 -0
- package/workflows/security-review.yaml +37 -0
- package/workflows/verify.yaml +93 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { githubAppClient, githubTokenClient, } from "./github-app-client.js";
|
|
2
|
+
/**
|
|
3
|
+
* GitHub client for the harness — uses GitHub App auth.
|
|
4
|
+
* Used by the orchestrator to post comments, not by agent sessions.
|
|
5
|
+
*/
|
|
6
|
+
export class GitHubClient {
|
|
7
|
+
octokit;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.octokit = githubAppClient(config);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Build a client authed with a raw bearer token (a pre-minted installation
|
|
13
|
+
* token) instead of App JWT auth. Used by the harness-side `post-review`
|
|
14
|
+
* action: prod passes the run's scoped review-write token; evals pass the
|
|
15
|
+
* mock's token + `baseUrl`. Avoids the App installation-token minting
|
|
16
|
+
* round-trip (which hard-codes api.github.com and the evals mock doesn't
|
|
17
|
+
* serve).
|
|
18
|
+
*/
|
|
19
|
+
static withToken(token, baseUrl) {
|
|
20
|
+
const client = Object.create(GitHubClient.prototype);
|
|
21
|
+
client.octokit = githubTokenClient(token, baseUrl);
|
|
22
|
+
return client;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create a new comment on an issue/PR. Returns the new comment id so callers
|
|
26
|
+
* that want to edit it later (the in-place status checklist — see
|
|
27
|
+
* `src/notify/transports/github.ts`) can hold onto a handle. Callers that
|
|
28
|
+
* just post a one-off comment can ignore the return.
|
|
29
|
+
*/
|
|
30
|
+
async postComment(owner, repo, issueNumber, body) {
|
|
31
|
+
const { data } = await this.octokit.rest.issues.createComment({
|
|
32
|
+
owner,
|
|
33
|
+
repo,
|
|
34
|
+
issue_number: issueNumber,
|
|
35
|
+
body,
|
|
36
|
+
});
|
|
37
|
+
return data.id;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* List every repository the App installation can access, as `owner/repo`
|
|
41
|
+
* full names. Used at boot to seed the managed-repo list from the App grant
|
|
42
|
+
* (see src/managed-repos.ts). The installation id is bound by the App auth
|
|
43
|
+
* strategy, so no argument is needed. Paginated — handles installs with
|
|
44
|
+
* hundreds of repos.
|
|
45
|
+
*/
|
|
46
|
+
async listInstallationRepos() {
|
|
47
|
+
const repos = await this.octokit.paginate(this.octokit.rest.apps.listReposAccessibleToInstallation, { per_page: 100 });
|
|
48
|
+
return repos.map((r) => r.full_name);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Edit an existing issue/PR comment in place. Paired with `postComment` to
|
|
52
|
+
* maintain a single status comment that updates as a workflow progresses,
|
|
53
|
+
* rather than posting a new comment per phase. GitHub does NOT notify
|
|
54
|
+
* watchers on edits, which is exactly why this keeps the thread quiet.
|
|
55
|
+
*/
|
|
56
|
+
async updateComment(owner, repo, commentId, body) {
|
|
57
|
+
await this.octokit.rest.issues.updateComment({
|
|
58
|
+
owner,
|
|
59
|
+
repo,
|
|
60
|
+
comment_id: commentId,
|
|
61
|
+
body,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Add an emoji reaction to a specific issue comment. Used as an immediate
|
|
66
|
+
* (silent) acknowledgment that the agent has accepted a request, before
|
|
67
|
+
* any actual work — and any chatty bot comments — start.
|
|
68
|
+
*
|
|
69
|
+
* Reaction `content` values: "+1" | "-1" | "laugh" | "confused" | "heart"
|
|
70
|
+
* | "hooray" | "rocket" | "eyes".
|
|
71
|
+
*/
|
|
72
|
+
async reactToComment(owner, repo, commentId, content = "rocket") {
|
|
73
|
+
await this.octokit.rest.reactions.createForIssueComment({
|
|
74
|
+
owner,
|
|
75
|
+
repo,
|
|
76
|
+
comment_id: commentId,
|
|
77
|
+
content,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Add an emoji reaction to an issue or PR itself (not a comment) — used to
|
|
82
|
+
* ack events that aren't comments, e.g. a freshly opened issue/PR. PRs are
|
|
83
|
+
* issues for the reactions API, so this works for both.
|
|
84
|
+
*/
|
|
85
|
+
async reactToIssue(owner, repo, issueNumber, content = "eyes") {
|
|
86
|
+
await this.octokit.rest.reactions.createForIssue({
|
|
87
|
+
owner,
|
|
88
|
+
repo,
|
|
89
|
+
issue_number: issueNumber,
|
|
90
|
+
content,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Add an emoji reaction to a pull-request review comment (inline diff
|
|
95
|
+
* comment). Distinct endpoint from issue comments — review comments live on
|
|
96
|
+
* the pulls API.
|
|
97
|
+
*/
|
|
98
|
+
async reactToReviewComment(owner, repo, commentId, content = "eyes") {
|
|
99
|
+
await this.octokit.rest.reactions.createForPullRequestReviewComment({
|
|
100
|
+
owner,
|
|
101
|
+
repo,
|
|
102
|
+
comment_id: commentId,
|
|
103
|
+
content,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async getIssue(owner, repo, issueNumber) {
|
|
107
|
+
const { data } = await this.octokit.rest.issues.get({
|
|
108
|
+
owner,
|
|
109
|
+
repo,
|
|
110
|
+
issue_number: issueNumber,
|
|
111
|
+
});
|
|
112
|
+
return data;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Fetch the issue body. Used by the dispatch path so build/explore/pr-fix
|
|
116
|
+
* workflows always see the real issue body, even when triggered from a
|
|
117
|
+
* comment (where the EventEnvelope.body field is the comment, not the
|
|
118
|
+
* issue body).
|
|
119
|
+
*/
|
|
120
|
+
async getIssueBody(owner, repo, issueNumber) {
|
|
121
|
+
const { data } = await this.octokit.rest.issues.get({
|
|
122
|
+
owner,
|
|
123
|
+
repo,
|
|
124
|
+
issue_number: issueNumber,
|
|
125
|
+
});
|
|
126
|
+
return data.body || "";
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* List all comments on an issue/PR, oldest first. Used by the dispatch path
|
|
130
|
+
* to inject the full conversation thread into the architect's context — the
|
|
131
|
+
* spec the bot writes during an `explore` run lives here, and the build
|
|
132
|
+
* cycle needs to see it to implement the agreed design.
|
|
133
|
+
*/
|
|
134
|
+
async listIssueComments(owner, repo, issueNumber) {
|
|
135
|
+
const data = await this.octokit.paginate(this.octokit.rest.issues.listComments, { owner, repo, issue_number: issueNumber, per_page: 100 });
|
|
136
|
+
return data.map((c) => ({
|
|
137
|
+
user: c.user?.login || "unknown",
|
|
138
|
+
body: c.body || "",
|
|
139
|
+
createdAt: c.created_at,
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
async getPullRequest(owner, repo, pullNumber) {
|
|
143
|
+
const { data } = await this.octokit.rest.pulls.get({
|
|
144
|
+
owner,
|
|
145
|
+
repo,
|
|
146
|
+
pull_number: pullNumber,
|
|
147
|
+
});
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The repo's default branch (e.g. `main`, `master`, `develop`). Used to
|
|
152
|
+
* scope build runs to the real base branch instead of assuming `main` — a
|
|
153
|
+
* `master`-default repo otherwise breaks every `git ... main..HEAD` the
|
|
154
|
+
* reviewer runs. See the `baseBranch` plumbing in src/index.ts.
|
|
155
|
+
*/
|
|
156
|
+
async getDefaultBranch(owner, repo) {
|
|
157
|
+
const { data } = await this.octokit.rest.repos.get({ owner, repo });
|
|
158
|
+
return data.default_branch;
|
|
159
|
+
}
|
|
160
|
+
/** Convenience: fetch only the PR's head commit SHA. Used by check-run code. */
|
|
161
|
+
async getPullRequestHeadSha(owner, repo, pullNumber) {
|
|
162
|
+
const { data } = await this.octokit.rest.pulls.get({
|
|
163
|
+
owner,
|
|
164
|
+
repo,
|
|
165
|
+
pull_number: pullNumber,
|
|
166
|
+
});
|
|
167
|
+
return data.head.sha;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Create a Check Run on a PR's head commit. Returns the new check_run id so
|
|
171
|
+
* the caller can later transition it from `in_progress` → `completed` with
|
|
172
|
+
* a conclusion. Repos that enable "Require status checks to pass" with
|
|
173
|
+
* `name` in their list will gate merges on the eventual conclusion.
|
|
174
|
+
*
|
|
175
|
+
* Requires the GitHub App to have `Checks: Read and write` permission.
|
|
176
|
+
*/
|
|
177
|
+
async createCheckRun(owner, repo, headSha, name, options = {}) {
|
|
178
|
+
const { data } = await this.octokit.rest.checks.create({
|
|
179
|
+
owner,
|
|
180
|
+
repo,
|
|
181
|
+
name,
|
|
182
|
+
head_sha: headSha,
|
|
183
|
+
status: "in_progress",
|
|
184
|
+
started_at: new Date().toISOString(),
|
|
185
|
+
...(options.detailsUrl ? { details_url: options.detailsUrl } : {}),
|
|
186
|
+
...(options.output ? { output: options.output } : {}),
|
|
187
|
+
});
|
|
188
|
+
return data.id;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Update an existing Check Run — typically to transition `in_progress` →
|
|
192
|
+
* `completed` with a conclusion. Conclusion values that branch protection
|
|
193
|
+
* treats as passing: `success`, `neutral`, `skipped`. Failing: `failure`,
|
|
194
|
+
* `cancelled`, `timed_out`, `action_required`.
|
|
195
|
+
*/
|
|
196
|
+
async updateCheckRun(owner, repo, checkRunId, update) {
|
|
197
|
+
await this.octokit.rest.checks.update({
|
|
198
|
+
owner,
|
|
199
|
+
repo,
|
|
200
|
+
check_run_id: checkRunId,
|
|
201
|
+
...(update.status ? { status: update.status } : {}),
|
|
202
|
+
...(update.conclusion ? { conclusion: update.conclusion } : {}),
|
|
203
|
+
...(update.status === "completed" ? { completed_at: new Date().toISOString() } : {}),
|
|
204
|
+
...(update.detailsUrl ? { details_url: update.detailsUrl } : {}),
|
|
205
|
+
...(update.output ? { output: update.output } : {}),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Find the bot's most recent review on this PR's current head commit. Used
|
|
210
|
+
* after a pr-review workflow finishes to derive the check-run conclusion
|
|
211
|
+
* from the review the agent actually posted (APPROVE / REQUEST_CHANGES /
|
|
212
|
+
* COMMENT). Returns null when the bot hasn't reviewed this SHA yet.
|
|
213
|
+
*
|
|
214
|
+
* `botLogin` defaults to `last-light[bot]` so the lookup matches App-auth'd
|
|
215
|
+
* reviews regardless of how the agent identified itself.
|
|
216
|
+
*/
|
|
217
|
+
async getLatestBotReview(owner, repo, pullNumber, headSha, botLogin = "last-light[bot]") {
|
|
218
|
+
const reviews = await this.octokit.paginate(this.octokit.rest.pulls.listReviews, {
|
|
219
|
+
owner,
|
|
220
|
+
repo,
|
|
221
|
+
pull_number: pullNumber,
|
|
222
|
+
per_page: 100,
|
|
223
|
+
});
|
|
224
|
+
// Reviews are returned oldest-first; iterate newest-first to pick the most
|
|
225
|
+
// recent one tied to this SHA. `commit_id` on a review is the head sha at
|
|
226
|
+
// the time the review was submitted, which is exactly the discriminator
|
|
227
|
+
// we want — re-pushes invalidate stale reviews here naturally.
|
|
228
|
+
for (let i = reviews.length - 1; i >= 0; i--) {
|
|
229
|
+
const r = reviews[i];
|
|
230
|
+
if (r.user?.login === botLogin && r.commit_id === headSha) {
|
|
231
|
+
return { state: r.state, body: r.body ?? null, submittedAt: r.submitted_at ?? null };
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Fetch a PR's unified diff (three-dot, base…head) as a string. Used by the
|
|
238
|
+
* `post-review` action to anchor findings to changed lines — the harness runs
|
|
239
|
+
* this in-process (not in the sandbox), so the diff comes from the API rather
|
|
240
|
+
* than a local `git diff`, with no dependency on checkout/fetch state.
|
|
241
|
+
*/
|
|
242
|
+
async getPullRequestDiff(owner, repo, pullNumber) {
|
|
243
|
+
const res = await this.octokit.rest.pulls.get({
|
|
244
|
+
owner,
|
|
245
|
+
repo,
|
|
246
|
+
pull_number: pullNumber,
|
|
247
|
+
mediaType: { format: "diff" },
|
|
248
|
+
});
|
|
249
|
+
// With `format: diff` Octokit returns the raw diff as the response body,
|
|
250
|
+
// typed as the JSON shape — cast through unknown.
|
|
251
|
+
return res.data;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Submit one formal PR review with an event (APPROVE / REQUEST_CHANGES /
|
|
255
|
+
* COMMENT) plus optional line-anchored inline comments. `commitId` pins the
|
|
256
|
+
* review to the reviewed head SHA. This is the single harness-side write for
|
|
257
|
+
* PR reviews — the reviewer agent never submits; it writes findings and the
|
|
258
|
+
* `post-review` action calls this. Throws on a non-2xx so the action can fail
|
|
259
|
+
* the phase visibly (or retry body-only).
|
|
260
|
+
*/
|
|
261
|
+
async createPullRequestReview(owner, repo, pullNumber, review) {
|
|
262
|
+
await this.octokit.rest.pulls.createReview({
|
|
263
|
+
owner,
|
|
264
|
+
repo,
|
|
265
|
+
pull_number: pullNumber,
|
|
266
|
+
body: review.body,
|
|
267
|
+
event: review.event,
|
|
268
|
+
...(review.comments && review.comments.length ? { comments: review.comments } : {}),
|
|
269
|
+
...(review.commitId ? { commit_id: review.commitId } : {}),
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Get failed check runs for a PR's head SHA.
|
|
274
|
+
* Fetches the actual job logs (not just annotations) to show real errors.
|
|
275
|
+
*/
|
|
276
|
+
async getFailedChecks(owner, repo, ref) {
|
|
277
|
+
try {
|
|
278
|
+
const { data } = await this.octokit.rest.checks.listForRef({
|
|
279
|
+
owner,
|
|
280
|
+
repo,
|
|
281
|
+
ref,
|
|
282
|
+
filter: "latest",
|
|
283
|
+
});
|
|
284
|
+
const failed = data.check_runs.filter((r) => r.conclusion === "failure" || r.conclusion === "timed_out");
|
|
285
|
+
if (failed.length === 0)
|
|
286
|
+
return "No failed checks found.";
|
|
287
|
+
const summaries = await Promise.all(failed.map(async (run) => {
|
|
288
|
+
let logExcerpt = "";
|
|
289
|
+
// Try to fetch the actual job log (contains the real errors)
|
|
290
|
+
if (run.details_url) {
|
|
291
|
+
try {
|
|
292
|
+
// Extract the job ID from the check run — the run is linked to a workflow job
|
|
293
|
+
const jobId = run.id;
|
|
294
|
+
const { data: logData } = await this.octokit.rest.actions.downloadJobLogsForWorkflowRun({
|
|
295
|
+
owner,
|
|
296
|
+
repo,
|
|
297
|
+
job_id: jobId,
|
|
298
|
+
});
|
|
299
|
+
// logData is a string with the full log
|
|
300
|
+
const fullLog = typeof logData === "string" ? logData : String(logData);
|
|
301
|
+
// Extract the last N lines which typically contain the error
|
|
302
|
+
const lines = fullLog.split("\n");
|
|
303
|
+
// Find error lines and surrounding context
|
|
304
|
+
const errorLines = [];
|
|
305
|
+
for (let i = 0; i < lines.length; i++) {
|
|
306
|
+
const line = lines[i];
|
|
307
|
+
if (line.match(/error|ERR!|FAIL|failed|Error:|npm ERR/i) && !line.match(/^$/)) {
|
|
308
|
+
// Include some context before and after
|
|
309
|
+
const start = Math.max(0, i - 2);
|
|
310
|
+
const end = Math.min(lines.length, i + 5);
|
|
311
|
+
for (let j = start; j < end; j++) {
|
|
312
|
+
if (!errorLines.includes(lines[j])) {
|
|
313
|
+
errorLines.push(lines[j]);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (errorLines.length > 0) {
|
|
319
|
+
logExcerpt = errorLines.slice(0, 50).join("\n");
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
// No error lines found — show the last 30 lines
|
|
323
|
+
logExcerpt = lines.slice(-30).join("\n");
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
// Job logs may not be available — fall back to annotations
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
// Fall back to annotations if no job logs
|
|
331
|
+
if (!logExcerpt) {
|
|
332
|
+
try {
|
|
333
|
+
const { data: annotations } = await this.octokit.rest.checks.listAnnotations({
|
|
334
|
+
owner,
|
|
335
|
+
repo,
|
|
336
|
+
check_run_id: run.id,
|
|
337
|
+
});
|
|
338
|
+
if (annotations.length > 0) {
|
|
339
|
+
logExcerpt = annotations
|
|
340
|
+
.filter((a) => a.annotation_level === "failure")
|
|
341
|
+
.slice(0, 10)
|
|
342
|
+
.map((a) => `${a.path}:${a.start_line} — ${a.message}`)
|
|
343
|
+
.join("\n");
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
catch { /* annotations may not be available */ }
|
|
347
|
+
}
|
|
348
|
+
return `### ${run.name}: ${run.conclusion}\n${logExcerpt || "No log details available."}`;
|
|
349
|
+
}));
|
|
350
|
+
return summaries.join("\n\n");
|
|
351
|
+
}
|
|
352
|
+
catch (err) {
|
|
353
|
+
return `Could not fetch check runs: ${err.message}`;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRo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{ GitAccessProfile } from "lastlight-workflow-engine";
|
|
3
|
+
export type { ExecutorConfig, ExecutionResult, ExtensionStatus, ExtensionStatusMap, SkillSummary, SkillsStatus, GitAccessProfile, GitSandboxAccess, } from "lastlight-workflow-engine";
|
|
4
|
+
/**
|
|
5
|
+
* agentic-pi's GitHub extension uses the same four profile names — they
|
|
6
|
+
* pass through unchanged. Kept as an explicit map so renames on either
|
|
7
|
+
* side surface as a type error rather than a silent runtime mismatch.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AGENTIC_PROFILE_FOR: Record<GitAccessProfile, string>;
|
|
10
|
+
export declare const GITHUB_PERMISSION_PROFILES: Record<GitAccessProfile, GitHubTokenPermissions>;
|
|
11
|
+
export declare function loadAgentContext(_dir?: string): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { loadAgentContext as loadResolvedAgentContext } from "../../workflows/loader.js";
|
|
2
|
+
/**
|
|
3
|
+
* agentic-pi's GitHub extension uses the same four profile names — they
|
|
4
|
+
* pass through unchanged. Kept as an explicit map so renames on either
|
|
5
|
+
* side surface as a type error rather than a silent runtime mismatch.
|
|
6
|
+
*/
|
|
7
|
+
export const AGENTIC_PROFILE_FOR = {
|
|
8
|
+
read: "read",
|
|
9
|
+
"issues-write": "issues-write",
|
|
10
|
+
"review-write": "review-write",
|
|
11
|
+
"repo-write": "repo-write",
|
|
12
|
+
};
|
|
13
|
+
export const GITHUB_PERMISSION_PROFILES = {
|
|
14
|
+
read: {
|
|
15
|
+
contents: "read",
|
|
16
|
+
issues: "read",
|
|
17
|
+
pull_requests: "read",
|
|
18
|
+
metadata: "read",
|
|
19
|
+
},
|
|
20
|
+
"issues-write": {
|
|
21
|
+
contents: "read",
|
|
22
|
+
issues: "write",
|
|
23
|
+
pull_requests: "read",
|
|
24
|
+
metadata: "read",
|
|
25
|
+
},
|
|
26
|
+
"review-write": {
|
|
27
|
+
contents: "read",
|
|
28
|
+
issues: "write",
|
|
29
|
+
pull_requests: "write",
|
|
30
|
+
metadata: "read",
|
|
31
|
+
},
|
|
32
|
+
"repo-write": {
|
|
33
|
+
contents: "write",
|
|
34
|
+
issues: "write",
|
|
35
|
+
pull_requests: "write",
|
|
36
|
+
metadata: "read",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
export function loadAgentContext(_dir) {
|
|
40
|
+
return loadResolvedAgentContext();
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../../src/engine/github/profiles.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,IAAI,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAkBzF;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAqC;IACnE,IAAI,EAAE,MAAM;IACZ,cAAc,EAAE,cAAc;IAC9B,cAAc,EAAE,cAAc;IAC9B,YAAY,EAAE,YAAY;CAC3B,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAqD;IAC1F,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,MAAM;QACd,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,MAAM;KACjB;IACD,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,OAAO;QACf,aAAa,EAAE,MAAM;QACrB,QAAQ,EAAE,MAAM;KACjB;IACD,cAAc,EAAE;QACd,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,OAAO;QACf,aAAa,EAAE,OAAO;QACtB,QAAQ,EAAE,MAAM;KACjB;IACD,YAAY,EAAE;QACZ,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,OAAO;QACf,aAAa,EAAE,OAAO;QACtB,QAAQ,EAAE,MAAM;KACjB;CACF,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,IAAa;IAC5C,OAAO,wBAAwB,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure PR-review composition: turn a set of structured findings + the PR diff
|
|
3
|
+
* into the payload for one formal GitHub review (`POST /pulls/{n}/reviews`).
|
|
4
|
+
*
|
|
5
|
+
* This is the tested core of the first-class `post-review` action
|
|
6
|
+
* (`PhaseExecutor.runPostReview`). It replaces the ~150-line JS blob that used
|
|
7
|
+
* to live inline in `workflows/pr-review.yaml` — that script depended on the AI
|
|
8
|
+
* agent hand-writing `pr_number`/`base_ref`/`head_sha` into the findings file
|
|
9
|
+
* and silently `exit 0`'d on any mismatch. Here the harness owns all of that:
|
|
10
|
+
* the agent supplies only *content* (`summary`, `event`, `findings`), and this
|
|
11
|
+
* module anchors each finding to the diff, demoting anything off-diff to the
|
|
12
|
+
* body (GitHub 422s on comments that don't sit on a changed line).
|
|
13
|
+
*
|
|
14
|
+
* No I/O — every function is a pure transform, so the anchoring rules are
|
|
15
|
+
* exercised directly in `review-poster.test.ts` rather than by eval-extracting
|
|
16
|
+
* a function out of a YAML string.
|
|
17
|
+
*/
|
|
18
|
+
export type ReviewEvent = "APPROVE" | "REQUEST_CHANGES" | "COMMENT";
|
|
19
|
+
export type ReviewSide = "LEFT" | "RIGHT";
|
|
20
|
+
/** One finding as written by the `pr-review` skill into findings.json. */
|
|
21
|
+
export interface ReviewFinding {
|
|
22
|
+
path: string;
|
|
23
|
+
line: number;
|
|
24
|
+
side?: ReviewSide;
|
|
25
|
+
start_line?: number;
|
|
26
|
+
severity?: string;
|
|
27
|
+
title?: string;
|
|
28
|
+
body?: string;
|
|
29
|
+
suggestion?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The findings document the agent writes. `pr_number` / `base_ref` /
|
|
33
|
+
* `head_sha` are intentionally NOT here — the harness knows them from its own
|
|
34
|
+
* run context and the PR object, so the agent never hand-copies metadata.
|
|
35
|
+
*/
|
|
36
|
+
export interface ReviewFindingsDoc {
|
|
37
|
+
skip?: boolean;
|
|
38
|
+
summary?: string;
|
|
39
|
+
event?: ReviewEvent;
|
|
40
|
+
findings?: ReviewFinding[];
|
|
41
|
+
}
|
|
42
|
+
/** An inline review comment in the shape GitHub's create-review API expects. */
|
|
43
|
+
export interface InlineComment {
|
|
44
|
+
path: string;
|
|
45
|
+
line: number;
|
|
46
|
+
side: ReviewSide;
|
|
47
|
+
body: string;
|
|
48
|
+
start_line?: number;
|
|
49
|
+
start_side?: ReviewSide;
|
|
50
|
+
}
|
|
51
|
+
/** Everything needed to POST one review, ready for `createPullRequestReview`. */
|
|
52
|
+
export interface BuiltReview {
|
|
53
|
+
event: ReviewEvent;
|
|
54
|
+
body: string;
|
|
55
|
+
comments: InlineComment[];
|
|
56
|
+
inlineCount: number;
|
|
57
|
+
demotedCount: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Map a unified diff to `path -> Set<"SIDE:line">`. Added/`+` and context lines
|
|
61
|
+
* are `RIGHT:<newLine>`; removed/`-` and context lines are `LEFT:<oldLine>` —
|
|
62
|
+
* mirroring GitHub's three-dot PR diff anchoring. A finding may be commented
|
|
63
|
+
* inline only when its `side:line` appears in this set.
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseDiff(diff: string): Map<string, Set<string>>;
|
|
66
|
+
/** True when a finding anchors onto a line that appears in the diff. */
|
|
67
|
+
export declare function isAnchored(f: ReviewFinding, commentable: Map<string, Set<string>> | null): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Partition findings into `inline` (anchor is on the diff) and `demoted`
|
|
70
|
+
* (off-diff, or missing path/line — folded into the body). When `commentable`
|
|
71
|
+
* is null (the diff couldn't be computed) every finding is demoted, so the
|
|
72
|
+
* review still posts and nothing is lost.
|
|
73
|
+
*/
|
|
74
|
+
export declare function splitFindings(findings: ReviewFinding[], commentable: Map<string, Set<string>> | null): {
|
|
75
|
+
inline: ReviewFinding[];
|
|
76
|
+
demoted: ReviewFinding[];
|
|
77
|
+
};
|
|
78
|
+
/** The "Additional findings" section appended to the body for demoted findings. */
|
|
79
|
+
export declare function renderDemoted(list: ReviewFinding[]): string;
|
|
80
|
+
/** Build the inline-comment objects GitHub's create-review API expects. */
|
|
81
|
+
export declare function toInlineComments(list: ReviewFinding[]): InlineComment[];
|
|
82
|
+
/**
|
|
83
|
+
* Resolve the review event. An explicit `doc.event` wins; otherwise an empty
|
|
84
|
+
* findings set is an `APPROVE` and anything else is a `COMMENT` (never an
|
|
85
|
+
* automatic `REQUEST_CHANGES` — that stays an explicit, deliberate call).
|
|
86
|
+
*/
|
|
87
|
+
export declare function resolveEvent(doc: ReviewFindingsDoc): ReviewEvent;
|
|
88
|
+
/**
|
|
89
|
+
* Compose the full review payload. Pass `commentable = null` to force every
|
|
90
|
+
* finding into the body (the diff-unavailable fallback).
|
|
91
|
+
*/
|
|
92
|
+
export declare function buildReview(doc: ReviewFindingsDoc, commentable: Map<string, Set<string>> | null): BuiltReview;
|
|
93
|
+
/**
|
|
94
|
+
* The body-only fallback: when the inline POST is rejected (e.g. a stale diff
|
|
95
|
+
* yields a 422 on a comment line), re-render with ALL findings in the body so
|
|
96
|
+
* the review still lands. Same event as the inline attempt.
|
|
97
|
+
*/
|
|
98
|
+
export declare function buildBodyOnlyReview(doc: ReviewFindingsDoc): BuiltReview;
|