@eliya-oss/agent-diff 0.1.0-alpha.14 → 0.1.0-alpha.15

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/main.js +147 -21
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.15
4
+
5
+ ### Patch Changes
6
+
7
+ - Pan the diff sideways to read past the right edge.
8
+
9
+ - The footer keeps the way out visible on a narrow terminal.
10
+
11
+ - Wrapping keeps every character and is remembered between sessions.
12
+
3
13
  ## 0.1.0-alpha.14
4
14
 
5
15
  ### Patch Changes
package/dist/main.js CHANGED
@@ -10808,6 +10808,7 @@ const inboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "i
10808
10808
  const outboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "outbox.jsonl");
10809
10809
  const statePath = (root, worktreePath) => join(branchDir(root, worktreePath), "state.json");
10810
10810
  const layersPath = (root, worktreePath) => join(branchDir(root, worktreePath), "layers.json");
10811
+ const settingsPath = (root) => join(root, "settings.json");
10811
10812
  const reportsDir = (root) => join(root, "reports");
10812
10813
  const reportPath = (root, stamp) => join(reportsDir(root), `${stamp}.md`);
10813
10814
  //#endregion
@@ -10832,6 +10833,10 @@ const readOptional = fn("Store.readOptional")(function* (path) {
10832
10833
  }).pipe(map(some), catchTag("StoreUnreadable", () => missing));
10833
10834
  });
10834
10835
  const missing = succeed(none());
10836
+ const parseSettings = (raw) => {
10837
+ const parsed = JSON.parse(raw);
10838
+ return typeof parsed.wrap === "boolean" ? { wrap: parsed.wrap } : {};
10839
+ };
10835
10840
  const parseBatches = (raw) => raw.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
10836
10841
  const parseAnswers = (raw) => raw.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
10837
10842
  const parseState = (raw) => ({
@@ -10881,6 +10886,28 @@ const cursorOps = (state, saveState, inbox) => {
10881
10886
  })
10882
10887
  };
10883
10888
  };
