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

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 +16 -0
  2. package/dist/main.js +167 -24
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.16
4
+
5
+ ### Patch Changes
6
+
7
+ - r reads the worktree list again, and notices reach the home screen.
8
+
9
+ ## 0.1.0-alpha.15
10
+
11
+ ### Patch Changes
12
+
13
+ - Pan the diff sideways to read past the right edge.
14
+
15
+ - The footer keeps the way out visible on a narrow terminal.
16
+
17
+ - Wrapping keeps every character and is remembered between sessions.
18
+
3
19
  ## 0.1.0-alpha.14
4
20
 
5
21
  ### 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,12 +12939,24 @@ 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",
12908
12957
  category: "Review",
12909
12958
  keys: ["r"],
12910
- screens: ["review"],
12959
+ screens: ["branches", "review"],
12911
12960
  hint: "reload"
12912
12961
  }),
12913
12962
  command({
@@ -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);
@@ -14619,7 +14722,7 @@ var Screen = class {
14619
14722
  const pane = homeWidth(this.renderer.width);
14620
14723
  const room = Math.max(HOME_PATH_MIN, pane - many.length - HOME_PATH_CHROME);
14621
14724
  this.landing.content = `${elide(shortPath(this.repo), room)} · ${many}`;
14622
- this.landingKeys.content = this.chipRow();
14725
+ this.landingKeys.content = this.homeKeys(state);
14623
14726
  this.diffPane.visible = state.screen !== "branches" && !(state.screen === "palette" && state.returnTo === "branches");
14624
14727
  if (this.diffPane.visible) this.paintDiff(state);
14625
14728
  this.paintPane(state);
@@ -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();
@@ -14809,6 +14913,11 @@ var Screen = class {
14809
14913
  this.landingKeys.content = this.chipRow();
14810
14914
  if (this.shown !== void 0) this.footer.content = this.footerText(this.shown);
14811
14915
  }
14916
+ homeKeys(state) {
14917
+ const chips = this.chipRow().chunks;
14918
+ if (state.notice.length === 0) return new StyledText(chips);
14919
+ return new StyledText([...chips, fg(palette.attention)(` ${state.notice}`)]);
14920
+ }
14812
14921
  chipRow() {
14813
14922
  return new StyledText(this.chips.flatMap((chip, index) => {
14814
14923
  const lit = index === this.hovered;
@@ -14979,21 +15088,28 @@ var App = class {
14979
15088
  noticeMs;
14980
15089
  sessionPath;
14981
15090
  remembered = "";
15091
+ wrapKept = false;
14982
15092
  keys = [];
14983
15093
  fading;
14984
15094
  wheel = 0;
15095
+ sideways = 0;
14985
15096
  constructor(options) {
14986
15097
  this.renderer = options.renderer;
14987
15098
  this.repo = options.repo;
14988
15099
  this.run = options.run;
14989
15100
  this.noticeMs = options.noticeMs ?? 2200;
14990
15101
  this.sessionPath = options.sessionPath;
15102
+ this.wrapKept = options.wrap === true;
14991
15103
  const { branches, renderer } = options;
14992
- this.state = initialState(branches);
15104
+ this.state = {
15105
+ ...initialState(branches),
15106
+ wrap: options.wrap === true
15107
+ };
14993
15108
  this.screen = new Screen(renderer, options.repo);
14994
15109
  this.screen.update(this.state);
14995
15110
  this.screen.listen({
14996
15111
  onScroll: (delta) => this.onWheel(delta),
15112
+ onPan: (delta) => this.onPanWheel(delta),
14997
15113
  onDrag: (from, to) => this.commit(draggedTo(this.measured(), from, to)),
14998
15114
  onChip: (key) => this.dispatchTask(() => this.onKey(asKey(key)))
14999
15115
  });
@@ -15025,6 +15141,11 @@ var App = class {
15025
15141
  });
15026
15142
  await this.loadSource();
15027
15143
  }
15144
+ rememberWrap(next) {
15145
+ if (next.wrap === this.wrapKept) return;
15146
+ this.wrapKept = next.wrap;
15147
+ this.run(saveWrap(next.wrap)).catch(() => void 0);
15148
+ }
15028
15149
  rememberPlace(next) {
15029
15150
  if (this.sessionPath === void 0 || next.screen !== "review") return;
15030
15151
  const session = sessionOf(next);
@@ -15049,11 +15170,18 @@ var App = class {
15049
15170
  this.wheel += delta;
15050
15171
  this.renderer.requestRender();
15051
15172
  }
15173
+ onPanWheel(delta) {
15174
+ this.sideways += delta;
15175
+ this.renderer.requestRender();
15176
+ }
15052
15177
  applyWheel() {
15053
- const delta = this.wheel;
15054
- if (delta === 0) return;
15178
+ const down = this.wheel;
15179
+ const across = this.sideways;
15180
+ if (down === 0 && across === 0) return;
15055
15181
  this.wheel = 0;
15056
- this.commit(scrolled(this.measured(), delta));
15182
+ this.sideways = 0;
15183
+ const moved = down === 0 ? this.measured() : scrolled(this.measured(), down);
15184
+ this.commit(across === 0 ? moved : panBy(moved, across));
15057
15185
  }
15058
15186
  syncGeometry() {
15059
15187
  const rows = this.screen.viewportRows();
@@ -15073,6 +15201,7 @@ var App = class {
15073
15201
  const appeared = next.notice.length > 0 && next.notice !== this.state.notice;
15074
15202
  this.state = next;
15075
15203
  this.rememberPlace(next);
15204
+ this.rememberWrap(next);
15076
15205
  this.screen.update(next);
15077
15206
  if (appeared) this.fade();
15078
15207
  }
@@ -15107,7 +15236,7 @@ var App = class {
15107
15236
  "rail.toggle": () => this.commitSynced("rail.toggle"),
15108
15237
  "file.vouch": () => this.vouch(false),
15109
15238
  "file.vouch.next": () => this.vouch(true),
15110
- "review.reload": () => this.reloadBranch(),
15239
+ "review.reload": () => this.state.screen === "branches" ? this.reloadList() : this.reloadBranch(),
15111
15240
  "pending.open": () => this.openPending(),
15112
15241
  "pending.edit": () => this.editStagedComment(),
15113
15242
  "pending.drop": () => this.dropStagedComment(),
@@ -15175,6 +15304,18 @@ var App = class {
15175
15304
  this.commit(await this.readBranch(branch.branch));
15176
15305
  await this.loadSource();
15177
15306
  }
15307
+ async reloadList() {
15308
+ const here = selectedBranch(this.state)?.branch;
15309
+ const branches = await this.run(listBranches(this.repo));
15310
+ const read = withBranches(this.state, branches);
15311
+ const at = branches.findIndex((candidate) => candidate.branch === here);
15312
+ const kept = at === -1 ? read : {
15313
+ ...read,
15314
+ branchIndex: at
15315
+ };
15316
+ this.commit(withNoticeHere(kept, "read the list again"));
15317
+ this.dispatchTask(() => this.loadPulls());
15318
+ }
15178
15319
  async reloadBranch() {
15179
15320
  const branch = selectedBranch(this.state);
15180
15321
  if (branch === void 0) return;
@@ -15382,6 +15523,7 @@ const launch = fn("Tui.launch")(function* (repo, renderer, noticeMs, sessionPath
15382
15523
  const context$2 = yield* context();
15383
15524
  const branches = yield* listBranches(repo);
15384
15525
  const resume = sessionPath === void 0 ? void 0 : yield* promise(() => readSession(sessionPath));
15526
+ const settings = yield* (yield* Store).settings();
15385
15527
  return new App({
15386
15528
  renderer,
15387
15529
  repo,
@@ -15389,7 +15531,8 @@ const launch = fn("Tui.launch")(function* (repo, renderer, noticeMs, sessionPath
15389
15531
  branches,
15390
15532
  noticeMs,
15391
15533
  sessionPath,
15392
- resume
15534
+ resume,
15535
+ wrap: settings.wrap === true
15393
15536
  });
15394
15537
  });
15395
15538
  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.16",
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": {