@eliya-oss/agent-diff 0.1.0-alpha.31 → 0.1.0-alpha.33

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.
@@ -17,6 +17,7 @@ the way it is, why it is tested the way it is. ADRs explain choices that outlive
17
17
  | [ADR-004](ADR-004-pnpm-native-releases.md) | pnpm's own release tooling instead of Changesets |
18
18
  | [ADR-005](ADR-005-a-mechanical-style-contract.md) | Style is a lint rule, not a document |
19
19
  | [ADR-006](ADR-006-the-terminal-runs-on-effect.md) | The terminal runs on Effect |
20
+ | [ADR-007](ADR-007-model-with-effect-not-only-run-on-it.md) | Model with Effect, not only run on it |
20
21
 
21
22
  ## Writing one
22
23
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @eliya-oss/agent-diff
2
2
 
3
+ ## 0.1.0-alpha.33
4
+
5
+ ### Patch Changes
6
+
7
+ - The store reports a damaged file instead of failing unexpectedly.
8
+
9
+ ## 0.1.0-alpha.32
10
+
11
+ ### Patch Changes
12
+
13
+ - The skill publishes a reading order on request, and tells the reviewer how to open the review.
14
+
3
15
  ## 0.1.0-alpha.31
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  # adiff
4
4
 
5
- A code review your agent can answer. You select lines in the terminal and comment; the agent picks
6
- each comment up by its id, does the work, and answers under your own words. A point stays open until
7
- you settle it.
5
+ An agent finishes a piece of work and leaves you a diff. You read it without knowing why any of it
6
+ was written that way, and asking means describing a line back in prose and reading the reply
7
+ somewhere far from the code it concerns. On a large change you carry the whole review in your head,
8
+ and it ends when your patience does.
9
+
10
+ adiff puts the conversation on the code. You comment on the lines in a terminal, the agent that
11
+ wrote them answers under your words, and a point stays open until you settle it.
8
12
 
9
13
  The agent can also hand you a reading order: its own diff in layers, a note on each, and a coverage
10
14
  check so nothing is quietly left out of the story.
@@ -64,7 +68,8 @@ A comment is handed over exactly once, so a second `take` returns only what was
64
68
  ## The reading order
65
69
 
66
70
  An agent knows the order it built a change in. Rebuilding that order by reading forty files is the
67
- expensive way to learn something it already has, so it can publish the reading itself:
71
+ expensive way to learn something it already has, so it can publish the reading itself when you ask
72
+ for one:
68
73
 
