lalph 0.1.57 → 0.1.58
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 +63 -18
- package/package.json +1 -1
- package/src/Linear.ts +9 -1
- package/src/Prd.ts +26 -0
- package/src/commands/root.ts +21 -15
package/dist/cli.mjs
CHANGED
|
@@ -5579,6 +5579,24 @@ const makeOrder$2 = Tuple$2;
|
|
|
5579
5579
|
//#endregion
|
|
5580
5580
|
//#region node_modules/.pnpm/effect@https+++pkg.pr.new+Effect-TS+effect-smol+effect@ebe9823_c0f064f881620a0abcd6a2c2ac2ce9e8/node_modules/effect/dist/Iterable.js
|
|
5581
5581
|
/**
|
|
5582
|
+
* Determine if an `Iterable` is empty
|
|
5583
|
+
*
|
|
5584
|
+
* @example
|
|
5585
|
+
* ```ts
|
|
5586
|
+
* import { isEmpty } from "effect/Iterable"
|
|
5587
|
+
* import * as assert from "node:assert"
|
|
5588
|
+
*
|
|
5589
|
+
* assert.deepStrictEqual(isEmpty([]), true)
|
|
5590
|
+
* assert.deepStrictEqual(isEmpty([1, 2, 3]), false)
|
|
5591
|
+
* ```
|
|
5592
|
+
*
|
|
5593
|
+
* @category guards
|
|
5594
|
+
* @since 2.0.0
|
|
5595
|
+
*/
|
|
5596
|
+
const isEmpty$1 = (self$1) => {
|
|
5597
|
+
return self$1[Symbol.iterator]().next().done === true;
|
|
5598
|
+
};
|
|
5599
|
+
/**
|
|
5582
5600
|
* Get the first element of a `Iterable`, or throw an error if the `Iterable` is empty.
|
|
5583
5601
|
*
|
|
5584
5602
|
* @example
|
|
@@ -134730,7 +134748,7 @@ var Linear = class extends Service()("lalph/Linear", { make: gen(function* () {
|
|
|
134730
134748
|
}) : use$2(f);
|
|
134731
134749
|
return [connection.nodes, some(connection).pipe(filter$5((c) => c.pageInfo.hasNextPage))];
|
|
134732
134750
|
}));
|
|
134733
|
-
const projects = stream$3((client) => client.projects());
|
|
134751
|
+
const projects = stream$3((client) => client.projects({ filter: { status: { type: { nin: ["canceled", "completed"] } } } }));
|
|
134734
134752
|
const labels = stream$3((client) => client.issueLabels());
|
|
134735
134753
|
const states = yield* runCollect(stream$3((client) => client.workflowStates()));
|
|
134736
134754
|
const viewer = yield* use$2((client) => client.viewer);
|
|
@@ -141566,15 +141584,30 @@ var Prd = class extends Service()("lalph/Prd", { make: gen(function* () {
|
|
|
141566
141584
|
state: "todo"
|
|
141567
141585
|
});
|
|
141568
141586
|
});
|
|
141569
|
-
if (worktree.inExisting)
|
|
141570
|
-
|
|
141571
|
-
|
|
141572
|
-
|
|
141573
|
-
|
|
141574
|
-
|
|
141575
|
-
|
|
141576
|
-
|
|
141577
|
-
|
|
141587
|
+
if (worktree.inExisting) {
|
|
141588
|
+
const initialPrdIssues = yield* readPrd;
|
|
141589
|
+
return {
|
|
141590
|
+
path: prdFile,
|
|
141591
|
+
mergableGithubPrs,
|
|
141592
|
+
maybeRevertIssue,
|
|
141593
|
+
revertUpdatedIssues: gen(function* () {
|
|
141594
|
+
const updated = yield* readPrd;
|
|
141595
|
+
for (const issue of updated) {
|
|
141596
|
+
if (issue.state !== "in-progress") continue;
|
|
141597
|
+
const prevIssue = initialPrdIssues.find((i) => i.id === issue.id);
|
|
141598
|
+
if (!prevIssue || prevIssue.state === "in-progress") continue;
|
|
141599
|
+
yield* source.updateIssue({
|
|
141600
|
+
issueId: issue.id,
|
|
141601
|
+
state: prevIssue.state
|
|
141602
|
+
});
|
|
141603
|
+
}
|
|
141604
|
+
}),
|
|
141605
|
+
flagUnmergable,
|
|
141606
|
+
findById: fnUntraced(function* (issueId) {
|
|
141607
|
+
return (yield* readPrd).find((i) => i.id === issueId) ?? null;
|
|
141608
|
+
})
|
|
141609
|
+
};
|
|
141610
|
+
}
|
|
141578
141611
|
yield* addFinalizer(() => ignore(fs.remove(prdFile)));
|
|
141579
141612
|
let current = yield* source.issues;
|
|
141580
141613
|
yield* fs.writeFileString(prdFile, PrdIssue.arrayToYaml(current));
|
|
@@ -141632,6 +141665,15 @@ var Prd = class extends Service()("lalph/Prd", { make: gen(function* () {
|
|
|
141632
141665
|
path: prdFile,
|
|
141633
141666
|
mergableGithubPrs,
|
|
141634
141667
|
maybeRevertIssue,
|
|
141668
|
+
revertUpdatedIssues: gen(function* () {
|
|
141669
|
+
for (const issue of updatedIssues.values()) {
|
|
141670
|
+
if (issue.state !== "done") continue;
|
|
141671
|
+
yield* source.updateIssue({
|
|
141672
|
+
issueId: issue.id,
|
|
141673
|
+
state: "todo"
|
|
141674
|
+
});
|
|
141675
|
+
}
|
|
141676
|
+
}),
|
|
141635
141677
|
flagUnmergable,
|
|
141636
141678
|
findById
|
|
141637
141679
|
};
|
|
@@ -141708,7 +141750,8 @@ const commandRoot = make$27("lalph", {
|
|
|
141708
141750
|
iterations$1 = currentIteration;
|
|
141709
141751
|
return log$1(`No more work to process, ending after ${currentIteration} iteration(s).`);
|
|
141710
141752
|
}
|
|
141711
|
-
|
|
141753
|
+
const log$2 = isEmpty$1(fibers) ? log$1("No more work to process, waiting 30 seconds...") : void_$1;
|
|
141754
|
+
return andThen(log$2, sleep(seconds(30)));
|
|
141712
141755
|
},
|
|
141713
141756
|
QuitError(_) {
|
|
141714
141757
|
quit = true;
|
|
@@ -141748,6 +141791,13 @@ const run = fnUntraced(function* (options) {
|
|
|
141748
141791
|
const currentBranch = (dir) => make$21({ cwd: dir })`git branch --show-current`.pipe(string, flatMap((output) => some(output.trim()).pipe(filter$5((b) => b.length > 0), fromOption)));
|
|
141749
141792
|
if (isSome(options.targetBranch)) yield* exec`git checkout ${`origin/${options.targetBranch.value}`}`;
|
|
141750
141793
|
yield* gen(function* () {
|
|
141794
|
+
let taskId = void 0;
|
|
141795
|
+
yield* addFinalizer(fnUntraced(function* (exit$2) {
|
|
141796
|
+
if (exit$2._tag === "Success") return;
|
|
141797
|
+
const prd$1 = yield* Prd;
|
|
141798
|
+
if (taskId) yield* prd$1.maybeRevertIssue({ issueId: taskId });
|
|
141799
|
+
else yield* prd$1.revertUpdatedIssues;
|
|
141800
|
+
}, ignore));
|
|
141751
141801
|
yield* cliAgent.command({
|
|
141752
141802
|
worktree,
|
|
141753
141803
|
prompt: promptGen.promptChoose,
|
|
@@ -141758,12 +141808,7 @@ const run = fnUntraced(function* (options) {
|
|
|
141758
141808
|
onTimeout: () => fail$4(new RunnerStalled())
|
|
141759
141809
|
}));
|
|
141760
141810
|
const taskJson = yield* fs.readFileString(pathService.join(worktree.directory, ".lalph", "task.json"));
|
|
141761
|
-
|
|
141762
|
-
yield* addFinalizer(fnUntraced(function* (exit$2) {
|
|
141763
|
-
if (exit$2._tag === "Success") return;
|
|
141764
|
-
const prd$1 = yield* Prd;
|
|
141765
|
-
yield* ignore(prd$1.maybeRevertIssue({ issueId: taskId }));
|
|
141766
|
-
}));
|
|
141811
|
+
taskId = (yield* decodeEffect(ChosenTask)(taskJson)).id;
|
|
141767
141812
|
yield* completeWith(options.startedDeferred, void_$1);
|
|
141768
141813
|
const exitCode$1 = yield* execWithStallTimeout(cliAgent.command({
|
|
141769
141814
|
worktree,
|
|
@@ -141932,7 +141977,7 @@ const commandAgent = make$27("agent").pipe(withDescription("Select the CLI agent
|
|
|
141932
141977
|
|
|
141933
141978
|
//#endregion
|
|
141934
141979
|
//#region package.json
|
|
141935
|
-
var version = "0.1.
|
|
141980
|
+
var version = "0.1.58";
|
|
141936
141981
|
|
|
141937
141982
|
//#endregion
|
|
141938
141983
|
//#region src/cli.ts
|
package/package.json
CHANGED
package/src/Linear.ts
CHANGED
|
@@ -68,7 +68,15 @@ class Linear extends ServiceMap.Service<Linear>()("lalph/Linear", {
|
|
|
68
68
|
}),
|
|
69
69
|
)
|
|
70
70
|
|
|
71
|
-
const projects = stream((client) =>
|
|
71
|
+
const projects = stream((client) =>
|
|
72
|
+
client.projects({
|
|
73
|
+
filter: {
|
|
74
|
+
status: {
|
|
75
|
+
type: { nin: ["canceled", "completed"] },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
)
|
|
72
80
|
const labels = stream((client) => client.issueLabels())
|
|
73
81
|
const states = yield* Stream.runCollect(
|
|
74
82
|
stream((client) => client.workflowStates()),
|
package/src/Prd.ts
CHANGED
|
@@ -28,6 +28,10 @@ export class Prd extends ServiceMap.Service<
|
|
|
28
28
|
readonly maybeRevertIssue: (options: {
|
|
29
29
|
readonly issueId: string
|
|
30
30
|
}) => Effect.Effect<void, PlatformError.PlatformError | IssueSourceError>
|
|
31
|
+
readonly revertUpdatedIssues: Effect.Effect<
|
|
32
|
+
void,
|
|
33
|
+
PlatformError.PlatformError | IssueSourceError
|
|
34
|
+
>
|
|
31
35
|
readonly flagUnmergable: (options: {
|
|
32
36
|
readonly issueId: string
|
|
33
37
|
}) => Effect.Effect<void, IssueSourceError>
|
|
@@ -98,10 +102,23 @@ export class Prd extends ServiceMap.Service<
|
|
|
98
102
|
})
|
|
99
103
|
|
|
100
104
|
if (worktree.inExisting) {
|
|
105
|
+
const initialPrdIssues = yield* readPrd
|
|
101
106
|
return {
|
|
102
107
|
path: prdFile,
|
|
103
108
|
mergableGithubPrs,
|
|
104
109
|
maybeRevertIssue,
|
|
110
|
+
revertUpdatedIssues: Effect.gen(function* () {
|
|
111
|
+
const updated = yield* readPrd
|
|
112
|
+
for (const issue of updated) {
|
|
113
|
+
if (issue.state !== "in-progress") continue
|
|
114
|
+
const prevIssue = initialPrdIssues.find((i) => i.id === issue.id)
|
|
115
|
+
if (!prevIssue || prevIssue.state === "in-progress") continue
|
|
116
|
+
yield* source.updateIssue({
|
|
117
|
+
issueId: issue.id!,
|
|
118
|
+
state: prevIssue.state,
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
105
122
|
flagUnmergable,
|
|
106
123
|
findById: Effect.fnUntraced(function* (issueId: string) {
|
|
107
124
|
const prdIssues = yield* readPrd
|
|
@@ -222,6 +239,15 @@ export class Prd extends ServiceMap.Service<
|
|
|
222
239
|
path: prdFile,
|
|
223
240
|
mergableGithubPrs,
|
|
224
241
|
maybeRevertIssue,
|
|
242
|
+
revertUpdatedIssues: Effect.gen(function* () {
|
|
243
|
+
for (const issue of updatedIssues.values()) {
|
|
244
|
+
if (issue.state !== "done") continue
|
|
245
|
+
yield* source.updateIssue({
|
|
246
|
+
issueId: issue.id!,
|
|
247
|
+
state: "todo",
|
|
248
|
+
})
|
|
249
|
+
}
|
|
250
|
+
}),
|
|
225
251
|
flagUnmergable,
|
|
226
252
|
findById,
|
|
227
253
|
}
|
package/src/commands/root.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
FiberSet,
|
|
10
10
|
FileSystem,
|
|
11
11
|
Filter,
|
|
12
|
+
Iterable,
|
|
12
13
|
Layer,
|
|
13
14
|
Option,
|
|
14
15
|
Path,
|
|
@@ -163,9 +164,10 @@ export const commandRoot = Command.make("lalph", {
|
|
|
163
164
|
`No more work to process, ending after ${currentIteration} iteration(s).`,
|
|
164
165
|
)
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
-
"No more work to process, waiting 30 seconds..."
|
|
168
|
-
|
|
167
|
+
const log = Iterable.isEmpty(fibers)
|
|
168
|
+
? Effect.log("No more work to process, waiting 30 seconds...")
|
|
169
|
+
: Effect.void
|
|
170
|
+
return Effect.andThen(log, Effect.sleep(Duration.seconds(30)))
|
|
169
171
|
},
|
|
170
172
|
QuitError(_) {
|
|
171
173
|
quit = true
|
|
@@ -268,6 +270,21 @@ const run = Effect.fnUntraced(
|
|
|
268
270
|
}
|
|
269
271
|
|
|
270
272
|
yield* Effect.gen(function* () {
|
|
273
|
+
let taskId: string | undefined = undefined
|
|
274
|
+
yield* Effect.addFinalizer(
|
|
275
|
+
Effect.fnUntraced(function* (exit) {
|
|
276
|
+
if (exit._tag === "Success") return
|
|
277
|
+
const prd = yield* Prd
|
|
278
|
+
if (taskId) {
|
|
279
|
+
yield* prd.maybeRevertIssue({
|
|
280
|
+
issueId: taskId,
|
|
281
|
+
})
|
|
282
|
+
} else {
|
|
283
|
+
yield* prd.revertUpdatedIssues
|
|
284
|
+
}
|
|
285
|
+
}, Effect.ignore),
|
|
286
|
+
)
|
|
287
|
+
|
|
271
288
|
yield* cliAgent
|
|
272
289
|
.command({
|
|
273
290
|
worktree,
|
|
@@ -286,18 +303,7 @@ const run = Effect.fnUntraced(
|
|
|
286
303
|
const taskJson = yield* fs.readFileString(
|
|
287
304
|
pathService.join(worktree.directory, ".lalph", "task.json"),
|
|
288
305
|
)
|
|
289
|
-
|
|
290
|
-
yield* Effect.addFinalizer(
|
|
291
|
-
Effect.fnUntraced(function* (exit) {
|
|
292
|
-
if (exit._tag === "Success") return
|
|
293
|
-
const prd = yield* Prd
|
|
294
|
-
yield* Effect.ignore(
|
|
295
|
-
prd.maybeRevertIssue({
|
|
296
|
-
issueId: taskId,
|
|
297
|
-
}),
|
|
298
|
-
)
|
|
299
|
-
}),
|
|
300
|
-
)
|
|
306
|
+
taskId = (yield* Schema.decodeEffect(ChosenTask)(taskJson)).id
|
|
301
307
|
|
|
302
308
|
yield* Deferred.completeWith(options.startedDeferred, Effect.void)
|
|
303
309
|
|