neondeck 1.0.0-beta.4
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/CHANGELOG.md +22 -0
- package/DEVELOPMENT.md +310 -0
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/SOUL.md +8 -0
- package/bin/neondeck.mjs +27 -0
- package/config/dashboard.json +208 -0
- package/config/dashboard.schema.json +207 -0
- package/dist/SOUL.md +8 -0
- package/dist/assets/app-BuuvLo98.js +3620 -0
- package/dist/assets/app-BuuvLo98.js.map +1 -0
- package/dist/assets/autopilot-CKgEx8yQ.js +68025 -0
- package/dist/assets/autopilot-CKgEx8yQ.js.map +1 -0
- package/dist/assets/briefing-DYVbJaqk.js +2 -0
- package/dist/assets/briefing-DoO-fJr1.js +22 -0
- package/dist/assets/briefing-DoO-fJr1.js.map +1 -0
- package/dist/assets/command-run-B2TWLpLL.js +20 -0
- package/dist/assets/command-run-B2TWLpLL.js.map +1 -0
- package/dist/assets/command-run-CzQra_Y7.js +2 -0
- package/dist/assets/display-assistant-CbCRBSYM.js +389 -0
- package/dist/assets/display-assistant-CbCRBSYM.js.map +1 -0
- package/dist/assets/fix-pr-ci-BlUl-2ht.js +46 -0
- package/dist/assets/fix-pr-ci-BlUl-2ht.js.map +1 -0
- package/dist/assets/fix-pr-ci-Dl1wpKXp.js +2 -0
- package/dist/assets/migrations/20260710061339_neondeck_pre_1_0_baseline/migration.sql +748 -0
- package/dist/assets/migrations/20260710061339_neondeck_pre_1_0_baseline/snapshot.json +7240 -0
- package/dist/assets/prepare-pr-worktree-CLzccRYh.js +2 -0
- package/dist/assets/prepare-pr-worktree-DxyTygiU.js +17 -0
- package/dist/assets/prepare-pr-worktree-DxyTygiU.js.map +1 -0
- package/dist/assets/push-pr-autofix-BFNSEASU.js +2 -0
- package/dist/assets/push-pr-autofix-DlVjw1IN.js +17 -0
- package/dist/assets/push-pr-autofix-DlVjw1IN.js.map +1 -0
- package/dist/assets/review-pr-for-human-B2j8wz2L.js +2 -0
- package/dist/assets/review-pr-for-human-DcGE-7wb.js +708 -0
- package/dist/assets/review-pr-for-human-DcGE-7wb.js.map +1 -0
- package/dist/assets/safety-CawD9GxD.js +2499 -0
- package/dist/assets/safety-CawD9GxD.js.map +1 -0
- package/dist/assets/scheduled-agent-instruction-CQgogBv3.js +22 -0
- package/dist/assets/scheduled-agent-instruction-CQgogBv3.js.map +1 -0
- package/dist/assets/scheduled-agent-instruction-Dr2ebZRD.js +2 -0
- package/dist/assets/scheduler-tick-Cy26qBld.js +105 -0
- package/dist/assets/scheduler-tick-Cy26qBld.js.map +1 -0
- package/dist/assets/skills/github-gh/SKILL.md +56 -0
- package/dist/assets/skills/neon-ci-fix/SKILL.md +15 -0
- package/dist/assets/skills/neon-docs-fix/SKILL.md +15 -0
- package/dist/assets/skills/neon-issue-triage/SKILL.md +13 -0
- package/dist/assets/skills/neon-pr-review/SKILL.md +19 -0
- package/dist/assets/skills/neondeck/SKILL.md +123 -0
- package/dist/assets/skills/neondeck-handoff/SKILL.md +31 -0
- package/dist/assets/triage-pr-event-BlE3GKNR.js +17 -0
- package/dist/assets/triage-pr-event-BlE3GKNR.js.map +1 -0
- package/dist/assets/triage-pr-event-hxUP587F.js +2 -0
- package/dist/assets/verify-then-push-pr-autofix-CIl5ZwZm.js +2 -0
- package/dist/assets/verify-then-push-pr-autofix-Djy0UFUv.js +75 -0
- package/dist/assets/verify-then-push-pr-autofix-Djy0UFUv.js.map +1 -0
- package/dist/config/dashboard.json +208 -0
- package/dist/config/dashboard.schema.json +207 -0
- package/dist/server.mjs +582 -0
- package/dist/server.mjs.map +1 -0
- package/dist/skills/github-gh/SKILL.md +56 -0
- package/dist/skills/neon-ci-fix/SKILL.md +15 -0
- package/dist/skills/neon-docs-fix/SKILL.md +15 -0
- package/dist/skills/neon-issue-triage/SKILL.md +13 -0
- package/dist/skills/neon-pr-review/SKILL.md +19 -0
- package/dist/skills/neondeck/SKILL.md +123 -0
- package/dist/skills/neondeck-handoff/SKILL.md +31 -0
- package/drizzle.config.ts +7 -0
- package/package.json +155 -0
- package/shared/patch-anchors.ts +78 -0
- package/src/agents/busywork-workflow.ts +24 -0
- package/src/agents/display-assistant.ts +134 -0
- package/src/agents/pr-review-assistant.ts +25 -0
- package/src/agents/scheduler-workflow.ts +20 -0
- package/src/agents/support/tools.ts +346 -0
- package/src/app.ts +1 -0
- package/src/cli/index.ts +560 -0
- package/src/cli/learning.ts +44 -0
- package/src/cli/mcp.ts +496 -0
- package/src/cli/modules.ts +107 -0
- package/src/cli/onboarding.ts +667 -0
- package/src/cli/options.ts +103 -0
- package/src/cli/output.ts +399 -0
- package/src/cli/preapprovals.ts +204 -0
- package/src/cli/prompts.ts +108 -0
- package/src/cli/types.ts +59 -0
- package/src/db.ts +41 -0
- package/src/desktop/open.ts +698 -0
- package/src/desktop/service.ts +863 -0
- package/src/domains/mcp/actions.ts +420 -0
- package/src/domains/mcp/config.ts +501 -0
- package/src/domains/mcp/format.ts +35 -0
- package/src/domains/mcp/gate.ts +188 -0
- package/src/domains/mcp/index.ts +9 -0
- package/src/domains/mcp/instructions.ts +18 -0
- package/src/domains/mcp/oauth.ts +1063 -0
- package/src/domains/mcp/policy.ts +15 -0
- package/src/domains/mcp/registry.ts +461 -0
- package/src/domains/mcp/schemas.ts +171 -0
- package/src/domains/mcp/stdio.ts +451 -0
- package/src/domains/mcp/store.ts +905 -0
- package/src/domains/mcp/tools.ts +119 -0
- package/src/lib/action-result.ts +51 -0
- package/src/lib/exec.ts +118 -0
- package/src/lib/git.ts +20 -0
- package/src/lib/report-html.ts +193 -0
- package/src/lib/sqlite.ts +51 -0
- package/src/lib/valibot.ts +33 -0
- package/src/modules/app-state/index.ts +5 -0
- package/src/modules/app-state/native-notifications.ts +76 -0
- package/src/modules/app-state/notification-events.ts +45 -0
- package/src/modules/app-state/notifications.ts +276 -0
- package/src/modules/app-state/types.ts +42 -0
- package/src/modules/app-state/workflow-summaries.ts +201 -0
- package/src/modules/autonomous-audit/index.ts +225 -0
- package/src/modules/autopilot/actions.ts +165 -0
- package/src/modules/autopilot/admissions.ts +865 -0
- package/src/modules/autopilot/approvals.ts +59 -0
- package/src/modules/autopilot/ci-fix-run.ts +1332 -0
- package/src/modules/autopilot/ci-fix.ts +692 -0
- package/src/modules/autopilot/comments.ts +426 -0
- package/src/modules/autopilot/fixtures.ts +344 -0
- package/src/modules/autopilot/github-facts.ts +303 -0
- package/src/modules/autopilot/index.ts +64 -0
- package/src/modules/autopilot/notifications.ts +271 -0
- package/src/modules/autopilot/push-support.ts +288 -0
- package/src/modules/autopilot/push.ts +661 -0
- package/src/modules/autopilot/recovery.ts +656 -0
- package/src/modules/autopilot/review-feedback.ts +651 -0
- package/src/modules/autopilot/review-support.ts +524 -0
- package/src/modules/autopilot/revision-run.ts +445 -0
- package/src/modules/autopilot/schemas.ts +485 -0
- package/src/modules/autopilot/state-mappers.ts +512 -0
- package/src/modules/autopilot/state-schemas.ts +451 -0
- package/src/modules/autopilot/state-store.ts +183 -0
- package/src/modules/autopilot/state.ts +255 -0
- package/src/modules/autopilot/triage-support.ts +234 -0
- package/src/modules/autopilot/triage.ts +156 -0
- package/src/modules/autopilot/utils.ts +145 -0
- package/src/modules/autopilot/worktree.ts +622 -0
- package/src/modules/autopilot-policy/config.ts +110 -0
- package/src/modules/autopilot-policy/index.ts +4 -0
- package/src/modules/autopilot-policy/risk.ts +359 -0
- package/src/modules/autopilot-policy/schemas.ts +284 -0
- package/src/modules/autopilot-policy/service.ts +304 -0
- package/src/modules/commands/actions.ts +112 -0
- package/src/modules/commands/handlers/index.ts +3 -0
- package/src/modules/commands/handlers/misc.ts +441 -0
- package/src/modules/commands/handlers/queue.ts +694 -0
- package/src/modules/commands/handlers/repo.ts +339 -0
- package/src/modules/commands/index.ts +5 -0
- package/src/modules/commands/registry.ts +157 -0
- package/src/modules/commands/runner.ts +152 -0
- package/src/modules/commands/schemas.ts +107 -0
- package/src/modules/commands/summaries.ts +92 -0
- package/src/modules/commands/utils.ts +113 -0
- package/src/modules/config/actions.ts +253 -0
- package/src/modules/config/events.ts +80 -0
- package/src/modules/config/files.ts +9 -0
- package/src/modules/config/history.ts +74 -0
- package/src/modules/config/index.ts +9 -0
- package/src/modules/config/mutations/dashboard.ts +319 -0
- package/src/modules/config/mutations/execution.ts +89 -0
- package/src/modules/config/mutations/models.ts +467 -0
- package/src/modules/config/mutations/providers.ts +163 -0
- package/src/modules/config/mutations/repos.ts +620 -0
- package/src/modules/config/read.ts +135 -0
- package/src/modules/config/result.ts +66 -0
- package/src/modules/config/schemas.ts +181 -0
- package/src/modules/docs-drift/index.ts +1 -0
- package/src/modules/docs-drift/service.ts +863 -0
- package/src/modules/execution/actions.ts +35 -0
- package/src/modules/execution/approvals.ts +322 -0
- package/src/modules/execution/exedev/checkouts.ts +356 -0
- package/src/modules/execution/exedev/context.ts +286 -0
- package/src/modules/execution/index.ts +7 -0
- package/src/modules/execution/policy.ts +102 -0
- package/src/modules/execution/run.ts +589 -0
- package/src/modules/execution/schemas.ts +116 -0
- package/src/modules/execution/scope.ts +137 -0
- package/src/modules/execution/store.ts +320 -0
- package/src/modules/execution/utils.ts +105 -0
- package/src/modules/execution-policy/index.ts +424 -0
- package/src/modules/flue/execution-context.ts +41 -0
- package/src/modules/github/actions.ts +334 -0
- package/src/modules/github/checks.ts +484 -0
- package/src/modules/github/client.ts +110 -0
- package/src/modules/github/comments.ts +204 -0
- package/src/modules/github/errors.ts +50 -0
- package/src/modules/github/index.ts +92 -0
- package/src/modules/github/issues.ts +116 -0
- package/src/modules/github/pr-file-cache.ts +264 -0
- package/src/modules/github/pull-requests.ts +384 -0
- package/src/modules/github/queue.ts +342 -0
- package/src/modules/github/reviews.ts +1421 -0
- package/src/modules/github/schemas.ts +794 -0
- package/src/modules/github/state-truncation.ts +31 -0
- package/src/modules/handoff/index.ts +2 -0
- package/src/modules/handoff/schemas.ts +61 -0
- package/src/modules/handoff/service.ts +587 -0
- package/src/modules/hygiene/index.ts +1 -0
- package/src/modules/hygiene/service.ts +513 -0
- package/src/modules/kilo/actions.ts +229 -0
- package/src/modules/kilo/ci-fix-run-reconcile.ts +299 -0
- package/src/modules/kilo/docs-drift-boundary.ts +178 -0
- package/src/modules/kilo/index.ts +8 -0
- package/src/modules/kilo/notifications.ts +295 -0
- package/src/modules/kilo/process.ts +637 -0
- package/src/modules/kilo/results/actions.ts +66 -0
- package/src/modules/kilo/results/gates.ts +227 -0
- package/src/modules/kilo/results/index.ts +23 -0
- package/src/modules/kilo/results/schemas.ts +112 -0
- package/src/modules/kilo/results/service.ts +512 -0
- package/src/modules/kilo/results/state.ts +508 -0
- package/src/modules/kilo/results/verify.ts +328 -0
- package/src/modules/kilo/revision-reconcile.ts +187 -0
- package/src/modules/kilo/runtime-facts.ts +128 -0
- package/src/modules/kilo/schemas.ts +265 -0
- package/src/modules/kilo/service.ts +714 -0
- package/src/modules/kilo/sessions-adapters.ts +343 -0
- package/src/modules/kilo/sessions.ts +446 -0
- package/src/modules/kilo/store.ts +689 -0
- package/src/modules/kilo/utils.ts +166 -0
- package/src/modules/learning/automation-health.ts +441 -0
- package/src/modules/learning/automation-memory.ts +179 -0
- package/src/modules/learning/index.ts +6 -0
- package/src/modules/learning/observability.ts +616 -0
- package/src/modules/learning/operator.ts +404 -0
- package/src/modules/learning/reviews/agents.ts +33 -0
- package/src/modules/learning/reviews/complete.ts +321 -0
- package/src/modules/learning/reviews/context.ts +145 -0
- package/src/modules/learning/reviews/events.ts +306 -0
- package/src/modules/learning/reviews/index.ts +6 -0
- package/src/modules/learning/reviews/pr-cadence.ts +157 -0
- package/src/modules/learning/reviews/pr-context.ts +749 -0
- package/src/modules/learning/reviews/prepare.ts +387 -0
- package/src/modules/learning/reviews/schemas.ts +184 -0
- package/src/modules/learning/reviews/store.ts +405 -0
- package/src/modules/learning/skill-patches/actions.ts +86 -0
- package/src/modules/learning/skill-patches/index.ts +3 -0
- package/src/modules/learning/skill-patches/schemas.ts +60 -0
- package/src/modules/learning/skill-patches/service.ts +571 -0
- package/src/modules/learning/skill-patches/support.ts +417 -0
- package/src/modules/memory/actions.ts +183 -0
- package/src/modules/memory/candidates.ts +525 -0
- package/src/modules/memory/events.ts +2 -0
- package/src/modules/memory/index.ts +6 -0
- package/src/modules/memory/prompt.ts +214 -0
- package/src/modules/memory/schemas.ts +170 -0
- package/src/modules/memory/service.ts +578 -0
- package/src/modules/memory/store.ts +489 -0
- package/src/modules/pr-events/actions.ts +191 -0
- package/src/modules/pr-events/index.ts +45 -0
- package/src/modules/pr-events/schemas.ts +186 -0
- package/src/modules/pr-events/service.ts +1414 -0
- package/src/modules/pr-events/target.ts +222 -0
- package/src/modules/pr-events/utils.ts +85 -0
- package/src/modules/pr-events/watermarks.ts +308 -0
- package/src/modules/pr-local-diffs/index.ts +334 -0
- package/src/modules/pr-review-assist/actions.ts +199 -0
- package/src/modules/pr-review-assist/index.ts +3 -0
- package/src/modules/pr-review-assist/schemas.ts +74 -0
- package/src/modules/pr-review-assist/service.ts +656 -0
- package/src/modules/prepared-diffs/actions.ts +132 -0
- package/src/modules/prepared-diffs/index.ts +53 -0
- package/src/modules/prepared-diffs/schemas.ts +255 -0
- package/src/modules/prepared-diffs/service.ts +777 -0
- package/src/modules/prepared-diffs/store.ts +606 -0
- package/src/modules/reports/index.ts +1 -0
- package/src/modules/reports/service.ts +322 -0
- package/src/modules/repos/index.ts +3 -0
- package/src/modules/repos/model-discovery.ts +233 -0
- package/src/modules/repos/providers.ts +194 -0
- package/src/modules/repos/registry.ts +232 -0
- package/src/modules/runtime/agent-config.ts +167 -0
- package/src/modules/runtime/doctor.ts +528 -0
- package/src/modules/runtime/env.ts +123 -0
- package/src/modules/runtime/index.ts +12 -0
- package/src/modules/runtime/local-api-auth.ts +43 -0
- package/src/modules/runtime/metrics.ts +211 -0
- package/src/modules/runtime/skills-actions.ts +141 -0
- package/src/modules/runtime/skills.ts +689 -0
- package/src/modules/runtime/soul.ts +68 -0
- package/src/modules/runtime/status-database.ts +252 -0
- package/src/modules/runtime/status-schema.ts +149 -0
- package/src/modules/runtime/status.ts +482 -0
- package/src/modules/runtime/subagents.ts +37 -0
- package/src/modules/runtime/utility-model.ts +47 -0
- package/src/modules/safety/index.ts +3 -0
- package/src/modules/safety/policy-entries.ts +2432 -0
- package/src/modules/safety/schemas.ts +63 -0
- package/src/modules/safety/service.ts +58 -0
- package/src/modules/safety/tools.ts +15 -0
- package/src/modules/scheduled-tasks/actions.ts +113 -0
- package/src/modules/scheduled-tasks/dispatch.ts +105 -0
- package/src/modules/scheduled-tasks/index.ts +6 -0
- package/src/modules/scheduled-tasks/schemas.ts +91 -0
- package/src/modules/scheduled-tasks/service.ts +296 -0
- package/src/modules/scheduled-tasks/store.ts +814 -0
- package/src/modules/scheduled-tasks/triggers.ts +87 -0
- package/src/modules/scheduler/actions.ts +37 -0
- package/src/modules/scheduler/dispatch.ts +126 -0
- package/src/modules/scheduler/index.ts +4 -0
- package/src/modules/scheduler/lease.ts +247 -0
- package/src/modules/scheduler/pr-watch-event-deltas.ts +367 -0
- package/src/modules/scheduler/pr-watch-events.ts +834 -0
- package/src/modules/scheduler/schemas.ts +79 -0
- package/src/modules/scheduler/service.ts +228 -0
- package/src/modules/scheduler/utils.ts +106 -0
- package/src/modules/scheduler/workflow-invocation.ts +40 -0
- package/src/modules/sessions/actions.ts +213 -0
- package/src/modules/sessions/active-session.ts +46 -0
- package/src/modules/sessions/agent-context.ts +146 -0
- package/src/modules/sessions/approval-nudges.ts +156 -0
- package/src/modules/sessions/events.ts +58 -0
- package/src/modules/sessions/index.ts +10 -0
- package/src/modules/sessions/queries.ts +252 -0
- package/src/modules/sessions/references.ts +113 -0
- package/src/modules/sessions/schemas.ts +263 -0
- package/src/modules/sessions/service.ts +845 -0
- package/src/modules/sessions/store.ts +559 -0
- package/src/modules/sessions/summaries.ts +129 -0
- package/src/modules/sessions/utils.ts +18 -0
- package/src/modules/watches/actions.ts +115 -0
- package/src/modules/watches/index.ts +6 -0
- package/src/modules/watches/polling.ts +245 -0
- package/src/modules/watches/references.ts +293 -0
- package/src/modules/watches/schemas.ts +156 -0
- package/src/modules/watches/service.ts +558 -0
- package/src/modules/watches/store.ts +398 -0
- package/src/modules/watches/utils.ts +51 -0
- package/src/modules/worktree-verification/index.ts +256 -0
- package/src/modules/worktrees/access.ts +129 -0
- package/src/modules/worktrees/actions.ts +108 -0
- package/src/modules/worktrees/cleanup.ts +98 -0
- package/src/modules/worktrees/errors.ts +38 -0
- package/src/modules/worktrees/git.ts +48 -0
- package/src/modules/worktrees/index.ts +5 -0
- package/src/modules/worktrees/locks.ts +192 -0
- package/src/modules/worktrees/paths.ts +209 -0
- package/src/modules/worktrees/queries.ts +31 -0
- package/src/modules/worktrees/schemas.ts +234 -0
- package/src/modules/worktrees/service.ts +657 -0
- package/src/modules/worktrees/store.ts +414 -0
- package/src/repo-edit/actions.ts +129 -0
- package/src/repo-edit/audit.ts +180 -0
- package/src/repo-edit/fuzzy-replace.ts +256 -0
- package/src/repo-edit/git.ts +784 -0
- package/src/repo-edit/index.ts +4 -0
- package/src/repo-edit/locks.ts +27 -0
- package/src/repo-edit/patch-parser.ts +212 -0
- package/src/repo-edit/patch-service.ts +572 -0
- package/src/repo-edit/path-safety.ts +294 -0
- package/src/repo-edit/schemas.ts +220 -0
- package/src/repo-edit/service.ts +488 -0
- package/src/repo-edit/support.ts +459 -0
- package/src/runtime-home/app-db/index.ts +73 -0
- package/src/runtime-home/app-db/migrate.ts +491 -0
- package/src/runtime-home/app-db/migrations/20260710061339_neondeck_pre_1_0_baseline/migration.sql +748 -0
- package/src/runtime-home/app-db/migrations/20260710061339_neondeck_pre_1_0_baseline/snapshot.json +7240 -0
- package/src/runtime-home/app-db/reconcile.ts +155 -0
- package/src/runtime-home/app-db/schema.ts +1118 -0
- package/src/runtime-home/bootstrap.ts +171 -0
- package/src/runtime-home/defaults.ts +42 -0
- package/src/runtime-home/files.ts +193 -0
- package/src/runtime-home/index.ts +68 -0
- package/src/runtime-home/paths.ts +75 -0
- package/src/runtime-home/schemas.ts +485 -0
- package/src/sandboxes/exedev.ts +676 -0
- package/src/server/app.ts +5 -0
- package/src/server/autopilot-push-dispatch.ts +326 -0
- package/src/server/create-app.ts +160 -0
- package/src/server/events/config-stream.ts +67 -0
- package/src/server/events/notification-stream.ts +49 -0
- package/src/server/events/session-stream.ts +49 -0
- package/src/server/http.ts +56 -0
- package/src/server/learning-hooks.ts +430 -0
- package/src/server/middleware.ts +81 -0
- package/src/server/routes/autopilot.ts +318 -0
- package/src/server/routes/commands.ts +12 -0
- package/src/server/routes/config.ts +124 -0
- package/src/server/routes/execution.ts +71 -0
- package/src/server/routes/github.ts +372 -0
- package/src/server/routes/handoff.ts +69 -0
- package/src/server/routes/kilo.ts +179 -0
- package/src/server/routes/learning.ts +384 -0
- package/src/server/routes/mcp.ts +301 -0
- package/src/server/routes/memory.ts +99 -0
- package/src/server/routes/metrics.ts +12 -0
- package/src/server/routes/notifications.ts +48 -0
- package/src/server/routes/repo-edit.ts +115 -0
- package/src/server/routes/reports.ts +127 -0
- package/src/server/routes/repos.ts +50 -0
- package/src/server/routes/runtime.ts +48 -0
- package/src/server/routes/safety.ts +13 -0
- package/src/server/routes/scheduled-tasks.ts +58 -0
- package/src/server/routes/scheduler.ts +13 -0
- package/src/server/routes/sessions.ts +216 -0
- package/src/server/routes/skills.ts +103 -0
- package/src/server/routes/watches.ts +81 -0
- package/src/server/routes/workflows.ts +21 -0
- package/src/server/routes/worktrees.ts +64 -0
- package/src/server/scheduler-workflow.ts +541 -0
- package/src/server/serve.ts +100 -0
- package/src/setup.ts +162 -0
- package/src/skills/github-gh/SKILL.md +56 -0
- package/src/skills/neon-ci-fix/SKILL.md +15 -0
- package/src/skills/neon-docs-fix/SKILL.md +15 -0
- package/src/skills/neon-issue-triage/SKILL.md +13 -0
- package/src/skills/neon-pr-review/SKILL.md +19 -0
- package/src/skills/neondeck/SKILL.md +123 -0
- package/src/skills/neondeck-handoff/SKILL.md +31 -0
- package/src/workflows/briefing.ts +14 -0
- package/src/workflows/command-run.ts +15 -0
- package/src/workflows/comment-pr-autofix-result.ts +10 -0
- package/src/workflows/curate_learning_store.ts +37 -0
- package/src/workflows/dev-doctor.ts +10 -0
- package/src/workflows/fix-pr-ci-failure.ts +10 -0
- package/src/workflows/fix-pr-ci.ts +15 -0
- package/src/workflows/fix-pr-review-feedback.ts +10 -0
- package/src/workflows/handoff_to_kilo.ts +10 -0
- package/src/workflows/prepare-pr-worktree.ts +10 -0
- package/src/workflows/promote_kilo_result.ts +10 -0
- package/src/workflows/push-pr-autofix.ts +10 -0
- package/src/workflows/reconcile_kilo_task.ts +10 -0
- package/src/workflows/review-pr-for-human.ts +15 -0
- package/src/workflows/review_conversation_for_learning.ts +37 -0
- package/src/workflows/review_kilo_result.ts +10 -0
- package/src/workflows/review_pr_batch_for_learning.ts +37 -0
- package/src/workflows/scheduled-agent-instruction.ts +16 -0
- package/src/workflows/scheduler-tick.ts +10 -0
- package/src/workflows/summarize_kilo_session.ts +25 -0
- package/src/workflows/triage-pr-event.ts +10 -0
- package/src/workflows/verify-pr-worktree.ts +10 -0
- package/src/workflows/verify-then-push-pr-autofix.ts +82 -0
- package/src/workflows/verify_kilo_result.ts +10 -0
- package/src/workflows/watch-pr.ts +10 -0
- package/web/dist/assets/GitHubPrReview-QK9oqeDs.js +2 -0
- package/web/dist/assets/MultiFileView-CMm6tA9f.js +2970 -0
- package/web/dist/assets/abap-CLvhMVsD.js +1 -0
- package/web/dist/assets/actionscript-3--17pq3dv.js +1 -0
- package/web/dist/assets/ada-C5qYipkI.js +1 -0
- package/web/dist/assets/andromeeda-vGVdxbeo.js +1 -0
- package/web/dist/assets/angular-html-BVBpGdXr.js +1 -0
- package/web/dist/assets/angular-ts-BfdufMKP.js +1 -0
- package/web/dist/assets/apache-U0d_L8uA.js +1 -0
- package/web/dist/assets/apex-VAyPSnFM.js +1 -0
- package/web/dist/assets/apl-DWBSSoBH.js +1 -0
- package/web/dist/assets/applescript-CCn79oCD.js +1 -0
- package/web/dist/assets/ara-4CJ0cIlV.js +1 -0
- package/web/dist/assets/asciidoc-DE70LPWp.js +1 -0
- package/web/dist/assets/asm-Cmm7eHzH.js +1 -0
- package/web/dist/assets/astro-3LtMP0Sq.js +1 -0
- package/web/dist/assets/aurora-x-CDeNXAV0.js +1 -0
- package/web/dist/assets/awk-BWXHIvNe.js +1 -0
- package/web/dist/assets/ayu-dark-DluEY0Gj.js +1 -0
- package/web/dist/assets/ayu-light-C3h-C4tm.js +1 -0
- package/web/dist/assets/ayu-mirage-Bqwy1Gya.js +1 -0
- package/web/dist/assets/ballerina-B7ZEbQpA.js +1 -0
- package/web/dist/assets/bat-Bo4NYOV-.js +1 -0
- package/web/dist/assets/beancount-D-usSTwE.js +1 -0
- package/web/dist/assets/berry-DKpUyyne.js +1 -0
- package/web/dist/assets/bibtex-Ci_nEsc7.js +1 -0
- package/web/dist/assets/bicep-CUHmPFLl.js +1 -0
- package/web/dist/assets/bird2-C6vDhewU.js +1 -0
- package/web/dist/assets/blade-llJRbbtR.js +1 -0
- package/web/dist/assets/bsl-BkkzgIyY.js +1 -0
- package/web/dist/assets/c-Wt1voDr2.js +1 -0
- package/web/dist/assets/c3-BFHwR3_K.js +1 -0
- package/web/dist/assets/cadence-CQ2zXKGN.js +1 -0
- package/web/dist/assets/cairo-DLTphjLi.js +1 -0
- package/web/dist/assets/catppuccin-frappe-3VR1Za6u.js +1 -0
- package/web/dist/assets/catppuccin-latte-DwIHMF0Q.js +1 -0
- package/web/dist/assets/catppuccin-macchiato-DYnBP6_5.js +1 -0
- package/web/dist/assets/catppuccin-mocha-DYhrFGRu.js +1 -0
- package/web/dist/assets/clarity-SemFz856.js +1 -0
- package/web/dist/assets/clojure-DqKBuwfJ.js +1 -0
- package/web/dist/assets/cmake-Bj61d0ZC.js +1 -0
- package/web/dist/assets/cobol-x_HIyl2P.js +1 -0
- package/web/dist/assets/codeowners-C8r90Shi.js +1 -0
- package/web/dist/assets/codeql-oeQT6MSM.js +1 -0
- package/web/dist/assets/coffee-CThvmt4R.js +1 -0
- package/web/dist/assets/common-lisp-Cv5bFMCO.js +1 -0
- package/web/dist/assets/coq-BrsZFFmf.js +1 -0
- package/web/dist/assets/cpp-NtAeskI3.js +1 -0
- package/web/dist/assets/crystal-DNu_sX0G.js +1 -0
- package/web/dist/assets/csharp-oqKa8noW.js +1 -0
- package/web/dist/assets/css-DJp_X0uY.js +1 -0
- package/web/dist/assets/csv-Dx-8-gkx.js +1 -0
- package/web/dist/assets/cue-CE9AQfxI.js +1 -0
- package/web/dist/assets/cypher-ClKdZ_lG.js +1 -0
- package/web/dist/assets/d-qD-0Kul2.js +1 -0
- package/web/dist/assets/dark-plus-Cs2F2srj.js +1 -0
- package/web/dist/assets/dart-CnvKMtbv.js +1 -0
- package/web/dist/assets/dax-BkyTk9wS.js +1 -0
- package/web/dist/assets/desktop-Dlh5hvp9.js +1 -0
- package/web/dist/assets/diff-woXpYk--.js +1 -0
- package/web/dist/assets/docker-IyjqRm3v.js +1 -0
- package/web/dist/assets/dotenv-_5a1GRtc.js +1 -0
- package/web/dist/assets/dracula-BHWKrbxM.js +1 -0
- package/web/dist/assets/dracula-soft-5eyTD99u.js +1 -0
- package/web/dist/assets/dream-maker-DW3nJb8Q.js +1 -0
- package/web/dist/assets/edge-ozw5tpLl.js +1 -0
- package/web/dist/assets/elixir-VhA6FeZt.js +1 -0
- package/web/dist/assets/elm-dREJmIFz.js +1 -0
- package/web/dist/assets/emacs-lisp-B4R74twV.js +1 -0
- package/web/dist/assets/erb-CIg6G69l.js +1 -0
- package/web/dist/assets/erlang-Cphh6RMH.js +1 -0
- package/web/dist/assets/everforest-dark-sB-x3p7T.js +1 -0
- package/web/dist/assets/everforest-light-Df2xbC6M.js +1 -0
- package/web/dist/assets/fennel-DQxkIbk2.js +1 -0
- package/web/dist/assets/fish-BJitypiv.js +1 -0
- package/web/dist/assets/fluent-C03EYrpw.js +1 -0
- package/web/dist/assets/fortran-fixed-form-DEKoE2YW.js +1 -0
- package/web/dist/assets/fortran-free-form-CYNrtFtB.js +1 -0
- package/web/dist/assets/fsharp-D13ZGOAj.js +1 -0
- package/web/dist/assets/gdresource-C0sCabJj.js +1 -0
- package/web/dist/assets/gdscript-Cp2uCuqX.js +1 -0
- package/web/dist/assets/gdshader-CBce3t8t.js +1 -0
- package/web/dist/assets/genie-CV2tkWYe.js +1 -0
- package/web/dist/assets/gherkin-DExj1W_8.js +1 -0
- package/web/dist/assets/git-commit-BSykSTBG.js +1 -0
- package/web/dist/assets/git-rebase-B44mJPta.js +1 -0
- package/web/dist/assets/github-dark-C-LZuMrd.js +1 -0
- package/web/dist/assets/github-dark-default-DXG-b-1a.js +1 -0
- package/web/dist/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
- package/web/dist/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
- package/web/dist/assets/github-light-EUqPIrTm.js +1 -0
- package/web/dist/assets/github-light-default-BXViO-2h.js +1 -0
- package/web/dist/assets/github-light-high-contrast-B68TUdTA.js +1 -0
- package/web/dist/assets/gleam-CSRkHgEL.js +1 -0
- package/web/dist/assets/glimmer-js-vH_gHG0-.js +1 -0
- package/web/dist/assets/glimmer-ts--abOzSAQ.js +1 -0
- package/web/dist/assets/glsl-Dv5r7kPw.js +1 -0
- package/web/dist/assets/gn-ilITqXS6.js +1 -0
- package/web/dist/assets/gnuplot-7GGW24-e.js +1 -0
- package/web/dist/assets/go-rLFTqkRN.js +1 -0
- package/web/dist/assets/graphql-CB4jsw2E.js +1 -0
- package/web/dist/assets/groovy-CacY0gHj.js +1 -0
- package/web/dist/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
- package/web/dist/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
- package/web/dist/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
- package/web/dist/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
- package/web/dist/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
- package/web/dist/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
- package/web/dist/assets/hack-DvEYX148.js +1 -0
- package/web/dist/assets/haml-zE6W3STP.js +1 -0
- package/web/dist/assets/handlebars-CzBR2SDs.js +1 -0
- package/web/dist/assets/haskell-D8IpX4py.js +1 -0
- package/web/dist/assets/haxe-OTjmBuCE.js +1 -0
- package/web/dist/assets/hcl-Dh228itO.js +1 -0
- package/web/dist/assets/hjson-CxZEssPk.js +1 -0
- package/web/dist/assets/hlsl-Cvrh5tZx.js +1 -0
- package/web/dist/assets/horizon-CE9ld1lL.js +1 -0
- package/web/dist/assets/horizon-bright-DSNQnXHK.js +1 -0
- package/web/dist/assets/houston-CsvMBhTu.js +1 -0
- package/web/dist/assets/html-C8UlPnhE.js +1 -0
- package/web/dist/assets/html-derivative-CY6NRz-J.js +1 -0
- package/web/dist/assets/http-Cyd7bS_S.js +1 -0
- package/web/dist/assets/hurl-CWPsiEpf.js +1 -0
- package/web/dist/assets/hxml-B0Qn7Nwc.js +1 -0
- package/web/dist/assets/hy-CZbG8q4J.js +1 -0
- package/web/dist/assets/imba-DsUTQ-LC.js +1 -0
- package/web/dist/assets/index-DqZpo0Jd.js +44 -0
- package/web/dist/assets/index-_jKCE4ks.css +2 -0
- package/web/dist/assets/ini-B5eOa1yu.js +1 -0
- package/web/dist/assets/java-CGc3VwQr.js +1 -0
- package/web/dist/assets/javascript-CUt1pgmJ.js +1 -0
- package/web/dist/assets/jinja-CD-Z-FLd.js +1 -0
- package/web/dist/assets/jison-imPNup1l.js +1 -0
- package/web/dist/assets/json-Bg9ijW3F.js +1 -0
- package/web/dist/assets/json5-BR5RXkoi.js +1 -0
- package/web/dist/assets/jsonc-CYpm1nAK.js +1 -0
- package/web/dist/assets/jsonl-CmCQp5Yx.js +1 -0
- package/web/dist/assets/jsonnet-CJTPZ8u_.js +1 -0
- package/web/dist/assets/jssm-DXw9l8Rf.js +1 -0
- package/web/dist/assets/jsx-CY6oMTks.js +1 -0
- package/web/dist/assets/julia-Dc3O-irA.js +1 -0
- package/web/dist/assets/just-BhOq_Kbv.js +1 -0
- package/web/dist/assets/kanagawa-dragon-CXtmUGW6.js +1 -0
- package/web/dist/assets/kanagawa-lotus-BN08jTvb.js +1 -0
- package/web/dist/assets/kanagawa-wave-CTweb8Dz.js +1 -0
- package/web/dist/assets/kdl-CsD5j6eV.js +1 -0
- package/web/dist/assets/kotlin-DhhofPvG.js +1 -0
- package/web/dist/assets/kusto-C7mF5XQf.js +1 -0
- package/web/dist/assets/laserwave-C_8bwKvT.js +1 -0
- package/web/dist/assets/latex-Cu4Y1d5w.js +1 -0
- package/web/dist/assets/lean-CewbzKMR.js +1 -0
- package/web/dist/assets/less-DVTAwKKz.js +1 -0
- package/web/dist/assets/light-plus-DVQuIRkW.js +1 -0
- package/web/dist/assets/liquid-CvXMrjlQ.js +1 -0
- package/web/dist/assets/llvm-Cm23YOpf.js +1 -0
- package/web/dist/assets/log-BNLmms1o.js +1 -0
- package/web/dist/assets/logo-Cluzi2Zq.js +1 -0
- package/web/dist/assets/lua-BjLEUjKY.js +1 -0
- package/web/dist/assets/luau-FMPmPwt6.js +1 -0
- package/web/dist/assets/make-Dixweg8N.js +1 -0
- package/web/dist/assets/markdown-BYOwaDjH.js +1 -0
- package/web/dist/assets/marko-DvhNOisQ.js +1 -0
- package/web/dist/assets/material-theme-Bm3Qr25_.js +1 -0
- package/web/dist/assets/material-theme-darker-2IIEA8gg.js +1 -0
- package/web/dist/assets/material-theme-lighter-uhdI0v04.js +1 -0
- package/web/dist/assets/material-theme-ocean-CHQ94UKr.js +1 -0
- package/web/dist/assets/material-theme-palenight-B5W6OYN7.js +1 -0
- package/web/dist/assets/matlab-D7qyCx1q.js +1 -0
- package/web/dist/assets/mdc-Bm9TpL1X.js +1 -0
- package/web/dist/assets/mdx-DQZ5AkYe.js +1 -0
- package/web/dist/assets/mermaid-Bk4SNUv9.js +1 -0
- package/web/dist/assets/min-dark-BSWPekZh.js +1 -0
- package/web/dist/assets/min-light-DDpmG2fV.js +1 -0
- package/web/dist/assets/mipsasm-BMqwQI7S.js +1 -0
- package/web/dist/assets/mojo-BgCJLMeH.js +1 -0
- package/web/dist/assets/monokai-CdkpiU2Y.js +1 -0
- package/web/dist/assets/moonbit-CaWjb8XO.js +1 -0
- package/web/dist/assets/move-B1IS1UjX.js +1 -0
- package/web/dist/assets/narrat-_X_XdTYD.js +1 -0
- package/web/dist/assets/nextflow-BJtWHP5T.js +1 -0
- package/web/dist/assets/nextflow-groovy-DJMQeKeT.js +1 -0
- package/web/dist/assets/nginx-Bhc82uuv.js +1 -0
- package/web/dist/assets/night-owl-DhmEMT88.js +1 -0
- package/web/dist/assets/night-owl-light-eJ-hLW7d.js +1 -0
- package/web/dist/assets/nim-DXTVBFnF.js +1 -0
- package/web/dist/assets/nix-IvuFDN5E.js +1 -0
- package/web/dist/assets/nord-Cb4Vim4T.js +1 -0
- package/web/dist/assets/nushell-DcLAeLz5.js +1 -0
- package/web/dist/assets/objective-c-D1A_Heim.js +1 -0
- package/web/dist/assets/objective-cpp-BsSzOQcm.js +1 -0
- package/web/dist/assets/ocaml-O90oeIOV.js +1 -0
- package/web/dist/assets/odin-B1RWQWA5.js +1 -0
- package/web/dist/assets/one-dark-pro-CLwyXe_n.js +1 -0
- package/web/dist/assets/one-light-D7Lr4KcI.js +1 -0
- package/web/dist/assets/openscad-BUDT5pXO.js +1 -0
- package/web/dist/assets/pascal-4ZHwLPI5.js +1 -0
- package/web/dist/assets/perl-C7veXV9z.js +1 -0
- package/web/dist/assets/php-BRiuMnnr.js +1 -0
- package/web/dist/assets/pierre-dark-CpLgRqie.js +1 -0
- package/web/dist/assets/pierre-dark-protanopia-deuteranopia-B35FxJx-.js +1 -0
- package/web/dist/assets/pierre-dark-soft-kZQmAZld.js +1 -0
- package/web/dist/assets/pierre-dark-tritanopia-CpjhbsIL.js +1 -0
- package/web/dist/assets/pierre-dark-vibrant-CpQYzh95.js +1 -0
- package/web/dist/assets/pierre-light-CoaEpmwp.js +1 -0
- package/web/dist/assets/pierre-light-protanopia-deuteranopia-0fSaH845.js +1 -0
- package/web/dist/assets/pierre-light-soft-lWLdNTOI.js +1 -0
- package/web/dist/assets/pierre-light-tritanopia-CEbqgOJL.js +1 -0
- package/web/dist/assets/pierre-light-vibrant-D80Fkn33.js +1 -0
- package/web/dist/assets/pkl-ot-7Btpt.js +1 -0
- package/web/dist/assets/plastic-DQwYfKfQ.js +1 -0
- package/web/dist/assets/plsql-DGHpHOYJ.js +1 -0
- package/web/dist/assets/po-BiJDBrnU.js +1 -0
- package/web/dist/assets/poimandres-DRFjx7u4.js +1 -0
- package/web/dist/assets/polar-C7UOKdEL.js +1 -0
- package/web/dist/assets/postcss-BXeXVLqQ.js +1 -0
- package/web/dist/assets/powerquery-DNMTfnFr.js +1 -0
- package/web/dist/assets/powershell-DshXNtvi.js +1 -0
- package/web/dist/assets/prisma-BsRQq5mF.js +1 -0
- package/web/dist/assets/prolog-iXnhIJG7.js +1 -0
- package/web/dist/assets/proto-DB4EqR-F.js +1 -0
- package/web/dist/assets/pug-C5hz5LQ7.js +1 -0
- package/web/dist/assets/puppet-CDv2pdJW.js +1 -0
- package/web/dist/assets/purescript-9MfHhQsQ.js +1 -0
- package/web/dist/assets/python-gzcpVVnB.js +1 -0
- package/web/dist/assets/qml-BdUV3aTS.js +1 -0
- package/web/dist/assets/qmldir-DCQb3MpD.js +1 -0
- package/web/dist/assets/qss-Fe1Jh2GI.js +1 -0
- package/web/dist/assets/r-8R7vtdQc.js +1 -0
- package/web/dist/assets/racket-DcIDlBhZ.js +1 -0
- package/web/dist/assets/raku-B3gFvitq.js +1 -0
- package/web/dist/assets/razor-DRL52XO2.js +1 -0
- package/web/dist/assets/red-CJ3rzSJv.js +1 -0
- package/web/dist/assets/reg-CRGYupPL.js +1 -0
- package/web/dist/assets/regexp-Omp9DhTb.js +1 -0
- package/web/dist/assets/rel-BtDbiS_P.js +1 -0
- package/web/dist/assets/riscv-Ckw8ddFX.js +1 -0
- package/web/dist/assets/rolldown-runtime-QTnfLwEv.js +1 -0
- package/web/dist/assets/ron-VUp2lXgN.js +1 -0
- package/web/dist/assets/rose-pine-BthvhNj6.js +1 -0
- package/web/dist/assets/rose-pine-dawn-Dg85fqjY.js +1 -0
- package/web/dist/assets/rose-pine-moon-hon4tzzS.js +1 -0
- package/web/dist/assets/rosmsg-CAekHB0j.js +1 -0
- package/web/dist/assets/rst-BHX71KW9.js +1 -0
- package/web/dist/assets/ruby-B--HzjGU.js +1 -0
- package/web/dist/assets/rust-Cfkwpbl8.js +1 -0
- package/web/dist/assets/sas-DrLaYOK_.js +1 -0
- package/web/dist/assets/sass-DXrisJhu.js +1 -0
- package/web/dist/assets/scala-DKOlJaKm.js +1 -0
- package/web/dist/assets/scheme-DQCgrYNe.js +1 -0
- package/web/dist/assets/scss-DdSxiZKl.js +1 -0
- package/web/dist/assets/sdbl-bTVj8UrX.js +1 -0
- package/web/dist/assets/shaderlab-TOUzSsQk.js +1 -0
- package/web/dist/assets/shellscript-DwcUjJBL.js +1 -0
- package/web/dist/assets/shellsession-CPZkydE6.js +1 -0
- package/web/dist/assets/slack-dark-DnToyrRv.js +1 -0
- package/web/dist/assets/slack-ochin-B2OO5cIa.js +1 -0
- package/web/dist/assets/smalltalk-B16xEiuN.js +1 -0
- package/web/dist/assets/snazzy-light-4G7pJPwS.js +1 -0
- package/web/dist/assets/solarized-dark-DV17i1UV.js +1 -0
- package/web/dist/assets/solarized-light-DSh2HLQt.js +1 -0
- package/web/dist/assets/solidity-CKzVLygQ.js +1 -0
- package/web/dist/assets/soy-Br5FhD7c.js +1 -0
- package/web/dist/assets/sparql-D_iOobhT.js +1 -0
- package/web/dist/assets/splunk-BC2Px7Mm.js +1 -0
- package/web/dist/assets/sql-DNssxck8.js +1 -0
- package/web/dist/assets/ssh-config-BgfXC-Er.js +1 -0
- package/web/dist/assets/stata-DXn1tqOr.js +1 -0
- package/web/dist/assets/stylus-B6D30XZt.js +1 -0
- package/web/dist/assets/surfaces-B8Ko8AJ3.js +1 -0
- package/web/dist/assets/surrealql-IeLNQw0f.js +1 -0
- package/web/dist/assets/svelte-DOdLCIlh.js +1 -0
- package/web/dist/assets/swift-DonLKvLd.js +1 -0
- package/web/dist/assets/synthwave-84-nFMaYfgc.js +1 -0
- package/web/dist/assets/system-verilog-DJ5XKQeo.js +1 -0
- package/web/dist/assets/systemd-BxMlprV5.js +1 -0
- package/web/dist/assets/talonscript-CohzipZa.js +1 -0
- package/web/dist/assets/tasl-DMoTqEGO.js +1 -0
- package/web/dist/assets/tcl-CZd0xW_V.js +1 -0
- package/web/dist/assets/templ-CIwIngms.js +1 -0
- package/web/dist/assets/terraform-DswuEJGm.js +1 -0
- package/web/dist/assets/tex-D8QMumu5.js +1 -0
- package/web/dist/assets/tokyo-night-oM2G3aXe.js +1 -0
- package/web/dist/assets/toml-CcmNWLt0.js +1 -0
- package/web/dist/assets/ts-tags-BMVY4q-l.js +1 -0
- package/web/dist/assets/tsv-sltzmVWM.js +1 -0
- package/web/dist/assets/tsx-5Eka4NBX.js +1 -0
- package/web/dist/assets/turtle-ByJddavk.js +1 -0
- package/web/dist/assets/twig-C8o_5mgw.js +1 -0
- package/web/dist/assets/typescript-DOu2WMV5.js +1 -0
- package/web/dist/assets/typespec-BRdr0IET.js +1 -0
- package/web/dist/assets/typst-DI99ib-x.js +1 -0
- package/web/dist/assets/v-DETTlOr0.js +1 -0
- package/web/dist/assets/vala-zf12oZj6.js +1 -0
- package/web/dist/assets/vb-Djn5o6TS.js +1 -0
- package/web/dist/assets/verilog-CiiDBU1e.js +1 -0
- package/web/dist/assets/vesper-DdrHHSXu.js +1 -0
- package/web/dist/assets/vhdl-BroJfC0k.js +1 -0
- package/web/dist/assets/viml-DvXPmvsu.js +1 -0
- package/web/dist/assets/vitesse-black-fwtXNY1n.js +1 -0
- package/web/dist/assets/vitesse-dark-BZCL-v6S.js +1 -0
- package/web/dist/assets/vitesse-light-VbXTXTou.js +1 -0
- package/web/dist/assets/vue-BU18DNDL.js +1 -0
- package/web/dist/assets/vue-html-BeluIYX0.js +1 -0
- package/web/dist/assets/vue-vine-DGUAbOCX.js +1 -0
- package/web/dist/assets/vyper-CgoNMtux.js +1 -0
- package/web/dist/assets/wasm-BnjxR4X6.js +1 -0
- package/web/dist/assets/wasm-ByWQv1Qj.js +1 -0
- package/web/dist/assets/wenyan-C8pVoKbM.js +1 -0
- package/web/dist/assets/wgsl-BsKzXJz4.js +1 -0
- package/web/dist/assets/wikitext-ClFFjSW2.js +1 -0
- package/web/dist/assets/wit-DdvCle-K.js +1 -0
- package/web/dist/assets/wolfram-DLL8P-h_.js +1 -0
- package/web/dist/assets/worker-CBKQOXEl.js +160 -0
- package/web/dist/assets/xml-DIqSwXR3.js +1 -0
- package/web/dist/assets/xsl-Ct_-YIAy.js +1 -0
- package/web/dist/assets/yaml-DTtCYNlS.js +1 -0
- package/web/dist/assets/zenscript-BnlCZFoB.js +1 -0
- package/web/dist/assets/zig-CMLA9XwU.js +1 -0
- package/web/dist/icons/neondeck-icon-192.png +0 -0
- package/web/dist/icons/neondeck-icon-512.png +0 -0
- package/web/dist/icons/neondeck-icon.svg +41 -0
- package/web/dist/icons/neondeck-maskable-512.png +0 -0
- package/web/dist/index.html +24 -0
- package/web/dist/manifest.webmanifest +28 -0
|
@@ -0,0 +1,1421 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import * as v from 'valibot';
|
|
3
|
+
import { isUniqueConstraintError, openDb } from '../../lib/sqlite';
|
|
4
|
+
import type { RuntimePaths } from '../../runtime-home';
|
|
5
|
+
import { addWorkflowSummary } from '../app-state';
|
|
6
|
+
import {
|
|
7
|
+
encodePathSegment,
|
|
8
|
+
githubFetch,
|
|
9
|
+
githubGraphqlFetch,
|
|
10
|
+
nextLink,
|
|
11
|
+
} from './client';
|
|
12
|
+
import { fetchPullRequestReviewThread } from './comments';
|
|
13
|
+
import { GitHubApiError, errorMessage } from './errors';
|
|
14
|
+
import { fetchPullRequestDetail } from './pull-requests';
|
|
15
|
+
import {
|
|
16
|
+
githubPullRequestReviewApiItemSchema,
|
|
17
|
+
githubPullRequestReviewCreatedApiResponseSchema,
|
|
18
|
+
} from './schemas';
|
|
19
|
+
import type {
|
|
20
|
+
GitHubPullRequestRequestedChangesState,
|
|
21
|
+
GitHubPullRequestReview,
|
|
22
|
+
GitHubPullRequestReviewApiItem,
|
|
23
|
+
GitHubPullRequestReviewThread,
|
|
24
|
+
GitHubSubmittedPullRequestReview,
|
|
25
|
+
} from './schemas';
|
|
26
|
+
|
|
27
|
+
export type GitHubPrReviewVerdict = 'comment' | 'approve' | 'request-changes';
|
|
28
|
+
|
|
29
|
+
export type GitHubPrReviewDraftStatus = 'draft' | 'submitted' | 'discarded';
|
|
30
|
+
|
|
31
|
+
export type GitHubPrReviewDraftCommentSide = 'RIGHT' | 'LEFT';
|
|
32
|
+
|
|
33
|
+
export type GitHubPrReviewDraftCommentOrigin = 'human' | 'neon';
|
|
34
|
+
|
|
35
|
+
export type GitHubPrReviewDraftComment = {
|
|
36
|
+
id: string;
|
|
37
|
+
draftId: string;
|
|
38
|
+
path: string;
|
|
39
|
+
side: GitHubPrReviewDraftCommentSide;
|
|
40
|
+
line: number;
|
|
41
|
+
startLine: number | null;
|
|
42
|
+
startSide: GitHubPrReviewDraftCommentSide | null;
|
|
43
|
+
body: string;
|
|
44
|
+
origin: GitHubPrReviewDraftCommentOrigin;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type GitHubPrReviewNeonSeedSeverity =
|
|
50
|
+
'critical' | 'major' | 'minor' | 'nit';
|
|
51
|
+
|
|
52
|
+
export type GitHubPrReviewNeonSeedOutcome = 'submitted' | 'skipped' | 'deleted';
|
|
53
|
+
|
|
54
|
+
export type GitHubPrReviewNeonSeededComment = {
|
|
55
|
+
commentId: string;
|
|
56
|
+
draftId: string;
|
|
57
|
+
repo: string;
|
|
58
|
+
prNumber: number;
|
|
59
|
+
headSha: string;
|
|
60
|
+
path: string;
|
|
61
|
+
side: GitHubPrReviewDraftCommentSide;
|
|
62
|
+
line: number;
|
|
63
|
+
startLine: number | null;
|
|
64
|
+
startSide: GitHubPrReviewDraftCommentSide | null;
|
|
65
|
+
severity: GitHubPrReviewNeonSeedSeverity;
|
|
66
|
+
summary: string;
|
|
67
|
+
source: string;
|
|
68
|
+
outcome: GitHubPrReviewNeonSeedOutcome | null;
|
|
69
|
+
outcomeAt: string | null;
|
|
70
|
+
seededAt: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type GitHubPrReviewDraft = {
|
|
74
|
+
id: string;
|
|
75
|
+
repo: string;
|
|
76
|
+
prNumber: number;
|
|
77
|
+
headSha: string;
|
|
78
|
+
verdict: GitHubPrReviewVerdict | null;
|
|
79
|
+
body: string | null;
|
|
80
|
+
status: GitHubPrReviewDraftStatus;
|
|
81
|
+
createdAt: string;
|
|
82
|
+
updatedAt: string;
|
|
83
|
+
submittedAt: string | null;
|
|
84
|
+
comments: GitHubPrReviewDraftComment[];
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type GitHubPrReviewSubmitFailure = {
|
|
88
|
+
code:
|
|
89
|
+
| 'invalid-review'
|
|
90
|
+
| 'draft-not-found'
|
|
91
|
+
| 'stale-draft'
|
|
92
|
+
| 'insufficient-scope'
|
|
93
|
+
| 'github-review-submit-failed';
|
|
94
|
+
message: string;
|
|
95
|
+
failingCommentIds?: string[];
|
|
96
|
+
requires?: string[];
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export class GitHubPrReviewSubmitError extends Error {
|
|
100
|
+
constructor(readonly failure: GitHubPrReviewSubmitFailure) {
|
|
101
|
+
super(failure.message);
|
|
102
|
+
this.name = 'GitHubPrReviewSubmitError';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const reviewVerdictSchema = v.picklist([
|
|
107
|
+
'comment',
|
|
108
|
+
'approve',
|
|
109
|
+
'request-changes',
|
|
110
|
+
]);
|
|
111
|
+
const reviewCommentSideSchema = v.picklist(['RIGHT', 'LEFT']);
|
|
112
|
+
const reviewCommentOriginSchema = v.picklist(['human', 'neon']);
|
|
113
|
+
const reviewNeonSeedSeveritySchema = v.picklist([
|
|
114
|
+
'critical',
|
|
115
|
+
'major',
|
|
116
|
+
'minor',
|
|
117
|
+
'nit',
|
|
118
|
+
]);
|
|
119
|
+
const reviewNeonSeedOutcomeSchema = v.picklist([
|
|
120
|
+
'submitted',
|
|
121
|
+
'skipped',
|
|
122
|
+
'deleted',
|
|
123
|
+
]);
|
|
124
|
+
const draftStatusSchema = v.picklist(['draft', 'submitted', 'discarded']);
|
|
125
|
+
|
|
126
|
+
const draftRowSchema = v.object({
|
|
127
|
+
id: v.string(),
|
|
128
|
+
repo: v.string(),
|
|
129
|
+
pr_number: v.number(),
|
|
130
|
+
head_sha: v.string(),
|
|
131
|
+
verdict: v.nullable(reviewVerdictSchema),
|
|
132
|
+
body: v.nullable(v.string()),
|
|
133
|
+
status: draftStatusSchema,
|
|
134
|
+
created_at: v.string(),
|
|
135
|
+
updated_at: v.string(),
|
|
136
|
+
submitted_at: v.nullable(v.string()),
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const draftCommentRowSchema = v.object({
|
|
140
|
+
id: v.string(),
|
|
141
|
+
draft_id: v.string(),
|
|
142
|
+
path: v.string(),
|
|
143
|
+
side: reviewCommentSideSchema,
|
|
144
|
+
line: v.number(),
|
|
145
|
+
start_line: v.nullable(v.number()),
|
|
146
|
+
start_side: v.nullable(reviewCommentSideSchema),
|
|
147
|
+
body: v.string(),
|
|
148
|
+
origin: reviewCommentOriginSchema,
|
|
149
|
+
created_at: v.string(),
|
|
150
|
+
updated_at: v.string(),
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const neonSeedRowSchema = v.object({
|
|
154
|
+
comment_id: v.string(),
|
|
155
|
+
draft_id: v.string(),
|
|
156
|
+
repo: v.string(),
|
|
157
|
+
pr_number: v.number(),
|
|
158
|
+
head_sha: v.string(),
|
|
159
|
+
path: v.string(),
|
|
160
|
+
side: reviewCommentSideSchema,
|
|
161
|
+
line: v.number(),
|
|
162
|
+
start_line: v.nullable(v.number()),
|
|
163
|
+
start_side: v.nullable(reviewCommentSideSchema),
|
|
164
|
+
severity: reviewNeonSeedSeveritySchema,
|
|
165
|
+
summary: v.string(),
|
|
166
|
+
source: v.string(),
|
|
167
|
+
outcome: v.nullable(reviewNeonSeedOutcomeSchema),
|
|
168
|
+
outcome_at: v.nullable(v.string()),
|
|
169
|
+
seeded_at: v.string(),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
const replyReviewThreadMutation = `
|
|
173
|
+
mutation NeondeckReplyPullRequestReviewThread($threadId: ID!, $body: String!) {
|
|
174
|
+
addPullRequestReviewThreadReply(input: { pullRequestReviewThreadId: $threadId, body: $body }) {
|
|
175
|
+
comment {
|
|
176
|
+
id
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
`;
|
|
181
|
+
|
|
182
|
+
const resolveReviewThreadMutation = `
|
|
183
|
+
mutation NeondeckResolvePullRequestReviewThread($threadId: ID!) {
|
|
184
|
+
resolveReviewThread(input: { threadId: $threadId }) {
|
|
185
|
+
thread {
|
|
186
|
+
id
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
`;
|
|
191
|
+
|
|
192
|
+
const unresolveReviewThreadMutation = `
|
|
193
|
+
mutation NeondeckUnresolvePullRequestReviewThread($threadId: ID!) {
|
|
194
|
+
unresolveReviewThread(input: { threadId: $threadId }) {
|
|
195
|
+
thread {
|
|
196
|
+
id
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
`;
|
|
201
|
+
|
|
202
|
+
export function readLivePrReviewDraft(options: {
|
|
203
|
+
databasePath: string;
|
|
204
|
+
repo: string;
|
|
205
|
+
prNumber: number;
|
|
206
|
+
}): GitHubPrReviewDraft | null {
|
|
207
|
+
const database = openDb(options.databasePath);
|
|
208
|
+
try {
|
|
209
|
+
const row = database
|
|
210
|
+
.prepare(
|
|
211
|
+
`
|
|
212
|
+
SELECT *
|
|
213
|
+
FROM pr_review_drafts
|
|
214
|
+
WHERE repo = ?
|
|
215
|
+
AND pr_number = ?
|
|
216
|
+
AND status = 'draft'
|
|
217
|
+
ORDER BY updated_at DESC
|
|
218
|
+
LIMIT 1;
|
|
219
|
+
`,
|
|
220
|
+
)
|
|
221
|
+
.get(options.repo, options.prNumber);
|
|
222
|
+
return row ? readDraftWithComments(database, row) : null;
|
|
223
|
+
} finally {
|
|
224
|
+
database.close();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function readPrReviewDraft(options: {
|
|
229
|
+
databasePath: string;
|
|
230
|
+
draftId: string;
|
|
231
|
+
}): GitHubPrReviewDraft | null {
|
|
232
|
+
const database = openDb(options.databasePath);
|
|
233
|
+
try {
|
|
234
|
+
const row = database
|
|
235
|
+
.prepare('SELECT * FROM pr_review_drafts WHERE id = ?;')
|
|
236
|
+
.get(options.draftId);
|
|
237
|
+
return row ? readDraftWithComments(database, row) : null;
|
|
238
|
+
} finally {
|
|
239
|
+
database.close();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function readPrReviewDraftForComment(options: {
|
|
244
|
+
databasePath: string;
|
|
245
|
+
commentId: string;
|
|
246
|
+
}): GitHubPrReviewDraft | null {
|
|
247
|
+
const database = openDb(options.databasePath);
|
|
248
|
+
try {
|
|
249
|
+
const row = database
|
|
250
|
+
.prepare('SELECT draft_id FROM pr_review_draft_comments WHERE id = ?;')
|
|
251
|
+
.get(options.commentId) as { draft_id?: unknown } | undefined;
|
|
252
|
+
const draftId = typeof row?.draft_id === 'string' ? row.draft_id : null;
|
|
253
|
+
return draftId ? readDraftWithCommentsById(database, draftId) : null;
|
|
254
|
+
} finally {
|
|
255
|
+
database.close();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export function upsertPrReviewDraft(options: {
|
|
260
|
+
databasePath: string;
|
|
261
|
+
repo: string;
|
|
262
|
+
prNumber: number;
|
|
263
|
+
headSha: string;
|
|
264
|
+
verdict?: GitHubPrReviewVerdict | null;
|
|
265
|
+
body?: string | null;
|
|
266
|
+
reanchorHeadSha?: boolean;
|
|
267
|
+
}): GitHubPrReviewDraft {
|
|
268
|
+
const database = openDb(options.databasePath);
|
|
269
|
+
const now = new Date().toISOString();
|
|
270
|
+
const body = normalizeNullableBody(options.body);
|
|
271
|
+
try {
|
|
272
|
+
const existing = database
|
|
273
|
+
.prepare(
|
|
274
|
+
`
|
|
275
|
+
SELECT *
|
|
276
|
+
FROM pr_review_drafts
|
|
277
|
+
WHERE repo = ?
|
|
278
|
+
AND pr_number = ?
|
|
279
|
+
AND status = 'draft'
|
|
280
|
+
LIMIT 1;
|
|
281
|
+
`,
|
|
282
|
+
)
|
|
283
|
+
.get(options.repo, options.prNumber);
|
|
284
|
+
|
|
285
|
+
if (existing) {
|
|
286
|
+
return updateExistingReviewDraft(database, existing, options, now);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const id = randomUUID();
|
|
290
|
+
try {
|
|
291
|
+
database
|
|
292
|
+
.prepare(
|
|
293
|
+
`
|
|
294
|
+
INSERT INTO pr_review_drafts (
|
|
295
|
+
id,
|
|
296
|
+
repo,
|
|
297
|
+
pr_number,
|
|
298
|
+
head_sha,
|
|
299
|
+
verdict,
|
|
300
|
+
body,
|
|
301
|
+
status,
|
|
302
|
+
created_at,
|
|
303
|
+
updated_at
|
|
304
|
+
)
|
|
305
|
+
VALUES (?, ?, ?, ?, ?, ?, 'draft', ?, ?);
|
|
306
|
+
`,
|
|
307
|
+
)
|
|
308
|
+
.run(
|
|
309
|
+
id,
|
|
310
|
+
options.repo,
|
|
311
|
+
options.prNumber,
|
|
312
|
+
options.headSha,
|
|
313
|
+
options.verdict ?? null,
|
|
314
|
+
body,
|
|
315
|
+
now,
|
|
316
|
+
now,
|
|
317
|
+
);
|
|
318
|
+
} catch (error) {
|
|
319
|
+
if (!isUniqueConstraintError(error)) throw error;
|
|
320
|
+
const winner = database
|
|
321
|
+
.prepare(
|
|
322
|
+
`
|
|
323
|
+
SELECT *
|
|
324
|
+
FROM pr_review_drafts
|
|
325
|
+
WHERE repo = ?
|
|
326
|
+
AND pr_number = ?
|
|
327
|
+
AND status = 'draft'
|
|
328
|
+
LIMIT 1;
|
|
329
|
+
`,
|
|
330
|
+
)
|
|
331
|
+
.get(options.repo, options.prNumber);
|
|
332
|
+
if (!winner) throw error;
|
|
333
|
+
return updateExistingReviewDraft(database, winner, options, now);
|
|
334
|
+
}
|
|
335
|
+
return readDraftWithCommentsById(database, id);
|
|
336
|
+
} finally {
|
|
337
|
+
database.close();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export function discardPrReviewDraft(options: {
|
|
342
|
+
databasePath: string;
|
|
343
|
+
repo: string;
|
|
344
|
+
prNumber: number;
|
|
345
|
+
}): GitHubPrReviewDraft | null {
|
|
346
|
+
const database = openDb(options.databasePath);
|
|
347
|
+
const now = new Date().toISOString();
|
|
348
|
+
try {
|
|
349
|
+
const row = database
|
|
350
|
+
.prepare(
|
|
351
|
+
`
|
|
352
|
+
SELECT *
|
|
353
|
+
FROM pr_review_drafts
|
|
354
|
+
WHERE repo = ?
|
|
355
|
+
AND pr_number = ?
|
|
356
|
+
AND status = 'draft'
|
|
357
|
+
LIMIT 1;
|
|
358
|
+
`,
|
|
359
|
+
)
|
|
360
|
+
.get(options.repo, options.prNumber);
|
|
361
|
+
if (!row) return null;
|
|
362
|
+
const draft = readDraftRow(row);
|
|
363
|
+
database
|
|
364
|
+
.prepare(
|
|
365
|
+
`
|
|
366
|
+
UPDATE pr_review_drafts
|
|
367
|
+
SET status = 'discarded',
|
|
368
|
+
updated_at = ?
|
|
369
|
+
WHERE id = ?;
|
|
370
|
+
`,
|
|
371
|
+
)
|
|
372
|
+
.run(now, draft.id);
|
|
373
|
+
return readDraftWithCommentsById(database, draft.id);
|
|
374
|
+
} finally {
|
|
375
|
+
database.close();
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export function addPrReviewDraftComment(options: {
|
|
380
|
+
databasePath: string;
|
|
381
|
+
draftId: string;
|
|
382
|
+
path: string;
|
|
383
|
+
side: GitHubPrReviewDraftCommentSide;
|
|
384
|
+
line: number;
|
|
385
|
+
startLine?: number | null;
|
|
386
|
+
startSide?: GitHubPrReviewDraftCommentSide | null;
|
|
387
|
+
body: string;
|
|
388
|
+
origin?: GitHubPrReviewDraftCommentOrigin;
|
|
389
|
+
}): GitHubPrReviewDraft {
|
|
390
|
+
const database = openDb(options.databasePath);
|
|
391
|
+
const now = new Date().toISOString();
|
|
392
|
+
try {
|
|
393
|
+
assertDraftIsLive(database, options.draftId);
|
|
394
|
+
assertValidReviewCommentAnchor(options);
|
|
395
|
+
database
|
|
396
|
+
.prepare(
|
|
397
|
+
`
|
|
398
|
+
INSERT INTO pr_review_draft_comments (
|
|
399
|
+
id,
|
|
400
|
+
draft_id,
|
|
401
|
+
path,
|
|
402
|
+
side,
|
|
403
|
+
line,
|
|
404
|
+
start_line,
|
|
405
|
+
start_side,
|
|
406
|
+
body,
|
|
407
|
+
origin,
|
|
408
|
+
created_at,
|
|
409
|
+
updated_at
|
|
410
|
+
)
|
|
411
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
|
412
|
+
`,
|
|
413
|
+
)
|
|
414
|
+
.run(
|
|
415
|
+
randomUUID(),
|
|
416
|
+
options.draftId,
|
|
417
|
+
options.path,
|
|
418
|
+
options.side,
|
|
419
|
+
options.line,
|
|
420
|
+
options.startLine ?? null,
|
|
421
|
+
options.startSide ?? null,
|
|
422
|
+
options.body.trim(),
|
|
423
|
+
options.origin ?? 'human',
|
|
424
|
+
now,
|
|
425
|
+
now,
|
|
426
|
+
);
|
|
427
|
+
touchDraft(database, options.draftId, now);
|
|
428
|
+
return readDraftWithCommentsById(database, options.draftId);
|
|
429
|
+
} finally {
|
|
430
|
+
database.close();
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export function updatePrReviewDraftComment(options: {
|
|
435
|
+
databasePath: string;
|
|
436
|
+
commentId: string;
|
|
437
|
+
body: string;
|
|
438
|
+
path?: string;
|
|
439
|
+
side?: GitHubPrReviewDraftCommentSide;
|
|
440
|
+
line?: number;
|
|
441
|
+
startLine?: number | null;
|
|
442
|
+
startSide?: GitHubPrReviewDraftCommentSide | null;
|
|
443
|
+
}): GitHubPrReviewDraft {
|
|
444
|
+
const database = openDb(options.databasePath);
|
|
445
|
+
const now = new Date().toISOString();
|
|
446
|
+
try {
|
|
447
|
+
const row = database
|
|
448
|
+
.prepare('SELECT draft_id FROM pr_review_draft_comments WHERE id = ?;')
|
|
449
|
+
.get(options.commentId) as { draft_id?: unknown } | undefined;
|
|
450
|
+
const draftId = typeof row?.draft_id === 'string' ? row.draft_id : null;
|
|
451
|
+
if (!draftId) throw new Error('Review draft comment not found.');
|
|
452
|
+
assertDraftIsLive(database, draftId);
|
|
453
|
+
const existing = database
|
|
454
|
+
.prepare(
|
|
455
|
+
`
|
|
456
|
+
SELECT path, side, line, start_line, start_side
|
|
457
|
+
FROM pr_review_draft_comments
|
|
458
|
+
WHERE id = ?;
|
|
459
|
+
`,
|
|
460
|
+
)
|
|
461
|
+
.get(options.commentId) as
|
|
462
|
+
| {
|
|
463
|
+
path: string;
|
|
464
|
+
side: GitHubPrReviewDraftCommentSide;
|
|
465
|
+
line: number;
|
|
466
|
+
start_line: number | null;
|
|
467
|
+
start_side: GitHubPrReviewDraftCommentSide | null;
|
|
468
|
+
}
|
|
469
|
+
| undefined;
|
|
470
|
+
if (!existing) throw new Error('Review draft comment not found.');
|
|
471
|
+
const nextAnchor = {
|
|
472
|
+
path: options.path ?? existing.path,
|
|
473
|
+
side: options.side ?? existing.side,
|
|
474
|
+
line: options.line ?? existing.line,
|
|
475
|
+
startLine:
|
|
476
|
+
'startLine' in options
|
|
477
|
+
? (options.startLine ?? null)
|
|
478
|
+
: existing.start_line,
|
|
479
|
+
startSide:
|
|
480
|
+
'startSide' in options
|
|
481
|
+
? (options.startSide ?? null)
|
|
482
|
+
: existing.start_side,
|
|
483
|
+
};
|
|
484
|
+
assertValidReviewCommentAnchor(nextAnchor);
|
|
485
|
+
database
|
|
486
|
+
.prepare(
|
|
487
|
+
`
|
|
488
|
+
UPDATE pr_review_draft_comments
|
|
489
|
+
SET path = ?,
|
|
490
|
+
side = ?,
|
|
491
|
+
line = ?,
|
|
492
|
+
start_line = ?,
|
|
493
|
+
start_side = ?,
|
|
494
|
+
body = ?,
|
|
495
|
+
updated_at = ?
|
|
496
|
+
WHERE id = ?;
|
|
497
|
+
`,
|
|
498
|
+
)
|
|
499
|
+
.run(
|
|
500
|
+
nextAnchor.path,
|
|
501
|
+
nextAnchor.side,
|
|
502
|
+
nextAnchor.line,
|
|
503
|
+
nextAnchor.startLine,
|
|
504
|
+
nextAnchor.startSide,
|
|
505
|
+
options.body.trim(),
|
|
506
|
+
now,
|
|
507
|
+
options.commentId,
|
|
508
|
+
);
|
|
509
|
+
touchDraft(database, draftId, now);
|
|
510
|
+
return readDraftWithCommentsById(database, draftId);
|
|
511
|
+
} finally {
|
|
512
|
+
database.close();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export function deletePrReviewDraftComment(options: {
|
|
517
|
+
databasePath: string;
|
|
518
|
+
commentId: string;
|
|
519
|
+
}): GitHubPrReviewDraft {
|
|
520
|
+
const database = openDb(options.databasePath);
|
|
521
|
+
const now = new Date().toISOString();
|
|
522
|
+
try {
|
|
523
|
+
const row = database
|
|
524
|
+
.prepare('SELECT draft_id FROM pr_review_draft_comments WHERE id = ?;')
|
|
525
|
+
.get(options.commentId) as { draft_id?: unknown } | undefined;
|
|
526
|
+
const draftId = typeof row?.draft_id === 'string' ? row.draft_id : null;
|
|
527
|
+
if (!draftId) throw new Error('Review draft comment not found.');
|
|
528
|
+
assertDraftIsLive(database, draftId);
|
|
529
|
+
database
|
|
530
|
+
.prepare('DELETE FROM pr_review_draft_comments WHERE id = ?;')
|
|
531
|
+
.run(options.commentId);
|
|
532
|
+
touchDraft(database, draftId, now);
|
|
533
|
+
return readDraftWithCommentsById(database, draftId);
|
|
534
|
+
} finally {
|
|
535
|
+
database.close();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export function recordPrReviewNeonSeed(options: {
|
|
540
|
+
databasePath: string;
|
|
541
|
+
draft: GitHubPrReviewDraft;
|
|
542
|
+
comment: GitHubPrReviewDraftComment;
|
|
543
|
+
severity: GitHubPrReviewNeonSeedSeverity;
|
|
544
|
+
summary: string;
|
|
545
|
+
source: string;
|
|
546
|
+
}): GitHubPrReviewNeonSeededComment {
|
|
547
|
+
const database = openDb(options.databasePath);
|
|
548
|
+
const now = new Date().toISOString();
|
|
549
|
+
try {
|
|
550
|
+
database
|
|
551
|
+
.prepare(
|
|
552
|
+
`
|
|
553
|
+
INSERT OR IGNORE INTO pr_review_neon_seeded_comments (
|
|
554
|
+
comment_id,
|
|
555
|
+
draft_id,
|
|
556
|
+
repo,
|
|
557
|
+
pr_number,
|
|
558
|
+
head_sha,
|
|
559
|
+
path,
|
|
560
|
+
side,
|
|
561
|
+
line,
|
|
562
|
+
start_line,
|
|
563
|
+
start_side,
|
|
564
|
+
severity,
|
|
565
|
+
summary,
|
|
566
|
+
source,
|
|
567
|
+
seeded_at
|
|
568
|
+
)
|
|
569
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);
|
|
570
|
+
`,
|
|
571
|
+
)
|
|
572
|
+
.run(
|
|
573
|
+
options.comment.id,
|
|
574
|
+
options.draft.id,
|
|
575
|
+
options.draft.repo,
|
|
576
|
+
options.draft.prNumber,
|
|
577
|
+
options.draft.headSha,
|
|
578
|
+
options.comment.path,
|
|
579
|
+
options.comment.side,
|
|
580
|
+
options.comment.line,
|
|
581
|
+
options.comment.startLine,
|
|
582
|
+
options.comment.startSide,
|
|
583
|
+
options.severity,
|
|
584
|
+
truncateSeedSummary(options.summary),
|
|
585
|
+
options.source,
|
|
586
|
+
now,
|
|
587
|
+
);
|
|
588
|
+
return readNeonSeedByCommentId(database, options.comment.id);
|
|
589
|
+
} finally {
|
|
590
|
+
database.close();
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export function deletePrReviewNeonSeedsForComments(options: {
|
|
595
|
+
databasePath: string;
|
|
596
|
+
commentIds: string[];
|
|
597
|
+
}) {
|
|
598
|
+
const commentIds = [...new Set(options.commentIds.filter(Boolean))];
|
|
599
|
+
if (commentIds.length === 0) return 0;
|
|
600
|
+
const database = openDb(options.databasePath);
|
|
601
|
+
try {
|
|
602
|
+
const placeholders = commentIds.map(() => '?').join(', ');
|
|
603
|
+
const result = database
|
|
604
|
+
.prepare(
|
|
605
|
+
`
|
|
606
|
+
DELETE FROM pr_review_neon_seeded_comments
|
|
607
|
+
WHERE comment_id IN (${placeholders});
|
|
608
|
+
`,
|
|
609
|
+
)
|
|
610
|
+
.run(...commentIds);
|
|
611
|
+
return Number(result.changes);
|
|
612
|
+
} finally {
|
|
613
|
+
database.close();
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
export async function submitPullRequestReview(options: {
|
|
618
|
+
token: string;
|
|
619
|
+
owner: string;
|
|
620
|
+
repo: string;
|
|
621
|
+
number: number;
|
|
622
|
+
databasePath: string;
|
|
623
|
+
paths: RuntimePaths;
|
|
624
|
+
draftId: string;
|
|
625
|
+
headSha: string;
|
|
626
|
+
commentIds?: string[];
|
|
627
|
+
fetchHeadSha?: (options: {
|
|
628
|
+
token: string;
|
|
629
|
+
owner: string;
|
|
630
|
+
repo: string;
|
|
631
|
+
number: number;
|
|
632
|
+
}) => Promise<string | null | undefined>;
|
|
633
|
+
}): Promise<{
|
|
634
|
+
draft: GitHubPrReviewDraft;
|
|
635
|
+
review: GitHubSubmittedPullRequestReview;
|
|
636
|
+
}> {
|
|
637
|
+
const draft = readPrReviewDraft({
|
|
638
|
+
databasePath: options.databasePath,
|
|
639
|
+
draftId: options.draftId,
|
|
640
|
+
});
|
|
641
|
+
if (!draft || draft.status !== 'draft') {
|
|
642
|
+
throw new GitHubPrReviewSubmitError({
|
|
643
|
+
code: 'draft-not-found',
|
|
644
|
+
message: 'Review draft was not found.',
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
const expectedRepo = `${options.owner}/${options.repo}`;
|
|
649
|
+
if (draft.repo !== expectedRepo || draft.prNumber !== options.number) {
|
|
650
|
+
throw new GitHubPrReviewSubmitError({
|
|
651
|
+
code: 'draft-not-found',
|
|
652
|
+
message: 'Review draft does not belong to this pull request.',
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
const currentHeadSha = await readCurrentPullRequestHeadSha(options);
|
|
657
|
+
if (draft.headSha !== currentHeadSha || options.headSha !== currentHeadSha) {
|
|
658
|
+
throw new GitHubPrReviewSubmitError({
|
|
659
|
+
code: 'stale-draft',
|
|
660
|
+
message: 'PR changed since this review draft was anchored.',
|
|
661
|
+
failingCommentIds: draft.comments.map((comment) => comment.id),
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const selectedCommentIds = options.commentIds
|
|
666
|
+
? new Set(options.commentIds)
|
|
667
|
+
: null;
|
|
668
|
+
const comments =
|
|
669
|
+
selectedCommentIds === null
|
|
670
|
+
? draft.comments
|
|
671
|
+
: draft.comments.filter((comment) => selectedCommentIds.has(comment.id));
|
|
672
|
+
const missingCommentIds = options.commentIds
|
|
673
|
+
? options.commentIds.filter(
|
|
674
|
+
(id) => !draft.comments.some((comment) => comment.id === id),
|
|
675
|
+
)
|
|
676
|
+
: [];
|
|
677
|
+
if (missingCommentIds.length > 0) {
|
|
678
|
+
throw new GitHubPrReviewSubmitError({
|
|
679
|
+
code: 'invalid-review',
|
|
680
|
+
message: 'Review draft comment ids do not belong to this draft.',
|
|
681
|
+
failingCommentIds: missingCommentIds,
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
const verdict = draft.verdict ?? 'comment';
|
|
686
|
+
const body = draft.body?.trim() ?? '';
|
|
687
|
+
if (verdict !== 'approve' && body.length === 0 && comments.length === 0) {
|
|
688
|
+
throw new GitHubPrReviewSubmitError({
|
|
689
|
+
code: 'invalid-review',
|
|
690
|
+
message: 'Review body or inline comments are required.',
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
let review: GitHubSubmittedPullRequestReview;
|
|
695
|
+
try {
|
|
696
|
+
review = await createPullRequestReview({
|
|
697
|
+
token: options.token,
|
|
698
|
+
owner: options.owner,
|
|
699
|
+
repo: options.repo,
|
|
700
|
+
number: options.number,
|
|
701
|
+
headSha: currentHeadSha,
|
|
702
|
+
verdict,
|
|
703
|
+
body,
|
|
704
|
+
comments,
|
|
705
|
+
});
|
|
706
|
+
} catch (error) {
|
|
707
|
+
const message = errorMessage(error);
|
|
708
|
+
if (isLikelyInsufficientScopeError(error, message)) {
|
|
709
|
+
throw new GitHubPrReviewSubmitError({
|
|
710
|
+
code: 'insufficient-scope',
|
|
711
|
+
message:
|
|
712
|
+
'GitHub token needs pull request write access to submit reviews.',
|
|
713
|
+
requires: ['pull_requests:write'],
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
throw new GitHubPrReviewSubmitError({
|
|
717
|
+
code: 'github-review-submit-failed',
|
|
718
|
+
message,
|
|
719
|
+
failingCommentIds: failingReviewCommentIdsFromGitHubError(
|
|
720
|
+
error,
|
|
721
|
+
comments,
|
|
722
|
+
),
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
const neonDraftOutcome = markNeonDraftSeedOutcomes(
|
|
727
|
+
options.databasePath,
|
|
728
|
+
draft,
|
|
729
|
+
comments,
|
|
730
|
+
);
|
|
731
|
+
const submitted = markDraftSubmitted(options.databasePath, draft.id);
|
|
732
|
+
await addWorkflowSummary(
|
|
733
|
+
{
|
|
734
|
+
workflow: 'github_pr_review',
|
|
735
|
+
runId: `github-pr-review:${draft.repo}#${draft.prNumber}:${review.id}`,
|
|
736
|
+
status: 'submitted',
|
|
737
|
+
summary: {
|
|
738
|
+
repo: draft.repo,
|
|
739
|
+
prNumber: draft.prNumber,
|
|
740
|
+
verdict,
|
|
741
|
+
commentCount: comments.length,
|
|
742
|
+
skippedCommentCount: draft.comments.length - comments.length,
|
|
743
|
+
neonDraftOutcome,
|
|
744
|
+
reviewUrl: review.url,
|
|
745
|
+
headSha: currentHeadSha,
|
|
746
|
+
},
|
|
747
|
+
},
|
|
748
|
+
options.paths,
|
|
749
|
+
);
|
|
750
|
+
|
|
751
|
+
return { draft: submitted, review };
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
function markNeonDraftSeedOutcomes(
|
|
755
|
+
databasePath: string,
|
|
756
|
+
draft: GitHubPrReviewDraft,
|
|
757
|
+
submittedComments: GitHubPrReviewDraftComment[],
|
|
758
|
+
) {
|
|
759
|
+
const database = openDb(databasePath);
|
|
760
|
+
try {
|
|
761
|
+
return summarizeAndPersistNeonDraftOutcome(
|
|
762
|
+
database,
|
|
763
|
+
draft,
|
|
764
|
+
submittedComments,
|
|
765
|
+
);
|
|
766
|
+
} finally {
|
|
767
|
+
database.close();
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
function summarizeAndPersistNeonDraftOutcome(
|
|
772
|
+
database: ReturnType<typeof openDb>,
|
|
773
|
+
draft: GitHubPrReviewDraft,
|
|
774
|
+
submittedComments: GitHubPrReviewDraftComment[],
|
|
775
|
+
) {
|
|
776
|
+
const seeds = readNeonSeedsForDraft(database, draft.id);
|
|
777
|
+
const survivingCommentsById = new Map(
|
|
778
|
+
draft.comments.map((comment) => [comment.id, comment]),
|
|
779
|
+
);
|
|
780
|
+
const submittedCommentsById = new Map(
|
|
781
|
+
submittedComments.map((comment) => [comment.id, comment]),
|
|
782
|
+
);
|
|
783
|
+
const now = new Date().toISOString();
|
|
784
|
+
const submittedSeeds = [];
|
|
785
|
+
const skippedSeeds = [];
|
|
786
|
+
const deletedSeeds = [];
|
|
787
|
+
const severityCounts: Record<
|
|
788
|
+
string,
|
|
789
|
+
{
|
|
790
|
+
seeded: number;
|
|
791
|
+
submitted: number;
|
|
792
|
+
skipped: number;
|
|
793
|
+
deleted: number;
|
|
794
|
+
editedSubmitted: number;
|
|
795
|
+
}
|
|
796
|
+
> = {};
|
|
797
|
+
|
|
798
|
+
for (const seed of seeds) {
|
|
799
|
+
const severity = severityCounts[seed.severity] ?? {
|
|
800
|
+
seeded: 0,
|
|
801
|
+
submitted: 0,
|
|
802
|
+
skipped: 0,
|
|
803
|
+
deleted: 0,
|
|
804
|
+
editedSubmitted: 0,
|
|
805
|
+
};
|
|
806
|
+
severity.seeded += 1;
|
|
807
|
+
severityCounts[seed.severity] = severity;
|
|
808
|
+
|
|
809
|
+
const submittedComment = submittedCommentsById.get(seed.commentId);
|
|
810
|
+
const outcome: GitHubPrReviewNeonSeedOutcome = submittedComment
|
|
811
|
+
? 'submitted'
|
|
812
|
+
: survivingCommentsById.has(seed.commentId)
|
|
813
|
+
? 'skipped'
|
|
814
|
+
: 'deleted';
|
|
815
|
+
database
|
|
816
|
+
.prepare(
|
|
817
|
+
`
|
|
818
|
+
UPDATE pr_review_neon_seeded_comments
|
|
819
|
+
SET outcome = ?,
|
|
820
|
+
outcome_at = ?
|
|
821
|
+
WHERE comment_id = ?;
|
|
822
|
+
`,
|
|
823
|
+
)
|
|
824
|
+
.run(outcome, now, seed.commentId);
|
|
825
|
+
|
|
826
|
+
if (outcome === 'submitted') {
|
|
827
|
+
if (!submittedComment) continue;
|
|
828
|
+
submittedSeeds.push(seed);
|
|
829
|
+
severity.submitted += 1;
|
|
830
|
+
if (submittedComment.updatedAt !== submittedComment.createdAt) {
|
|
831
|
+
severity.editedSubmitted += 1;
|
|
832
|
+
}
|
|
833
|
+
continue;
|
|
834
|
+
}
|
|
835
|
+
if (outcome === 'skipped') {
|
|
836
|
+
skippedSeeds.push(seed);
|
|
837
|
+
severity.skipped += 1;
|
|
838
|
+
continue;
|
|
839
|
+
}
|
|
840
|
+
deletedSeeds.push(seed);
|
|
841
|
+
severity.deleted += 1;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
const editedSubmitted = submittedSeeds.filter((seed) => {
|
|
845
|
+
const comment = submittedCommentsById.get(seed.commentId);
|
|
846
|
+
return Boolean(comment && comment.updatedAt !== comment.createdAt);
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
return {
|
|
850
|
+
seededNeonCommentCount: seeds.length,
|
|
851
|
+
survivingNeonCommentCount: seeds.filter((seed) =>
|
|
852
|
+
survivingCommentsById.has(seed.commentId),
|
|
853
|
+
).length,
|
|
854
|
+
submittedNeonCommentCount: submittedSeeds.length,
|
|
855
|
+
skippedNeonCommentCount: skippedSeeds.length,
|
|
856
|
+
deletedNeonCommentCount: deletedSeeds.length,
|
|
857
|
+
skippedOrDeletedNeonCommentCount: skippedSeeds.length + deletedSeeds.length,
|
|
858
|
+
editedSubmittedNeonCommentCount: editedSubmitted.length,
|
|
859
|
+
submittedNeonCommentIds: submittedSeeds.map((seed) => seed.commentId),
|
|
860
|
+
skippedNeonCommentIds: skippedSeeds.map((seed) => seed.commentId),
|
|
861
|
+
deletedNeonCommentIds: deletedSeeds.map((seed) => seed.commentId),
|
|
862
|
+
bySeverity: severityCounts,
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
function readNeonSeedByCommentId(
|
|
867
|
+
database: ReturnType<typeof openDb>,
|
|
868
|
+
commentId: string,
|
|
869
|
+
) {
|
|
870
|
+
const row = database
|
|
871
|
+
.prepare(
|
|
872
|
+
`
|
|
873
|
+
SELECT *
|
|
874
|
+
FROM pr_review_neon_seeded_comments
|
|
875
|
+
WHERE comment_id = ?
|
|
876
|
+
LIMIT 1;
|
|
877
|
+
`,
|
|
878
|
+
)
|
|
879
|
+
.get(commentId);
|
|
880
|
+
if (!row) throw new Error('Neon review seed ledger row was not recorded.');
|
|
881
|
+
return readNeonSeedRow(row);
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
function readNeonSeedsForDraft(
|
|
885
|
+
database: ReturnType<typeof openDb>,
|
|
886
|
+
draftId: string,
|
|
887
|
+
) {
|
|
888
|
+
return database
|
|
889
|
+
.prepare(
|
|
890
|
+
`
|
|
891
|
+
SELECT *
|
|
892
|
+
FROM pr_review_neon_seeded_comments
|
|
893
|
+
WHERE draft_id = ?
|
|
894
|
+
ORDER BY seeded_at ASC;
|
|
895
|
+
`,
|
|
896
|
+
)
|
|
897
|
+
.all(draftId)
|
|
898
|
+
.map(readNeonSeedRow);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
function readNeonSeedRow(row: unknown): GitHubPrReviewNeonSeededComment {
|
|
902
|
+
const parsed = v.parse(neonSeedRowSchema, row);
|
|
903
|
+
return {
|
|
904
|
+
commentId: parsed.comment_id,
|
|
905
|
+
draftId: parsed.draft_id,
|
|
906
|
+
repo: parsed.repo,
|
|
907
|
+
prNumber: parsed.pr_number,
|
|
908
|
+
headSha: parsed.head_sha,
|
|
909
|
+
path: parsed.path,
|
|
910
|
+
side: parsed.side,
|
|
911
|
+
line: parsed.line,
|
|
912
|
+
startLine: parsed.start_line,
|
|
913
|
+
startSide: parsed.start_side,
|
|
914
|
+
severity: parsed.severity,
|
|
915
|
+
summary: parsed.summary,
|
|
916
|
+
source: parsed.source,
|
|
917
|
+
outcome: parsed.outcome,
|
|
918
|
+
outcomeAt: parsed.outcome_at,
|
|
919
|
+
seededAt: parsed.seeded_at,
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
function truncateSeedSummary(value: string) {
|
|
924
|
+
const trimmed = value.trim();
|
|
925
|
+
return trimmed.length > 1_000 ? `${trimmed.slice(0, 1_000)}...` : trimmed;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
export async function replyToPullRequestReviewThread(options: {
|
|
929
|
+
token: string;
|
|
930
|
+
threadId: string;
|
|
931
|
+
body: string;
|
|
932
|
+
}): Promise<GitHubPullRequestReviewThread> {
|
|
933
|
+
try {
|
|
934
|
+
await githubGraphqlFetch(options.token, replyReviewThreadMutation, {
|
|
935
|
+
threadId: options.threadId,
|
|
936
|
+
body: options.body,
|
|
937
|
+
});
|
|
938
|
+
} catch (error) {
|
|
939
|
+
throw rewriteThreadMutationError(error);
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
return fetchPullRequestReviewThread({
|
|
943
|
+
token: options.token,
|
|
944
|
+
threadId: options.threadId,
|
|
945
|
+
});
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
export async function resolvePullRequestReviewThread(options: {
|
|
949
|
+
token: string;
|
|
950
|
+
threadId: string;
|
|
951
|
+
}): Promise<GitHubPullRequestReviewThread> {
|
|
952
|
+
try {
|
|
953
|
+
await githubGraphqlFetch(options.token, resolveReviewThreadMutation, {
|
|
954
|
+
threadId: options.threadId,
|
|
955
|
+
});
|
|
956
|
+
} catch (error) {
|
|
957
|
+
throw rewriteThreadMutationError(error);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
return fetchPullRequestReviewThread({
|
|
961
|
+
token: options.token,
|
|
962
|
+
threadId: options.threadId,
|
|
963
|
+
});
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
export async function unresolvePullRequestReviewThread(options: {
|
|
967
|
+
token: string;
|
|
968
|
+
threadId: string;
|
|
969
|
+
}): Promise<GitHubPullRequestReviewThread> {
|
|
970
|
+
try {
|
|
971
|
+
await githubGraphqlFetch(options.token, unresolveReviewThreadMutation, {
|
|
972
|
+
threadId: options.threadId,
|
|
973
|
+
});
|
|
974
|
+
} catch (error) {
|
|
975
|
+
throw rewriteThreadMutationError(error);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
return fetchPullRequestReviewThread({
|
|
979
|
+
token: options.token,
|
|
980
|
+
threadId: options.threadId,
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
export async function fetchPullRequestReviews(options: {
|
|
985
|
+
token: string;
|
|
986
|
+
owner: string;
|
|
987
|
+
repo: string;
|
|
988
|
+
number: number;
|
|
989
|
+
}): Promise<GitHubPullRequestReview[]> {
|
|
990
|
+
return (await fetchPullRequestReviewsWithMetadata(options)).reviews;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
export async function fetchPullRequestReviewsWithMetadata(options: {
|
|
994
|
+
token: string;
|
|
995
|
+
owner: string;
|
|
996
|
+
repo: string;
|
|
997
|
+
number: number;
|
|
998
|
+
}): Promise<{ reviews: GitHubPullRequestReview[]; truncated: boolean }> {
|
|
999
|
+
const reviews: GitHubPullRequestReviewApiItem[] = [];
|
|
1000
|
+
let nextUrl: string | undefined =
|
|
1001
|
+
`https://api.github.com/repos/${encodePathSegment(options.owner)}/${encodePathSegment(options.repo)}/pulls/${options.number}/reviews?per_page=100`;
|
|
1002
|
+
let pageCount = 0;
|
|
1003
|
+
|
|
1004
|
+
while (nextUrl && pageCount < 3) {
|
|
1005
|
+
pageCount += 1;
|
|
1006
|
+
const response = await githubFetch(options.token, nextUrl);
|
|
1007
|
+
const data = v.parse(
|
|
1008
|
+
v.array(githubPullRequestReviewApiItemSchema),
|
|
1009
|
+
await response.json(),
|
|
1010
|
+
);
|
|
1011
|
+
reviews.push(...data);
|
|
1012
|
+
nextUrl = nextLink(response.headers.get('link'));
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
return {
|
|
1016
|
+
reviews: reviews.map((review) => ({
|
|
1017
|
+
id: review.id,
|
|
1018
|
+
nodeId: review.node_id ?? null,
|
|
1019
|
+
state: review.state,
|
|
1020
|
+
authorLogin: review.user?.login ?? null,
|
|
1021
|
+
submittedAt: review.submitted_at ?? null,
|
|
1022
|
+
commitId: review.commit_id ?? null,
|
|
1023
|
+
url: review.html_url ?? null,
|
|
1024
|
+
})),
|
|
1025
|
+
truncated: Boolean(nextUrl),
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
export function requestedChangesStateFromReviews(
|
|
1030
|
+
reviews: GitHubPullRequestReview[],
|
|
1031
|
+
): GitHubPullRequestRequestedChangesState {
|
|
1032
|
+
const relevantStates = new Set([
|
|
1033
|
+
'APPROVED',
|
|
1034
|
+
'CHANGES_REQUESTED',
|
|
1035
|
+
'DISMISSED',
|
|
1036
|
+
]);
|
|
1037
|
+
const history = reviews
|
|
1038
|
+
.filter((review) => relevantStates.has(review.state))
|
|
1039
|
+
.sort(compareReviewAge);
|
|
1040
|
+
const latestByReviewer = Array.from(
|
|
1041
|
+
history
|
|
1042
|
+
.reduce((items, review) => {
|
|
1043
|
+
items.set(review.authorLogin ?? `review:${review.id}`, review);
|
|
1044
|
+
return items;
|
|
1045
|
+
}, new Map<string, GitHubPullRequestReview>())
|
|
1046
|
+
.values(),
|
|
1047
|
+
).sort(compareReviewAge);
|
|
1048
|
+
|
|
1049
|
+
return {
|
|
1050
|
+
active: latestByReviewer.filter(
|
|
1051
|
+
(review) => review.state === 'CHANGES_REQUESTED',
|
|
1052
|
+
),
|
|
1053
|
+
latestByReviewer,
|
|
1054
|
+
history,
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
function compareReviewAge(
|
|
1059
|
+
left: GitHubPullRequestReview,
|
|
1060
|
+
right: GitHubPullRequestReview,
|
|
1061
|
+
) {
|
|
1062
|
+
const leftTime = left.submittedAt ? Date.parse(left.submittedAt) : 0;
|
|
1063
|
+
const rightTime = right.submittedAt ? Date.parse(right.submittedAt) : 0;
|
|
1064
|
+
return leftTime - rightTime || left.id - right.id;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
function readDraftWithComments(
|
|
1068
|
+
database: ReturnType<typeof openDb>,
|
|
1069
|
+
row: unknown,
|
|
1070
|
+
) {
|
|
1071
|
+
const draft = readDraftRow(row);
|
|
1072
|
+
return {
|
|
1073
|
+
...draft,
|
|
1074
|
+
comments: readDraftComments(database, draft.id),
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
function updateExistingReviewDraft(
|
|
1079
|
+
database: ReturnType<typeof openDb>,
|
|
1080
|
+
row: unknown,
|
|
1081
|
+
options: {
|
|
1082
|
+
headSha?: string;
|
|
1083
|
+
verdict?: GitHubPrReviewVerdict | null;
|
|
1084
|
+
body?: string | null;
|
|
1085
|
+
reanchorHeadSha?: boolean;
|
|
1086
|
+
},
|
|
1087
|
+
updatedAt: string,
|
|
1088
|
+
) {
|
|
1089
|
+
const draft = readDraftRow(row);
|
|
1090
|
+
const nextVerdict =
|
|
1091
|
+
'verdict' in options ? (options.verdict ?? null) : draft.verdict;
|
|
1092
|
+
const nextBody =
|
|
1093
|
+
'body' in options ? normalizeNullableBody(options.body) : draft.body;
|
|
1094
|
+
database
|
|
1095
|
+
.prepare(
|
|
1096
|
+
`
|
|
1097
|
+
UPDATE pr_review_drafts
|
|
1098
|
+
SET head_sha = ?,
|
|
1099
|
+
verdict = ?,
|
|
1100
|
+
body = ?,
|
|
1101
|
+
updated_at = ?
|
|
1102
|
+
WHERE id = ?;
|
|
1103
|
+
`,
|
|
1104
|
+
)
|
|
1105
|
+
.run(
|
|
1106
|
+
options.reanchorHeadSha
|
|
1107
|
+
? (options.headSha ?? draft.headSha)
|
|
1108
|
+
: draft.headSha,
|
|
1109
|
+
nextVerdict,
|
|
1110
|
+
nextBody,
|
|
1111
|
+
updatedAt,
|
|
1112
|
+
draft.id,
|
|
1113
|
+
);
|
|
1114
|
+
return readDraftWithCommentsById(database, draft.id);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
function readDraftWithCommentsById(
|
|
1118
|
+
database: ReturnType<typeof openDb>,
|
|
1119
|
+
draftId: string,
|
|
1120
|
+
) {
|
|
1121
|
+
const row = database
|
|
1122
|
+
.prepare('SELECT * FROM pr_review_drafts WHERE id = ?;')
|
|
1123
|
+
.get(draftId);
|
|
1124
|
+
if (!row) throw new Error('Review draft not found.');
|
|
1125
|
+
return readDraftWithComments(database, row);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
function readDraftRow(row: unknown): Omit<GitHubPrReviewDraft, 'comments'> {
|
|
1129
|
+
const parsed = v.parse(draftRowSchema, row);
|
|
1130
|
+
return {
|
|
1131
|
+
id: parsed.id,
|
|
1132
|
+
repo: parsed.repo,
|
|
1133
|
+
prNumber: parsed.pr_number,
|
|
1134
|
+
headSha: parsed.head_sha,
|
|
1135
|
+
verdict: parsed.verdict,
|
|
1136
|
+
body: parsed.body,
|
|
1137
|
+
status: parsed.status,
|
|
1138
|
+
createdAt: parsed.created_at,
|
|
1139
|
+
updatedAt: parsed.updated_at,
|
|
1140
|
+
submittedAt: parsed.submitted_at,
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
function readDraftComments(
|
|
1145
|
+
database: ReturnType<typeof openDb>,
|
|
1146
|
+
draftId: string,
|
|
1147
|
+
): GitHubPrReviewDraftComment[] {
|
|
1148
|
+
return database
|
|
1149
|
+
.prepare(
|
|
1150
|
+
`
|
|
1151
|
+
SELECT *
|
|
1152
|
+
FROM pr_review_draft_comments
|
|
1153
|
+
WHERE draft_id = ?
|
|
1154
|
+
ORDER BY created_at ASC;
|
|
1155
|
+
`,
|
|
1156
|
+
)
|
|
1157
|
+
.all(draftId)
|
|
1158
|
+
.map((row) => {
|
|
1159
|
+
const parsed = v.parse(draftCommentRowSchema, row);
|
|
1160
|
+
return {
|
|
1161
|
+
id: parsed.id,
|
|
1162
|
+
draftId: parsed.draft_id,
|
|
1163
|
+
path: parsed.path,
|
|
1164
|
+
side: parsed.side,
|
|
1165
|
+
line: parsed.line,
|
|
1166
|
+
startLine: parsed.start_line,
|
|
1167
|
+
startSide: parsed.start_side,
|
|
1168
|
+
body: parsed.body,
|
|
1169
|
+
origin: parsed.origin,
|
|
1170
|
+
createdAt: parsed.created_at,
|
|
1171
|
+
updatedAt: parsed.updated_at,
|
|
1172
|
+
};
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function assertDraftIsLive(
|
|
1177
|
+
database: ReturnType<typeof openDb>,
|
|
1178
|
+
draftId: string,
|
|
1179
|
+
) {
|
|
1180
|
+
const row = database
|
|
1181
|
+
.prepare('SELECT status FROM pr_review_drafts WHERE id = ?;')
|
|
1182
|
+
.get(draftId) as { status?: unknown } | undefined;
|
|
1183
|
+
if (row?.status !== 'draft') {
|
|
1184
|
+
throw new Error('Review draft is not editable.');
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
function touchDraft(
|
|
1189
|
+
database: ReturnType<typeof openDb>,
|
|
1190
|
+
draftId: string,
|
|
1191
|
+
updatedAt: string,
|
|
1192
|
+
) {
|
|
1193
|
+
database
|
|
1194
|
+
.prepare('UPDATE pr_review_drafts SET updated_at = ? WHERE id = ?;')
|
|
1195
|
+
.run(updatedAt, draftId);
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
function markDraftSubmitted(
|
|
1199
|
+
databasePath: string,
|
|
1200
|
+
draftId: string,
|
|
1201
|
+
): GitHubPrReviewDraft {
|
|
1202
|
+
const database = openDb(databasePath);
|
|
1203
|
+
const now = new Date().toISOString();
|
|
1204
|
+
try {
|
|
1205
|
+
database
|
|
1206
|
+
.prepare(
|
|
1207
|
+
`
|
|
1208
|
+
UPDATE pr_review_drafts
|
|
1209
|
+
SET status = 'submitted',
|
|
1210
|
+
submitted_at = ?,
|
|
1211
|
+
updated_at = ?
|
|
1212
|
+
WHERE id = ?;
|
|
1213
|
+
`,
|
|
1214
|
+
)
|
|
1215
|
+
.run(now, now, draftId);
|
|
1216
|
+
return readDraftWithCommentsById(database, draftId);
|
|
1217
|
+
} finally {
|
|
1218
|
+
database.close();
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
async function readCurrentPullRequestHeadSha(options: {
|
|
1223
|
+
token: string;
|
|
1224
|
+
owner: string;
|
|
1225
|
+
repo: string;
|
|
1226
|
+
number: number;
|
|
1227
|
+
fetchHeadSha?: (options: {
|
|
1228
|
+
token: string;
|
|
1229
|
+
owner: string;
|
|
1230
|
+
repo: string;
|
|
1231
|
+
number: number;
|
|
1232
|
+
}) => Promise<string | null | undefined>;
|
|
1233
|
+
}) {
|
|
1234
|
+
const fetchHeadSha =
|
|
1235
|
+
options.fetchHeadSha ??
|
|
1236
|
+
(async (input: {
|
|
1237
|
+
token: string;
|
|
1238
|
+
owner: string;
|
|
1239
|
+
repo: string;
|
|
1240
|
+
number: number;
|
|
1241
|
+
}) => (await fetchPullRequestDetail(input)).headSha);
|
|
1242
|
+
const headSha = await fetchHeadSha({
|
|
1243
|
+
token: options.token,
|
|
1244
|
+
owner: options.owner,
|
|
1245
|
+
repo: options.repo,
|
|
1246
|
+
number: options.number,
|
|
1247
|
+
});
|
|
1248
|
+
if (!headSha) {
|
|
1249
|
+
throw new GitHubPrReviewSubmitError({
|
|
1250
|
+
code: 'stale-draft',
|
|
1251
|
+
message: 'Current PR head SHA is unavailable.',
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
return headSha;
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
async function createPullRequestReview(options: {
|
|
1258
|
+
token: string;
|
|
1259
|
+
owner: string;
|
|
1260
|
+
repo: string;
|
|
1261
|
+
number: number;
|
|
1262
|
+
headSha: string;
|
|
1263
|
+
verdict: GitHubPrReviewVerdict;
|
|
1264
|
+
body: string;
|
|
1265
|
+
comments: GitHubPrReviewDraftComment[];
|
|
1266
|
+
}): Promise<GitHubSubmittedPullRequestReview> {
|
|
1267
|
+
const response = await githubFetch(
|
|
1268
|
+
options.token,
|
|
1269
|
+
`https://api.github.com/repos/${encodePathSegment(options.owner)}/${encodePathSegment(options.repo)}/pulls/${options.number}/reviews`,
|
|
1270
|
+
{
|
|
1271
|
+
method: 'POST',
|
|
1272
|
+
body: JSON.stringify({
|
|
1273
|
+
commit_id: options.headSha,
|
|
1274
|
+
event: reviewEvent(options.verdict),
|
|
1275
|
+
body: options.body,
|
|
1276
|
+
comments: options.comments.map(reviewCommentPayload),
|
|
1277
|
+
}),
|
|
1278
|
+
},
|
|
1279
|
+
);
|
|
1280
|
+
const review = v.parse(
|
|
1281
|
+
githubPullRequestReviewCreatedApiResponseSchema,
|
|
1282
|
+
await response.json(),
|
|
1283
|
+
);
|
|
1284
|
+
|
|
1285
|
+
return {
|
|
1286
|
+
id: review.id,
|
|
1287
|
+
nodeId: review.node_id ?? null,
|
|
1288
|
+
state: review.state,
|
|
1289
|
+
authorLogin: review.user?.login ?? null,
|
|
1290
|
+
submittedAt: review.submitted_at ?? null,
|
|
1291
|
+
commitId: review.commit_id ?? null,
|
|
1292
|
+
url: review.html_url ?? null,
|
|
1293
|
+
body:
|
|
1294
|
+
'body' in review && typeof review.body === 'string' ? review.body : null,
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
function reviewEvent(verdict: GitHubPrReviewVerdict) {
|
|
1299
|
+
if (verdict === 'approve') return 'APPROVE';
|
|
1300
|
+
if (verdict === 'request-changes') return 'REQUEST_CHANGES';
|
|
1301
|
+
return 'COMMENT';
|
|
1302
|
+
}
|
|
1303
|
+
|
|
1304
|
+
function reviewCommentPayload(comment: GitHubPrReviewDraftComment) {
|
|
1305
|
+
return {
|
|
1306
|
+
path: comment.path,
|
|
1307
|
+
side: comment.side,
|
|
1308
|
+
line: comment.line,
|
|
1309
|
+
...(comment.startLine ? { start_line: comment.startLine } : {}),
|
|
1310
|
+
...(comment.startSide ? { start_side: comment.startSide } : {}),
|
|
1311
|
+
body: comment.body,
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
function assertValidReviewCommentAnchor(options: {
|
|
1316
|
+
side: GitHubPrReviewDraftCommentSide;
|
|
1317
|
+
line: number;
|
|
1318
|
+
startLine?: number | null;
|
|
1319
|
+
startSide?: GitHubPrReviewDraftCommentSide | null;
|
|
1320
|
+
}) {
|
|
1321
|
+
if (options.line < 1 || !Number.isInteger(options.line)) {
|
|
1322
|
+
throw new Error('Review comment line must be a positive integer.');
|
|
1323
|
+
}
|
|
1324
|
+
if (options.startLine == null) return;
|
|
1325
|
+
if (options.startLine < 1 || !Number.isInteger(options.startLine)) {
|
|
1326
|
+
throw new Error('Review comment start line must be a positive integer.');
|
|
1327
|
+
}
|
|
1328
|
+
const startSide = options.startSide ?? options.side;
|
|
1329
|
+
if (startSide === options.side && options.startLine > options.line) {
|
|
1330
|
+
throw new Error('Review comment range start must not follow the end line.');
|
|
1331
|
+
}
|
|
1332
|
+
if (startSide === 'RIGHT' && options.side === 'LEFT') {
|
|
1333
|
+
throw new Error('Review comment cross-side range must start on LEFT.');
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
function normalizeNullableBody(value: string | null | undefined) {
|
|
1338
|
+
if (value == null) return null;
|
|
1339
|
+
const trimmed = value.trim();
|
|
1340
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
function isLikelyInsufficientScopeError(error: unknown, message: string) {
|
|
1344
|
+
if (error instanceof GitHubApiError && error.status === 403) return true;
|
|
1345
|
+
return /Resource not accessible by integration|pull request write access/i.test(
|
|
1346
|
+
message,
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
function failingReviewCommentIdsFromGitHubError(
|
|
1351
|
+
error: unknown,
|
|
1352
|
+
comments: GitHubPrReviewDraftComment[],
|
|
1353
|
+
) {
|
|
1354
|
+
if (!(error instanceof GitHubApiError)) {
|
|
1355
|
+
return comments.map((comment) => comment.id);
|
|
1356
|
+
}
|
|
1357
|
+
const indexed = failingReviewCommentIndexes(error.data);
|
|
1358
|
+
if (indexed.size > 0) {
|
|
1359
|
+
return comments
|
|
1360
|
+
.filter((_comment, index) => indexed.has(index))
|
|
1361
|
+
.map((comment) => comment.id);
|
|
1362
|
+
}
|
|
1363
|
+
const matched = comments.filter((comment) =>
|
|
1364
|
+
githubErrorDataMentionsComment(error.data, comment),
|
|
1365
|
+
);
|
|
1366
|
+
return matched.length > 0
|
|
1367
|
+
? matched.map((comment) => comment.id)
|
|
1368
|
+
: comments.map((comment) => comment.id);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
function failingReviewCommentIndexes(data: unknown) {
|
|
1372
|
+
const indexes = new Set<number>();
|
|
1373
|
+
for (const item of githubErrorItems(data)) {
|
|
1374
|
+
const text = Object.values(item)
|
|
1375
|
+
.filter((value) => typeof value === 'string' || typeof value === 'number')
|
|
1376
|
+
.join(' ');
|
|
1377
|
+
for (const match of text.matchAll(/comments\[(\d+)]/gi)) {
|
|
1378
|
+
indexes.add(Number(match[1]));
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
return indexes;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
function githubErrorDataMentionsComment(
|
|
1385
|
+
data: unknown,
|
|
1386
|
+
comment: GitHubPrReviewDraftComment,
|
|
1387
|
+
) {
|
|
1388
|
+
const lineNeedles = [
|
|
1389
|
+
`line ${comment.line}`,
|
|
1390
|
+
`line:${comment.line}`,
|
|
1391
|
+
`line: ${comment.line}`,
|
|
1392
|
+
`"line":${comment.line}`,
|
|
1393
|
+
];
|
|
1394
|
+
return githubErrorItems(data).some((item) => {
|
|
1395
|
+
const text = JSON.stringify(item);
|
|
1396
|
+
return (
|
|
1397
|
+
text.includes(comment.path) &&
|
|
1398
|
+
lineNeedles.some((needle) => text.includes(needle))
|
|
1399
|
+
);
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
function githubErrorItems(data: unknown): Array<Record<string, unknown>> {
|
|
1404
|
+
if (!data || typeof data !== 'object') return [];
|
|
1405
|
+
const errors = 'errors' in data ? data.errors : null;
|
|
1406
|
+
if (!Array.isArray(errors)) return [];
|
|
1407
|
+
return errors.filter(
|
|
1408
|
+
(item): item is Record<string, unknown> =>
|
|
1409
|
+
Boolean(item) && typeof item === 'object',
|
|
1410
|
+
);
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
function rewriteThreadMutationError(error: unknown) {
|
|
1414
|
+
const message = errorMessage(error);
|
|
1415
|
+
if (isLikelyInsufficientScopeError(error, message)) {
|
|
1416
|
+
return new Error(
|
|
1417
|
+
'GitHub token needs pull request write access to update review threads.',
|
|
1418
|
+
);
|
|
1419
|
+
}
|
|
1420
|
+
return error instanceof Error ? error : new Error(message);
|
|
1421
|
+
}
|