10889
+ const settingsOps = (root) => {
10890
+ return {
10891
+ settings: fn("Store.settings")(function* () {
10892
+ const raw = yield* readOptional(settingsPath(root));
10893
+ return match$2(raw, {
10894
+ onNone: () => ({}),
10895
+ onSome: parseSettings
10896
+ });
10897
+ }),
10898
+ saveSettings: fn("Store.saveSettings")(function* (next) {
10899
+ const path = settingsPath(root);
10900
+ yield* ensureDir(root);
10901
+ yield* tryPromise({
10902
+ try: () => writeFile(path, JSON.stringify(next), "utf8"),
10903
+ catch: (cause) => new StoreUnwritable({
10904
+ path,
10905
+ reason: String(cause)
10906
+ })
10907
+ });
10908
+ })
10909
+ };
10910
+ };
10884
10911
  const reportOps = (root) => fn("Store.saveReport")(function* (stamp, text) {
10885
10912
  const path = reportPath(root, stamp);
10886
10913
  yield* ensureDir(reportsDir(root));
@@ -10979,6 +11006,7 @@ const makeStore = (root) => {
10979
11006
  state,
10980
11007
  saveState,
10981
11008
  saveReport: reportOps(root),
11009
+ ...settingsOps(root),
10982
11010
  ...answerOps(root),
10983
11011
  ...layersOps(root),
10984
11012
  ...cursors
@@ -11282,6 +11310,14 @@ const fileSource = fn("Cli.fileSource")(function* (repo, branch, file) {
11282
11310
  const found = yield* git.source(worktree, file);
11283
11311
  return getOrElse(found, () => []);
11284
11312
  });
11313
+ const saveWrap = fn("Cli.saveWrap")(function* (wrap) {
11314
+ const store = yield* Store;
11315
+ const current = yield* store.settings();
11316
+ yield* store.saveSettings({
11317
+ ...current,
11318
+ wrap
11319
+ });
11320
+ });
11285
11321
  //#endregion
11286
11322
  //#region src/domain/layers/model.ts
11287
11323
  const REMAINDER_TITLE = "not in any layer";
@@ -12415,6 +12451,7 @@ const initialState = (branches) => ({
12415
12451
  focus: "diff",
12416
12452
  navOpen: true,
12417
12453
  wrap: false,
12454
+ pan: 0,
12418
12455
  layers: [],
12419
12456
  layersStale: false,
12420
12457
  pulls: {},
@@ -12902,6 +12939,18 @@ const commands = [
12902
12939
  screens: ["review"],
12903
12940
  hint: "wrap"
12904
12941
  }),
12942
+ command({
12943
+ action: "pan.right",
12944
+ title: "Pan the diff right",
12945
+ keys: [">"],
12946
+ screens: ["review"]
12947
+ }),
12948
+ command({
12949
+ action: "pan.left",
12950
+ title: "Pan the diff left",
12951
+ keys: ["<"],
12952
+ screens: ["review"]
12953
+ }),
12905
12954
  command({
12906
12955
  action: "review.reload",
12907
12956
  title: "Read the branch again",
@@ -13207,6 +13256,14 @@ const layerComment = (state, delta) => {
13207
13256
  if (file !== void 0) return atComment(state, file, delta);
13208
13257
  return here.length > 0 ? state : withNotice(state, "no comments yet");
13209
13258
  };
13259
+ const PAN_STEP = 8;
13260
+ const panned = (state, delta) => {
13261
+ if (state.wrap) return withNotice(state, "wrapping is on, so there is nothing to pan");
13262
+ return {
13263
+ ...state,
13264
+ pan: Math.max(0, state.pan + delta)
13265
+ };
13266
+ };
13210
13267
  const movePending = (state, delta) => ({
13211
13268
  ...state,
13212
13269
  pendingIndex: clamp(state.pendingIndex + delta, 0, Math.max(0, state.pending.length - 1))
@@ -13392,8 +13449,11 @@ const transitions = {
13392
13449
  }),
13393
13450
  "wrap.toggle": (state) => ({
13394
13451
  ...state,
13395
- wrap: !state.wrap
13452
+ wrap: !state.wrap,
13453
+ pan: 0
13396
13454
  }),
13455
+ "pan.right": (state) => panned(state, PAN_STEP),
13456
+ "pan.left": (state) => panned(state, -8),
13397
13457
  "review.reload": (state) => state,
13398
13458
  "rail.toggle": toggleRail,
13399
13459
  "file.vouch": (state) => state,
@@ -13465,6 +13525,10 @@ const withPending = (state, pending, screen) => ({
13465
13525
  staged: pending.length,
13466
13526
  screen
13467
13527
  });
13528
+ const panBy = (state, delta) => state.wrap ? state : {
13529
+ ...state,
13530
+ pan: Math.max(0, state.pan + delta)
13531
+ };
13468
13532
  const withSent = (state, sent) => ({
13469
13533
  ...state,
13470
13534
  sent
@@ -13737,6 +13801,33 @@ const ANSWER_MARK = "↳";
13737
13801
  const OVERSCAN = 2;
13738
13802
  const SIGN_WIDTH = 2;
13739
13803
  const SCROLL_ROWS = 3;
13804
+ const PAN_COLUMNS = 8;
13805
+ const WAYS = {
13806
+ up: {
13807
+ step: -1,
13808
+ across: false
13809
+ },
13810
+ down: {
13811
+ step: 1,
13812
+ across: false
13813
+ },
13814
+ left: {
13815
+ step: -1,
13816
+ across: true
13817
+ },
13818
+ right: {
13819
+ step: 1,
13820
+ across: true
13821
+ }
13822
+ };
13823
+ const notchesIn = (event) => Math.max(1, event.scroll?.delta ?? 1);
13824
+ const wheelTo = (event, handlers) => {
13825
+ const way = WAYS[event.scroll?.direction ?? ""];
13826
+ if (way === void 0) return;
13827
+ const step = way.step * notchesIn(event);
13828
+ if (way.across || event.modifiers?.shift === true) handlers.pan(step * PAN_COLUMNS);
13829
+ else handlers.scroll(step * SCROLL_ROWS);
13830
+ };
13740
13831
  const SIGNS = {
13741
13832
  added: {
13742
13833
  text: " +",
@@ -13830,12 +13921,7 @@ var DiffView = class {
13830
13921
  return this.numbers;
13831
13922
  }
13832
13923
  listenTo(handlers) {
13833
- this.numbers.onMouseScroll = (event) => {
13834
- const way = event.scroll?.direction;
13835
- if (way !== "up" && way !== "down") return;
13836
- const size = Math.max(1, event.scroll?.delta ?? 1) * SCROLL_ROWS;
13837
- handlers.scroll(way === "up" ? -size : size);
13838
- };
13924
+ this.numbers.onMouseScroll = (event) => wheelTo(event, handlers);
13839
13925
  this.numbers.onMouseDown = (event) => handlers.down(event.y);
13840
13926
  this.numbers.onMouseDrag = (event) => handlers.drag(event.y);
13841
13927
  this.numbers.onMouseDragEnd = (event) => handlers.dragEnd(event.y);
@@ -13886,11 +13972,26 @@ var DiffView = class {
13886
13972
  this.code.onHighlight = (highlights) => [...highlights.filter((highlight) => !spans.some(([from, to]) => highlight[0] < to && highlight[1] > from)), ...spans];
13887
13973
  }
13888
13974
  setWrap(on) {
13889
- if (on === this.wrapped) return;
13890
- this.wrapped = on;
13891
- this.code.wrapMode = on ? "word" : "none";
13892
- this.code.requestRender();
13893
- this.numbers.requestRender();
13975
+ if (on !== this.wrapped) {
13976
+ this.wrapped = on;
13977
+ this.code.wrapMode = on ? "word" : "none";
13978
+ this.code.requestRender();
13979
+ this.numbers.requestRender();
13980
+ }
13981
+ this.fitWrapWidth();
13982
+ }
13983
+ setPan(columns) {
13984
+ const wanted = this.wrapped ? 0 : Math.max(0, Math.min(this.code.maxScrollX, columns));
13985
+ if (this.code.scrollX !== wanted) this.code.scrollX = wanted;
13986
+ if (this.pinned.scrollX !== wanted) this.pinned.scrollX = wanted;
13987
+ }
13988
+ panned() {
13989
+ return this.code.scrollX;
13990
+ }
13991
+ fitWrapWidth() {
13992
+ const room = this.numbers.width - Math.max(0, this.code.x - this.numbers.x);
13993
+ const wanted = this.wrapped && room > 0 ? room : "100%";
13994
+ if (this.code.width !== wanted) this.code.width = wanted;
13894
13995
  }
13895
13996
  sources() {
13896
13997
  const reported = this.code.lineInfo?.lineSources;
@@ -14459,7 +14560,8 @@ const headerParts = (state, branch, path) => [
14459
14560
  state.vouched.length === 0 ? "" : reviewedCount(state),
14460
14561
  state.staged === 0 ? "" : `${state.staged} staged`,
14461
14562
  contextLabel(state.context),
14462
- hiddenLines(state) === 0 ? "" : `⋯ ${hiddenLines(state)} lines hidden`
14563
+ hiddenLines(state) === 0 ? "" : `⋯ ${hiddenLines(state)} lines hidden`,
14564
+ state.pan === 0 ? "" : `→ ${state.pan} columns`
14463
14565
  ];
14464
14566
  const fallbackScope = (state, top) => {
14465
14567
  const scope = (selectedPatch(state)?.hunks.findLast((hunk) => hunk.startRow < top))?.scope ?? "";
@@ -14585,6 +14687,7 @@ var Screen = class {
14585
14687
  this.mouse = mouse;
14586
14688
  this.view.listenTo({
14587
14689
  scroll: (delta) => this.mouse?.onScroll(delta),
14690
+ pan: (delta) => this.mouse?.onPan(delta),
14588
14691
  down: (y) => {
14589
14692
  this.dragFrom = this.rowAtY(y);
14590
14693
  this.mouse?.onDrag(this.dragFrom, this.dragFrom, false);
@@ -14663,15 +14766,15 @@ var Screen = class {
14663
14766
  const readout = selectionReadout(state);
14664
14767
  this.lead = readout.length === 0 ? 0 : readout.length + 3;
14665
14768
  const lead = readout.length === 0 ? [] : [fg(palette.muted)(`${readout} `)];
14666
- if (state.notice.length === 0) return new StyledText([...lead, ...this.chipRow().chunks]);
14667
- const tail = ` ${state.notice}`;
14769
+ const tail = state.notice.length === 0 ? "" : ` ${state.notice}`;
14668
14770
  const width = this.footer.width > 0 ? this.footer.width : this.renderer.width;
14669
14771
  const room = Math.max(0, width - this.lead - tail.length);
14670
14772
  const chips = keptWithin(this.chipRow().chunks, room);
14773
+ const notice = tail.length === 0 ? [] : [fg(palette.attention)(tail)];
14671
14774
  return new StyledText([
14672
14775
  ...lead,
14673
14776
  ...chips,
14674
- fg(palette.attention)(tail)
14777
+ ...notice
14675
14778
  ]);
14676
14779
  }
14677
14780
  paneRoom() {
@@ -14706,6 +14809,7 @@ var Screen = class {
14706
14809
  const patch = shown.patch;
14707
14810
  this.paintSticky(state, state.top);
14708
14811
  this.view.setWrap(state.wrap);
14812
+ this.view.setPan(state.pan);
14709
14813
  this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
14710
14814
  this.view.fit(this.diffScroll.height);
14711
14815
  const height = this.view.rows();
@@ -14979,21 +15083,28 @@ var App = class {
14979
15083
  noticeMs;
14980
15084
  sessionPath;
14981
15085
  remembered = "";
15086
+ wrapKept = false;
14982
15087
  keys = [];
14983
15088
  fading;
14984
15089
  wheel = 0;
15090
+ sideways = 0;
14985
15091
  constructor(options) {
14986
15092
  this.renderer = options.renderer;
14987
15093
  this.repo = options.repo;
14988
15094
  this.run = options.run;
14989
15095
  this.noticeMs = options.noticeMs ?? 2200;
14990
15096
  this.sessionPath = options.sessionPath;
15097
+ this.wrapKept = options.wrap === true;
14991
15098
  const { branches, renderer } = options;
14992
- this.state = initialState(branches);
15099
+ this.state = {
15100
+ ...initialState(branches),
15101
+ wrap: options.wrap === true
15102
+ };
14993
15103
  this.screen = new Screen(renderer, options.repo);
14994
15104
  this.screen.update(this.state);
14995
15105
  this.screen.listen({
14996
15106
  onScroll: (delta) => this.onWheel(delta),
15107
+ onPan: (delta) => this.onPanWheel(delta),
14997
15108
  onDrag: (from, to) => this.commit(draggedTo(this.measured(), from, to)),
14998
15109
  onChip: (key) => this.dispatchTask(() => this.onKey(asKey(key)))
14999
15110
  });
@@ -15025,6 +15136,11 @@ var App = class {
15025
15136
  });
15026
15137
  await this.loadSource();
15027
15138
  }
15139
+ rememberWrap(next) {
15140
+ if (next.wrap === this.wrapKept) return;
15141
+ this.wrapKept = next.wrap;
15142
+ this.run(saveWrap(next.wrap)).catch(() => void 0);
15143
+ }
15028
15144
  rememberPlace(next) {
15029
15145
  if (this.sessionPath === void 0 || next.screen !== "review") return;
15030
15146
  const session = sessionOf(next);
@@ -15049,11 +15165,18 @@ var App = class {
15049
15165
  this.wheel += delta;
15050
15166
  this.renderer.requestRender();
15051
15167
  }
15168
+ onPanWheel(delta) {
15169
+ this.sideways += delta;
15170
+ this.renderer.requestRender();
15171
+ }
15052
15172
  applyWheel() {
15053
- const delta = this.wheel;
15054
- if (delta === 0) return;
15173
+ const down = this.wheel;
15174
+ const across = this.sideways;
15175
+ if (down === 0 && across === 0) return;
15055
15176
  this.wheel = 0;
15056
- this.commit(scrolled(this.measured(), delta));
15177
+ this.sideways = 0;
15178
+ const moved = down === 0 ? this.measured() : scrolled(this.measured(), down);
15179
+ this.commit(across === 0 ? moved : panBy(moved, across));
15057
15180
  }
15058
15181
  syncGeometry() {
15059
15182
  const rows = this.screen.viewportRows();
@@ -15073,6 +15196,7 @@ var App = class {
15073
15196
  const appeared = next.notice.length > 0 && next.notice !== this.state.notice;
15074
15197
  this.state = next;
15075
15198
  this.rememberPlace(next);
15199
+ this.rememberWrap(next);
15076
15200
  this.screen.update(next);
15077
15201
  if (appeared) this.fade();
15078
15202
  }
@@ -15382,6 +15506,7 @@ const launch = fn("Tui.launch")(function* (repo, renderer, noticeMs, sessionPath
15382
15506
  const context$2 = yield* context();
15383
15507
  const branches = yield* listBranches(repo);
15384
15508
  const resume = sessionPath === void 0 ? void 0 : yield* promise(() => readSession(sessionPath));
15509
+ const settings = yield* (yield* Store).settings();
15385
15510
  return new App({
15386
15511
  renderer,
15387
15512
  repo,
@@ -15389,7 +15514,8 @@ const launch = fn("Tui.launch")(function* (repo, renderer, noticeMs, sessionPath
15389
15514
  branches,
15390
15515
  noticeMs,
15391
15516
  sessionPath,
15392
- resume
15517
+ resume,
15518
+ wrap: settings.wrap === true
15393
15519
  });
15394
15520
  });
15395
15521
  const untilDestroyed = (renderer) => callback((resume) => {
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "bin": {
22
22
  "adiff": "./bin/adiff.js"
23
23
  },
24
- "version": "0.1.0-alpha.14",
24
+ "version": "0.1.0-alpha.15",
25
25
  "description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
26
26
  "license": "MIT",
27
27
  "repository": {