lalph 0.3.27 → 0.3.29

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lalph",
3
3
  "type": "module",
4
- "version": "0.3.27",
4
+ "version": "0.3.29",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -22,17 +22,18 @@
22
22
  "devDependencies": {
23
23
  "@changesets/changelog-github": "^0.5.2",
24
24
  "@changesets/cli": "^2.29.8",
25
- "@effect/language-service": "^0.73.1",
26
- "@effect/platform-node": "4.0.0-beta.2",
25
+ "@effect/language-service": "^0.75.1",
26
+ "@effect/platform-node": "4.0.0-beta.7",
27
27
  "@linear/sdk": "^75.0.0",
28
28
  "@octokit/plugin-rest-endpoint-methods": "^17.0.0",
29
29
  "@octokit/types": "^16.0.0",
30
+ "@typescript/native-preview": "7.0.0-dev.20260219.1",
30
31
  "concurrently": "^9.2.1",
31
- "effect": "4.0.0-beta.2",
32
+ "effect": "4.0.0-beta.7",
32
33
  "husky": "^9.1.7",
33
34
  "lint-staged": "^16.2.7",
34
35
  "octokit": "^5.0.5",
35
- "oxlint": "^1.47.0",
36
+ "oxlint": "^1.49.0",
36
37
  "prettier": "^3.8.1",
37
38
  "tsdown": "^0.20.3",
38
39
  "typescript": "^5.9.3",
@@ -48,7 +49,7 @@
48
49
  ]
49
50
  },
50
51
  "scripts": {
51
- "check": "concurrently \"tsc --noEmit\" \"oxlint -c .oxlintrc.json\" \"pnpm build\"",
52
+ "check": "concurrently \"pnpm tsgo --noEmit\" \"pnpm oxlint -c .oxlintrc.json\" \"pnpm build\"",
52
53
  "build": "tsdown"
53
54
  }
54
55
  }
