@effect-agent/pr-review 0.1.0-beta.11 → 0.1.0-beta.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/NOTICE +26 -0
  2. package/README.md +181 -172
  3. package/dist/Review.d.mts +294 -0
  4. package/dist/Review.mjs +738 -0
  5. package/dist/Review.mjs.map +1 -0
  6. package/dist/ReviewRepository-Wd_4qCaO.d.mts +71 -0
  7. package/dist/ReviewRepository.d.mts +2 -0
  8. package/dist/ReviewRepository.mjs +15 -0
  9. package/dist/ReviewRepository.mjs.map +1 -0
  10. package/dist/index.d.mts +3 -718
  11. package/dist/index.mjs +3 -66
  12. package/dist/repository-D7NN3225.mjs +101 -0
  13. package/dist/repository-D7NN3225.mjs.map +1 -0
  14. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  15. package/package.json +1 -54
  16. package/src/Review.ts +1111 -0
  17. package/src/ReviewRepository.ts +9 -0
  18. package/src/index.ts +2 -21
  19. package/src/internal/repository.ts +156 -0
  20. package/dist/action.d.mts +0 -190
  21. package/dist/action.mjs +0 -423
  22. package/dist/action.mjs.map +0 -1
  23. package/dist/cli.d.mts +0 -1
  24. package/dist/cli.mjs +0 -103
  25. package/dist/cli.mjs.map +0 -1
  26. package/dist/fan-out-TrA9EUCr.d.mts +0 -1085
  27. package/dist/github-5TCFrxfX.mjs +0 -1676
  28. package/dist/github-5TCFrxfX.mjs.map +0 -1
  29. package/dist/index.mjs.map +0 -1
  30. package/dist/providers-DobNWMUn.mjs +0 -990
  31. package/dist/providers-DobNWMUn.mjs.map +0 -1
  32. package/dist/testing.d.mts +0 -131
  33. package/dist/testing.mjs +0 -230
  34. package/dist/testing.mjs.map +0 -1
  35. package/src/action.ts +0 -697
  36. package/src/cli.ts +0 -214
  37. package/src/internal/action-entry.ts +0 -43
  38. package/src/internal/coverage.ts +0 -245
  39. package/src/internal/diff.ts +0 -134
  40. package/src/internal/effort.ts +0 -86
  41. package/src/internal/factory.ts +0 -374
  42. package/src/internal/fan-out-scripted.ts +0 -164
  43. package/src/internal/fan-out.ts +0 -450
  44. package/src/internal/fingerprint.ts +0 -74
  45. package/src/internal/fixtures.ts +0 -131
  46. package/src/internal/github-env.ts +0 -148
  47. package/src/internal/github.ts +0 -774
  48. package/src/internal/ignore.ts +0 -88
  49. package/src/internal/profiles.ts +0 -79
  50. package/src/internal/providers.ts +0 -94
  51. package/src/internal/render.ts +0 -428
  52. package/src/internal/retirement.ts +0 -332
  53. package/src/internal/review-agent.ts +0 -385
  54. package/src/internal/review-state.ts +0 -488
  55. package/src/internal/review-units.ts +0 -167
  56. package/src/internal/run.ts +0 -397
  57. package/src/internal/scripted.ts +0 -108
  58. package/src/internal/source.ts +0 -110
  59. package/src/testing.ts +0 -8
