lalph 0.3.21 → 0.3.23

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.21",
4
+ "version": "0.3.23",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -23,12 +23,12 @@
23
23
  "@changesets/changelog-github": "^0.5.2",
24
24
  "@changesets/cli": "^2.29.8",
25
25
  "@effect/language-service": "^0.72.0",
26
- "@effect/platform-node": "https://pkg.pr.new/Effect-TS/effect-smol/@effect/platform-node@dad8007",
26
+ "@effect/platform-node": "https://pkg.pr.new/Effect-TS/effect-smol/@effect/platform-node@33f368f",
27
27
  "@linear/sdk": "^72.0.0",
28
28
  "@octokit/plugin-rest-endpoint-methods": "^17.0.0",
29
29
  "@octokit/types": "^16.0.0",
30
30
  "concurrently": "^9.2.1",
31
- "effect": "https://pkg.pr.new/Effect-TS/effect-smol/effect@dad8007",
31
+ "effect": "https://pkg.pr.new/Effect-TS/effect-smol/effect@33f368f",
32
32
  "husky": "^9.1.7",
33
33
  "lint-staged": "^16.2.7",
34
34
  "octokit": "^5.0.5",
@@ -171,11 +171,7 @@ export const currentIssuesAtom = Atom.family((projectId: ProjectId) =>
171
171
  Effect.withSpan("currentIssuesAtom.refresh"),
172
172
  )
173
173
  const handle = setTimeout(() => {
174
- try {
175
- get.refreshSelf()
176
- } catch {
177
- // ignore - if the atom is no longer in use, refreshing will throw an error, which we can safely ignore
178
- }
174
+ get.refreshSelf()
179
175
  }, 30_000)
180
176
  get.addFinalizer(() => clearTimeout(handle))
181
177
  return issues