69
74
  ```bash
70
75
  adiff layers set --worktree . --json -
package/dist/main.js CHANGED
@@ -490,6 +490,71 @@ function isBoolean(input) {
490
490
  return typeof input === "boolean";
491
491
  }
492
492
  /**
493
+ * Checks whether a value is a `symbol`.
494
+ *
495
+ * **When to use**
496
+ *
497
+ * Use when you need a `Predicate` guard to narrow an `unknown` value to a
498
+ * symbol.
499
+ *
500
+ * **Details**
501
+ *
502
+ * Uses `typeof input === "symbol"`.
503
+ *
504
+ * **Example** (Guarding symbols)
505
+ *
506
+ * ```ts
507
+ * import { Predicate } from "effect"
508
+ *
509
+ * const data: unknown = Symbol.for("id")
510
+ *
511
+ * if (Predicate.isSymbol(data)) {
512
+ * console.log(data.description)
513
+ * }
514
+ * ```
515
+ *
516
+ * @see {@link isPropertyKey}
517
+ * @category guards
518
+ * @since 2.0.0
519
+ */
520
+ function isSymbol(input) {
521
+ return typeof input === "symbol";
522
+ }
523
+ /**
524
+ * Checks whether a value is a valid `PropertyKey` (string, number, or symbol).
525
+ *
526
+ * **When to use**
527
+ *
528
+ * Use when you need a `Predicate` guard for unknown property keys before
529
+ * indexing.
530
+ *
531
+ * **Details**
532
+ *
533
+ * Uses `isString`, `isNumber`, and `isSymbol`.
534
+ *
535
+ * **Example** (Guarding property keys)
536
+ *
537
+ * ```ts
538
+ * import { Predicate } from "effect"
539
+ *
540
+ * const key: unknown = "name"
541
+ * const obj: Record<PropertyKey, unknown> = { name: "Ada" }
542
+ *
543
+ * if (Predicate.isPropertyKey(key) && key in obj) {
544
+ * console.log(obj[key])
545
+ * }
546
+ * ```
547
+ *
548
+ * @see {@link isString}
549
+ * @see {@link isNumber}
550
+ * @see {@link isSymbol}
551
+ * @category guards
552
+ * @since 4.0.0
553
+ */
554
+ function isPropertyKey(u) {
555
+ return isString(u) || isNumber(u) || isSymbol(u);
556
+ }
557
+ /**
493
558
  * Checks whether a value is a `function`.
494
559
  *
495
560
  * **When to use**
@@ -11251,6 +11316,9 @@ const passthrough_$1 = /*#__PURE__*/ new Getter(succeed);
11251
11316
  function isPassthrough(getter) {
11252
11317
  return getter.run === passthrough_$1.run;
11253
11318
  }
11319
+ function passthrough$1() {
11320
+ return passthrough_$1;
11321
+ }
11254
11322
  /**
11255
11323
  * Creates a getter that applies a pure function to present values.
11256
11324
  *
@@ -11443,6 +11511,80 @@ var Transformation = class Transformation {
11443
11511
  }
11444
11512
  };
11445
11513
  /**
11514
+ * Returns `true` if `u` is a `Transformation` instance.
11515
+ *
11516
+ * **When to use**
11517
+ *
11518
+ * Use to check whether a value is already a schema transformation before
11519
+ * wrapping it.
11520
+ *
11521
+ * **Details**
11522
+ *
11523
+ * - Pure predicate, no side effects.
11524
+ * - Acts as a TypeScript type guard.
11525
+ *
11526
+ * **Example** (Checking a value)
11527
+ *
11528
+ * ```ts
11529
+ * import { SchemaTransformation } from "effect"
11530
+ *
11531
+ * SchemaTransformation.isTransformation(SchemaTransformation.trim())
11532
+ * // true
11533
+ *
11534
+ * SchemaTransformation.isTransformation({ decode: null, encode: null })
11535
+ * // false
11536
+ * ```
11537
+ *
11538
+ * @see {@link Transformation}
11539
+ * @see {@link make}
11540
+ *
11541
+ * @category guards
11542
+ * @since 4.0.0
11543
+ */
11544
+ function isTransformation(u) {
11545
+ return hasProperty(u, TypeId$9) && u[TypeId$9] === TypeId$9;
11546
+ }
11547
+ /**
11548
+ * Constructs a `Transformation` from an object with `decode` and `encode`
11549
+ * `Getter`s. If the input is already a `Transformation`, returns it as-is.
11550
+ *
11551
+ * **When to use**
11552
+ *
11553
+ * Use when you already have schema getter instances and want to pair them into
11554
+ * a schema transformation.
11555
+ * - You want idempotent wrapping (won't double-wrap).
11556
+ *
11557
+ * **Details**
11558
+ *
11559
+ * - Returns the input unchanged if it is already a `Transformation`.
11560
+ *
11561
+ * **Example** (Wrapping existing getters)
11562
+ *
11563
+ * ```ts
11564
+ * import { SchemaGetter, SchemaTransformation } from "effect"
11565
+ *
11566
+ * const t = SchemaTransformation.make({
11567
+ * decode: SchemaGetter.transform<number, string>((s) => Number(s)),
11568
+ * encode: SchemaGetter.transform<string, number>((n) => String(n))
11569
+ * })
11570
+ * ```
11571
+ *
11572
+ * @see {@link transform} — simpler constructor from pure functions
11573
+ * @see {@link transformOrFail} — constructor from effectful functions
11574
+ * @see {@link Transformation}
11575
+ *
11576
+ * @category constructors
11577
+ * @since 3.10.0
11578
+ */
11579
+ const make$8 = (options) => {
11580
+ if (isTransformation(options)) return options;
11581
+ return new Transformation(options.decode, options.encode);
11582
+ };
11583
+ const passthrough_ = /*#__PURE__*/ new Transformation(/*#__PURE__*/ passthrough$1(), /*#__PURE__*/ passthrough$1());
11584
+ function passthrough() {
11585
+ return passthrough_;
11586
+ }
11587
+ /**
11446
11588
  * Decodes a `string` into a `number` and encodes a `number` back to a
11447
11589
  * `string`.
11448
11590
  *
@@ -11664,6 +11806,59 @@ var Base = class {
11664
11806
  }
11665
11807
  };
11666
11808
  /**
11809
+ * AST node matching the `null` literal value.
11810
+ *
11811
+ * **Details**
11812
+ *
11813
+ * Parsing succeeds only when the input is exactly `null`.
11814
+ *
11815
+ * @see {@link null_ null}
11816
+ * @see {@link isNull}
11817
+ * @category models
11818
+ * @since 4.0.0
11819
+ */
11820
+ var Null = class extends Base {
11821
+ _tag = "Null";
11822
+ /** @internal */
11823
+ getParser() {
11824
+ return fromConst(this, null);
11825
+ }
11826
+ /** @internal */
11827
+ getExpected() {
11828
+ return "null";
11829
+ }
11830
+ };
11831
+ const null_ = /*#__PURE__*/ new Null();
11832
+ /**
11833
+ * AST node matching the `undefined` value.
11834
+ *
11835
+ * **Details**
11836
+ *
11837
+ * Parsing succeeds only when the input is exactly `undefined`.
11838
+ *
11839
+ * @see {@link undefined}
11840
+ * @see {@link isUndefined}
11841
+ * @category models
11842
+ * @since 4.0.0
11843
+ */
11844
+ var Undefined$1 = class extends Base {
11845
+ _tag = "Undefined";
11846
+ /** @internal */
11847
+ getParser() {
11848
+ return fromConst(this, void 0);
11849
+ }
11850
+ /** @internal */
11851
+ toCodecJson() {
11852
+ return replaceEncoding(this, [undefinedToNull]);
11853
+ }
11854
+ /** @internal */
11855
+ getExpected() {
11856
+ return "undefined";
11857
+ }
11858
+ };
11859
+ const undefinedToNull = /*#__PURE__*/ new Link(null_, /*#__PURE__*/ new Transformation(/*#__PURE__*/ transform$1(() => void 0), /*#__PURE__*/ transform$1(() => null)));
11860
+ const undefined_ = /*#__PURE__*/ new Undefined$1();
11861
+ /**
11667
11862
  * AST node matching an exact primitive value (string, number, boolean, or
11668
11863
  * bigint).
11669
11864
  *
@@ -12071,6 +12266,32 @@ var PropertySignature = class {
12071
12266
  this.type = type;
12072
12267
  }
12073
12268
  };
12269
+ /**
12270
+ * Represents a bidirectional merge strategy for index signature key-value pairs.
12271
+ *
12272
+ * **Details**
12273
+ *
12274
+ * Used by {@link IndexSignature} when the same key appears multiple times
12275
+ * (e.g. from `Schema.extend` or overlapping records). Provides separate
12276
+ * `decode` and `encode` combiners that determine how duplicate entries are
12277
+ * merged.
12278
+ *
12279
+ * @see {@link IndexSignature}
12280
+ * @category models
12281
+ * @since 4.0.0
12282
+ */
12283
+ var KeyValueCombiner = class KeyValueCombiner {
12284
+ decode;
12285
+ encode;
12286
+ constructor(decode, encode) {
12287
+ this.decode = decode;
12288
+ this.encode = encode;
12289
+ }
12290
+ /** @internal */
12291
+ flip() {
12292
+ return new KeyValueCombiner(this.encode, this.decode);
12293
+ }
12294
+ };
12074
12295
  function isIndexSignatureParameterSide(ast) {
12075
12296
  switch (ast._tag) {
12076
12297
  case "String":
@@ -12338,6 +12559,14 @@ function struct(fields, checks, annotations) {
12338
12559
  return new PropertySignature(key, fields[key].ast);
12339
12560
  }), [], annotations, checks);
12340
12561
  }
12562
+ /** @internal */
12563
+ function getAST(self) {
12564
+ return self.ast;
12565
+ }
12566
+ /** @internal */
12567
+ function union(members, mode, checks) {
12568
+ return new Union$1(members.map(getAST), mode, void 0, checks);
12569
+ }
12341
12570
  function getCandidateTypes(ast) {
12342
12571
  switch (ast._tag) {
12343
12572
  case "Null": return ["null"];
@@ -12825,12 +13054,20 @@ function updateLastLink(encoding, f) {
12825
13054
  return out === last ? encoding : append$1(encoding.slice(0, encoding.length - 1), out);
12826
13055
  }
12827
13056
  /** @internal */
13057
+ function applyToLastLink(f) {
13058
+ return (ast) => ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, f)) : ast;
13059
+ }
13060
+ /** @internal */
12828
13061
  function applyToSelfOrLastLinkEncoding(f) {
12829
13062
  function out(ast) {
12830
13063
  return ast.encoding ? replaceEncoding(ast, updateLastLink(ast.encoding, out)) : f(ast);
12831
13064
  }
12832
13065
  return memoize(out);
12833
13066
  }
13067
+ function appendTransformation(from, transformation, to) {
13068
+ const link = new Link(from, transformation);
13069
+ return replaceEncoding(to, to.encoding ? [...to.encoding, link] : [link]);
13070
+ }
12834
13071
  /** @internal */
12835
13072
  function brand$1(ast, brand) {
12836
13073
  const existing = resolveBrands(ast);
@@ -12854,6 +13091,75 @@ function annotateKey(ast, annotations) {
12854
13091
  ...annotations
12855
13092
  }) : new Context(false, false, void 0, annotations));
12856
13093
  }
13094
+ const optionalKeyLastLink = /*#__PURE__*/ applyToLastLink(optionalKey$1);
13095
+ /**
13096
+ * Marks an AST node's property key as optional by setting
13097
+ * {@link Context.isOptional} to `true`.
13098
+ *
13099
+ * **Details**
13100
+ *
13101
+ * Also propagates the optional flag through the last link of the encoding
13102
+ * chain if present.
13103
+ *
13104
+ * @see {@link isOptional}
13105
+ * @see {@link Context}
13106
+ * @category transforming
13107
+ * @since 4.0.0
13108
+ */
13109
+ function optionalKey$1(ast) {
13110
+ const context = ast.context ? ast.context.isOptional === false ? new Context(true, ast.context.isMutable, ast.context.defaultValue, ast.context.annotations) : ast.context : new Context(true, false);
13111
+ return optionalKeyLastLink(replaceContext(ast, context));
13112
+ }
13113
+ /**
13114
+ * Attaches a `Transformation` to the `to` AST, making it decode from the
13115
+ * `from` AST and encode back to it.
13116
+ *
13117
+ * **Details**
13118
+ *
13119
+ * This is the low-level primitive behind `Schema.transform` and
13120
+ * `Schema.transformOrFail`. It appends a {@link Link} to the `to` node's
13121
+ * encoding chain.
13122
+ *
13123
+ * - Returns a new AST with the same type as `to`.
13124
+ *
13125
+ * @see {@link Link}
13126
+ * @see {@link Encoding}
13127
+ * @see {@link flip}
13128
+ * @category transforming
13129
+ * @since 4.0.0
13130
+ */
13131
+ function decodeTo$1(from, to, transformation) {
13132
+ return appendTransformation(from, transformation, to);
13133
+ }
13134
+ function parseParameter(ast) {
13135
+ const literals = [];
13136
+ const parameters = [];
13137
+ function go(ast) {
13138
+ switch (ast._tag) {
13139
+ case "Literal":
13140
+ if (isPropertyKey(ast.literal)) literals.push(ast.literal);
13141
+ return;
13142
+ case "UniqueSymbol":
13143
+ literals.push(ast.symbol);
13144
+ return;
13145
+ case "Never": return;
13146
+ case "Union":
13147
+ for (let i = 0; i < ast.types.length; i++) go(ast.types[i]);
13148
+ return;
13149
+ default: parameters.push(ast);
13150
+ }
13151
+ }
13152
+ go(ast);
13153
+ return {
13154
+ literals,
13155
+ parameters
13156
+ };
13157
+ }
13158
+ /** @internal */
13159
+ function record(key, value, keyValueCombiner) {
13160
+ const { literals, parameters: indexSignatures } = parseParameter(key);
13161
+ return new Objects(literals.map((literal) => new PropertySignature(literal, value)), indexSignatures.map((parameter) => new IndexSignature(parameter, value, keyValueCombiner)));
13162
+ }
12857
13163
  /**
12858
13164
  * Returns `true` if the AST node represents an optional property.
12859
13165
  *
@@ -15716,6 +16022,67 @@ function decodeUnknownEffect(schema, options) {
15716
16022
  */
15717
16023
  const make$1 = make$2;
15718
16024
  /**
16025
+ * Creates an exact optional key schema for struct fields. Unlike `optional`,
16026
+ * this creates exact optional properties (not `| undefined`) that can be
16027
+ * completely omitted from the object.
16028
+ *
16029
+ * **Example** (Creating a struct with optional key)
16030
+ *
16031
+ * ```ts
16032
+ * import { Schema } from "effect"
16033
+ *
16034
+ * const schema = Schema.Struct({
16035
+ * name: Schema.String,
16036
+ * age: Schema.optionalKey(Schema.Number)
16037
+ * })
16038
+ *
16039
+ * // Type: { readonly name: string; readonly age?: number }
16040
+ * type Person = typeof schema["Type"]
16041
+ * ```
16042
+ *
16043
+ * @category combinators
16044
+ * @since 4.0.0
16045
+ */
16046
+ const optionalKey = /*#__PURE__*/ lambda((schema) => make$1(optionalKey$1(schema.ast), { schema }));
16047
+ /**
16048
+ * Creates a schema for a single literal value (string, number, bigint, boolean, or null).
16049
+ *
16050
+ * **Example** (Defining a string literal)
16051
+ *
16052
+ * ```ts
16053
+ * import { Schema } from "effect"
16054
+ *
16055
+ * const schema = Schema.Literal("hello")
16056
+ * // Type: Schema.Literal<"hello">
16057
+ * ```
16058
+ *
16059
+ * @see {@link Literals} for a schema that represents a union of literals.
16060
+ * @see {@link tag} for a schema that represents a literal value that can be
16061
+ * used as a discriminator field in tagged unions and has a constructor default.
16062
+ * @category constructors
16063
+ * @since 3.10.0
16064
+ */
16065
+ function Literal(literal) {
16066
+ const out = make$1(new Literal$1(literal), {
16067
+ literal,
16068
+ transform(to) {
16069
+ return out.pipe(decodeTo(Literal(to), {
16070
+ decode: transform$1(() => to),
16071
+ encode: transform$1(() => literal)
16072
+ }));
16073
+ }
16074
+ });
16075
+ return out;
16076
+ }
16077
+ /**
16078
+ * Schema for the `undefined` literal. Validates that the input is strictly `undefined`.
16079
+ *
16080
+ * @see {@link UndefinedOr} for a union with another schema.
16081
+ * @category schemas
16082
+ * @since 3.10.0
16083
+ */
16084
+ const Undefined = /*#__PURE__*/ make$1(undefined_);
16085
+ /**
15719
16086
  * Schema for `string` values. Validates that the input is `typeof` `"string"`.
15720
16087
  *
15721
16088
  * @category schemas
@@ -15723,6 +16090,21 @@ const make$1 = make$2;
15723
16090
  */
15724
16091
  const String$1 = /*#__PURE__*/ make$1(string);
15725
16092
  /**
16093
+ * Schema for `number` values, including `NaN`, `Infinity`, and `-Infinity`.
16094
+ *
16095
+ * **Details**
16096
+ *
16097
+ * Default JSON serializer:
16098
+ *
16099
+ * - Finite numbers are serialized as numbers.
16100
+ * - Non-finite values are serialized as strings (`"NaN"`, `"Infinity"`, `"-Infinity"`).
16101
+ *
16102
+ * @see {@link Finite} for a schema that excludes non-finite values.
16103
+ * @category schemas
16104
+ * @since 4.0.0
16105
+ */
16106
+ const Number$1 = /*#__PURE__*/ make$1(number);
16107
+ /**
15726
16108
  * Schema for `boolean` values. Validates that the input is `typeof` `"boolean"`.
15727
16109
  *
15728
16110
  * **When to use**
@@ -15781,10 +16163,124 @@ function Struct(fields) {
15781
16163
  return makeStruct(struct(fields, void 0), fields);
15782
16164
  }
15783
16165
  /**
16166
+ * Defines a record schema whose dynamic properties are selected by a key schema
16167
+ * and decoded with a value schema.
16168
+ *
16169
+ * **Details**
16170
+ *
16171
+ * For dynamic keys, the key schema selects matching own properties and the
16172
+ * value schema decodes or encodes only those selected properties. Checks on
16173
+ * string, number, symbol, and template literal key schemas narrow which
16174
+ * properties are selected.
16175
+ *
16176
+ * For transformed key schemas, property selection is based on encoded property
16177
+ * names before the selected key is decoded.
16178
+ *
16179
+ * **Example** (Defining a string-keyed record of numbers)
16180
+ *
16181
+ * ```ts
16182
+ * import { Schema } from "effect"
16183
+ *
16184
+ * const schema = Schema.Record(Schema.String, Schema.Number)
16185
+ *
16186
+ * // { readonly [x: string]: number }
16187
+ * type R = typeof schema.Type
16188
+ *
16189
+ * const result = Schema.decodeUnknownSync(schema)({ a: 1, b: 2 })
16190
+ * console.log(result)
16191
+ * // { a: 1, b: 2 }
16192
+ * ```
16193
+ *
16194
+ * @category constructors
16195
+ * @since 3.10.0
16196
+ */
16197
+ function Record(key, value, options) {
16198
+ const keyValueCombiner = options?.keyValueCombiner?.decode || options?.keyValueCombiner?.encode ? new KeyValueCombiner(options.keyValueCombiner.decode, options.keyValueCombiner.encode) : void 0;
16199
+ return make$1(record(key.ast, value.ast, keyValueCombiner), {
16200
+ key,
16201
+ value
16202
+ });
16203
+ }
16204
+ /**
15784
16205
  * @category constructors
15785
16206
  * @since 4.0.0
15786
16207
  */
15787
16208
  const ArraySchema = /*#__PURE__*/ lambda((schema) => make$1(new Arrays(false, [], [schema.ast]), { value: schema }));
16209
+ function makeUnion(ast, members) {
16210
+ return make$1(ast, {
16211
+ members,
16212
+ mapMembers(f, options) {
16213
+ const members = f(this.members);
16214
+ return makeUnion(union(members, this.ast.mode, options?.unsafePreserveChecks ? this.ast.checks : void 0), members);
16215
+ }
16216
+ });
16217
+ }
16218
+ /**
16219
+ * Creates a union schema from an array of member schemas. Members are tested in
16220
+ * order; the first match is returned.
16221
+ *
16222
+ * **Details**
16223
+ *
16224
+ * Optionally, specify `mode`:
16225
+ * - `"anyOf"` (default) — matches if any member matches.
16226
+ * - `"oneOf"` — matches if exactly one member matches.
16227
+ *
16228
+ * **Example** (Defining a string or number union)
16229
+ *
16230
+ * ```ts
16231
+ * import { Schema } from "effect"
16232
+ *
16233
+ * const schema = Schema.Union([Schema.String, Schema.Number])
16234
+ *
16235
+ * Schema.decodeUnknownSync(schema)("hello") // "hello"
16236
+ * Schema.decodeUnknownSync(schema)(42) // 42
16237
+ * ```
16238
+ *
16239
+ * @category constructors
16240
+ * @since 3.10.0
16241
+ */
16242
+ function Union(members, options) {
16243
+ return makeUnion(union(members, options?.mode ?? "anyOf", void 0), members);
16244
+ }
16245
+ /**
16246
+ * Creates a union schema from an array of literal values.
16247
+ *
16248
+ * **Example** (Defining status codes)
16249
+ *
16250
+ * ```ts
16251
+ * import { Schema } from "effect"
16252
+ *
16253
+ * const schema = Schema.Literals(["active", "inactive", "pending"])
16254
+ * // accepts "active", "inactive", or "pending"
16255
+ * ```
16256
+ *
16257
+ * @see {@link Literal} for a schema that represents a single literal.
16258
+ * @category constructors
16259
+ * @since 4.0.0
16260
+ */
16261
+ function Literals(literals) {
16262
+ const members = literals.map(Literal);
16263
+ return make$1(union(members, "anyOf", void 0), {
16264
+ literals,
16265
+ members,
16266
+ mapMembers(f) {
16267
+ return Union(f(this.members));
16268
+ },
16269
+ pick(literals) {
16270
+ return Literals(literals);
16271
+ },
16272
+ transform(to) {
16273
+ return Union(members.map((member, index) => member.transform(to[index])));
16274
+ }
16275
+ });
16276
+ }
16277
+ /**
16278
+ * Creates a union schema of `S | undefined`.
16279
+ *
16280
+ * @category constructors
16281
+ * @since 3.10.0
16282
+ */
16283
+ const UndefinedOr = /*#__PURE__*/ lambda((self) => Union([self, Undefined]));
15788
16284
  /**
15789
16285
  * Adds a nominal brand to a schema, intersecting the output type with
15790
16286
  * `Brand.Brand<B>` to prevent accidental mixing of structurally identical types.
@@ -15810,6 +16306,111 @@ function brand(identifier) {
15810
16306
  identifier
15811
16307
  });
15812
16308
  }
16309
+ function decodeTo(to, transformation) {
16310
+ return (from) => {
16311
+ return make$1(decodeTo$1(from.ast, to.ast, transformation ? make$8(transformation) : passthrough()), {
16312
+ from,
16313
+ to
16314
+ });
16315
+ };
16316
+ }
16317
+ /**
16318
+ * Creates a custom validation filter from a predicate function.
16319
+ *
16320
+ * **Details**
16321
+ *
16322
+ * The predicate receives the decoded input value, the schema AST, and parse
16323
+ * options, and returns a `FilterOutput`. Non-success outputs are normalized into
16324
+ * schema issues. The `annotations` parameter annotates the filter itself; with
16325
+ * the default formatter, failures use `message` first, `expected` second, and
16326
+ * `<filter>` when neither is provided.
16327
+ *
16328
+ * When `abort` is `true`, parsing stops after this filter fails instead of
16329
+ * collecting later check failures.
16330
+ *
16331
+ * **Example** (Reporting failure at a nested path)
16332
+ *
16333
+ * ```ts
16334
+ * import { Schema } from "effect"
16335
+ *
16336
+ * const schema = Schema.Struct({ password: Schema.String, confirmPassword: Schema.String }).check(
16337
+ * Schema.makeFilter((o) =>
16338
+ * o.password === o.confirmPassword
16339
+ * ? undefined
16340
+ * : { path: ["password"], issue: "password and confirmPassword must match" }
16341
+ * )
16342
+ * )
16343
+ *
16344
+ * console.log(String(Schema.decodeUnknownExit(schema)({ password: "123456", confirmPassword: "1234567" })))
16345
+ * // Failure(Cause([Fail(SchemaError: password and confirmPassword must match
16346
+ * // at ["password"])]))
16347
+ * ```
16348
+ *
16349
+ * **Example** (Reporting multiple failures at once)
16350
+ *
16351
+ * ```ts
16352
+ * import { Schema } from "effect"
16353
+ *
16354
+ * const schema = Schema.Struct({ a: Schema.Finite, b: Schema.Finite, c: Schema.Finite }).check(
16355
+ * Schema.makeFilter((o) => {
16356
+ * const issues: Array<Schema.FilterIssue> = []
16357
+ * if (o.a > 0) {
16358
+ * if (o.b <= 0) issues.push({ path: ["b"], issue: "b must be greater than 0" })
16359
+ * if (o.c <= 0) issues.push({ path: ["c"], issue: "c must be greater than 0" })
16360
+ * }
16361
+ * return issues
16362
+ * })
16363
+ * )
16364
+ *
16365
+ * console.log(String(Schema.decodeUnknownExit(schema)({ a: 1, b: 0, c: 0 })))
16366
+ * // Failure(Cause([Fail(SchemaError: b must be greater than 0
16367
+ * // at ["b"]
16368
+ * // c must be greater than 0
16369
+ * // at ["c"])]))
16370
+ * ```
16371
+ *
16372
+ * @category constructors
16373
+ * @since 4.0.0
16374
+ */
16375
+ const makeFilter = makeFilter$1;
16376
+ /**
16377
+ * Validates that a number is a safe integer (within the safe integer range
16378
+ * that can be exactly represented in JavaScript).
16379
+ *
16380
+ * **Details**
16381
+ *
16382
+ * JSON Schema:
16383
+ *
16384
+ * This check corresponds to the `type: "integer"` constraint in JSON Schema.
16385
+ *
16386
+ * Arbitrary:
16387
+ *
16388
+ * When generating test data with fast-check, this applies an `integer: true`
16389
+ * constraint to ensure generated numbers are integers.
16390
+ *
16391
+ * @category Integer checks
16392
+ * @since 4.0.0
16393
+ */
16394
+ function isInt(annotations) {
16395
+ return makeFilter((n) => globalThis.Number.isSafeInteger(n), {
16396
+ expected: "an integer",
16397
+ representation: {
16398
+ id: "effect/schema/isInt",
16399
+ payload: null
16400
+ },
16401
+ toJsonSchema: () => ({ type: "integer" }),
16402
+ toCode: () => ({ runtime: "Schema.isInt()" }),
16403
+ arbitrary: { constraint: { integer: true } },
16404
+ ...annotations
16405
+ });
16406
+ }
16407
+ /**
16408
+ * Schema for integers, rejecting `NaN`, `Infinity`, and `-Infinity`.
16409
+ *
16410
+ * @category Number
16411
+ * @since 3.10.0
16412
+ */
16413
+ const Int = /*#__PURE__*/ Number$1.check(/*#__PURE__*/ isInt());
15813
16414
  globalThis.RegExp;
15814
16415
  globalThis.URL;
15815
16416
  globalThis.File;
@@ -16609,6 +17210,59 @@ const emptyBranchState = {
16609
17210
  pending: [],
16610
17211
  settled: {}
16611
17212
  };
17213
+ const StoredComment = Struct({
17214
+ id: String$1,
17215
+ anchor: Struct({
17216
+ path: String$1,
17217
+ blob: String$1,
17218
+ snippet: String$1,
17219
+ side: Literals(["old", "new"]),
17220
+ start: Int,
17221
+ end: Int
17222
+ }),
17223
+ body: String$1
17224
+ });
17225
+ const StoredAnswer = Struct({
17226
+ comment: String$1,
17227
+ body: String$1,
17228
+ head: String$1,
17229
+ asks: Boolean,
17230
+ at: String$1
17231
+ });
17232
+ const Batch = Struct({
17233
+ id: String$1,
17234
+ at: String$1,
17235
+ head: String$1,
17236
+ comments: ArraySchema(StoredComment)
17237
+ });
17238
+ const BranchState = Struct({
17239
+ vouches: optionalKey(Record(String$1, String$1)),
17240
+ consumed: optionalKey(Int),
17241
+ pending: optionalKey(ArraySchema(StoredComment)),
17242
+ settled: optionalKey(Record(String$1, String$1))
17243
+ });
17244
+ const Settings = Struct({ wrap: optionalKey(Boolean) });
17245
+ const StoredLayer = Struct({
17246
+ title: String$1,
17247
+ blocks: ArraySchema(Union([Struct({
17248
+ kind: Literal("prose"),
17249
+ markdown: String$1
17250
+ }), Struct({
17251
+ kind: Literal("code"),
17252
+ path: String$1,
17253
+ start: Int,
17254
+ end: Int
17255
+ })]))
17256
+ });
17257
+ const StoredLayers = Struct({
17258
+ version: Int,
17259
+ head: String$1,
17260
+ base: String$1,
17261
+ parent: optionalKey(UndefinedOr(Int)),
17262
+ written: String$1,
17263
+ summary: String$1,
17264
+ layers: ArraySchema(StoredLayer)
17265
+ });
16612
17266
  //#endregion
16613
17267
  //#region src/service/store/paths.ts
16614
17268
  const NON_SLUG = /[^a-zA-Z0-9]+/g;
@@ -16644,15 +17298,44 @@ const readOptional = fn("Store.readOptional")(function* (path) {
16644
17298
  }).pipe(map(some), catchTag("StoreUnreadable", () => missing));
16645
17299
  });
16646
17300
  const missing = succeed(none());
16647
- const parseSettings = (raw) => {
16648
- const parsed = JSON.parse(raw);
16649
- return typeof parsed.wrap === "boolean" ? { wrap: parsed.wrap } : {};
16650
- };
16651
- const parseBatches = (raw) => raw.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
16652
- const parseAnswers = (raw) => raw.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
16653
- const parseState = (raw) => ({
16654
- ...emptyBranchState,
16655
- ...JSON.parse(raw)
17301
+ const damaged = (path) => (reason) => new StoreUnreadable({
17302
+ path,
17303
+ reason: String(reason)
17304
+ });
17305
+ const jsonOf = (path, raw) => try_({
17306
+ try: () => JSON.parse(raw),
17307
+ catch: damaged(path)
17308
+ });
17309
+ const decoded = (schema) => {
17310
+ const decode = decodeUnknownEffect(schema);
17311
+ return (path, value) => mapError(decode(value), damaged(path));
17312
+ };
17313
+ const asSettings = decoded(Settings);
17314
+ const asBatch = decoded(Batch);
17315
+ const asAnswer = decoded(StoredAnswer);
17316
+ const asState = decoded(BranchState);
17317
+ const asLayers = decoded(StoredLayers);
17318
+ const linesOf = (raw) => raw.split("\n").filter((line) => line.trim().length > 0);
17319
+ const readLines = (path, raw, as) => forEach(linesOf(raw), (line) => jsonOf(path, line).pipe(flatMap((value) => as(path, value))));
17320
+ const parseSettings = fn("Store.parseSettings")(function* (path, raw) {
17321
+ const value = yield* jsonOf(path, raw);
17322
+ return yield* asSettings(path, value);
17323
+ });
17324
+ const parseState = fn("Store.parseState")(function* (path, raw) {
17325
+ const value = yield* jsonOf(path, raw);
17326
+ const held = yield* asState(path, value);
17327
+ return {
17328
+ ...emptyBranchState,
17329
+ ...held
17330
+ };
17331
+ });
17332
+ const parseLayers = fn("Store.parseLayers")(function* (path, raw) {
17333
+ const value = yield* jsonOf(path, raw);
17334
+ const held = yield* asLayers(path, value);
17335
+ return {
17336
+ ...held,
17337
+ parent: held.parent
17338
+ };
16656
17339
  });
16657
17340
  const cursorOps = (state, saveState, inbox) => {
16658
17341
  return {
@@ -16700,10 +17383,11 @@ const cursorOps = (state, saveState, inbox) => {
16700
17383
  const settingsOps = (root) => {
16701
17384
  return {
16702
17385
  settings: gen(function* () {
16703
- const raw = yield* readOptional(settingsPath(root));
16704
- return match$3(raw, {
16705
- onNone: () => ({}),
16706
- onSome: parseSettings
17386
+ const path = settingsPath(root);
17387
+ const raw = yield* readOptional(path);
17388
+ return yield* match$3(raw, {
17389
+ onNone: () => succeed({}),
17390
+ onSome: (text) => parseSettings(path, text)
16707
17391
  });
16708
17392
  }).pipe(withSpan("Store.settings")),
16709
17393
  saveSettings: fn("Store.saveSettings")(function* (next) {
@@ -16745,10 +17429,11 @@ const answerOps = (root) => {
16745
17429
  });
16746
17430
  }),
16747
17431
  answers: fn("Store.answers")(function* (worktreePath) {
16748
- const raw = yield* readOptional(outboxPath(root, worktreePath));
16749
- return match$3(raw, {
16750
- onNone: () => [],
16751
- onSome: parseAnswers
17432
+ const path = outboxPath(root, worktreePath);
17433
+ const raw = yield* readOptional(path);
17434
+ return yield* match$3(raw, {
17435
+ onNone: () => succeed([]),
17436
+ onSome: (text) => readLines(path, text, asAnswer)
16752
17437
  });
16753
17438
  })
16754
17439
  };
@@ -16756,8 +17441,10 @@ const answerOps = (root) => {
16756
17441
  const layersOps = (root) => {
16757
17442
  return {
16758
17443
  layers: fn("Store.layers")(function* (worktreePath) {
16759
- const raw = yield* readOptional(layersPath(root, worktreePath));
16760
- return map$4(raw, (text) => JSON.parse(text));
17444
+ const path = layersPath(root, worktreePath);
17445
+ const raw = yield* readOptional(path);
17446
+ if (isNone(raw)) return none();
17447
+ return some(yield* parseLayers(path, raw.value));
16761
17448
  }),
16762
17449
  saveLayers: fn("Store.saveLayers")(function* (worktreePath, next) {
16763
17450
  const path = layersPath(root, worktreePath);
@@ -16772,43 +17459,55 @@ const layersOps = (root) => {
16772
17459
  })
16773
17460
  };
16774
17461
  };
17462
+ const inboxOps = (root) => {
17463
+ return {
17464
+ submit: fn("Store.submit")(function* (worktreePath, batch) {
17465
+ const path = inboxPath(root, worktreePath);
17466
+ yield* ensureDir(branchDir(root, worktreePath));
17467
+ yield* tryPromise({
17468
+ try: () => appendFile(path, `${JSON.stringify(batch)}\n`, "utf8"),
17469
+ catch: (cause) => new StoreUnwritable({
17470
+ path,
17471
+ reason: String(cause)
17472
+ })
17473
+ });
17474
+ }),
17475
+ inbox: fn("Store.inbox")(function* (worktreePath) {
17476
+ const path = inboxPath(root, worktreePath);
17477
+ const raw = yield* readOptional(path);
17478
+ return yield* match$3(raw, {
17479
+ onNone: () => succeed([]),
17480
+ onSome: (text) => readLines(path, text, asBatch)
17481
+ });
17482
+ })
17483
+ };
17484
+ };
17485
+ const stateOps = (root) => {
17486
+ return {
17487
+ state: fn("Store.state")(function* (worktreePath) {
17488
+ const path = statePath(root, worktreePath);
17489
+ const raw = yield* readOptional(path);
17490
+ return yield* match$3(raw, {
17491
+ onNone: () => succeed(emptyBranchState),
17492
+ onSome: (text) => parseState(path, text)
17493
+ });
17494
+ }),
17495
+ saveState: fn("Store.saveState")(function* (worktreePath, next) {
17496
+ const path = statePath(root, worktreePath);
17497
+ yield* ensureDir(branchDir(root, worktreePath));
17498
+ yield* tryPromise({
17499
+ try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
17500
+ catch: (cause) => new StoreUnwritable({
17501
+ path,
17502
+ reason: String(cause)
17503
+ })
17504
+ });
17505
+ })
17506
+ };
17507
+ };
16775
17508
  const makeStore = (root) => {
16776
- const submit = fn("Store.submit")(function* (worktreePath, batch) {
16777
- const path = inboxPath(root, worktreePath);
16778
- yield* ensureDir(branchDir(root, worktreePath));
16779
- yield* tryPromise({
16780
- try: () => appendFile(path, `${JSON.stringify(batch)}\n`, "utf8"),
16781
- catch: (cause) => new StoreUnwritable({
16782
- path,
16783
- reason: String(cause)
16784
- })
16785
- });
16786
- });
16787
- const inbox = fn("Store.inbox")(function* (worktreePath) {
16788
- const raw = yield* readOptional(inboxPath(root, worktreePath));
16789
- return match$3(raw, {
16790
- onNone: () => [],
16791
- onSome: parseBatches
16792
- });
16793
- });
16794
- const state = fn("Store.state")(function* (worktreePath) {
16795
- const raw = yield* readOptional(statePath(root, worktreePath));
16796
- return match$3(raw, {
16797
- onNone: () => emptyBranchState,
16798
- onSome: parseState
16799
- });
16800
- });
16801
- const saveState = fn("Store.saveState")(function* (worktreePath, next) {
16802
- const path = statePath(root, worktreePath);
16803
- yield* ensureDir(branchDir(root, worktreePath));
16804
- yield* tryPromise({
16805
- try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
16806
- catch: (cause) => new StoreUnwritable({
16807
- path,
16808
- reason: String(cause)
16809
- })
16810
- });
16811
- });
17509
+ const { submit, inbox } = inboxOps(root);
17510
+ const { state, saveState } = stateOps(root);
16812
17511
  const cursors = cursorOps(state, saveState, inbox);
16813
17512
  return {
16814
17513
  root,
@@ -17143,8 +17842,11 @@ const INSTRUCTIONS = [
17143
17842
  "",
17144
17843
  "Review of work in this repository happens in adiff. Before you say you are done, run",
17145
17844
  "`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.",