@@ -1,148 +0,0 @@
1
- import { Config, Effect, FileSystem, Layer, Option, Schema } from "effect";
2
- import type { HttpClient } from "effect/unstable/http";
3
-
4
- import type { PriorReviews, ReviewPublisher } from "./github.ts";
5
- import {
6
- DEFAULT_GITHUB_REVIEW_AUTHOR_LOGIN,
7
- GitHubReviewTarget,
8
- gitHubPriorReviewsLayer,
9
- gitHubPullRequestSourceLayer,
10
- gitHubReviewPublisherLayer,
11
- gitHubReviewRetirementHostLayer,
12
- } from "./github.ts";
13
- import type { ReviewRetirementHost } from "./retirement.ts";
14
- import type { PullRequestSource } from "./source.ts";
15
-
16
- // ---------------------------------------------------------------------------
17
- // GitHub Actions environment resolution: which pull request to review, from
18
- // explicit values first and the standard Actions environment second
19
- // (GITHUB_REPOSITORY, GITHUB_EVENT_PATH, GITHUB_API_URL, GITHUB_TOKEN).
20
- // Platform-free: FileSystem and Config are Effect services supplied by the
21
- // host entrypoint.
22
- // ---------------------------------------------------------------------------
23
-
24
- /** The pull request could not be resolved from options or the environment. */
25
- export class ReviewTargetUnresolved extends Schema.TaggedError<ReviewTargetUnresolved>()(
26
- "ReviewTargetUnresolved",
27
- {
28
- reason: Schema.String,
29
- },
30
- ) {
31
- override get message() {
32
- return this.reason;
33
- }
34
- }
35
-
36
- /** The slice of a GitHub Actions event payload this package understands. */
37
- export const GitHubEventWire = Schema.Struct({
38
- pull_request: Schema.optionalKey(
39
- Schema.Struct({
40
- number: Schema.Int,
41
- draft: Schema.optionalKey(Schema.Boolean),
42
- }),
43
- ),
44
- repository: Schema.optionalKey(Schema.Struct({ full_name: Schema.String })),
45
- });
46
- export type GitHubEventWire = typeof GitHubEventWire.Type;
47
-
48
- const decodeEvent = Schema.decodeUnknownEffect(Schema.fromJsonString(GitHubEventWire));
49
-
50
- /** Read and decode the GITHUB_EVENT_PATH payload, or none outside Actions. */
51
- export const readGitHubEvent = Effect.fn("readGitHubEvent")(function* () {
52
- const eventPath = yield* Config.string("GITHUB_EVENT_PATH").pipe(Config.withDefault(""));
53
- if (eventPath === "") return Option.none<GitHubEventWire>();
54
- const fs = yield* FileSystem.FileSystem;
55
- const raw = yield* fs
56
- .readFileString(eventPath)
57
- .pipe(
58
- Effect.mapError((error) =>
59
- ReviewTargetUnresolved.make({ reason: `Cannot read event payload: ${error.message}` }),
60
- ),
61
- );
62
- const event = yield* decodeEvent(raw).pipe(
63
- Effect.mapError((error) =>
64
- ReviewTargetUnresolved.make({ reason: `Cannot decode event payload: ${error.message}` }),
65
- ),
66
- );
67
- return Option.some(event);
68
- });
69
-
70
- export interface ResolvedReviewTarget {
71
- readonly repository: string;
72
- readonly number: number;
73
- }
74
-
75
- /**
76
- * Resolve the review target: explicit values win, then GITHUB_REPOSITORY and
77
- * the pull_request event payload. Fails typed when no target can be named.
78
- */
79
- export const resolveReviewTarget = Effect.fn("resolveReviewTarget")(function* (options: {
80
- readonly repository?: string | undefined;
81
- readonly number?: number | undefined;
82
- }) {
83
- let repository = options.repository ?? "";
84
- if (repository === "") {
85
- repository = yield* Config.string("GITHUB_REPOSITORY").pipe(Config.withDefault(""));
86
- }
87
- let number = options.number;
88
- if (number === undefined || repository === "") {
89
- const event = yield* readGitHubEvent();
90
- if (Option.isSome(event)) {
91
- number ??= event.value.pull_request?.number;
92
- if (repository === "") repository = event.value.repository?.full_name ?? "";
93
- }
94
- }
95
- if (repository === "" || number === undefined) {
96
- return yield* ReviewTargetUnresolved.make({
97
- reason:
98
- "No pull request to review: pass an explicit repository and number, or run inside a GitHub Actions pull_request event.",
99
- });
100
- }
101
- return { repository, number } satisfies ResolvedReviewTarget;
102
- });
103
-
104
- /**
105
- * Build the GitHub source and publisher Layers for one resolved target,
106
- * reading GITHUB_API_URL, GITHUB_TOKEN, and PR_REVIEW_AUTHOR_LOGIN from
107
- * configuration. The returned Layer is the complete GitHub side of a review
108
- * run.
109
- */
110
- export const gitHubReviewLayers = (
111
- target: ResolvedReviewTarget,
112
- ): Layer.Layer<
113
- PullRequestSource | ReviewPublisher | PriorReviews | ReviewRetirementHost,
114
- Config.ConfigError,
115
- HttpClient.HttpClient
116
- > =>
117
- Layer.unwrap(
118
- Effect.gen(function* () {
119
- const apiUrl = yield* Config.string("GITHUB_API_URL").pipe(
120
- Config.withDefault("https://api.github.com"),
121
- );
122
- const graphqlUrl = yield* Config.string("GITHUB_GRAPHQL_URL").pipe(
123
- Config.withDefault(
124
- apiUrl === "https://api.github.com"
125
- ? "https://api.github.com/graphql"
126
- : apiUrl.replace(/\/api\/v3$/, "/api/graphql"),
127
- ),
128
- );
129
- const token = yield* Config.option(Config.redacted("GITHUB_TOKEN"));
130
- const reviewAuthorLogin = yield* Config.nonEmptyString("PR_REVIEW_AUTHOR_LOGIN").pipe(
131
- Config.withDefault(DEFAULT_GITHUB_REVIEW_AUTHOR_LOGIN),
132
- );
133
- const targetLayer = GitHubReviewTarget.layer({
134
- apiUrl,
135
- graphqlUrl,
136
- repository: target.repository,
137
- number: target.number,
138
- token,
139
- reviewAuthorLogin,
140
- });
141
- return Layer.mergeAll(
142
- gitHubPullRequestSourceLayer.pipe(Layer.provide(targetLayer)),
143
- gitHubReviewPublisherLayer.pipe(Layer.provide(targetLayer)),
144
- gitHubPriorReviewsLayer.pipe(Layer.provide(targetLayer)),
145
- gitHubReviewRetirementHostLayer.pipe(Layer.provide(targetLayer)),
146
- );
147
- }),
148
- );