package/src/Github/Cli.ts CHANGED
@@ -45,7 +45,7 @@ export class GithubCli extends ServiceMap.Service<GithubCli>()(
45
45
  Effect.map((data) => {
46
46
  const comments =
47
47
  data.data.repository.pullRequest.comments.nodes.filter(
48
- (c) => !c.author.login.startsWith("github"),
48
+ (c) => !c.isBot,
49
49
  )
50
50
  const reviews =
51
51
  data.data.repository.pullRequest.reviews.nodes.filter(
@@ -5,6 +5,7 @@ import {
5
5
  Option,
6
6
  Schedule,
7
7
  Schema,
8
+ Semaphore,
8
9
  ServiceMap,
9
10
  } from "effect"
10
11
  import {
@@ -64,7 +65,7 @@ export class TokenManager extends ServiceMap.Service<TokenManager>()(
64
65
  }
65
66
  return currentToken.value
66
67
  })
67
- const get = Effect.makeSemaphoreUnsafe(1).withPermit(getNoLock)
68
+ const get = Semaphore.makeUnsafe(1).withPermit(getNoLock)
68
69
 
69
70
  const deviceCode = Effect.gen(function* () {
70
71
  const code = yield* HttpClientRequest.post(
package/src/Github.ts CHANGED
@@ -31,69 +31,87 @@ export class GithubError extends Data.TaggedError("GithubError")<{
31
31
  readonly cause: unknown
32
32
  }> {}
33
33
 
34
- export class Github extends ServiceMap.Service<Github>()("lalph/Github", {
35
- make: Effect.gen(function* () {
36
- const tokens = yield* TokenManager
37
- const clients = yield* RcMap.make({
38
- lookup: (token: string) =>
39
- Effect.succeed(new Octokit({ auth: token }).rest),
40
- idleTimeToLive: "1 minute",
41
- })
42
- const getClient = tokens.get.pipe(
43
- Effect.flatMap(({ token }) => RcMap.get(clients, token)),
44
- Effect.mapError((cause) => new GithubError({ cause })),
45
- )
34
+ export type GithubApi = Api["rest"]
35
+ export type GithubResponse<A> = OctokitResponse<A>
36
+
37
+ export interface GithubService {
38
+ readonly request: <A>(
39
+ f: (_: GithubApi) => Promise<A>,
40
+ ) => Effect.Effect<A, GithubError, never>
41
+ readonly wrap: <A, Args extends Array<unknown>>(
42
+ f: (_: GithubApi) => (...args: Args) => Promise<GithubResponse<A>>,
43
+ ) => (...args: Args) => Effect.Effect<A, GithubError, never>
44
+ readonly stream: <A>(
45
+ f: (_: GithubApi, page: number) => Promise<GithubResponse<Array<A>>>,
46
+ ) => Stream.Stream<A, GithubError, never>
47
+ }
46
48
 
47
- const request = <A>(f: (_: Api["rest"]) => Promise<A>) =>
48
- getClient.pipe(
49
- Effect.flatMap((rest) =>
50
- Effect.tryPromise({
51
- try: () => f(rest),
52
- catch: (cause) => new GithubError({ cause }),
53
- }),
54
- ),
55
- Effect.scoped,
56
- Effect.withSpan("Github.request"),
49
+ export class Github extends ServiceMap.Service<Github, GithubService>()(
50
+ "lalph/Github",
51
+ {
52
+ make: Effect.gen(function* () {
53
+ const tokens = yield* TokenManager
54
+ const clients = yield* RcMap.make({
55
+ lookup: (token: string) =>
56
+ Effect.succeed(new Octokit({ auth: token }).rest),
57
+ idleTimeToLive: "1 minute",
58
+ })
59
+ const getClient = tokens.get.pipe(
60
+ Effect.flatMap(({ token }) => RcMap.get(clients, token)),
61
+ Effect.mapError((cause) => new GithubError({ cause })),
57
62
  )
58
63
 
59
- const wrap =
60
- <A, Args extends Array<unknown>>(
61
- f: (_: Api["rest"]) => (...args: Args) => Promise<OctokitResponse<A>>,
62
- ) =>
63
- (...args: Args) =>
64
+ const request = <A>(f: (_: GithubApi) => Promise<A>) =>
64
65
  getClient.pipe(
65
66
  Effect.flatMap((rest) =>
66
67
  Effect.tryPromise({
67
- try: () => f(rest)(...args),
68
+ try: () => f(rest),
68
69
  catch: (cause) => new GithubError({ cause }),
69
70
  }),
70
71
  ),
71
72
  Effect.scoped,
72
- Effect.map((_) => _.data),
73
- Effect.withSpan("Github.wrap"),
73
+ Effect.withSpan("Github.request"),
74
74
  )
75
75
 
76
- const stream = <A>(
77
- f: (_: Api["rest"], page: number) => Promise<OctokitResponse<Array<A>>>,
78
- ) =>
79
- Stream.paginate(0, (page) =>
80
- getClient.pipe(
81
- Effect.flatMap((rest) =>
82
- Effect.tryPromise({
83
- try: () => f(rest, page),
84
- catch: (cause) => new GithubError({ cause }),
85
- }),
86
- ),
87
- Effect.scoped,
88
- Effect.map(
89
- (_) => [_.data, maybeNextPage(page, _.headers.link)] as const,
76
+ const wrap =
77
+ <A, Args extends Array<unknown>>(
78
+ f: (_: GithubApi) => (...args: Args) => Promise<OctokitResponse<A>>,
79
+ ) =>
80
+ (...args: Args) =>
81
+ getClient.pipe(
82
+ Effect.flatMap((rest) =>
83
+ Effect.tryPromise({
84
+ try: () => f(rest)(...args),
85
+ catch: (cause) => new GithubError({ cause }),
86
+ }),
87
+ ),
88
+ Effect.scoped,
89
+ Effect.map((_) => _.data),
90
+ Effect.withSpan("Github.wrap"),
91
+ )
92
+
93
+ const stream = <A>(
94
+ f: (_: GithubApi, page: number) => Promise<OctokitResponse<Array<A>>>,
95
+ ) =>
96
+ Stream.paginate(0, (page) =>
97
+ getClient.pipe(
98
+ Effect.flatMap((rest) =>
99
+ Effect.tryPromise({
100
+ try: () => f(rest, page),
101
+ catch: (cause) => new GithubError({ cause }),
102
+ }),
103
+ ),
104
+ Effect.scoped,
105
+ Effect.map(
106
+ (_) => [_.data, maybeNextPage(page, _.headers.link)] as const,
107
+ ),
90
108
  ),
91
- ),
92
- )
109
+ )
93
110
 
94
- return { request, wrap, stream } as const
95
- }),
96
- }) {
111
+ return { request, wrap, stream } as const
112
+ }),
113
+ },
114
+ ) {
97
115
  static layer = Layer.effect(this, this.make).pipe(
98
116
  Layer.provide(TokenManager.layer),
99
117
  )
@@ -2,10 +2,12 @@ import {
2
2
  DateTime,
3
3
  Deferred,
4
4
  Effect,
5
+ Encoding,
5
6
  Layer,
6
7
  Option,
7
8
  Schedule,
8
9
  Schema,
10
+ Semaphore,
9
11
  ServiceMap,
10
12
  } from "effect"
11
13
  import {
@@ -18,7 +20,6 @@ import {
18
20
  HttpServerRequest,
19
21
  HttpServerResponse,
20
22
  } from "effect/unstable/http"
21
- import { Base64Url } from "effect/encoding"
22
23
  import { NodeHttpServer } from "@effect/platform-node"
23
24
  import { createServer } from "node:http"
24
25
  import { KeyValueStore } from "effect/unstable/persistence"
@@ -80,7 +81,7 @@ export class TokenManager extends ServiceMap.Service<TokenManager>()(
80
81
  return currentToken.value
81
82
  }),
82
83
  )
83
- const get = Effect.makeSemaphoreUnsafe(1).withPermit(getNoLock)
84
+ const get = Semaphore.makeUnsafe(1).withPermit(getNoLock)
84
85
 
85
86
  const pkce = Effect.gen(function* () {
86
87
  const deferred = yield* Deferred.make<typeof CallbackParams.Type>()
@@ -116,7 +117,9 @@ export class TokenManager extends ServiceMap.Service<TokenManager>()(
116
117
  const verifierSha256 = yield* Effect.promise(() =>
117
118
  crypto.subtle.digest("SHA-256", new TextEncoder().encode(verifier)),
118
119
  )
119
- const challenge = Base64Url.encode(new Uint8Array(verifierSha256))
120
+ const challenge = Encoding.encodeBase64Url(
121
+ new Uint8Array(verifierSha256),
122
+ )
120
123
 
121
124
  const url = `https://linear.app/oauth/authorize?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=read,write&code_challenge=${challenge}&code_challenge_method=S256`
122
125
 
package/src/Prd.ts CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  Path,
8
8
  PlatformError,
9
9
  Schedule,
10
+ Semaphore,
10
11
  ServiceMap,
11
12
  Stream,
12
13
  } from "effect"
@@ -65,7 +66,7 @@ export class Prd extends ServiceMap.Service<
65
66
  { suspendOnWaiting: true },
66
67
  )
67
68
 
68
- const syncSemaphore = Effect.makeSemaphoreUnsafe(1)
69
+ const syncSemaphore = Semaphore.makeUnsafe(1)
69
70
 
70
71
  const maybeRevertIssue = Effect.fnUntraced(function* (options: {
71
72
  readonly issueId: string
package/src/Worktree.ts CHANGED
@@ -264,7 +264,7 @@ const makeExecHelpers = Effect.fnUntraced(function* (options: {
264
264
  if (DateTime.isLessThan(deadline, now)) {
265
265
  return Effect.fail(new RunnerStalled())
266
266
  }
267
- const timeUntilDeadline = DateTime.distanceDuration(deadline, now)
267
+ const timeUntilDeadline = DateTime.distance(deadline, now)
268
268
  return Effect.flatMap(Effect.sleep(timeUntilDeadline), loop)
269
269
  })
270
270
 
@@ -8,6 +8,7 @@ import {
8
8
  Iterable,
9
9
  Option,
10
10
  Path,
11
+ Semaphore,
11
12
  Stream,
12
13
  } from "effect"
13
14
  import { PromptGen } from "../PromptGen.ts"
@@ -248,7 +249,7 @@ const runProject = Effect.fnUntraced(
248
249
  }) {
249
250
  const isFinite = Number.isFinite(options.iterations)
250
251
  const iterationsDisplay = isFinite ? options.iterations : "unlimited"
251
- const semaphore = Effect.makeSemaphoreUnsafe(options.project.concurrency)
252
+ const semaphore = Semaphore.makeUnsafe(options.project.concurrency)
252
253
  const fibers = yield* FiberSet.make()
253
254
 
254
255
  yield* resetInProgress.pipe(Effect.withSpan("Main.resetInProgress"))
@@ -4,12 +4,29 @@ export class Author extends S.Class<Author>("Author")({
4
4
  login: S.String,
5
5
  }) {}
6
6
 
7
+ // Prefixes of bot users that we want to ignore when determining if a comment is
8
+ // from a bot or not. This is not an exhaustive list, but covers some common
9
+ // cases.
10
+ const commonBotUserPrefixes = [
11
+ "dependabot",
12
+ "github",
13
+ "changeset",
14
+ "renovate",
15
+ "snyk",
16
+ "coderabbit",
17
+ ]
18
+
7
19
  export class Comment extends S.Class<Comment>("Comment")({
8
20
  id: S.String,
9
21
  body: S.String,
10
22
  author: Author,
11
23
  createdAt: S.String,
12
- }) {}
24
+ }) {
25
+ get isBot() {
26
+ const login = this.author.login.toLowerCase()
27
+ return commonBotUserPrefixes.some((prefix) => login.startsWith(prefix))
28
+ }
29
+ }
13
30
 
14
31
  export class PullRequestComments extends S.Class<PullRequestComments>(
15
32
  "PullRequestComments",