@eliya-oss/agent-diff 0.1.0-alpha.5 → 0.1.0-alpha.7

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/main.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { randomUUID } from "node:crypto";
2
2
  import { appendFile, mkdir, readFile, realpath, writeFile } from "node:fs/promises";
3
3
  import { text } from "node:stream/consumers";
4
- import { join } from "node:path";
4
+ import { dirname, join } from "node:path";
5
5
  import { execFile } from "node:child_process";
6
6
  import { promisify } from "node:util";
7
7
  import { homedir, hostname, platform } from "node:os";
8
+ import { existsSync, readFileSync } from "node:fs";
9
+ import { fileURLToPath } from "node:url";
8
10
  import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, LineNumberRenderable, RGBA, SelectRenderable, StyledText, SyntaxStyle, TextRenderable, bg, createCliRenderer, fg, getTreeSitterClient, pathToFiletype, t } from "@opentui/core";
9
11
  //#region node_modules/.pnpm/effect@4.0.0-beta.102/node_modules/effect/dist/Pipeable.js
10
12
  /**
@@ -10803,7 +10805,7 @@ const defaultRoot = () => join(homedir(), ".adiff");
10803
10805
  const branchDir = (root, worktreePath) => join(root, "branches", slugOf(worktreePath));
10804
10806
  const inboxPath = (root, worktreePath) => join(branchDir(root, worktreePath), "inbox.jsonl");
10805
10807
  const statePath = (root, worktreePath) => join(branchDir(root, worktreePath), "state.json");
10806
- const storyPath = (root, worktreePath) => join(branchDir(root, worktreePath), "story.json");
10808
+ const layersPath = (root, worktreePath) => join(branchDir(root, worktreePath), "layers.json");
10807
10809
  const reportsDir = (root) => join(root, "reports");
10808
10810
  const reportPath = (root, stamp) => join(reportsDir(root), `${stamp}.md`);
10809
10811
  //#endregion
@@ -10856,14 +10858,14 @@ const cursorOps = (state, saveState, inbox) => {
10856
10858
  })
10857
10859
  };
10858
10860
  };
10859
- const storyOps = (root) => {
10861
+ const layersOps = (root) => {
10860
10862
  return {
10861
- story: fn("Store.story")(function* (worktreePath) {
10862
- const raw = yield* readOptional(storyPath(root, worktreePath));
10863
+ layers: fn("Store.layers")(function* (worktreePath) {
10864
+ const raw = yield* readOptional(layersPath(root, worktreePath));
10863
10865
  return map$4(raw, (text) => JSON.parse(text));
10864
10866
  }),
10865
- saveStory: fn("Store.saveStory")(function* (worktreePath, next) {
10866
- const path = storyPath(root, worktreePath);
10867
+ saveLayers: fn("Store.saveLayers")(function* (worktreePath, next) {
10868
+ const path = layersPath(root, worktreePath);
10867
10869
  yield* ensureDir(branchDir(root, worktreePath));
10868
10870
  yield* tryPromise({
10869
10871
  try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
@@ -10932,7 +10934,7 @@ const makeStore = (root) => {
10932
10934
  state,
10933
10935
  saveState,
10934
10936
  saveReport,
10935
- ...storyOps(root),
10937
+ ...layersOps(root),
10936
10938
  ...cursors
10937
10939
  };
10938
10940
  };
@@ -10947,8 +10949,8 @@ var UnknownCommand = class extends TaggedError("UnknownCommand") {};
10947
10949
  var MissingOption = class extends TaggedError("MissingOption") {};
10948
10950
  var EmptyReview = class extends TaggedError("EmptyReview") {};
10949
10951
  var UnknownWorktree = class extends TaggedError("UnknownWorktree") {};
10950
- var MalformedStory = class extends TaggedError("MalformedStory") {};
10951
- var NoStory = class extends TaggedError("NoStory") {};
10952
+ var MalformedLayers = class extends TaggedError("MalformedLayers") {};
10953
+ var NoLayers = class extends TaggedError("NoLayers") {};
10952
10954
  //#endregion
10953
10955
  //#region src/cli/commands.ts
10954
10956
  const CONTEXT = 3;
@@ -10976,17 +10978,17 @@ const waitingOn = fn("Cli.waitingOn")(function* (worktree) {
10976
10978
  const store = yield* Store;
10977
10979
  const state = yield* store.state(worktree.path);
10978
10980
  const batches = yield* store.inbox(worktree.path);
10979
- const told = yield* store.story(worktree.path);
10981
+ const told = yield* store.layers(worktree.path);
10980
10982
  return {
10981
10983
  staged: state.pending.length,
10982
10984
  unread: Math.max(0, batches.length - state.consumed),
10983
- steps: match$2(told, {
10985
+ layers: match$2(told, {
10984
10986
  onNone: () => 0,
10985
- onSome: (story) => story.steps.length
10987
+ onSome: (layers) => layers.layers.length
10986
10988
  }),
10987
10989
  stale: match$2(told, {
10988
10990
  onNone: () => false,
10989
- onSome: (story) => story.head !== worktree.head
10991
+ onSome: (layers) => layers.head !== worktree.head
10990
10992
  })
10991
10993
  };
10992
10994
  });
@@ -11006,7 +11008,7 @@ const listBranches = fn("Cli.listBranches")(function* (repo) {
11006
11008
  removed: stat.removed,
11007
11009
  staged: waiting.staged,
11008
11010
  unread: waiting.unread,
11009
- steps: waiting.steps,
11011
+ layers: waiting.layers,
11010
11012
  stale: waiting.stale
11011
11013
  });
11012
11014
  }
@@ -11202,19 +11204,19 @@ const fileSource = fn("Cli.fileSource")(function* (repo, branch, file) {
11202
11204
  return getOrElse(found, () => []);
11203
11205
  });
11204
11206
  //#endregion
11205
- //#region src/domain/narrative/model.ts
11206
- const REMAINDER_TITLE = "not in any step";
11207
+ //#region src/domain/layers/model.ts
11208
+ const REMAINDER_TITLE = "not in any layer";
11207
11209
  //#endregion
11208
- //#region src/domain/narrative/coverage.ts
11210
+ //#region src/domain/layers/coverage.ts
11209
11211
  const codeBlockOf$1 = (span) => ({
11210
11212
  kind: "code",
11211
11213
  path: span.path,
11212
11214
  start: span.start,
11213
11215
  end: span.end
11214
11216
  });
11215
- const codeBlocks = (step) => step.blocks.filter((block) => block.kind === "code");
11216
- const noteOf = (step) => step.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
11217
- const spansOf$1 = (steps) => steps.flatMap((step) => codeBlocks(step).map(({ path, start, end }) => ({
11217
+ const codeBlocks = (layer) => layer.blocks.filter((block) => block.kind === "code");
11218
+ const noteOf = (layer) => layer.blocks.filter((block) => block.kind === "prose").map((block) => block.markdown.trim()).filter((markdown) => markdown.length > 0).join(" ");
11219
+ const spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({ path, start, end }) => ({
11218
11220
  path,
11219
11221
  start,
11220
11222
  end
@@ -11231,8 +11233,8 @@ const spanOfHunk = (patch, hunk) => {
11231
11233
  });
11232
11234
  };
11233
11235
  const overlaps = (a, b) => a.path === b.path && a.start <= b.end && a.end >= b.start;
11234
- const coverage = (patches, steps) => {
11235
- const claimed = spansOf$1(steps);
11236
+ const coverage = (patches, layers) => {
11237
+ const claimed = spansOf$1(layers);
11236
11238
  const hunks = patches.flatMap((patch) => patch.hunks.flatMap((hunk) => match$2(spanOfHunk(patch, hunk), {
11237
11239
  onNone: () => [],
11238
11240
  onSome: (s) => [s]
@@ -11244,9 +11246,9 @@ const coverage = (patches, steps) => {
11244
11246
  missing
11245
11247
  };
11246
11248
  };
11247
- const withFullCoverage = (patches, story) => {
11248
- const gap = coverage(patches, story.steps);
11249
- if (gap.missing.length === 0) return story;
11249
+ const withFullCoverage = (patches, layers) => {
11250
+ const gap = coverage(patches, layers.layers);
11251
+ if (gap.missing.length === 0) return layers;
11250
11252
  const remainder = {
11251
11253
  title: REMAINDER_TITLE,
11252
11254
  blocks: [{
@@ -11255,21 +11257,48 @@ const withFullCoverage = (patches, story) => {
11255
11257
  }, ...gap.missing.map((span) => codeBlockOf$1(span))]
11256
11258
  };
11257
11259
  return {
11258
- ...story,
11259
- steps: [...story.steps, remainder]
11260
+ ...layers,
11261
+ layers: [...layers.layers, remainder]
11260
11262
  };
11261
11263
  };
11264
+ const proseAnchors = (layer) => {
11265
+ const anchors = [];
11266
+ let pending = [];
11267
+ let last;
11268
+ for (const block of layer.blocks) {
11269
+ if (block.kind === "prose") {
11270
+ const markdown = block.markdown.trim();
11271
+ if (markdown.length > 0) pending.push(markdown);
11272
+ continue;
11273
+ }
11274
+ for (const markdown of pending) anchors.push({
11275
+ path: block.path,
11276
+ line: block.start,
11277
+ markdown,
11278
+ after: false
11279
+ });
11280
+ pending = [];
11281
+ last = block;
11282
+ }
11283
+ if (last === void 0) return anchors;
11284
+ return [...anchors, ...pending.map((markdown) => ({
11285
+ path: last.path,
11286
+ line: last.end,
11287
+ markdown,
11288
+ after: true
11289
+ }))];
11290
+ };
11262
11291
  //#endregion
11263
- //#region src/domain/narrative/version.ts
11264
- const statusOf = (patches, story, branchHead) => {
11265
- const gap = coverage(patches, story.steps);
11292
+ //#region src/domain/layers/version.ts
11293
+ const statusOf = (patches, layers, branchHead) => {
11294
+ const gap = coverage(patches, layers.layers);
11266
11295
  const present = new Set(patches.map((patch) => patch.path));
11267
- const mentioned = new Set(spansOf$1(story.steps).map((span) => span.path));
11296
+ const mentioned = new Set(spansOf$1(layers.layers).map((span) => span.path));
11268
11297
  return {
11269
- version: story.version,
11270
- parent: story.parent,
11271
- stale: story.head !== branchHead,
11272
- storyHead: story.head,
11298
+ version: layers.version,
11299
+ parent: layers.parent,
11300
+ stale: layers.head !== branchHead,
11301
+ layersHead: layers.head,
11273
11302
  branchHead,
11274
11303
  uncovered: gap.missing,
11275
11304
  vanished: [...mentioned].filter((path) => !present.has(path)),
@@ -11278,9 +11307,9 @@ const statusOf = (patches, story, branchHead) => {
11278
11307
  };
11279
11308
  };
11280
11309
  //#endregion
11281
- //#region src/cli/story.ts
11310
+ //#region src/cli/layers.ts
11282
11311
  const unique = (paths) => [...new Set(paths)];
11283
- const spansOfStep = (step) => codeBlocks(step).map(({ path, start, end }) => ({
11312
+ const spansOfLayer = (layer) => codeBlocks(layer).map(({ path, start, end }) => ({
11284
11313
  path,
11285
11314
  start,
11286
11315
  end
@@ -11300,20 +11329,20 @@ const codeBlockOf = (span) => ({
11300
11329
  start: span.start,
11301
11330
  end: span.end
11302
11331
  });
11303
- const blocksOf = (step) => {
11304
- if (Array.isArray(step.blocks)) return step.blocks.filter(isBlock);
11305
- const note = typeof step.note === "string" ? [{
11332
+ const blocksOf = (layer) => {
11333
+ if (Array.isArray(layer.blocks)) return layer.blocks.filter(isBlock);
11334
+ const note = typeof layer.note === "string" ? [{
11306
11335
  kind: "prose",
11307
- markdown: step.note
11336
+ markdown: layer.note
11308
11337
  }] : [];
11309
- const spans = Array.isArray(step.spans) ? step.spans.filter(isSpan) : [];
11338
+ const spans = Array.isArray(layer.spans) ? layer.spans.filter(isSpan) : [];
11310
11339
  return [...note, ...spans.map(codeBlockOf)];
11311
11340
  };
11312
- const stepOf = (value) => {
11313
- const step = value;
11314
- const title = typeof step?.title === "string" ? step.title.trim() : "";
11315
- if (step === void 0 || title.length === 0) return none();
11316
- const blocks = blocksOf(step);
11341
+ const layerOf = (value) => {
11342
+ const layer = value;
11343
+ const title = typeof layer?.title === "string" ? layer.title.trim() : "";
11344
+ if (layer === void 0 || title.length === 0) return none();
11345
+ const blocks = blocksOf(layer);
11317
11346
  return blocks.length === 0 ? none() : some({
11318
11347
  title,
11319
11348
  blocks
@@ -11327,55 +11356,56 @@ const parsed = (text) => {
11327
11356
  return none();
11328
11357
  }
11329
11358
  };
11330
- const readStory = fn("Cli.readStory")(function* (text) {
11359
+ const readLayers = fn("Cli.readLayers")(function* (text) {
11331
11360
  const document = yield* match$2(parsed(text), {
11332
- onNone: () => new MalformedStory({ reason: "the story is not a JSON object" }),
11361
+ onNone: () => new MalformedLayers({ reason: "the layers is not a JSON object" }),
11333
11362
  onSome: succeed
11334
11363
  });
11335
- const raw = document["steps"];
11336
- const steps = (Array.isArray(raw) ? raw : []).flatMap((entry) => match$2(stepOf(entry), {
11364
+ const raw = document["layers"];
11365
+ const layers = (Array.isArray(raw) ? raw : []).flatMap((entry) => match$2(layerOf(entry), {
11337
11366
  onNone: () => [],
11338
- onSome: (step) => [step]
11367
+ onSome: (layer) => [layer]
11339
11368
  }));
11340
- if (steps.length === 0) return yield* new MalformedStory({ reason: "every step needs a title and at least one span or block" });
11369
+ if (layers.length === 0) return yield* new MalformedLayers({ reason: "every layer needs a title and at least one span or block" });
11341
11370
  const summary = document["summary"];
11342
11371
  return {
11343
11372
  summary: typeof summary === "string" ? summary : "",
11344
- steps
11373
+ layers
11345
11374
  };
11346
11375
  });
11347
11376
  const fromStored = (stored) => ({
11348
11377
  ...stored,
11349
11378
  parent: fromNullishOr(stored.parent)
11350
11379
  });
11351
- const toStored = (story) => ({
11352
- ...story,
11353
- parent: getOrUndefined$1(story.parent)
11380
+ const toStored = (layers) => ({
11381
+ ...layers,
11382
+ parent: getOrUndefined$1(layers.parent)
11354
11383
  });
11355
- const stepsOf = (patches, story) => {
11384
+ const reportedLayers = (patches, layers) => {
11356
11385
  const present = new Set(patches.map((patch) => patch.path));
11357
- return withFullCoverage(patches, story).steps.map((step) => ({
11358
- title: step.title,
11359
- note: noteOf(step),
11360
- files: unique(spansOfStep(step).map((span) => span.path)).filter((path) => present.has(path)),
11361
- spans: spansOfStep(step)
11386
+ return withFullCoverage(patches, layers).layers.map((layer) => ({
11387
+ title: layer.title,
11388
+ note: noteOf(layer),
11389
+ files: unique(spansOfLayer(layer).map((span) => span.path)).filter((path) => present.has(path)),
11390
+ spans: spansOfLayer(layer),
11391
+ prose: proseAnchors(layer).filter((anchor) => present.has(anchor.path))
11362
11392
  }));
11363
11393
  };
11364
- const reportOf = (patches, story, branchHead) => {
11365
- const status = statusOf(patches, story, branchHead);
11394
+ const reportOf = (patches, layers, branchHead) => {
11395
+ const status = statusOf(patches, layers, branchHead);
11366
11396
  return {
11367
11397
  version: status.version,
11368
11398
  parent: getOrUndefined$1(status.parent),
11369
- head: status.storyHead,
11399
+ head: status.layersHead,
11370
11400
  branchHead: status.branchHead,
11371
11401
  stale: status.stale,
11372
- written: story.written,
11373
- summary: story.summary,
11402
+ written: layers.written,
11403
+ summary: layers.summary,
11374
11404
  covered: status.covered,
11375
11405
  total: status.total,
11376
11406
  uncovered: status.uncovered,
11377
11407
  vanished: status.vanished,
11378
- steps: stepsOf(patches, story)
11408
+ layers: reportedLayers(patches, layers)
11379
11409
  };
11380
11410
  };
11381
11411
  const resolve = (path) => realpath(path).catch(() => path);
@@ -11391,17 +11421,17 @@ const worktreeAt = fn("Cli.worktreeAt")(function* (worktreePath) {
11391
11421
  known: worktrees.map((entry) => entry.path)
11392
11422
  }) : succeed(found);
11393
11423
  });
11394
- const storyOf = fn("Cli.storyOf")(function* (worktree) {
11424
+ const storedLayers = fn("Cli.storedLayers")(function* (worktree) {
11395
11425
  const store = yield* Store;
11396
- return map$4(yield* store.story(worktree.path), fromStored);
11426
+ return map$4(yield* store.layers(worktree.path), fromStored);
11397
11427
  });
11398
- const setStory = fn("Cli.setStory")(function* (worktreePath, text, written) {
11428
+ const setLayers = fn("Cli.setLayers")(function* (worktreePath, text, written) {
11399
11429
  const store = yield* Store;
11400
11430
  const worktree = yield* worktreeAt(worktreePath);
11401
- const input = yield* readStory(text);
11431
+ const input = yield* readLayers(text);
11402
11432
  const patches = yield* patchesOf(worktree);
11403
- const previous = yield* storyOf(worktree);
11404
- const story = {
11433
+ const previous = yield* storedLayers(worktree);
11434
+ const layers = {
11405
11435
  version: match$2(previous, {
11406
11436
  onNone: () => 1,
11407
11437
  onSome: (old) => old.version + 1
@@ -11411,31 +11441,31 @@ const setStory = fn("Cli.setStory")(function* (worktreePath, text, written) {
11411
11441
  base: worktree.base,
11412
11442
  written,
11413
11443
  summary: input.summary,
11414
- steps: input.steps
11444
+ layers: input.layers
11415
11445
  };
11416
- yield* store.saveStory(worktree.path, toStored(story));
11417
- return reportOf(patches, story, worktree.head);
11446
+ yield* store.saveLayers(worktree.path, toStored(layers));
11447
+ return reportOf(patches, layers, worktree.head);
11418
11448
  });
11419
- const showStory = fn("Cli.showStory")(function* (worktreePath) {
11449
+ const showLayers = fn("Cli.showLayers")(function* (worktreePath) {
11420
11450
  const worktree = yield* worktreeAt(worktreePath);
11421
11451
  const patches = yield* patchesOf(worktree);
11422
- const found = yield* storyOf(worktree);
11423
- const story = yield* match$2(found, {
11424
- onNone: () => new NoStory({ worktree: worktree.path }),
11452
+ const found = yield* storedLayers(worktree);
11453
+ const layers = yield* match$2(found, {
11454
+ onNone: () => new NoLayers({ worktree: worktree.path }),
11425
11455
  onSome: succeed
11426
11456
  });
11427
- return reportOf(patches, story, worktree.head);
11457
+ return reportOf(patches, layers, worktree.head);
11428
11458
  });
11429
- const listStorySteps = fn("Cli.listStorySteps")(function* (repo, branch) {
11459
+ const listLayers = fn("Cli.listLayers")(function* (repo, branch) {
11430
11460
  const worktree = yield* findBranch(repo, branch);
11431
- const found = yield* storyOf(worktree);
11461
+ const found = yield* storedLayers(worktree);
11432
11462
  if (isNone(found)) return {
11433
- steps: [],
11463
+ layers: [],
11434
11464
  stale: false
11435
11465
  };
11436
11466
  const patches = yield* patchesOf(worktree);
11437
11467
  return {
11438
- steps: stepsOf(patches, found.value),
11468
+ layers: reportedLayers(patches, found.value),
11439
11469
  stale: found.value.head !== worktree.head
11440
11470
  };
11441
11471
  });
@@ -11611,26 +11641,26 @@ const catalog = [
11611
11641
  example: "adiff review progress --repo . --branch cdr-1"
11612
11642
  },
11613
11643
  {
11614
- name: "story set",
11615
- about: "Write the reading order for this worktree's diff: ordered steps over spans of files",
11644
+ name: "layers set",
11645
+ about: "Write the reading order for this worktree's diff: ordered layers over spans of files",
11616
11646
  safety: "write",
11617
11647
  options: [{
11618
11648
  name: "worktree",
11619
11649
  required: true,
11620
11650
  value: "path",
11621
- about: "The worktree the story is about"
11651
+ about: "The worktree the layers is about"
11622
11652
  }, {
11623
11653
  name: "json",
11624
11654
  required: true,
11625
11655
  value: "file|-",
11626
- about: "The story document, as a file path or - to read stdin"
11656
+ about: "The layers document, as a file path or - to read stdin"
11627
11657
  }],
11628
- dataKey: "story",
11629
- example: "adiff story set --worktree . --json -"
11658
+ dataKey: "layers",
11659
+ example: "adiff layers set --worktree . --json -"
11630
11660
  },
11631
11661
  {
11632
- name: "story show",
11633
- about: "The story of a worktree, with the hunks no step claims",
11662
+ name: "layers show",
11663
+ about: "The layers of a worktree, with the hunks no layer claims",
11634
11664
  safety: "read",
11635
11665
  options: [{
11636
11666
  name: "worktree",
@@ -11638,8 +11668,8 @@ const catalog = [
11638
11668
  value: "path",
11639
11669
  about: "The worktree to read"
11640
11670
  }],
11641
- dataKey: "story",
11642
- example: "adiff story show --worktree . --fields steps,uncovered"
11671
+ dataKey: "layers",
11672
+ example: "adiff layers show --worktree . --fields layers,uncovered"
11643
11673
  },
11644
11674
  {
11645
11675
  name: "review open",
@@ -11693,17 +11723,17 @@ const ADVICE = {
11693
11723
  },
11694
11724
  UnknownWorktree: {
11695
11725
  exit: 3,
11696
- suggestion: "Run `adiff story set` from inside a worktree of the repository under review.",
11726
+ suggestion: "Run `adiff layers set` from inside a worktree of the repository under review.",
11697
11727
  retriable: false
11698
11728
  },
11699
- MalformedStory: {
11729
+ MalformedLayers: {
11700
11730
  exit: 2,
11701
- suggestion: "A story is {\"summary\":\"…\",\"steps\":[{\"title\":\"…\",\"spans\":[{\"path\":\"…\",\"start\":1,\"end\":9}]}]}.",
11731
+ suggestion: "A layers is {\"summary\":\"…\",\"layers\":[{\"title\":\"…\",\"spans\":[{\"path\":\"…\",\"start\":1,\"end\":9}]}]}.",
11702
11732
  retriable: false
11703
11733
  },
11704
- NoStory: {
11734
+ NoLayers: {
11705
11735
  exit: 3,
11706
- suggestion: "No story has been written for this worktree. Write one with `adiff story set`.",
11736
+ suggestion: "No layers has been written for this worktree. Write one with `adiff layers set`.",
11707
11737
  retriable: false
11708
11738
  },
11709
11739
  UnselectableRange: {
@@ -11747,6 +11777,98 @@ const failure = (cause) => {
11747
11777
  };
11748
11778
  };
11749
11779
  //#endregion
11780
+ //#region src/cli/help.ts
11781
+ const NAME_ROOM = 18;
11782
+ const REACH = 5;
11783
+ const manifest = () => {
11784
+ const here = dirname(fileURLToPath(import.meta.url));
11785
+ return Array.from({ length: REACH }, (_, layer) => join(here, ...Array(layer).fill(".."))).map((at) => join(at, "package.json")).find((path) => existsSync(path));
11786
+ };
11787
+ const version = () => {
11788
+ const path = manifest();
11789
+ if (path === void 0) return "unknown";
11790
+ const raw = readFileSync(path, "utf8");
11791
+ return JSON.parse(raw).version ?? "unknown";
11792
+ };
11793
+ const line = (command) => ` ${command.name.padEnd(NAME_ROOM)}${command.about}`;
11794
+ const banner = () => [
11795
+ `adiff ${version()}`,
11796
+ "",
11797
+ "Review the work an agent did in a git worktree, and hand your comments back.",
11798
+ "",
11799
+ " adiff review open --repo . open the terminal on this repository",
11800
+ " adiff comment take --worktree . collect the comments left for you",
11801
+ "",
11802
+ "adiff --help lists every command. adiff describe answers the same as JSON."
11803
+ ].join("\n");
11804
+ const help = () => [
11805
+ "adiff, for reviewing an agent's work in a worktree",
11806
+ "",
11807
+ "Commands:",
11808
+ ...catalog.map(line),
11809
+ "",
11810
+ "Run `adiff help <command>` for its options."
11811
+ ].join("\n");
11812
+ const option = (spec) => ` --${spec.name.padEnd(16)}${spec.about}${spec.required ? " (required)" : ""}`;
11813
+ const helpFor = (name) => {
11814
+ const command = findCommand(name);
11815
+ if (command === void 0) return void 0;
11816
+ const options = command.options.length === 0 ? [] : [
11817
+ "",
11818
+ "Options:",
11819
+ ...command.options.map(option)
11820
+ ];
11821
+ return [
11822
+ `adiff ${command.name}`,
11823
+ "",
11824
+ command.about,
11825
+ ...options
11826
+ ].join("\n");
11827
+ };
11828
+ //#endregion
11829
+ //#region src/service/forge/service.ts
11830
+ var Forge = class extends Service()("Forge") {};
11831
+ const LIMIT = "200";
11832
+ const TIMEOUT_MS = 4e3;
11833
+ const stateOf = (row) => {
11834
+ if (row.isDraft === true && row.state === "OPEN") return "draft";
11835
+ if (row.state === "MERGED") return "merged";
11836
+ if (row.state === "CLOSED") return "closed";
11837
+ return "open";
11838
+ };
11839
+ const parse = (raw) => {
11840
+ const rows = JSON.parse(raw);
11841
+ if (!Array.isArray(rows)) return [];
11842
+ return rows.filter((row) => typeof row.headRefName === "string").map((row) => ({
11843
+ branch: String(row.headRefName),
11844
+ state: stateOf(row)
11845
+ }));
11846
+ };
11847
+ const ask = (repo) => new Promise((resolve) => {
11848
+ execFile("gh", [
11849
+ "pr",
11850
+ "list",
11851
+ "--state",
11852
+ "all",
11853
+ "--limit",
11854
+ LIMIT,
11855
+ "--json",
11856
+ "headRefName,state,isDraft"
11857
+ ], {
11858
+ cwd: repo,
11859
+ timeout: TIMEOUT_MS,
11860
+ encoding: "utf8"
11861
+ }, (error, stdout) => {
11862
+ if (error !== null) return resolve([]);
11863
+ try {
11864
+ resolve(parse(stdout));
11865
+ } catch {
11866
+ resolve([]);
11867
+ }
11868
+ });
11869
+ });
11870
+ const ForgeLive = succeed$1(Forge)({ pulls: (repo) => promise(() => ask(repo)) });
11871
+ //#endregion
11750
11872
  //#region src/tui/gaps.ts
11751
11873
  const sourceLength = (source) => source.at(-1)?.trim() === "" ? source.length - 1 : source.length;
11752
11874
  const markerText = (hidden) => `⋯ ${hidden} lines hidden · press l`;
@@ -11853,7 +11975,7 @@ const compose = (build) => {
11853
11975
  };
11854
11976
  };
11855
11977
  const cache = /* @__PURE__ */ new WeakMap();
