@eliya-oss/agent-diff 0.1.0-alpha.37 → 0.1.0-alpha.39
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/bin/adiff.js +3 -2
- package/dist/main.js +513 -29
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @eliya-oss/agent-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.39
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `adiff upgrade` works out how this copy was installed and names the one command that updates it, and the terminal mentions a newer version once in the footer without ever checking on a command's path.
|
|
8
|
+
|
|
9
|
+
## 0.1.0-alpha.38
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- adiff --version answers from a version built into the bundle rather than a package.json found beside it, and a Bun runtime opens the terminal itself instead of going looking for a Node it does not need.
|
|
14
|
+
|
|
3
15
|
## 0.1.0-alpha.37
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/bin/adiff.js
CHANGED
|
@@ -33,8 +33,9 @@ const drawsTerminal = (argv) => {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const rendersHere = () =>
|
|
36
|
-
|
|
37
|
-
process.getBuiltinModule
|
|
36
|
+
process.versions.bun !== undefined ||
|
|
37
|
+
(typeof process.getBuiltinModule === "function" &&
|
|
38
|
+
process.getBuiltinModule("node:ffi") !== undefined)
|
|
38
39
|
|
|
39
40
|
const NODE_DIRECTORY = /^(?:v?\d|node)/
|
|
40
41
|
|
package/dist/main.js
CHANGED
|
@@ -888,6 +888,72 @@ function safeToString(input) {
|
|
|
888
888
|
return "[toString threw]";
|
|
889
889
|
}
|
|
890
890
|
}
|
|
891
|
+
/**
|
|
892
|
+
* Stringifies a value to JSON safely, silently dropping circular references.
|
|
893
|
+
*
|
|
894
|
+
* **When to use**
|
|
895
|
+
*
|
|
896
|
+
* Use when you need valid JSON output, unlike `format`, and the input may
|
|
897
|
+
* contain circular references that should be silently omitted rather than
|
|
898
|
+
* throwing a `TypeError`.
|
|
899
|
+
*
|
|
900
|
+
* **Details**
|
|
901
|
+
*
|
|
902
|
+
* Uses `JSON.stringify` internally with a replacer that tracks the current
|
|
903
|
+
* object ancestry. Circular references are replaced with `undefined`, which
|
|
904
|
+
* omits them from object output. `Redactable` values are automatically redacted
|
|
905
|
+
* before serialization. Values not supported by JSON, such as `BigInt`,
|
|
906
|
+
* `Symbol`, `undefined`, and functions, follow standard `JSON.stringify`
|
|
907
|
+
* behavior. The `space` parameter controls indentation and defaults to `0`.
|
|
908
|
+
*
|
|
909
|
+
* **Example** (Formatting compact JSON)
|
|
910
|
+
*
|
|
911
|
+
* ```ts
|
|
912
|
+
* import { Formatter } from "effect"
|
|
913
|
+
*
|
|
914
|
+
* console.log(Formatter.formatJson({ name: "Alice", age: 30 }))
|
|
915
|
+
* // {"name":"Alice","age":30}
|
|
916
|
+
* ```
|
|
917
|
+
*
|
|
918
|
+
* **Example** (Handling circular references)
|
|
919
|
+
*
|
|
920
|
+
* ```ts
|
|
921
|
+
* import { Formatter } from "effect"
|
|
922
|
+
*
|
|
923
|
+
* const obj: any = { name: "test" }
|
|
924
|
+
* obj.self = obj
|
|
925
|
+
* console.log(Formatter.formatJson(obj))
|
|
926
|
+
* // {"name":"test"}
|
|
927
|
+
* ```
|
|
928
|
+
*
|
|
929
|
+
* **Example** (Pretty-printed JSON)
|
|
930
|
+
*
|
|
931
|
+
* ```ts
|
|
932
|
+
* import { Formatter } from "effect"
|
|
933
|
+
*
|
|
934
|
+
* console.log(Formatter.formatJson({ name: "Alice", age: 30 }, { space: 2 }))
|
|
935
|
+
* // {
|
|
936
|
+
* // "name": "Alice",
|
|
937
|
+
* // "age": 30
|
|
938
|
+
* // }
|
|
939
|
+
* ```
|
|
940
|
+
*
|
|
941
|
+
* @see {@link format}
|
|
942
|
+
* @see {@link Formatter}
|
|
943
|
+
* @category serialization
|
|
944
|
+
* @since 4.0.0
|
|
945
|
+
*/
|
|
946
|
+
function formatJson(input, options) {
|
|
947
|
+
const ancestors = [];
|
|
948
|
+
return JSON.stringify(input, function(_key, value) {
|
|
949
|
+
const redacted = redact(value);
|
|
950
|
+
if (typeof redacted !== "object" || redacted === null) return redacted;
|
|
951
|
+
while (ancestors.length > 0 && ancestors[ancestors.length - 1] !== this) ancestors.pop();
|
|
952
|
+
if (ancestors.includes(redacted)) return;
|
|
953
|
+
ancestors.push(redacted);
|
|
954
|
+
return redacted;
|
|
955
|
+
}, options?.space);
|
|
956
|
+
}
|
|
891
957
|
var CIRCULAR;
|
|
892
958
|
var init_Formatter = __esmMin((() => {
|
|
893
959
|
init_Predicate();
|
|
@@ -896,8 +962,9 @@ var init_Formatter = __esmMin((() => {
|
|
|
896
962
|
}));
|
|
897
963
|
//#endregion
|
|
898
964
|
//#region node_modules/.pnpm/effect@4.0.0-beta.102/node_modules/effect/dist/Inspectable.js
|
|
899
|
-
var NodeInspectSymbol, toJson;
|
|
965
|
+
var NodeInspectSymbol, toJson, toStringUnknown;
|
|
900
966
|
var init_Inspectable = __esmMin((() => {
|
|
967
|
+
init_Formatter();
|
|
901
968
|
init_Predicate();
|
|
902
969
|
init_Redactable();
|
|
903
970
|
NodeInspectSymbol = /*#__PURE__*/ Symbol.for("nodejs.util.inspect.custom");
|
|
@@ -910,6 +977,14 @@ var init_Inspectable = __esmMin((() => {
|
|
|
910
977
|
}
|
|
911
978
|
return redact(input);
|
|
912
979
|
};
|
|
980
|
+
toStringUnknown = (u, whitespace = 2) => {
|
|
981
|
+
if (typeof u === "string") return u;
|
|
982
|
+
try {
|
|
983
|
+
return typeof u === "object" ? formatJson(u, { space: whitespace }) : String(u);
|
|
984
|
+
} catch {
|
|
985
|
+
return String(u);
|
|
986
|
+
}
|
|
987
|
+
};
|
|
913
988
|
}));
|
|
914
989
|
//#endregion
|
|
915
990
|
//#region node_modules/.pnpm/effect@4.0.0-beta.102/node_modules/effect/dist/Utils.js
|
|
@@ -973,7 +1048,7 @@ var init_Utils = __esmMin((() => {
|
|
|
973
1048
|
function defaultEvaluate(_fiber) {
|
|
974
1049
|
return exitDie(`Effect.evaluate: Not implemented`);
|
|
975
1050
|
}
|
|
976
|
-
var EffectTypeId, ExitTypeId, effectVariance, identifier, args, evaluate, contA, contE, contAll, Yield, PipeInspectableProto, EffectProto, isEffect, isExit, CauseTypeId, CauseReasonTypeId, isCause, CauseImpl, annotationsMap, ReasonBase, constEmptyAnnotations, Fail, causeFromReasons, causeFail, Die, causeDie, causeAnnotate, isFailReason$1, isDieReason, isInterruptReason, makePrimitiveProto, makePrimitive, makeExit, exitSucceed, StackTraceKey, InterruptorStackTrace$1, exitFailCause, exitFail, exitDie, withFiber$1, YieldableError, Error$1, TaggedError$1, DoneTypeId, isDone$1, DoneVoid, Done, doneVoid, done$2;
|
|
1051
|
+
var EffectTypeId, ExitTypeId, effectVariance, identifier, args, evaluate, contA, contE, contAll, Yield, PipeInspectableProto, EffectProto, isEffect, isExit, CauseTypeId, CauseReasonTypeId, isCause, CauseImpl, annotationsMap, ReasonBase, constEmptyAnnotations, Fail, causeFromReasons, causeEmpty, causeFail, Die, causeDie, causeAnnotate, isFailReason$1, isDieReason, isInterruptReason, makePrimitiveProto, makePrimitive, makeExit, exitSucceed, StackTraceKey, InterruptorStackTrace$1, exitFailCause, exitFail, exitDie, withFiber$1, YieldableError, Error$1, TaggedError$1, DoneTypeId, isDone$1, DoneVoid, Done, doneVoid, done$2;
|
|
977
1052
|
var init_core = __esmMin((() => {
|
|
978
1053
|
init_Equal();
|
|
979
1054
|
init_Formatter();
|
|
@@ -1123,6 +1198,7 @@ var init_core = __esmMin((() => {
|
|
|
1123
1198
|
}
|
|
1124
1199
|
};
|
|
1125
1200
|
causeFromReasons = (reasons) => new CauseImpl(reasons);
|
|
1201
|
+
causeEmpty = /*#__PURE__*/ new CauseImpl([]);
|
|
1126
1202
|
causeFail = (error) => new CauseImpl([new Fail(error)]);
|
|
1127
1203
|
Die = class extends ReasonBase {
|
|
1128
1204
|
defect;
|
|
@@ -2261,7 +2337,7 @@ var init_Tracer = __esmMin((() => {
|
|
|
2261
2337
|
var FiberRuntimeMetricsKey;
|
|
2262
2338
|
var init_metric = __esmMin((() => {
|
|
2263
2339
|
FiberRuntimeMetricsKey = "effect/observability/Metric/FiberRuntimeMetricsKey";
|
|
2264
|
-
})), CurrentStackFrame, TracerEnabled, TracerTimingEnabled, TracerSpanAnnotations, TracerSpanLinks, CurrentLogLevel, MinimumLogLevel, init_references = __esmMin((() => {
|
|
2340
|
+
})), CurrentStackFrame, TracerEnabled, TracerTimingEnabled, TracerSpanAnnotations, TracerSpanLinks, CurrentLogAnnotations, CurrentLogLevel, MinimumLogLevel, CurrentLogSpans, init_references = __esmMin((() => {
|
|
2265
2341
|
init_Context();
|
|
2266
2342
|
init_Function();
|
|
2267
2343
|
CurrentStackFrame = /*#__PURE__*/ Reference("effect/References/CurrentStackFrame", { defaultValue: constUndefined });
|
|
@@ -2269,8 +2345,10 @@ var init_metric = __esmMin((() => {
|
|
|
2269
2345
|
TracerTimingEnabled = /*#__PURE__*/ Reference("effect/References/TracerTimingEnabled", { defaultValue: constTrue });
|
|
2270
2346
|
TracerSpanAnnotations = /*#__PURE__*/ Reference("effect/References/TracerSpanAnnotations", { defaultValue: () => ({}) });
|
|
2271
2347
|
TracerSpanLinks = /*#__PURE__*/ Reference("effect/References/TracerSpanLinks", { defaultValue: () => [] });
|
|
2348
|
+
CurrentLogAnnotations = /*#__PURE__*/ Reference("effect/References/CurrentLogAnnotations", { defaultValue: () => ({}) });
|
|
2272
2349
|
CurrentLogLevel = /*#__PURE__*/ Reference("effect/References/CurrentLogLevel", { defaultValue: () => "Info" });
|
|
2273
2350
|
MinimumLogLevel = /*#__PURE__*/ Reference("effect/References/MinimumLogLevel", { defaultValue: () => "Info" });
|
|
2351
|
+
CurrentLogSpans = /*#__PURE__*/ Reference("effect/References/CurrentLogSpans", { defaultValue: () => [] });
|
|
2274
2352
|
})), addSpanStackTrace, makeStackCleaner, spanCleaner, init_tracer = __esmMin((() => {
|
|
2275
2353
|
init_stackTraceLimit();
|
|
2276
2354
|
addSpanStackTrace = (options) => {
|
|
@@ -2299,13 +2377,15 @@ var init_metric = __esmMin((() => {
|
|
|
2299
2377
|
};
|
|
2300
2378
|
};
|
|
2301
2379
|
spanCleaner = /*#__PURE__*/ makeStackCleaner(3);
|
|
2302
|
-
})), init_version$1 = __esmMin((() => {})), Interrupt, causeInterrupt, findError$1, hasInterrupts, causeFilterInterruptors, causeCombine, causeMap, causePartition, causeSquash, FiberTypeId, fiberVariance, fiberIdStore, getCurrentFiber, FiberImpl, deferredInterruptCont, fiberMiddleware, fiberStackAnnotations, fiberAwait, fiberAwaitAll, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$4, failCause$3, fail$2, sync$2, suspend$1, yieldNowWith, yieldNow, succeedSome$1, succeedNone$1, failCauseSync$1, die, failSync, void_$2, try_$1, promise$1, tryPromise$1, withFiberId, callbackOptions, asyncFinalizer, callback$2, never, gen$1, fnUntraced$1, defineFunctionLength, fnStackCleaner, fn$1, makeFn, fnUntracedEager$1, fromIteratorEagerUnsafe, fromIteratorUnsafe, as$1, asSome, andThen$1, tap$1, asVoid$1, raceAllFirst, raceFirst$1, flatMap$1, OnSuccessProto, effectIsExit, flatMapEager$1, map$2, mapEager$1, exitInterrupt$1, exitIsSuccess, exitFilterCause, exitVoid, exitMap, exitAsVoidAll, updateContext, updateService, contextWith$1, provideContext, provideService, provideServiceImpl, when$1, forever$1, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchIf, catchTag$1, mapError$1, option$2, matchCauseEffect, OnSuccessAndFailureProto, matchEffect, match, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scopedWith, acquireRelease$1, onExitPrimitive, onExit$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, interrupt$2, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, forkUnsafe$1, forkDetach$1, forkIn$1, runForkWith, runFork$1, runPromiseExitWith, runPromiseWith, runPromise$1, runSyncExitWith, runSyncExit$1, runSyncWith, runSync$1, succeedTrue, succeedFalse, Latch, makeLatchUnsafe, bigint0, NoopSpanProto, noopSpan, filterDisablePropagation, makeSpanUnsafe, provideSpanStackFrame, useSpan, provideParentSpan, withParentSpan, withSpan$1, ClockRef, MAX_TIMER_MILLIS, ClockImpl, performanceNowNanos, processOrPerformanceNow, clockWith, sleep$1, AsyncFiberErrorTypeId, AsyncFiberError, UnknownErrorTypeId, UnknownError, logLevelToOrder, LogLevelOrder, isLogLevelGreaterThan, colors, init_effect = __esmMin((() => {
|
|
2380
|
+
})), init_version$1 = __esmMin((() => {})), Interrupt, causeInterrupt, findFail, findError$1, hasInterrupts, causeFilterInterruptors, causeCombine, causeMap, causePartition, causeSquash, causePrettyErrors, causePrettyError, causePrettyMessage, locationRegExp, cleanErrorStack, addStackAnnotations, interruptCauseStack, currentStackTrace, causePretty, renderPrettyError, renderErrorCause, FiberTypeId, fiberVariance, fiberIdStore, getCurrentFiber, FiberImpl, deferredInterruptCont, fiberMiddleware, fiberStackAnnotations, fiberAwait, fiberAwaitAll, fiberInterrupt, fiberInterruptAs, fiberInterruptAll, succeed$4, failCause$3, fail$2, sync$2, suspend$1, yieldNowWith, yieldNow, succeedSome$1, succeedNone$1, failCauseSync$1, die, failSync, void_$2, try_$1, promise$1, tryPromise$1, withFiberId, callbackOptions, asyncFinalizer, callback$2, never, gen$1, fnUntraced$1, defineFunctionLength, fnStackCleaner, fn$1, makeFn, fnUntracedEager$1, fromIteratorEagerUnsafe, fromIteratorUnsafe, as$1, asSome, andThen$1, tap$1, asVoid$1, raceAllFirst, raceFirst$1, flatMap$1, OnSuccessProto, effectIsExit, flatMapEager$1, map$2, mapEager$1, exitInterrupt$1, exitIsSuccess, exitFilterCause, exitVoid, exitMap, exitAsVoidAll, updateContext, updateService, contextWith$1, provideContext, provideService, provideServiceImpl, when$1, forever$1, catchCause$1, OnFailureProto, catchCauseFilter, catch_, catchIf, catchTag$1, mapError$1, orElseSucceed$1, ignore$1, option$2, matchCauseEffect, OnSuccessAndFailureProto, matchEffect, match, exit$1, exitPrimitive, ScopeTypeId, ScopeCloseableTypeId, scopeTag, scopeClose, scopeCloseUnsafe, scopeCloseFinalizers, scopeForkUnsafe, scopeAddFinalizerExit, scopeAddFinalizer, scopeAddFinalizerUnsafe, scopeRemoveFinalizerUnsafe, scopeMakeUnsafe, constScopeEmpty, scope, provideScope, scopedWith, acquireRelease$1, onExitPrimitive, onExit$1, onExitFilter, onError$1, onErrorFilter, onInterrupt$1, interrupt$2, uninterruptible$1, setInterruptible, setInterruptibleTrue, setInterruptibleFalse, setFiberInterruptible, interruptible, uninterruptibleMask, whileLoop$1, forEach$1, forEachSequential, iterateEagerImpl, iterateEager, forEachConcurrent, forkUnsafe$1, forkDetach$1, forkIn$1, runForkWith, runFork$1, runPromiseExitWith, runPromiseWith, runPromise$1, runSyncExitWith, runSyncExit$1, runSyncWith, runSync$1, succeedTrue, succeedFalse, Latch, makeLatchUnsafe, bigint0, NoopSpanProto, noopSpan, filterDisablePropagation, makeSpanUnsafe, provideSpanStackFrame, useSpan, provideParentSpan, withParentSpan, withSpan$1, ClockRef, MAX_TIMER_MILLIS, ClockImpl, performanceNowNanos, processOrPerformanceNow, clockWith, sleep$1, AsyncFiberErrorTypeId, AsyncFiberError, UnknownErrorTypeId, UnknownError, ConsoleRef, logLevelToOrder, LogLevelOrder, isLogLevelGreaterThan, CurrentLoggers, LogToStderr, LoggerTypeId, LoggerProto, loggerMake, formatLabel, formatLogSpan, logWithLevel, colors, defaultDateFormat, defaultLogger, tracerLogger, init_effect = __esmMin((() => {
|
|
2303
2381
|
init_Array();
|
|
2304
2382
|
init_Context();
|
|
2305
2383
|
init_Duration();
|
|
2306
2384
|
init_Equal();
|
|
2385
|
+
init_Formatter();
|
|
2307
2386
|
init_Function();
|
|
2308
2387
|
init_Hash();
|
|
2388
|
+
init_Inspectable();
|
|
2309
2389
|
init_Option();
|
|
2310
2390
|
init_Order();
|
|
2311
2391
|
init_Pipeable();
|
|
@@ -2317,6 +2397,7 @@ var init_metric = __esmMin((() => {
|
|
|
2317
2397
|
init_Utils();
|
|
2318
2398
|
init_core();
|
|
2319
2399
|
init_metric();
|
|
2400
|
+
init_record();
|
|
2320
2401
|
init_references();
|
|
2321
2402
|
init_stackTraceLimit();
|
|
2322
2403
|
init_tracer();
|
|
@@ -2344,6 +2425,10 @@ var init_metric = __esmMin((() => {
|
|
|
2344
2425
|
}
|
|
2345
2426
|
};
|
|
2346
2427
|
causeInterrupt = (fiberId) => new CauseImpl([new Interrupt(fiberId)]);
|
|
2428
|
+
findFail = (self) => {
|
|
2429
|
+
const reason = self.reasons.find(isFailReason$1);
|
|
2430
|
+
return reason ? succeed$5(reason) : fail$3(self);
|
|
2431
|
+
};
|
|
2347
2432
|
findError$1 = (self) => {
|
|
2348
2433
|
for (let i = 0; i < self.reasons.length; i++) {
|
|
2349
2434
|
const reason = self.reasons[i];
|
|
@@ -2395,6 +2480,109 @@ var init_metric = __esmMin((() => {
|
|
|
2395
2480
|
else if (partitioned.Interrupt.length > 0) return new globalThis.Error("All fibers interrupted without error");
|
|
2396
2481
|
return new globalThis.Error("Empty cause");
|
|
2397
2482
|
};
|
|
2483
|
+
causePrettyErrors = (self, options) => {
|
|
2484
|
+
const errors = [];
|
|
2485
|
+
const interrupts = [];
|
|
2486
|
+
if (self.reasons.length === 0) return errors;
|
|
2487
|
+
const prevStackLimit = getStackTraceLimit();
|
|
2488
|
+
setStackTraceLimit(1);
|
|
2489
|
+
for (const failure of self.reasons) {
|
|
2490
|
+
if (failure._tag === "Interrupt") {
|
|
2491
|
+
interrupts.push(failure);
|
|
2492
|
+
continue;
|
|
2493
|
+
}
|
|
2494
|
+
errors.push(causePrettyError(failure._tag === "Die" ? failure.defect : failure.error, failure.annotations, options));
|
|
2495
|
+
}
|
|
2496
|
+
if (errors.length === 0) {
|
|
2497
|
+
const cause = /* @__PURE__ */ new Error("The fiber was interrupted by:");
|
|
2498
|
+
cause.name = "InterruptCause";
|
|
2499
|
+
cause.stack = interruptCauseStack(cause, interrupts);
|
|
2500
|
+
const error = new globalThis.Error("All fibers interrupted without error", { cause });
|
|
2501
|
+
error.name = "InterruptError";
|
|
2502
|
+
error.stack = `${error.name}: ${error.message}`;
|
|
2503
|
+
errors.push(causePrettyError(error, interrupts[0].annotations, options));
|
|
2504
|
+
}
|
|
2505
|
+
setStackTraceLimit(prevStackLimit);
|
|
2506
|
+
return errors;
|
|
2507
|
+
};
|
|
2508
|
+
causePrettyError = (original, annotations, options) => {
|
|
2509
|
+
const kind = typeof original;
|
|
2510
|
+
let error;
|
|
2511
|
+
if (original && kind === "object") {
|
|
2512
|
+
error = new globalThis.Error(causePrettyMessage(original), { cause: original.cause ? causePrettyError(original.cause) : void 0 });
|
|
2513
|
+
if (typeof original.name === "string") error.name = original.name;
|
|
2514
|
+
if (typeof original.stack === "string") error.stack = cleanErrorStack(original.stack, error, annotations);
|
|
2515
|
+
else {
|
|
2516
|
+
const stack = `${error.name}: ${error.message}`;
|
|
2517
|
+
error.stack = annotations ? addStackAnnotations(stack, annotations) : stack;
|
|
2518
|
+
}
|
|
2519
|
+
if (options?.includeCauseInStack) error.stack = renderPrettyError(error);
|
|
2520
|
+
for (const key of Object.keys(original)) if (!(key in error)) error[key] = original[key];
|
|
2521
|
+
} else error = new globalThis.Error(!original ? `Unknown error: ${original}` : kind === "string" ? original : formatJson(original));
|
|
2522
|
+
return error;
|
|
2523
|
+
};
|
|
2524
|
+
causePrettyMessage = (u) => {
|
|
2525
|
+
if (typeof u.message === "string") return u.message;
|
|
2526
|
+
else if (typeof u.toString === "function" && u.toString !== Object.prototype.toString && u.toString !== Array.prototype.toString) try {
|
|
2527
|
+
return u.toString();
|
|
2528
|
+
} catch {}
|
|
2529
|
+
return formatJson(u);
|
|
2530
|
+
};
|
|
2531
|
+
locationRegExp = /\((.*)\)/g;
|
|
2532
|
+
cleanErrorStack = (stack, error, annotations) => {
|
|
2533
|
+
const message = `${error.name}: ${error.message}`;
|
|
2534
|
+
const lines = (stack.startsWith(message) ? stack.slice(message.length) : stack).split("\n");
|
|
2535
|
+
const out = [message];
|
|
2536
|
+
for (let i = 1; i < lines.length; i++) {
|
|
2537
|
+
if (/(?:Generator\.next|~effect\/Effect)/.test(lines[i])) break;
|
|
2538
|
+
out.push(lines[i]);
|
|
2539
|
+
}
|
|
2540
|
+
return annotations ? addStackAnnotations(out.join("\n"), annotations) : out.join("\n");
|
|
2541
|
+
};
|
|
2542
|
+
addStackAnnotations = (stack, annotations) => {
|
|
2543
|
+
const frame = annotations?.get(StackTraceKey.key);
|
|
2544
|
+
if (frame) stack = `${stack}\n${currentStackTrace(frame)}`;
|
|
2545
|
+
return stack;
|
|
2546
|
+
};
|
|
2547
|
+
interruptCauseStack = (error, interrupts) => {
|
|
2548
|
+
const out = [`${error.name}: ${error.message}`];
|
|
2549
|
+
for (const current of interrupts) {
|
|
2550
|
+
const fiberId = current.fiberId !== void 0 ? `#${current.fiberId}` : "unknown";
|
|
2551
|
+
const frame = current.annotations.get(InterruptorStackTrace$1.key);
|
|
2552
|
+
out.push(` at fiber (${fiberId})`);
|
|
2553
|
+
if (frame) out.push(currentStackTrace(frame));
|
|
2554
|
+
}
|
|
2555
|
+
return out.join("\n");
|
|
2556
|
+
};
|
|
2557
|
+
currentStackTrace = (frame) => {
|
|
2558
|
+
const out = [];
|
|
2559
|
+
let current = frame;
|
|
2560
|
+
let i = 0;
|
|
2561
|
+
while (current && i < 10) {
|
|
2562
|
+
const stack = current.stack();
|
|
2563
|
+
if (stack) {
|
|
2564
|
+
const locationMatchAll = stack.matchAll(locationRegExp);
|
|
2565
|
+
let match = false;
|
|
2566
|
+
for (const [, location] of locationMatchAll) {
|
|
2567
|
+
match = true;
|
|
2568
|
+
out.push(` at ${current.name} (${location})`);
|
|
2569
|
+
}
|
|
2570
|
+
if (!match) out.push(` at ${current.name} (${stack.replace(/^at /, "")})`);
|
|
2571
|
+
} else out.push(` at ${current.name}`);
|
|
2572
|
+
current = current.parent;
|
|
2573
|
+
i++;
|
|
2574
|
+
}
|
|
2575
|
+
return out.join("\n");
|
|
2576
|
+
};
|
|
2577
|
+
causePretty = (cause) => causePrettyErrors(cause).map(renderPrettyError).join("\n");
|
|
2578
|
+
renderPrettyError = (e) => e.cause ? `${e.stack} {\n${renderErrorCause(e.cause, " ")}\n}` : e.stack;
|
|
2579
|
+
renderErrorCause = (cause, prefix) => {
|
|
2580
|
+
const lines = cause.stack.split("\n");
|
|
2581
|
+
let stack = `${prefix}[cause]: ${lines[0]}`;
|
|
2582
|
+
for (let i = 1, len = lines.length; i < len; i++) stack += `\n${prefix}${lines[i]}`;
|
|
2583
|
+
if (cause.cause) stack += ` {\n${renderErrorCause(cause.cause, `${prefix} `)}\n${prefix}}`;
|
|
2584
|
+
return stack;
|
|
2585
|
+
};
|
|
2398
2586
|
FiberTypeId = `~effect/Fiber/dev`;
|
|
2399
2587
|
fiberVariance = {
|
|
2400
2588
|
_A: identity,
|
|
@@ -2985,6 +3173,21 @@ var init_metric = __esmMin((() => {
|
|
|
2985
3173
|
return catchIf(self, pred, f, orElse);
|
|
2986
3174
|
});
|
|
2987
3175
|
mapError$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (error) => failSync(() => f(error))));
|
|
3176
|
+
orElseSucceed$1 = /*#__PURE__*/ dual(2, (self, f) => catch_(self, (_) => sync$2(f)));
|
|
3177
|
+
ignore$1 = /*#__PURE__*/ dual((args) => isEffect(args[0]), (self, options) => {
|
|
3178
|
+
if (!options?.log) return matchEffect(self, {
|
|
3179
|
+
onFailure: (_) => void_$2,
|
|
3180
|
+
onSuccess: (_) => void_$2
|
|
3181
|
+
});
|
|
3182
|
+
const logEffect = logWithLevel(options.log === true ? void 0 : options.log);
|
|
3183
|
+
return matchCauseEffect(self, {
|
|
3184
|
+
onFailure(cause) {
|
|
3185
|
+
const failure = findFail(cause);
|
|
3186
|
+
return isFailure(failure) ? failCause$3(failure.failure) : options.message === void 0 ? logEffect(cause) : logEffect(options.message, cause);
|
|
3187
|
+
},
|
|
3188
|
+
onSuccess: (_) => void_$2
|
|
3189
|
+
});
|
|
3190
|
+
});
|
|
2988
3191
|
option$2 = (self) => match(self, {
|
|
2989
3192
|
onFailure: none,
|
|
2990
3193
|
onSuccess: some
|
|
@@ -3654,6 +3857,7 @@ var init_metric = __esmMin((() => {
|
|
|
3654
3857
|
});
|
|
3655
3858
|
}
|
|
3656
3859
|
};
|
|
3860
|
+
ConsoleRef = /*#__PURE__*/ Reference("effect/Console/CurrentConsole", { defaultValue: () => globalThis.console });
|
|
3657
3861
|
logLevelToOrder = (level) => {
|
|
3658
3862
|
switch (level) {
|
|
3659
3863
|
case "All": return Number.MIN_SAFE_INTEGER;
|
|
@@ -3668,6 +3872,57 @@ var init_metric = __esmMin((() => {
|
|
|
3668
3872
|
};
|
|
3669
3873
|
LogLevelOrder = /*#__PURE__*/ mapInput(Number$4, logLevelToOrder);
|
|
3670
3874
|
isLogLevelGreaterThan = /*#__PURE__*/ isGreaterThan$1(LogLevelOrder);
|
|
3875
|
+
CurrentLoggers = /*#__PURE__*/ Reference("effect/Loggers/CurrentLoggers", { defaultValue: () => /* @__PURE__ */ new Set([defaultLogger, tracerLogger]) });
|
|
3876
|
+
LogToStderr = /*#__PURE__*/ Reference("effect/Logger/LogToStderr", { defaultValue: constFalse });
|
|
3877
|
+
LoggerTypeId = "~effect/Logger";
|
|
3878
|
+
LoggerProto = {
|
|
3879
|
+
[LoggerTypeId]: {
|
|
3880
|
+
_Message: identity,
|
|
3881
|
+
_Output: identity
|
|
3882
|
+
},
|
|
3883
|
+
pipe() {
|
|
3884
|
+
return pipeArguments(this, arguments);
|
|
3885
|
+
}
|
|
3886
|
+
};
|
|
3887
|
+
loggerMake = (log) => {
|
|
3888
|
+
const self = Object.create(LoggerProto);
|
|
3889
|
+
self.log = log;
|
|
3890
|
+
return self;
|
|
3891
|
+
};
|
|
3892
|
+
formatLabel = (key) => key.replace(/[\s="]/g, "_");
|
|
3893
|
+
formatLogSpan = (self, now) => {
|
|
3894
|
+
return `${formatLabel(self[0])}=${now - self[1]}ms`;
|
|
3895
|
+
};
|
|
3896
|
+
logWithLevel = (level) => (...message) => {
|
|
3897
|
+
let cause = void 0;
|
|
3898
|
+
for (let i = 0, len = message.length; i < len; i++) {
|
|
3899
|
+
const msg = message[i];
|
|
3900
|
+
if (isCause(msg)) {
|
|
3901
|
+
if (cause) message.splice(i, 1);
|
|
3902
|
+
else message = message.slice(0, i).concat(message.slice(i + 1));
|
|
3903
|
+
cause = cause ? causeFromReasons(cause.reasons.concat(msg.reasons)) : msg;
|
|
3904
|
+
i--;
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
if (cause === void 0) cause = causeEmpty;
|
|
3908
|
+
return withFiber$1((fiber) => {
|
|
3909
|
+
const logLevel = level ?? fiber.currentLogLevel;
|
|
3910
|
+
if (isLogLevelGreaterThan(fiber.minimumLogLevel, logLevel)) return void_$2;
|
|
3911
|
+
const clock = fiber.getRef(ClockRef);
|
|
3912
|
+
const loggers = fiber.getRef(CurrentLoggers);
|
|
3913
|
+
if (loggers.size > 0) {
|
|
3914
|
+
const date = new Date(clock.currentTimeMillisUnsafe());
|
|
3915
|
+
for (const logger of loggers) logger.log({
|
|
3916
|
+
cause,
|
|
3917
|
+
fiber,
|
|
3918
|
+
date,
|
|
3919
|
+
logLevel,
|
|
3920
|
+
message
|
|
3921
|
+
});
|
|
3922
|
+
}
|
|
3923
|
+
return void_$2;
|
|
3924
|
+
});
|
|
3925
|
+
};
|
|
3671
3926
|
colors = {
|
|
3672
3927
|
bold: "1",
|
|
3673
3928
|
red: "31",
|
|
@@ -3681,6 +3936,31 @@ var init_metric = __esmMin((() => {
|
|
|
3681
3936
|
bgBrightRed: "101"
|
|
3682
3937
|
};
|
|
3683
3938
|
colors.gray, colors.blue, colors.green, colors.yellow, colors.red, colors.bgBrightRed, colors.black;
|
|
3939
|
+
defaultDateFormat = (date) => `${date.getHours().toString().padStart(2, "0")}:${date.getMinutes().toString().padStart(2, "0")}:${date.getSeconds().toString().padStart(2, "0")}.${date.getMilliseconds().toString().padStart(3, "0")}`;
|
|
3940
|
+
defaultLogger = /*#__PURE__*/ loggerMake(({ cause, date, fiber, logLevel, message }) => {
|
|
3941
|
+
const message_ = Array.isArray(message) ? message.slice() : [message];
|
|
3942
|
+
if (cause.reasons.length > 0) message_.push(causePretty(cause));
|
|
3943
|
+
const now = date.getTime();
|
|
3944
|
+
const spans = fiber.getRef(CurrentLogSpans);
|
|
3945
|
+
let spanString = "";
|
|
3946
|
+
for (const span of spans) spanString += ` ${formatLogSpan(span, now)}`;
|
|
3947
|
+
const annotations = fiber.getRef(CurrentLogAnnotations);
|
|
3948
|
+
if (Object.keys(annotations).length > 0) message_.push(annotations);
|
|
3949
|
+
const console = fiber.getRef(ConsoleRef);
|
|
3950
|
+
(fiber.getRef(LogToStderr) ? console.error : console.log)(`[${defaultDateFormat(date)}] ${logLevel.toUpperCase()} (#${fiber.id})${spanString}:`, ...message_);
|
|
3951
|
+
});
|
|
3952
|
+
tracerLogger = /*#__PURE__*/ loggerMake(({ cause, fiber, logLevel, message }) => {
|
|
3953
|
+
const clock = fiber.getRef(ClockRef);
|
|
3954
|
+
const annotations = fiber.getRef(CurrentLogAnnotations);
|
|
3955
|
+
const span = fiber.currentSpan;
|
|
3956
|
+
if (span === void 0 || span._tag === "ExternalSpan") return;
|
|
3957
|
+
const attributes = {};
|
|
3958
|
+
for (const [key, value] of Object.entries(annotations)) assignProperty(attributes, key, value);
|
|
3959
|
+
attributes["effect.fiberId"] = fiber.id;
|
|
3960
|
+
attributes["effect.logLevel"] = logLevel.toUpperCase();
|
|
3961
|
+
if (cause.reasons.length > 0) attributes["effect.cause"] = causePretty(cause);
|
|
3962
|
+
span.event(toStringUnknown(Array.isArray(message) && message.length === 1 ? message[0] : message), clock.currentTimeNanosUnsafe(), attributes);
|
|
3963
|
+
});
|
|
3684
3964
|
})), isFailReason, map$1, squash, findError, isDone, done$1;
|
|
3685
3965
|
var init_Cause = __esmMin((() => {
|
|
3686
3966
|
init_Context();
|
|
@@ -3965,7 +4245,7 @@ var provideLayer, provide$1, init_layer = __esmMin((() => {
|
|
|
3965
4245
|
init_effect();
|
|
3966
4246
|
provideLayer = (self, layer, options) => scopedWith((scope) => flatMap$1(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope) : buildWithScope(layer, scope), (context) => provideContext(self, context)));
|
|
3967
4247
|
provide$1 = /*#__PURE__*/ dual((args) => isEffect(args[0]), (self, source, options) => isContext(source) ? provideContext(self, source) : provideLayer(self, Array.isArray(source) ? mergeAll(...source) : source, options));
|
|
3968
|
-
})), forEach, whileLoop, promise, tryPromise, succeed, succeedNone, succeedSome, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, try_, withFiber, flatMap, andThen, tap, option$1, exit, map, as, asVoid, catchTag, catchCause, mapError, sleep, raceFirst, when, contextWith, provide, acquireRelease, onError, onExit, interrupt$1, onInterrupt, uninterruptible, forever, withSpan, forkIn, forkDetach, runFork, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, flatMapEager, fnUntracedEager;
|
|
4248
|
+
})), forEach, whileLoop, promise, tryPromise, succeed, succeedNone, succeedSome, suspend, sync, void_, callback$1, gen, fail, failCause, failCauseSync, try_, withFiber, flatMap, andThen, tap, option$1, exit, map, as, asVoid, catchTag, catchCause, mapError, ignore, orElseSucceed, sleep, raceFirst, when, contextWith, provide, acquireRelease, onError, onExit, interrupt$1, onInterrupt, uninterruptible, forever, withSpan, forkIn, forkDetach, runFork, runPromise, runSync, runSyncExit, fnUntraced, fn, mapEager, flatMapEager, fnUntracedEager;
|
|
3969
4249
|
var init_Effect = __esmMin((() => {
|
|
3970
4250
|
init_Context();
|
|
3971
4251
|
init_core();
|
|
@@ -3999,6 +4279,8 @@ var init_Effect = __esmMin((() => {
|
|
|
3999
4279
|
catchTag = catchTag$1;
|
|
4000
4280
|
catchCause = catchCause$1;
|
|
4001
4281
|
mapError = mapError$1;
|
|
4282
|
+
ignore = ignore$1;
|
|
4283
|
+
orElseSucceed = orElseSucceed$1;
|
|
4002
4284
|
sleep = sleep$1;
|
|
4003
4285
|
raceFirst = raceFirst$1;
|
|
4004
4286
|
when = when$1;
|
|
@@ -7957,7 +8239,7 @@ var init_model$2 = __esmMin((() => {
|
|
|
7957
8239
|
}));
|
|
7958
8240
|
//#endregion
|
|
7959
8241
|
//#region src/service/store/schema.ts
|
|
7960
|
-
var Side, Anchor, StoredComment, StoredAnswer, Batch, BranchState, Settings, Prose, Code, StoredLayer, StoredLayers;
|
|
8242
|
+
var Side, Anchor, StoredComment, StoredAnswer, Batch, BranchState, Settings, UpgradeCheck, Prose, Code, StoredLayer, StoredLayers;
|
|
7961
8243
|
var init_schema = __esmMin((() => {
|
|
7962
8244
|
init_dist();
|
|
7963
8245
|
Side = Literals(["old", "new"]);
|
|
@@ -7995,6 +8277,12 @@ var init_schema = __esmMin((() => {
|
|
|
7995
8277
|
removed: optionalKey(Record(String$1, String$1))
|
|
7996
8278
|
});
|
|
7997
8279
|
Settings = Struct({ wrap: optionalKey(Boolean) });
|
|
8280
|
+
UpgradeCheck = Struct({
|
|
8281
|
+
note: optionalKey(String$1),
|
|
8282
|
+
checkedAt: optionalKey(String$1),
|
|
8283
|
+
latest: optionalKey(String$1),
|
|
8284
|
+
told: optionalKey(String$1)
|
|
8285
|
+
});
|
|
7998
8286
|
Prose = Struct({
|
|
7999
8287
|
kind: Literal("prose"),
|
|
8000
8288
|
markdown: String$1
|
|
@@ -8021,7 +8309,7 @@ var init_schema = __esmMin((() => {
|
|
|
8021
8309
|
}));
|
|
8022
8310
|
//#endregion
|
|
8023
8311
|
//#region src/service/store/paths.ts
|
|
8024
|
-
var NON_SLUG, slugOf, defaultRoot, branchDir, inboxPath, outboxPath, statePath, layersPath, settingsPath, reportsDir, reportPath;
|
|
8312
|
+
var NON_SLUG, slugOf, defaultRoot, branchDir, inboxPath, outboxPath, statePath, layersPath, settingsPath, upgradePath, reportsDir, reportPath;
|
|
8025
8313
|
var init_paths = __esmMin((() => {
|
|
8026
8314
|
NON_SLUG = /[^a-zA-Z0-9]+/g;
|
|
8027
8315
|
slugOf = (worktreePath) => worktreePath.replace(NON_SLUG, "-");
|
|
@@ -8032,9 +8320,10 @@ var init_paths = __esmMin((() => {
|
|
|
8032
8320
|
statePath = (root, worktreePath) => join(branchDir(root, worktreePath), "state.json");
|
|
8033
8321
|
layersPath = (root, worktreePath) => join(branchDir(root, worktreePath), "layers.json");
|
|
8034
8322
|
settingsPath = (root) => join(root, "settings.json");
|
|
8323
|
+
upgradePath = (root) => join(root, "upgrade.json");
|
|
8035
8324
|
reportsDir = (root) => join(root, "reports");
|
|
8036
8325
|
reportPath = (root, stamp) => join(reportsDir(root), `${stamp}.md`);
|
|
8037
|
-
})), Store, ensureDir, readOptional, missing, damaged, jsonOf, decoded, asSettings, asBatch, asAnswer, asState, asLayers, linesOf, readLines, parseSettings, parseState, parseLayers, cursorOps, settingsOps, reportOps, HEAD_REF, headOf$1, keyOf$2, answerOps, layersOps, inboxOps, stateOps, makeStore, storeAt;
|
|
8326
|
+
})), Store, ensureDir, readOptional, missing, damaged, jsonOf, decoded, asSettings, asUpgradeCheck, asBatch, asAnswer, asState, asLayers, linesOf, readLines, parseSettings, parseUpgradeCheck, parseState, parseLayers, cursorOps, settingsOps, upgradeOps, reportOps, HEAD_REF, headOf$1, keyOf$2, answerOps, layersOps, inboxOps, stateOps, makeStore, storeAt;
|
|
8038
8327
|
var init_service$1 = __esmMin((() => {
|
|
8039
8328
|
init_dist();
|
|
8040
8329
|
init_error$2();
|
|
@@ -8074,6 +8363,7 @@ var init_service$1 = __esmMin((() => {
|
|
|
8074
8363
|
return (path, value) => mapError(decode(value), damaged(path));
|
|
8075
8364
|
};
|
|
8076
8365
|
asSettings = decoded(Settings);
|
|
8366
|
+
asUpgradeCheck = decoded(UpgradeCheck);
|
|
8077
8367
|
asBatch = decoded(Batch);
|
|
8078
8368
|
asAnswer = decoded(StoredAnswer);
|
|
8079
8369
|
asState = decoded(BranchState);
|
|
@@ -8084,6 +8374,10 @@ var init_service$1 = __esmMin((() => {
|
|
|
8084
8374
|
const value = yield* jsonOf(path, raw);
|
|
8085
8375
|
return yield* asSettings(path, value);
|
|
8086
8376
|
});
|
|
8377
|
+
parseUpgradeCheck = fn("Store.parseUpgradeCheck")(function* (path, raw) {
|
|
8378
|
+
const value = yield* jsonOf(path, raw);
|
|
8379
|
+
return yield* asUpgradeCheck(path, value);
|
|
8380
|
+
});
|
|
8087
8381
|
parseState = fn("Store.parseState")(function* (path, raw) {
|
|
8088
8382
|
const value = yield* jsonOf(path, raw);
|
|
8089
8383
|
const held = yield* asState(path, value);
|
|
@@ -8166,6 +8460,29 @@ var init_service$1 = __esmMin((() => {
|
|
|
8166
8460
|
})
|
|
8167
8461
|
};
|
|
8168
8462
|
};
|
|
8463
|
+
upgradeOps = (root) => {
|
|
8464
|
+
return {
|
|
8465
|
+
upgradeCheck: gen(function* () {
|
|
8466
|
+
const path = upgradePath(root);
|
|
8467
|
+
const raw = yield* readOptional(path);
|
|
8468
|
+
return yield* match$3(raw, {
|
|
8469
|
+
onNone: () => succeed({}),
|
|
8470
|
+
onSome: (text) => parseUpgradeCheck(path, text)
|
|
8471
|
+
});
|
|
8472
|
+
}).pipe(withSpan("Store.upgradeCheck")),
|
|
8473
|
+
saveUpgradeCheck: fn("Store.saveUpgradeCheck")(function* (next) {
|
|
8474
|
+
const path = upgradePath(root);
|
|
8475
|
+
yield* ensureDir(root);
|
|
8476
|
+
yield* tryPromise({
|
|
8477
|
+
try: () => writeFile(path, JSON.stringify(next, void 0, 2), "utf8"),
|
|
8478
|
+
catch: (cause) => new StoreUnwritable({
|
|
8479
|
+
path,
|
|
8480
|
+
reason: String(cause)
|
|
8481
|
+
})
|
|
8482
|
+
});
|
|
8483
|
+
})
|
|
8484
|
+
};
|
|
8485
|
+
};
|
|
8169
8486
|
reportOps = (root) => fn("Store.saveReport")(function* (stamp, text) {
|
|
8170
8487
|
const path = reportPath(root, stamp);
|
|
8171
8488
|
yield* ensureDir(reportsDir(root));
|
|
@@ -8297,6 +8614,7 @@ var init_service$1 = __esmMin((() => {
|
|
|
8297
8614
|
saveState,
|
|
8298
8615
|
saveReport: reportOps(root),
|
|
8299
8616
|
...settingsOps(root),
|
|
8617
|
+
...upgradeOps(root),
|
|
8300
8618
|
...answerOps(root),
|
|
8301
8619
|
...layersOps(root),
|
|
8302
8620
|
...cursors
|
|
@@ -8635,13 +8953,13 @@ var init_commands = __esmMin((() => {
|
|
|
8635
8953
|
}));
|
|
8636
8954
|
//#endregion
|
|
8637
8955
|
//#region src/cli/init.ts
|
|
8638
|
-
var BEGIN, END, REACH
|
|
8956
|
+
var BEGIN, END, REACH, INSTRUCTIONS, IMPORT, blockIn, replaced, appended, planFor, readAt, writeAt, settle, skillSource, shippedSkill, settleSkill, initRepository;
|
|
8639
8957
|
var init_init = __esmMin((() => {
|
|
8640
8958
|
init_dist();
|
|
8641
8959
|
init_error$1();
|
|
8642
8960
|
BEGIN = "<!-- adiff:begin -->";
|
|
8643
8961
|
END = "<!-- adiff:end -->";
|
|
8644
|
-
REACH
|
|
8962
|
+
REACH = 5;
|
|
8645
8963
|
INSTRUCTIONS = [
|
|
8646
8964
|
BEGIN,
|
|
8647
8965
|
"## Review",
|
|
@@ -8716,7 +9034,7 @@ var init_init = __esmMin((() => {
|
|
|
8716
9034
|
});
|
|
8717
9035
|
skillSource = () => {
|
|
8718
9036
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
8719
|
-
return Array.from({ length: REACH
|
|
9037
|
+
return Array.from({ length: REACH }, (_, layer) => join(here, ...Array(layer).fill(".."))).map((at) => join(at, "skills", "adiff", "SKILL.md")).find((path) => existsSync(path));
|
|
8720
9038
|
};
|
|
8721
9039
|
shippedSkill = fn("Cli.shippedSkill")(function* () {
|
|
8722
9040
|
const source = skillSource();
|
|
@@ -8755,7 +9073,7 @@ var init_init = __esmMin((() => {
|
|
|
8755
9073
|
}));
|
|
8756
9074
|
//#endregion
|
|
8757
9075
|
//#region src/cli/pane.ts
|
|
8758
|
-
var TIMEOUT_MS$1, set, splitters, selfInvocation, ran, split, openPane;
|
|
9076
|
+
var TIMEOUT_MS$1, set, splitters, selfInvocation, ran$1, split, openPane;
|
|
8759
9077
|
var init_pane = __esmMin((() => {
|
|
8760
9078
|
init_dist();
|
|
8761
9079
|
TIMEOUT_MS$1 = 5e3;
|
|
@@ -8830,11 +9148,11 @@ var init_pane = __esmMin((() => {
|
|
|
8830
9148
|
repo
|
|
8831
9149
|
];
|
|
8832
9150
|
};
|
|
8833
|
-
ran = (binary, args) => callback$1((resume) => {
|
|
9151
|
+
ran$1 = (binary, args) => callback$1((resume) => {
|
|
8834
9152
|
execFile(binary, [...args], { timeout: TIMEOUT_MS$1 }, (cause) => resume(succeed(cause === null)));
|
|
8835
9153
|
});
|
|
8836
9154
|
split = fn("Cli.split")(function* (chosen, repo) {
|
|
8837
|
-
return yield* ran(chosen.binary, chosen.args(repo, selfInvocation(repo)));
|
|
9155
|
+
return yield* ran$1(chosen.binary, chosen.args(repo, selfInvocation(repo)));
|
|
8838
9156
|
});
|
|
8839
9157
|
openPane = fn("Cli.openPane")(function* (repo) {
|
|
8840
9158
|
const command = `adiff review open --repo ${repo}`;
|
|
@@ -8852,12 +9170,130 @@ var init_pane = __esmMin((() => {
|
|
|
8852
9170
|
});
|
|
8853
9171
|
}));
|
|
8854
9172
|
//#endregion
|
|
9173
|
+
//#region package.json
|
|
9174
|
+
init_commands();
|
|
9175
|
+
init_init();
|
|
9176
|
+
init_pane();
|
|
9177
|
+
var version$1 = "0.1.0-alpha.39";
|
|
9178
|
+
//#endregion
|
|
9179
|
+
//#region src/cli/upgrade.ts
|
|
9180
|
+
var PACKAGE, TAG, RELEASES, REGISTRY, ASK_MS, RUN_MS, CELLAR, COMPILED, INSTALLED, BUN_GLOBAL, routeOf, checkoutOf, assetOf, commandFor, NOTES, RUNNABLE, NUMBERS, numbersIn, compare$1, partsOf, newer, tagIn, fetched, askLatest, ran, here, noteFor, upgradeAdiff;
|
|
9181
|
+
var init_upgrade$1 = __esmMin((() => {
|
|
9182
|
+
init_dist();
|
|
9183
|
+
PACKAGE = "@eliya-oss/agent-diff";
|
|
9184
|
+
TAG = "alpha";
|
|
9185
|
+
RELEASES = "https://github.com/Newbie012/agent-diff/releases/latest";
|
|
9186
|
+
REGISTRY = `https://registry.npmjs.org/-/package/${encodeURIComponent(PACKAGE)}/dist-tags`;
|
|
9187
|
+
ASK_MS = 2500;
|
|
9188
|
+
RUN_MS = 3e5;
|
|
9189
|
+
CELLAR = /[/\\]Cellar[/\\]adiff[/\\]/;
|
|
9190
|
+
COMPILED = /^[/\\]\$bunfs[/\\]/;
|
|
9191
|
+
INSTALLED = /node_modules[/\\]@eliya-oss[/\\]agent-diff/;
|
|
9192
|
+
BUN_GLOBAL = /[/\\]\.bun[/\\]install[/\\]global[/\\]/;
|
|
9193
|
+
routeOf = (executable, module) => {
|
|
9194
|
+
if (CELLAR.test(executable) || CELLAR.test(module)) return "brew";
|
|
9195
|
+
if (COMPILED.test(module)) return "binary";
|
|
9196
|
+
if (!INSTALLED.test(module)) return "source";
|
|
9197
|
+
return BUN_GLOBAL.test(module) ? "bun" : "npm";
|
|
9198
|
+
};
|
|
9199
|
+
checkoutOf = (module) => module.replace(/[/\\](?:src|dist)[/\\].*$/, "").replace(/[/\\](?:src|dist)$/, "");
|
|
9200
|
+
assetOf = () => `adiff-${process.platform}-${process.arch}`;
|
|
9201
|
+
commandFor = (route, executable, module) => {
|
|
9202
|
+
if (route === "brew") return "brew upgrade Newbie012/tap/adiff";
|
|
9203
|
+
if (route === "npm") return `npm i -g ${PACKAGE}@${TAG}`;
|
|
9204
|
+
if (route === "bun") return `bun add -g ${PACKAGE}@${TAG}`;
|
|
9205
|
+
if (route === "source") return `git -C ${checkoutOf(module)} pull && pnpm install && pnpm build`;
|
|
9206
|
+
return `curl -fsSL ${RELEASES}/download/${assetOf()} -o ${executable} && chmod +x ${executable}`;
|
|
9207
|
+
};
|
|
9208
|
+
NOTES = {
|
|
9209
|
+
brew: "Homebrew installed this build, so Homebrew replaces it.",
|
|
9210
|
+
npm: `npm installed this build. Name the ${TAG} tag: the latest tag on the registry is an old build.`,
|
|
9211
|
+
bun: `bun installed this build. Name the ${TAG} tag: the latest tag on the registry is an old build.`,
|
|
9212
|
+
binary: `This is a downloaded binary, so nothing upgrades it on its own. The command replaces it in place; a running executable cannot rewrite itself, so run it yourself. Every build is on ${RELEASES}.`,
|
|
9213
|
+
source: "This is running from a checkout, so git is what updates it."
|
|
9214
|
+
};
|
|
9215
|
+
RUNNABLE = /* @__PURE__ */ new Set([
|
|
9216
|
+
"brew",
|
|
9217
|
+
"npm",
|
|
9218
|
+
"bun"
|
|
9219
|
+
]);
|
|
9220
|
+
NUMBERS = /\d+/g;
|
|
9221
|
+
numbersIn = (text) => (text.match(NUMBERS) ?? []).map((digits) => Number(digits));
|
|
9222
|
+
compare$1 = (left, right) => {
|
|
9223
|
+
const [head, ...restLeft] = left;
|
|
9224
|
+
const [other, ...restRight] = right;
|
|
9225
|
+
if (head === void 0 && other === void 0) return 0;
|
|
9226
|
+
if (head === void 0) return -1;
|
|
9227
|
+
if (other === void 0) return 1;
|
|
9228
|
+
if (head === other) return compare$1(restLeft, restRight);
|
|
9229
|
+
return head < other ? -1 : 1;
|
|
9230
|
+
};
|
|
9231
|
+
partsOf = (version) => {
|
|
9232
|
+
const [core = "", ...rest] = version.split("-");
|
|
9233
|
+
return {
|
|
9234
|
+
core: numbersIn(core),
|
|
9235
|
+
pre: numbersIn(rest.join("-"))
|
|
9236
|
+
};
|
|
9237
|
+
};
|
|
9238
|
+
newer = (candidate, held) => {
|
|
9239
|
+
const left = partsOf(candidate);
|
|
9240
|
+
const right = partsOf(held);
|
|
9241
|
+
const cores = compare$1(left.core, right.core);
|
|
9242
|
+
if (cores !== 0) return cores > 0;
|
|
9243
|
+
if (left.pre.length === 0 && right.pre.length === 0) return false;
|
|
9244
|
+
if (left.pre.length === 0) return true;
|
|
9245
|
+
if (right.pre.length === 0) return false;
|
|
9246
|
+
return compare$1(left.pre, right.pre) > 0;
|
|
9247
|
+
};
|
|
9248
|
+
tagIn = (body) => {
|
|
9249
|
+
if (typeof body !== "object" || body === void 0 || body === null) return void 0;
|
|
9250
|
+
const tags = body;
|
|
9251
|
+
const named = tags[TAG] ?? tags["latest"];
|
|
9252
|
+
return typeof named === "string" ? named : void 0;
|
|
9253
|
+
};
|
|
9254
|
+
fetched = (url) => fetch(url, { signal: AbortSignal.timeout(ASK_MS) }).then((response) => response.ok ? response.json() : void 0).then(tagIn).catch(() => void 0);
|
|
9255
|
+
askLatest = promise(() => fetched(process.env["ADIFF_REGISTRY"] ?? REGISTRY));
|
|
9256
|
+
ran = (command) => callback$1((resume) => {
|
|
9257
|
+
execFile("/bin/sh", ["-c", command], { timeout: RUN_MS }, (cause) => resume(succeed(!cause)));
|
|
9258
|
+
});
|
|
9259
|
+
here = () => ({
|
|
9260
|
+
executable: process.execPath,
|
|
9261
|
+
module: fileURLToPath(new URL(".", import.meta.url))
|
|
9262
|
+
});
|
|
9263
|
+
noteFor = (route, run, version, checked) => {
|
|
9264
|
+
const refused = run && !RUNNABLE.has(route) ? " adiff will not run this one for you; run it yourself." : "";
|
|
9265
|
+
const blind = checked ? "" : ` adiff could not reach the registry, so it cannot say whether ${version} is current. Every build is listed on ${RELEASES}.`;
|
|
9266
|
+
return `${NOTES[route]}${refused}${blind}`;
|
|
9267
|
+
};
|
|
9268
|
+
upgradeAdiff = fn("Cli.upgradeAdiff")(function* (run) {
|
|
9269
|
+
const { executable, module } = here();
|
|
9270
|
+
const route = routeOf(executable, module);
|
|
9271
|
+
const version = version$1;
|
|
9272
|
+
const command = commandFor(route, executable, module);
|
|
9273
|
+
const latest = yield* askLatest;
|
|
9274
|
+
const current = latest === void 0 ? void 0 : !newer(latest, version);
|
|
9275
|
+
const known = latest === void 0 ? {} : {
|
|
9276
|
+
latest,
|
|
9277
|
+
current: current === true
|
|
9278
|
+
};
|
|
9279
|
+
const performed = run && RUNNABLE.has(route) && current !== true ? yield* ran(command) : false;
|
|
9280
|
+
return {
|
|
9281
|
+
route,
|
|
9282
|
+
version,
|
|
9283
|
+
checked: latest !== void 0,
|
|
9284
|
+
...known,
|
|
9285
|
+
command,
|
|
9286
|
+
ran: performed,
|
|
9287
|
+
note: noteFor(route, run, version, latest !== void 0)
|
|
9288
|
+
};
|
|
9289
|
+
});
|
|
9290
|
+
}));
|
|
9291
|
+
//#endregion
|
|
8855
9292
|
//#region src/cli/search.ts
|
|
8856
9293
|
var HIT, NEAR, rowOf, readRows, near, byChangedFirst, searchBranch;
|
|
8857
9294
|
var init_search = __esmMin((() => {
|
|
8858
9295
|
init_dist();
|
|
8859
9296
|
init_git();
|
|
8860
|
-
init_commands();
|
|
8861
9297
|
HIT = /^(.+?):(\d+):(.*)$/;
|
|
8862
9298
|
NEAR = /^(.+?)-(\d+)-(.*)$/;
|
|
8863
9299
|
rowOf = (line) => {
|
|
@@ -9712,6 +10148,19 @@ var init_catalog = __esmMin((() => {
|
|
|
9712
10148
|
dataKey: "changes",
|
|
9713
10149
|
example: "adiff init --repo . --write"
|
|
9714
10150
|
},
|
|
10151
|
+
{
|
|
10152
|
+
name: "upgrade",
|
|
10153
|
+
about: "Work out how adiff was installed and name the one command that updates it. Prints, does not run",
|
|
10154
|
+
safety: "read",
|
|
10155
|
+
options: [{
|
|
10156
|
+
name: "run",
|
|
10157
|
+
required: false,
|
|
10158
|
+
value: "flag",
|
|
10159
|
+
about: "Run the command instead of printing it. Ignored for a downloaded binary or a checkout, which adiff will not rewrite under itself"
|
|
10160
|
+
}],
|
|
10161
|
+
dataKey: "upgrade",
|
|
10162
|
+
example: "adiff upgrade --fields route,command"
|
|
10163
|
+
},
|
|
9715
10164
|
{
|
|
9716
10165
|
name: "describe",
|
|
9717
10166
|
about: "This catalog, as JSON",
|
|
@@ -9826,8 +10275,7 @@ var init_report$1 = __esmMin((() => {
|
|
|
9826
10275
|
//#region src/cli/index.ts
|
|
9827
10276
|
var init_cli = __esmMin((() => {
|
|
9828
10277
|
init_commands();
|
|
9829
|
-
|
|
9830
|
-
init_pane();
|
|
10278
|
+
init_upgrade$1();
|
|
9831
10279
|
init_search();
|
|
9832
10280
|
init_layers();
|
|
9833
10281
|
init_threads();
|
|
@@ -9841,17 +10289,7 @@ var init_cli = __esmMin((() => {
|
|
|
9841
10289
|
init_cli();
|
|
9842
10290
|
init_catalog();
|
|
9843
10291
|
const NAME_ROOM = 18;
|
|
9844
|
-
const
|
|
9845
|
-
const manifest = () => {
|
|
9846
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
9847
|
-
return Array.from({ length: REACH }, (_, layer) => join(here, ...Array(layer).fill(".."))).map((at) => join(at, "package.json")).find((path) => existsSync(path));
|
|
9848
|
-
};
|
|
9849
|
-
const version = () => {
|
|
9850
|
-
const path = manifest();
|
|
9851
|
-
if (path === void 0) return "unknown";
|
|
9852
|
-
const raw = readFileSync(path, "utf8");
|
|
9853
|
-
return JSON.parse(raw).version ?? "unknown";
|
|
9854
|
-
};
|
|
10292
|
+
const version = () => version$1;
|
|
9855
10293
|
const line = (command) => ` ${command.name.padEnd(NAME_ROOM)}${command.about}`;
|
|
9856
10294
|
const banner = () => [
|
|
9857
10295
|
`adiff ${version()}`,
|
|
@@ -13482,11 +13920,50 @@ var init_session = __esmMin((() => {
|
|
|
13482
13920
|
writeSession = fn("Tui.writeSession")(function* (path, session) {
|
|
13483
13921
|
yield* promise(() => saved(path, session));
|
|
13484
13922
|
});
|
|
13923
|
+
}));
|
|
13924
|
+
//#endregion
|
|
13925
|
+
//#region src/tui/upgrade.ts
|
|
13926
|
+
var DAY_MS, NOTE, off, stale, refresh, worded, upgradeHint;
|
|
13927
|
+
var init_upgrade = __esmMin((() => {
|
|
13928
|
+
init_dist();
|
|
13929
|
+
init_store();
|
|
13930
|
+
DAY_MS = 864e5;
|
|
13931
|
+
NOTE = "adiff keeps this file so it asks the registry for the newest version at most once a day, never while you are waiting on a command. told is the version it has already mentioned once. Delete the file and it is written again. Set ADIFF_NO_UPGRADE_CHECK=1 to stop the check and the hint entirely.";
|
|
13932
|
+
off = () => process.env["ADIFF_NO_UPGRADE_CHECK"] !== void 0;
|
|
13933
|
+
stale = (held) => held.checkedAt === void 0 || Date.now() - Date.parse(held.checkedAt) > DAY_MS;
|
|
13934
|
+
refresh = gen(function* () {
|
|
13935
|
+
const store = yield* Store;
|
|
13936
|
+
const latest = yield* askLatest;
|
|
13937
|
+
if (latest === void 0) return;
|
|
13938
|
+
const held = yield* store.upgradeCheck;
|
|
13939
|
+
yield* store.saveUpgradeCheck({
|
|
13940
|
+
...held,
|
|
13941
|
+
note: NOTE,
|
|
13942
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13943
|
+
latest
|
|
13944
|
+
});
|
|
13945
|
+
}).pipe(withSpan("Tui.refreshUpgrade"));
|
|
13946
|
+
worded = gen(function* () {
|
|
13947
|
+
if (off()) return "";
|
|
13948
|
+
const store = yield* Store;
|
|
13949
|
+
const held = yield* store.upgradeCheck;
|
|
13950
|
+
const { latest } = held;
|
|
13951
|
+
const due = latest !== void 0 && latest !== held.told && newer(latest, version$1);
|
|
13952
|
+
if (due && latest !== void 0) yield* store.saveUpgradeCheck({
|
|
13953
|
+
...held,
|
|
13954
|
+
note: NOTE,
|
|
13955
|
+
told: latest
|
|
13956
|
+
});
|
|
13957
|
+
if (stale(held)) yield* forkDetach(ignore(refresh));
|
|
13958
|
+
return due ? `adiff ${latest} is out · adiff upgrade` : "";
|
|
13959
|
+
}).pipe(withSpan("Tui.upgradeHint"));
|
|
13960
|
+
upgradeHint = worded.pipe(orElseSucceed(() => ""));
|
|
13485
13961
|
})), PRINTABLE, KEY_HISTORY, copyToClipboard, asKey, keyName, App, settledPath, launch, told, untilDestroyed, runOn, runTui;
|
|
13486
13962
|
var init_app = __esmMin((() => {
|
|
13487
13963
|
init_dist();
|
|
13488
13964
|
init_report();
|
|
13489
13965
|
init_patch();
|
|
13966
|
+
init_cli();
|
|
13490
13967
|
init_store();
|
|
13491
13968
|
init_watch();
|
|
13492
13969
|
init_forge();
|
|
@@ -13497,6 +13974,7 @@ var init_app = __esmMin((() => {
|
|
|
13497
13974
|
init_display();
|
|
13498
13975
|
init_intent();
|
|
13499
13976
|
init_session();
|
|
13977
|
+
init_upgrade();
|
|
13500
13978
|
PRINTABLE = /^[\S ]$/;
|
|
13501
13979
|
KEY_HISTORY = 40;
|
|
13502
13980
|
copyToClipboard = (text) => {
|
|
@@ -14237,9 +14715,11 @@ var init_app = __esmMin((() => {
|
|
|
14237
14715
|
const store = yield* Store;
|
|
14238
14716
|
const wrap = (yield* store.settings).wrap === true;
|
|
14239
14717
|
const display = yield* Display.pipe(provide(displayOn(renderer, repo)));
|
|
14718
|
+
const waiting = yield* upgradeHint;
|
|
14240
14719
|
const state = yield* make({
|
|
14241
14720
|
...initialState(branches),
|
|
14242
|
-
wrap
|
|
14721
|
+
wrap,
|
|
14722
|
+
waiting
|
|
14243
14723
|
});
|
|
14244
14724
|
const painting = yield* forkDetach(runForEach(changes(state), display.paint));
|
|
14245
14725
|
const intents = yield* unbounded();
|
|
@@ -14470,6 +14950,10 @@ const routes = {
|
|
|
14470
14950
|
"layers set": layersSet,
|
|
14471
14951
|
"layers show": layersShow,
|
|
14472
14952
|
init,
|
|
14953
|
+
upgrade: fn("Main.upgrade")(function* (options) {
|
|
14954
|
+
const report = yield* upgradeAdiff(options["run"] !== void 0);
|
|
14955
|
+
yield* answer(options, { upgrade: report });
|
|
14956
|
+
}),
|
|
14473
14957
|
describe: fn("Main.describe")(function* (options) {
|
|
14474
14958
|
const wanted = options["command"];
|
|
14475
14959
|
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.39",
|
|
27
27
|
"description": "Review the work an agent left you without losing the thread: comments live on the lines, the agent answers them, and each point stays open until you settle it.",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"repository": {
|