@eliya-oss/agent-diff 0.1.0-alpha.166 → 0.1.0-alpha.167

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.167
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(review): A comment the hunks cannot place is matched against every line of the code it quoted, so a comment about a deleted doc comment is no longer hung on the next `*/` in the file.
8
+
9
+ - feat(cli): `adiff resume` opens the review left last in the repository it is run from, and `adiff resume --check` names that branch without opening anything.
10
+
3
11
  ## 0.1.0-alpha.166
4
12
 
5
13
  ### Patch Changes
package/dist/main.js CHANGED
@@ -9245,6 +9245,7 @@ var init_model$6 = __esmMin((() => {
9245
9245
  taken: {},
9246
9246
  vouches: {},
9247
9247
  parts: {},
9248
+ openedAt: "",
9248
9249
  consumed: 0,
9249
9250
  settled: {},
9250
9251
  removed: {},
@@ -9305,6 +9306,7 @@ var init_schema = __esmMin((() => {
9305
9306
  taken: optionalKey(Record(String$1, String$1)),
9306
9307
  vouches: Stamps.pipe(noStamps),
9307
9308
  parts: Stamps.pipe(noStamps),
9309
+ openedAt: String$1.pipe(withDecodingDefaultKey(succeed$1(""))),
9308
9310
  consumed: Int.pipe(withDecodingDefaultKey(succeed$1(0))),
9309
9311
  settled: Stamps.pipe(noStamps),
9310
9312
  removed: Stamps.pipe(noStamps),
@@ -10577,7 +10579,7 @@ var init_error = __esmMin((() => {
10577
10579
  }));
10578
10580
  //#endregion
10579
10581
  //#region src/cli/commands.ts
10580
- var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, readParts, blobOf, vouchIn, toggleVouch, readingOf, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, linesIn, lastLineOf, nearestLine, stillInFile, foundOutsideTheHunks, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$2, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, listRefs, setBase, clearBase, markRead;
10582
+ var realOf, CONTEXT, POLL, AUTO, askedFor$1, basedOn, worktreeNamed, findBranch, baseFor, patchesOf, findPatch, waitingOn, summaryOf, summaryFor, listBranches, readParts, blobOf, vouchIn, toggleVouch, readingOf, markOpened, lastOpenedIn, progressIn, reviewProgress, bodyOf, saidTo, spunOf, sentOf, whereItSitsNow$1, linesIn, trimmedLines, NAMES_SOMETHING, worthMatching, blockAt, wholeSnippetIn, stillInFile, foundOutsideTheHunks, sentIn, listSent, anchorIn, commentsIn, commentIn, submitComment, submitComments, without$2, submitReply, listPatches, patchIn, flatten, threadBefore, takeComments, repoOf$1, worktreeOf$1, branchAt, awaitComments, saveReport, fileSource, fileBefore, readPreferences, readPreference, ON, OFF, preferenceValue, savePreference, listRefs, setBase, clearBase, markRead;
10581
10583
  var init_commands = __esmMin((() => {
10582
10584
  init_dist();
10583
10585
  init_patch();
@@ -10758,6 +10760,21 @@ var init_commands = __esmMin((() => {
10758
10760
  patches: yield* patchesOf(worktree)
10759
10761
  };
10760
10762
  });
10763
+ markOpened = fn("Cli.markOpened")(function* (worktreePath, at) {
10764
+ yield* (yield* Store).changeState(worktreePath, (was) => ({
10765
+ ...was,
10766
+ openedAt: at
10767
+ }));
10768
+ });
10769
+ lastOpenedIn = fn("Cli.lastOpenedIn")(function* (repo) {
10770
+ const store = yield* Store;
10771
+ const trees = yield* (yield* Git).worktrees(repo);
10772
+ const openedOf = (tree) => map(store.state(tree.path), (held) => ({
10773
+ branch: tree.branch,
10774
+ at: held.openedAt
10775
+ }));
10776
+ return (yield* forEach(trees, openedOf)).filter((one) => one.at.length > 0).toSorted((left, right) => right.at.localeCompare(left.at))[0];
10777
+ });
10761
10778
  progressIn = fn("Cli.progressIn")(function* (reading) {
10762
10779
  const current = yield* (yield* Store).state(reading.worktree.path);
10763
10780
  const files = reading.patches.map((patch) => ({
@@ -10845,14 +10862,19 @@ var init_commands = __esmMin((() => {
10845
10862
  });
10846
10863
  };
10847
10864
  linesIn = (found) => getOrElse$1(found, () => []);
10848
- lastLineOf = (snippet) => snippet.split("\n").map((line) => line.trim()).findLast((line) => line.length > 0) ?? "";
10849
- nearestLine = (source, wanted, was) => {
10850
- const found = source.flatMap((line, at) => line.trim() === wanted ? [at + 1] : []);
10865
+ trimmedLines = (snippet) => snippet.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
10866
+ NAMES_SOMETHING = /[A-Za-z0-9_$]{3}/;
10867
+ worthMatching = (wanted) => wanted.length > 1 || wanted[0] !== void 0 && NAMES_SOMETHING.test(wanted[0]);
10868
+ blockAt = (source, wanted, at) => wanted.every((line, step) => (source[at + step] ?? "").trim() === line);
10869
+ wholeSnippetIn = (source, wanted, was) => {
10870
+ const found = source.flatMap((_, at) => blockAt(source, wanted, at) ? [at + wanted.length] : []);
10851
10871
  if (found.length === 0) return void 0;
10852
10872
  return found.reduce((best, line) => Math.abs(line - was) < Math.abs(best - was) ? line : best);
10853
10873
  };
10854
10874
  stillInFile = (comment, source) => {
10855
- const line = nearestLine(source, lastLineOf(comment.snippet), comment.end);
10875
+ const wanted = trimmedLines(comment.snippet);
10876
+ if (!worthMatching(wanted)) return comment;
10877
+ const line = wholeSnippetIn(source, wanted, comment.end);
10856
10878
  if (line === void 0) return comment;
10857
10879
  const span = Math.max(0, comment.end - comment.start);
10858
10880
  return {
@@ -11373,7 +11395,7 @@ var init_pane = __esmMin((() => {
11373
11395
  //#region package.json
11374
11396
  init_drafts();
11375
11397
  init_pane();
11376
- var version$1 = "0.1.0-alpha.166";
11398
+ var version$1 = "0.1.0-alpha.167";
11377
11399
  //#endregion
11378
11400
  //#region src/cli/upgrade.ts
11379
11401
  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$1, newer, tagIn, fetched, askLatest, here, findUpgrade, willUpgrade, ranChild, runUpgrade, statusOf$1, sayFound, sayDone, attempted, SAY_SKILL_TOO, upgradeReport;
@@ -12930,6 +12952,26 @@ var init_catalog = __esmMin((() => {
12930
12952
  dataKey: "upgrade",
12931
12953
  example: "adiff upgrade --check --json --fields route,latest,current"
12932
12954
  },
12955
+ {
12956
+ name: "resume",
12957
+ about: "Open the review you left last in this repository. Opens the terminal, like `review open`, on the branch it was opened on most recently",
12958
+ group: SET_UP,
12959
+ addresses: "none",
12960
+ safety: "read",
12961
+ options: [{
12962
+ name: "repo",
12963
+ required: false,
12964
+ value: "path",
12965
+ about: "The repository, defaulting to where you are"
12966
+ }, {
12967
+ name: "check",
12968
+ required: false,
12969
+ value: "flag",
12970
+ about: "Name the branch that would open, without opening anything. Always exits 0"
12971
+ }],
12972
+ dataKey: "resume",
12973
+ example: "adiff resume"
12974
+ },
12933
12975
  {
12934
12976
  name: "describe",
12935
12977
  about: "This catalog, as JSON",
@@ -20811,6 +20853,7 @@ var init_app = __esmMin((() => {
20811
20853
  return gen({ self: this }, function* () {
20812
20854
  const reading = yield* readingOf(this.repo, name, this.base);
20813
20855
  this.reading = reading;
20856
+ yield* markOpened(reading.worktree.path, (/* @__PURE__ */ new Date()).toISOString());
20814
20857
  const [progress, layers, sent, remarks] = yield* all([
20815
20858
  progressIn(reading),
20816
20859
  layersIn(reading),
@@ -22279,11 +22322,31 @@ const addressOf = fn("Main.addressOf")(function* (name, options) {
22279
22322
  if (worktree !== void 0) return yield* byWorktree(options, worktree);
22280
22323
  return yield* new MissingOption({ option: addressing[0]?.name ?? "worktree" });
22281
22324
  });
22325
+ const RESUME_ADVICE = "Nothing has been opened here yet. Run `adiff review open --repo .` and pick a branch.";
22326
+ const resume = fn("Main.resume")(function* (options) {
22327
+ const repo = options["repo"] ?? process.cwd();
22328
+ const found = yield* lastOpenedIn(repo);
22329
+ if (options["check"] !== void 0) return yield* answer(options, {
22330
+ resume: found === void 0 ? {} : found,
22331
+ advice: found === void 0 ? RESUME_ADVICE : ""
22332
+ });
22333
+ if (found === void 0) {
22334
+ process.stderr.write(`${RESUME_ADVICE}\n`);
22335
+ return yield* sync(() => process.exit(3));
22336
+ }
22337
+ const { runTui } = yield* promise(() => Promise.resolve().then(() => (init_tui(), tui_exports)));
22338
+ return yield* runTui(repo, {
22339
+ sessionPath: process.env["ADIFF_SESSION"],
22340
+ branch: found.branch,
22341
+ base: options["base"]
22342
+ });
22343
+ });
22282
22344
  const dispatch = fn("Main.dispatch")(function* (name, given) {
22283
22345
  const options = yield* addressOf(name, given);
22284
22346
  const route = Object.hasOwn(routes, name) ? routes[name] : void 0;
22285
22347
  if (route !== void 0) return yield* route(options);
22286
22348
  if (name === "file review") return yield* fileReview(options);
22349
+ if (name === "resume") return yield* resume(options);
22287
22350
  if (name === "review open") {
22288
22351
  const { runTui } = yield* promise(() => Promise.resolve().then(() => (init_tui(), tui_exports)));
22289
22352
  return yield* runTui(yield* required(options, "repo"), {
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.166",
26
+ "version": "0.1.0-alpha.167",
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": {