@eliya-oss/agent-diff 0.1.0-alpha.20 → 0.1.0-alpha.22

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.
@@ -15,6 +15,8 @@ the way it is, why it is tested the way it is. ADRs explain choices that outlive
15
15
  | [ADR-002](ADR-002-effect-v4-and-module-boundaries.md) | Effect v4, and modules sealed behind `index.ts` |
16
16
  | [ADR-003](ADR-003-blackbox-testdriver.md) | Black-box tests through a TestDriver, and no unit tests |
17
17
  | [ADR-004](ADR-004-pnpm-native-releases.md) | pnpm's own release tooling instead of Changesets |
18
+ | [ADR-005](ADR-005-a-mechanical-style-contract.md) | Style is a lint rule, not a document |
19
+ | [ADR-006](ADR-006-the-terminal-runs-on-effect.md) | The terminal runs on Effect |
18
20
 
19
21
  ## Writing one
20
22
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.22
4
+
5
+ ### Patch Changes
6
+
7
+ - A selection reaching over hidden lines reports the range it will actually comment on.
8
+
9
+ - Composing on a row that carries no line says so instead of opening a panel that cannot send.
10
+
11
+ - The stale mark on the layer rail reads in full at any width.
12
+
13
+ ## 0.1.0-alpha.21
14
+
15
+ ### Patch Changes
16
+
17
+ - The store answers with the settings effect directly.
18
+
3
19
  ## 0.1.0-alpha.20
4
20
 
5
21
  ### Patch Changes
