@eliya-oss/agent-diff 0.1.0-alpha.32 → 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.
- package/.agents/adr/README.md +1 -0
- package/CHANGELOG.md +6 -0
- package/README.md +7 -3
- package/dist/main.js +754 -55
- package/package.json +2 -2
package/.agents/adr/README.md
CHANGED
|
@@ -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
package/README.md
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
# adiff
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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.
|
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
|
|
16648
|
-
|
|
16649
|
-
|
|
16650
|
-
};
|
|
16651
|
-
const
|
|
16652
|
-
|
|
16653
|
-
|
|
16654
|
-
|
|
16655
|
-
|
|
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
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
|
|
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
|
|
16749
|
-
|
|
16750
|
-
|
|
16751
|
-
|
|
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
|
|
16760
|
-
|
|
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 =
|
|
16777
|
-
|
|
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,
|
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.
|
|
27
|
-
"description": "
|
|
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",
|