@eliya-oss/agent-diff 0.1.0-alpha.26 → 0.1.0-alpha.27

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,11 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.27
4
+
5
+ ### Minor Changes
6
+
7
+ - adiff init writes the review loop into a repository's agent instructions.
8
+
3
9
  ## 0.1.0-alpha.26
4
10
 
5
11
  ### Patch Changes
package/dist/main.js CHANGED
@@ -2606,7 +2606,7 @@ const isSome = isSome$1;
2606
2606
  * @category pattern matching
2607
2607
  * @since 2.0.0
2608
2608
  */
2609
- const match$2 = /*#__PURE__*/ dual(2, (self, { onNone, onSome }) => isNone(self) ? onNone() : onSome(self.value));
2609
+ const match$3 = /*#__PURE__*/ dual(2, (self, { onNone, onSome }) => isNone(self) ? onNone() : onSome(self.value));
2610
2610
  /**
2611
2611
  * Extracts the value from a `Some`, or evaluates a fallback thunk on `None`.
2612
2612
  *
@@ -4618,7 +4618,7 @@ const weeks = (weeks) => make$13(weeks * 6048e5);
4618
4618
  * @category getters
4619
4619
  * @since 2.0.0
4620
4620
  */
4621
- const toMillis = (self) => match(fromInputUnsafe(self), {
4621
+ const toMillis = (self) => match$1(fromInputUnsafe(self), {
4622
4622
  onMillis: identity,
4623
4623
  onNanos: (nanos) => Number(nanos) / 1e6,
4624
4624
  onInfinity: () => Infinity,
@@ -4691,7 +4691,7 @@ const toNanosUnsafe = (input) => {
4691
4691
  * @category pattern matching
4692
4692
  * @since 2.0.0
4693
4693
  */
4694
- const match = /*#__PURE__*/ dual(2, (self, options) => {
4694
+ const match$1 = /*#__PURE__*/ dual(2, (self, options) => {
4695
4695
  switch (self.value._tag) {
4696
4696
  case "Millis": return options.onMillis(self.value.millis);
4697
4697
  case "Nanos": return options.onNanos(self.value.nanos);
@@ -6027,6 +6027,39 @@ const catchTag$1 = /*#__PURE__*/ dual((args) => isEffect(args[0]), (self, k, f,
6027
6027
  /** @internal */
6028
6028
  const mapError$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (error) => failSync(() => f(error))));
6029
6029
  /** @internal */
6030
+ const option$2 = (self) => match(self, {
6031
+ onFailure: none,
6032
+ onSuccess: some
6033
+ });
6034
+ /** @internal */
6035
+ const matchCauseEffect = /*#__PURE__*/ dual(2, (self, options) => {
6036
+ const primitive = Object.create(OnSuccessAndFailureProto);
6037
+ primitive[args] = self;
6038
+ primitive[contA] = options.onSuccess.length !== 1 ? (a) => options.onSuccess(a) : options.onSuccess;
6039
+ primitive[contE] = options.onFailure.length !== 1 ? (cause) => options.onFailure(cause) : options.onFailure;
6040
+ return primitive;
6041
+ });
6042
+ const OnSuccessAndFailureProto = /*#__PURE__*/ makePrimitiveProto({
6043
+ op: "OnSuccessAndFailure",
6044
+ [evaluate](fiber) {
6045
+ fiber._stack.push(this);
6046
+ return this[args];
6047
+ }
6048
+ });
6049
+ /** @internal */
6050
+ const matchEffect = /*#__PURE__*/ dual(2, (self, options) => matchCauseEffect(self, {
6051
+ onFailure: (cause) => {
6052
+ const fail = cause.reasons.find(isFailReason$1);
6053
+ return fail ? internalCall(() => options.onFailure(fail.error)) : failCause$3(cause);
6054
+ },
6055
+ onSuccess: options.onSuccess
6056
+ }));
6057
+ /** @internal */
6058
+ const match = /*#__PURE__*/ dual(2, (self, options) => matchEffect(self, {
6059
+ onFailure: (error) => sync$2(() => options.onFailure(error)),
6060
+ onSuccess: (value) => sync$2(() => options.onSuccess(value))
6061
+ }));
6062
+ /** @internal */
6030
6063
  const exit$1 = (self) => effectIsExit(self) ? exitSucceed(self) : exitPrimitive(self);
6031
6064
  const exitPrimitive = /*#__PURE__*/ makePrimitive({
6032
6065
  op: "Exit",
@@ -9104,6 +9137,53 @@ const andThen = andThen$1;
9104
9137
  */
9105
9138
  const tap = tap$1;
9106
9139
  /**
9140
+ * Converts success to `Option.some` and failure to `Option.none`.
9141
+ *
9142
+ * **When to use**
9143
+ *
9144
+ * Use when you only care whether an effect succeeds and want recoverable
9145
+ * failures represented as `Option.none`.
9146
+ *
9147
+ * **Details**
9148
+ *
9149
+ * Success values become `Option.some`, recoverable failures become
9150
+ * `Option.none`, and defects still fail the effect.
9151
+ *
9152
+ * **Gotchas**
9153
+ *
9154
+ * `option` only captures typed, recoverable failures as `Option.none`.
9155
+ * Defects and interruptions are not captured inside the `Option` and still
9156
+ * fail the effect.
9157
+ *
9158
+ * `option` also discards typed failure values. Use `result` if the failure
9159
+ * value matters.
9160
+ *
9161
+ * **Example** (Capturing success or failure as Option)
9162
+ *
9163
+ * ```ts
9164
+ * import { Console, Effect, Option } from "effect"
9165
+ *
9166
+ * const program = Effect.gen(function*() {
9167
+ * const someValue = yield* Effect.option(Effect.succeed(1))
9168
+ * const noneValue = yield* Effect.option(Effect.fail("missing"))
9169
+ *
9170
+ * yield* Console.log(Option.isSome(someValue))
9171
+ * yield* Console.log(Option.isNone(noneValue))
9172
+ * })
9173
+ *
9174
+ * Effect.runPromise(program)
9175
+ * // true
9176
+ * // true
9177
+ * ```
9178
+ *
9179
+ * @see {@link result} for a version that uses `Result` instead.
9180
+ * @see {@link exit} for a version that encapsulates both recoverable errors and defects in an `Exit`.
9181
+ *
9182
+ * @category outcome encapsulation
9183
+ * @since 2.0.0
9184
+ */
9185
+ const option$1 = option$2;
9186
+ /**
9107
9187
  * Transforms an effect to encapsulate both failure and success using the `Exit`
9108
9188
  * data type.
9109
9189
  *
@@ -16183,7 +16263,7 @@ const lineOn = (row, side) => side === "new" ? row.newLine : row.oldLine;
16183
16263
  //#endregion
16184
16264
  //#region src/domain/patch/anchor.ts
16185
16265
  const sideOf = (rows) => rows.some((row) => isSome(row.newLine)) ? "new" : "old";
16186
- const linesOn = (rows, side) => rows.flatMap((row) => match$2(lineOn(row, side), {
16266
+ const linesOn = (rows, side) => rows.flatMap((row) => match$3(lineOn(row, side), {
16187
16267
  onNone: () => [],
16188
16268
  onSome: (n) => [n]
16189
16269
  }));
@@ -16621,7 +16701,7 @@ const settingsOps = (root) => {
16621
16701
  return {
16622
16702
  settings: gen(function* () {
16623
16703
  const raw = yield* readOptional(settingsPath(root));
16624
- return match$2(raw, {
16704
+ return match$3(raw, {
16625
16705
  onNone: () => ({}),
16626
16706
  onSome: parseSettings
16627
16707
  });
@@ -16666,7 +16746,7 @@ const answerOps = (root) => {
16666
16746
  }),
16667
16747
  answers: fn("Store.answers")(function* (worktreePath) {
16668
16748
  const raw = yield* readOptional(outboxPath(root, worktreePath));
16669
- return match$2(raw, {
16749
+ return match$3(raw, {
16670
16750
  onNone: () => [],
16671
16751
  onSome: parseAnswers
16672
16752
  });
@@ -16706,14 +16786,14 @@ const makeStore = (root) => {
16706
16786
  });
16707
16787
  const inbox = fn("Store.inbox")(function* (worktreePath) {
16708
16788
  const raw = yield* readOptional(inboxPath(root, worktreePath));
16709
- return match$2(raw, {
16789
+ return match$3(raw, {
16710
16790
  onNone: () => [],
16711
16791
  onSome: parseBatches
16712
16792
  });
16713
16793
  });
16714
16794
  const state = fn("Store.state")(function* (worktreePath) {
16715
16795
  const raw = yield* readOptional(statePath(root, worktreePath));
16716
- return match$2(raw, {
16796
+ return match$3(raw, {
16717
16797
  onNone: () => emptyBranchState,
16718
16798
  onSome: parseState
16719
16799
  });
@@ -16757,6 +16837,7 @@ var EmptyReview = class extends TaggedError("EmptyReview") {};
16757
16837
  var UnknownWorktree = class extends TaggedError("UnknownWorktree") {};
16758
16838
  var MalformedLayers = class extends TaggedError("MalformedLayers") {};
16759
16839
  var NoLayers = class extends TaggedError("NoLayers") {};
16840
+ var InitUnwritable = class extends TaggedError("InitUnwritable") {};
16760
16841
  //#endregion
16761
16842
  //#region src/cli/commands.ts
16762
16843
  const CONTEXT = 3;
@@ -16776,7 +16857,7 @@ const patchesOf = fn("Cli.patchesOf")(function* (worktree, context = CONTEXT) {
16776
16857
  return parsePatches(raw);
16777
16858
  });
16778
16859
  const findPatch = (patches, file) => fromNullishOr(patches.find((patch) => patch.path === file));
16779
- const rowsCovering = (patch, side, start, end) => patch.rows.filter((row) => match$2(lineOn(row, side), {
16860
+ const rowsCovering = (patch, side, start, end) => patch.rows.filter((row) => match$3(lineOn(row, side), {
16780
16861
  onNone: () => false,
16781
16862
  onSome: (line) => line >= start && line <= end
16782
16863
  })).map((row) => row.index);
@@ -16788,11 +16869,11 @@ const waitingOn = fn("Cli.waitingOn")(function* (worktree) {
16788
16869
  return {
16789
16870
  staged: state.pending.length,
16790
16871
  unread: Math.max(0, batches.length - state.consumed),
16791
- layers: match$2(told, {
16872
+ layers: match$3(told, {
16792
16873
  onNone: () => 0,
16793
16874
  onSome: (layers) => layers.layers.length
16794
16875
  }),
16795
- stale: match$2(told, {
16876
+ stale: match$3(told, {
16796
16877
  onNone: () => false,
16797
16878
  onSome: (layers) => layers.head !== worktree.head
16798
16879
  })
@@ -16826,7 +16907,7 @@ const toggleVouch = fn("Cli.toggleVouch")(function* (request) {
16826
16907
  const store = yield* Store;
16827
16908
  const worktree = yield* findBranch(request.repo, request.branch);
16828
16909
  const patches = yield* patchesOf(worktree);
16829
- const blob = yield* match$2(blobOf(patches, request.file), {
16910
+ const blob = yield* match$3(blobOf(patches, request.file), {
16830
16911
  onNone: () => new UnknownFile({
16831
16912
  file: request.file,
16832
16913
  known: patches.map((patch) => patch.path)
@@ -16864,7 +16945,7 @@ const reviewProgress = fn("Cli.reviewProgress")(function* (repo, branch) {
16864
16945
  const anchorRequest = fn("Cli.anchorRequest")(function* (request) {
16865
16946
  const worktree = yield* findBranch(request.repo, request.branch);
16866
16947
  const patches = yield* patchesOf(worktree, WHOLE_FILE$1);
16867
- const resolved = yield* match$2(findPatch(patches, request.file), {
16948
+ const resolved = yield* match$3(findPatch(patches, request.file), {
16868
16949
  onNone: () => new UnknownFile({
16869
16950
  file: request.file,
16870
16951
  known: patches.map((candidate) => candidate.path)
@@ -16877,7 +16958,7 @@ const anchorRequest = fn("Cli.anchorRequest")(function* (request) {
16877
16958
  const found = first === void 0 || last === void 0 ? none() : anchorFor(resolved, first, last);
16878
16959
  return {
16879
16960
  worktree,
16880
- anchor: yield* match$2(found, {
16961
+ anchor: yield* match$3(found, {
16881
16962
  onNone: () => new UnselectableRange({
16882
16963
  file: request.file,
16883
16964
  start: request.start,
@@ -16980,7 +17061,7 @@ const submitComment = fn("Cli.submitComment")(function* (request) {
16980
17061
  const worktree = yield* findBranch(request.repo, request.branch);
16981
17062
  const patches = yield* patchesOf(worktree, WHOLE_FILE$1);
16982
17063
  const patch = findPatch(patches, request.file);
16983
- const resolved = yield* match$2(patch, {
17064
+ const resolved = yield* match$3(patch, {
16984
17065
  onNone: () => new UnknownFile({
16985
17066
  file: request.file,
16986
17067
  known: patches.map((candidate) => candidate.path)
@@ -16991,7 +17072,7 @@ const submitComment = fn("Cli.submitComment")(function* (request) {
16991
17072
  const first = rows[0];
16992
17073
  const last = rows.at(-1);
16993
17074
  const anchor = first === void 0 || last === void 0 ? none() : anchorFor(resolved, first, last);
16994
- const chosen = yield* match$2(anchor, {
17075
+ const chosen = yield* match$3(anchor, {
16995
17076
  onNone: () => new UnselectableRange({
16996
17077
  file: request.file,
16997
17078
  start: request.start,
@@ -17052,6 +17133,118 @@ const saveWrap = fn("Cli.saveWrap")(function* (wrap) {
17052
17133
  });
17053
17134
  });
17054
17135
  //#endregion
17136
+ //#region src/cli/init.ts
17137
+ const BEGIN = "<!-- adiff:begin -->";
17138
+ const END = "<!-- adiff:end -->";
17139
+ const REACH$1 = 5;
17140
+ const INSTRUCTIONS = [
17141
+ BEGIN,
17142
+ "## Review",
17143
+ "",
17144
+ "Review of work in this repository happens in adiff. Before you say you are done, run",
17145
+ "`adiff comment take --worktree . --wait 300` in the background and handle what arrives.",
17146
+ "Answer a comment with `adiff comment answer --worktree . --id <id> --body <text>`, and write the",
17147
+ "reading order for your diff with `adiff layers set`. `adiff describe` lists the rest.",
17148
+ END
17149
+ ].join("\n");
17150
+ const IMPORT = [
17151
+ BEGIN,
17152
+ "@AGENTS.md",
17153
+ END
17154
+ ].join("\n");
17155
+ const blockIn = (text) => {
17156
+ const opens = text.indexOf(BEGIN);
17157
+ const closes = text.indexOf(END, opens);
17158
+ return opens === -1 || closes === -1 ? none() : some(text.slice(opens, closes + 18));
17159
+ };
17160
+ const replaced = (text, block, wanted) => text.replace(block, wanted);
17161
+ const appended = (text, wanted) => text.endsWith("\n") ? `${text}\n${wanted}\n` : `${text}\n\n${wanted}\n`;
17162
+ const planFor = (current, wanted) => {
17163
+ const text = getOrUndefined$1(current);
17164
+ if (text === void 0) return {
17165
+ action: "create",
17166
+ next: `${wanted}\n`
17167
+ };
17168
+ const found = blockIn(text);
17169
+ if (isNone(found)) return {
17170
+ action: "append",
17171
+ next: appended(text, wanted)
17172
+ };
17173
+ return found.value === wanted ? {
17174
+ action: "unchanged",
17175
+ next: text
17176
+ } : {
17177
+ action: "update",
17178
+ next: replaced(text, found.value, wanted)
17179
+ };
17180
+ };
17181
+ const readAt = fn("Cli.readAt")(function* (path) {
17182
+ return yield* tryPromise({
17183
+ try: () => readFile(path, "utf8"),
17184
+ catch: () => new InitUnwritable({
17185
+ path,
17186
+ reason: "unreadable"
17187
+ })
17188
+ }).pipe(option$1);
17189
+ });
17190
+ const writeAt = fn("Cli.writeAt")(function* (path, text) {
17191
+ yield* tryPromise({
17192
+ try: () => mkdir(dirname(path), { recursive: true }).then(() => writeFile(path, text, "utf8")),
17193
+ catch: (cause) => new InitUnwritable({
17194
+ path,
17195
+ reason: String(cause)
17196
+ })
17197
+ });
17198
+ });
17199
+ const settle = fn("Cli.settle")(function* (root, name, wanted, write) {
17200
+ const path = join(root, name);
17201
+ const current = yield* readAt(path);
17202
+ const plan = planFor(current, wanted);
17203
+ if (write && plan.action !== "unchanged") yield* writeAt(path, plan.next);
17204
+ return {
17205
+ path: name,
17206
+ action: plan.action
17207
+ };
17208
+ });
17209
+ const skillSource = () => {
17210
+ const here = dirname(fileURLToPath(import.meta.url));
17211
+ return Array.from({ length: REACH$1 }, (_, layer) => join(here, ...Array(layer).fill(".."))).map((at) => join(at, "skills", "adiff", "SKILL.md")).find((path) => existsSync(path));
17212
+ };
17213
+ const shippedSkill = fn("Cli.shippedSkill")(function* () {
17214
+ const source = skillSource();
17215
+ return yield* source === void 0 ? new InitUnwritable({
17216
+ path: "skills/adiff/SKILL.md",
17217
+ reason: "not found beside this build"
17218
+ }) : sync(() => readFileSync(source, "utf8"));
17219
+ });
17220
+ const settleSkill = fn("Cli.settleSkill")(function* (root, write) {
17221
+ const name = join(".claude", "skills", "adiff", "SKILL.md");
17222
+ const wanted = yield* shippedSkill();
17223
+ const current = yield* readAt(join(root, name));
17224
+ const action = match$3(current, {
17225
+ onNone: () => "create",
17226
+ onSome: (text) => text === wanted ? "unchanged" : "update"
17227
+ });
17228
+ if (write && action !== "unchanged") yield* writeAt(join(root, name), wanted);
17229
+ return {
17230
+ path: name,
17231
+ action
17232
+ };
17233
+ });
17234
+ const initRepository = fn("Cli.initRepository")(function* (request) {
17235
+ const instructions = yield* settle(request.repo, "AGENTS.md", INSTRUCTIONS, request.write);
17236
+ const memory = yield* settle(request.repo, "CLAUDE.md", IMPORT, request.write);
17237
+ const skill = request.skill ? [yield* settleSkill(request.repo, request.write)] : [];
17238
+ return {
17239
+ wrote: request.write,
17240
+ changes: [
17241
+ instructions,
17242
+ memory,
17243
+ ...skill
17244
+ ]
17245
+ };
17246
+ });
17247
+ //#endregion
17055
17248
  //#region src/cli/search.ts
17056
17249
  const HIT = /^(.+?):(\d+):(.*)$/;
17057
17250
  const NEAR = /^(.+?)-(\d+)-(.*)$/;
@@ -17123,7 +17316,7 @@ const spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({
17123
17316
  end
17124
17317
  })));
17125
17318
  const spanOfHunk = (patch, hunk) => {
17126
- const lines = hunk.rows.flatMap((row) => match$2(orElse(row.newLine, () => row.oldLine), {
17319
+ const lines = hunk.rows.flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
17127
17320
  onNone: () => [],
17128
17321
  onSome: (n) => [n]
17129
17322
  }));
@@ -17136,7 +17329,7 @@ const spanOfHunk = (patch, hunk) => {
17136
17329
  const overlaps = (a, b) => a.path === b.path && a.start <= b.end && a.end >= b.start;
17137
17330
  const coverage = (patches, layers) => {
17138
17331
  const claimed = spansOf$1(layers);
17139
- const hunks = patches.flatMap((patch) => patch.hunks.flatMap((hunk) => match$2(spanOfHunk(patch, hunk), {
17332
+ const hunks = patches.flatMap((patch) => patch.hunks.flatMap((hunk) => match$3(spanOfHunk(patch, hunk), {
17140
17333
  onNone: () => [],
17141
17334
  onSome: (s) => [s]
17142
17335
  })));
@@ -17259,12 +17452,12 @@ const parsed = (text) => {
17259
17452
  }
17260
17453
  };
17261
17454
  const readLayers = fn("Cli.readLayers")(function* (text) {
17262
- const document = yield* match$2(parsed(text), {
17455
+ const document = yield* match$3(parsed(text), {
17263
17456
  onNone: () => new MalformedLayers({ reason: "the layers is not a JSON object" }),
17264
17457
  onSome: succeed
17265
17458
  });
17266
17459
  const raw = document["layers"];
17267
- const layers = (Array.isArray(raw) ? raw : []).flatMap((entry) => match$2(layerOf(entry), {
17460
+ const layers = (Array.isArray(raw) ? raw : []).flatMap((entry) => match$3(layerOf(entry), {
17268
17461
  onNone: () => [],
17269
17462
  onSome: (layer) => [layer]
17270
17463
  }));
@@ -17335,7 +17528,7 @@ const setLayers = fn("Cli.setLayers")(function* (worktreePath, text, written) {
17335
17528
  const patches = yield* patchesOf(worktree);
17336
17529
  const previous = yield* storedLayers(worktree);
17337
17530
  const layers = {
17338
- version: match$2(previous, {
17531
+ version: match$3(previous, {
17339
17532
  onNone: () => 1,
17340
17533
  onSome: (old) => old.version + 1
17341
17534
  }),
@@ -17353,7 +17546,7 @@ const showLayers = fn("Cli.showLayers")(function* (worktreePath) {
17353
17546
  const worktree = yield* worktreeAt(worktreePath);
17354
17547
  const patches = yield* patchesOf(worktree);
17355
17548
  const found = yield* storedLayers(worktree);
17356
- const layers = yield* match$2(found, {
17549
+ const layers = yield* match$3(found, {
17357
17550
  onNone: () => new NoLayers({ worktree: worktree.path }),
17358
17551
  onSome: succeed
17359
17552
  });
@@ -17456,7 +17649,7 @@ const optionsFrom = (argv) => {
17456
17649
  };
17457
17650
  const required = fn("Cli.required")(function* (options, name) {
17458
17651
  const value = fromNullishOr(options[name]);
17459
- return yield* match$2(value, {
17652
+ return yield* match$3(value, {
17460
17653
  onNone: () => new MissingOption({ option: name }),
17461
17654
  onSome: succeed
17462
17655
  });
@@ -17750,6 +17943,33 @@ const catalog = [
17750
17943
  dataKey: "",
17751
17944
  example: "adiff review open --repo ."
17752
17945
  },
17946
+ {
17947
+ name: "init",
17948
+ about: "Write the review loop into this repository's agent instructions, so an agent finds it unprompted",
17949
+ safety: "write",
17950
+ options: [
17951
+ {
17952
+ name: "repo",
17953
+ required: true,
17954
+ value: "path",
17955
+ about: "Repository to write the loop into"
17956
+ },
17957
+ {
17958
+ name: "write",
17959
+ required: false,
17960
+ value: "flag",
17961
+ about: "Make the changes. Without it, init reports what each file would become"
17962
+ },
17963
+ {
17964
+ name: "skill",
17965
+ required: false,
17966
+ value: "flag",
17967
+ about: "Also commit the adiff skill at .claude/skills/adiff/SKILL.md"
17968
+ }
17969
+ ],
17970
+ dataKey: "changes",
17971
+ example: "adiff init --repo . --write"
17972
+ },
17753
17973
  {
17754
17974
  name: "describe",
17755
17975
  about: "This catalog, as JSON",
@@ -17812,6 +18032,11 @@ const ADVICE = {
17812
18032
  suggestion: "No comment carries that id. `adiff comment take` reports the ids an agent can answer, and `adiff comment threads` reports every id on a branch.",
17813
18033
  retriable: false
17814
18034
  },
18035
+ InitUnwritable: {
18036
+ exit: 1,
18037
+ suggestion: "adiff init writes AGENTS.md and CLAUDE.md in the repository you point --repo at. Check that path is a directory you can write to.",
18038
+ retriable: false
18039
+ },
17815
18040
  UnselectableRange: {
17816
18041
  exit: 2,
17817
18042
  suggestion: "Those lines are not in the diff. Check --side: new is the working tree, old is the version being replaced.",
@@ -17991,7 +18216,7 @@ const spansOf = (patch, total) => {
17991
18216
  trailing
17992
18217
  ];
17993
18218
  };
17994
- const linesFrom = (build, from, to) => build.full === void 0 || to < from ? [] : build.full.rows.filter((row) => match$2(row.newLine, {
18219
+ const linesFrom = (build, from, to) => build.full === void 0 || to < from ? [] : build.full.rows.filter((row) => match$3(row.newLine, {
17995
18220
  onNone: () => false,
17996
18221
  onSome: (line) => line >= from && line <= to
17997
18222
  }));
@@ -18413,7 +18638,7 @@ const hiddenLines = (state) => shownOf(state)?.gaps.reduce((total, gap) => total
18413
18638
  const markedRows = (state) => {
18414
18639
  const patch = selectedPatch(state);
18415
18640
  if (patch === void 0) return /* @__PURE__ */ new Set();
18416
- const rows = state.pending.filter((entry) => entry.file === patch.path).flatMap((entry) => patch.rows.filter((row) => match$2(row.newLine, {
18641
+ const rows = state.pending.filter((entry) => entry.file === patch.path).flatMap((entry) => patch.rows.filter((row) => match$3(row.newLine, {
18417
18642
  onNone: () => false,
18418
18643
  onSome: (line) => line >= entry.start && line <= entry.end
18419
18644
  })).map((row) => row.index));
@@ -18428,7 +18653,7 @@ const selectedRows = (state) => {
18428
18653
  };
18429
18654
  const snippetOf = (state, limit) => selectedRows(state).slice(0, limit).map((row) => `${lineOf(row).padStart(4)} ${row.text}`);
18430
18655
  const selectedLineCount = (state) => selectedRows(state).length;
18431
- const lineOf = (row) => match$2(row.newLine, {
18656
+ const lineOf = (row) => match$3(row.newLine, {
18432
18657
  onNone: () => "-",
18433
18658
  onSome: (line) => String(line)
18434
18659
  });
@@ -18443,7 +18668,7 @@ const composeTarget = (state) => {
18443
18668
  if (patch === void 0) return "";
18444
18669
  const [from, to] = selectionRange(state);
18445
18670
  const anchor = anchorFor(patch, from, to);
18446
- const span = match$2(anchor, {
18671
+ const span = match$3(anchor, {
18447
18672
  onNone: () => "",
18448
18673
  onSome: (found) => found.start === found.end ? `${found.start}` : `${found.start}-${found.end}`
18449
18674
  });
@@ -18543,7 +18768,7 @@ const sourceLineAt = (state, row) => {
18543
18768
  return getOrUndefined$1(found.newLine) ?? getOrUndefined$1(found.oldLine);
18544
18769
  };
18545
18770
  const rowAtSourceLine = (patch, line) => {
18546
- return patch.rows.find((row) => match$2(row.newLine, {
18771
+ return patch.rows.find((row) => match$3(row.newLine, {
18547
18772
  onNone: () => false,
18548
18773
  onSome: (value) => value >= line
18549
18774
  }))?.index ?? 0;
@@ -22085,6 +22310,17 @@ const routes = {
22085
22310
  const layers = yield* showLayers(yield* required(options, "worktree"));
22086
22311
  yield* answer(options, { layers });
22087
22312
  }),
22313
+ init: fn("Main.init")(function* (options) {
22314
+ const report = yield* initRepository({
22315
+ repo: yield* required(options, "repo"),
22316
+ write: options["write"] !== void 0,
22317
+ skill: options["skill"] !== void 0
22318
+ });
22319
+ yield* answer(options, {
22320
+ wrote: report.wrote,
22321
+ changes: report.changes
22322
+ });
22323
+ }),
22088
22324
  describe: fn("Main.describe")(function* (options) {
22089
22325
  const wanted = options["command"];
22090
22326
  const asked = wanted === void 0 || wanted === "true" ? void 0 : wanted;
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.26",
26
+ "version": "0.1.0-alpha.27",
27
27
  "description": "Review agent work across git worktrees like a PR, and hand the comments back to the agent.",
28
28
  "license": "MIT",
29
29
  "repository": {