package/dist/main.js CHANGED
@@ -5132,6 +5132,19 @@ const MinimumLogLevel = /*#__PURE__*/ Reference("effect/References/MinimumLogLev
5132
5132
  //#endregion
5133
5133
  //#region node_modules/.pnpm/effect@4.0.0-beta.102/node_modules/effect/dist/internal/tracer.js
5134
5134
  /** @internal */
5135
+ const addSpanStackTrace = (options) => {
5136
+ if (options?.captureStackTrace === false) return options;
5137
+ else if (options?.captureStackTrace !== void 0 && typeof options.captureStackTrace !== "boolean") return options;
5138
+ const limit = getStackTraceLimit();
5139
+ setStackTraceLimit(3);
5140
+ const traceError = /* @__PURE__ */ new Error();
5141
+ setStackTraceLimit(limit);
5142
+ return {
5143
+ ...options,
5144
+ captureStackTrace: spanCleaner(() => traceError.stack)
5145
+ };
5146
+ };
5147
+ /** @internal */
5135
5148
  const makeStackCleaner = (line) => (stack) => {
5136
5149
  let cache;
5137
5150
  return () => {
@@ -5145,6 +5158,7 @@ const makeStackCleaner = (line) => (stack) => {
5145
5158
  }
5146
5159
  };
5147
5160
  };
5161
+ const spanCleaner = /*#__PURE__*/ makeStackCleaner(3);
5148
5162
  //#endregion
5149
5163
  //#region node_modules/.pnpm/effect@4.0.0-beta.102/node_modules/effect/dist/internal/effect.js
5150
5164
  /** @internal */
@@ -5584,6 +5598,8 @@ const callback$1 = (register) => callbackOptions(register, register.length >= 2)
5584
5598
  /** @internal */
5585
5599
  const never = /*#__PURE__*/ callback$1(constVoid);
5586
5600
  /** @internal */
5601
+ const gen$1 = (...args) => suspend(() => fromIteratorUnsafe(args.length === 1 ? args[0]() : args[1].call(args[0].self)));
5602
+ /** @internal */
5587
5603
  const fnUntraced = (body, ...pipeables) => {
5588
5604
  const fn = pipeables.length === 0 ? function() {
5589
5605
  return suspend(() => fromIteratorUnsafe(body.apply(this, arguments)));
@@ -6241,6 +6257,14 @@ const makeSpanUnsafe = (fiber, name, options) => {
6241
6257
  }
6242
6258
  return span;
6243
6259
  };
6260
+ const provideSpanStackFrame = (name, stack) => {
6261
+ stack = typeof stack === "function" ? stack : constUndefined;
6262
+ return updateService(CurrentStackFrame, (parent) => ({
6263
+ name,
6264
+ stack,
6265
+ parent
6266
+ }));
6267
+ };
6244
6268
  /** @internal */
6245
6269
  const useSpan = (name, ...args) => {
6246
6270
  const options = args.length === 1 ? void 0 : args[0];
@@ -6256,6 +6280,32 @@ const useSpan = (name, ...args) => {
6256
6280
  };
6257
6281
  const provideParentSpan = /*#__PURE__*/ provideService(ParentSpan);
6258
6282
  /** @internal */
6283
+ const withParentSpan = function() {
6284
+ const dataFirst = isEffect(arguments[0]);
6285
+ const span = dataFirst ? arguments[1] : arguments[0];
6286
+ let options = dataFirst ? arguments[2] : arguments[1];
6287
+ let provideStackFrame = identity;
6288
+ if (span._tag === "Span") {
6289
+ options = addSpanStackTrace(options);
6290
+ provideStackFrame = provideSpanStackFrame(span.name, options?.captureStackTrace);
6291
+ }
6292
+ if (dataFirst) return provideParentSpan(provideStackFrame(arguments[0]), span);
6293
+ return (self) => provideParentSpan(provideStackFrame(self), span);
6294
+ };
6295
+ /** @internal */
6296
+ const withSpan$1 = function() {
6297
+ const dataFirst = typeof arguments[0] !== "string";
6298
+ const name = dataFirst ? arguments[1] : arguments[0];
6299
+ const traceOptions = addSpanStackTrace(arguments[2]);
6300
+ if (dataFirst) {
6301
+ const self = arguments[0];
6302
+ return useSpan(name, arguments[2], (span) => withParentSpan(self, span, traceOptions));
6303
+ }
6304
+ const fnArg = typeof arguments[1] === "function" ? arguments[1] : void 0;
6305
+ const options = fnArg ? void 0 : arguments[1];
6306
+ return (self, ...args) => useSpan(name, fnArg ? fnArg(...args) : options, (span) => withParentSpan(self, span, traceOptions));
6307
+ };
6308
+ /** @internal */
6259
6309
  const ClockRef = /*#__PURE__*/ Reference("effect/Clock", { defaultValue: () => new ClockImpl() });
6260
6310
  const MAX_TIMER_MILLIS = 2 ** 31 - 1;
6261
6311
  var ClockImpl = class {
@@ -7546,6 +7596,57 @@ const void_ = void_$2;
7546
7596
  */
7547
7597
  const callback = callback$1;
7548
7598
  /**
7599
+ * Provides a way to write effectful code using generator functions, simplifying
7600
+ * control flow and error handling.
7601
+ *
7602
+ * **When to use**
7603
+ *
7604
+ * Use when you want to write effectful code that looks and behaves like
7605
+ * synchronous code, while still handling asynchronous tasks, errors, and complex
7606
+ * control flow such as loops and conditions.
7607
+ *
7608
+ * Generator functions work similarly to `async/await` but keep errors,
7609
+ * requirements, and interruption in the Effect type. You can `yield*` values
7610
+ * from effects and return the final result at the end.
7611
+ *
7612
+ * **Example** (Sequencing effects with generators)
7613
+ *
7614
+ * ```ts
7615
+ * import { Data, Effect } from "effect"
7616
+ *
7617
+ * class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
7618
+ *
7619
+ * const addServiceCharge = (amount: number) => amount + 1
7620
+ *
7621
+ * const applyDiscount = (
7622
+ * total: number,
7623
+ * discountRate: number
7624
+ * ): Effect.Effect<number, DiscountRateError> =>
7625
+ * discountRate === 0
7626
+ * ? Effect.fail(new DiscountRateError())
7627
+ * : Effect.succeed(total - (total * discountRate) / 100)
7628
+ *
7629
+ * const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
7630
+ *
7631
+ * const fetchDiscountRate = Effect.promise(() => Promise.resolve(5))
7632
+ *
7633
+ * export const program = Effect.gen(function*() {
7634
+ * const transactionAmount = yield* fetchTransactionAmount
7635
+ * const discountRate = yield* fetchDiscountRate
7636
+ * const discountedAmount = yield* applyDiscount(
7637
+ * transactionAmount,
7638
+ * discountRate
7639
+ * )
7640
+ * const finalAmount = addServiceCharge(discountedAmount)
7641
+ * return `Final amount to charge: ${finalAmount}`
7642
+ * })
7643
+ * ```
7644
+ *
7645
+ * @category constructors
7646
+ * @since 2.0.0
7647
+ */
7648
+ const gen = gen$1;
7649
+ /**
7549
7650
  * Creates an `Effect` that represents a recoverable error.
7550
7651
  *
7551
7652
  * **When to use**
@@ -8005,6 +8106,28 @@ const context = context$1;
8005
8106
  */
8006
8107
  const provide = provide$1;
8007
8108
  /**
8109
+ * Wraps the effect with a child span for tracing.
8110
+ *
8111
+ * **Example** (Wrapping an effect in a child span)
8112
+ *
8113
+ * ```ts
8114
+ * import { Effect } from "effect"
8115
+ *
8116
+ * const task = Effect.gen(function*() {
8117
+ * yield* Effect.log("Executing task")
8118
+ * return "result"
8119
+ * })
8120
+ *
8121
+ * const traced = Effect.withSpan(task, "my-task", {
8122
+ * attributes: { version: "1.0" }
8123
+ * })
8124
+ * ```
8125
+ *
8126
+ * @category tracing
8127
+ * @since 2.0.0
8128
+ */
8129
+ const withSpan = withSpan$1;
8130
+ /**
8008
8131
  * Executes an effect as a Promise with the provided services.
8009
8132
  *
8010
8133
  * **When to use**
@@ -11877,13 +12000,13 @@ const cursorOps = (state, saveState, inbox) => {
11877
12000
  };
11878
12001
  const settingsOps = (root) => {
11879
12002
  return {
11880
- settings: fn("Store.settings")(function* () {
12003
+ settings: gen(function* () {
11881
12004
  const raw = yield* readOptional(settingsPath(root));
11882
12005
  return match$2(raw, {
11883
12006
  onNone: () => ({}),
11884
12007
  onSome: parseSettings
11885
12008
  });
11886
- }),
12009
+ }).pipe(withSpan("Store.settings")),
11887
12010
  saveSettings: fn("Store.saveSettings")(function* (next) {
11888
12011
  const path = settingsPath(root);
11889
12012
  yield* ensureDir(root);
@@ -12302,7 +12425,7 @@ const fileSource = fn("Cli.fileSource")(function* (repo, branch, file) {
12302
12425
  });
12303
12426
  const saveWrap = fn("Cli.saveWrap")(function* (wrap) {
12304
12427
  const store = yield* Store;
12305
- const current = yield* store.settings();
12428
+ const current = yield* store.settings;
12306
12429
  yield* store.saveSettings({
12307
12430
  ...current,
12308
12431
  wrap
@@ -13620,12 +13743,15 @@ const markedRows = (state) => {
13620
13743
  })).map((row) => row.index));
13621
13744
  return new Set(rows);
13622
13745
  };
13623
- const snippetOf = (state, limit) => {
13746
+ const carriesLine = (row) => isSome(row.newLine) || isSome(row.oldLine);
13747
+ const selectedRows = (state) => {
13624
13748
  const patch = selectedPatch(state);
13625
13749
  if (patch === void 0) return [];
13626
13750
  const [from, to] = selectionRange(state);
13627
- return patch.rows.slice(from, to + 1).slice(0, limit).map((row) => `${String(lineOf(row)).padStart(4)} ${row.text}`);
13751
+ return patch.rows.slice(from, to + 1).filter(carriesLine);
13628
13752
  };
13753
+ const snippetOf = (state, limit) => selectedRows(state).slice(0, limit).map((row) => `${lineOf(row).padStart(4)} ${row.text}`);
13754
+ const selectedLineCount = (state) => selectedRows(state).length;
13629
13755
  const lineOf = (row) => match$2(row.newLine, {
13630
13756
  onNone: () => "-",
13631
13757
  onSome: (line) => String(line)
@@ -13640,17 +13766,18 @@ const composeTarget = (state) => {
13640
13766
  const patch = selectedPatch(state);
13641
13767
  if (patch === void 0) return "";
13642
13768
  const [from, to] = selectionRange(state);
13643
- const first = sourceLineAt(state, from) ?? from + 1;
13644
- const last = sourceLineAt(state, to) ?? to + 1;
13645
- const span = first === last ? `${first}` : `${first}-${last}`;
13646
- return `Comment on ${patch.path}:${span}`;
13769
+ const anchor = anchorFor(patch, from, to);
13770
+ const span = match$2(anchor, {
13771
+ onNone: () => "",
13772
+ onSome: (found) => found.start === found.end ? `${found.start}` : `${found.start}-${found.end}`
13773
+ });
13774
+ return span === "" ? `Comment on ${patch.path}` : `Comment on ${patch.path}:${span}`;
13647
13775
  };
13648
13776
  const selectionReadout = (state) => {
13649
13777
  const patch = selectedPatch(state);
13650
13778
  if (patch === void 0 || !state.selecting) return "";
13651
- const [from, to] = selectionRange(state);
13652
- const lines = to - from + 1;
13653
- return `${patch.path} ${lines} lines`;
13779
+ const lines = selectedRows(state).length;
13780
+ return `${patch.path} ${lines} ${lines === 1 ? "line" : "lines"}`;
13654
13781
  };
13655
13782
  const WHOLE_FILE = 1e5;
13656
13783
  const CONTEXT_STEPS = [
@@ -14458,12 +14585,17 @@ const startSelection = (state) => ({
14458
14585
  selecting: true,
14459
14586
  anchorRow: state.cursor
14460
14587
  });
14461
- const openCompose = (state) => ({
14462
- ...state,
14463
- screen: "compose",
14464
- draft: "",
14465
- anchorRow: state.selecting ? state.anchorRow : state.cursor
14466
- });
14588
+ const openCompose = (state) => {
14589
+ const patch = selectedPatch(state);
14590
+ const [from, to] = selectionRange(state);
14591
+ if (!(patch !== void 0 && isSome(anchorFor(patch, from, to)))) return withNoticeHere(state, "no line here to comment on");
14592
+ return {
14593
+ ...state,
14594
+ screen: "compose",
14595
+ draft: "",
14596
+ anchorRow: state.selecting ? state.anchorRow : state.cursor
14597
+ };
14598
+ };
14467
14599
  const goBack = (state) => {
14468
14600
  if (state.screen === "pending") return {
14469
14601
  ...state,
@@ -15729,6 +15861,7 @@ const STEP_NUMBER = 3;
15729
15861
  const STEP_LEAD = 8;
15730
15862
  const NOTE_LEAD = 10;
15731
15863
  const STEP_GAP = 1;
15864
+ const staleBanner = (room) => wrapped("stale, the branch moved on", room).map((line) => ` ${line}`).join("\n");
15732
15865
  const layerRoom = (state, pane) => {
15733
15866
  const tally = Math.max(1, ...state.layers.map((layer) => `${layer.files.length}`.length));
15734
15867
  return {
@@ -15943,7 +16076,7 @@ var Screen = class {
15943
16076
  const window = railWindow(layerRows(state, room.title, room.note), height, state.layerIndex);
15944
16077
  const rows = window.rows.map((row) => fg(layerPaint(state, row))(`${layerText(state, row, room)}\n`));
15945
16078
  const more = window.more > 0 ? [fg(palette.faint)(` … ${window.more} more`)] : [];
15946
- const warn = state.layersStale ? [fg(palette.attention)(` stale, the branch moved on\n\n`)] : [];
16079
+ const warn = state.layersStale ? [fg(palette.attention)(`${staleBanner(room.note)}\n`)] : [];
15947
16080
  return new StyledText([
15948
16081
  ...warn,
15949
16082
  ...rows,
@@ -16168,7 +16301,7 @@ var Screen = class {
16168
16301
  }
16169
16302
  const room = composeRoom(this.renderer.width);
16170
16303
  const snippet = snippetOf(state, SNIPPET_LINES);
16171
- const more = selectionRange(state)[1] - selectionRange(state)[0] + 1 - snippet.length;
16304
+ const more = selectedLineCount(state) - snippet.length;
16172
16305
  const tail = more > 0 ? [` … ${more} more lines`] : [];
16173
16306
  const quoted = [...snippet, ...tail].map((line) => clip(line, room.text));
16174
16307
  const written = laidOut(`${state.draft}▌`.split("\n"), room.text);
@@ -16711,7 +16844,7 @@ const launch = fn("Tui.launch")(function* (repo, renderer, noticeMs, sessionPath
16711
16844
  const branches = yield* listBranches(repo);
16712
16845
  const resume = sessionPath === void 0 ? void 0 : yield* promise(() => readSession(sessionPath));
16713
16846
  const store = yield* Store;
16714
- const settings = yield* store.settings();
16847
+ const settings = yield* store.settings;
16715
16848
  return new App({
16716
16849
  renderer,
16717
16850
  repo,
@@ -16873,7 +17006,7 @@ const routes = {
16873
17006
  name: asked,
16874
17007
  known: commandNames
16875
17008
  });
16876
- yield* answer(options, { commands: found === void 0 ? catalog : [found] });
17009
+ return yield* answer(options, { commands: found === void 0 ? catalog : [found] });
16877
17010
  })
16878
17011
  };
16879
17012
  const run = fn("Main.run")(function* (name, options) {
package/package.json CHANGED
@@ -2,11 +2,12 @@
2
2
  "name": "@eliya-oss/agent-diff",
3
3
  "type": "module",
4
4
  "devDependencies": {
5
- "@effect/tsgo": "^0.28.0",
5
+ "@effect/tsgo": "^0.31.0",
6
6
  "@effect/vitest": "^4.0.0-beta.102",
7
7
  "@types/node": "^26.1.2",
8
8
  "effect": "^4.0.0-beta.102",
9
- "oxlint": "^1.76.0",
9
+ "oxlint": "1.77.0",
10
+ "oxlint-tsgolint": "^7.0.2001",
10
11
  "rolldown": "^1.2.1",
11
12
  "vitest": "^4.1.10"
12
13
  },
@@ -22,7 +23,7 @@
22
23
  "bin": {
23
24
  "adiff": "./bin/adiff.js"
24
25
  },
25
- "version": "0.1.0-alpha.20",
26
+ "version": "0.1.0-alpha.22",
26
27
  "description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
27
28
  "license": "MIT",
28
29
  "repository": {
@@ -42,7 +43,7 @@
42
43
  "check": "pnpm run typecheck && pnpm run lint && pnpm run build && pnpm test",
43
44
  "build": "rolldown -c rolldown.config.ts",
44
45
  "typecheck": "tsc --noEmit",
45
- "lint": "oxlint && node scripts/check-rules.ts && pnpm run lint:effect",
46
+ "lint": "oxlint && node scripts/check-rules.ts",
46
47
  "test": "NODE_OPTIONS=--experimental-ffi vitest run",
47
48
  "test:watch": "NODE_OPTIONS=--experimental-ffi vitest",
48
49
  "dev": "node --experimental-ffi --disable-warning=ExperimentalWarning src/main.ts",
@@ -52,7 +53,6 @@
52
53
  "sketch": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/sketch.ts",
53
54
  "watch": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/watch.ts",
54
55
  "serve": "node --experimental-ffi --disable-warning=ExperimentalWarning scripts/serve.ts",
55
- "play": "node --watch --watch-path=src --watch-path=scripts --experimental-ffi --disable-warning=ExperimentalWarning scripts/play.ts",
56
- "lint:effect": "effect-tsgo diagnostics --project tsconfig.json --format text --severity error,warning --lspconfig '{\"diagnostics\":{\"floatingEffect\":\"error\",\"missingEffectError\":\"error\",\"missingEffectContext\":\"error\",\"classSelfMismatch\":\"error\",\"anyUnknownInErrorContext\":\"error\",\"genericEffectServices\":\"error\",\"effectFnImplicitAny\":\"error\"}}'"
56
+ "play": "node --watch --watch-path=src --watch-path=scripts --experimental-ffi --disable-warning=ExperimentalWarning scripts/play.ts"
57
57
  }
58
58
  }