lalph 0.1.112 → 0.1.114

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 CHANGED
@@ -142414,6 +142414,26 @@ const LinearIssueSource = effect$1(IssueSource, gen(function* () {
142414
142414
  const linearIssueId = identifierMap.get(issueId);
142415
142415
  yield* linear.use((c) => c.updateIssue(linearIssueId, { stateId: canceledState.id }));
142416
142416
  }, mapError$2((cause) => new IssueSourceError({ cause }))),
142417
+ status: gen(function* () {
142418
+ const label = labelId;
142419
+ const autoMergeLabel = autoMergeLabelId;
142420
+ const teams = yield* runCollect(linear.stream(() => project.teams()));
142421
+ const labels = yield* runCollect(linear.labels);
142422
+ const teamName = teams.find((team) => team.id === teamId)?.name ?? teamId;
142423
+ const resolveLabel = (value) => match$7(value, {
142424
+ onNone: () => "None",
142425
+ onSome: (id) => labels.find((label) => label.id === id)?.name ?? id
142426
+ });
142427
+ const resolveAutoMergeLabel = (value) => match$7(value, {
142428
+ onNone: () => "Disabled",
142429
+ onSome: (id) => labels.find((label) => label.id === id)?.name ?? id
142430
+ });
142431
+ console.log(`Issue source: Linear`);
142432
+ console.log(`Project: ${project.name}`);
142433
+ console.log(`Team: ${teamName}`);
142434
+ console.log(`Label filter: ${resolveLabel(label)}`);
142435
+ console.log(`Auto-merge label: ${resolveAutoMergeLabel(autoMergeLabel)}`);
142436
+ }).pipe(mapError$2((cause) => new IssueSourceError({ cause }))),
142417
142437
  ensureInProgress: () => void_$1
142418
142438
  });
142419
142439
  })).pipe(provide$3([Linear.layer, layer$17]));
@@ -148959,6 +148979,18 @@ const GithubIssueSource = effect$1(IssueSource, gen(function* () {
148959
148979
  state: "closed"
148960
148980
  });
148961
148981
  }, mapError$2((cause) => new IssueSourceError({ cause }))),