11856
- const keyOf = (total, full, reveals) => [
11978
+ const keyOf$1 = (total, full, reveals) => [
11857
11979
  total,
11858
11980
  full === void 0 ? 0 : full.rows.length,
11859
11981
  reveals.map((entry) => `${entry.gap}-${entry.lines}`).join(",")
@@ -11864,7 +11986,7 @@ const shownOf = (state) => {
11864
11986
  const full = state.full.find((patch) => patch.path === base.path);
11865
11987
  const total = sourceLength(state.source);
11866
11988
  const reveals = state.revealed.filter((entry) => entry.file === base.path);
11867
- const key = keyOf(total, full, reveals);
11989
+ const key = keyOf$1(total, full, reveals);
11868
11990
  const known = cache.get(base);
11869
11991
  const found = known?.get(key);
11870
11992
  if (found !== void 0) return found;
@@ -11983,7 +12105,7 @@ const visit = (walk, id, depth) => {
11983
12105
  fileIndex: void 0,
11984
12106
  files: filesUnder(walk.tree, last.id)
11985
12107
  });
11986
- if (collapsed.some((step) => walk.closed.includes(step.path))) return;
12108
+ if (collapsed.some((layer) => walk.closed.includes(layer.path))) return;
11987
12109
  for (const child of last.children) visit(walk, child, depth + 1);
11988
12110
  };
11989
12111
  const flattenTree = (tree, closed) => {
@@ -12037,27 +12159,35 @@ const initialState = (branches) => ({
12037
12159
  revealed: [],
12038
12160
  focus: "diff",
12039
12161
  navOpen: true,
12040
- steps: [],
12041
- storyStale: false,
12042
- stepIndex: 0,
12043
- openSteps: [],
12162
+ layers: [],
12163
+ layersStale: false,
12164
+ pulls: {},
12165
+ layerIndex: 0,
12166
+ openLayers: [],
12044
12167
  rail: "tree"
12045
12168
  });
12046
- const onSteps = (state) => state.rail === "steps" && state.steps.length > 0;
12047
- const stepFiles = (state, stepIndex) => {
12048
- const step = state.steps[stepIndex];
12049
- if (step === void 0) return [];
12050
- return step.files.flatMap((path) => {
12169
+ const onLayers = (state) => state.rail === "layers" && state.layers.length > 0;
12170
+ const selectedLayer = (state) => state.layers[state.layerIndex];
12171
+ const proseFor = (state, path) => {
12172
+ if (!onLayers(state)) return [];
12173
+ const layer = selectedLayer(state);
12174
+ if (layer === void 0) return [];
12175
+ return layer.prose.filter((anchor) => anchor.path === path);
12176
+ };
12177
+ const layerFiles = (state, layerIndex) => {
12178
+ const layer = state.layers[layerIndex];
12179
+ if (layer === void 0) return [];
12180
+ return layer.files.flatMap((path) => {
12051
12181
  const at = state.patches.findIndex((patch) => patch.path === path);
12052
12182
  return at === -1 ? [] : [at];
12053
12183
  });
12054
12184
  };
12055
- const stepHolding = (state, fileIndex) => {
12185
+ const layerHolding = (state, fileIndex) => {
12056
12186
  const path = state.patches[fileIndex]?.path;
12057
- const at = state.steps.findIndex((step) => step.files.includes(path ?? ""));
12058
- return at === -1 ? state.stepIndex : at;
12187
+ const at = state.layers.findIndex((layer) => layer.files.includes(path ?? ""));
12188
+ return at === -1 ? state.layerIndex : at;
12059
12189
  };
12060
- const stepOpen = (state, stepIndex) => state.openSteps.includes(stepIndex);
12190
+ const layerOpen = (state, layerIndex) => state.openLayers.includes(layerIndex);
12061
12191
  const chunked = (word, room) => word.length <= room ? [word] : [word.slice(0, room), ...chunked(word.slice(room), room)];
12062
12192
  const packed = (lines, word, room) => {
12063
12193
  const last = lines.at(-1);
@@ -12069,29 +12199,50 @@ const wrapped = (text, room) => {
12069
12199
  return text.split(/\s+/).filter((word) => word.length > 0).flatMap((word) => chunked(word, width)).reduce((lines, word) => packed(lines, word, width), []);
12070
12200
  };
12071
12201
  const NO_NOTE = "no note";
12072
- const noteRows$1 = (state, stepIndex, room) => {
12073
- const lines = wrapped(state.steps[stepIndex]?.note ?? "", room);
12202
+ const noteRows$1 = (state, layerIndex, room) => {
12203
+ const lines = wrapped(state.layers[layerIndex]?.note ?? "", room);
12074
12204
  return (lines.length === 0 ? [NO_NOTE] : lines).map((text) => ({
12075
- index: stepIndex,
12205
+ index: layerIndex,
12076
12206
  kind: "note",
12077
12207
  text,
12078
12208
  lead: false
12079
12209
  }));
12080
12210
  };
12081
- const titleRows = (state, stepIndex, room) => wrapped(state.steps[stepIndex]?.title ?? "", room).map((text, at) => ({
12082
- index: stepIndex,
12211
+ const titleRows = (state, layerIndex, room) => wrapped(state.layers[layerIndex]?.title ?? "", room).map((text, at) => ({
12212
+ index: layerIndex,
12083
12213
  kind: "title",
12084
12214
  text,
12085
12215
  lead: at === 0
12086
12216
  }));
12087
- const stepRows = (state, titleRoom, noteRoom) => state.steps.flatMap((_, index) => stepOpen(state, index) ? [...titleRows(state, index, titleRoom), ...noteRows$1(state, index, noteRoom)] : titleRows(state, index, titleRoom));
12088
- const railWindow = (rows, height, stepIndex) => {
12217
+ const clipEnd = (text, room) => {
12218
+ if (text.length <= room) return text;
12219
+ const parts = text.split("/");
12220
+ const kept = [];
12221
+ for (const part of parts.toReversed()) {
12222
+ if ([part, ...kept].join("/").length + 2 > room) break;
12223
+ kept.unshift(part);
12224
+ }
12225
+ return `…/${kept.length === 0 ? parts.at(-1) ?? text : kept.join("/")}`;
12226
+ };
12227
+ const FILE_LEAD = 2;
12228
+ const fileRows = (state, layerIndex, room) => (state.layers[layerIndex]?.files ?? []).map((path) => ({
12229
+ index: layerIndex,
12230
+ kind: "file",
12231
+ text: clipEnd(path, Math.max(1, room - FILE_LEAD)),
12232
+ lead: false
12233
+ }));
12234
+ const layerRows = (state, titleRoom, noteRoom) => state.layers.flatMap((_, index) => layerOpen(state, index) ? [
12235
+ ...titleRows(state, index, titleRoom),
12236
+ ...noteRows$1(state, index, noteRoom),
12237
+ ...fileRows(state, index, noteRoom)
12238
+ ] : titleRows(state, index, titleRoom));
12239
+ const railWindow = (rows, height, layerIndex) => {
12089
12240
  if (rows.length <= height) return {
12090
12241
  rows,
12091
12242
  more: 0
12092
12243
  };
12093
- const first = Math.max(0, rows.findIndex((row) => row.index === stepIndex));
12094
- const block = rows.findLastIndex((row) => row.index === stepIndex) - first + 1;
12244
+ const first = Math.max(0, rows.findIndex((row) => row.index === layerIndex));
12245
+ const block = rows.findLastIndex((row) => row.index === layerIndex) - first + 1;
12095
12246
  const wanted = block >= height ? first : first - Math.floor((height - block) / 2);
12096
12247
  const start = Math.max(0, Math.min(rows.length - height, wanted));
12097
12248
  return {
@@ -12180,7 +12331,7 @@ const CONTEXT_STEPS = [
12180
12331
  60,
12181
12332
  WHOLE_FILE
12182
12333
  ];
12183
- const stepContext = (current, delta) => {
12334
+ const layerContext = (current, delta) => {
12184
12335
  const at = CONTEXT_STEPS.indexOf(current);
12185
12336
  const next = Math.max(0, Math.min(CONTEXT_STEPS.length - 1, (at === -1 ? 0 : at) + delta));
12186
12337
  return CONTEXT_STEPS[next] ?? current;
@@ -12221,8 +12372,8 @@ const nextUnreviewed = (state, from) => {
12221
12372
  return [...order.slice(start + 1), ...order.slice(0, start + 1)].find((index) => !isReviewed(state, index));
12222
12373
  };
12223
12374
  const reviewedCount = (state) => `${state.vouched.length}/${state.patches.length} reviewed`;
12224
- const fileOrder = (state) => onSteps(state) ? stepFiles(state, state.stepIndex) : treeRows(state).flatMap((row) => row.fileIndex === void 0 ? [] : [row.fileIndex]);
12225
- const stepFile = (state, delta) => {
12375
+ const fileOrder = (state) => onLayers(state) ? layerFiles(state, state.layerIndex) : treeRows(state).flatMap((row) => row.fileIndex === void 0 ? [] : [row.fileIndex]);
12376
+ const layerFile = (state, delta) => {
12226
12377
  const order = fileOrder(state);
12227
12378
  const position = order.indexOf(state.patchIndex);
12228
12379
  if (position === -1) return order[0] ?? state.patchIndex;
@@ -12293,6 +12444,7 @@ const command = (input) => ({
12293
12444
  hint: "",
12294
12445
  listed: true,
12295
12446
  whenStaged: false,
12447
+ whenLayers: false,
12296
12448
  ...input
12297
12449
  });
12298
12450
  const commands = [
@@ -12426,21 +12578,23 @@ const commands = [
12426
12578
  }),
12427
12579
  command({
12428
12580
  action: "rail.toggle",
12429
- title: "Switch between steps and files",
12581
+ title: "Switch between layers and files",
12430
12582
  category: "Files",
12431
12583
  keys: ["s"],
12432
- screens: ["review"]
12584
+ screens: ["review"],
12585
+ hint: "layers",
12586
+ whenLayers: true
12433
12587
  }),
12434
12588
  command({
12435
12589
  action: "tree.collapse",
12436
- title: "Close the folder, step, or gap",
12590
+ title: "Close the folder, layer, or gap",
12437
12591
  category: "Files",
12438
12592
  keys: ["h"],
12439
12593
  screens: ["review"]
12440
12594
  }),
12441
12595
  command({
12442
12596
  action: "tree.expand",
12443
- title: "Open the folder, step, or gap",
12597
+ title: "Open the folder, layer, or gap",
12444
12598
  category: "Files",
12445
12599
  keys: ["l"],
12446
12600
  screens: ["review"]
@@ -12611,7 +12765,7 @@ const displayKey = (key) => {
12611
12765
  if (key.startsWith("ctrl+")) return `^${key.slice(5)}`;
12612
12766
  return GLYPHS[key] ?? key;
12613
12767
  };
12614
- const hintsFor = (screen, staged) => commandsFor(screen).filter((entry) => entry.hint.length > 0).filter((entry) => !entry.whenStaged || staged > 0).map((entry) => ({
12768
+ const hintsFor = (screen, staged, layers = 0) => commandsFor(screen).filter((entry) => entry.hint.length > 0).filter((entry) => !entry.whenStaged || staged > 0).filter((entry) => !entry.whenLayers || layers > 0).map((entry) => ({
12615
12769
  key: displayKey(entry.keys[0] ?? ""),
12616
12770
  hint: entry.hint,
12617
12771
  press: entry.keys[0] ?? ""
@@ -12672,7 +12826,7 @@ const atRow = (state, row) => withCursorVisible({
12672
12826
  ...state,
12673
12827
  cursor: clamp(row, 0, lastRow(selectedPatch(state)))
12674
12828
  });
12675
- const stepHunk = (state, delta) => {
12829
+ const layerHunk = (state, delta) => {
12676
12830
  const starts = hunkStarts(state);
12677
12831
  const target = delta > 0 ? starts.find((start) => start > state.cursor) : starts.findLast((start) => start < state.cursor);
12678
12832
  return target === void 0 ? state : atRow(state, target);
@@ -12695,7 +12849,7 @@ const atComment = (state, file, delta) => {
12695
12849
  const landing = delta > 0 ? rows[0] : rows.at(-1);
12696
12850
  return landing === void 0 ? moved : atRow(moved, landing);
12697
12851
  };
12698
- const stepComment = (state, delta) => {
12852
+ const layerComment = (state, delta) => {
12699
12853
  const here = commentRowsIn(state, state.patchIndex);
12700
12854
  const target = delta > 0 ? here.find((row) => row > state.cursor) : here.findLast((row) => row < state.cursor);
12701
12855
  if (target !== void 0) return atRow(state, target);
@@ -12707,13 +12861,13 @@ const movePending = (state, delta) => ({
12707
12861
  ...state,
12708
12862
  pendingIndex: clamp(state.pendingIndex + delta, 0, Math.max(0, state.pending.length - 1))
12709
12863
  });
12710
- const moveStep = (state, delta) => {
12711
- const stepIndex = clamp(state.stepIndex + delta, 0, Math.max(0, state.steps.length - 1));
12864
+ const moveLayer = (state, delta) => {
12865
+ const layerIndex = clamp(state.layerIndex + delta, 0, Math.max(0, state.layers.length - 1));
12712
12866
  const landed = {
12713
12867
  ...state,
12714
- stepIndex
12868
+ layerIndex
12715
12869
  };
12716
- const patchIndex = stepFiles(landed, stepIndex)[0] ?? landed.patchIndex;
12870
+ const patchIndex = layerFiles(landed, layerIndex)[0] ?? landed.patchIndex;
12717
12871
  return {
12718
12872
  ...landed,
12719
12873
  patchIndex,
@@ -12723,18 +12877,18 @@ const moveStep = (state, delta) => {
12723
12877
  selecting: false
12724
12878
  };
12725
12879
  };
12726
- const inRail = (state, delta) => onSteps(state) ? moveStep(state, delta) : moveFile(state, delta);
12727
- const stepDown = (state, delta) => state.focus === "tree" ? inRail(state, delta) : moveCursor(state, delta);
12880
+ const inRail = (state, delta) => onLayers(state) ? moveLayer(state, delta) : moveFile(state, delta);
12881
+ const layerDown = (state, delta) => state.focus === "tree" ? inRail(state, delta) : moveCursor(state, delta);
12728
12882
  const toggleRail = (state) => {
12729
- if (state.steps.length === 0) return withNotice(state, "no story for this branch");
12730
- if (state.rail === "steps") return {
12883
+ if (state.layers.length === 0) return withNotice(state, "no layers for this branch");
12884
+ if (state.rail === "layers") return {
12731
12885
  ...state,
12732
12886
  rail: "tree"
12733
12887
  };
12734
12888
  return {
12735
12889
  ...state,
12736
- rail: "steps",
12737
- stepIndex: stepHolding(state, state.patchIndex)
12890
+ rail: "layers",
12891
+ layerIndex: layerHolding(state, state.patchIndex)
12738
12892
  };
12739
12893
  };
12740
12894
  const foldDirectory = (state, shut) => {
@@ -12746,21 +12900,21 @@ const foldDirectory = (state, shut) => {
12746
12900
  closed: shut ? [...closed, directory] : closed
12747
12901
  };
12748
12902
  };
12749
- const foldStep = (state, shut) => {
12750
- const open = state.openSteps.filter((index) => index !== state.stepIndex);
12903
+ const foldLayer = (state, shut) => {
12904
+ const open = state.openLayers.filter((index) => index !== state.layerIndex);
12751
12905
  return {
12752
12906
  ...state,
12753
- openSteps: shut ? open : [...open, state.stepIndex]
12907
+ openLayers: shut ? open : [...open, state.layerIndex]
12754
12908
  };
12755
12909
  };
12756
- const fold = (state, shut) => onSteps(state) ? foldStep(state, shut) : foldDirectory(state, shut);
12910
+ const fold = (state, shut) => onLayers(state) ? foldLayer(state, shut) : foldDirectory(state, shut);
12757
12911
  const moveBranch = (state, delta) => ({
12758
12912
  ...state,
12759
12913
  branchIndex: clamp(state.branchIndex + delta, 0, Math.max(0, state.branches.length - 1))
12760
12914
  });
12761
12915
  const moveFile = (state, delta) => ({
12762
12916
  ...state,
12763
- patchIndex: stepFile(state, delta),
12917
+ patchIndex: layerFile(state, delta),
12764
12918
  top: 0,
12765
12919
  cursor: 0,
12766
12920
  anchorRow: 0,
@@ -12825,18 +12979,18 @@ const transitions = {
12825
12979
  "branch.next": (state) => moveBranch(state, 1),
12826
12980
  "branch.prev": (state) => moveBranch(state, -1),
12827
12981
  "branch.open": (state) => state,
12828
- "cursor.next": (state) => stepDown(state, 1),
12982
+ "cursor.next": (state) => layerDown(state, 1),
12829
12983
  "cursor.top": (state) => atRow(state, 0),
12830
12984
  "cursor.bottom": (state) => atRow(state, lastRow(selectedPatch(state))),
12831
12985
  "cursor.pageDown": (state) => moveCursor(state, Math.max(1, Math.floor(state.viewport / 2))),
12832
12986
  "cursor.pageUp": (state) => moveCursor(state, -Math.max(1, Math.floor(state.viewport / 2))),
12833
12987
  "context.more": (state) => state,
12834
12988
  "context.less": (state) => state,
12835
- "comment.next": (state) => stepComment(state, 1),
12836
- "comment.prev": (state) => stepComment(state, -1),
12837
- "hunk.next": (state) => stepHunk(state, 1),
12838
- "hunk.prev": (state) => stepHunk(state, -1),
12839
- "cursor.prev": (state) => stepDown(state, -1),
12989
+ "comment.next": (state) => layerComment(state, 1),
12990
+ "comment.prev": (state) => layerComment(state, -1),
12991
+ "hunk.next": (state) => layerHunk(state, 1),
12992
+ "hunk.prev": (state) => layerHunk(state, -1),
12993
+ "cursor.prev": (state) => layerDown(state, -1),
12840
12994
  "file.next": (state) => moveFile(state, 1),
12841
12995
  "file.prev": (state) => moveFile(state, -1),
12842
12996
  "select.start": startSelection,
@@ -12935,24 +13089,28 @@ const withSent = (state, sent) => ({
12935
13089
  ...state,
12936
13090
  sent
12937
13091
  });
12938
- const withStory = (state, told) => {
12939
- const steps = told.steps;
13092
+ const withLayers = (state, told) => {
13093
+ const layers = told.layers;
12940
13094
  const opened = {
12941
13095
  ...state,
12942
- steps,
12943
- storyStale: told.stale,
12944
- stepIndex: 0,
12945
- openSteps: [],
12946
- rail: steps.length === 0 ? "tree" : "steps"
13096
+ layers,
13097
+ layersStale: told.stale,
13098
+ layerIndex: 0,
13099
+ openLayers: [],
13100
+ rail: layers.length === 0 ? "tree" : "layers"
12947
13101
  };
12948
- if (steps.length === 0) return opened;
13102
+ if (layers.length === 0) return opened;
12949
13103
  return {
12950
13104
  ...opened,
12951
- patchIndex: stepFiles(opened, 0)[0] ?? opened.patchIndex,
13105
+ patchIndex: layerFiles(opened, 0)[0] ?? opened.patchIndex,
12952
13106
  cursor: 0,
12953
13107
  top: 0
12954
13108
  };
12955
13109
  };
13110
+ const withPulls = (state, pulls) => ({
13111
+ ...state,
13112
+ pulls
13113
+ });
12956
13114
  const withBranches = (state, branches) => ({
12957
13115
  ...state,
12958
13116
  branches,
@@ -13160,6 +13318,7 @@ const syntaxTheme = {
13160
13318
  fg: "#9aa7c7",
13161
13319
  italic: true
13162
13320
  },
13321
+ prose: { fg: "#a9b4cc" },
13163
13322
  "note.sent": {
13164
13323
  fg: "#6d7893",
13165
13324
  italic: true
@@ -13276,8 +13435,10 @@ var DiffView = class {
13276
13435
  }
13277
13436
  listenTo(handlers) {
13278
13437
  this.numbers.onMouseScroll = (event) => {
13438
+ const way = event.scroll?.direction;
13439
+ if (way !== "up" && way !== "down") return;
13279
13440
  const size = Math.max(1, event.scroll?.delta ?? 1) * SCROLL_ROWS;
13280
- handlers.scroll(event.scroll?.direction === "up" ? -size : size);
13441
+ handlers.scroll(way === "up" ? -size : size);
13281
13442
  };
13282
13443
  this.numbers.onMouseDown = (event) => handlers.down(event.y);
13283
13444
  this.numbers.onMouseDrag = (event) => handlers.drag(event.y);
@@ -13304,20 +13465,25 @@ var DiffView = class {
13304
13465
  rows() {
13305
13466
  return this.fitted;
13306
13467
  }
13307
- show(patch, notes, gaps) {
13308
- const room = notes.length === 0 ? NOTE_MIN : this.noteRoom();
13309
- const key = [room, ...notes.map((note) => `${note.side}${note.line}:${note.body}`)].join("\0");
13468
+ show(patch, notes, gaps, prose = []) {
13469
+ const room = notes.length === 0 && prose.length === 0 ? NOTE_MIN : this.noteRoom();
13470
+ const key = keyOf(room, notes, prose);
13310
13471
  if (patch === this.shown && key === this.noted) return;
13311
13472
  this.pinnedText = "";
13312
13473
  this.shown = patch;
13313
13474
  this.noted = key;
13314
- this.display = layout(patch, notes, room, gaps);
13315
- this.starts = /* @__PURE__ */ new Map();
13316
- for (const [index, entry] of this.display.entries()) if (!entry.comment && !this.starts.has(entry.row)) this.starts.set(entry.row, index);
13475
+ this.display = layout({
13476
+ patch,
13477
+ notes,
13478
+ room,
13479
+ gaps,
13480
+ prose
13481
+ });
13482
+ this.starts = startsOf(this.display);
13317
13483
  this.code.filetype = pathToFiletype(patch.path) ?? "text";
13318
13484
  this.code.content = this.display.map((entry) => entry.text).join("\n");
13319
13485
  this.numbers.setLineNumbers(lineNumbers(patch, this.display));
13320
- this.numbers.setHideLineNumbers(new Set(this.display.flatMap((entry, index) => entry.comment || entry.gap ? [index] : [])));
13486
+ this.numbers.setHideLineNumbers(bareOf(this.display));
13321
13487
  this.numbers.setLineSigns(lineSigns(patch, this.display));
13322
13488
  this.numbers.setLineColors(/* @__PURE__ */ new Map());
13323
13489
  const spans = noteSpans(this.display);
@@ -13328,7 +13494,8 @@ var DiffView = class {
13328
13494
  return this.display[at]?.row ?? 0;
13329
13495
  }
13330
13496
  isComment(display) {
13331
- return this.display[display]?.comment === true;
13497
+ const entry = this.display[display];
13498
+ return entry?.comment === true || entry?.prose === true;
13332
13499
  }
13333
13500
  scrollTo(row, cursor) {
13334
13501
  const highest = Math.max(0, this.display.length - this.rows());
@@ -13345,7 +13512,7 @@ var DiffView = class {
13345
13512
  for (let index = Math.max(0, from - OVERSCAN); index < last; index++) {
13346
13513
  const entry = this.display[index];
13347
13514
  if (entry === void 0) continue;
13348
- const paint = entry.comment ? NOTE_PAINT : paintOf(entry.row);
13515
+ const paint = entry.comment || entry.prose ? NOTE_PAINT : paintOf(entry.row);
13349
13516
  if (paint !== void 0) colors.set(index, paint);
13350
13517
  }
13351
13518
  this.numbers.setLineColors(colors);
@@ -13354,7 +13521,19 @@ var DiffView = class {
13354
13521
  return WASH[kind];
13355
13522
  }
13356
13523
  };
13524
+ const startsOf = (display) => {
13525
+ const starts = /* @__PURE__ */ new Map();
13526
+ for (const [index, entry] of display.entries()) if (!entry.comment && !starts.has(entry.row)) starts.set(entry.row, index);
13527
+ return starts;
13528
+ };
13529
+ const bareOf = (display) => new Set(display.flatMap((entry, index) => entry.comment || entry.gap || entry.prose ? [index] : []));
13530
+ const keyOf = (room, notes, prose) => [
13531
+ room,
13532
+ ...notes.map((note) => `${note.side}${note.line}:${note.body}`),
13533
+ ...prose.map((entry) => `p${entry.line}${entry.after ? ">" : "<"}:${entry.markdown}`)
13534
+ ].join("\0");
13357
13535
  const groupOf = (entry) => {
13536
+ if (entry.prose) return "prose";
13358
13537
  if (entry.gap) return "gap";
13359
13538
  if (!entry.comment) return void 0;
13360
13539
  if (entry.label) return "note.label";
@@ -13396,45 +13575,66 @@ const noteRows = (note, row, room) => noteLines(note, room).map((line, index) =>
13396
13575
  comment: true,
13397
13576
  sent: note.sent,
13398
13577
  label: index === 0,
13399
- gap: false
13578
+ gap: false,
13579
+ prose: false
13400
13580
  }));
13401
- const layout = (patch, notes, room, gaps) => {
13402
- const display = [];
13403
- for (const row of patch.rows) {
13404
- display.push({
13405
- text: row.text,
13406
- row: row.index,
13407
- comment: false,
13408
- sent: false,
13409
- label: false,
13410
- gap: gaps.has(row.index)
13411
- });
13412
- for (const note of notes) if (sideLineOf(row, note.side) === note.line) display.push(...noteRows(note, row.index, room));
13413
- }
13414
- return display;
13415
- };
13581
+ const proseRows = (entry, row, room) => [...entry.markdown.split("\n").flatMap((line) => wrap(line, room - 2)), ""].map((line) => ({
13582
+ text: line.length === 0 ? "" : ` ${line}`,
13583
+ row,
13584
+ comment: false,
13585
+ sent: false,
13586
+ label: false,
13587
+ gap: false,
13588
+ prose: true
13589
+ }));
13590
+ const proseAt = (plan, row, after) => {
13591
+ const line = sideLineOf(row, "new");
13592
+ if (line === void 0) return [];
13593
+ return plan.prose.filter((entry) => entry.after === after && entry.line === line);
13594
+ };
13595
+ const notesAt = (plan, row) => plan.notes.filter((note) => sideLineOf(row, note.side) === note.line).flatMap((note) => noteRows(note, row.index, plan.room));
13596
+ const codeRow = (plan, row) => ({
13597
+ text: row.text,
13598
+ row: row.index,
13599
+ comment: false,
13600
+ sent: false,
13601
+ label: false,
13602
+ gap: plan.gaps.has(row.index),
13603
+ prose: false
13604
+ });
13605
+ const rowsFor = (plan, row) => [
13606
+ ...proseAt(plan, row, false).flatMap((entry) => proseRows(entry, row.index, plan.room)),
13607
+ codeRow(plan, row),
13608
+ ...notesAt(plan, row),
13609
+ ...proseAt(plan, row, true).flatMap((entry) => proseRows(entry, row.index, plan.room))
13610
+ ];
13611
+ const layout = (plan) => plan.patch.rows.flatMap((row) => rowsFor(plan, row));
13416
13612
  const lineNumbers = (patch, display) => {
13417
13613
  const numbers = /* @__PURE__ */ new Map();
13418
13614
  const rows = new Map(patch.rows.map((row) => [row.index, row]));
13419
13615
  for (const [index, entry] of display.entries()) {
13420
- const row = entry.comment ? void 0 : rows.get(entry.row);
13616
+ const row = entry.comment || entry.prose ? void 0 : rows.get(entry.row);
13421
13617
  const line = row === void 0 ? void 0 : numberFor(row);
13422
13618
  if (line !== void 0) numbers.set(index, line);
13423
13619
  }
13424
13620
  return numbers;
13425
13621
  };
13622
+ const BARE_SIGN = {
13623
+ after: " ",
13624
+ afterColor: palette.accent
13625
+ };
13626
+ const signFor = (entry, rows) => {
13627
+ if (entry.comment || entry.prose) return BARE_SIGN;
13628
+ const row = rows.get(entry.row);
13629
+ const sign = row === void 0 ? void 0 : SIGNS[row.kind];
13630
+ return sign === void 0 ? BARE_SIGN : {
13631
+ after: sign.text,
13632
+ afterColor: sign.color
13633
+ };
13634
+ };
13426
13635
  const lineSigns = (patch, display) => {
13427
- const signs = /* @__PURE__ */ new Map();
13428
13636
  const rows = new Map(patch.rows.map((row) => [row.index, row]));
13429
- for (const [index, entry] of display.entries()) {
13430
- const row = rows.get(entry.row);
13431
- const sign = entry.comment || row === void 0 ? void 0 : SIGNS[row.kind];
13432
- signs.set(index, {
13433
- after: sign?.text ?? " ",
13434
- afterColor: sign?.color ?? palette.accent
13435
- });
13436
- }
13437
- return signs;
13637
+ return new Map(display.map((entry, index) => [index, signFor(entry, rows)]));
13438
13638
  };
13439
13639
  const sideLineOf = (row, side) => getOrUndefined$1(lineOn(row, side));
13440
13640
  //#endregion
@@ -13744,33 +13944,44 @@ const shortPath = (path) => {
13744
13944
  const home = process.env["HOME"] ?? "";
13745
13945
  return home.length > 0 && path.startsWith(home) ? `~${path.slice(home.length)}` : path;
13746
13946
  };
13947
+ const HOME_PATH_MIN = 24;
13948
+ const HOME_PATH_CHROME = 10;
13949
+ const elide = (path, room) => {
13950
+ if (path.length <= room) return path;
13951
+ const parts = path.split("/").filter((part) => part.length > 0);
13952
+ const lead = path.startsWith("~") ? "~" : "";
13953
+ const tail = parts.slice(-2).join("/");
13954
+ const middled = `${path.startsWith("/") ? `/${parts[0] ?? ""}` : lead}/…/${tail}`;
13955
+ return middled.length <= room ? middled : `…/${tail}`;
13956
+ };
13747
13957
  const contextLabel = (context) => {
13748
13958
  if (context === 3) return "";
13749
13959
  return context >= 1e5 ? "whole file" : `±${context}`;
13750
13960
  };
13751
13961
  const nameRoom = (pane) => Math.max(BRANCH_NAME_MIN, Math.min(BRANCH_NAME, pane - BRANCH_TAIL));
13752
- const columns = (cells, room) => `${clip(cells.name, room).padEnd(room)}${cells.files.padStart(5)}${cells.added.padStart(8)}${cells.gone.padStart(8)} ${cells.story.padStart(8)} ${cells.state}`;
13962
+ const columns = (cells, room) => `${clip(cells.name, room).padEnd(room)}${cells.files.padStart(5)}${cells.added.padStart(8)}${cells.gone.padStart(8)} ${cells.layers.padStart(8)} ${cells.state}`;
13753
13963
  const branchHeading = (room) => ` ${columns({
13754
13964
  name: "WORKTREE",
13755
13965
  files: "FILES",
13756
13966
  added: "+",
13757
13967
  gone: "-",
13758
- story: "STORY",
13968
+ layers: "LAYERS",
13759
13969
  state: "STATE"
13760
13970
  }, room)}`;
13761
13971
  const atHome = (state) => state.screen === "branches" || state.screen === "palette" && state.returnTo === "branches";
13762
- const storyCell = (branch) => {
13763
- if (branch.steps === 0) return "";
13764
- return branch.stale ? `${branch.steps} stale` : `${branch.steps} story`;
13972
+ const layersCell = (branch) => {
13973
+ if (branch.layers === 0) return "";
13974
+ return branch.stale ? `${branch.layers} stale` : `${branch.layers} layers`;
13765
13975
  };
13976
+ const stateCell = (state, branch) => [state.pulls[branch.branch] ?? "", waitingLabel(branch).trim()].filter((part) => part.length > 0).join(" ");
13766
13977
  const branchCells = (branch, here, room) => ({
13767
13978
  lead: `${here ? marks().cursor : " "} `,
13768
13979
  name: clip(branch.branch, room).padEnd(room),
13769
13980
  files: `${branch.files}`.padStart(5),
13770
13981
  added: `+${branch.added}`.padStart(8),
13771
13982
  gone: `-${branch.removed}`.padStart(8),
13772
- story: storyCell(branch),
13773
- state: waitingLabel(branch).trim()
13983
+ layers: layersCell(branch),
13984
+ state: ""
13774
13985
  });
13775
13986
  const headerParts = (state, branch, path) => [
13776
13987
  branch,
@@ -13802,30 +14013,32 @@ const STEP_NUMBER = 3;
13802
14013
  const STEP_LEAD = 8;
13803
14014
  const NOTE_LEAD = 10;
13804
14015
  const STEP_GAP = 1;
13805
- const stepRoom = (state, pane) => {
13806
- const tally = Math.max(1, ...state.steps.map((step) => `${step.files.length}`.length));
14016
+ const layerRoom = (state, pane) => {
14017
+ const tally = Math.max(1, ...state.layers.map((layer) => `${layer.files.length}`.length));
13807
14018
  return {
13808
14019
  title: Math.max(4, pane - PANE_CHROME - STEP_LEAD - STEP_GAP - tally),
13809
14020
  note: Math.max(4, pane - PANE_CHROME - NOTE_LEAD),
13810
14021
  tally
13811
14022
  };
13812
14023
  };
13813
- const stepFold = (state, index) => {
13814
- if (stepOpen(state, index)) return "▾";
13815
- return (state.steps[index]?.note ?? "").length === 0 ? " " : "▸";
14024
+ const layerFold = (state, index) => {
14025
+ if (layerOpen(state, index)) return "▾";
14026
+ return (state.layers[index]?.note ?? "").length === 0 ? " " : "▸";
13816
14027
  };
13817
- const stepHead = (state, row) => {
14028
+ const layerHead = (state, row) => {
13818
14029
  if (!row.lead) return " ".repeat(STEP_LEAD);
13819
- return `${row.index === state.stepIndex ? state.focus === "tree" ? "▸" : "·" : " "} ${stepFold(state, row.index)} ${`${row.index + 1}.`.padStart(STEP_NUMBER)} `;
14030
+ return `${row.index === state.layerIndex ? state.focus === "tree" ? "▸" : "·" : " "} ${layerFold(state, row.index)} ${`${row.index + 1}.`.padStart(STEP_NUMBER)} `;
13820
14031
  };
13821
- const stepText = (state, row, room) => {
14032
+ const layerText = (state, row, room) => {
14033
+ if (row.kind === "file") return `${" ".repeat(NOTE_LEAD)}${marks().file} ${row.text}`;
13822
14034
  if (row.kind === "note") return `${" ".repeat(NOTE_LEAD)}${row.text}`;
13823
- const tail = (row.lead ? `${state.steps[row.index]?.files.length ?? 0}` : "").padStart(room.tally + STEP_GAP);
13824
- return `${stepHead(state, row)}${row.text.padEnd(room.title)}${tail}`;
14035
+ const tail = (row.lead ? `${state.layers[row.index]?.files.length ?? 0}` : "").padStart(room.tally + STEP_GAP);
14036
+ return `${layerHead(state, row)}${row.text.padEnd(room.title)}${tail}`;
13825
14037
  };
13826
- const stepPaint = (state, row) => {
14038
+ const layerPaint = (state, row) => {
14039
+ if (row.kind === "file") return palette.ink;
13827
14040
  if (row.kind === "note") return palette.faint;
13828
- return row.index === state.stepIndex ? palette.ink : palette.muted;
14041
+ return row.index === state.layerIndex ? palette.ink : palette.muted;
13829
14042
  };
13830
14043
  var Screen = class {
13831
14044
  header;
@@ -13929,12 +14142,14 @@ var Screen = class {
13929
14142
  }
13930
14143
  update(state) {
13931
14144
  this.shown = state;
13932
- this.chips = hintsFor(state.screen, state.staged);
14145
+ this.chips = hintsFor(state.screen, state.staged, state.layers.length);
13933
14146
  this.header.content = this.headerText(state);
13934
14147
  this.footer.content = this.footerText(state);
13935
14148
  this.list.content = this.listText(state);
13936
14149
  const many = state.branches.length === 1 ? "1 worktree" : `${state.branches.length} worktrees`;
13937
- this.landing.content = `${shortPath(this.repo)} · ${many}`;
14150
+ const pane = homeWidth(this.renderer.width);
14151
+ const room = Math.max(HOME_PATH_MIN, pane - many.length - HOME_PATH_CHROME);
14152
+ this.landing.content = `${elide(shortPath(this.repo), room)} · ${many}`;
13938
14153
  this.landingKeys.content = this.chipRow();
13939
14154
  this.diffPane.visible = state.screen !== "branches" && !(state.screen === "palette" && state.returnTo === "branches");
13940
14155
  if (this.diffPane.visible) this.paintDiff(state);
@@ -13991,7 +14206,7 @@ var Screen = class {
13991
14206
  }
13992
14207
  listText(state) {
13993
14208
  if (atHome(state)) return this.branchTable(state);
13994
- if (onSteps(state)) return this.stepRail(state);
14209
+ if (onLayers(state)) return this.layerRail(state);
13995
14210
  const height = Math.max(1, this.listPane.height - 1);
13996
14211
  const pane = this.paneRoom();
13997
14212
  const window = treeWindow(state, height);
@@ -13999,13 +14214,13 @@ var Screen = class {
13999
14214
  const more = window.more > 0 ? [fg(palette.faint)(` … ${window.more} more`)] : [];
14000
14215
  return new StyledText([...rows, ...more]);
14001
14216
  }
14002
- stepRail(state) {
14217
+ layerRail(state) {
14003
14218
  const height = Math.max(1, this.listPane.height - 1);
14004
- const room = stepRoom(state, this.paneRoom());
14005
- const window = railWindow(stepRows(state, room.title, room.note), height, state.stepIndex);
14006
- const rows = window.rows.map((row) => fg(stepPaint(state, row))(`${stepText(state, row, room)}\n`));
14219
+ const room = layerRoom(state, this.paneRoom());
14220
+ const window = railWindow(layerRows(state, room.title, room.note), height, state.layerIndex);
14221
+ const rows = window.rows.map((row) => fg(layerPaint(state, row))(`${layerText(state, row, room)}\n`));
14007
14222
  const more = window.more > 0 ? [fg(palette.faint)(` … ${window.more} more`)] : [];
14008
- const warn = state.storyStale ? [fg(palette.attention)(` stale, the branch moved on\n\n`)] : [];
14223
+ const warn = state.layersStale ? [fg(palette.attention)(` stale, the branch moved on\n\n`)] : [];
14009
14224
  return new StyledText([
14010
14225
  ...warn,
14011
14226
  ...rows,
@@ -14017,7 +14232,7 @@ var Screen = class {
14017
14232
  if (shown === void 0) return;
14018
14233
  const patch = shown.patch;
14019
14234
  this.paintSticky(state, state.top);
14020
- this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown));
14235
+ this.view.show(patch, notesFor(state, patch.path), gapRowSet(shown), proseFor(state, patch.path));
14021
14236
  this.view.fit(this.diffScroll.height);
14022
14237
  const height = this.view.rows();
14023
14238
  const top = this.view.scrollTo(state.top, state.cursor);
@@ -14101,8 +14316,8 @@ var Screen = class {
14101
14316
  fg(palette.faint)(cells.files),
14102
14317
  fg(palette.added)(cells.added),
14103
14318
  fg(palette.removed)(cells.gone),
14104
- fg(palette.accent)(` ${cells.story.padStart(8)}`),
14105
- fg(palette.attention)(` ${cells.state}\n`)
14319
+ fg(palette.accent)(` ${cells.layers.padStart(8)}`),
14320
+ fg(palette.attention)(` ${stateCell(state, branch)}\n`)
14106
14321
  ];
14107
14322
  });
14108
14323
  return new StyledText([...heading, ...rows]);
@@ -14122,8 +14337,14 @@ var Screen = class {
14122
14337
  }
14123
14338
  chipRow() {
14124
14339
  return new StyledText(this.chips.flatMap((chip, index) => {
14125
- const paint = index === this.hovered ? bg(palette.cursor) : fg(palette.faint);
14126
- return [index === this.hovered ? paint(` ${chip.key} ${chip.hint} `) : fg(palette.ink)(chip.key), index === this.hovered ? fg(palette.faint)(" ") : fg(palette.faint)(` ${chip.hint} `)];
14340
+ const lit = index === this.hovered;
14341
+ const key = fg(palette.ink)(chip.key);
14342
+ const hint = fg(lit ? palette.ink : palette.faint)(` ${chip.hint}`);
14343
+ return [
14344
+ lit ? bg(palette.cursor)(key) : key,
14345
+ lit ? bg(palette.cursor)(hint) : hint,
14346
+ fg(palette.faint)(" ")
14347
+ ];
14127
14348
  }));
14128
14349
  }
14129
14350
  paintPane(state) {
@@ -14305,6 +14526,7 @@ var App = class {
14305
14526
  renderer.on("frame", () => this.syncGeometry());
14306
14527
  renderer.setFrameCallback(async () => this.applyWheel());
14307
14528
  const resume = options.resume;
14529
+ this.dispatchTask(() => this.loadPulls());
14308
14530
  if (resume !== void 0) this.dispatchTask(() => this.resume(resume));
14309
14531
  }
14310
14532
  dispatchTask(task) {
@@ -14465,10 +14687,10 @@ var App = class {
14465
14687
  const patches = await this.run(listPatches(this.repo, branch.branch));
14466
14688
  const progress = await this.run(reviewProgress(this.repo, branch.branch));
14467
14689
  const pending = await this.run(listPending(this.repo, branch.branch));
14468
- const steps = await this.run(listStorySteps(this.repo, branch.branch));
14690
+ const layers = await this.run(listLayers(this.repo, branch.branch));
14469
14691
  const opened = withVouched(withPatches(this.state, patches), progress.vouched);
14470
14692
  const sent = await this.loadSent(branch.branch);
14471
- this.commit(withStory(withSent(withPending(opened, pending, "review"), sent), steps));
14693
+ this.commit(withLayers(withSent(withPending(opened, pending, "review"), sent), layers));
14472
14694
  await this.loadSource();
14473
14695
  }
14474
14696
  async goBack() {
@@ -14537,6 +14759,13 @@ var App = class {
14537
14759
  loadSent(branch) {
14538
14760
  return this.run(listSent(this.repo, branch));
14539
14761
  }
14762
+ async loadPulls() {
14763
+ const forge = await this.run(map(Forge, (service) => service));
14764
+ const pulls = await this.run(forge.pulls(this.repo));
14765
+ if (pulls.length === 0) return;
14766
+ const found = Object.fromEntries(pulls.map((pull) => [pull.branch, pull.state]));
14767
+ this.commit(withPulls(this.state, found));
14768
+ }
14540
14769
  async loadSource() {
14541
14770
  const branch = selectedBranch(this.state);
14542
14771
  const patch = selectedPatch(this.state);
@@ -14546,7 +14775,7 @@ var App = class {
14546
14775
  }
14547
14776
  async expand(delta) {
14548
14777
  const branch = selectedBranch(this.state);
14549
- const next = stepContext(this.state.context, delta);
14778
+ const next = layerContext(this.state.context, delta);
14550
14779
  if (branch === void 0 || next === this.state.context) return;
14551
14780
  const line = sourceLineAt(this.state, this.state.cursor);
14552
14781
  const patches = await this.run(listPatches(this.repo, branch.branch, next));
@@ -14715,7 +14944,7 @@ const reviewStatus = fn("Main.reviewStatus")(function* (options) {
14715
14944
  const documentAt = fn("Main.documentAt")(function* (source) {
14716
14945
  return yield* tryPromise({
14717
14946
  try: () => source === "-" ? text(process.stdin) : readFile(source, "utf8"),
14718
- catch: (cause) => new MalformedStory({ reason: String(cause) })
14947
+ catch: (cause) => new MalformedLayers({ reason: String(cause) })
14719
14948
  });
14720
14949
  });
14721
14950
  const routes = {
@@ -14725,14 +14954,14 @@ const routes = {
14725
14954
  "comment take": commentTake,
14726
14955
  "review submit": reviewSubmit,
14727
14956
  "review progress": reviewStatus,
14728
- "story set": fn("Main.storySet")(function* (options) {
14957
+ "layers set": fn("Main.layersSet")(function* (options) {
14729
14958
  const document = yield* documentAt(yield* required(options, "json"));
14730
- const story = yield* setStory(yield* required(options, "worktree"), document, options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
14731
- yield* answer(options, { story });
14959
+ const layers = yield* setLayers(yield* required(options, "worktree"), document, options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
14960
+ yield* answer(options, { layers });
14732
14961
  }),
14733
- "story show": fn("Main.storyShow")(function* (options) {
14734
- const story = yield* showStory(yield* required(options, "worktree"));
14735
- yield* answer(options, { story });
14962
+ "layers show": fn("Main.layersShow")(function* (options) {
14963
+ const layers = yield* showLayers(yield* required(options, "worktree"));
14964
+ yield* answer(options, { layers });
14736
14965
  }),
14737
14966
  describe: fn("Main.describe")(function* (options) {
14738
14967
  const wanted = options["command"];
@@ -14761,7 +14990,26 @@ const nameOf = (argv) => {
14761
14990
  return findCommand(pair) === void 0 ? words[0] ?? "" : pair;
14762
14991
  };
14763
14992
  const argv = process.argv.slice(2);
14764
- const layer = mergeAll(GitLive, storeAt(process.env["ADIFF_ROOT"] ?? defaultRoot()));
14993
+ const ASKS = {
14994
+ "--version": version,
14995
+ "-v": version,
14996
+ "--help": help,
14997
+ "-h": help
14998
+ };
14999
+ const spoken = (words) => {
15000
+ const [first, ...rest] = words;
15001
+ if (first === void 0) return banner();
15002
+ const asked = ASKS[first];
15003
+ if (asked !== void 0) return asked();
15004
+ if (first !== "help") return void 0;
15005
+ return rest.length === 0 ? help() : helpFor(rest.join(" ")) ?? help();
15006
+ };
15007
+ const said = spoken(argv);
15008
+ if (said !== void 0) {
15009
+ process.stdout.write(`${said}\n`);
15010
+ process.exit(0);
15011
+ }
15012
+ const layer = mergeAll(GitLive, ForgeLive, storeAt(process.env["ADIFF_ROOT"] ?? defaultRoot()));
14765
15013
  const exit = await runPromiseExit(run(nameOf(argv), optionsFrom(argv)).pipe(provide(layer)));
14766
15014
  if (isFailure(exit)) {
14767
15015
  const reported = failure(squash(exit.cause));