@eliya-oss/agent-diff 0.1.0-alpha.73 → 0.1.0-alpha.75

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 +234 -134
  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.75
4
+
5
+ ### Patch Changes
6
+
7
+ - The suite runs in three parts at once, so a change reaches a release in about half the time it took.
8
+
9
+ - Cmd and option in the compose box now do what they do everywhere else: cmd moves to the ends of a line or the draft, option moves by word, and a key held with a modifier is never typed. Letting go of shift after growing a selection opens the comment on it.
10
+
11
+ - The box a comment is written in is opentui's textarea now, rather than one written here: the caret is the terminal's own, and undo, selection, and word and line movement come with it. Cmd and option keys the box does not carry by default are added to it.
12
+
13
+ ## 0.1.0-alpha.74
14
+
15
+ ### Patch Changes
16
+
17
+ - The box a comment is written in behaves like one: the caret is the cell it stands on rather than a character shifting the words, and the arrows move a line at a time through the wrap. `shift` with an arrow grows the selection to comment on.
18
+
3
19
  ## 0.1.0-alpha.73
4
20
 
5
21
  ### Patch Changes
package/dist/main.js CHANGED
@@ -5,9 +5,9 @@ import { text } from "node:stream/consumers";
5
5
  import { dirname, join, resolve } from "node:path";
6
6
  import { execFile, spawn } from "node:child_process";
7
7
  import { promisify } from "node:util";
8
- import { appendFileSync, existsSync, mkdirSync, readFileSync, realpathSync, watch } from "node:fs";
8
+ import { existsSync, mkdirSync, readFileSync, realpathSync, watch } from "node:fs";
9
9
  import { fileURLToPath } from "node:url";
10
- import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, LineNumberRenderable, RGBA, StyledText, SyntaxStyle, TextRenderable, bg, createCliRenderer, decodePasteBytes, fg, getTreeSitterClient, pathToFiletype, stripAnsiSequences, t } from "@opentui/core";
10
+ import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, LineNumberRenderable, RGBA, StyledText, SyntaxStyle, TextRenderable, TextareaRenderable, bg, createCliRenderer, decodePasteBytes, defaultTextareaKeyBindings, fg, getTreeSitterClient, pathToFiletype, stripAnsiSequences, t } from "@opentui/core";
11
11
  //#region \0rolldown/runtime.js
12
12
  var __defProp = Object.defineProperty;
