@eliya-oss/agent-diff 0.1.0-alpha.26 → 0.1.0-alpha.28
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 +12 -0
- package/dist/main.js +390 -41
- package/package.json +1 -1
- package/skills/adiff/SKILL.md +24 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @eliya-oss/agent-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.28
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- An agent can open the review in a split pane beside the conversation.
|
|
8
|
+
|
|
9
|
+
## 0.1.0-alpha.27
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- adiff init writes the review loop into a repository's agent instructions.
|
|
14
|
+
|
|
3
15
|
## 0.1.0-alpha.26
|
|
4
16
|
|
|
5
17
|
### 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$
|
|
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
|
*
|
|
@@ -13634,7 +13714,7 @@ const make$6 = (value) => {
|
|
|
13634
13714
|
* @category general
|
|
13635
13715
|
* @since 2.0.0
|
|
13636
13716
|
*/
|
|
13637
|
-
const set$
|
|
13717
|
+
const set$2 = /*#__PURE__*/ dual(2, (self, value) => {
|
|
13638
13718
|
self.current = value;
|
|
13639
13719
|
return self;
|
|
13640
13720
|
});
|
|
@@ -13842,7 +13922,7 @@ const subscribe = (self) => uninterruptible(contextWith((services) => {
|
|
|
13842
13922
|
return addFinalizer(scope, unsubscribe(subscription)).pipe(andThen(addFinalizerExit(localScope, (exit) => close(scope, exit))), as(subscription));
|
|
13843
13923
|
}));
|
|
13844
13924
|
const unsubscribe = (self) => uninterruptible(withFiber((state) => {
|
|
13845
|
-
set$
|
|
13925
|
+
set$2(self.shutdownFlag, true);
|
|
13846
13926
|
return forEach(takeAll$2(self.pollers), (d) => interruptWith(d, state.id), {
|
|
13847
13927
|
discard: true,
|
|
13848
13928
|
concurrency: "unbounded"
|
|
@@ -16176,14 +16256,14 @@ const setUnsafe = (self, value) => {
|
|
|
16176
16256
|
* @category setters
|
|
16177
16257
|
* @since 2.0.0
|
|
16178
16258
|
*/
|
|
16179
|
-
const set = /*#__PURE__*/ dual(2, (self, value) => self.semaphore.withPermit(sync(() => setUnsafe(self, value))));
|
|
16259
|
+
const set$1 = /*#__PURE__*/ dual(2, (self, value) => self.semaphore.withPermit(sync(() => setUnsafe(self, value))));
|
|
16180
16260
|
String$1.pipe(brand("@adiff/Blob"));
|
|
16181
16261
|
String$1.pipe(brand("@adiff/FilePath"));
|
|
16182
16262
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
16872
|
+
layers: match$3(told, {
|
|
16792
16873
|
onNone: () => 0,
|
|
16793
16874
|
onSome: (layers) => layers.layers.length
|
|
16794
16875
|
}),
|
|
16795
|
-
stale: match$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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,212 @@ 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
|
|
17248
|
+
//#region src/cli/pane.ts
|
|
17249
|
+
const TIMEOUT_MS$1 = 5e3;
|
|
17250
|
+
const set = (name) => (process.env[name] ?? "").length > 0;
|
|
17251
|
+
const splitters = [
|
|
17252
|
+
{
|
|
17253
|
+
pane: "tmux",
|
|
17254
|
+
binary: "tmux",
|
|
17255
|
+
present: () => set("TMUX"),
|
|
17256
|
+
args: (repo, run) => [
|
|
17257
|
+
"split-window",
|
|
17258
|
+
"-h",
|
|
17259
|
+
"-c",
|
|
17260
|
+
repo,
|
|
17261
|
+
...run
|
|
17262
|
+
]
|
|
17263
|
+
},
|
|
17264
|
+
{
|
|
17265
|
+
pane: "zellij",
|
|
17266
|
+
binary: "zellij",
|
|
17267
|
+
present: () => set("ZELLIJ"),
|
|
17268
|
+
args: (repo, run) => [
|
|
17269
|
+
"action",
|
|
17270
|
+
"new-pane",
|
|
17271
|
+
"-d",
|
|
17272
|
+
"right",
|
|
17273
|
+
"--cwd",
|
|
17274
|
+
repo,
|
|
17275
|
+
"--",
|
|
17276
|
+
...run
|
|
17277
|
+
]
|
|
17278
|
+
},
|
|
17279
|
+
{
|
|
17280
|
+
pane: "wezterm",
|
|
17281
|
+
binary: "wezterm",
|
|
17282
|
+
present: () => set("WEZTERM_PANE"),
|
|
17283
|
+
args: (repo, run) => [
|
|
17284
|
+
"cli",
|
|
17285
|
+
"split-pane",
|
|
17286
|
+
"--right",
|
|
17287
|
+
"--cwd",
|
|
17288
|
+
repo,
|
|
17289
|
+
"--",
|
|
17290
|
+
...run
|
|
17291
|
+
]
|
|
17292
|
+
},
|
|
17293
|
+
{
|
|
17294
|
+
pane: "kitty",
|
|
17295
|
+
binary: "kitten",
|
|
17296
|
+
present: () => set("KITTY_LISTEN_ON"),
|
|
17297
|
+
args: (repo, run) => [
|
|
17298
|
+
"@",
|
|
17299
|
+
"launch",
|
|
17300
|
+
"--type=window",
|
|
17301
|
+
"--cwd",
|
|
17302
|
+
repo,
|
|
17303
|
+
...run
|
|
17304
|
+
]
|
|
17305
|
+
}
|
|
17306
|
+
];
|
|
17307
|
+
const selfInvocation = (repo) => {
|
|
17308
|
+
const entry = process.argv[1];
|
|
17309
|
+
return [
|
|
17310
|
+
...entry === void 0 ? ["adiff"] : [
|
|
17311
|
+
process.execPath,
|
|
17312
|
+
...process.execArgv,
|
|
17313
|
+
entry
|
|
17314
|
+
],
|
|
17315
|
+
"review",
|
|
17316
|
+
"open",
|
|
17317
|
+
"--repo",
|
|
17318
|
+
repo
|
|
17319
|
+
];
|
|
17320
|
+
};
|
|
17321
|
+
const ran = (binary, args) => callback$1((resume) => {
|
|
17322
|
+
execFile(binary, [...args], { timeout: TIMEOUT_MS$1 }, (cause) => resume(succeed(cause === null)));
|
|
17323
|
+
});
|
|
17324
|
+
const split = fn("Cli.split")(function* (chosen, repo) {
|
|
17325
|
+
return yield* ran(chosen.binary, chosen.args(repo, selfInvocation(repo)));
|
|
17326
|
+
});
|
|
17327
|
+
const openPane = fn("Cli.openPane")(function* (repo) {
|
|
17328
|
+
const command = `adiff review open --repo ${repo}`;
|
|
17329
|
+
const chosen = splitters.find((candidate) => candidate.present());
|
|
17330
|
+
if (chosen === void 0) return {
|
|
17331
|
+
opened: false,
|
|
17332
|
+
pane: "none",
|
|
17333
|
+
command
|
|
17334
|
+
};
|
|
17335
|
+
return {
|
|
17336
|
+
opened: yield* split(chosen, repo),
|
|
17337
|
+
pane: chosen.pane,
|
|
17338
|
+
command
|
|
17339
|
+
};
|
|
17340
|
+
});
|
|
17341
|
+
//#endregion
|
|
17055
17342
|
//#region src/cli/search.ts
|
|
17056
17343
|
const HIT = /^(.+?):(\d+):(.*)$/;
|
|
17057
17344
|
const NEAR = /^(.+?)-(\d+)-(.*)$/;
|
|
@@ -17123,7 +17410,7 @@ const spansOf$1 = (layers) => layers.flatMap((layer) => codeBlocks(layer).map(({
|
|
|
17123
17410
|
end
|
|
17124
17411
|
})));
|
|
17125
17412
|
const spanOfHunk = (patch, hunk) => {
|
|
17126
|
-
const lines = hunk.rows.flatMap((row) => match$
|
|
17413
|
+
const lines = hunk.rows.flatMap((row) => match$3(orElse(row.newLine, () => row.oldLine), {
|
|
17127
17414
|
onNone: () => [],
|
|
17128
17415
|
onSome: (n) => [n]
|
|
17129
17416
|
}));
|
|
@@ -17136,7 +17423,7 @@ const spanOfHunk = (patch, hunk) => {
|
|
|
17136
17423
|
const overlaps = (a, b) => a.path === b.path && a.start <= b.end && a.end >= b.start;
|
|
17137
17424
|
const coverage = (patches, layers) => {
|
|
17138
17425
|
const claimed = spansOf$1(layers);
|
|
17139
|
-
const hunks = patches.flatMap((patch) => patch.hunks.flatMap((hunk) => match$
|
|
17426
|
+
const hunks = patches.flatMap((patch) => patch.hunks.flatMap((hunk) => match$3(spanOfHunk(patch, hunk), {
|
|
17140
17427
|
onNone: () => [],
|
|
17141
17428
|
onSome: (s) => [s]
|
|
17142
17429
|
})));
|
|
@@ -17259,12 +17546,12 @@ const parsed = (text) => {
|
|
|
17259
17546
|
}
|
|
17260
17547
|
};
|
|
17261
17548
|
const readLayers = fn("Cli.readLayers")(function* (text) {
|
|
17262
|
-
const document = yield* match$
|
|
17549
|
+
const document = yield* match$3(parsed(text), {
|
|
17263
17550
|
onNone: () => new MalformedLayers({ reason: "the layers is not a JSON object" }),
|
|
17264
17551
|
onSome: succeed
|
|
17265
17552
|
});
|
|
17266
17553
|
const raw = document["layers"];
|
|
17267
|
-
const layers = (Array.isArray(raw) ? raw : []).flatMap((entry) => match$
|
|
17554
|
+
const layers = (Array.isArray(raw) ? raw : []).flatMap((entry) => match$3(layerOf(entry), {
|
|
17268
17555
|
onNone: () => [],
|
|
17269
17556
|
onSome: (layer) => [layer]
|
|
17270
17557
|
}));
|
|
@@ -17335,7 +17622,7 @@ const setLayers = fn("Cli.setLayers")(function* (worktreePath, text, written) {
|
|
|
17335
17622
|
const patches = yield* patchesOf(worktree);
|
|
17336
17623
|
const previous = yield* storedLayers(worktree);
|
|
17337
17624
|
const layers = {
|
|
17338
|
-
version: match$
|
|
17625
|
+
version: match$3(previous, {
|
|
17339
17626
|
onNone: () => 1,
|
|
17340
17627
|
onSome: (old) => old.version + 1
|
|
17341
17628
|
}),
|
|
@@ -17353,7 +17640,7 @@ const showLayers = fn("Cli.showLayers")(function* (worktreePath) {
|
|
|
17353
17640
|
const worktree = yield* worktreeAt(worktreePath);
|
|
17354
17641
|
const patches = yield* patchesOf(worktree);
|
|
17355
17642
|
const found = yield* storedLayers(worktree);
|
|
17356
|
-
const layers = yield* match$
|
|
17643
|
+
const layers = yield* match$3(found, {
|
|
17357
17644
|
onNone: () => new NoLayers({ worktree: worktree.path }),
|
|
17358
17645
|
onSome: succeed
|
|
17359
17646
|
});
|
|
@@ -17456,7 +17743,7 @@ const optionsFrom = (argv) => {
|
|
|
17456
17743
|
};
|
|
17457
17744
|
const required = fn("Cli.required")(function* (options, name) {
|
|
17458
17745
|
const value = fromNullishOr(options[name]);
|
|
17459
|
-
return yield* match$
|
|
17746
|
+
return yield* match$3(value, {
|
|
17460
17747
|
onNone: () => new MissingOption({ option: name }),
|
|
17461
17748
|
onSome: succeed
|
|
17462
17749
|
});
|
|
@@ -17750,6 +18037,41 @@ const catalog = [
|
|
|
17750
18037
|
dataKey: "",
|
|
17751
18038
|
example: "adiff review open --repo ."
|
|
17752
18039
|
},
|
|
18040
|
+
{
|
|
18041
|
+
name: "review pane",
|
|
18042
|
+
about: "Open the review beside the conversation, in whichever multiplexer is running. Answers with the command when none is",
|
|
18043
|
+
safety: "read",
|
|
18044
|
+
options: [repo],
|
|
18045
|
+
dataKey: "pane",
|
|
18046
|
+
example: "adiff review pane --repo ."
|
|
18047
|
+
},
|
|
18048
|
+
{
|
|
18049
|
+
name: "init",
|
|
18050
|
+
about: "Write the review loop into this repository's agent instructions, so an agent finds it unprompted",
|
|
18051
|
+
safety: "write",
|
|
18052
|
+
options: [
|
|
18053
|
+
{
|
|
18054
|
+
name: "repo",
|
|
18055
|
+
required: true,
|
|
18056
|
+
value: "path",
|
|
18057
|
+
about: "Repository to write the loop into"
|
|
18058
|
+
},
|
|
18059
|
+
{
|
|
18060
|
+
name: "write",
|
|
18061
|
+
required: false,
|
|
18062
|
+
value: "flag",
|
|
18063
|
+
about: "Make the changes. Without it, init reports what each file would become"
|
|
18064
|
+
},
|
|
18065
|
+
{
|
|
18066
|
+
name: "skill",
|
|
18067
|
+
required: false,
|
|
18068
|
+
value: "flag",
|
|
18069
|
+
about: "Also commit the adiff skill at .claude/skills/adiff/SKILL.md"
|
|
18070
|
+
}
|
|
18071
|
+
],
|
|
18072
|
+
dataKey: "changes",
|
|
18073
|
+
example: "adiff init --repo . --write"
|
|
18074
|
+
},
|
|
17753
18075
|
{
|
|
17754
18076
|
name: "describe",
|
|
17755
18077
|
about: "This catalog, as JSON",
|
|
@@ -17812,6 +18134,11 @@ const ADVICE = {
|
|
|
17812
18134
|
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
18135
|
retriable: false
|
|
17814
18136
|
},
|
|
18137
|
+
InitUnwritable: {
|
|
18138
|
+
exit: 1,
|
|
18139
|
+
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.",
|
|
18140
|
+
retriable: false
|
|
18141
|
+
},
|
|
17815
18142
|
UnselectableRange: {
|
|
17816
18143
|
exit: 2,
|
|
17817
18144
|
suggestion: "Those lines are not in the diff. Check --side: new is the working tree, old is the version being replaced.",
|
|
@@ -17991,7 +18318,7 @@ const spansOf = (patch, total) => {
|
|
|
17991
18318
|
trailing
|
|
17992
18319
|
];
|
|
17993
18320
|
};
|
|
17994
|
-
const linesFrom = (build, from, to) => build.full === void 0 || to < from ? [] : build.full.rows.filter((row) => match$
|
|
18321
|
+
const linesFrom = (build, from, to) => build.full === void 0 || to < from ? [] : build.full.rows.filter((row) => match$3(row.newLine, {
|
|
17995
18322
|
onNone: () => false,
|
|
17996
18323
|
onSome: (line) => line >= from && line <= to
|
|
17997
18324
|
}));
|
|
@@ -18413,7 +18740,7 @@ const hiddenLines = (state) => shownOf(state)?.gaps.reduce((total, gap) => total
|
|
|
18413
18740
|
const markedRows = (state) => {
|
|
18414
18741
|
const patch = selectedPatch(state);
|
|
18415
18742
|
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$
|
|
18743
|
+
const rows = state.pending.filter((entry) => entry.file === patch.path).flatMap((entry) => patch.rows.filter((row) => match$3(row.newLine, {
|
|
18417
18744
|
onNone: () => false,
|
|
18418
18745
|
onSome: (line) => line >= entry.start && line <= entry.end
|
|
18419
18746
|
})).map((row) => row.index));
|
|
@@ -18428,7 +18755,7 @@ const selectedRows = (state) => {
|
|
|
18428
18755
|
};
|
|
18429
18756
|
const snippetOf = (state, limit) => selectedRows(state).slice(0, limit).map((row) => `${lineOf(row).padStart(4)} ${row.text}`);
|
|
18430
18757
|
const selectedLineCount = (state) => selectedRows(state).length;
|
|
18431
|
-
const lineOf = (row) => match$
|
|
18758
|
+
const lineOf = (row) => match$3(row.newLine, {
|
|
18432
18759
|
onNone: () => "-",
|
|
18433
18760
|
onSome: (line) => String(line)
|
|
18434
18761
|
});
|
|
@@ -18443,7 +18770,7 @@ const composeTarget = (state) => {
|
|
|
18443
18770
|
if (patch === void 0) return "";
|
|
18444
18771
|
const [from, to] = selectionRange(state);
|
|
18445
18772
|
const anchor = anchorFor(patch, from, to);
|
|
18446
|
-
const span = match$
|
|
18773
|
+
const span = match$3(anchor, {
|
|
18447
18774
|
onNone: () => "",
|
|
18448
18775
|
onSome: (found) => found.start === found.end ? `${found.start}` : `${found.start}-${found.end}`
|
|
18449
18776
|
});
|
|
@@ -18543,7 +18870,7 @@ const sourceLineAt = (state, row) => {
|
|
|
18543
18870
|
return getOrUndefined$1(found.newLine) ?? getOrUndefined$1(found.oldLine);
|
|
18544
18871
|
};
|
|
18545
18872
|
const rowAtSourceLine = (patch, line) => {
|
|
18546
|
-
return patch.rows.find((row) => match$
|
|
18873
|
+
return patch.rows.find((row) => match$3(row.newLine, {
|
|
18547
18874
|
onNone: () => false,
|
|
18548
18875
|
onSome: (value) => value >= line
|
|
18549
18876
|
}))?.index ?? 0;
|
|
@@ -21416,7 +21743,7 @@ var App = class {
|
|
|
21416
21743
|
return getUnsafe(this.held);
|
|
21417
21744
|
}
|
|
21418
21745
|
write(next) {
|
|
21419
|
-
runSync(set(this.held, next));
|
|
21746
|
+
runSync(set$1(this.held, next));
|
|
21420
21747
|
}
|
|
21421
21748
|
commit(next) {
|
|
21422
21749
|
const appeared = next.notice.length > 0 && next.notice !== this.state.notice;
|
|
@@ -22064,6 +22391,26 @@ const documentAt = fn("Main.documentAt")(function* (source) {
|
|
|
22064
22391
|
catch: (cause) => new MalformedLayers({ reason: String(cause) })
|
|
22065
22392
|
});
|
|
22066
22393
|
});
|
|
22394
|
+
const layersSet = fn("Main.layersSet")(function* (options) {
|
|
22395
|
+
const document = yield* documentAt(yield* required(options, "json"));
|
|
22396
|
+
const layers = yield* setLayers(yield* required(options, "worktree"), document, options["at"] ?? (/* @__PURE__ */ new Date()).toISOString());
|
|
22397
|
+
yield* answer(options, { layers });
|
|
22398
|
+
});
|
|
22399
|
+
const layersShow = fn("Main.layersShow")(function* (options) {
|
|
22400
|
+
const layers = yield* showLayers(yield* required(options, "worktree"));
|
|
22401
|
+
yield* answer(options, { layers });
|
|
22402
|
+
});
|
|
22403
|
+
const init = fn("Main.init")(function* (options) {
|
|
22404
|
+
const report = yield* initRepository({
|
|
22405
|
+
repo: yield* required(options, "repo"),
|
|
22406
|
+
write: options["write"] !== void 0,
|
|
22407
|
+
skill: options["skill"] !== void 0
|
|
22408
|
+
});
|
|
22409
|
+
yield* answer(options, {
|
|
22410
|
+
wrote: report.wrote,
|
|
22411
|
+
changes: report.changes
|
|
22412
|
+
});
|
|
22413
|
+
});
|
|
22067
22414
|
const routes = {
|
|
22068
22415
|
"branch list": branchList,
|
|
22069
22416
|
"comment add": commentAdd,
|
|
@@ -22075,16 +22422,18 @@ const routes = {
|
|
|
22075
22422
|
"comment threads": commentThreads,
|
|
22076
22423
|
"comment resolve": commentResolve,
|
|
22077
22424
|
"review submit": reviewSubmit,
|
|
22078
|
-
"review
|
|
22079
|
-
|
|
22080
|
-
|
|
22081
|
-
|
|
22082
|
-
|
|
22083
|
-
|
|
22084
|
-
|
|
22085
|
-
const layers = yield* showLayers(yield* required(options, "worktree"));
|
|
22086
|
-
yield* answer(options, { layers });
|
|
22425
|
+
"review pane": fn("Main.reviewPane")(function* (options) {
|
|
22426
|
+
const report = yield* openPane(yield* required(options, "repo"));
|
|
22427
|
+
yield* answer(options, {
|
|
22428
|
+
opened: report.opened,
|
|
22429
|
+
pane: report.pane,
|
|
22430
|
+
command: report.command
|
|
22431
|
+
});
|
|
22087
22432
|
}),
|
|
22433
|
+
"review progress": reviewStatus,
|
|
22434
|
+
"layers set": layersSet,
|
|
22435
|
+
"layers show": layersShow,
|
|
22436
|
+
init,
|
|
22088
22437
|
describe: fn("Main.describe")(function* (options) {
|
|
22089
22438
|
const wanted = options["command"];
|
|
22090
22439
|
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
|
+
"version": "0.1.0-alpha.28",
|
|
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": {
|
package/skills/adiff/SKILL.md
CHANGED
|
@@ -156,11 +156,32 @@ Setting a layers again supersedes the previous one and bumps `version`; the laye
|
|
|
156
156
|
it was written for, and adiff reports it as `stale` once the branch moves past that commit. After
|
|
157
157
|
you address a review, write the layers again.
|
|
158
158
|
|
|
159
|
+
## Put the review in front of them
|
|
160
|
+
|
|
161
|
+
When someone asks you for a review, open it rather than describing how:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
adiff review pane --repo <repo>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
It splits the pane they are already looking at, so their next move is to look right rather than to
|
|
168
|
+
type. The answer says what happened:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api"}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
`opened:false` means nothing could be split, which is ordinary: a terminal without tmux, Zellij,
|
|
175
|
+
WezTerm or kitty has nowhere to put a pane. The answer carries `command` either way, so quote that
|
|
176
|
+
line and let them run it.
|
|
177
|
+
|
|
178
|
+
Open a pane when a review was asked for. Finishing work is not a reason on its own, and taking over
|
|
179
|
+
someone's screen uninvited is worse than a line they have to copy.
|
|
180
|
+
|
|
159
181
|
## Tell the reviewer how to read it
|
|
160
182
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
worktree belongs to:
|
|
183
|
+
Whether or not a pane opened, say what to do with it. Name the repository they should point at,
|
|
184
|
+
which is the repository the worktree belongs to:
|
|
164
185
|
|
|
165
186
|
> Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
|
|
166
187
|
> lists the layers in reading order; `j` and `k` move between them and the diff follows. Inside a
|