lalph 0.3.107 → 0.3.109
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/dist/cli.mjs +19 -17
- package/package.json +1 -1
- package/src/Agents/chooser.ts +6 -4
- package/src/GitFlow.ts +3 -4
- package/src/IssueSource.ts +14 -6
- package/src/Prd.ts +1 -15
- package/src/commands/root.ts +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -178369,6 +178369,7 @@ const IssuesChange = taggedEnum();
|
|
|
178369
178369
|
var IssueSource = class IssueSource extends Service$1()("lalph/IssueSource") {
|
|
178370
178370
|
static make(impl) {
|
|
178371
178371
|
return gen(function* () {
|
|
178372
|
+
const handle = yield* make$58();
|
|
178372
178373
|
const refs = yield* make$48({
|
|
178373
178374
|
lookup: fnUntraced(function* (projectId) {
|
|
178374
178375
|
const ref = yield* make$47(IssuesChange.Internal({ issues: yield* pipe$1(impl.issues(projectId), orElseSucceed(empty$17)) }));
|
|
@@ -178377,10 +178378,15 @@ var IssueSource = class IssueSource extends Service$1()("lalph/IssueSource") {
|
|
|
178377
178378
|
}),
|
|
178378
178379
|
capacity: Number.MAX_SAFE_INTEGER
|
|
178379
178380
|
});
|
|
178381
|
+
const updateIssues = fnUntraced(function* (projectId) {
|
|
178382
|
+
const issues = yield* impl.issues(projectId);
|
|
178383
|
+
yield* set$3(yield* get$6(refs, projectId), IssuesChange.Internal({ issues }));
|
|
178384
|
+
return issues;
|
|
178385
|
+
});
|
|
178380
178386
|
const update$2 = fnUntraced(function* (projectId, f) {
|
|
178381
178387
|
yield* update(yield* get$6(refs, projectId), (change) => IssuesChange.Internal({ issues: f(change.issues) }));
|
|
178388
|
+
yield* run$4(handle, delay(updateIssues(projectId), "5 seconds"));
|
|
178382
178389
|
});
|
|
178383
|
-
const updateIssues = (projectId) => pipe$1(impl.issues(projectId), tap$1((issues) => update$2(projectId, () => issues)));
|
|
178384
178390
|
return IssueSource.of({
|
|
178385
178391
|
...impl,
|
|
178386
178392
|
ref: (projectId) => get$6(refs, projectId),
|
|
@@ -241356,7 +241362,7 @@ var Prd = class extends Service$1()("lalph/Prd", { make: gen(function* () {
|
|
|
241356
241362
|
const getCurrentIssues = get$5(issuesRef).pipe(map$10((i) => i.issues));
|
|
241357
241363
|
const syncSemaphore = makeUnsafe$9(1);
|
|
241358
241364
|
const maybeRevertIssue = fnUntraced(function* (options) {
|
|
241359
|
-
const issue =
|
|
241365
|
+
const issue = yield* source.findById(projectId, options.issueId);
|
|
241360
241366
|
if (!issue || issue.state === "in-review") return;
|
|
241361
241367
|
yield* source.updateIssue({
|
|
241362
241368
|
projectId,
|
|
@@ -241453,9 +241459,6 @@ var Prd = class extends Service$1()("lalph/Prd", { make: gen(function* () {
|
|
|
241453
241459
|
}, scoped$1, withSpan$1("Prd.updateSync"), run$4(updateSyncHandle, { onlyIfMissing: true }), syncSemaphore.withPermitsIfAvailable(1));
|
|
241454
241460
|
yield* fs.watch(lalphDir).pipe(filter$3((event) => event.path.endsWith("prd.yml")), debounce(50), runForEach((_) => clear(updateSyncHandle).pipe(andThen(ignore$1(sync$3)))), retry$1(forever$1), forkScoped);
|
|
241455
241461
|
yield* changes(issuesRef).pipe(filter$3((change) => change._tag === "External"), runForEach((s) => updateSync(s.issues)), forkScoped);
|
|
241456
|
-
const findById = fnUntraced(function* (issueId) {
|
|
241457
|
-
return (yield* getCurrentIssues).find((i) => i.id === issueId) ?? null;
|
|
241458
|
-
});
|
|
241459
241462
|
return {
|
|
241460
241463
|
path: prdFile,
|
|
241461
241464
|
maybeRevertIssue,
|
|
@@ -241470,7 +241473,6 @@ var Prd = class extends Service$1()("lalph/Prd", { make: gen(function* () {
|
|
|
241470
241473
|
}
|
|
241471
241474
|
})),
|
|
241472
241475
|
flagUnmergable,
|
|
241473
|
-
findById,
|
|
241474
241476
|
setChosenIssueId,
|
|
241475
241477
|
setAutoMerge
|
|
241476
241478
|
};
|
|
@@ -241485,7 +241487,6 @@ var Prd = class extends Service$1()("lalph/Prd", { make: gen(function* () {
|
|
|
241485
241487
|
maybeRevertIssue: () => void_$2,
|
|
241486
241488
|
revertUpdatedIssues: void_$2,
|
|
241487
241489
|
flagUnmergable: () => void_$2,
|
|
241488
|
-
findById: () => succeed$4(null),
|
|
241489
241490
|
setChosenIssueId: () => void_$2,
|
|
241490
241491
|
setAutoMerge: () => void_$2
|
|
241491
241492
|
});
|
|
@@ -241754,7 +241755,7 @@ After making any changes, commit and push them to the same pull request.
|
|
|
241754
241755
|
prState = yield* worktree.viewPrState(prState.value.number);
|
|
241755
241756
|
yield* log$1("PR state after merge", prState);
|
|
241756
241757
|
if (isSome(prState) && prState.value.state === "MERGED") {
|
|
241757
|
-
const issue = yield*
|
|
241758
|
+
const issue = yield* source.findById(projectId, options.issueId);
|
|
241758
241759
|
if (issue && issue.state !== "done") yield* source.updateIssue({
|
|
241759
241760
|
projectId,
|
|
241760
241761
|
issueId: options.issueId,
|
|
@@ -241799,11 +241800,11 @@ But you **do not** need to git push your changes or switch branches.
|
|
|
241799
241800
|
}
|
|
241800
241801
|
}),
|
|
241801
241802
|
autoMerge: fnUntraced(function* (options) {
|
|
241802
|
-
const
|
|
241803
|
+
const source = yield* IssueSource;
|
|
241803
241804
|
const projectId = yield* CurrentProjectId;
|
|
241804
|
-
const issue = yield*
|
|
241805
|
+
const issue = yield* source.findById(projectId, options.issueId);
|
|
241805
241806
|
if (!issue || issue.state !== "in-review") return;
|
|
241806
|
-
yield*
|
|
241807
|
+
yield* source.updateIssue({
|
|
241807
241808
|
projectId,
|
|
241808
241809
|
issueId: options.issueId,
|
|
241809
241810
|
state: "done"
|
|
@@ -241840,11 +241841,12 @@ var GitFlowError = class extends TaggedError("GitFlowError") {};
|
|
|
241840
241841
|
//#endregion
|
|
241841
241842
|
//#region src/Agents/chooser.ts
|
|
241842
241843
|
const agentChooser = fnUntraced(function* (options) {
|
|
241844
|
+
const projectId = yield* CurrentProjectId;
|
|
241843
241845
|
const fs = yield* FileSystem;
|
|
241844
241846
|
const pathService = yield* Path$1;
|
|
241845
241847
|
const worktree = yield* Worktree;
|
|
241846
241848
|
const promptGen = yield* PromptGen;
|
|
241847
|
-
const
|
|
241849
|
+
const source = yield* IssueSource;
|
|
241848
241850
|
const gitFlow = yield* GitFlow;
|
|
241849
241851
|
const waitForFile = yield* makeWaitForFile;
|
|
241850
241852
|
if (!options.preset.cliAgent.command) {
|
|
@@ -241856,7 +241858,7 @@ const agentChooser = fnUntraced(function* (options) {
|
|
|
241856
241858
|
stallTimeout: options.stallTimeout,
|
|
241857
241859
|
mode: "choose"
|
|
241858
241860
|
}).pipe(provideService$2(ChosenTaskDeferred, deferred), flatMap$5(() => fail$6(new ChosenTaskNotFound$1())), raceFirst(_await(deferred)));
|
|
241859
|
-
const prdTask = yield*
|
|
241861
|
+
const prdTask = yield* source.findById(projectId, result.taskId);
|
|
241860
241862
|
if (!prdTask) return yield* new ChosenTaskNotFound$1();
|
|
241861
241863
|
return {
|
|
241862
241864
|
id: result.taskId,
|
|
@@ -241874,7 +241876,7 @@ const agentChooser = fnUntraced(function* (options) {
|
|
|
241874
241876
|
onTimeout: () => fail$6(new RunnerStalled())
|
|
241875
241877
|
}), raceFirst(taskJsonCreated));
|
|
241876
241878
|
return yield* pipe$1(fs.readFileString(pathService.join(worktree.directory, ".lalph", "task.json")), flatMap$5(decodeEffect(ChosenTask)), mapError$2((_) => new ChosenTaskNotFound$1()), flatMap$5(fnUntraced(function* (task) {
|
|
241877
|
-
const prdTask = yield*
|
|
241879
|
+
const prdTask = yield* source.findById(projectId, task.id);
|
|
241878
241880
|
if (prdTask) return {
|
|
241879
241881
|
...task,
|
|
241880
241882
|
prd: prdTask
|
|
@@ -242086,7 +242088,7 @@ const run = fnUntraced(function* (options) {
|
|
|
242086
242088
|
}
|
|
242087
242089
|
const taskPreset = getOrElse$2(yield* source.issueCliAgentPreset(chosenTask.prd), () => preset);
|
|
242088
242090
|
const catchStallInReview = (effect) => catchIf$2(effect, (u) => u instanceof RunnerStalled, fnUntraced(function* (e) {
|
|
242089
|
-
if ((yield*
|
|
242091
|
+
if ((yield* source.findById(projectId, taskId))?.state === "in-review") return;
|
|
242090
242092
|
return yield* e;
|
|
242091
242093
|
}));
|
|
242092
242094
|
if (yield* gen(function* () {
|
|
@@ -242157,7 +242159,7 @@ const run = fnUntraced(function* (options) {
|
|
|
242157
242159
|
targetBranch: getOrUndefined$2(options.targetBranch),
|
|
242158
242160
|
issueId: taskId
|
|
242159
242161
|
});
|
|
242160
|
-
if ((yield*
|
|
242162
|
+
if ((yield* source.findById(projectId, taskId))?.autoMerge) yield* gitFlow.autoMerge({
|
|
242161
242163
|
targetBranch: getOrUndefined$2(options.targetBranch),
|
|
242162
242164
|
issueId: taskId,
|
|
242163
242165
|
worktree
|
|
@@ -242682,7 +242684,7 @@ const commandEdit = make$60("edit").pipe(withDescription("Open the selected proj
|
|
|
242682
242684
|
const commandSource = make$60("source").pipe(withDescription("Select the issue source to use (e.g. GitHub Issues or Linear). This applies to all projects."), withHandler(() => selectIssueSource), provide(Settings.layer));
|
|
242683
242685
|
//#endregion
|
|
242684
242686
|
//#region package.json
|
|
242685
|
-
var version = "0.3.
|
|
242687
|
+
var version = "0.3.109";
|
|
242686
242688
|
//#endregion
|
|
242687
242689
|
//#region src/Tracing.ts
|
|
242688
242690
|
const TracingLayer = unwrap$3(gen(function* () {
|
package/package.json
CHANGED
package/src/Agents/chooser.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
Schema,
|
|
10
10
|
} from "effect"
|
|
11
11
|
import { PromptGen } from "../PromptGen.ts"
|
|
12
|
-
import { Prd } from "../Prd.ts"
|
|
13
12
|
import { ChildProcess } from "effect/unstable/process"
|
|
14
13
|
import { Worktree } from "../Worktree.ts"
|
|
15
14
|
import { RunnerStalled } from "../domain/Errors.ts"
|
|
@@ -18,16 +17,19 @@ import { GitFlow } from "../GitFlow.ts"
|
|
|
18
17
|
import type { CliAgentPreset } from "../domain/CliAgentPreset.ts"
|
|
19
18
|
import { runClanka } from "../Clanka.ts"
|
|
20
19
|
import { ChosenTaskDeferred } from "../TaskTools.ts"
|
|
20
|
+
import { IssueSource } from "../IssueSource.ts"
|
|
21
|
+
import { CurrentProjectId } from "../Settings.ts"
|
|
21
22
|
|
|
22
23
|
export const agentChooser = Effect.fnUntraced(function* (options: {
|
|
23
24
|
readonly stallTimeout: Duration.Duration
|
|
24
25
|
readonly preset: CliAgentPreset
|
|
25
26
|
}) {
|
|
27
|
+
const projectId = yield* CurrentProjectId
|
|
26
28
|
const fs = yield* FileSystem.FileSystem
|
|
27
29
|
const pathService = yield* Path.Path
|
|
28
30
|
const worktree = yield* Worktree
|
|
29
31
|
const promptGen = yield* PromptGen
|
|
30
|
-
const
|
|
32
|
+
const source = yield* IssueSource
|
|
31
33
|
const gitFlow = yield* GitFlow
|
|
32
34
|
const waitForFile = yield* makeWaitForFile
|
|
33
35
|
|
|
@@ -45,7 +47,7 @@ export const agentChooser = Effect.fnUntraced(function* (options: {
|
|
|
45
47
|
Effect.flatMap(() => Effect.fail(new ChosenTaskNotFound())),
|
|
46
48
|
Effect.raceFirst(Deferred.await(deferred)),
|
|
47
49
|
)
|
|
48
|
-
const prdTask = yield*
|
|
50
|
+
const prdTask = yield* source.findById(projectId, result.taskId)
|
|
49
51
|
if (!prdTask) return yield* new ChosenTaskNotFound()
|
|
50
52
|
return {
|
|
51
53
|
id: result.taskId,
|
|
@@ -85,7 +87,7 @@ export const agentChooser = Effect.fnUntraced(function* (options: {
|
|
|
85
87
|
Effect.mapError((_) => new ChosenTaskNotFound()),
|
|
86
88
|
Effect.flatMap(
|
|
87
89
|
Effect.fnUntraced(function* (task) {
|
|
88
|
-
const prdTask = yield*
|
|
90
|
+
const prdTask = yield* source.findById(projectId, task.id)
|
|
89
91
|
if (prdTask) return { ...task, prd: prdTask }
|
|
90
92
|
return yield* new ChosenTaskNotFound()
|
|
91
93
|
}),
|
package/src/GitFlow.ts
CHANGED
|
@@ -103,7 +103,7 @@ After making any changes, commit and push them to the same pull request.
|
|
|
103
103
|
prState = yield* worktree.viewPrState(prState.value.number)
|
|
104
104
|
yield* Effect.log("PR state after merge", prState)
|
|
105
105
|
if (Option.isSome(prState) && prState.value.state === "MERGED") {
|
|
106
|
-
const issue = yield*
|
|
106
|
+
const issue = yield* source.findById(projectId, options.issueId)
|
|
107
107
|
if (issue && issue.state !== "done") {
|
|
108
108
|
yield* source.updateIssue({
|
|
109
109
|
projectId,
|
|
@@ -182,13 +182,12 @@ But you **do not** need to git push your changes or switch branches.
|
|
|
182
182
|
}
|
|
183
183
|
}),
|
|
184
184
|
autoMerge: Effect.fnUntraced(function* (options) {
|
|
185
|
-
const
|
|
185
|
+
const source = yield* IssueSource
|
|
186
186
|
const projectId = yield* CurrentProjectId
|
|
187
|
-
const issue = yield*
|
|
187
|
+
const issue = yield* source.findById(projectId, options.issueId)
|
|
188
188
|
if (!issue || issue.state !== "in-review") {
|
|
189
189
|
return
|
|
190
190
|
}
|
|
191
|
-
const source = yield* IssueSource
|
|
192
191
|
yield* source.updateIssue({
|
|
193
192
|
projectId,
|
|
194
193
|
issueId: options.issueId,
|
package/src/IssueSource.ts
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
Data,
|
|
4
4
|
Duration,
|
|
5
5
|
Effect,
|
|
6
|
+
FiberHandle,
|
|
6
7
|
Option,
|
|
7
8
|
Schema,
|
|
8
9
|
ScopedCache,
|
|
@@ -94,6 +95,8 @@ export class IssueSource extends ServiceMap.Service<
|
|
|
94
95
|
>()("lalph/IssueSource") {
|
|
95
96
|
static make(impl: Omit<IssueSource["Service"], "ref" | "findById">) {
|
|
96
97
|
return Effect.gen(function* () {
|
|
98
|
+
const handle = yield* FiberHandle.make()
|
|
99
|
+
|
|
97
100
|
const refs = yield* ScopedCache.make({
|
|
98
101
|
lookup: Effect.fnUntraced(function* (projectId: ProjectId) {
|
|
99
102
|
const ref = yield* SubscriptionRef.make<IssuesChange>(
|
|
@@ -125,6 +128,13 @@ export class IssueSource extends ServiceMap.Service<
|
|
|
125
128
|
capacity: Number.MAX_SAFE_INTEGER,
|
|
126
129
|
})
|
|
127
130
|
|
|
131
|
+
const updateIssues = Effect.fnUntraced(function* (projectId: ProjectId) {
|
|
132
|
+
const issues = yield* impl.issues(projectId)
|
|
133
|
+
const ref = yield* ScopedCache.get(refs, projectId)
|
|
134
|
+
yield* SubscriptionRef.set(ref, IssuesChange.Internal({ issues }))
|
|
135
|
+
return issues
|
|
136
|
+
})
|
|
137
|
+
|
|
128
138
|
const update = Effect.fnUntraced(function* (
|
|
129
139
|
projectId: ProjectId,
|
|
130
140
|
f: (_: ReadonlyArray<PrdIssue>) => ReadonlyArray<PrdIssue>,
|
|
@@ -135,13 +145,11 @@ export class IssueSource extends ServiceMap.Service<
|
|
|
135
145
|
issues: f(change.issues),
|
|
136
146
|
}),
|
|
137
147
|
)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
pipe(
|
|
142
|
-
impl.issues(projectId),
|
|
143
|
-
Effect.tap((issues) => update(projectId, () => issues)),
|
|
148
|
+
yield* FiberHandle.run(
|
|
149
|
+
handle,
|
|
150
|
+
Effect.delay(updateIssues(projectId), "5 seconds"),
|
|
144
151
|
)
|
|
152
|
+
})
|
|
145
153
|
|
|
146
154
|
return IssueSource.of({
|
|
147
155
|
...impl,
|
package/src/Prd.ts
CHANGED
|
@@ -32,12 +32,6 @@ export class Prd extends ServiceMap.Service<
|
|
|
32
32
|
readonly flagUnmergable: (options: {
|
|
33
33
|
readonly issueId: string
|
|
34
34
|
}) => Effect.Effect<void, IssueSourceError>
|
|
35
|
-
readonly findById: (
|
|
36
|
-
issueId: string,
|
|
37
|
-
) => Effect.Effect<
|
|
38
|
-
PrdIssue | null,
|
|
39
|
-
PlatformError.PlatformError | IssueSourceError
|
|
40
|
-
>
|
|
41
35
|
readonly setChosenIssueId: (issueId: string | null) => Effect.Effect<void>
|
|
42
36
|
readonly setAutoMerge: (enabled: boolean) => Effect.Effect<void>
|
|
43
37
|
}
|
|
@@ -68,8 +62,7 @@ export class Prd extends ServiceMap.Service<
|
|
|
68
62
|
const maybeRevertIssue = Effect.fnUntraced(function* (options: {
|
|
69
63
|
readonly issueId: string
|
|
70
64
|
}) {
|
|
71
|
-
const
|
|
72
|
-
const issue = updated.find((i) => i.id === options.issueId)
|
|
65
|
+
const issue = yield* source.findById(projectId, options.issueId)
|
|
73
66
|
if (!issue || issue.state === "in-review") return
|
|
74
67
|
yield* source.updateIssue({
|
|
75
68
|
projectId,
|
|
@@ -244,11 +237,6 @@ export class Prd extends ServiceMap.Service<
|
|
|
244
237
|
Effect.forkScoped,
|
|
245
238
|
)
|
|
246
239
|
|
|
247
|
-
const findById = Effect.fnUntraced(function* (issueId: string) {
|
|
248
|
-
const current = yield* getCurrentIssues
|
|
249
|
-
return current.find((i) => i.id === issueId) ?? null
|
|
250
|
-
})
|
|
251
|
-
|
|
252
240
|
return {
|
|
253
241
|
path: prdFile,
|
|
254
242
|
maybeRevertIssue,
|
|
@@ -265,7 +253,6 @@ export class Prd extends ServiceMap.Service<
|
|
|
265
253
|
}),
|
|
266
254
|
),
|
|
267
255
|
flagUnmergable,
|
|
268
|
-
findById,
|
|
269
256
|
setChosenIssueId,
|
|
270
257
|
setAutoMerge,
|
|
271
258
|
}
|
|
@@ -287,7 +274,6 @@ export class Prd extends ServiceMap.Service<
|
|
|
287
274
|
maybeRevertIssue: () => Effect.void,
|
|
288
275
|
revertUpdatedIssues: Effect.void,
|
|
289
276
|
flagUnmergable: () => Effect.void,
|
|
290
|
-
findById: () => Effect.succeed(null),
|
|
291
277
|
setChosenIssueId: () => Effect.void,
|
|
292
278
|
setAutoMerge: () => Effect.void,
|
|
293
279
|
})
|
package/src/commands/root.ts
CHANGED
|
@@ -200,7 +200,7 @@ const run = Effect.fnUntraced(
|
|
|
200
200
|
effect,
|
|
201
201
|
(u): u is RunnerStalled => u instanceof RunnerStalled,
|
|
202
202
|
Effect.fnUntraced(function* (e) {
|
|
203
|
-
const task = yield*
|
|
203
|
+
const task = yield* source.findById(projectId, taskId!)
|
|
204
204
|
const inReview = task?.state === "in-review"
|
|
205
205
|
if (inReview) return
|
|
206
206
|
return yield* e
|
|
@@ -315,7 +315,7 @@ const run = Effect.fnUntraced(
|
|
|
315
315
|
issueId: taskId,
|
|
316
316
|
})
|
|
317
317
|
|
|
318
|
-
const task = yield*
|
|
318
|
+
const task = yield* source.findById(projectId, taskId)
|
|
319
319
|
if (task?.autoMerge) {
|
|
320
320
|
yield* gitFlow.autoMerge({
|
|
321
321
|
targetBranch: Option.getOrUndefined(options.targetBranch),
|