13
13
  var __esmMin = (fn, res, err) => () => {
@@ -9661,7 +9661,7 @@ var init_pane = __esmMin((() => {
9661
9661
  init_commands();
9662
9662
  init_init();
9663
9663
  init_pane();
9664
- var version$1 = "0.1.0-alpha.73";
9664
+ var version$1 = "0.1.0-alpha.75";
9665
9665
  //#endregion
9666
9666
  //#region src/cli/upgrade.ts
9667
9667
  var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, ROUTES, asRoute, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, runUpgrade, statusOf$1, sayFound, sayDone, attempted, REFRESH_MS, refreshSkills, updatedIn, sayRefreshed, upgradeReport;
@@ -11394,7 +11394,7 @@ var init_tree = __esmMin((() => {
11394
11394
  return node.children.reduce((total, child) => total + filesUnder(tree, child), 0);
11395
11395
  };
11396
11396
  crowdedDirectories = (tree, limit) => tree.nodes.filter((node) => node.kind === "directory" && directFiles(tree, node.id) > limit).map((node) => node.path);
11397
- })), nothingReviewed, initialState, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, caretAt, drafted, WORD, wordLeft, wordRight, caretByWord, lineStart, lineEnd, caretToEdge, composeTarget, pickedText, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelIndexOf, panelEntry, threadChosen, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
11397
+ })), nothingReviewed, initialState, TREE_MAX, TREE_MIN, TREE_SHARE, DIFF_MIN, DIFF_ROOMY, bodyRoom, treeWidth, reviewWidth, panelFits, panelShown, onLayers, selectedLayer, proseFor, layerFiles, layerHolding, layerOpen, chunked, packed, shortened, wordWrapped, wrapped, NO_NOTE, noteRows$1, proseRow, proseRows$1, titleRows, clipEnd, FILE_LEAD, fileRows, layerRows, railWindow, selectedBranch, selectedPatch, pullHere, knownToHaveNoPull, kept, treeOf, reviewedCountIn, treeRows, crowdedOf, foldersOfFile, isReviewed, treeStart, treeWindow, commentsOn, hiddenLines, markedRows, carriesLine, selectedRows, snippetOf, selectedLineCount, lineOf, brokenAt, laidLine, laidDraft, caretRow, caretColumn, caretOn, caretAt, COMPOSE_BOX, COMPOSE_MARGIN, COMPOSE_PAD, COMPOSE_LEAST, composeBox, composeRoom$1, composeTarget, pickedText, selectedLines, KEYWORDS, NAME, longestName$1, searchTerm, matchHere, selectionReadout, WHOLE_FILE, CONTEXT_STEPS, wholeFileOff, contextToggled, layerContext, newLineAt, sourceLineAt, rowAtSourceLine, rowShowing, lineOnSide, commentRowsIn, threadsAtRow, stopsAtRow, threadAtStop, threadAtRow, openCommentRows, filesWithComments, answerCount, answersIn, newerOf, sectionOf, sentEntry, panelEntries, panelIndexOf, panelEntry, threadChosen, spokenSince, hunkStarts, changeAround, nextUnreviewed, reviewedCount, fileOrder, layerFile, selectionRange;
11398
11398
  var init_model = __esmMin((() => {
11399
11399
  init_dist();
11400
11400
  init_patch();
@@ -11652,31 +11652,55 @@ var init_model = __esmMin((() => {
11652
11652
  onNone: () => "-",
11653
11653
  onSome: (line) => String(line)
11654
11654
  });
11655
- caretAt = (state) => Math.max(0, Math.min(state.draft.length, state.caret));
11656
- drafted = (state) => {
11657
- const at = caretAt(state);
11658
- return `${state.draft.slice(0, at)}▌${state.draft.slice(at)}`;
11655
+ brokenAt = (text, room) => {
11656
+ const space = text.lastIndexOf(" ", room);
11657
+ return space > 0 ? space + 1 : room;
11659
11658
  };
11660
- WORD = /[\p{L}\p{N}_]/u;
11661
- wordLeft = (draft, from) => {
11662
- let at = from;
11663
- while (at > 0 && !WORD.test(draft[at - 1] ?? "")) at -= 1;
11664
- while (at > 0 && WORD.test(draft[at - 1] ?? "")) at -= 1;
11665
- return at;
11659
+ laidLine = (line, from, room) => {
11660
+ const rows = [];
11661
+ let at = 0;
11662
+ while (line.length - at > room) {
11663
+ const width = brokenAt(line.slice(at), room);
11664
+ rows.push({
11665
+ text: line.slice(at, at + width),
11666
+ from: from + at
11667
+ });
11668
+ at += width;
11669
+ }
11670
+ rows.push({
11671
+ text: line.slice(at),
11672
+ from: from + at
11673
+ });
11674
+ return rows;
11666
11675
  };
11667
- wordRight = (draft, from) => {
11668
- let at = from;
11669
- while (at < draft.length && !WORD.test(draft[at] ?? "")) at += 1;
11670
- while (at < draft.length && WORD.test(draft[at] ?? "")) at += 1;
11671
- return at;
11676
+ laidDraft = (draft, room) => {
11677
+ const width = Math.max(1, room);
11678
+ const rows = [];
11679
+ let from = 0;
11680
+ for (const line of draft.split("\n")) {
11681
+ rows.push(...laidLine(line, from, width));
11682
+ from += line.length + 1;
11683
+ }
11684
+ return rows;
11672
11685
  };
11673
- caretByWord = (state, delta) => delta < 0 ? wordLeft(state.draft, caretAt(state)) : wordRight(state.draft, caretAt(state));
11674
- lineStart = (draft, at) => draft.lastIndexOf("\n", at - 1) + 1;
11675
- lineEnd = (draft, at) => {
11676
- const found = draft.indexOf("\n", at);
11677
- return found === -1 ? draft.length : found;
11686
+ caretRow = (rows, caret) => {
11687
+ const at = rows.findIndex((row) => caret >= row.from && caret <= row.from + row.text.length);
11688
+ return at === -1 ? Math.max(0, rows.length - 1) : at;
11678
11689
  };
11679
- caretToEdge = (state, edge) => edge === "start" ? lineStart(state.draft, caretAt(state)) : lineEnd(state.draft, caretAt(state));
11690
+ caretColumn = (rows, caret) => caret - (rows[caretRow(rows, caret)]?.from ?? 0);
11691
+ caretOn = (rows, row, column) => {
11692
+ const held = rows[Math.max(0, Math.min(rows.length - 1, row))];
11693
+ if (held === void 0) return 0;
11694
+ const last = held.text.endsWith(" ") ? held.text.length - 1 : held.text.length;
11695
+ return held.from + Math.min(column, Math.max(0, last));
11696
+ };
11697
+ caretAt = (state) => Math.max(0, Math.min(state.draft.length, state.caret));
11698
+ COMPOSE_BOX = 72;
11699
+ COMPOSE_MARGIN = 4;
11700
+ COMPOSE_PAD = 5;
11701
+ COMPOSE_LEAST = 8;
11702
+ composeBox = (columns) => Math.max(0, Math.min(COMPOSE_BOX, columns - COMPOSE_MARGIN));
11703
+ composeRoom$1 = (columns) => Math.max(COMPOSE_LEAST, composeBox(columns) - COMPOSE_PAD);
11680
11704
  composeTarget = (state) => {
11681
11705
  const patch = selectedPatch(state);
11682
11706
  if (patch === void 0) return "";
@@ -12214,6 +12238,24 @@ var init_command = __esmMin((() => {
12214
12238
  keys: ["G"],
12215
12239
  screens: ["branches"]
12216
12240
  }),
12241
+ command({
12242
+ action: "select.grow",
12243
+ panes: ["diff"],
12244
+ title: "Take the line below into the selection",
12245
+ category: "Selecting",
12246
+ keys: ["shift+down"],
12247
+ screens: ["review"],
12248
+ listed: false
12249
+ }),
12250
+ command({
12251
+ action: "select.shrink",
12252
+ panes: ["diff"],
12253
+ title: "Take the line above into the selection",
12254
+ category: "Selecting",
12255
+ keys: ["shift+up"],
12256
+ screens: ["review"],
12257
+ listed: false
12258
+ }),
12217
12259
  command({
12218
12260
  action: "select.hunk",
12219
12261
  category: "Selecting",
@@ -12617,7 +12659,7 @@ var init_match = __esmMin((() => {
12617
12659
  }));
12618
12660
  //#endregion
12619
12661
  //#region src/tui/reduce.ts
12620
- var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, panBy, withSent, withArrived, withColumns, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, inserted, asksAQuery, typed, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, pasted, backspaced, cutBackTo, wordBackspaced, lineBackspaced, deleted, caretMoved, caretJumped, caretHomed, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
12662
+ var clamp, lastRow, rowsIn, withCursorVisible, moveCursor, stepStop, scrolled, draggedTo, pickedIn, atRow, noneLeft, layerHunk, nextFileWithComments, atComment, nothingOpen, layerComment, PAN_STEP, panned, moveLayer, inRail, railScrolled, movePanel, layerDown, PANES, panesShown, focusStepped, togglePanel, packedAway, zoom, toggleRail, foldDirectory, foldLayer, foldThread, fold, moveBranch, moveFile, selectHunk, swapEnds, atBranch, grownBy, startSelection, openCompose, goBack, walkMatches, openPalette, openKeys, movePalette, paletteMatches, keyMatches, offered, paletteChoice, transitions, reduce, atFile, withContext, withFull, revealsAfter, gapOpened, panBy, withSent, withArrived, withColumns, withLayers, withPulls, withSilentForge, withBranches, withSource, withVouched, restoredTo, openedAt, withPatches, inserted, asksAQuery, typed, TAB_WIDTH, SPACE_CODE, ERASED_FROM, ERASED_TO, readable, legible, pasted, backspaced, withDraft, paletteMoved, paletteClosed, withWaiting, withMatches, withNoticeHere, withNotice;
12621
12663
  var init_reduce = __esmMin((() => {
12622
12664
  init_dist();
12623
12665
  init_patch();
@@ -12892,6 +12934,18 @@ var init_reduce = __esmMin((() => {
12892
12934
  ...state,
12893
12935
  branchIndex: clamp(at, 0, Math.max(0, state.branches.length - 1))
12894
12936
  });
12937
+ grownBy = (state, delta) => {
12938
+ const held = state.selecting ? state : {
12939
+ ...state,
12940
+ selecting: true,
12941
+ anchorRow: state.cursor
12942
+ };
12943
+ return withCursorVisible({
12944
+ ...held,
12945
+ stop: 0,
12946
+ cursor: clamp(held.cursor + delta, 0, lastRow(selectedPatch(state)))
12947
+ });
12948
+ };
12895
12949
  startSelection = (state) => ({
12896
12950
  ...state,
12897
12951
  selecting: true,
@@ -12998,6 +13052,8 @@ var init_reduce = __esmMin((() => {
12998
13052
  "file.next": (state) => moveFile(state, 1),
12999
13053
  "file.prev": (state) => moveFile(state, -1),
13000
13054
  "select.start": startSelection,
13055
+ "select.grow": (state) => grownBy(state, 1),
13056
+ "select.shrink": (state) => grownBy(state, -1),
13001
13057
  "select.hunk": selectHunk,
13002
13058
  "select.swap": swapEnds,
13003
13059
  "compose.open": openCompose,
@@ -13274,37 +13330,10 @@ var init_reduce = __esmMin((() => {
13274
13330
  caret: at - 1
13275
13331
  };
13276
13332
  };
13277
- cutBackTo = (state, to) => {
13278
- const at = caretAt(state);
13279
- if (to >= at) return state;
13280
- return {
13281
- ...state,
13282
- draft: `${state.draft.slice(0, to)}${state.draft.slice(at)}`,
13283
- caret: to
13284
- };
13285
- };
13286
- wordBackspaced = (state) => asksAQuery(state) ? backspaced(state) : cutBackTo(state, caretByWord(state, -1));
13287
- lineBackspaced = (state) => asksAQuery(state) ? backspaced(state) : cutBackTo(state, caretToEdge(state, "start"));
13288
- deleted = (state) => {
13289
- const at = caretAt(state);
13290
- if (at >= state.draft.length) return state;
13291
- return {
13292
- ...state,
13293
- draft: `${state.draft.slice(0, at)}${state.draft.slice(at + 1)}`,
13294
- caret: at
13295
- };
13296
- };
13297
- caretMoved = (state, delta) => ({
13298
- ...state,
13299
- caret: clamp(caretAt(state) + delta, 0, state.draft.length)
13300
- });
13301
- caretJumped = (state, delta) => ({
13333
+ withDraft = (state, draft) => ({
13302
13334
  ...state,
13303
- caret: caretByWord(state, delta)
13304
- });
13305
- caretHomed = (state, edge) => ({
13306
- ...state,
13307
- caret: caretToEdge(state, edge)
13335
+ draft,
13336
+ caret: draft.length
13308
13337
  });
13309
13338
  paletteMoved = (state, delta) => movePalette(state, delta);
13310
13339
  paletteClosed = (state) => ({
@@ -14129,7 +14158,7 @@ var init_diffview = __esmMin((() => {
14129
14158
  }));
14130
14159
  //#endregion
14131
14160
  //#region src/tui/render.ts
14132
- var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, COMPOSE_PAD, COMPOSE_MIN_TEXT, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, panelMark, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
14161
+ var ROW_HEIGHT, COMPOSE_WIDTH, GUTTER_X, CHIP_GAP, FRAME_PAD, MODAL_ROOM, COMPOSE_CHROME, COMPOSE_ACTION_ROWS, reportActions, actionsText, SNIPPET_LINES, PALETTE_KEY, PALETTE_TITLE, PALETTE_GAP, PALETTE_CHROME, PENDING_CHROME, PALETTE_WIDTH, PANEL_SHARE, PANEL_MAX, PANEL_FLOOR, PANEL_FOOT, PANEL_QUARTER, PANEL_FIFTH, PANE_CHROME, PANE_EDGES, PANE_INSET, BRANCH_WIDTH, BRANCH_NAME_MIN, BRANCH_TAIL, EMPTY_LIST, MODAL_MARGIN, shareOf, homeWidth, longestName, commandRow, modalWidth, panelWidth, panelTop, panelRows, composeRoom, laidOut$1, STICKY_MAX, pickPaint, SELECTION, CURSOR, ACCENT, GAP_PAINT, bar, makeList, makeDiffPane, makePanel, makeListParts, makeListText, makeGutter, makeScroller, makeScrim, makeScroll, makePalette, makePaletteParts, makeChoices, LIST_LEAD, windowed, listText, stack, makeBody, makeHome, makeModals, makeKeysParts, makeFoundParts, FONTS, logoFont, makeLanding, makeLogo, MAC_KEYS, makeComposeParts, makeCompose, clip, clipHead, clipMiddle, clipPath, treeLabel, waitingLabel, inRange, notesOf, notesFor, paired, keptWithin, CHIP_CHUNKS, shortPath, HOME_PATH_MIN, HOME_PATH_CHROME, elide, contextLabel, nameRoom, columns, FORGE_SILENT, unaskedForge, branchHeading, atHome, layersCell, baseLabel, stateCell, branchCells, headerParts, HEADER_GAP, HEADER_PATH_MIN, headerRoom, headerFitted, fallbackScope, treeMarks, treeTail, treeLine, STEP_NUMBER, STEP_LEAD, NOTE_LEAD, STEP_GAP, STALE_ROOM, STALE_LONG, STALE_SHORT, staleBanner, layerRoom, layerFold, layerHead, layerText, layerPaint, PANEL_TITLES, PANEL_ORDER, PANEL_LEAD, PANEL_EMPTY, panelMark, panelWhere, panelBody, panelPair, panelSection, PULL_HINT, panelText, Screen;
14133
14162
  var init_render = __esmMin((() => {
14134
14163
  init_command();
14135
14164
  init_patch();
@@ -14147,8 +14176,6 @@ var init_render = __esmMin((() => {
14147
14176
  MODAL_ROOM = 8;
14148
14177
  COMPOSE_CHROME = 3;
14149
14178
  COMPOSE_ACTION_ROWS = 2;
14150
- COMPOSE_PAD = 5;
14151
- COMPOSE_MIN_TEXT = 8;
14152
14179
  reportActions = (full) => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^t")} ${fg(palette.muted)(full ? "sending everything" : "sending the least")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("copy and save")}`;
14153
14180
  actionsText = () => t`${fg(palette.accent)("esc")} ${fg(palette.muted)("cancel")} ${fg(palette.accent)("^s")} ${fg(palette.muted)("send it")}`;
14154
14181
  SNIPPET_LINES = 4;
@@ -14184,13 +14211,10 @@ var init_render = __esmMin((() => {
14184
14211
  panelWidth = (width) => modalWidth(width, shareOf(width, PALETTE_WIDTH));
14185
14212
  panelTop = (height, part) => Math.max(2, Math.floor(height / part));
14186
14213
  panelRows = (height, part) => Math.max(PANEL_FLOOR, height - panelTop(height, part) - PANEL_FOOT);
14187
- composeRoom = (width) => {
14188
- const box = modalWidth(width, COMPOSE_WIDTH);
14189
- return {
14190
- box,
14191
- text: Math.max(COMPOSE_MIN_TEXT, box - COMPOSE_PAD)
14192
- };
14193
- };
14214
+ composeRoom = (width) => ({
14215
+ box: composeBox(width),
14216
+ text: composeRoom$1(width)
14217
+ });
14194
14218
  laidOut$1 = (lines, room) => lines.flatMap((line) => {
14195
14219
  const parts = wrapped(line, room);
14196
14220
  return parts.length === 0 ? [""] : parts;
@@ -14446,6 +14470,50 @@ var init_render = __esmMin((() => {
14446
14470
  marginBottom: 2,
14447
14471
  flexShrink: 0
14448
14472
  });
14473
+ MAC_KEYS = [
14474
+ {
14475
+ name: "left",
14476
+ super: true,
14477
+ action: "line-home"
14478
+ },
14479
+ {
14480
+ name: "right",
14481
+ super: true,
14482
+ action: "line-end"
14483
+ },
14484
+ {
14485
+ name: "left",
14486
+ super: true,
14487
+ shift: true,
14488
+ action: "select-line-home"
14489
+ },
14490
+ {
14491
+ name: "right",
14492
+ super: true,
14493
+ shift: true,
14494
+ action: "select-line-end"
14495
+ },
14496
+ {
14497
+ name: "up",
14498
+ super: true,
14499
+ action: "buffer-home"
14500
+ },
14501
+ {
14502
+ name: "down",
14503
+ super: true,
14504
+ action: "buffer-end"
14505
+ },
14506
+ {
14507
+ name: "backspace",
14508
+ super: true,
14509
+ action: "delete-to-line-start"
14510
+ },
14511
+ {
14512
+ name: "backspace",
14513
+ meta: true,
14514
+ action: "delete-word-backward"
14515
+ }
14516
+ ];
14449
14517
  makeComposeParts = (renderer) => ({
14450
14518
  title: new TextRenderable(renderer, {
14451
14519
  id: "compose-title",
@@ -14453,12 +14521,23 @@ var init_render = __esmMin((() => {
14453
14521
  fg: palette.ink,
14454
14522
  wrapMode: "none"
14455
14523
  }),
14456
- body: new TextRenderable(renderer, {
14457
- id: "compose-body",
14524
+ quoted: new TextRenderable(renderer, {
14525
+ id: "compose-quoted",
14458
14526
  content: "",
14459
- fg: palette.ink,
14527
+ fg: palette.muted,
14460
14528
  wrapMode: "none"
14461
14529
  }),
14530
+ body: new TextareaRenderable(renderer, {
14531
+ id: "compose-body",
14532
+ wrapMode: "word",
14533
+ keyBindings: [...defaultTextareaKeyBindings, ...MAC_KEYS],
14534
+ backgroundColor: palette.panel,
14535
+ focusedBackgroundColor: palette.panel,
14536
+ textColor: palette.ink,
14537
+ focusedTextColor: palette.ink,
14538
+ cursorColor: palette.ink,
14539
+ placeholder: ""
14540
+ }),
14462
14541
  actions: new TextRenderable(renderer, {
14463
14542
  id: "compose-actions",
14464
14543
  content: "",
@@ -14761,6 +14840,7 @@ var init_render = __esmMin((() => {
14761
14840
  shown;
14762
14841
  chips = [];
14763
14842
  composeTitle;
14843
+ composeQuoted;
14764
14844
  composeBody;
14765
14845
  composeActions;
14766
14846
  footer;
@@ -14807,6 +14887,7 @@ var init_render = __esmMin((() => {
14807
14887
  const inside = makeComposeParts(renderer);
14808
14888
  this.compose = makeCompose(renderer);
14809
14889
  this.composeTitle = inside.title;
14890
+ this.composeQuoted = inside.quoted;
14810
14891
  this.composeBody = inside.body;
14811
14892
  this.composeActions = inside.actions;
14812
14893
  this.scrim = makeScrim(renderer);
@@ -14890,6 +14971,9 @@ var init_render = __esmMin((() => {
14890
14971
  tallestRows() {
14891
14972
  return this.view.tallestRows();
14892
14973
  }
14974
+ writing() {
14975
+ return this.composeBody;
14976
+ }
14893
14977
  railRows() {
14894
14978
  return this.listRoom();
14895
14979
  }
@@ -15082,6 +15166,7 @@ var init_render = __esmMin((() => {
15082
15166
  this.body.add(this.panelPane);
15083
15167
  stack(this.compose, [
15084
15168
  this.composeTitle,
15169
+ this.composeQuoted,
15085
15170
  this.composeBody,
15086
15171
  this.composeActions
15087
15172
  ]);
@@ -15239,15 +15324,14 @@ var init_render = __esmMin((() => {
15239
15324
  this.compose.visible = state.screen === "compose" || state.screen === "report";
15240
15325
  if (state.screen !== "report") return;
15241
15326
  const room = composeRoom(this.renderer.width);
15242
- const lines = laidOut$1([
15243
- state.reportFull ? "What went wrong? Everything on screen is attached for you." : "What went wrong? Only what you type is sent.",
15244
- "",
15245
- drafted(state)
15246
- ], room.text);
15327
+ const asked = state.reportFull ? "What went wrong? Everything on screen is attached for you." : "What went wrong? Only what you type is sent.";
15328
+ const lead = laidOut$1([asked], room.text);
15247
15329
  this.composeTitle.content = "Report a bug";
15248
- this.composeBody.content = lines.join("\n");
15330
+ this.composeQuoted.content = lead.join("\n");
15331
+ this.composeQuoted.height = lead.length;
15332
+ const written = this.fitBody(state, room.text);
15249
15333
  this.composeActions.content = reportActions(state.reportFull);
15250
- this.compose.height = lines.length + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
15334
+ this.compose.height = lead.length + written + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
15251
15335
  this.compose.width = room.box;
15252
15336
  this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room.box) / 2));
15253
15337
  this.compose.top = Math.max(2, Math.floor(this.renderer.height / 4));
@@ -15288,27 +15372,26 @@ var init_render = __esmMin((() => {
15288
15372
  });
15289
15373
  };
15290
15374
  }
15375
+ fitBody(state, room) {
15376
+ if (this.composeBody.width !== room) this.composeBody.width = room;
15377
+ const rows = Math.max(1, laidDraft(state.draft, room).length);
15378
+ if (this.composeBody.height !== rows) this.composeBody.height = rows;
15379
+ return rows;
15380
+ }
15291
15381
  paintCompose(state) {
15292
15382
  this.compose.visible = state.screen === "compose";
15293
- if (state.screen !== "compose") {
15294
- this.composeBody.content = "";
15295
- return;
15296
- }
15383
+ if (state.screen !== "compose") return;
15297
15384
  const room = composeRoom(this.renderer.width);
15298
15385
  const snippet = snippetOf(state, SNIPPET_LINES);
15299
15386
  const more = selectedLineCount(state) - snippet.length;
15300
15387
  const tail = more > 0 ? [` … ${more} more lines`] : [];
15301
15388
  const quoted = [...snippet, ...tail].map((line) => clip(line, room.text));
15302
- const written = laidOut$1(drafted(state).split("\n"), room.text);
15303
- const lines = [
15304
- ...quoted,
15305
- "",
15306
- ...written
15307
- ];
15308
15389
  this.composeTitle.content = clip(composeTarget(state), room.text);
15309
- this.composeBody.content = lines.join("\n");
15390
+ this.composeQuoted.content = [...quoted, ""].join("\n");
15391
+ this.composeQuoted.height = quoted.length + 1;
15392
+ const written = this.fitBody(state, room.text);
15310
15393
  this.composeActions.content = actionsText();
15311
- const height = lines.length + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
15394
+ const height = quoted.length + 1 + written + COMPOSE_ACTION_ROWS + COMPOSE_CHROME;
15312
15395
  this.compose.height = height;
15313
15396
  this.compose.width = room.box;
15314
15397
  this.compose.left = Math.max(FRAME_PAD, Math.floor((this.renderer.width - room.box) / 2));
@@ -15341,6 +15424,13 @@ var init_display = __esmMin((() => {
15341
15424
  room: sync(() => screen.noteRoom()),
15342
15425
  tallest: sync(() => screen.tallestRows()),
15343
15426
  rail: sync(() => screen.railRows()),
15427
+ onWritten: (told) => sync(() => {
15428
+ screen.writing().onContentChange = () => told(screen.writing().plainText);
15429
+ }),
15430
+ written: sync(() => screen.writing().plainText),
15431
+ write: (text) => sync(() => screen.writing().setText(text)),
15432
+ writeIn: (text) => sync(() => screen.writing().insertText(text)),
15433
+ writeOn: (on) => sync(() => on ? screen.writing().focus() : screen.writing().blur()),
15344
15434
  at: sync(() => screen.scrolledAt()),
15345
15435
  rowAt: (visual) => sync(() => screen.rowAtScreen(visual)),
15346
15436
  screenRowOf: (row) => sync(() => screen.screenRowOf(row)),
@@ -15426,7 +15516,7 @@ var init_upgrade = __esmMin((() => {
15426
15516
  return due ? `adiff ${latest} is out · adiff upgrade` : "";
15427
15517
  }).pipe(withSpan("Tui.upgradeHint"));
15428
15518
  upgradeHint = worded.pipe(orElseSucceed(() => ""));
15429
- })), PRINTABLE, KEY_HISTORY, TRAIL_HISTORY, clockOf, momentOf, noticeOf, handOver, copyToClipboard, lineUnder, asKey, openedPull, byWord, WORD_STEP, caretSideways, caretFor, erasedBy, LISTENS, listens, laidOut, keyName, App, turnedOver, settledPath, openingOn, launch, told, untilDestroyed, runOn, runTui;
15519
+ })), PRINTABLE, KEY_HISTORY, TRAIL_HISTORY, clockOf, momentOf, noticeOf, handOver, copyToClipboard, lineUnder, asKey, openedPull, LISTENS, WRITES, writesInto, listens, laidOut, ARROWS, keyName, App, turnedOver, settledPath, openingOn, launch, told, untilDestroyed, runOn, runTui;
15430
15520
  var init_app = __esmMin((() => {
15431
15521
  init_dist();
15432
15522
  init_report();
@@ -15491,34 +15581,19 @@ var init_app = __esmMin((() => {
15491
15581
  if (!opened) return "could not reach the pull request";
15492
15582
  return state.length === 0 ? "opened the pull request" : `opened the ${state} pull request`;
15493
15583
  };
15494
- byWord = (key) => key.option || key.meta || key.ctrl;
15495
- WORD_STEP = {
15496
- b: -1,
15497
- f: 1
15498
- };
15499
- caretSideways = (state, key) => {
15500
- const step = key.name === "left" ? -1 : key.name === "right" ? 1 : 0;
15501
- if (step === 0) return void 0;
15502
- return byWord(key) ? caretJumped(state, step) : caretMoved(state, step);
15503
- };
15504
- caretFor = (state, key) => {
15505
- const sideways = caretSideways(state, key);
15506
- if (sideways !== void 0) return sideways;
15507
- const word = byWord(key) ? WORD_STEP[key.name] : void 0;
15508
- if (word !== void 0) return caretJumped(state, word);
15509
- if (key.name === "home") return caretHomed(state, "start");
15510
- if (key.name === "end") return caretHomed(state, "end");
15511
- return key.name === "delete" ? deleted(state) : void 0;
15512
- };
15513
- erasedBy = (state, key) => {
15514
- if (key.meta || key.ctrl) return lineBackspaced(state);
15515
- return key.option ? wordBackspaced(state) : backspaced(state);
15516
- };
15517
15584
  LISTENS = /* @__PURE__ */ new Set(["keys", "palette"]);
15585
+ WRITES = /* @__PURE__ */ new Set(["compose", "report"]);
15586
+ writesInto = (screen) => WRITES.has(screen);
15518
15587
  listens = (screen) => LISTENS.has(screen);
15519
15588
  laidOut = (key) => key.baseCode === void 0 || key.name.length !== 1 ? key.name : String.fromCodePoint(key.baseCode);
15589
+ ARROWS = /* @__PURE__ */ new Set([
15590
+ "up",
15591
+ "down",
15592
+ "left",
15593
+ "right"
15594
+ ]);
15520
15595
  keyName = (key) => {
15521
- if (key.shift && key.name === "tab") return "shift+tab";
15596
+ if (key.shift && (key.name === "tab" || ARROWS.has(key.name))) return `shift+${key.name}`;
15522
15597
  const named = laidOut(key);
15523
15598
  const base = key.shift && named.length === 1 ? named.toUpperCase() : named;
15524
15599
  return key.ctrl ? `ctrl+${base}` : base;
@@ -15538,6 +15613,7 @@ var init_app = __esmMin((() => {
15538
15613
  remembered = "";
15539
15614
  wrapKept = false;
15540
15615
  stickyKept = true;
15616
+ grewWithShift = false;
15541
15617
  keys = [];
15542
15618
  trail = [];
15543
15619
  began = Date.now();
@@ -15566,7 +15642,9 @@ var init_app = __esmMin((() => {
15566
15642
  onRail: (delta) => this.dispatchTask(this.rolled(delta))
15567
15643
  }));
15568
15644
  renderer.on("selection", () => this.copyDragged());
15645
+ runSync(options.display.onWritten((text) => this.readBack(text)));
15569
15646
  renderer.keyInput.on("keypress", (key) => this.dispatch(key));
15647
+ renderer.keyInput.on("keyrelease", (key) => this.letGo(key));
15570
15648
  renderer.keyInput.on("paste", (event) => this.dispatchPaste(event));
15571
15649
  renderer.on("destroy", () => this.stopWatching());
15572
15650
  renderer.on("destroy", () => this.stopFading());
@@ -15661,13 +15739,23 @@ var init_app = __esmMin((() => {
15661
15739
  runFork(writeSession(this.sessionPath, session));
15662
15740
  }
15663
15741
  dispatch(key) {
15742
+ if (key.eventType === "release") {
15743
+ this.letGo(key);
15744
+ return;
15745
+ }
15664
15746
  if (this.renderer.hasSelection) this.renderer.clearSelection();
15665
15747
  offerUnsafe(this.intents, Intent.Key({ key }));
15666
15748
  }
15749
+ letGo(key) {
15750
+ if (!key.name.endsWith("shift") || !this.grewWithShift) return;
15751
+ this.grewWithShift = false;
15752
+ offerUnsafe(this.intents, Intent.Key({ key: asKey("c") }));
15753
+ }
15667
15754
  dispatchPaste(event) {
15668
15755
  offerUnsafe(this.intents, Intent.Paste({ text: decodePasteBytes(event.bytes) }));
15669
15756
  }
15670
15757
  onPaste(text) {
15758
+ if (writesInto(this.state.screen)) return;
15671
15759
  if (!takesText(this.state.screen)) return;
15672
15760
  this.commit(pasted(this.state, text));
15673
15761
  }
@@ -15770,6 +15858,7 @@ var init_app = __esmMin((() => {
15770
15858
  }
15771
15859
  commit(given) {
15772
15860
  const next = given.patchIndex === this.state.patchIndex ? given : turnedOver(given);
15861
+ this.turnWriting(next);
15773
15862
  const appeared = next.notice.length > 0 && next.notice !== this.state.notice;
15774
15863
  if (appeared) this.recordNotice(next.notice);
15775
15864
  this.rememberPlace(next);
@@ -15874,6 +15963,7 @@ var init_app = __esmMin((() => {
15874
15963
  onKey(key, forced) {
15875
15964
  return gen({ self: this }, function* () {
15876
15965
  const action = forced ?? actionFor(this.state.screen, keyName(key), this.state.focus);
15966
+ this.grewWithShift = action === "select.grow" || action === "select.shrink";
15877
15967
  this.remember(action, key);
15878
15968
  if (action === void 0) {
15879
15969
  this.onText(key);
@@ -15887,29 +15977,37 @@ var init_app = __esmMin((() => {
15887
15977
  yield* effect();
15888
15978
  });
15889
15979
  }
15980
+ typedIn(key) {
15981
+ if (key.ctrl || key.option || key.meta || key.super === true) return false;
15982
+ return PRINTABLE.test(key.sequence);
15983
+ }
15890
15984
  onText(key) {
15891
- if (!takesText(this.state.screen)) return;
15985
+ if (!listens(this.state.screen)) return;
15892
15986
  if (key.name === "backspace") {
15893
- this.commit(erasedBy(this.state, key));
15987
+ this.commit(backspaced(this.state));
15894
15988
  return;
15895
15989
  }
15896
- if (key.name === "down") {
15897
- this.commit(paletteMoved(this.state, 1));
15990
+ if (key.name === "down" || key.name === "up") {
15991
+ this.commit(paletteMoved(this.state, key.name === "down" ? 1 : -1));
15898
15992
  return;
15899
15993
  }
15900
- if (key.name === "up") {
15901
- this.commit(paletteMoved(this.state, -1));
15994
+ if (this.typedIn(key)) this.commit(typed(this.state, key.sequence));
15995
+ }
15996
+ turnWriting(next) {
15997
+ const was = writesInto(this.state.screen);
15998
+ const now = writesInto(next.screen);
15999
+ if (was === now) return;
16000
+ if (now) runSync(this.display.write(next.draft));
16001
+ runSync(this.display.writeOn(now));
16002
+ }
16003
+ readBack(text) {
16004
+ const clean = legible(stripAnsiSequences(text));
16005
+ if (clean !== text) {
16006
+ runSync(this.display.write(clean));
15902
16007
  return;
15903
16008
  }
15904
- if (this.onCaret(key)) return;
15905
- if (PRINTABLE.test(key.sequence)) this.commit(typed(this.state, key.sequence));
15906
- }
15907
- onCaret(key) {
15908
- if (this.state.screen === "palette" || this.state.screen === "keys") return false;
15909
- const moved = caretFor(this.state, key);
15910
- if (moved === void 0) return false;
15911
- this.commit(moved);
15912
- return true;
16009
+ if (text === this.state.draft) return;
16010
+ this.commit(withDraft(this.state, text));
15913
16011
  }
15914
16012
  runChoice() {
15915
16013
  return gen({ self: this }, function* () {
@@ -15953,11 +16051,6 @@ var init_app = __esmMin((() => {
15953
16051
  }
15954
16052
  copyDragged() {
15955
16053
  const taken = this.renderer.getSelection()?.getSelectedText() ?? "";
15956
- const where = process.env["ADIFF_TRACE"];
15957
- if (where !== void 0) {
15958
- const holder = this.renderer.getSelectionContainer()?.id ?? "none";
15959
- appendFileSync(where, `${this.state.screen} in=${holder} ${JSON.stringify(taken).slice(0, 70)}\n`);
15960
- }
15961
16054
  if (taken.trim().length === 0) return;
15962
16055
  copyToClipboard(taken);
15963
16056
  const lines = taken.split("\n").length;
@@ -16448,7 +16541,10 @@ var init_app = __esmMin((() => {
16448
16541
  yield* untilDestroyed(renderer);
16449
16542
  });
16450
16543
  runTui = fn("Tui.run")(function* (repo, sessionPath, branch) {
16451
- const renderer = yield* promise(() => createCliRenderer({ exitOnCtrlC: true }));
16544
+ const renderer = yield* promise(() => createCliRenderer({
16545
+ exitOnCtrlC: true,
16546
+ useKittyKeyboard: { events: true }
16547
+ }));
16452
16548
  yield* runOn(repo, renderer, sessionPath, branch);
16453
16549
  });
16454
16550
  }));
@@ -16458,10 +16554,14 @@ var tui_exports = /* @__PURE__ */ __exportAll({
16458
16554
  App: () => App,
16459
16555
  Screen: () => Screen,
16460
16556
  actionFor: () => actionFor,
16557
+ caretColumn: () => caretColumn,
16558
+ caretOn: () => caretOn,
16559
+ caretRow: () => caretRow,
16461
16560
  commands: () => commands,
16462
16561
  commandsFor: () => commandsFor,
16463
16562
  hintsFor: () => hintsFor,
16464
16563
  initialState: () => initialState,
16564
+ laidDraft: () => laidDraft,
16465
16565
  launch: () => launch,
16466
16566
  listableFor: () => listableFor,
16467
16567
  palette: () => palette,
package/package.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "bin": {
24
24
  "adiff": "./bin/adiff.js"
25
25
  },
26
- "version": "0.1.0-alpha.73",
26
+ "version": "0.1.0-alpha.75",
27
27
  "description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
28
28
  "license": "MIT",
29
29
  "repository": {