17845
+ "Answer a comment with `adiff comment answer --worktree . --id <id> --body <text>`.",
17846
+ "When you hand work over, say it is ready and name the command that opens the review:",
17847
+ "`adiff review open --repo <repo>`, or `adiff review pane --repo <repo>` to open it alongside.",
17848
+ "Publish a reading order with `adiff layers set` only when you are asked for one.",
17849
+ "`adiff describe` lists the rest.",
17148
17850
  END
17149
17851
  ].join("\n");
17150
17852
  const IMPORT = [
@@ -18223,7 +18925,7 @@ const banner = () => [
18223
18925
  "",
18224
18926
  " adiff comment take --worktree . --wait 300 block until a comment arrives",
18225
18927
  " adiff comment answer --worktree . --id <id> --body '…'",
18226
- " adiff layers set --worktree . --json - publish the reading order",
18928
+ " adiff layers set --worktree . --json - publish a reading order, when asked",
18227
18929
  "",
18228
18930
  "Every comment carries an id, and an answer goes back to the reviewer under it.",
18229
18931
  "",
package/package.json CHANGED
@@ -23,8 +23,8 @@
23
23
  "bin": {
24
24
  "adiff": "./bin/adiff.js"
25
25
  },
26
- "version": "0.1.0-alpha.31",
27
- "description": "A code review your agent can answer: comments carry ids, the agent replies under them, and it publishes the reading order for its own diff.",
26
+ "version": "0.1.0-alpha.33",
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": {
30
30
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: adiff
3
- description: Pick up review comments left on this worktree's diff in the adiff terminal, act on them, and write the layers that explains the diff. Use when the user says they left comments, asks you to check adiff, asks you to watch for review feedback, or asks you to hand work over for review.
3
+ description: Pick up review comments left on this worktree's diff in the adiff terminal, act on them, and answer them by id. Use when the user says they left comments, asks you to check adiff, asks you to watch for review feedback, or asks you to hand work over for review.
4
4
  ---
5
5
 
6
6
  # adiff
@@ -93,11 +93,56 @@ Read `suggestion` before doing anything else — it names the command that resol
93
93
  Retry only when `retriable` is true. `UnknownBranch` means this worktree is not one adiff knows
94
94
  about, because the reviewer has not opened it; report that rather than looping.
95
95
 
96
- ## Handing work over: write the layers
96
+ ## Handing work over
97
97
 
98
- You know the order the change was built in. The reviewer does not, and rebuilding it by reading
99
- every file is the most expensive way to learn something you already have. When you finish a piece
100
- of work, write a **layers**: an ordered set of layers over the diff, each one a claim about a span of
98
+ Finishing is not a reason to publish anything. Say the work is ready, put the review in front of
99
+ them if they asked for one, and say how to read it. That is the whole handover. A reading order is
100
+ extra work you do on request, and it has its own section further down.
101
+
102
+ ## Put the review in front of them
103
+
104
+ When someone asks you for a review, open it rather than describing how:
105
+
106
+ ```bash
107
+ adiff review pane --repo <repo>
108
+ ```
109
+
110
+ It splits the pane they are already looking at, so their next move is to look right rather than to
111
+ type. The answer says what happened:
112
+
113
+ ```json
114
+ {"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api"}
115
+ ```
116
+
117
+ `opened:false` means nothing could be split, which is ordinary: a terminal without tmux, Zellij,
118
+ WezTerm or kitty has nowhere to put a pane. The answer carries `command` either way, so quote that
119
+ line and let them run it.
120
+
121
+ Open a pane when a review was asked for. Finishing work is not a reason on its own, and taking over
122
+ someone's screen uninvited is worse than a line they have to copy.
123
+
124
+ ## Tell the reviewer how to read it
125
+
126
+ Whether or not a pane opened, say what to do with it. Name the repository they should point at,
127
+ which is the repository the worktree belongs to:
128
+
129
+ > Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
130
+ > lists the files; `j` and `k` move down the diff, `]` and `[` walk between files. Select lines with
131
+ > `v`, write a comment with `c`, stage it with `ctrl+a`, and send the whole review with `S`. Press
132
+ > `?` for the rest.
133
+
134
+ Fill the repository path in yourself so nobody has to compose the command.
135
+
136
+ Say what you want looked at hardest, and where you are unsure. A reviewer who knows which part you
137
+ doubt spends their attention there. Offer a reading order rather than writing one: if the change is
138
+ long enough that the order matters, say you can publish one and let them decide.
139
+
140
+ ## Publishing a reading order, when you are asked for one
141
+
142
+ Only when the reviewer asks. A reading order is a real piece of work, it can be wrong, and one
143
+ nobody wanted spends their attention on your summary rather than on the code.
144
+
145
+ When they do ask, write **layers**: an ordered set over the diff, each one a claim about a span of
101
146
  code. The reviewer then walks the argument instead of the filesystem.
102
147
 
103
148
  ```bash
@@ -156,44 +201,13 @@ with:
156
201
  adiff layers show --worktree . --fields covered,partial,total,uncovered
157
202
  ```
158
203
 
159
- Setting a layers again supersedes the previous one and bumps `version`; the layers records the commit
160
- it was written for, and adiff reports it as `stale` once the branch moves past that commit. After
161
- you address a review, write the layers again.
162
-
163
- ## Put the review in front of them
164
-
165
- When someone asks you for a review, open it rather than describing how:
166
-
167
- ```bash
168
- adiff review pane --repo <repo>
169
- ```
170
-
171
- It splits the pane they are already looking at, so their next move is to look right rather than to
172
- type. The answer says what happened:
173
-
174
- ```json
175
- {"ok":true,"opened":true,"pane":"tmux","command":"adiff review open --repo /work/api"}
176
- ```
177
-
178
- `opened:false` means nothing could be split, which is ordinary: a terminal without tmux, Zellij,
179
- WezTerm or kitty has nowhere to put a pane. The answer carries `command` either way, so quote that
180
- line and let them run it.
181
-
182
- Open a pane when a review was asked for. Finishing work is not a reason on its own, and taking over
183
- someone's screen uninvited is worse than a line they have to copy.
184
-
185
- ## Tell the reviewer how to read it
186
-
187
- Whether or not a pane opened, say what to do with it. Name the repository they should point at,
188
- which is the repository the worktree belongs to:
189
-
190
- > Open it with `adiff review open --repo <repo>`, then press `enter` on this branch. The sidebar
191
- > lists the layers in reading order; `j` and `k` move between them and the diff follows. Inside a
192
- > layer, `]` and `[` walk its files. Select lines with `v`, write a comment with `c`, stage it with
193
- > `ctrl+a`, and send the whole review with `S`. Press `?` for the rest.
204
+ Setting layers again supersedes the previous set and bumps `version`; the set records the commit it
205
+ was written for, and adiff reports it as `stale` once the branch moves past that commit. Once a
206
+ reviewer has a reading order, keep it true: write it again after you address their comments.
194
207
 
195
- Say what you want looked at hardest, and where you are unsure. A reviewer who knows which layer you
196
- doubt spends their attention there.
208
+ When you have published one, tell them the sidebar now holds it: `s` swaps between the layers and
209
+ the files, `j` and `k` move between layers with the diff following, and `]` and `[` walk the files
210
+ inside a layer.
197
211
 
198
212
  ## Discovering the rest
199
213