148982
+ status: sync(() => {
148983
+ console.log(`Issue source: GitHub Issues`);
148984
+ console.log(`Repository: ${cli.owner}/${cli.repo}`);
148985
+ console.log(`Label filter: ${match$7(labelFilter, {
148986
+ onNone: () => "None",
148987
+ onSome: (value) => value
148988
+ })}`);
148989
+ console.log(`Auto-merge label: ${match$7(autoMergeLabelName, {
148990
+ onNone: () => "Disabled",
148991
+ onSome: (value) => value
148992
+ })}`);
148993
+ }),
148962
148994
  ensureInProgress: fnUntraced(function* (issueId) {
148963
148995
  const issueNumber = Number(issueId.slice(1));
148964
148996
  yield* pipe(github.request((rest) => rest.issues.get({
@@ -149003,10 +149035,47 @@ const getOrSelectAutoMergeLabel = gen(function* () {
149003
149035
  const resetGithub = labelFilter.set(none$3()).pipe(andThen(autoMergeLabel.set(none$3())));
149004
149036
  const maybeNextPage = (page, linkHeader) => pipe(fromNullishOr$2(linkHeader), filter$8((_) => _.includes(`rel="next"`)), as$2(page + 1));
149005
149037
 
149038
+ //#endregion
149039
+ //#region src/Tracing.ts
149040
+ const TracingLayer = unwrap$3(gen(function* () {
149041
+ const logLevel = yield* MinimumLogLevel;
149042
+ if (isLessThan$1("Trace", logLevel)) return empty$14;
149043
+ return TracerLogger;
149044
+ }));
149045
+ const TracerLogger = gen(function* () {
149046
+ const loggers = yield* CurrentLoggers;
149047
+ const tracer = yield* Tracer;
149048
+ const fiber = getCurrent();
149049
+ const log = (message, time) => {
149050
+ const options = {
149051
+ message,
149052
+ fiber,
149053
+ date: new Date(Number(time / BigInt(1e6))),
149054
+ logLevel: "Trace",
149055
+ cause: empty$13
149056
+ };
149057
+ loggers.forEach((logger) => {
149058
+ logger.log(options);
149059
+ });
149060
+ };
149061
+ return make$55({ span(name, parent, annotations, links, startTime, kind, options) {
149062
+ const span = tracer.span(name, parent, annotations, links, startTime, kind, options);
149063
+ log(`${name}: started`, startTime);
149064
+ const oldEnd = span.end;
149065
+ span.end = (endTime, cause) => {
149066
+ const duration = nanos(endTime - span.status.startTime);
149067
+ log(`${name}: completed. Took ${format$2(duration)}`, endTime);
149068
+ return oldEnd.call(span, endTime, cause);
149069
+ };
149070
+ return span;
149071
+ } });
149072
+ }).pipe(effect$1(Tracer));
149073
+
149006
149074
  //#endregion
149007
149075
  //#region src/shared/runtime.ts
149008
149076
  const lalphMemoMap = makeMemoMapUnsafe();
149009
- const makeAtomRuntime = context({ memoMap: lalphMemoMap });
149077
+ const atomRuntime = context({ memoMap: lalphMemoMap });
149078
+ atomRuntime.addGlobalLayer(TracingLayer);
149010
149079
 
149011
149080
  //#endregion
149012
149081
  //#region src/IssueSources.ts
@@ -149021,7 +149090,7 @@ const issueSources = [{
149021
149090
  name: "GitHub Issues",
149022
149091
  layer: GithubIssueSource,
149023
149092
  reset: resetGithub,
149024
- githubPrInstructions: `At the start of your PR description, include a line that closes the issue, like: Closes {task id}.`
149093
+ githubPrInstructions: `At the start of your PR description, include a line that closes the issue: Closes {task id}`
149025
149094
  }];
149026
149095
  const selectedIssueSource = new Setting("issueSource", Literals(issueSources.map((s) => s.id)));
149027
149096
  const selectIssueSource = gen(function* () {
@@ -149044,6 +149113,9 @@ const getOrSelectIssueSource = gen(function* () {
149044
149113
  const resetCurrentIssueSource = gen(function* () {
149045
149114
  yield* (yield* getOrSelectIssueSource).reset;
149046
149115
  });
149116
+ const statusCurrentIssueSource = gen(function* () {
149117
+ yield* (yield* IssueSource).status;
149118
+ });
149047
149119
  var CurrentIssueSource = class CurrentIssueSource extends Service()("lalph/CurrentIssueSource") {
149048
149120
  static layer = effectServices(gen(function* () {
149049
149121
  const source = yield* getOrSelectIssueSource;
@@ -149051,15 +149123,15 @@ var CurrentIssueSource = class CurrentIssueSource extends Service()("lalph/Curre
149051
149123
  return add$5(services, CurrentIssueSource, source);
149052
149124
  })).pipe(provide$3([Settings.layer, PlatformServices]));
149053
149125
  };
149054
- const issueSourceRuntime = makeAtomRuntime(CurrentIssueSource.layer.pipe(orDie$3));
149126
+ const issueSourceRuntime = atomRuntime(CurrentIssueSource.layer.pipe(orDie$3));
149055
149127
  const currentIssuesAtom = pipe(issueSourceRuntime.atom(fnUntraced(function* (get) {
149056
- const issues = yield* (yield* IssueSource).issues;
149128
+ const issues = yield* (yield* IssueSource).issues.pipe(withSpan("currentIssuesAtom.refresh"));
149057
149129
  const handle = setTimeout(() => {
149058
149130
  get.refreshSelf();
149059
149131
  }, 3e4);
149060
149132
  get.addFinalizer(() => clearTimeout(handle));
149061
149133
  return issues;
149062
- })), makeAtomRuntime.withReactivity(["issues"]), keepAlive);
149134
+ })), atomRuntime.withReactivity(["issues"]), keepAlive);
149063
149135
  const getCurrentIssues = getResult(currentIssuesAtom, { suspendOnWaiting: true });
149064
149136
  const checkForWork = gen(function* () {
149065
149137
  if (!(yield* getCurrentIssues).some((issue) => issue.state === "todo" && issue.blockedBy.length === 0)) return yield* new NoMoreWork({});
@@ -149909,7 +149981,10 @@ const run = fnUntraced(function* (options) {
149909
149981
  yield* worktree.exec`git push -u ${parsed.remote} ${parsed.branch}`;
149910
149982
  }
149911
149983
  }
149912
- if (gitFlow.branch) yield* worktree.exec`git checkout -b ${gitFlow.branch}`;
149984
+ if (gitFlow.branch) {
149985
+ yield* worktree.exec`git branch -D ${gitFlow.branch}`;
149986
+ yield* worktree.exec`git checkout -b ${gitFlow.branch}`;
149987
+ }
149913
149988
  yield* addFinalizer(fnUntraced(function* () {
149914
149989
  const currentBranchName = yield* worktree.currentBranch(worktree.directory).pipe(option$1, map$8(getOrUndefined));
149915
149990
  if (!currentBranchName) return;
@@ -150196,44 +150271,12 @@ const commandShell = make$34("shell").pipe(withDescription("Enter an interactive
150196
150271
  const commandSource = make$34("source").pipe(withDescription("Select the issue source to use"), withHandler(() => selectIssueSource), provide(Settings.layer));
150197
150272
 
150198
150273
  //#endregion
150199
- //#region package.json
150200
- var version = "0.1.112";
150274
+ //#region src/commands/status.ts
150275
+ const commandStatus = make$34("status").pipe(withDescription("Show the selected issue source options"), withHandler(() => statusCurrentIssueSource), provide(Settings.layer), provide(CurrentIssueSource.layer));
150201
150276
 
150202
150277
  //#endregion
150203
- //#region src/Tracing.ts
150204
- const TracingLayer = unwrap$3(gen(function* () {
150205
- const logLevel = yield* MinimumLogLevel;
150206
- if (isLessThan$1("Trace", logLevel)) return empty$14;
150207
- return TracerLogger;
150208
- }));
150209
- const TracerLogger = gen(function* () {
150210
- const loggers = yield* CurrentLoggers;
150211
- const tracer = yield* Tracer;
150212
- const fiber = getCurrent();
150213
- const log = (message, time) => {
150214
- const options = {
150215
- message,
150216
- fiber,
150217
- date: new Date(Number(time / BigInt(1e6))),
150218
- logLevel: "Trace",
150219
- cause: empty$13
150220
- };
150221
- loggers.forEach((logger) => {
150222
- logger.log(options);
150223
- });
150224
- };
150225
- return make$55({ span(name, parent, annotations, links, startTime, kind, options) {
150226
- const span = tracer.span(name, parent, annotations, links, startTime, kind, options);
150227
- log(`${name}: started`, startTime);
150228
- const oldEnd = span.end;
150229
- span.end = (endTime, cause) => {
150230
- const duration = nanos(endTime - span.status.startTime);
150231
- log(`${name}: completed. Took ${format$2(duration)}`, endTime);
150232
- return oldEnd.call(span, endTime, cause);
150233
- };
150234
- return span;
150235
- } });
150236
- }).pipe(effect$1(Tracer));
150278
+ //#region package.json
150279
+ var version = "0.1.114";
150237
150280
 
150238
150281
  //#endregion
150239
150282
  //#region src/cli.ts
@@ -150243,10 +150286,16 @@ commandRoot.pipe(withSubcommands([
150243
150286
  commandEdit,
150244
150287
  commandShell,
150245
150288
  commandSource,
150289
+ commandStatus,
150246
150290
  commandAgent
150247
150291
  ]), provideEffectDiscard(fnUntraced(function* (options) {
150248
150292
  if (options.reset) yield* resetCurrentIssueSource;
150249
- })), provide(Settings.layer), provide(TracingLayer), provide(({ verbose }) => verbose ? succeed$2(MinimumLogLevel, "All") : empty$14), (_) => run$4(_, { version }), provide$1(PlatformServices), provideService(CurrentMemoMap, lalphMemoMap), runMain);
150293
+ })), provide(Settings.layer), provide(TracingLayer), provide(({ verbose }) => {
150294
+ if (!verbose) return empty$14;
150295
+ const logLevel = succeed$2(MinimumLogLevel, "All");
150296
+ atomRuntime.addGlobalLayer(logLevel);
150297
+ return logLevel;
150298
+ }), run$4({ version }), provide$1(PlatformServices), provideService(CurrentMemoMap, lalphMemoMap), runMain);
150250
150299
 
150251
150300
  //#endregion
150252
150301
  export { };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lalph",
3
3
  "type": "module",
4
- "version": "0.1.112",
4
+ "version": "0.1.114",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/src/Github.ts CHANGED
@@ -382,6 +382,22 @@ export const GithubIssueSource = Layer.effect(
382
382
  },
383
383
  Effect.mapError((cause) => new IssueSourceError({ cause })),
384
384
  ),
385
+ status: Effect.sync(() => {
386
+ console.log(`Issue source: GitHub Issues`)
387
+ console.log(`Repository: ${cli.owner}/${cli.repo}`)
388
+ console.log(
389
+ `Label filter: ${Option.match(labelFilter, {
390
+ onNone: () => "None",
391
+ onSome: (value) => value,
392
+ })}`,
393
+ )
394
+ console.log(
395
+ `Auto-merge label: ${Option.match(autoMergeLabelName, {
396
+ onNone: () => "Disabled",
397
+ onSome: (value) => value,
398
+ })}`,
399
+ )
400
+ }),
385
401
  ensureInProgress: Effect.fnUntraced(
386
402
  function* (issueId: string) {
387
403
  const issueNumber = Number(issueId.slice(1))
@@ -24,6 +24,8 @@ export class IssueSource extends ServiceMap.Service<
24
24
  issueId: string,
25
25
  ) => Effect.Effect<void, IssueSourceError>
26
26
 
27
+ readonly status: Effect.Effect<void, IssueSourceError>
28
+
27
29
  readonly ensureInProgress: (
28
30
  issueId: string,
29
31
  ) => Effect.Effect<void, IssueSourceError>
@@ -5,7 +5,7 @@ import { Prompt } from "effect/unstable/cli"
5
5
  import { GithubIssueSource, resetGithub } from "./Github.ts"
6
6
  import { IssueSource } from "./IssueSource.ts"
7
7
  import { PlatformServices } from "./shared/platform.ts"
8
- import { makeAtomRuntime as atomRuntime } from "./shared/runtime.ts"
8
+ import { atomRuntime } from "./shared/runtime.ts"
9
9
  import { Atom, Reactivity } from "effect/unstable/reactivity"
10
10
  import type { PrdIssue } from "./domain/PrdIssue.ts"
11
11
 
@@ -22,7 +22,7 @@ const issueSources: ReadonlyArray<typeof CurrentIssueSource.Service> = [
22
22
  name: "GitHub Issues",
23
23
  layer: GithubIssueSource,
24
24
  reset: resetGithub,
25
- githubPrInstructions: `At the start of your PR description, include a line that closes the issue, like: Closes {task id}.`,
25
+ githubPrInstructions: `At the start of your PR description, include a line that closes the issue: Closes {task id}`,
26
26
  },
27
27
  ]
28
28
 
@@ -57,6 +57,11 @@ export const resetCurrentIssueSource = Effect.gen(function* () {
57
57
  yield* source.reset
58
58
  })
59
59
 
60
+ export const statusCurrentIssueSource = Effect.gen(function* () {
61
+ const service = yield* IssueSource
62
+ yield* service.status
63
+ })
64
+
60
65
  export class CurrentIssueSource extends ServiceMap.Service<
61
66
  CurrentIssueSource,
62
67
  {
@@ -92,10 +97,12 @@ export const currentIssuesAtom = pipe(
92
97
  issueSourceRuntime.atom(
93
98
  Effect.fnUntraced(function* (get) {
94
99
  const source = yield* IssueSource
95
- const issues = yield* source.issues
100
+ const issues = yield* source.issues.pipe(
101
+ Effect.withSpan("currentIssuesAtom.refresh"),
102
+ )
96
103
  const handle = setTimeout(() => {
97
104
  get.refreshSelf()
98
- }, 30000)
105
+ }, 30_000)
99
106
  get.addFinalizer(() => clearTimeout(handle))
100
107
  return issues
101
108
  }),
package/src/Linear.ts CHANGED
@@ -403,6 +403,33 @@ export const LinearIssueSource = Layer.effect(
403
403
  },
404
404
  Effect.mapError((cause) => new IssueSourceError({ cause })),
405
405
  ),
406
+ status: Effect.gen(function* () {
407
+ const label = labelId
408
+ const autoMergeLabel = autoMergeLabelId
409
+ const teams = yield* Stream.runCollect(
410
+ linear.stream(() => project.teams()),
411
+ )
412
+ const labels = yield* Stream.runCollect(linear.labels)
413
+ const teamName =
414
+ teams.find((team) => team.id === teamId)?.name ?? teamId
415
+ const resolveLabel = (value: Option.Option<string>) =>
416
+ Option.match(value, {
417
+ onNone: () => "None",
418
+ onSome: (id) => labels.find((label) => label.id === id)?.name ?? id,
419
+ })
420
+ const resolveAutoMergeLabel = (value: Option.Option<string>) =>
421
+ Option.match(value, {
422
+ onNone: () => "Disabled",
423
+ onSome: (id) => labels.find((label) => label.id === id)?.name ?? id,
424
+ })
425
+ console.log(`Issue source: Linear`)
426
+ console.log(`Project: ${project.name}`)
427
+ console.log(`Team: ${teamName}`)
428
+ console.log(`Label filter: ${resolveLabel(label)}`)
429
+ console.log(
430
+ `Auto-merge label: ${resolveAutoMergeLabel(autoMergeLabel)}`,
431
+ )
432
+ }).pipe(Effect.mapError((cause) => new IssueSourceError({ cause }))),
406
433
  // linear api writes and reflected immediately in reads, so no-op
407
434
  ensureInProgress: () => Effect.void,
408
435
  })
package/src/cli.ts CHANGED
@@ -10,12 +10,13 @@ import { commandIssue } from "./commands/issue.ts"
10
10
  import { commandEdit } from "./commands/edit.ts"
11
11
  import { commandShell } from "./commands/shell.ts"
12
12
  import { commandSource } from "./commands/source.ts"
13
+ import { commandStatus } from "./commands/status.ts"
13
14
  import { commandAgent } from "./commands/agent.ts"
14
15
  import PackageJson from "../package.json" with { type: "json" }
15
16
  import { resetCurrentIssueSource } from "./IssueSources.ts"
16
17
  import { TracingLayer } from "./Tracing.ts"
17
18
  import { MinimumLogLevel } from "effect/References"
18
- import { lalphMemoMap } from "./shared/runtime.ts"
19
+ import { atomRuntime, lalphMemoMap } from "./shared/runtime.ts"
19
20
  import { PlatformServices } from "./shared/platform.ts"
20
21
 
21
22
  commandRoot.pipe(
@@ -25,6 +26,7 @@ commandRoot.pipe(
25
26
  commandEdit,
26
27
  commandShell,
27
28
  commandSource,
29
+ commandStatus,
28
30
  commandAgent,
29
31
  ]),
30
32
  // Common flags are handled here
@@ -37,13 +39,15 @@ commandRoot.pipe(
37
39
  ),
38
40
  Command.provide(Settings.layer),
39
41
  Command.provide(TracingLayer),
40
- Command.provide(({ verbose }) =>
41
- verbose ? Layer.succeed(MinimumLogLevel, "All") : Layer.empty,
42
- ),
43
- (_) =>
44
- Command.run(_, {
45
- version: PackageJson.version,
46
- }),
42
+ Command.provide(({ verbose }) => {
43
+ if (!verbose) return Layer.empty
44
+ const logLevel = Layer.succeed(MinimumLogLevel, "All")
45
+ atomRuntime.addGlobalLayer(logLevel)
46
+ return logLevel
47
+ }),
48
+ Command.run({
49
+ version: PackageJson.version,
50
+ }),
47
51
  Effect.provide(PlatformServices),
48
52
  Effect.provideService(Layer.CurrentMemoMap, lalphMemoMap),
49
53
  NodeRuntime.runMain,
@@ -74,6 +74,7 @@ const run = Effect.fnUntraced(
74
74
  }
75
75
  }
76
76
  if (gitFlow.branch) {
77
+ yield* worktree.exec`git branch -D ${gitFlow.branch}`
77
78
  yield* worktree.exec`git checkout -b ${gitFlow.branch}`
78
79
  }
79
80
 
@@ -0,0 +1,13 @@
1
+ import { Command } from "effect/unstable/cli"
2
+ import {
3
+ CurrentIssueSource,
4
+ statusCurrentIssueSource,
5
+ } from "../IssueSources.ts"
6
+ import { Settings } from "../Settings.ts"
7
+
8
+ export const commandStatus = Command.make("status").pipe(
9
+ Command.withDescription("Show the selected issue source options"),
10
+ Command.withHandler(() => statusCurrentIssueSource),
11
+ Command.provide(Settings.layer),
12
+ Command.provide(CurrentIssueSource.layer),
13
+ )
@@ -1,6 +1,9 @@
1
1
  import { Layer } from "effect"
2
2
  import { Atom } from "effect/unstable/reactivity"
3
+ import { TracingLayer } from "../Tracing.ts"
3
4
 
4
5
  export const lalphMemoMap = Layer.makeMemoMapUnsafe()
5
6
 
6
- export const makeAtomRuntime = Atom.context({ memoMap: lalphMemoMap })
7
+ export const atomRuntime = Atom.context({ memoMap: lalphMemoMap })
8
+
9
+ atomRuntime.addGlobalLayer(TracingLayer)