@effect-agent/pr-review 0.1.0-beta.9 → 0.1.0-beta.90

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 +170 -168
  3. package/dist/Review.d.mts +294 -0
  4. package/dist/Review.mjs +702 -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 -717
  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 +1052 -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-C6gq3CFg.d.mts +0 -1081
  27. package/dist/github-Lfa_ox-u.mjs +0 -1673
  28. package/dist/github-Lfa_ox-u.mjs.map +0 -1
  29. package/dist/index.mjs.map +0 -1
  30. package/dist/providers-CaOnz7mK.mjs +0 -987
  31. package/dist/providers-CaOnz7mK.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 -42
  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 -142
  47. package/src/internal/github.ts +0 -761
  48. package/src/internal/ignore.ts +0 -88
  49. package/src/internal/profiles.ts +0 -79
  50. package/src/internal/providers.ts +0 -91
  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,142 +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
- GitHubReviewTarget,
7
- gitHubPriorReviewsLayer,
8
- gitHubPullRequestSourceLayer,
9
- gitHubReviewPublisherLayer,
10
- gitHubReviewRetirementHostLayer,
11
- } from "./github.ts";
12
- import type { ReviewRetirementHost } from "./retirement.ts";
13
- import type { PullRequestSource } from "./source.ts";
14
-
15
- // ---------------------------------------------------------------------------
16
- // GitHub Actions environment resolution: which pull request to review, from
17
- // explicit values first and the standard Actions environment second
18
- // (GITHUB_REPOSITORY, GITHUB_EVENT_PATH, GITHUB_API_URL, GITHUB_TOKEN).
19
- // Platform-free: FileSystem and Config are Effect services supplied by the
20
- // host entrypoint.
21
- // ---------------------------------------------------------------------------
22
-
23
- /** The pull request could not be resolved from options or the environment. */
24
- export class ReviewTargetUnresolved extends Schema.TaggedError<ReviewTargetUnresolved>()(
25
- "ReviewTargetUnresolved",
26
- {
27
- reason: Schema.String,
28
- },
29
- ) {
30
- override get message() {
31
- return this.reason;
32
- }
33
- }
34
-
35
- /** The slice of a GitHub Actions event payload this package understands. */
36
- export const GitHubEventWire = Schema.Struct({
37
- pull_request: Schema.optionalKey(
38
- Schema.Struct({
39
- number: Schema.Int,
40
- draft: Schema.optionalKey(Schema.Boolean),
41
- }),
42
- ),
43
- repository: Schema.optionalKey(Schema.Struct({ full_name: Schema.String })),
44
- });
45
- export type GitHubEventWire = typeof GitHubEventWire.Type;
46
-
47
- const decodeEvent = Schema.decodeUnknownEffect(Schema.fromJsonString(GitHubEventWire));
48
-
49
- /** Read and decode the GITHUB_EVENT_PATH payload, or none outside Actions. */
50
- export const readGitHubEvent = Effect.fn("readGitHubEvent")(function* () {
51
- const eventPath = yield* Config.string("GITHUB_EVENT_PATH").pipe(Config.withDefault(""));
52
- if (eventPath === "") return Option.none<GitHubEventWire>();
53
- const fs = yield* FileSystem.FileSystem;
54
- const raw = yield* fs
55
- .readFileString(eventPath)
56
- .pipe(
57
- Effect.mapError((error) =>
58
- ReviewTargetUnresolved.make({ reason: `Cannot read event payload: ${error.message}` }),
59
- ),
60
- );
61
- const event = yield* decodeEvent(raw).pipe(
62
- Effect.mapError((error) =>
63
- ReviewTargetUnresolved.make({ reason: `Cannot decode event payload: ${error.message}` }),
64
- ),
65
- );
66
- return Option.some(event);
67
- });
68
-
69
- export interface ResolvedReviewTarget {
70
- readonly repository: string;
71
- readonly number: number;
72
- }
73
-
74
- /**
75
- * Resolve the review target: explicit values win, then GITHUB_REPOSITORY and
76
- * the pull_request event payload. Fails typed when no target can be named.
77
- */
78
- export const resolveReviewTarget = Effect.fn("resolveReviewTarget")(function* (options: {
79
- readonly repository?: string | undefined;
80
- readonly number?: number | undefined;
81
- }) {
82
- let repository = options.repository ?? "";
83
- if (repository === "") {
84
- repository = yield* Config.string("GITHUB_REPOSITORY").pipe(Config.withDefault(""));
85
- }
86
- let number = options.number;
87
- if (number === undefined || repository === "") {
88
- const event = yield* readGitHubEvent();
89
- if (Option.isSome(event)) {
90
- number ??= event.value.pull_request?.number;
91
- if (repository === "") repository = event.value.repository?.full_name ?? "";
92
- }
93
- }
94
- if (repository === "" || number === undefined) {
95
- return yield* ReviewTargetUnresolved.make({
96
- reason:
97
- "No pull request to review: pass an explicit repository and number, or run inside a GitHub Actions pull_request event.",
98
- });
99
- }
100
- return { repository, number } satisfies ResolvedReviewTarget;
101
- });
102
-
103
- /**
104
- * Build the GitHub source and publisher Layers for one resolved target,
105
- * reading GITHUB_API_URL and GITHUB_TOKEN from configuration. The returned
106
- * Layer is the complete GitHub side of a review run.
107
- */
108
- export const gitHubReviewLayers = (
109
- target: ResolvedReviewTarget,
110
- ): Layer.Layer<
111
- PullRequestSource | ReviewPublisher | PriorReviews | ReviewRetirementHost,
112
- Config.ConfigError,
113
- HttpClient.HttpClient
114
- > =>
115
- Layer.unwrap(
116
- Effect.gen(function* () {
117
- const apiUrl = yield* Config.string("GITHUB_API_URL").pipe(
118
- Config.withDefault("https://api.github.com"),
119
- );
120
- const graphqlUrl = yield* Config.string("GITHUB_GRAPHQL_URL").pipe(
121
- Config.withDefault(
122
- apiUrl === "https://api.github.com"
123
- ? "https://api.github.com/graphql"
124
- : apiUrl.replace(/\/api\/v3$/, "/api/graphql"),
125
- ),
126
- );
127
- const token = yield* Config.option(Config.redacted("GITHUB_TOKEN"));
128
- const targetLayer = GitHubReviewTarget.layer({
129
- apiUrl,
130
- graphqlUrl,
131
- repository: target.repository,
132
- number: target.number,
133
- token,
134
- });
135
- return Layer.mergeAll(
136
- gitHubPullRequestSourceLayer.pipe(Layer.provide(targetLayer)),
137
- gitHubReviewPublisherLayer.pipe(Layer.provide(targetLayer)),
138
- gitHubPriorReviewsLayer.pipe(Layer.provide(targetLayer)),
139
- gitHubReviewRetirementHostLayer.pipe(Layer.provide(targetLayer)),
140
- );
141
- }),
142
- );