lalph 0.3.45 → 0.3.47

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
@@ -5353,6 +5353,18 @@ const succeed$8 = succeed$9;
5353
5353
  */
5354
5354
  const fail$10 = fail$11;
5355
5355
  /**
5356
+ * A pre-built `Result<void>` holding `undefined` as its failure value.
5357
+ *
5358
+ * - Use when you need a `Result` that represents "failed with no meaningful value"
5359
+ * - Equivalent to `Result.fail(undefined)` but avoids an extra allocation
5360
+ *
5361
+ * @see {@link fail}
5362
+ *
5363
+ * @category Constructors
5364
+ * @since 4.0.0
5365
+ */
5366
+ const failVoid = /* @__PURE__ */ fail$10(void 0);
5367
+ /**
5356
5368
  * Checks whether a `Result` is a `Failure`.
5357
5369
  *
5358
5370
  * - Acts as a TypeScript type guard, narrowing to `Failure<A, E>`
@@ -13021,7 +13033,7 @@ const repeat$1 = /* @__PURE__ */ dual(2, (self, options) => {
13021
13033
  return repeatOrElse$1(self, typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options), fail$9);
13022
13034
  });
13023
13035
  /** @internal */
13024
- const retry$2 = /* @__PURE__ */ dual(2, (self, options) => {
13036
+ const retry$4 = /* @__PURE__ */ dual(2, (self, options) => {
13025
13037
  return retryOrElse$1(self, typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options), fail$9);
13026
13038
  });
13027
13039
  const passthroughForever = /* @__PURE__ */ passthrough$2(forever$1);
@@ -14800,7 +14812,7 @@ const tapCause = tapCause$1;
14800
14812
  * @since 2.0.0
14801
14813
  * @category Error Handling
14802
14814
  */
14803
- const retry$1 = retry$2;
14815
+ const retry$3 = retry$4;
14804
14816
  /**
14805
14817
  * Discards both the success and failure values of an effect.
14806
14818
  *
@@ -24046,6 +24058,90 @@ const set$9 = /* @__PURE__ */ dual(2, (self, value) => {
24046
24058
  self.current = value;
24047
24059
  return self;
24048
24060
  });
24061
+ /**
24062
+ * Sets the MutableRef to a new value and returns the new value.
24063
+ *
24064
+ * @example
24065
+ * ```ts
24066
+ * import { MutableRef } from "effect"
24067
+ *
24068
+ * const ref = MutableRef.make("old")
24069
+ *
24070
+ * // Set and get the new value
24071
+ * const newValue = MutableRef.setAndGet(ref, "new")
24072
+ * console.log(newValue) // "new"
24073
+ * console.log(MutableRef.get(ref)) // "new"
24074
+ *
24075
+ * // Useful for assignments that need the value
24076
+ * const counter = MutableRef.make(0)
24077
+ * const currentValue = MutableRef.setAndGet(counter, 42)
24078
+ * console.log(`Counter set to: ${currentValue}`) // "Counter set to: 42"
24079
+ *
24080
+ * // Pipe-able version
24081
+ * const setValue = MutableRef.setAndGet("final")
24082
+ * const result = setValue(ref)
24083
+ * console.log(result) // "final"
24084
+ *
24085
+ * // Difference from set: returns value instead of reference
24086
+ * const ref1 = MutableRef.make(1)
24087
+ * const returnedRef = MutableRef.set(ref1, 2) // Returns MutableRef
24088
+ * const returnedValue = MutableRef.setAndGet(ref1, 3) // Returns value
24089
+ * console.log(returnedValue) // 3
24090
+ * ```
24091
+ *
24092
+ * @since 2.0.0
24093
+ * @category general
24094
+ */
24095
+ const setAndGet = /* @__PURE__ */ dual(2, (self, value) => {
24096
+ self.current = value;
24097
+ return self.current;
24098
+ });
24099
+ /**
24100
+ * Updates the MutableRef with the result of applying a function to its current value,
24101
+ * and returns the new value.
24102
+ *
24103
+ * @example
24104
+ * ```ts
24105
+ * import { MutableRef } from "effect"
24106
+ *
24107
+ * const counter = MutableRef.make(5)
24108
+ *
24109
+ * // Increment and get the new value
24110
+ * const newValue = MutableRef.updateAndGet(counter, (n) => n + 1)
24111
+ * console.log(newValue) // 6
24112
+ * console.log(MutableRef.get(counter)) // 6
24113
+ *
24114
+ * // Double the value and get the result
24115
+ * const doubled = MutableRef.updateAndGet(counter, (n) => n * 2)
24116
+ * console.log(doubled) // 12
24117
+ *
24118
+ * // Transform string and get result
24119
+ * const message = MutableRef.make("hello")
24120
+ * const upperCase = MutableRef.updateAndGet(message, (s) => s.toUpperCase())
24121
+ * console.log(upperCase) // "HELLO"
24122
+ *
24123
+ * // Pipe-able version
24124
+ * const increment = MutableRef.updateAndGet((n: number) => n + 1)
24125
+ * const result = increment(counter)
24126
+ * console.log(result) // 13 (new value)
24127
+ *
24128
+ * // Useful for calculations that need the result
24129
+ * const score = MutableRef.make(100)
24130
+ * const bonus = 50
24131
+ * const newScore = MutableRef.updateAndGet(score, (s) => s + bonus)
24132
+ * console.log(`New score: ${newScore}`) // "New score: 150"
24133
+ *
24134
+ * // Array transformations
24135
+ * const list = MutableRef.make<Array<number>>([1, 2, 3])
24136
+ * const newList = MutableRef.updateAndGet(list, (arr) => arr.map((x) => x * 2))
24137
+ * console.log(newList) // [2, 4, 6]
24138
+ * console.log(MutableRef.get(list)) // [2, 4, 6]
24139
+ * ```
24140
+ *
24141
+ * @since 2.0.0
24142
+ * @category general
24143
+ */
24144
+ const updateAndGet = /* @__PURE__ */ dual(2, (self, f) => setAndGet(self, f(get$14(self))));
24049
24145
  //#endregion
24050
24146
  //#region node_modules/.pnpm/effect@4.0.0-beta.30/node_modules/effect/dist/PubSub.js
24051
24147
  /**
@@ -27684,6 +27780,18 @@ const filterArray = /* @__PURE__ */ dual(2, (self, predicate) => transformPull$1
27684
27780
  * @since 4.0.0
27685
27781
  * @category Filtering
27686
27782
  */
27783
+ const filterMapArray = /* @__PURE__ */ dual(2, (self, filter) => transformPull$1(self, (pull) => succeed$3(flatMap$4(pull, function loop(arr) {
27784
+ const passes = [];
27785
+ for (let i = 0; i < arr.length; i++) {
27786
+ const result = filter(arr[i]);
27787
+ if (isSuccess$5(result)) passes.push(result.success);
27788
+ }
27789
+ return isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$4(pull, loop);
27790
+ }))));
27791
+ /**
27792
+ * @since 4.0.0
27793
+ * @category Filtering
27794
+ */
27687
27795
  const filterMapArrayEffect = /* @__PURE__ */ dual(2, (self, filter) => transformPull$1(self, (pull) => succeed$3(flatMap$4(pull, function loop(arr) {
27688
27796
  return flatMap$4(filterMapEffect$1(arr, filter), (passes) => isReadonlyArrayNonEmpty(passes) ? succeed$3(passes) : flatMap$4(pull, loop));
27689
27797
  }))));
@@ -27796,6 +27904,63 @@ const mapError$1 = /* @__PURE__ */ dual(2, (self, f) => catch_$1(self, (err) =>
27796
27904
  */
27797
27905
  const orDie$1 = (self) => catch_$1(self, die$1);
27798
27906
  /**
27907
+ * Returns a new channel that retries this channel according to the specified
27908
+ * schedule whenever it fails.
27909
+ *
27910
+ * @since 4.0.0
27911
+ * @category utils
27912
+ */
27913
+ const retry$2 = /* @__PURE__ */ dual(2, (self, schedule) => suspend$2(() => {
27914
+ let step = void 0;
27915
+ let meta = CurrentMetadata.defaultValue();
27916
+ const withReset = onFirst(provideServiceEffect(self, CurrentMetadata, sync(() => meta)), () => {
27917
+ step = void 0;
27918
+ return void_$1;
27919
+ });
27920
+ const resolvedSchedule = typeof schedule === "function" ? schedule(identity) : schedule;
27921
+ const loop = catch_$1(withReset, fnUntraced(function* (error) {
27922
+ if (!step) step = yield* toStepWithMetadata(resolvedSchedule);
27923
+ meta = yield* step(error);
27924
+ return loop;
27925
+ }, (effect, error) => catchDone(effect, () => succeed$3(fail$3(error))), unwrap$2));
27926
+ return loop;
27927
+ }));
27928
+ /**
27929
+ * Returns a new channel, which sequentially combines this channel, together
27930
+ * with the provided factory function, which creates a second channel based on
27931
+ * the output values of this channel. The result is a channel that will first
27932
+ * perform the functions of this channel, before performing the functions of
27933
+ * the created channel (including yielding its terminal value).
27934
+ *
27935
+ * @example
27936
+ * ```ts
27937
+ * import { Channel, Data } from "effect"
27938
+ *
27939
+ * class SwitchError extends Data.TaggedError("SwitchError")<{
27940
+ * readonly reason: string
27941
+ * }> {}
27942
+ *
27943
+ * // Create a channel that outputs numbers
27944
+ * const numberChannel = Channel.fromIterable([1, 2, 3])
27945
+ *
27946
+ * // Switch to new channels based on each value
27947
+ * const switchedChannel = Channel.switchMap(
27948
+ * numberChannel,
27949
+ * (n) => Channel.fromIterable([`value-${n}`])
27950
+ * )
27951
+ *
27952
+ * // Outputs: "value-1", "value-2", "value-3"
27953
+ * ```
27954
+ *
27955
+ * @since 2.0.0
27956
+ * @category sequencing
27957
+ */
27958
+ const switchMap$1 = /* @__PURE__ */ dual((args) => isChannel(args[0]), (self, f, options) => self.pipe(map$7(f), mergeAll$1({
27959
+ ...options,
27960
+ concurrency: options?.concurrency ?? 1,
27961
+ switch: true
27962
+ })));
27963
+ /**
27799
27964
  * Merges multiple channels with specified concurrency and buffering options.
27800
27965
  *
27801
27966
  * @example
@@ -28066,6 +28231,18 @@ const onExit = /* @__PURE__ */ dual(2, (self, finalizer) => fromTransformBracket
28066
28231
  * @since 4.0.0
28067
28232
  * @category utils
28068
28233
  */
28234
+ const onFirst = /* @__PURE__ */ dual(2, (self, onFirst) => transformPull$1(self, (pull) => sync(() => {
28235
+ let isFirst = true;
28236
+ const pullFirst = tap$1(pull, (element) => {
28237
+ isFirst = false;
28238
+ return onFirst(element);
28239
+ });
28240
+ return suspend$3(() => isFirst ? pullFirst : pull);
28241
+ })));
28242
+ /**
28243
+ * @since 4.0.0
28244
+ * @category utils
28245
+ */
28069
28246
  const onEnd$1 = /* @__PURE__ */ dual(2, (self, onEnd) => transformPull$1(self, (pull) => succeed$3(catchDone(pull, (leftover) => flatMap$4(onEnd, () => done(leftover))))));
28070
28247
  /**
28071
28248
  * Returns a new channel with an attached finalizer. The finalizer is
@@ -28104,6 +28281,11 @@ const runWith$1 = (self, f, onHalt) => suspend$3(() => {
28104
28281
  */
28105
28282
  const provideService$1 = /* @__PURE__ */ dual(3, (self, key, service) => fromTransform$1((upstream, scope) => map$8(provideService$2(toTransform(self)(upstream, scope), key, service), provideService$2(key, service))));
28106
28283
  /**
28284
+ * @since 4.0.0
28285
+ * @category Services
28286
+ */
28287
+ const provideServiceEffect = /* @__PURE__ */ dual(3, (self, key, service) => fromTransform$1((upstream, scope) => flatMap$4(service, (s) => toTransform(provideService$1(self, key, s))(upstream, scope))));
28288
+ /**
28107
28289
  * Runs a channel and discards all output elements, returning only the final result.
28108
28290
  *
28109
28291
  * @example
@@ -29581,6 +29763,30 @@ const tap = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options)
29581
29763
  */
29582
29764
  const flatMap$2 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, flatMap$3((a) => f(a).channel, options), fromChannel));
29583
29765
  /**
29766
+ * Switches to the latest stream produced by the mapping function, interrupting
29767
+ * the previous stream when a new element arrives.
29768
+ *
29769
+ * @example
29770
+ * ```ts
29771
+ * import { Console, Effect, Stream } from "effect"
29772
+ *
29773
+ * const program = Stream.make(1, 2, 3).pipe(
29774
+ * Stream.switchMap((n) => (n === 3 ? Stream.make(n) : Stream.never)),
29775
+ * Stream.runCollect
29776
+ * )
29777
+ *
29778
+ * Effect.gen(function*() {
29779
+ * const result = yield* program
29780
+ * yield* Console.log(result)
29781
+ * // Output: [ 3 ]
29782
+ * })
29783
+ * ```
29784
+ *
29785
+ * @since 4.0.0
29786
+ * @category Sequencing
29787
+ */
29788
+ const switchMap = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, f, options) => self.channel.pipe(flattenArray, switchMap$1((a) => f(a).channel, options), fromChannel));
29789
+ /**
29584
29790
  * Flattens a stream of streams into a single stream by concatenating the
29585
29791
  * inner streams in strict order.
29586
29792
  *
@@ -29764,6 +29970,13 @@ const mergeAll = /* @__PURE__ */ dual(2, (streams, options) => flatten(fromItera
29764
29970
  */
29765
29971
  const filter$3 = /* @__PURE__ */ dual(2, (self, predicate) => fromChannel(filterArray(toChannel(self), predicate)));
29766
29972
  /**
29973
+ * Filters and maps stream elements in one pass using a `Filter`.
29974
+ *
29975
+ * @since 4.0.0
29976
+ * @category Filtering
29977
+ */
29978
+ const filterMap$2 = /* @__PURE__ */ dual(2, (self, filter) => fromChannel(filterMapArray(toChannel(self), filter)));
29979
+ /**
29767
29980
  * Effectfully filters and maps elements in a single pass.
29768
29981
  *
29769
29982
  * @since 4.0.0
@@ -29945,6 +30158,38 @@ const mapError = /* @__PURE__ */ dual(2, (self, f) => fromChannel(mapError$1(sel
29945
30158
  */
29946
30159
  const orDie = (self) => fromChannel(orDie$1(self.channel));
29947
30160
  /**
30161
+ * When the stream fails, retry it according to the given schedule.
30162
+ *
30163
+ * This retries the entire stream, so will re-execute all of the stream's
30164
+ * acquire operations.
30165
+ *
30166
+ * The schedule is reset as soon as the first element passes through the
30167
+ * stream again.
30168
+ *
30169
+ * @example
30170
+ * ```ts
30171
+ * import { Console, Effect, Schedule, Stream } from "effect"
30172
+ *
30173
+ * const program = Effect.gen(function*() {
30174
+ * const values = yield* Stream.make(1).pipe(
30175
+ * Stream.concat(Stream.fail("boom")),
30176
+ * Stream.retry(Schedule.recurs(1)),
30177
+ * Stream.take(2),
30178
+ * Stream.runCollect
30179
+ * )
30180
+ *
30181
+ * yield* Console.log(values)
30182
+ * })
30183
+ *
30184
+ * Effect.runPromise(program)
30185
+ * // Output: [ 1, 1 ]
30186
+ * ```
30187
+ *
30188
+ * @since 2.0.0
30189
+ * @category Error Handling
30190
+ */
30191
+ const retry$1 = /* @__PURE__ */ dual(2, (self, policy) => fromChannel(retry$2(self.channel, policy)));
30192
+ /**
29948
30193
  * Takes the first `n` elements from this stream, returning `Stream.empty` when `n < 1`.
29949
30194
  *
29950
30195
  * @example
@@ -57286,7 +57531,7 @@ const retryTransient = /* @__PURE__ */ dual(2, (self, options) => {
57286
57531
  schedule: passthroughSchedule,
57287
57532
  times,
57288
57533
  while: isTransientResponse
57289
- }), retryOn === "response-only" ? identity : retry$1({
57534
+ }), retryOn === "response-only" ? identity : retry$3({
57290
57535
  while: isOnlySchedule || options.while === void 0 ? isTransientError : or(isTransientError, options.while),
57291
57536
  schedule,
57292
57537
  times
@@ -87378,6 +87623,15 @@ var PrdIssue = class PrdIssue extends Class$1("PrdIssue")({
87378
87623
  autoMerge
87379
87624
  });
87380
87625
  }
87626
+ update(options) {
87627
+ return new PrdIssue({
87628
+ ...this,
87629
+ title: options.title ?? this.title,
87630
+ description: options.description ?? this.description,
87631
+ state: options.state ?? this.state,
87632
+ blockedBy: options.blockedBy ?? this.blockedBy
87633
+ });
87634
+ }
87381
87635
  };
87382
87636
  //#endregion
87383
87637
  //#region node_modules/.pnpm/@linear+sdk@77.0.0_graphql@16.12.0/node_modules/@linear/sdk/dist/chunk-DPPnyiuk.mjs
@@ -179923,7 +180177,7 @@ var CurrentIssueSource = class CurrentIssueSource extends Service$1()("lalph/Cur
179923
180177
  const services$8 = yield* services();
179924
180178
  const refresh = set$4(ref, build$1).pipe(provideServices(services$8));
179925
180179
  const proxy = IssueSource.of({
179926
- issues: (projectId) => get$6(ref).pipe(flatMap$4((source) => source.issues(projectId)), tapErrorTag("IssueSourceError", (e) => logWarning("Rebuilding issue source due to error", fail$7(e)).pipe(andThen(ignore$1(refresh)))), retry$1(refreshSchedule)),
180180
+ issues: (projectId) => get$6(ref).pipe(flatMap$4((source) => source.issues(projectId)), tapErrorTag("IssueSourceError", (e) => logWarning("Rebuilding issue source due to error", fail$7(e)).pipe(andThen(ignore$1(refresh)))), retry$3(refreshSchedule)),
179927
180181
  createIssue: (projectId, options) => get$6(ref).pipe(flatMap$4((source) => source.createIssue(projectId, options))),
179928
180182
  updateIssue: (options) => get$6(ref).pipe(flatMap$4((source) => source.updateIssue(options))),
179929
180183
  cancelIssue: (projectId, issueId) => get$6(ref).pipe(flatMap$4((source) => source.cancelIssue(projectId, issueId))),
@@ -180191,7 +180445,7 @@ ${options.gitFlow.reviewInstructions}
180191
180445
  # Previous instructions (only for context, do not repeat)
180192
180446
 
180193
180447
  ${options.prompt}`;
180194
- const promptReviewCustom = (options) => `${options.prompt}
180448
+ const promptReviewCustom = (options) => options.removePrdNotes ? options.prompt : `${options.prompt}
180195
180449
 
180196
180450
  ${prdNotes(options)}`;
180197
180451
  const promptTimeout = (options) => `Your earlier attempt to complete the task with id \`${options.taskId}\` took too
@@ -180775,7 +181029,7 @@ var Prd = class extends Service$1()("lalph/Prd", { make: gen(function* () {
180775
181029
  if (currentYaml === nextYaml) return;
180776
181030
  yield* fs.writeFileString(prdFile, nextYaml);
180777
181031
  }, scoped$1, withSpan("Prd.updateSync"), run$3(updateSyncHandle, { onlyIfMissing: true }), syncSemaphore.withPermitsIfAvailable(1));
180778
- yield* fs.watch(lalphDir).pipe(debounce(50), runForEach((_) => clear(updateSyncHandle).pipe(andThen(ignore$1(sync$2)))), retry$1(forever$1), forkScoped);
181032
+ yield* fs.watch(lalphDir).pipe(debounce(50), runForEach((_) => clear(updateSyncHandle).pipe(andThen(ignore$1(sync$2)))), retry$3(forever$1), forkScoped);
180779
181033
  yield* toStreamResult(registry, currentIssuesAtom(projectId)).pipe(runForEach(updateSync), forkScoped);
180780
181034
  const findById = fnUntraced(function* (issueId) {
180781
181035
  return (yield* getCurrentIssues).find((i) => i.id === issueId) ?? null;
@@ -187991,7 +188245,7 @@ var ji = Bt, Ii = Object.assign(Qe, { sync: Bt }), zi = Ut, Bi = Object.assign(e
187991
188245
  });
187992
188246
  Ze.glob = Ze;
187993
188247
  //#endregion
187994
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/ApplyPatch.js
188248
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/ApplyPatch.js
187995
188249
  /**
187996
188250
  * @since 1.0.0
187997
188251
  */
@@ -188019,17 +188273,27 @@ const locate = (text) => {
188019
188273
  end
188020
188274
  };
188021
188275
  };
188276
+ const parseChunkHeader = (line) => {
188277
+ if (line === "@@") return;
188278
+ const unified = line.match(/^@@\s+-\d+(?:,\d+)?\s+\+\d+(?:,\d+)?\s+@@(?:\s?(.*))?$/);
188279
+ if (unified) {
188280
+ const ctx = unified[1]?.trim();
188281
+ return ctx === void 0 || ctx.length === 0 ? void 0 : ctx;
188282
+ }
188283
+ const ctx = line.slice(2).trim();
188284
+ return ctx.length === 0 ? void 0 : ctx;
188285
+ };
188022
188286
  const parseChunks = (lines, start, end = lines.length) => {
188023
188287
  const chunks = Array();
188024
188288
  let i = start;
188025
188289
  while (i < end) {
188026
188290
  const line = lines[i];
188027
- if (line.startsWith("***")) break;
188291
+ if (line.startsWith("***") || line.startsWith("diff --git ")) break;
188028
188292
  if (!line.startsWith("@@")) {
188029
188293
  i++;
188030
188294
  continue;
188031
188295
  }
188032
- const ctx = line.slice(2).trim();
188296
+ const ctx = parseChunkHeader(line);
188033
188297
  const old = Array();
188034
188298
  const next = Array();
188035
188299
  let eof = false;
@@ -188041,19 +188305,20 @@ const parseChunks = (lines, start, end = lines.length) => {
188041
188305
  i++;
188042
188306
  break;
188043
188307
  }
188044
- if (line.startsWith("@@") || line.startsWith("***")) break;
188308
+ if (line.startsWith("@@") || line.startsWith("***") || line.startsWith("diff --git ")) break;
188045
188309
  if (line.startsWith(" ")) {
188046
188310
  const text = line.slice(1);
188047
188311
  old.push(text);
188048
188312
  next.push(text);
188049
188313
  } else if (line.startsWith("-")) old.push(line.slice(1));
188050
188314
  else if (line.startsWith("+")) next.push(line.slice(1));
188315
+ else if (line === "\") {}
188051
188316
  i++;
188052
188317
  }
188053
188318
  chunks.push({
188054
188319
  old,
188055
188320
  next,
188056
- ...ctx.length > 0 ? { ctx } : {},
188321
+ ...ctx === void 0 ? {} : { ctx },
188057
188322
  ...eof ? { eof: true } : {}
188058
188323
  });
188059
188324
  }
@@ -188076,64 +188341,158 @@ const parseAdd = (lines, start, end) => {
188076
188341
  next: i
188077
188342
  };
188078
188343
  };
188079
- const parsePatch = (input) => {
188080
- const text = normalize(input);
188081
- if (text.length === 0) throw new Error("patchText is required");
188082
- if (text === `${BEGIN}\n${END}`) throw new Error("patch rejected: empty patch");
188083
- const { lines, begin, end } = locate(text);
188344
+ const normalizeDiffPath = (path) => {
188345
+ if (path === "/dev/null") return path;
188346
+ if (path.startsWith("a/") || path.startsWith("b/")) return path.slice(2);
188347
+ return path;
188348
+ };
188349
+ const parseHeaderPath = (line, prefix) => {
188350
+ const body = line.slice(prefix.length);
188351
+ const tabIndex = body.indexOf(" ");
188352
+ return normalizeDiffPath((tabIndex === -1 ? body : body.slice(0, tabIndex)).trim());
188353
+ };
188354
+ const parseDiffGitPaths = (line) => {
188355
+ const match = line.match(/^diff --git a\/(.+) b\/(.+)$/);
188356
+ if (!match) return;
188357
+ return [match[1], match[2]];
188358
+ };
188359
+ const hasDiffHeaders = (lines) => lines.some((line) => line.startsWith("diff --git ") || line.startsWith("--- ") || line.startsWith("rename from ") || line.startsWith("rename to "));
188360
+ const parseGitPatch = (text) => {
188361
+ const lines = text.split("\n");
188084
188362
  const out = Array();
188085
- let i = begin + 1;
188086
- while (i < end) {
188087
- while (i < end && lines[i].trim() === "") i++;
188088
- if (i === end) break;
188089
- const line = lines[i];
188090
- if (line.startsWith(ADD)) {
188091
- const path = line.slice(13).trim();
188092
- if (path.length === 0) fail("missing add file path");
188093
- const parsed = parseAdd(lines, i + 1, end);
188363
+ let i = 0;
188364
+ while (i < lines.length) {
188365
+ while (i < lines.length && lines[i].trim() === "") i++;
188366
+ if (i >= lines.length) break;
188367
+ let oldPath;
188368
+ let newPath;
188369
+ let renameFrom;
188370
+ let renameTo;
188371
+ if (lines[i].startsWith("diff --git ")) {
188372
+ const parsedPaths = parseDiffGitPaths(lines[i]);
188373
+ if (!parsedPaths) return fail(`invalid git diff header: ${lines[i]}`);
188374
+ const [parsedOldPath, parsedNewPath] = parsedPaths;
188375
+ oldPath = parsedOldPath;
188376
+ newPath = parsedNewPath;
188377
+ i++;
188378
+ }
188379
+ while (i < lines.length) {
188380
+ const line = lines[i];
188381
+ if (line.startsWith("diff --git ")) break;
188382
+ if (line.startsWith("rename from ")) {
188383
+ renameFrom = line.slice(12).trim();
188384
+ i++;
188385
+ continue;
188386
+ }
188387
+ if (line.startsWith("rename to ")) {
188388
+ renameTo = line.slice(10).trim();
188389
+ i++;
188390
+ continue;
188391
+ }
188392
+ if (line.startsWith("--- ")) {
188393
+ oldPath = parseHeaderPath(line, "--- ");
188394
+ i++;
188395
+ if (i >= lines.length || !lines[i].startsWith("+++ ")) fail("missing new file header");
188396
+ newPath = parseHeaderPath(lines[i], "+++ ");
188397
+ i++;
188398
+ break;
188399
+ }
188400
+ if (line.startsWith("@@")) break;
188401
+ i++;
188402
+ }
188403
+ const parsed = parseChunks(lines, i);
188404
+ i = parsed.next;
188405
+ const fromPath = normalizeDiffPath(renameFrom ?? oldPath ?? "/dev/null");
188406
+ const toPath = normalizeDiffPath(renameTo ?? newPath ?? fromPath);
188407
+ if (fromPath === "/dev/null") {
188408
+ if (toPath === "/dev/null") fail("invalid diff: both file paths are /dev/null");
188094
188409
  out.push({
188095
188410
  type: "add",
188096
- path,
188097
- content: parsed.content
188411
+ path: toPath,
188412
+ content: patchChunks(toPath, "", parsed.chunks)
188098
188413
  });
188099
- i = parsed.next;
188100
188414
  continue;
188101
188415
  }
188102
- if (line.startsWith(DELETE)) {
188103
- const path = line.slice(16).trim();
188104
- if (path.length === 0) fail("missing delete file path");
188416
+ if (toPath === "/dev/null") {
188105
188417
  out.push({
188106
188418
  type: "delete",
188107
- path
188419
+ path: fromPath
188108
188420
  });
188109
- i++;
188110
188421
  continue;
188111
188422
  }
188112
- if (line.startsWith(UPDATE)) {
188113
- const path = line.slice(16).trim();
188114
- if (path.length === 0) fail("missing update file path");
188115
- i++;
188116
- let movePath;
188117
- if (i < end && lines[i].startsWith(MOVE)) {
188118
- movePath = lines[i].slice(12).trim();
188119
- if (movePath.length === 0) fail("missing move file path");
188423
+ if (parsed.chunks.length === 0 && fromPath === toPath) fail(`no hunks found for ${fromPath}`);
188424
+ out.push({
188425
+ type: "update",
188426
+ path: fromPath,
188427
+ chunks: parsed.chunks,
188428
+ ...toPath === fromPath ? {} : { movePath: toPath }
188429
+ });
188430
+ }
188431
+ if (out.length === 0) fail("no hunks found");
188432
+ return out;
188433
+ };
188434
+ const parsePatch = (input) => {
188435
+ const text = normalize(input);
188436
+ if (text.length === 0) throw new Error("patchText is required");
188437
+ if (text === `${BEGIN}\n${END}`) throw new Error("patch rejected: empty patch");
188438
+ if (text.startsWith(BEGIN)) {
188439
+ const { lines, begin, end } = locate(text);
188440
+ const out = Array();
188441
+ let i = begin + 1;
188442
+ while (i < end) {
188443
+ while (i < end && lines[i].trim() === "") i++;
188444
+ if (i === end) break;
188445
+ const line = lines[i];
188446
+ if (line.startsWith(ADD)) {
188447
+ const path = line.slice(13).trim();
188448
+ if (path.length === 0) fail("missing add file path");
188449
+ const parsed = parseAdd(lines, i + 1, end);
188450
+ out.push({
188451
+ type: "add",
188452
+ path,
188453
+ content: parsed.content
188454
+ });
188455
+ i = parsed.next;
188456
+ continue;
188457
+ }
188458
+ if (line.startsWith(DELETE)) {
188459
+ const path = line.slice(16).trim();
188460
+ if (path.length === 0) fail("missing delete file path");
188461
+ out.push({
188462
+ type: "delete",
188463
+ path
188464
+ });
188465
+ i++;
188466
+ continue;
188467
+ }
188468
+ if (line.startsWith(UPDATE)) {
188469
+ const path = line.slice(16).trim();
188470
+ if (path.length === 0) fail("missing update file path");
188120
188471
  i++;
188472
+ let movePath;
188473
+ if (i < end && lines[i].startsWith(MOVE)) {
188474
+ movePath = lines[i].slice(12).trim();
188475
+ if (movePath.length === 0) fail("missing move file path");
188476
+ i++;
188477
+ }
188478
+ const parsed = parseChunks(lines, i, end);
188479
+ if (parsed.chunks.length === 0) fail("no hunks found");
188480
+ out.push({
188481
+ type: "update",
188482
+ path,
188483
+ chunks: parsed.chunks,
188484
+ ...movePath === void 0 ? {} : { movePath }
188485
+ });
188486
+ i = parsed.next;
188487
+ continue;
188121
188488
  }
188122
- const parsed = parseChunks(lines, i, end);
188123
- if (parsed.chunks.length === 0) fail("no hunks found");
188124
- out.push({
188125
- type: "update",
188126
- path,
188127
- chunks: parsed.chunks,
188128
- ...movePath === void 0 ? {} : { movePath }
188129
- });
188130
- i = parsed.next;
188131
- continue;
188489
+ fail(`unexpected line in wrapped patch: ${line}`);
188132
188490
  }
188133
- fail(`unexpected line in wrapped patch: ${line}`);
188491
+ if (out.length === 0) fail("no hunks found");
188492
+ return out;
188134
188493
  }
188135
- if (out.length === 0) fail("no hunks found");
188136
- return out;
188494
+ if (hasDiffHeaders(text.split("\n"))) return parseGitPatch(text);
188495
+ return fail("Invalid patch format: expected git/unified diff");
188137
188496
  };
188138
188497
  const normalizeUnicode = (line) => line.replace(/[\u2018\u2019\u201A\u201B]/g, "'").replace(/[\u201C\u201D\u201E\u201F]/g, "\"").replace(/[\u2010\u2011\u2012\u2013\u2014\u2015]/g, "-").replace(/\u2026/g, "...").replace(/\u00A0/g, " ");
188139
188498
  const match = (lines, part, from, same, eof) => {
@@ -188215,7 +188574,7 @@ const patchChunks = (file, input, chunks) => {
188215
188574
  return eol === "\r\n" ? text.replace(/\n/g, "\r\n") : text;
188216
188575
  };
188217
188576
  //#endregion
188218
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/AgentTools.js
188577
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/AgentTools.js
188219
188578
  /**
188220
188579
  * @since 1.0.0
188221
188580
  */
@@ -188247,15 +188606,15 @@ const AgentTools = make$9(make$7("readFile", {
188247
188606
  }),
188248
188607
  success: NullOr(String$1),
188249
188608
  dependencies: [CurrentDirectory]
188250
- }), make$7("createFile", {
188251
- description: "Write content to a file, creating parent directories if needed.",
188609
+ }), make$7("writeFile", {
188610
+ description: "Write content to a file, creating parent directories if needed. PREFER USING applyPatch to update existing files.",
188252
188611
  parameters: Struct({
188253
188612
  path: String$1,
188254
188613
  content: String$1
188255
188614
  }),
188256
188615
  dependencies: [CurrentDirectory]
188257
188616
  }), make$7("applyPatch", {
188258
- description: "Apply a wrapped patch with Add/Delete/Update sections.",
188617
+ description: "Apply a git diff / unified diff patch across one or more files.",
188259
188618
  parameters: String$1.annotate({ identifier: "patch" }),
188260
188619
  success: String$1,
188261
188620
  dependencies: [CurrentDirectory]
@@ -188341,8 +188700,8 @@ const AgentToolHandlers = AgentTools.toLayer(gen(function* () {
188341
188700
  if (options.endLine) stream = take(stream, options.endLine - (options.startLine ?? 1) + 1);
188342
188701
  return yield* runCollect(stream).pipe(map$8(join$3("\n")), catchReason("PlatformError", "NotFound", () => succeed$3(null)), orDie$2);
188343
188702
  }),
188344
- createFile: fn("AgentTools.createFile")(function* (options) {
188345
- yield* logInfo(`Calling "createFile"`).pipe(annotateLogs({ path: options.path }));
188703
+ writeFile: fn("AgentTools.writeFile")(function* (options) {
188704
+ yield* logInfo(`Calling "writeFile"`).pipe(annotateLogs({ path: options.path }));
188346
188705
  const cwd = yield* CurrentDirectory;
188347
188706
  const path = pathService.resolve(cwd, options.path);
188348
188707
  if (yield* fs.exists(path)) return yield* die$2("File already exists");
@@ -188511,7 +188870,7 @@ const AgentToolHandlers = AgentTools.toLayer(gen(function* () {
188511
188870
  }));
188512
188871
  var ApplyPatchError = class extends TaggedClass$1("ApplyPatchError") {};
188513
188872
  //#endregion
188514
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/Executor.js
188873
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/Executor.js
188515
188874
  /**
188516
188875
  * @since 1.0.0
188517
188876
  */
@@ -188591,7 +188950,7 @@ var QueueWriteStream = class extends Writable {
188591
188950
  }
188592
188951
  };
188593
188952
  //#endregion
188594
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/TypeBuilder.js
188953
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/TypeBuilder.js
188595
188954
  const resolveDocumentation = resolveAt("documentation");
188596
188955
  const identifierPattern = /^[$A-Z_a-z][$0-9A-Z_a-z]*$/u;
188597
188956
  const Precedence = {
@@ -188864,7 +189223,7 @@ const render = (schema, options) => {
188864
189223
  return printNode({ text: documentation === void 0 ? rendered.text : `${renderJsDoc(documentation, 0, printerOptions)}${printerOptions.newLine}${rendered.text}` }, printerOptions);
188865
189224
  };
188866
189225
  //#endregion
188867
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/ToolkitRenderer.js
189226
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/ToolkitRenderer.js
188868
189227
  /**
188869
189228
  * @since 1.0.0
188870
189229
  */
@@ -188886,7 +189245,7 @@ declare function ${name}(${params}): Promise<${render(tool.successSchema)}>`);
188886
189245
  }) });
188887
189246
  };
188888
189247
  //#endregion
188889
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/Agent.js
189248
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/Agent.js
188890
189249
  /**
188891
189250
  * @since 1.0.0
188892
189251
  */
@@ -189126,7 +189485,7 @@ ${prompt}`));
189126
189485
  case "finish": break;
189127
189486
  }
189128
189487
  return void_$1;
189129
- }), retry$1({ while: (err) => {
189488
+ }), retry$3({ while: (err) => {
189130
189489
  response = [];
189131
189490
  return err.isRetryable;
189132
189491
  } }), modelConfig.systemPromptTransform ? (effect) => modelConfig.systemPromptTransform(system, effect) : identity);
@@ -189200,7 +189559,7 @@ const generateSystemMulti = (toolsDts) => {
189200
189559
 
189201
189560
  - Use \`console.log\` to print any output you need.
189202
189561
  - Top level await is supported.
189203
- - **Prefer using the functions provided** over the bash tool
189562
+ - AVOID passing scripts into the "bash" function, and instead write javascript.
189204
189563
 
189205
189564
  **When you have fully completed your task**, call the "taskComplete" function with the final output.
189206
189565
  Make sure every detail of the task is done before calling "taskComplete".
@@ -189218,7 +189577,7 @@ const generateSystemSingle = (toolsDts) => {
189218
189577
 
189219
189578
  - Use \`console.log\` to print any output you need.
189220
189579
  - Top level await is supported.
189221
- - **Prefer using the functions provided** over the bash tool
189580
+ - AVOID passing scripts into the "bash" function, and instead write javascript.
189222
189581
 
189223
189582
  You have the following functions available to you:
189224
189583
 
@@ -189527,7 +189886,7 @@ var Retry = class Retry extends TaggedClass$1("Retry") {
189527
189886
  }
189528
189887
  };
189529
189888
  //#endregion
189530
- //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/Generated.js
189889
+ //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/Generated.js
189531
189890
  /**
189532
189891
  * @since 1.0.0
189533
189892
  */ const AdminApiKey = /* @__PURE__ */ Struct({
@@ -195933,6 +196292,13 @@ const ResponseStreamEvent = /* @__PURE__ */ Union([
195933
196292
  ResponseInProgressEvent,
195934
196293
  ResponseFailedEvent,
195935
196294
  ResponseIncompleteEvent,
196295
+ /* @__PURE__ */ Struct({
196296
+ "type": Literal("keepalive").annotate({ "description": "The type of the keepalive event. Always `keepalive`." }),
196297
+ "sequence_number": Number$1.annotate({ "description": "The sequence number of this keepalive event." }).check(isInt())
196298
+ }).annotate({
196299
+ "title": "Keep alive",
196300
+ "description": "A keepalive event emitted during long-running response streams."
196301
+ }),
195936
196302
  ResponseOutputItemAddedEvent,
195937
196303
  ResponseOutputItemDoneEvent,
195938
196304
  ResponseReasoningSummaryPartAddedEvent,
@@ -197588,7 +197954,7 @@ const OpenAiClientError = (tag, cause, response) => new OpenAiClientErrorImpl({
197588
197954
  request: response.request
197589
197955
  });
197590
197956
  //#endregion
197591
- //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/internal/errors.js
197957
+ //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/internal/errors.js
197592
197958
  /** @internal */
197593
197959
  const OpenAiErrorBody$1 = /* @__PURE__ */ Struct({ error: /* @__PURE__ */ Struct({
197594
197960
  message: String$1,
@@ -197801,7 +198167,7 @@ const mapStatusCodeToReason$1 = ({ status, headers, message, metadata, http }) =
197801
198167
  }
197802
198168
  };
197803
198169
  //#endregion
197804
- //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/OpenAiConfig.js
198170
+ //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/OpenAiConfig.js
197805
198171
  /**
197806
198172
  * @since 1.0.0
197807
198173
  */
@@ -197816,7 +198182,7 @@ var OpenAiConfig$1 = class OpenAiConfig$1 extends Service$1()("@effect/ai-openai
197816
198182
  static getOrUndefined = /* @__PURE__ */ map$8(/* @__PURE__ */ services(), (context) => context.mapUnsafe.get(OpenAiConfig$1.key));
197817
198183
  };
197818
198184
  //#endregion
197819
- //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/OpenAiClient.js
198185
+ //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/OpenAiClient.js
197820
198186
  /**
197821
198187
  * OpenAI Client module for interacting with OpenAI's API.
197822
198188
  *
@@ -197887,7 +198253,7 @@ const make$3 = /* @__PURE__ */ fnUntraced(function* (options) {
197887
198253
  */
197888
198254
  const layer$3 = (options) => effect$1(OpenAiClient$1, make$3(options));
197889
198255
  //#endregion
197890
- //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/internal/utilities.js
198256
+ //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/internal/utilities.js
197891
198257
  const finishReasonMap$1 = {
197892
198258
  content_filter: "content-filter",
197893
198259
  function_call: "tool-calls",
@@ -197905,7 +198271,7 @@ const resolveFinishReason$1 = (finishReason, hasToolCalls) => {
197905
198271
  return reason;
197906
198272
  };
197907
198273
  //#endregion
197908
- //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/OpenAiTelemetry.js
198274
+ //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/OpenAiTelemetry.js
197909
198275
  /**
197910
198276
  * OpenAI telemetry attributes for OpenTelemetry integration.
197911
198277
  *
@@ -197934,7 +198300,7 @@ const addGenAIAnnotations$1 = /* @__PURE__ */ dual(2, (span, options) => {
197934
198300
  }
197935
198301
  });
197936
198302
  //#endregion
197937
- //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/OpenAiLanguageModel.js
198303
+ //#region node_modules/.pnpm/@effect+ai-openai@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai/dist/OpenAiLanguageModel.js
197938
198304
  /**
197939
198305
  * OpenAI Language Model implementation.
197940
198306
  *
@@ -199647,7 +200013,7 @@ const transformToolCallParams = /* @__PURE__ */ fnUntraced(function* (tools, too
199647
200013
  })));
199648
200014
  });
199649
200015
  //#endregion
199650
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/CodexAuth.js
200016
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/CodexAuth.js
199651
200017
  /**
199652
200018
  * @since 1.0.0
199653
200019
  */
@@ -199825,7 +200191,7 @@ var CodexAuth = class CodexAuth extends Service$1()("clanka/CodexAuth") {
199825
200191
  user_code: deviceCode.userCode
199826
200192
  }));
199827
200193
  const delayMs = deviceCode.intervalMs + POLLING_SAFETY_MARGIN_MS;
199828
- return yield* httpClient.execute(request).pipe(retry$1({
200194
+ return yield* httpClient.execute(request).pipe(retry$3({
199829
200195
  while: (e) => e.response?.status === 403 || e.response?.status === 404,
199830
200196
  schedule: spaced(delayMs)
199831
200197
  }), mapError$2((cause) => requestDeviceCodeError("Failed to poll Codex device authorization", cause)), flatMap$4((response) => schemaBodyJson(AuthorizationCodeResponseSchema)(response).pipe(mapError$2((cause) => requestDeviceCodeError("Failed to decode the Codex authorization approval response", cause)), map$8((payload) => ({
@@ -199867,7 +200233,7 @@ var CodexAuth = class CodexAuth extends Service$1()("clanka/CodexAuth") {
199867
200233
  static layerClient = this.layerClientNoDeps.pipe(provide$3(CodexAuth.layer));
199868
200234
  };
199869
200235
  //#endregion
199870
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/Codex.js
200236
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/Codex.js
199871
200237
  /**
199872
200238
  * @since 1.0.0
199873
200239
  */
@@ -199896,7 +200262,7 @@ const model$1 = (model, options) => make$6("openai", model, merge$5(layer$2({
199896
200262
  supportsNoTools: options?.supportsNoTools ?? true
199897
200263
  })).pipe(provide$3(layerClient$1)));
199898
200264
  //#endregion
199899
- //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/internal/errors.js
200265
+ //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/internal/errors.js
199900
200266
  /** @internal */
199901
200267
  const OpenAiErrorBody = /* @__PURE__ */ Struct({ error: /* @__PURE__ */ Struct({
199902
200268
  message: String$1,
@@ -200104,7 +200470,7 @@ const mapStatusCodeToReason = ({ status, headers, message, metadata, http }) =>
200104
200470
  }
200105
200471
  };
200106
200472
  //#endregion
200107
- //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/OpenAiConfig.js
200473
+ //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/OpenAiConfig.js
200108
200474
  /**
200109
200475
  * @since 1.0.0
200110
200476
  */
@@ -200119,7 +200485,7 @@ var OpenAiConfig = class OpenAiConfig extends Service$1()("@effect/ai-openai-com
200119
200485
  static getOrUndefined = /* @__PURE__ */ map$8(/* @__PURE__ */ services(), (context) => context.mapUnsafe.get(OpenAiConfig.key));
200120
200486
  };
200121
200487
  //#endregion
200122
- //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/OpenAiClient.js
200488
+ //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/OpenAiClient.js
200123
200489
  /**
200124
200490
  * @since 1.0.0
200125
200491
  */
@@ -200188,27 +200554,34 @@ const CreateEmbeddingResponseSchema = /* @__PURE__ */ Struct({
200188
200554
  total_tokens: Number$1
200189
200555
  }))
200190
200556
  });
200191
- const ChatCompletionToolCall = /* @__PURE__ */ Struct({
200192
- id: /* @__PURE__ */ optionalKey(String$1),
200193
- index: /* @__PURE__ */ optionalKey(Number$1),
200194
- type: /* @__PURE__ */ optionalKey(String$1),
200195
- function: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Struct({
200196
- name: String$1,
200197
- arguments: /* @__PURE__ */ optionalKey(String$1)
200198
- }))
200199
- });
200200
200557
  const ChatCompletionChoice = /* @__PURE__ */ Struct({
200201
200558
  index: Number$1,
200202
200559
  finish_reason: /* @__PURE__ */ optionalKey(/* @__PURE__ */ NullOr(String$1)),
200203
200560
  message: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Struct({
200204
200561
  role: /* @__PURE__ */ optionalKey(String$1),
200205
200562
  content: /* @__PURE__ */ optionalKey(/* @__PURE__ */ NullOr(String$1)),
200206
- tool_calls: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Array$1(ChatCompletionToolCall))
200563
+ tool_calls: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Array$1(/* @__PURE__ */ Struct({
200564
+ id: /* @__PURE__ */ optionalKey(String$1),
200565
+ index: /* @__PURE__ */ optionalKey(Number$1),
200566
+ type: /* @__PURE__ */ optionalKey(String$1),
200567
+ function: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Struct({
200568
+ name: String$1,
200569
+ arguments: /* @__PURE__ */ optionalKey(String$1)
200570
+ }))
200571
+ })))
200207
200572
  })),
200208
200573
  delta: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Struct({
200209
200574
  role: /* @__PURE__ */ optionalKey(String$1),
200210
200575
  content: /* @__PURE__ */ optionalKey(/* @__PURE__ */ NullOr(String$1)),
200211
- tool_calls: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Array$1(ChatCompletionToolCall))
200576
+ tool_calls: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Array$1(/* @__PURE__ */ Struct({
200577
+ id: /* @__PURE__ */ optionalKey(String$1),
200578
+ index: /* @__PURE__ */ optionalKey(Number$1),
200579
+ type: /* @__PURE__ */ optionalKey(String$1),
200580
+ function: /* @__PURE__ */ optionalKey(/* @__PURE__ */ Struct({
200581
+ name: /* @__PURE__ */ optionalKey(String$1),
200582
+ arguments: /* @__PURE__ */ optionalKey(String$1)
200583
+ }))
200584
+ })))
200212
200585
  }))
200213
200586
  });
200214
200587
  const ChatCompletionUsage = /* @__PURE__ */ Struct({
@@ -200248,7 +200621,7 @@ const decodeChatCompletionSseData = (data) => {
200248
200621
  return isChatCompletionChunk(parsed) ? parsed : void 0;
200249
200622
  };
200250
200623
  //#endregion
200251
- //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/internal/utilities.js
200624
+ //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/internal/utilities.js
200252
200625
  const finishReasonMap = {
200253
200626
  content_filter: "content-filter",
200254
200627
  function_call: "tool-calls",
@@ -200264,7 +200637,7 @@ const resolveFinishReason = (finishReason, hasToolCalls) => {
200264
200637
  return reason;
200265
200638
  };
200266
200639
  //#endregion
200267
- //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/OpenAiTelemetry.js
200640
+ //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/OpenAiTelemetry.js
200268
200641
  /**
200269
200642
  * OpenAI telemetry attributes for OpenTelemetry integration.
200270
200643
  *
@@ -200293,7 +200666,7 @@ const addGenAIAnnotations = /* @__PURE__ */ dual(2, (span, options) => {
200293
200666
  }
200294
200667
  });
200295
200668
  //#endregion
200296
- //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/OpenAiLanguageModel.js
200669
+ //#region node_modules/.pnpm/@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30/node_modules/@effect/ai-openai-compat/dist/OpenAiLanguageModel.js
200297
200670
  /**
200298
200671
  * OpenAI Language Model implementation.
200299
200672
  *
@@ -200751,11 +201124,11 @@ const makeStreamResponse = /* @__PURE__ */ fnUntraced(function* ({ stream, respo
200751
201124
  hasToolCalls = hasToolCalls || choice.delta.tool_calls.length > 0;
200752
201125
  choice.delta.tool_calls.forEach((deltaTool, indexInChunk) => {
200753
201126
  const toolIndex = deltaTool.index ?? indexInChunk;
200754
- const toolId = deltaTool.id ?? `${event.id}_tool_${toolIndex}`;
201127
+ const activeToolCall = activeToolCalls[toolIndex];
201128
+ const toolId = activeToolCall?.id ?? deltaTool.id ?? `${event.id}_tool_${toolIndex}`;
200755
201129
  const providerToolName = deltaTool.function?.name;
200756
- const toolName = toolNameMapper.getCustomName(providerToolName ?? "unknown_tool");
201130
+ const toolName = providerToolName !== void 0 ? toolNameMapper.getCustomName(providerToolName) : activeToolCall?.name ?? toolNameMapper.getCustomName("unknown_tool");
200757
201131
  const argumentsDelta = deltaTool.function?.arguments ?? "";
200758
- const activeToolCall = activeToolCalls[toolIndex];
200759
201132
  if (isUndefined(activeToolCall)) {
200760
201133
  activeToolCalls[toolIndex] = {
200761
201134
  id: toolId,
@@ -201175,7 +201548,7 @@ const getUsageDetailNumber = (details, field) => {
201175
201548
  return typeof value === "number" ? value : void 0;
201176
201549
  };
201177
201550
  //#endregion
201178
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/CopilotAuth.js
201551
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/CopilotAuth.js
201179
201552
  /**
201180
201553
  * @since 1.0.0
201181
201554
  */
@@ -201366,7 +201739,7 @@ var GithubCopilotAuth = class GithubCopilotAuth extends Service$1()("clanka/Gith
201366
201739
  static layerClient = this.layerClientNoDeps.pipe(provide$3(GithubCopilotAuth.layer));
201367
201740
  };
201368
201741
  //#endregion
201369
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/Copilot.js
201742
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/Copilot.js
201370
201743
  /**
201371
201744
  * @since 1.0.0
201372
201745
  */
@@ -201789,7 +202162,7 @@ Object.defineProperties(createChalk.prototype, styles);
201789
202162
  const chalk = createChalk();
201790
202163
  createChalk({ level: stderrColor ? stderrColor.level : 0 });
201791
202164
  //#endregion
201792
- //#region node_modules/.pnpm/clanka@0.0.15_@effect+ai-openai-compat@4.0.0-beta.29_effect@4.0.0-beta.30__@effect+ai-o_cb421abed6b4689eec8c33622f2a024f/node_modules/clanka/dist/OutputFormatter.js
202165
+ //#region node_modules/.pnpm/clanka@0.0.17_@effect+ai-openai-compat@4.0.0-beta.30_effect@4.0.0-beta.30__@effect+ai-o_aaa5a0e42657b29782e5d1fe76ccda57/node_modules/clanka/dist/OutputFormatter.js
201793
202166
  /**
201794
202167
  * @since 1.0.0
201795
202168
  */
@@ -201833,19 +202206,24 @@ const doneIcon = "";
201833
202206
  //#endregion
201834
202207
  //#region src/TaskTools.ts
201835
202208
  var ChosenTaskDeferred = class extends Reference("lalph/TaskTools/ChosenTaskDeferred", { defaultValue: makeUnsafe$13 }) {};
202209
+ var CurrentTaskRef = class CurrentTaskRef extends Service$1()("lalph/TaskTools/CurrentTaskRef") {
202210
+ static update(f) {
202211
+ return serviceOption(CurrentTaskRef).pipe(map$8(map$15((ref) => updateAndGet(ref, f))));
202212
+ }
202213
+ };
202214
+ const TaskList = Array$1(Struct({
202215
+ id: String$1.annotate({ documentation: "The unique identifier of the task." }),
202216
+ ...pick(PrdIssue.fields, [
202217
+ "title",
202218
+ "description",
202219
+ "state",
202220
+ "priority",
202221
+ "blockedBy"
202222
+ ])
202223
+ }));
201836
202224
  var TaskTools = class extends make$9(make$7("listTasks", {
201837
202225
  description: "Returns the current list of tasks.",
201838
- success: Array$1(Struct({
201839
- id: String$1.annotate({ documentation: "The unique identifier of the task." }),
201840
- ...pick(PrdIssue.fields, [
201841
- "title",
201842
- "description",
201843
- "state",
201844
- "priority",
201845
- "estimate",
201846
- "blockedBy"
201847
- ])
201848
- })),
202226
+ success: TaskList,
201849
202227
  dependencies: [CurrentProjectId]
201850
202228
  }), make$7("createTask", {
201851
202229
  description: "Create a new task and return it's id.",
@@ -201854,7 +202232,6 @@ var TaskTools = class extends make$9(make$7("listTasks", {
201854
202232
  description: PrdIssue.fields.description,
201855
202233
  state: PrdIssue.fields.state,
201856
202234
  priority: PrdIssue.fields.priority,
201857
- estimate: PrdIssue.fields.estimate,
201858
202235
  blockedBy: PrdIssue.fields.blockedBy
201859
202236
  }),
201860
202237
  success: String$1,
@@ -201869,6 +202246,10 @@ var TaskTools = class extends make$9(make$7("listTasks", {
201869
202246
  blockedBy: optional$2(PrdIssue.fields.blockedBy)
201870
202247
  }),
201871
202248
  dependencies: [CurrentProjectId]
202249
+ }), make$7("removeTask", {
202250
+ description: "Remove a task by it's id.",
202251
+ parameters: String$1.annotate({ identifier: "taskId" }),
202252
+ dependencies: [CurrentProjectId]
201872
202253
  })) {};
201873
202254
  var TaskToolsWithChoose = class extends merge(TaskTools, make$9(make$7("chooseTask", {
201874
202255
  description: "Choose the task to work on",
@@ -201876,6 +202257,10 @@ var TaskToolsWithChoose = class extends merge(TaskTools, make$9(make$7("chooseTa
201876
202257
  taskId: String$1,
201877
202258
  githubPrNumber: optional$2(Number$1)
201878
202259
  })
202260
+ }), make$7("listEligibleTasks", {
202261
+ description: "List tasks eligible for being chosen with chooseTask.",
202262
+ success: TaskList,
202263
+ dependencies: [CurrentProjectId]
201879
202264
  }))) {};
201880
202265
  const TaskToolsHandlers = TaskToolsWithChoose.toLayer(gen(function* () {
201881
202266
  const source = yield* IssueSource;
@@ -201889,7 +202274,18 @@ const TaskToolsHandlers = TaskToolsWithChoose.toLayer(gen(function* () {
201889
202274
  description: issue.description,
201890
202275
  state: issue.state,
201891
202276
  priority: issue.priority,
201892
- estimate: issue.estimate,
202277
+ blockedBy: issue.blockedBy
202278
+ }));
202279
+ }, orDie$2),
202280
+ listEligibleTasks: fn("TaskTools.listEligibleTasks")(function* () {
202281
+ yield* log$1(`Calling "listEligibleTasks"`);
202282
+ const projectId = yield* CurrentProjectId;
202283
+ return (yield* source.issues(projectId)).filter((t) => t.blockedBy.length === 0 && t.state === "todo").map((issue) => ({
202284
+ id: issue.id ?? "",
202285
+ title: issue.title,
202286
+ description: issue.description,
202287
+ state: issue.state,
202288
+ priority: issue.priority,
201893
202289
  blockedBy: issue.blockedBy
201894
202290
  }));
201895
202291
  }, orDie$2),
@@ -201903,17 +202299,24 @@ const TaskToolsHandlers = TaskToolsWithChoose.toLayer(gen(function* () {
201903
202299
  return (yield* source.createIssue(projectId, new PrdIssue({
201904
202300
  ...options,
201905
202301
  id: null,
202302
+ estimate: null,
201906
202303
  autoMerge: false
201907
202304
  }))).id;
201908
202305
  }, orDie$2),
201909
202306
  updateTask: fn("TaskTools.updateTask")(function* (options) {
201910
202307
  yield* log$1(`Calling "updateTask"`).pipe(annotateLogs({ taskId: options.taskId }));
201911
202308
  const projectId = yield* CurrentProjectId;
202309
+ yield* CurrentTaskRef.update((prev) => prev.update(options));
201912
202310
  yield* source.updateIssue({
201913
202311
  projectId,
201914
202312
  issueId: options.taskId,
201915
202313
  ...options
201916
202314
  });
202315
+ }, orDie$2),
202316
+ removeTask: fn("TaskTools.removeTask")(function* (taskId) {
202317
+ yield* log$1(`Calling "removeTask"`).pipe(annotateLogs({ taskId }));
202318
+ const projectId = yield* CurrentProjectId;
202319
+ yield* source.cancelIssue(projectId, taskId);
201917
202320
  }, orDie$2)
201918
202321
  });
201919
202322
  }));
@@ -201965,10 +202368,15 @@ const runClanka = fnUntraced(
201965
202368
  tools: options.withChoose ? TaskToolsWithChoose : TaskTools,
201966
202369
  subagentModel: clankaSubagent(models, options.model)
201967
202370
  }).pipe(provide$1(models.get(options.model)));
201968
- return yield* (options.stallTimeout ? withStallTimeout(options.stallTimeout)(agent.output) : agent.output).pipe(pretty, runForEachArray((out) => {
202371
+ let stream = options.stallTimeout ? withStallTimeout(options.stallTimeout)(agent.output) : agent.output;
202372
+ if (options.steer) yield* options.steer.pipe(switchMap(fnUntraced(function* (message) {
202373
+ yield* log$1(`Received steer message: ${message}`);
202374
+ yield* agent.steer(message);
202375
+ }, fromEffectDrain)), runDrain, forkScoped);
202376
+ return yield* stream.pipe(pretty, runForEachArray((out) => {
201969
202377
  for (const item of out) process.stdout.write(item);
201970
202378
  return void_$1;
201971
- }), (_) => _);
202379
+ }));
201972
202380
  },
201973
202381
  scoped$1,
201974
202382
  provide$1([layerServices, TaskToolsHandlers])
@@ -201984,8 +202392,9 @@ const agentWorker = fnUntraced(function* (options) {
201984
202392
  model: options.preset.extraArgs.join(" "),
201985
202393
  system: options.system,
201986
202394
  prompt: options.prompt,
201987
- stallTimeout: options.stallTimeout
201988
- });
202395
+ stallTimeout: options.stallTimeout,
202396
+ steer: options.steer
202397
+ }).pipe(options.taskRef ? provideService$2(CurrentTaskRef, options.taskRef) : identity);
201989
202398
  return ExitCode(0);
201990
202399
  }
201991
202400
  return yield* pipe(options.preset.cliAgent.command({
@@ -202168,7 +202577,8 @@ const agentReviewer = fnUntraced(function* (options) {
202168
202577
  }),
202169
202578
  onSome: (prompt) => promptGen.promptReviewCustom({
202170
202579
  prompt,
202171
- specsDirectory: options.specsDirectory
202580
+ specsDirectory: options.specsDirectory,
202581
+ removePrdNotes: true
202172
202582
  })
202173
202583
  }),
202174
202584
  stallTimeout: options.stallTimeout
@@ -202183,7 +202593,8 @@ const agentReviewer = fnUntraced(function* (options) {
202183
202593
  }),
202184
202594
  onSome: (prompt) => promptGen.promptReviewCustom({
202185
202595
  prompt,
202186
- specsDirectory: options.specsDirectory
202596
+ specsDirectory: options.specsDirectory,
202597
+ removePrdNotes: false
202187
202598
  })
202188
202599
  }),
202189
202600
  prdFilePath: pathService.join(".lalph", "prd.yml"),
@@ -202284,17 +202695,30 @@ const run = fnUntraced(function* (options) {
202284
202695
  }));
202285
202696
  if (yield* gen(function* () {
202286
202697
  registry.update(currentWorker.state, (s) => s.transitionTo(WorkerStatus.Working({ issueId: taskId })));
202287
- const instructions = (yield* PromptGen).prompt({
202698
+ const promptGen = yield* PromptGen;
202699
+ const instructions = taskPreset.cliAgent.command ? promptGen.prompt({
202288
202700
  specsDirectory: options.specsDirectory,
202289
202701
  targetBranch: getOrUndefined$1(options.targetBranch),
202290
202702
  task: chosenTask.prd,
202291
202703
  githubPrNumber: chosenTask.githubPrNumber ?? void 0,
202292
202704
  gitFlow
202705
+ }) : promptGen.promptClanka({
202706
+ specsDirectory: options.specsDirectory,
202707
+ targetBranch: getOrUndefined$1(options.targetBranch),
202708
+ task: chosenTask.prd,
202709
+ githubPrNumber: chosenTask.githubPrNumber ?? void 0,
202710
+ gitFlow
202711
+ });
202712
+ const issueRef = make$63(chosenTask.prd.update({ state: "in-progress" }));
202713
+ const steer = yield* taskUpdateSteer({
202714
+ issueId: taskId,
202715
+ current: issueRef
202293
202716
  });
202294
202717
  yield* log$1(`Agent exited with code: ${yield* agentWorker({
202295
202718
  stallTimeout: options.stallTimeout,
202296
202719
  preset: taskPreset,
202297
- prompt: instructions
202720
+ prompt: instructions,
202721
+ steer
202298
202722
  }).pipe(catchStallInReview, withSpan("Main.agentWorker"))}`);
202299
202723
  if (options.review) {
202300
202724
  registry.update(currentWorker.state, (s) => s.transitionTo(WorkerStatus.Reviewing({ issueId: taskId })));
@@ -202421,6 +202845,19 @@ const watchTaskState = fnUntraced(function* (options) {
202421
202845
  }));
202422
202846
  }), withSpan("Main.watchTaskState"));
202423
202847
  });
202848
+ const taskUpdateSteer = fnUntraced(function* (options) {
202849
+ return toStreamResult(yield* AtomRegistry, currentIssuesAtom(yield* CurrentProjectId)).pipe(drop(1), retry$1(forever$1), orDie, filterMap$2((issues) => {
202850
+ const issue = issues.find((entry) => entry.id === options.issueId);
202851
+ if (!issue) return failVoid;
202852
+ if (!issue.isChangedComparedTo(options.current.current)) return failVoid;
202853
+ set$9(options.current, issue);
202854
+ return succeed$8(`The task has been updated by the user. Here is the latest information:
202855
+
202856
+ # ${issue.title}
202857
+
202858
+ ${issue.description}`);
202859
+ }));
202860
+ });
202424
202861
  //#endregion
202425
202862
  //#region src/Agents/planner.ts
202426
202863
  const agentPlanner = fnUntraced(function* (options) {
@@ -202520,7 +202957,12 @@ var Editor = class extends Service$1()("lalph/Editor", { make: gen(function* ()
202520
202957
  const content = (yield* fs.readFileString(file)).trim();
202521
202958
  if (content === initialContent) return yield* new NoSuchElementError();
202522
202959
  return content;
202523
- }, scoped$1, provideService$2(ChildProcessSpawner, spawner), option$1)
202960
+ }, scoped$1, provideService$2(ChildProcessSpawner, spawner), option$1),
202961
+ saveTemp: fnUntraced(function* (content, options) {
202962
+ const file = yield* fs.makeTempFile({ suffix: options.suffix ?? ".txt" });
202963
+ yield* fs.writeFileString(file, content);
202964
+ return file;
202965
+ })
202524
202966
  };
202525
202967
  }) }) {
202526
202968
  static layer = effect$1(this, this.make).pipe(provide$3(PlatformServices));
@@ -202537,6 +202979,10 @@ const commandPlan = make$46("plan", {
202537
202979
  onSuccess: (path) => fs.readFileString(path).pipe(asSome)
202538
202980
  });
202539
202981
  if (isNone(thePlan)) return;
202982
+ yield* addFinalizer((exit) => {
202983
+ if (isSuccess$3(exit)) return void_$1;
202984
+ return pipe(editor.saveTemp(thePlan.value, { suffix: ".md" }), flatMap$4((file) => log$1(`Saved your plan to: ${file}`)), ignore$1);
202985
+ });
202540
202986
  yield* gen(function* () {
202541
202987
  const project = withNewProject ? yield* addOrUpdateProject() : yield* selectProject;
202542
202988
  const { specsDirectory } = yield* commandRoot;
@@ -202553,7 +202999,7 @@ const commandPlan = make$46("plan", {
202553
202999
  CurrentIssueSource.layer,
202554
203000
  ClankaModels.layer
202555
203001
  ]));
202556
- }, provide$1(Editor.layer))), withSubcommands([commandPlanTasks]));
203002
+ }, scoped$1, provide$1(Editor.layer))), withSubcommands([commandPlanTasks]));
202557
203003
  const plan = fnUntraced(function* (options) {
202558
203004
  const fs = yield* FileSystem;
202559
203005
  const pathService = yield* Path$1;
@@ -202630,12 +203076,18 @@ const FrontMatterSchema = toCodecJson(Struct({
202630
203076
  autoMerge: Boolean$2
202631
203077
  }));
202632
203078
  const handler$1 = flow(withHandler(fnUntraced(function* () {
202633
- const content = yield* (yield* Editor).editTemp({
203079
+ const editor = yield* Editor;
203080
+ const content = yield* editor.editTemp({
202634
203081
  suffix: ".md",
202635
203082
  initialContent: issueTemplate
202636
203083
  });
202637
203084
  if (isNone(content)) return;
202638
- const lines = content.value.split("\n");
203085
+ const contentValue = content.value.trim();
203086
+ yield* addFinalizer((exit) => {
203087
+ if (isSuccess$3(exit)) return void_$1;
203088
+ return pipe(editor.saveTemp(contentValue, { suffix: ".md" }), flatMap$4((file) => log$1(`Saved your issue to: ${file}`)), ignore$1);
203089
+ });
203090
+ const lines = contentValue.split("\n");
202639
203091
  const yamlLines = [];
202640
203092
  let descriptionStartIndex = 0;
202641
203093
  for (let i = 0; i < lines.length; i++) {
@@ -202663,7 +203115,7 @@ const handler$1 = flow(withHandler(fnUntraced(function* () {
202663
203115
  console.log(`Created issue with ID: ${created.id}`);
202664
203116
  console.log(`URL: ${created.url}`);
202665
203117
  }).pipe(provide$1([layerProjectIdPrompt, CurrentIssueSource.layer]));
202666
- })), provide(Editor.layer));
203118
+ }, scoped$1)), provide(Editor.layer));
202667
203119
  const commandIssue = make$46("issue").pipe(withDescription("Create a new issue in your editor."), withAlias("i"), handler$1);
202668
203120
  //#endregion
202669
203121
  //#region src/commands/edit.ts
@@ -202677,7 +203129,7 @@ const commandEdit = make$46("edit").pipe(withDescription("Open the selected proj
202677
203129
  const commandSource = make$46("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));
202678
203130
  //#endregion
202679
203131
  //#region package.json
202680
- var version = "0.3.45";
203132
+ var version = "0.3.47";
202681
203133
  //#endregion
202682
203134
  //#region src/commands/projects/ls.ts
202683
203135
  const commandProjectsLs = make$46("ls").pipe(withDescription("List configured projects and how they run (enabled state, concurrency, branch, git flow, review agent)."), withHandler(fnUntraced(function* () {