package/src/Github/Cli.ts CHANGED
@@ -150,7 +150,9 @@ const renderReviewComments = (
150
150
  comment: ReviewComment,
151
151
  followup: Array<ReviewComment>,
152
152
  ) => `<comment author="${comment.author.login}" path="${comment.path}">
153
- <diffHunk>${comment.diffHunk}</diffHunk>
153
+ <diffHunk><![CDATA[
154
+ ${comment.diffHunk}
155
+ ]]></diffHunk>
154
156
  ${comment.originalLine ? `<lineNumber>${comment.originalLine}</lineNumber>` : ""}
155
157
  <body>${comment.body}</body>${
156
158
  followup.length > 0
package/src/Kvs.ts CHANGED
@@ -1,18 +1,36 @@
1
- import { Layer, LayerMap } from "effect"
1
+ import { Effect, Layer, LayerMap, Path } from "effect"
2
2
  import { KeyValueStore } from "effect/unstable/persistence"
3
3
  import { PlatformServices } from "./shared/platform.ts"
4
4
  import { ProjectId } from "./domain/Project.ts"
5
+ import { resolveLalphDirectory } from "./shared/lalphDirectory.ts"
5
6
 
6
- export const layerKvs = KeyValueStore.layerFileSystem(".lalph/config").pipe(
7
- Layer.provide(PlatformServices),
8
- )
7
+ export const layerKvs = Layer.unwrap(
8
+ Effect.gen(function* () {
9
+ const pathService = yield* Path.Path
10
+ const directory = yield* resolveLalphDirectory()
11
+ return KeyValueStore.layerFileSystem(
12
+ pathService.join(directory, ".lalph", "config"),
13
+ )
14
+ }),
15
+ ).pipe(Layer.provide(PlatformServices))
9
16
 
10
17
  export class ProjectsKvs extends LayerMap.Service<ProjectsKvs>()(
11
18
  "lalph/ProjectsKvs",
12
19
  {
13
20
  lookup: (projectId: ProjectId) =>
14
- KeyValueStore.layerFileSystem(
15
- `.lalph/projects/${encodeURIComponent(projectId)}`,
21
+ Layer.unwrap(
22
+ Effect.gen(function* () {
23
+ const pathService = yield* Path.Path
24
+ const directory = yield* resolveLalphDirectory()
25
+ return KeyValueStore.layerFileSystem(
26
+ pathService.join(
27
+ directory,
28
+ ".lalph",
29
+ "projects",
30
+ encodeURIComponent(projectId),
31
+ ),
32
+ )
33
+ }),
16
34
  ).pipe(Layer.orDie),
17
35
  dependencies: [PlatformServices],
18
36
  },
@@ -1,8 +1,18 @@
1
- import { Layer } from "effect"
1
+ import { Effect, Layer, Path } from "effect"
2
2
  import { KeyValueStore, Persistence } from "effect/unstable/persistence"
3
3
  import { PlatformServices } from "./shared/platform.ts"
4
+ import { resolveLalphDirectory } from "./shared/lalphDirectory.ts"
4
5
 
5
- export const layerPersistence = Persistence.layerKvs.pipe(
6
- Layer.provide(KeyValueStore.layerFileSystem(".lalph/cache")),
7
- Layer.provide(PlatformServices),
8
- )
6
+ export const layerPersistence = Layer.unwrap(
7
+ Effect.gen(function* () {
8
+ const pathService = yield* Path.Path
9
+ const directory = yield* resolveLalphDirectory()
10
+ return Persistence.layerKvs.pipe(
11
+ Layer.provide(
12
+ KeyValueStore.layerFileSystem(
13
+ pathService.join(directory, ".lalph", "cache"),
14
+ ),
15
+ ),
16
+ )
17
+ }),
18
+ ).pipe(Layer.provide(PlatformServices))
@@ -4,6 +4,7 @@ import { ChildProcess } from "effect/unstable/process"
4
4
  import { Prd } from "../Prd.ts"
5
5
  import { Worktree } from "../Worktree.ts"
6
6
  import { layerProjectIdPrompt } from "../Projects.ts"
7
+ import { resolveLalphDirectory } from "../shared/lalphDirectory.ts"
7
8
 
8
9
  export const commandSh = Command.make("sh").pipe(
9
10
  Command.withDescription(
@@ -15,14 +16,15 @@ export const commandSh = Command.make("sh").pipe(
15
16
  const worktree = yield* Worktree
16
17
  const fs = yield* FileSystem.FileSystem
17
18
  const pathService = yield* Path.Path
19
+ const lalphDirectory = yield* resolveLalphDirectory()
18
20
 
19
21
  // link to lalph config
20
22
  yield* fs.symlink(
21
- pathService.resolve(pathService.join(".lalph", "config")),
23
+ pathService.join(lalphDirectory, ".lalph", "config"),
22
24
  pathService.join(worktree.directory, ".lalph", "config"),
23
25
  )
24
26
  yield* fs.symlink(
25
- pathService.resolve(pathService.join(".lalph", "projects")),
27
+ pathService.join(lalphDirectory, ".lalph", "projects"),
26
28
  pathService.join(worktree.directory, ".lalph", "projects"),
27
29
  )
28
30
 
@@ -0,0 +1,43 @@
1
+ import { Effect, FileSystem, Option, Path } from "effect"
2
+
3
+ const findProjectRoot = Effect.fnUntraced(function* (cwd: string) {
4
+ const fs = yield* FileSystem.FileSystem
5
+ const pathService = yield* Path.Path
6
+
7
+ let current = cwd
8
+ while (true) {
9
+ const inProjectRoot = yield* fs.exists(pathService.join(current, ".git"))
10
+ if (inProjectRoot) {
11
+ return Option.some(current)
12
+ }
13
+
14
+ const parent = pathService.dirname(current)
15
+ if (parent === current) {
16
+ return Option.none<string>()
17
+ }
18
+ current = parent
19
+ }
20
+ })
21
+
22
+ export const resolveLalphDirectory = Effect.fnUntraced(function* () {
23
+ const fs = yield* FileSystem.FileSystem
24
+ const pathService = yield* Path.Path
25
+ const cwd = pathService.resolve(".")
26
+
27
+ const inCwd = yield* fs.exists(pathService.join(cwd, ".lalph"))
28
+ if (inCwd) {
29
+ return cwd
30
+ }
31
+
32
+ const projectRoot = yield* findProjectRoot(cwd)
33
+ if (Option.isSome(projectRoot)) {
34
+ const inProjectRoot = yield* fs.exists(
35
+ pathService.join(projectRoot.value, ".lalph"),
36
+ )
37
+ if (inProjectRoot) {
38
+ return projectRoot.value
39
+ }
40
+ }
41
+
42
+ return cwd
43
+ })