@okfit/engine 0.18.2 → 0.19.1
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/edits/FrontmatterEdits.js +1 -1
- package/errors.js +21 -2
- package/index.d.ts +52 -34
- package/index.js +10 -10
- package/move/run.js +10 -14
- package/overlay/layer.js +16 -3
- package/package.json +19 -19
- package/platform.js +5 -3
- package/render/distribution.js +1 -1
- package/render/graph.js +1 -1
- package/render/json.js +2 -2
- package/render/move.js +1 -1
- package/render/query.js +1 -1
- package/render/stale.js +1 -1
- package/render/sync.js +2 -2
- package/render/verify.js +1 -1
- package/sync/generated.js +2 -2
- package/sync/run.js +1 -1
- package/sync/write.js +4 -4
- package/tsdoc-metadata.json +1 -1
- package/verify/diff.js +21 -22
- package/verify/run.js +9 -5
- package/version.js +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { documentNewline, locate, locateTopLevelScalar, stripBom } from "../verify/locate.js";
|
|
2
1
|
import { formatDigest, locateIntegrity, spliceIntegrityVerified } from "../verify/integrity.js";
|
|
2
|
+
import { documentNewline, locate, locateTopLevelScalar, stripBom } from "../verify/locate.js";
|
|
3
3
|
import { orderVerifyEdits, splice, spliceTopLevelScalar } from "../verify/splice.js";
|
|
4
4
|
import { DiagnosticRange } from "@okfit/core";
|
|
5
5
|
import { Effect, Result, Runtime, Schema } from "effect";
|
package/errors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Runtime, Schema } from "effect";
|
|
2
|
-
import { ErrorText } from "@effected/
|
|
2
|
+
import { ErrorText } from "@effected/kit";
|
|
3
3
|
|
|
4
4
|
// src/errors.ts
|
|
5
5
|
/**
|
|
@@ -86,6 +86,25 @@ var VerifyUnsupportedFrontmatterError = class extends Schema.TaggedError()("Veri
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
/**
|
|
89
|
+
* `okfit verify` cannot bind a verification to a concept whose content cannot be
|
|
90
|
+
* hashed: a frontmatter value holds an unpaired surrogate (a YAML `"\\uD800"`
|
|
91
|
+
* escape), which the content digest's canonical JSON refuses (okfit#327). Nothing
|
|
92
|
+
* was written. Exit 3, like the other verify refusals.
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
var VerifyContentUnhashableError = class extends Schema.TaggedError()("VerifyContentUnhashableError", {
|
|
97
|
+
id: Schema.String,
|
|
98
|
+
path: Schema.Array(Schema.Union([Schema.String, Schema.Number])),
|
|
99
|
+
detail: Schema.String
|
|
100
|
+
}) {
|
|
101
|
+
[Runtime.errorExitCode] = 3;
|
|
102
|
+
get message() {
|
|
103
|
+
const where = this.path.length === 0 ? "its frontmatter" : this.path.join(".");
|
|
104
|
+
return `"${this.id}" cannot be verified: ${where} cannot be hashed (${this.detail}); fix the value, then re-run okfit verify`;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
89
108
|
* `okfit verify --revoke` found no `verified` entry by the resolved actor on
|
|
90
109
|
* the concept, so there is nothing to remove. Exit 3, like any other verify
|
|
91
110
|
* outcome that cannot proceed on the concept.
|
|
@@ -327,4 +346,4 @@ var MoveError = class extends Schema.TaggedError()("MoveError", {
|
|
|
327
346
|
}
|
|
328
347
|
};
|
|
329
348
|
|
|
330
|
-
export { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError };
|
|
349
|
+
export { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError };
|
package/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AppDirs, AppDirs as AppDirs$1, Xdg, Xdg as Xdg$1, XdgEnvError } from "@effected/xdg";
|
|
2
2
|
import { Actor, BundleLoadError, ConceptId, Diagnostic, DiagnosticRange, DiagnosticSeverity, GraphLink, GraphNode, GraphNodeKind, LinkGraph, LoadedBundle, LoadedConcept, OkfitConfig, OkfitConfigFile, PathField, StaleConcept, Status, ValidationReport } from "@okfit/core";
|
|
3
|
-
import { Context,
|
|
3
|
+
import { Context, DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Result, Runtime, Schema } from "effect";
|
|
4
4
|
import { ConfigReadError } from "@effected/config-file";
|
|
5
5
|
import { ConceptSignal, DriftReason, GeneratedAtError, GitHistory, GitHistoryError, IntegrityState, Layout, Profile, ProfileDiagnostic } from "@okfit/profiles";
|
|
6
6
|
import { FrontmatterWriteError, MarkdownEdit, MarkdownParseError } from "@effected/markdown";
|
|
7
7
|
import { YamlParseError } from "@effected/yaml";
|
|
8
|
+
import { Digest } from "effect/crypto";
|
|
8
9
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
9
|
-
import { Distribution as Distribution$1 } from "@effected/
|
|
10
|
+
import { Distribution as Distribution$1 } from "@effected/kit";
|
|
10
11
|
import { Git, GitCommandError, UnknownRefError } from "@effected/git";
|
|
11
|
-
import { ChildProcessSpawner } from "effect/process";
|
|
12
12
|
/**
|
|
13
13
|
* What {@link resolveProjectRoot} needs about the winning discovery source
|
|
14
14
|
* (K-12, K-58). Narrower than `@effected/config-file`'s own
|
|
@@ -140,6 +140,23 @@ export declare class VerifyUnsupportedFrontmatterError extends VerifyUnsupported
|
|
|
140
140
|
readonly [Runtime.errorExitCode] = 3;
|
|
141
141
|
get message(): string;
|
|
142
142
|
}
|
|
143
|
+
declare const VerifyContentUnhashableError_base: Schema.Class<VerifyContentUnhashableError, Schema.TaggedStruct<"VerifyContentUnhashableError", {
|
|
144
|
+
readonly id: Schema.String;
|
|
145
|
+
readonly path: Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>;
|
|
146
|
+
readonly detail: Schema.String;
|
|
147
|
+
}>, import("effect/Cause").YieldableError>;
|
|
148
|
+
/**
|
|
149
|
+
* `okfit verify` cannot bind a verification to a concept whose content cannot be
|
|
150
|
+
* hashed: a frontmatter value holds an unpaired surrogate (a YAML `"\\uD800"`
|
|
151
|
+
* escape), which the content digest's canonical JSON refuses (okfit#327). Nothing
|
|
152
|
+
* was written. Exit 3, like the other verify refusals.
|
|
153
|
+
*
|
|
154
|
+
* @public
|
|
155
|
+
*/
|
|
156
|
+
export declare class VerifyContentUnhashableError extends VerifyContentUnhashableError_base {
|
|
157
|
+
readonly [Runtime.errorExitCode] = 3;
|
|
158
|
+
get message(): string;
|
|
159
|
+
}
|
|
143
160
|
declare const VerifyNothingToRevokeError_base: Schema.Class<VerifyNothingToRevokeError, Schema.TaggedStruct<"VerifyNothingToRevokeError", {
|
|
144
161
|
readonly id: Schema.String;
|
|
145
162
|
readonly actor: Schema.String;
|
|
@@ -780,7 +797,7 @@ type PlanError = MoveError | TargetResolutionError | BundleLoadError | PlatformE
|
|
|
780
797
|
*
|
|
781
798
|
* @public
|
|
782
799
|
*/
|
|
783
|
-
export declare const planMove: (options: PlanMoveOptions) => Effect.Effect<MovePlan, PlanError,
|
|
800
|
+
export declare const planMove: (options: PlanMoveOptions) => Effect.Effect<MovePlan, PlanError, Digest.Digest | FileSystem.FileSystem | Path.Path>;
|
|
784
801
|
/**
|
|
785
802
|
* Plan the move, then (unless `dryRun`) write it: every referrer atomically, the moved file's new
|
|
786
803
|
* text over its old path, then a rename to the destination (its directory created first). Nothing is
|
|
@@ -792,7 +809,7 @@ export declare const runMove: (options: RunMoveOptions) => Effect.Effect<{
|
|
|
792
809
|
readonly plan: MovePlan;
|
|
793
810
|
readonly bundleRoot: string;
|
|
794
811
|
readonly dryRun: boolean;
|
|
795
|
-
}, PlanError,
|
|
812
|
+
}, PlanError, Digest.Digest | FileSystem.FileSystem | Path.Path>;
|
|
796
813
|
/**
|
|
797
814
|
* One unsaved document: `path` is bundle-relative posix (`metrics/churn.md`),
|
|
798
815
|
* `text` the full file contents.
|
|
@@ -865,7 +882,8 @@ export declare class OverlayDocuments extends OverlayDocuments_base {
|
|
|
865
882
|
}
|
|
866
883
|
/**
|
|
867
884
|
* Wrap `underlying` so `readFile`, `readFileString`, `exists`, `stat` and `lstat` answer
|
|
868
|
-
* from `documents` for open paths, and a non-recursive `readDirectory`
|
|
885
|
+
* from `documents` for open paths, and a non-recursive `readDirectory` (and
|
|
886
|
+
* `readDirectoryEntries`, Effect 4.1's typed listing, as a `"File"`) also lists
|
|
869
887
|
* open documents whose parent is the directory read (so a brand-new unsaved file
|
|
870
888
|
* is walked). Every other member, and every path not open, is `underlying`'s.
|
|
871
889
|
*
|
|
@@ -883,8 +901,9 @@ export declare const layerOverlayFileSystem: Layer.Layer<FileSystem.FileSystem,
|
|
|
883
901
|
* `Layer.provide(Xdg.layer)` alone does not close it.
|
|
884
902
|
* `Layer.provideMerge(NodeServices.layer)` supplies `FileSystem`/`Path` to
|
|
885
903
|
* both members and keeps every service in the output.
|
|
886
|
-
* `NodeServices.layer` provides `ChildProcessSpawner |
|
|
887
|
-
* a superset of `Command.Environment`.
|
|
904
|
+
* `NodeServices.layer` provides `ChildProcessSpawner | FileSystem | Path | Stdio | Terminal`,
|
|
905
|
+
* a superset of `Command.Environment`. Since Effect 4.1 it carries no crypto, so
|
|
906
|
+
* `NodeCrypto.layerDigest` supplies the `Digest` every body and content digest needs.
|
|
888
907
|
*
|
|
889
908
|
* K-13: `Xdg.layer` fails with `XdgEnvError` when `HOME` is unset. Callers
|
|
890
909
|
* are responsible for providing this layer INSIDE whatever region renders
|
|
@@ -893,7 +912,7 @@ export declare const layerOverlayFileSystem: Layer.Layer<FileSystem.FileSystem,
|
|
|
893
912
|
*
|
|
894
913
|
* @public
|
|
895
914
|
*/
|
|
896
|
-
export declare const OkfitPlatform: Layer.Layer<AppDirs$1 | Xdg$1 | NodeServices.NodeServices, import("@effected/xdg").XdgEnvError, never>;
|
|
915
|
+
export declare const OkfitPlatform: Layer.Layer<AppDirs$1 | import("effect/crypto/Digest").Digest | Xdg$1 | NodeServices.NodeServices, import("@effected/xdg").XdgEnvError, never>;
|
|
897
916
|
/**
|
|
898
917
|
* Filter for {@link ConceptQuery.list}. Every field is optional; an absent
|
|
899
918
|
* field does not constrain.
|
|
@@ -1129,7 +1148,7 @@ export declare const contextEnvelope: (input: {
|
|
|
1129
1148
|
* reports; `engine_version` and `okf_version` are the pair a reader
|
|
1130
1149
|
* compares.
|
|
1131
1150
|
*
|
|
1132
|
-
* Re-exported from `@effected/
|
|
1151
|
+
* Re-exported from `@effected/kit`'s own `Distribution` -- the shape
|
|
1133
1152
|
* both `@okfit/cli`'s `CurrentDistribution` (K-137/carrier-version-threading)
|
|
1134
1153
|
* and every JSON envelope in this package agree on, instead of two
|
|
1135
1154
|
* independently hand-rolled `{ name, version }` structs drifting apart.
|
|
@@ -1457,7 +1476,7 @@ export declare const moveEnvelope: (input: {
|
|
|
1457
1476
|
* @public
|
|
1458
1477
|
*/
|
|
1459
1478
|
export declare const TrustDrift: Schema.Struct<{
|
|
1460
|
-
readonly reason: Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed"]>;
|
|
1479
|
+
readonly reason: Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed", "content-unhashable"]>;
|
|
1461
1480
|
readonly edited_by: Schema.NullOr<Schema.String>;
|
|
1462
1481
|
readonly edited_at: Schema.NullOr<Schema.String>;
|
|
1463
1482
|
}>;
|
|
@@ -1545,7 +1564,7 @@ export declare const QueryGetEnvelope: Schema.Struct<{
|
|
|
1545
1564
|
readonly integrity: Schema.Literals<readonly ["current", "drifted", "none"]>;
|
|
1546
1565
|
readonly stale: Schema.Boolean;
|
|
1547
1566
|
readonly drift: Schema.NullOr<Schema.Struct<{
|
|
1548
|
-
readonly reason: Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed"]>;
|
|
1567
|
+
readonly reason: Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed", "content-unhashable"]>;
|
|
1549
1568
|
readonly edited_by: Schema.NullOr<Schema.String>;
|
|
1550
1569
|
readonly edited_at: Schema.NullOr<Schema.String>;
|
|
1551
1570
|
}>>;
|
|
@@ -1808,7 +1827,7 @@ interface SyncPlan {
|
|
|
1808
1827
|
*
|
|
1809
1828
|
* @public
|
|
1810
1829
|
*/
|
|
1811
|
-
export declare const planSync: (options: SyncOptions) => Effect.Effect<SyncPlan, BundleLoadError | GeneratedAtError, Git | GitHistory | FileSystem.FileSystem | Path.Path |
|
|
1830
|
+
export declare const planSync: (options: SyncOptions) => Effect.Effect<SyncPlan, BundleLoadError | GeneratedAtError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Digest.Digest>;
|
|
1812
1831
|
/**
|
|
1813
1832
|
* Performs exactly the writes a {@link SyncPlan} recorded (atomically, in plan
|
|
1814
1833
|
* order), then the `--staged` re-add, and returns the non-dry-run
|
|
@@ -1831,7 +1850,7 @@ export declare const applySyncPlan: (plan: SyncPlan) => Effect.Effect<{
|
|
|
1831
1850
|
*
|
|
1832
1851
|
* @public
|
|
1833
1852
|
*/
|
|
1834
|
-
export declare const runSync: (options: SyncOptions) => Effect.Effect<SyncResult, BundleLoadError | GeneratedAtError | SyncPlanStaleError, Git | GitHistory | FileSystem.FileSystem | Path.Path |
|
|
1853
|
+
export declare const runSync: (options: SyncOptions) => Effect.Effect<SyncResult, BundleLoadError | GeneratedAtError | SyncPlanStaleError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Digest.Digest>;
|
|
1835
1854
|
/** @public */
|
|
1836
1855
|
export declare const SyncModeEnvelope: Schema.Struct<{
|
|
1837
1856
|
readonly selected: Schema.Boolean;
|
|
@@ -2061,7 +2080,7 @@ export declare const VerifyEnvelope: Schema.Struct<{
|
|
|
2061
2080
|
readonly to: Schema.Literals<readonly ["stable", "draft"]>;
|
|
2062
2081
|
}>>;
|
|
2063
2082
|
/** Why the prior human verification no longer bound the concept; absent when it did not drift. */
|
|
2064
|
-
readonly prior_integrity: Schema.optionalKey<Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed"]>>;
|
|
2083
|
+
readonly prior_integrity: Schema.optionalKey<Schema.Literals<readonly ["content-changed", "unbound", "entry-superseded", "actor-not-allowed", "content-unhashable"]>>;
|
|
2065
2084
|
readonly dry_run: Schema.Boolean;
|
|
2066
2085
|
readonly exit_code: Schema.Literal<0>;
|
|
2067
2086
|
}>;
|
|
@@ -2231,7 +2250,7 @@ interface WatchedFilesOutcome {
|
|
|
2231
2250
|
*
|
|
2232
2251
|
* @public
|
|
2233
2252
|
*/
|
|
2234
|
-
type BundleSessionServices = FileSystem.FileSystem | Path.Path | Git | GitHistory |
|
|
2253
|
+
type BundleSessionServices = FileSystem.FileSystem | Path.Path | Git | GitHistory | Digest.Digest;
|
|
2235
2254
|
/** @public */
|
|
2236
2255
|
interface BundleSessionShape {
|
|
2237
2256
|
/** Absolute, resolved bundle root. */
|
|
@@ -2349,7 +2368,7 @@ export declare const stampPublication: (options: {
|
|
|
2349
2368
|
readonly bundleRoot: string;
|
|
2350
2369
|
readonly id: string;
|
|
2351
2370
|
readonly dryRun: boolean;
|
|
2352
|
-
}) => Effect.Effect<PublicationEnvelope, PublicationNotFoundError | NotAPublicationError | BundleLoadError | YamlParseError | UnsupportedFrontmatterError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path |
|
|
2371
|
+
}) => Effect.Effect<PublicationEnvelope, PublicationNotFoundError | NotAPublicationError | BundleLoadError | YamlParseError | UnsupportedFrontmatterError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Digest.Digest>;
|
|
2353
2372
|
/**
|
|
2354
2373
|
* One resolved concept target: the argument as typed, the bundle-relative
|
|
2355
2374
|
* posix file path, and the concept id (absent only for a non-concept file
|
|
@@ -2398,7 +2417,7 @@ interface ContextTrustOptions {
|
|
|
2398
2417
|
*
|
|
2399
2418
|
* @public
|
|
2400
2419
|
*/
|
|
2401
|
-
export declare const runContextTrust: (options: ContextTrustOptions) => Effect.Effect<ContextTrust, BundleLoadError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path |
|
|
2420
|
+
export declare const runContextTrust: (options: ContextTrustOptions) => Effect.Effect<ContextTrust, BundleLoadError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Digest.Digest>;
|
|
2402
2421
|
declare const Now_base: Context.ServiceClass<Now, "@okfit/engine/Now", DateTime.Utc>;
|
|
2403
2422
|
/**
|
|
2404
2423
|
* K-47's ambient clock. `bin.ts` resolves `OKFIT_NOW` (or the wall clock)
|
|
@@ -2481,7 +2500,7 @@ interface RunResult {
|
|
|
2481
2500
|
*
|
|
2482
2501
|
* @public
|
|
2483
2502
|
*/
|
|
2484
|
-
export declare const run: (options: RunOptions) => Effect.Effect<RunResult, BundleLoadError | GitHistoryError | GitCommandError | UnknownRefError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Git | GitHistory |
|
|
2503
|
+
export declare const run: (options: RunOptions) => Effect.Effect<RunResult, BundleLoadError | GitHistoryError | GitCommandError | UnknownRefError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Git | GitHistory | Digest.Digest>;
|
|
2485
2504
|
/**
|
|
2486
2505
|
* What changed in a concept file since a human last verified it.
|
|
2487
2506
|
*
|
|
@@ -2509,11 +2528,10 @@ type ChangeSince = {
|
|
|
2509
2528
|
* at or before `at`; the patch is `git diff <baseline> -- <file>`.
|
|
2510
2529
|
*
|
|
2511
2530
|
* Git access: `@effected/git`'s `Git.log` (scoped to the file, newest first,
|
|
2512
|
-
* filtered here on `committedAt`) finds the baseline
|
|
2513
|
-
* and
|
|
2514
|
-
*
|
|
2515
|
-
* `
|
|
2516
|
-
* failure maps onto `Git`'s own `GitCommandError`.
|
|
2531
|
+
* filtered here on `committedAt`) finds the baseline (`Git.log` has no
|
|
2532
|
+
* `until`), and `Git.diffFile` produces the patch with the output-shaping
|
|
2533
|
+
* flags pinned, so user git config cannot change its bytes. Every diff
|
|
2534
|
+
* failure is reported as `GitCommandError`, the one error callers handle.
|
|
2517
2535
|
*
|
|
2518
2536
|
* @param options - `file` is the absolute path of the concept file; `at` is the
|
|
2519
2537
|
* time the binding recorded.
|
|
@@ -2537,7 +2555,7 @@ export declare const changeSince: (options: {
|
|
|
2537
2555
|
_tag: "diff";
|
|
2538
2556
|
baseline: string;
|
|
2539
2557
|
patch: string;
|
|
2540
|
-
}, GitCommandError,
|
|
2558
|
+
}, GitCommandError, Git | Path.Path>;
|
|
2541
2559
|
/** @internal */
|
|
2542
2560
|
interface VerifyOptions {
|
|
2543
2561
|
readonly id: string;
|
|
@@ -2644,8 +2662,8 @@ export declare const runVerify: (options: VerifyOptions) => Effect.Effect<{
|
|
|
2644
2662
|
} | null;
|
|
2645
2663
|
statusFragment: string | null;
|
|
2646
2664
|
content: string;
|
|
2647
|
-
priorDrift: "actor-not-allowed" | "content-changed" | "entry-superseded" | "unbound" | null;
|
|
2648
|
-
}, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/
|
|
2665
|
+
priorDrift: "actor-not-allowed" | "content-changed" | "content-unhashable" | "entry-superseded" | "unbound" | null;
|
|
2666
|
+
}, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyContentUnhashableError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
|
|
2649
2667
|
/**
|
|
2650
2668
|
* What {@link inspectDrift} found out about one concept before a re-verify.
|
|
2651
2669
|
*
|
|
@@ -2675,9 +2693,9 @@ export declare const inspectDrift: (options: {
|
|
|
2675
2693
|
}) => Effect.Effect<{
|
|
2676
2694
|
id: ConceptId;
|
|
2677
2695
|
absolutePath: string;
|
|
2678
|
-
drift: "actor-not-allowed" | "content-changed" | "entry-superseded" | "unbound" | null;
|
|
2696
|
+
drift: "actor-not-allowed" | "content-changed" | "content-unhashable" | "entry-superseded" | "unbound" | null;
|
|
2679
2697
|
boundAt?: DateTime.Utc;
|
|
2680
|
-
},
|
|
2698
|
+
}, VerifyConceptNotFoundError | import("@okfit/core").BundleLoadError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | Path.Path>;
|
|
2681
2699
|
/**
|
|
2682
2700
|
* Options for {@link runRevoke}.
|
|
2683
2701
|
*
|
|
@@ -2782,7 +2800,7 @@ export declare const runVerifyBatch: (options: VerifyBatchOptions) => Effect.Eff
|
|
|
2782
2800
|
readonly id: string;
|
|
2783
2801
|
readonly reason: VerifyBatchSkipReason;
|
|
2784
2802
|
}[];
|
|
2785
|
-
}, import("effect/PlatformError").PlatformError | VerifySelectionError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/
|
|
2803
|
+
}, import("effect/PlatformError").PlatformError | VerifyContentUnhashableError | VerifySelectionError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
|
|
2786
2804
|
/**
|
|
2787
2805
|
* Issue #214: options for {@link runVerifyIds}.
|
|
2788
2806
|
*
|
|
@@ -2830,7 +2848,7 @@ export declare const runVerifyIds: (options: VerifyIdsOptions) => Effect.Effect<
|
|
|
2830
2848
|
fragment: string;
|
|
2831
2849
|
}[];
|
|
2832
2850
|
skipped: never[];
|
|
2833
|
-
}, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/
|
|
2851
|
+
}, import("effect/PlatformError").PlatformError | VerifyConceptNotFoundError | VerifyContentUnhashableError | VerifyUnsupportedFrontmatterError | import("@effected/yaml").YamlParseError | import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
|
|
2834
2852
|
/**
|
|
2835
2853
|
* Options for {@link loadPickerCandidates}.
|
|
2836
2854
|
*
|
|
@@ -2851,7 +2869,7 @@ interface PickerCandidatesOptions {
|
|
|
2851
2869
|
export declare const loadPickerCandidates: (options: PickerCandidatesOptions) => Effect.Effect<{
|
|
2852
2870
|
by: Actor;
|
|
2853
2871
|
candidates: readonly PickerCandidate[];
|
|
2854
|
-
}, import("
|
|
2872
|
+
}, import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
|
|
2855
2873
|
/**
|
|
2856
2874
|
* Issue #228: as {@link loadPickerCandidates}, but the rows are the concepts
|
|
2857
2875
|
* stale at `now` (any type, the actor's own attestations included), for
|
|
@@ -2864,7 +2882,7 @@ export declare const loadStaleCandidates: (options: PickerCandidatesOptions & {
|
|
|
2864
2882
|
}) => Effect.Effect<{
|
|
2865
2883
|
by: Actor;
|
|
2866
2884
|
candidates: readonly PickerCandidate[];
|
|
2867
|
-
}, import("
|
|
2885
|
+
}, import("@okfit/core").BundleLoadError | import("@okfit/profiles").VerifierError, import("effect/crypto/Digest").Digest | FileSystem.FileSystem | import("@effected/git").Git | Path.Path>;
|
|
2868
2886
|
/**
|
|
2869
2887
|
* The verify picker's diff previews: for each drifted candidate, in candidate
|
|
2870
2888
|
* order and one at a time, what changed in its file since its verification was
|
|
@@ -2875,7 +2893,7 @@ export declare const loadStaleCandidates: (options: PickerCandidatesOptions & {
|
|
|
2875
2893
|
*
|
|
2876
2894
|
* @public
|
|
2877
2895
|
*/
|
|
2878
|
-
export declare const loadPreviews: (candidates: readonly PickerCandidate[]) => Effect.Effect<ReadonlyMap<string, ChangeSince>, never, import("
|
|
2896
|
+
export declare const loadPreviews: (candidates: readonly PickerCandidate[]) => Effect.Effect<ReadonlyMap<string, ChangeSince>, never, import("@effected/git").Git | Path.Path>;
|
|
2879
2897
|
/**
|
|
2880
2898
|
* The version this engine reports as `engine_version` in every JSON
|
|
2881
2899
|
* envelope. `@savvy-web/bundler` replaces `process.env.__PACKAGE_VERSION__`
|
package/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { resolveBundleRoot, resolveProjectRoot } from "./config/anchor.js";
|
|
2
|
-
import { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError } from "./errors.js";
|
|
3
2
|
import { buildConfigLayer, provideConfig } from "./config/layer.js";
|
|
4
3
|
import { DEFAULT_PROFILE_NAME, resolveProjectConfig } from "./config/resolve.js";
|
|
5
4
|
import { runContext } from "./context/run.js";
|
|
6
5
|
import { FrontmatterEdits, UnsupportedFrontmatterError } from "./edits/FrontmatterEdits.js";
|
|
6
|
+
import { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError } from "./errors.js";
|
|
7
7
|
import { ExternalReferences, ReferenceCheck, ReferenceState } from "./external/ExternalReferences.js";
|
|
8
8
|
import { runGraph } from "./graph/run.js";
|
|
9
9
|
import { CONFIG_RELATIVE_PATH, configValue, files, targetPaths } from "./init/scaffold.js";
|
|
10
10
|
import { referencesOf, rewriteReference } from "./move/references.js";
|
|
11
|
-
import { Targets } from "./targets/resolve.js";
|
|
12
11
|
import { planMove, runMove } from "./move/run.js";
|
|
13
|
-
import { OverlayDocuments, layerOverlayFileSystem, makeOverlayFileSystem } from "./overlay/layer.js";
|
|
14
12
|
import { provideDocuments, resolveDocumentPath } from "./overlay/documents.js";
|
|
13
|
+
import { OverlayDocuments, layerOverlayFileSystem, makeOverlayFileSystem } from "./overlay/layer.js";
|
|
15
14
|
import { OkfitPlatform } from "./platform.js";
|
|
16
15
|
import { ConceptQuery } from "./query/ConceptQuery.js";
|
|
17
16
|
import { ContextEnvelope, ContextField, ContextFieldValue, ContextTag, ContextTrust, ContextType, contextEnvelope } from "./render/context.js";
|
|
18
17
|
import { DistributionField } from "./render/distribution.js";
|
|
19
18
|
import { forDiagnostics, tally } from "./render/exit.js";
|
|
20
|
-
import { ENGINE_VERSION } from "./version.js";
|
|
21
19
|
import { GraphEdgeEnvelope, GraphEnvelope, GraphNodeEnvelope, GraphSummary, graphEnvelope } from "./render/graph.js";
|
|
22
|
-
import { collect, sort } from "./render/sort.js";
|
|
23
20
|
import { JsonDiagnostic, JsonEnvelope, JsonErrorEnvelope, JsonSummary, json, jsonError } from "./render/json.js";
|
|
24
21
|
import { MoveEnvelope, moveEnvelope } from "./render/move.js";
|
|
25
22
|
import { ConceptSummary, QueryGetEnvelope, QueryLink, QueryListEnvelope, QueryNeighbor, QueryNeighborsEnvelope, TrustDrift, queryGetEnvelope, queryListEnvelope, queryNeighborsEnvelope, signalFor, toConceptSummary, toTrustDrift } from "./render/query.js";
|
|
23
|
+
import { collect, sort } from "./render/sort.js";
|
|
26
24
|
import { StaleEnvelope, StaleItem, StaleSummary, staleEnvelope } from "./render/stale.js";
|
|
27
|
-
import { SkipReason, applySyncPlan, planSync, runSync } from "./sync/run.js";
|
|
28
25
|
import { PublicationEnvelope, SyncEnvelope, SyncModeEnvelope, syncEnvelope } from "./render/sync.js";
|
|
29
26
|
import { RevokeEnvelope, VerifyBatchEnvelope, VerifyEnvelope, revokeEnvelope, verifyBatchEnvelope, verifyEnvelope } from "./render/verify.js";
|
|
30
|
-
import {
|
|
27
|
+
import { BundleSession } from "./session/BundleSession.js";
|
|
31
28
|
import { conceptFor } from "./session/concept.js";
|
|
32
29
|
import { withFallbackRange } from "./session/range.js";
|
|
33
|
-
import { BundleSession } from "./session/BundleSession.js";
|
|
34
30
|
import { runStale } from "./stale/run.js";
|
|
35
31
|
import { NotAPublicationError, PublicationNotFoundError, stampPublication } from "./sync/publication.js";
|
|
32
|
+
import { SkipReason, applySyncPlan, planSync, runSync } from "./sync/run.js";
|
|
33
|
+
import { Targets } from "./targets/resolve.js";
|
|
36
34
|
import { runContextTrust } from "./trust/run.js";
|
|
35
|
+
import { Now, run } from "./validate/run.js";
|
|
37
36
|
import { changeSince } from "./verify/diff.js";
|
|
38
|
-
import { resolveBatchTypes, selectAttestable, selectPickerCandidates, selectStaleCandidates } from "./verify/select.js";
|
|
39
37
|
import { inspectDrift, loadPickerCandidates, loadPreviews, loadStaleCandidates, runRevoke, runRevokeIds, runVerify, runVerifyBatch, runVerifyIds } from "./verify/run.js";
|
|
38
|
+
import { resolveBatchTypes, selectAttestable, selectPickerCandidates, selectStaleCandidates } from "./verify/select.js";
|
|
39
|
+
import { ENGINE_VERSION } from "./version.js";
|
|
40
40
|
|
|
41
|
-
export { BundleSession, CONFIG_RELATIVE_PATH, ConceptQuery, ConceptSummary, ConfigMalformedError, ConfigPathNotFoundError, ContextEnvelope, ContextField, ContextFieldValue, ContextTag, ContextTrust, ContextType, DEFAULT_PROFILE_NAME, DistributionField, DocumentPathError, ENGINE_VERSION, ExternalReferences, FrontmatterEdits, GraphEdgeEnvelope, GraphEnvelope, GraphNodeEnvelope, GraphSummary, InitOverwriteError, JsonDiagnostic, JsonEnvelope, JsonErrorEnvelope, JsonSummary, MoveEnvelope, MoveError, NotAPublicationError, Now, OkfitPlatform, OverlayDocuments, PublicationEnvelope, PublicationNotFoundError, QueryConceptNotFoundError, QueryGetEnvelope, QueryLink, QueryListEnvelope, QueryNeighbor, QueryNeighborsEnvelope, QuerySelectionError, QueryUnknownVocabularyError, ReferenceCheck, ReferenceState, RevokeEnvelope, SkipReason, StaleEnvelope, StaleItem, StaleSummary, SyncEnvelope, SyncModeEnvelope, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, Targets, TrustDrift, UnsupportedFrontmatterError, VerifyBatchEnvelope, VerifyConceptNotFoundError, VerifyEnvelope, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError, applySyncPlan, buildConfigLayer, changeSince, collect, conceptFor, configValue, contextEnvelope, files, forDiagnostics, graphEnvelope, inspectDrift, json, jsonError, layerOverlayFileSystem, loadPickerCandidates, loadPreviews, loadStaleCandidates, makeOverlayFileSystem, moveEnvelope, planMove, planSync, provideConfig, provideDocuments, queryGetEnvelope, queryListEnvelope, queryNeighborsEnvelope, referencesOf, resolveBatchTypes, resolveBundleRoot, resolveDocumentPath, resolveProjectConfig, resolveProjectRoot, revokeEnvelope, rewriteReference, run, runContext, runContextTrust, runGraph, runMove, runRevoke, runRevokeIds, runStale, runSync, runVerify, runVerifyBatch, runVerifyIds, selectAttestable, selectPickerCandidates, selectStaleCandidates, signalFor, sort, staleEnvelope, stampPublication, syncEnvelope, tally, targetPaths, toConceptSummary, toTrustDrift, verifyBatchEnvelope, verifyEnvelope, withFallbackRange };
|
|
41
|
+
export { BundleSession, CONFIG_RELATIVE_PATH, ConceptQuery, ConceptSummary, ConfigMalformedError, ConfigPathNotFoundError, ContextEnvelope, ContextField, ContextFieldValue, ContextTag, ContextTrust, ContextType, DEFAULT_PROFILE_NAME, DistributionField, DocumentPathError, ENGINE_VERSION, ExternalReferences, FrontmatterEdits, GraphEdgeEnvelope, GraphEnvelope, GraphNodeEnvelope, GraphSummary, InitOverwriteError, JsonDiagnostic, JsonEnvelope, JsonErrorEnvelope, JsonSummary, MoveEnvelope, MoveError, NotAPublicationError, Now, OkfitPlatform, OverlayDocuments, PublicationEnvelope, PublicationNotFoundError, QueryConceptNotFoundError, QueryGetEnvelope, QueryLink, QueryListEnvelope, QueryNeighbor, QueryNeighborsEnvelope, QuerySelectionError, QueryUnknownVocabularyError, ReferenceCheck, ReferenceState, RevokeEnvelope, SkipReason, StaleEnvelope, StaleItem, StaleSummary, SyncEnvelope, SyncModeEnvelope, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, Targets, TrustDrift, UnsupportedFrontmatterError, VerifyBatchEnvelope, VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyEnvelope, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError, applySyncPlan, buildConfigLayer, changeSince, collect, conceptFor, configValue, contextEnvelope, files, forDiagnostics, graphEnvelope, inspectDrift, json, jsonError, layerOverlayFileSystem, loadPickerCandidates, loadPreviews, loadStaleCandidates, makeOverlayFileSystem, moveEnvelope, planMove, planSync, provideConfig, provideDocuments, queryGetEnvelope, queryListEnvelope, queryNeighborsEnvelope, referencesOf, resolveBatchTypes, resolveBundleRoot, resolveDocumentPath, resolveProjectConfig, resolveProjectRoot, revokeEnvelope, rewriteReference, run, runContext, runContextTrust, runGraph, runMove, runRevoke, runRevokeIds, runStale, runSync, runVerify, runVerifyBatch, runVerifyIds, selectAttestable, selectPickerCandidates, selectStaleCandidates, signalFor, sort, staleEnvelope, stampPublication, syncEnvelope, tally, targetPaths, toConceptSummary, toTrustDrift, verifyBatchEnvelope, verifyEnvelope, withFallbackRange };
|
package/move/run.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { MoveError } from "../errors.js";
|
|
2
|
-
import { referencesOf, rewriteReference } from "./references.js";
|
|
3
2
|
import { writeAtomic } from "../sync/write.js";
|
|
4
|
-
import { relativeInside } from "../targets/inside.js";
|
|
5
3
|
import { Targets } from "../targets/resolve.js";
|
|
4
|
+
import { referencesOf, rewriteReference } from "./references.js";
|
|
6
5
|
import { Bundle, ConceptId } from "@okfit/core";
|
|
7
6
|
import { Effect, FileSystem, Option, Path } from "effect";
|
|
8
7
|
import { Trust } from "@okfit/profiles";
|
|
9
8
|
import { MarkdownEdit } from "@effected/markdown";
|
|
10
9
|
import { posix } from "node:path";
|
|
10
|
+
import { relativeWithin } from "@effected/walker";
|
|
11
11
|
|
|
12
12
|
// src/move/run.ts
|
|
13
13
|
const withMd = (value) => value.endsWith(".md") ? value : `${value}.md`;
|
|
@@ -21,24 +21,20 @@ const resolveDestination = Effect.fn("okfit/move/destination")(function* (to, cw
|
|
|
21
21
|
const fs = yield* FileSystem.FileSystem;
|
|
22
22
|
const path = yield* Path.Path;
|
|
23
23
|
const realOr = (absolute) => fs.realPath(absolute).pipe(Effect.orElseSucceed(() => absolute));
|
|
24
|
-
/** Real path of the deepest existing ancestor, re-joined with the rest (the file does not exist yet). */
|
|
25
|
-
const realish = (absolute) => Effect.gen(function* () {
|
|
26
|
-
const resolved = yield* fs.realPath(absolute).pipe(Effect.option);
|
|
27
|
-
if (Option.isSome(resolved)) return resolved.value;
|
|
28
|
-
const parent = path.dirname(absolute);
|
|
29
|
-
if (parent === absolute) return absolute;
|
|
30
|
-
return path.join(yield* realish(parent), path.basename(absolute));
|
|
31
|
-
});
|
|
32
24
|
const root = yield* realOr(bundle.root);
|
|
33
|
-
/**
|
|
34
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Bundle-relative posix path of `absolute` (`""` for the root itself), resolved physically through
|
|
27
|
+
* its deepest existing ancestor, since the destination does not exist yet (`@effected/walker`'s
|
|
28
|
+
* `relativeWithin`); `undefined` outside the bundle or when containment cannot be proved.
|
|
29
|
+
*/
|
|
30
|
+
const within = (absolute) => Effect.map(relativeWithin(root, absolute), Option.getOrUndefined);
|
|
35
31
|
const exists = (absolute) => fs.exists(absolute).pipe(Effect.orElseSucceed(() => false));
|
|
36
32
|
const isDirectory = (absolute) => fs.stat(absolute).pipe(Effect.map((info) => info.type === "Directory"), Effect.orElseSucceed(() => false));
|
|
37
33
|
const trailingSlash = /\/$/.test(to);
|
|
38
34
|
const spelled = trailingSlash ? to.replace(/\/+$/, "") : to;
|
|
39
35
|
const base = posix.basename(sourcePath);
|
|
40
36
|
const underCwd = path.isAbsolute(spelled) ? spelled : path.resolve(cwd, spelled);
|
|
41
|
-
const cwdPath =
|
|
37
|
+
const cwdPath = yield* within(underCwd);
|
|
42
38
|
const lexicalInside = (base) => {
|
|
43
39
|
const relative = path.relative(base, underCwd);
|
|
44
40
|
return relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
@@ -49,7 +45,7 @@ const resolveDestination = Effect.fn("okfit/move/destination")(function* (to, cw
|
|
|
49
45
|
if (!idReadable) return void 0;
|
|
50
46
|
const id = Option.getOrUndefined(ConceptId.normalize(spelled));
|
|
51
47
|
if (id === void 0) return void 0;
|
|
52
|
-
return
|
|
48
|
+
return yield* within(path.join(root, posix.normalize(id)));
|
|
53
49
|
});
|
|
54
50
|
const dirs = [cwdPath, idPath].filter((candidate) => candidate !== void 0);
|
|
55
51
|
const existingDir = yield* Effect.findFirst(dirs, (candidate) => isDirectory(path.join(root, candidate)));
|
package/overlay/layer.js
CHANGED
|
@@ -71,7 +71,8 @@ const shadowInfo = (documents, path, read) => Effect.flatMap(documents.get(path)
|
|
|
71
71
|
}));
|
|
72
72
|
/**
|
|
73
73
|
* Wrap `underlying` so `readFile`, `readFileString`, `exists`, `stat` and `lstat` answer
|
|
74
|
-
* from `documents` for open paths, and a non-recursive `readDirectory`
|
|
74
|
+
* from `documents` for open paths, and a non-recursive `readDirectory` (and
|
|
75
|
+
* `readDirectoryEntries`, Effect 4.1's typed listing, as a `"File"`) also lists
|
|
75
76
|
* open documents whose parent is the directory read (so a brand-new unsaved file
|
|
76
77
|
* is walked). Every other member, and every path not open, is `underlying`'s.
|
|
77
78
|
*
|
|
@@ -95,11 +96,23 @@ const makeOverlayFileSystem = (underlying, documents) => FileSystem.FileSystem.o
|
|
|
95
96
|
lstat: (path) => shadowInfo(documents, path, underlying.lstat),
|
|
96
97
|
readDirectory: (path, options) => options?.recursive === true ? underlying.readDirectory(path, options) : Effect.gen(function* () {
|
|
97
98
|
const names = yield* underlying.readDirectory(path, options);
|
|
98
|
-
const
|
|
99
|
-
const extra = (yield* documents.entries()).map(([key]) => parentAndName(key)).filter(([parent, name]) => parent === directory && !names.includes(name)).map(([, name]) => name);
|
|
99
|
+
const extra = yield* overlayOnlyNames(documents, path, names);
|
|
100
100
|
return extra.length === 0 ? names : [...names, ...extra];
|
|
101
|
+
}),
|
|
102
|
+
readDirectoryEntries: (path) => Effect.gen(function* () {
|
|
103
|
+
const entries = yield* underlying.readDirectoryEntries(path);
|
|
104
|
+
const extra = yield* overlayOnlyNames(documents, path, entries.map((entry) => entry.name));
|
|
105
|
+
return extra.length === 0 ? entries : [...entries, ...extra.map((name) => ({
|
|
106
|
+
name,
|
|
107
|
+
type: "File"
|
|
108
|
+
}))];
|
|
101
109
|
})
|
|
102
110
|
});
|
|
111
|
+
/** Names of open documents directly under `path` that `listed` does not already hold. */
|
|
112
|
+
const overlayOnlyNames = (documents, path, listed) => Effect.map(documents.entries(), (entries) => {
|
|
113
|
+
const directory = trimTrailingSeparators(path);
|
|
114
|
+
return entries.map(([key]) => parentAndName(key)).filter(([parent, name]) => parent === directory && !listed.includes(name)).map(([, name]) => name);
|
|
115
|
+
});
|
|
103
116
|
/**
|
|
104
117
|
* The ambient `FileSystem`, shadowed by the ambient `OverlayDocuments`.
|
|
105
118
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okfit/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The okfit engine: platform layer, config discovery, and the validate, verify, sync, init and context programs shared by the okfit CLI and MCP server.",
|
|
6
6
|
"keywords": [
|
|
@@ -34,24 +34,24 @@
|
|
|
34
34
|
"./package.json": "./package.json"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@effect/platform-node": "
|
|
38
|
-
"@effected/app": "^0.
|
|
39
|
-
"@effected/config-file": "^0.
|
|
40
|
-
"@effected/
|
|
41
|
-
"@effected/
|
|
42
|
-
"@effected/
|
|
43
|
-
"@effected/
|
|
44
|
-
"@effected/markdown": "^0.
|
|
45
|
-
"@effected/schemastore": "^0.
|
|
46
|
-
"@effected/source": "^0.
|
|
47
|
-
"@effected/store": "^0.
|
|
48
|
-
"@effected/toml": "^0.
|
|
49
|
-
"@effected/walker": "^0.
|
|
50
|
-
"@effected/xdg": "^0.
|
|
51
|
-
"@effected/yaml": "^0.
|
|
52
|
-
"@okfit/core": "0.
|
|
53
|
-
"@okfit/profiles": "0.
|
|
54
|
-
"effect": "
|
|
37
|
+
"@effect/platform-node": "~4.1.2",
|
|
38
|
+
"@effected/app": "^0.31.0",
|
|
39
|
+
"@effected/config-file": "^0.24.0",
|
|
40
|
+
"@effected/git": "^0.30.0",
|
|
41
|
+
"@effected/glob": "^0.18.0",
|
|
42
|
+
"@effected/jsonc": "^0.23.0",
|
|
43
|
+
"@effected/kit": "^0.12.0",
|
|
44
|
+
"@effected/markdown": "^0.26.0",
|
|
45
|
+
"@effected/schemastore": "^0.29.0",
|
|
46
|
+
"@effected/source": "^0.3.0",
|
|
47
|
+
"@effected/store": "^0.23.0",
|
|
48
|
+
"@effected/toml": "^0.19.0",
|
|
49
|
+
"@effected/walker": "^0.25.0",
|
|
50
|
+
"@effected/xdg": "^0.19.0",
|
|
51
|
+
"@effected/yaml": "^0.28.0",
|
|
52
|
+
"@okfit/core": "0.12.1",
|
|
53
|
+
"@okfit/profiles": "0.14.1",
|
|
54
|
+
"effect": "~4.1.2"
|
|
55
55
|
},
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=24.11.0"
|
package/platform.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
+
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
2
3
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
3
4
|
import { AppDirs, Xdg } from "@effected/xdg";
|
|
4
5
|
|
|
@@ -16,8 +17,9 @@ const OKFIT_APP_NAMESPACE = "okfit";
|
|
|
16
17
|
* `Layer.provide(Xdg.layer)` alone does not close it.
|
|
17
18
|
* `Layer.provideMerge(NodeServices.layer)` supplies `FileSystem`/`Path` to
|
|
18
19
|
* both members and keeps every service in the output.
|
|
19
|
-
* `NodeServices.layer` provides `ChildProcessSpawner |
|
|
20
|
-
* a superset of `Command.Environment`.
|
|
20
|
+
* `NodeServices.layer` provides `ChildProcessSpawner | FileSystem | Path | Stdio | Terminal`,
|
|
21
|
+
* a superset of `Command.Environment`. Since Effect 4.1 it carries no crypto, so
|
|
22
|
+
* `NodeCrypto.layerDigest` supplies the `Digest` every body and content digest needs.
|
|
21
23
|
*
|
|
22
24
|
* K-13: `Xdg.layer` fails with `XdgEnvError` when `HOME` is unset. Callers
|
|
23
25
|
* are responsible for providing this layer INSIDE whatever region renders
|
|
@@ -26,6 +28,6 @@ const OKFIT_APP_NAMESPACE = "okfit";
|
|
|
26
28
|
*
|
|
27
29
|
* @public
|
|
28
30
|
*/
|
|
29
|
-
const OkfitPlatform = Layer.mergeAll(Xdg.layer, AppDirs.layer({ namespace: OKFIT_APP_NAMESPACE }).pipe(Layer.provide(Xdg.layer))).pipe(Layer.provideMerge(NodeServices.layer));
|
|
31
|
+
const OkfitPlatform = Layer.mergeAll(Xdg.layer, AppDirs.layer({ namespace: OKFIT_APP_NAMESPACE }).pipe(Layer.provide(Xdg.layer))).pipe(Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layerDigest)));
|
|
30
32
|
|
|
31
33
|
export { OKFIT_APP_NAMESPACE, OkfitPlatform };
|
package/render/distribution.js
CHANGED
package/render/graph.js
CHANGED
package/render/json.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { ENGINE_VERSION } from "../version.js";
|
|
1
2
|
import { DistributionField as DistributionField$1 } from "./distribution.js";
|
|
2
3
|
import { tally } from "./exit.js";
|
|
3
|
-
import { ENGINE_VERSION } from "../version.js";
|
|
4
4
|
import { sort } from "./sort.js";
|
|
5
5
|
import { DiagnosticRange, DiagnosticSeverity } from "@okfit/core";
|
|
6
6
|
import { Runtime, Schema } from "effect";
|
|
7
|
-
import { ErrorText } from "@effected/
|
|
7
|
+
import { ErrorText } from "@effected/kit";
|
|
8
8
|
|
|
9
9
|
// src/render/json.ts
|
|
10
10
|
/** One entry of the `diagnostics` array (K-21). @public */
|
package/render/move.js
CHANGED
package/render/query.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DistributionField } from "./distribution.js";
|
|
2
1
|
import { ENGINE_VERSION } from "../version.js";
|
|
2
|
+
import { DistributionField } from "./distribution.js";
|
|
3
3
|
import { Derive, GraphNodeKind, Status } from "@okfit/core";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
import { DriftReason } from "@okfit/profiles";
|
package/render/stale.js
CHANGED
package/render/sync.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DistributionField } from "./distribution.js";
|
|
2
|
-
import { ENGINE_VERSION } from "../version.js";
|
|
3
1
|
import { SkipReason } from "../sync/run.js";
|
|
2
|
+
import { ENGINE_VERSION } from "../version.js";
|
|
3
|
+
import { DistributionField } from "./distribution.js";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
|
|
6
6
|
// src/render/sync.ts
|
package/render/verify.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DistributionField } from "./distribution.js";
|
|
2
1
|
import { ENGINE_VERSION } from "../version.js";
|
|
2
|
+
import { DistributionField } from "./distribution.js";
|
|
3
3
|
import { Status } from "@okfit/core";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
import { DriftReason } from "@okfit/profiles";
|
package/sync/generated.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FrontmatterEdits } from "../edits/FrontmatterEdits.js";
|
|
2
2
|
import { locateIntegrity, locateLegacyBodySha256, removeLine, spliceIntegrityGenerated } from "../verify/integrity.js";
|
|
3
|
+
import { detectNewline, locateGenerated, locateGeneratedBlock, stripBom } from "../verify/locate.js";
|
|
3
4
|
import { mergeSameOffset, spliceGenerated, spliceGeneratedBlock } from "../verify/splice.js";
|
|
4
|
-
import { FrontmatterEdits } from "../edits/FrontmatterEdits.js";
|
|
5
5
|
import { writeAtomic } from "./write.js";
|
|
6
6
|
import { Timestamp } from "@okfit/core";
|
|
7
7
|
import { Effect, FileSystem, Path, Schema } from "effect";
|
package/sync/run.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SyncPlanStaleError } from "../errors.js";
|
|
2
|
-
import { writeAtomic } from "./write.js";
|
|
3
2
|
import { syncGenerated } from "./generated.js";
|
|
4
3
|
import { syncIndex } from "./index.js";
|
|
5
4
|
import { logWindow, syncLog, wantsLogEntry } from "./log.js";
|
|
5
|
+
import { writeAtomic } from "./write.js";
|
|
6
6
|
import { Bundle, Derive } from "@okfit/core";
|
|
7
7
|
import { DateTime, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
8
8
|
import { Derivation } from "@okfit/profiles";
|
package/sync/write.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, FileSystem, Option, Path } from "effect";
|
|
2
|
-
import {
|
|
2
|
+
import { SecureRandom } from "effect/crypto";
|
|
3
3
|
|
|
4
4
|
// src/sync/write.ts
|
|
5
5
|
/**
|
|
@@ -22,8 +22,8 @@ import { randomUUID } from "node:crypto";
|
|
|
22
22
|
* DISCREPANCY from S-33's literal "the temp name carries the pid": `src/`
|
|
23
23
|
* outside `bin.ts`/`commands/*`/`internal/exit.ts`/`internal/tty.ts` never
|
|
24
24
|
* reads the global `process` (K-39, enforced by `__test__/boundaries.test.ts`),
|
|
25
|
-
* and `sync/write.ts` is not on that allowlist. A
|
|
26
|
-
* (`
|
|
25
|
+
* and `sync/write.ts` is not on that allowlist. A random UUIDv4 token
|
|
26
|
+
* (`SecureRandom.uuidV4Unsafe` from `effect/crypto`, not `process`) satisfies S-33's actual requirement --
|
|
27
27
|
* two concurrent `sync` runs never collide on a fixed temp name -- without
|
|
28
28
|
* widening the process-access boundary for one helper. Recorded here per
|
|
29
29
|
* the Global Constraints' "record the discrepancy" instruction.
|
|
@@ -36,7 +36,7 @@ const writeAtomic = Effect.fn("okfit/sync/writeAtomic")(function* (target, conte
|
|
|
36
36
|
const resolved = yield* fs.realPath(target).pipe(Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(target)));
|
|
37
37
|
const dir = path.dirname(resolved);
|
|
38
38
|
const base = path.basename(resolved);
|
|
39
|
-
const tempPath = path.join(dir, `${base}.okfit-sync.${
|
|
39
|
+
const tempPath = path.join(dir, `${base}.okfit-sync.${SecureRandom.uuidV4Unsafe()}.tmp`);
|
|
40
40
|
const originalMode = yield* fs.stat(resolved).pipe(Effect.map((info) => Option.some(info.mode)), Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(Option.none())));
|
|
41
41
|
yield* fs.writeFileString(tempPath, contents).pipe(Effect.tap(() => Option.match(originalMode, {
|
|
42
42
|
onNone: () => Effect.void,
|
package/tsdoc-metadata.json
CHANGED
package/verify/diff.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DateTime, Effect, Path } from "effect";
|
|
2
2
|
import { Git, GitCommandError } from "@effected/git";
|
|
3
|
-
import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
4
3
|
|
|
5
4
|
// src/verify/diff.ts
|
|
6
5
|
/**
|
|
@@ -11,11 +10,10 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
|
11
10
|
* at or before `at`; the patch is `git diff <baseline> -- <file>`.
|
|
12
11
|
*
|
|
13
12
|
* Git access: `@effected/git`'s `Git.log` (scoped to the file, newest first,
|
|
14
|
-
* filtered here on `committedAt`) finds the baseline
|
|
15
|
-
* and
|
|
16
|
-
*
|
|
17
|
-
* `
|
|
18
|
-
* failure maps onto `Git`'s own `GitCommandError`.
|
|
13
|
+
* filtered here on `committedAt`) finds the baseline (`Git.log` has no
|
|
14
|
+
* `until`), and `Git.diffFile` produces the patch with the output-shaping
|
|
15
|
+
* flags pinned, so user git config cannot change its bytes. Every diff
|
|
16
|
+
* failure is reported as `GitCommandError`, the one error callers handle.
|
|
19
17
|
*
|
|
20
18
|
* @param options - `file` is the absolute path of the concept file; `at` is the
|
|
21
19
|
* time the binding recorded.
|
|
@@ -23,7 +21,6 @@ import { ChildProcess, ChildProcessSpawner } from "effect/process";
|
|
|
23
21
|
*/
|
|
24
22
|
const changeSince = Effect.fn("okfit/verify/changeSince")(function* (options) {
|
|
25
23
|
const git = yield* Git;
|
|
26
|
-
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
27
24
|
const path = yield* Path.Path;
|
|
28
25
|
const cwd = path.dirname(options.file);
|
|
29
26
|
const name = path.basename(options.file);
|
|
@@ -37,26 +34,28 @@ const changeSince = Effect.fn("okfit/verify/changeSince")(function* (options) {
|
|
|
37
34
|
_tag: "no-baseline",
|
|
38
35
|
reason: "no-commit-before"
|
|
39
36
|
};
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"--",
|
|
46
|
-
name
|
|
47
|
-
];
|
|
48
|
-
const patch = yield* spawner.string(ChildProcess.setCwd(ChildProcess.make("git", args), cwd)).pipe(Effect.mapError((error) => new GitCommandError({
|
|
49
|
-
kind: "failed",
|
|
50
|
-
args,
|
|
51
|
-
cwd,
|
|
52
|
-
stderr: "",
|
|
53
|
-
detail: error.message
|
|
54
|
-
})));
|
|
37
|
+
const patch = yield* git.diffFile(cwd, baseline.sha, name, { allowMissing: true }).pipe(Effect.catchTags({
|
|
38
|
+
NotARepositoryError: (error) => Effect.fail(asCommandError(error, baseline.sha, name, cwd)),
|
|
39
|
+
UnknownRefError: (error) => Effect.fail(asCommandError(error, baseline.sha, name, cwd)),
|
|
40
|
+
FileNotFoundError: (error) => Effect.fail(asCommandError(error, baseline.sha, name, cwd))
|
|
41
|
+
}));
|
|
55
42
|
return {
|
|
56
43
|
_tag: "diff",
|
|
57
44
|
baseline: baseline.sha.slice(0, 7),
|
|
58
45
|
patch
|
|
59
46
|
};
|
|
60
47
|
});
|
|
48
|
+
const asCommandError = (error, ref, name, cwd) => new GitCommandError({
|
|
49
|
+
kind: "failed",
|
|
50
|
+
args: [
|
|
51
|
+
"diff",
|
|
52
|
+
ref,
|
|
53
|
+
"--",
|
|
54
|
+
name
|
|
55
|
+
],
|
|
56
|
+
cwd,
|
|
57
|
+
stderr: "",
|
|
58
|
+
detail: error.message
|
|
59
|
+
});
|
|
61
60
|
|
|
62
61
|
export { changeSince };
|
package/verify/run.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifyUnsupportedFrontmatterError } from "../errors.js";
|
|
2
|
-
import { documentNewline, locate, locateTopLevelScalar, locateVerifiedAt, stripBom } from "./locate.js";
|
|
3
|
-
import { locateIntegrity, removeIntegrityVerified, spliceIntegrityVerified } from "./integrity.js";
|
|
4
|
-
import { orderVerifyEdits, quoteLike, splice, spliceTopLevelScalar } from "./splice.js";
|
|
1
|
+
import { VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyNothingToRevokeError, VerifyUnsupportedFrontmatterError } from "../errors.js";
|
|
5
2
|
import { changeSince } from "./diff.js";
|
|
3
|
+
import { locateIntegrity, removeIntegrityVerified, spliceIntegrityVerified } from "./integrity.js";
|
|
4
|
+
import { documentNewline, locate, locateTopLevelScalar, locateVerifiedAt, stripBom } from "./locate.js";
|
|
6
5
|
import { locateVerifiedEntries } from "./revoke.js";
|
|
7
6
|
import { resolveBatchTypes, selectAttestable, selectPickerCandidates, selectStaleCandidates } from "./select.js";
|
|
7
|
+
import { orderVerifyEdits, quoteLike, splice, spliceTopLevelScalar } from "./splice.js";
|
|
8
8
|
import { Bundle, ConceptId, Derive, Timestamp } from "@okfit/core";
|
|
9
9
|
import { DateTime, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
10
10
|
import { Derivation, Trust } from "@okfit/profiles";
|
|
@@ -29,7 +29,11 @@ const UNDECODABLE_CODES = /* @__PURE__ */ new Set([
|
|
|
29
29
|
]);
|
|
30
30
|
/** Steps 9-14 of runVerify: read, locate (fail closed), splice; no write. */
|
|
31
31
|
const prepareVerify = Effect.fn("okfit/verify/prepareVerify")(function* (bundle, concept, actor, at, status, staleAfter = void 0) {
|
|
32
|
-
const content = yield* Derivation.contentDigest(concept.frontmatter.raw, concept.document.source)
|
|
32
|
+
const content = yield* Derivation.contentDigest(concept.frontmatter.raw, concept.document.source).pipe(Effect.catchTag("ContentUnhashableError", (error) => Effect.fail(new VerifyContentUnhashableError({
|
|
33
|
+
id: concept.id,
|
|
34
|
+
path: error.path,
|
|
35
|
+
detail: error.detail
|
|
36
|
+
}))));
|
|
33
37
|
const fs = yield* FileSystem.FileSystem;
|
|
34
38
|
const absolutePath = (yield* Path.Path).join(bundle.root, concept.path);
|
|
35
39
|
const source = new TextDecoder("utf-8", { ignoreBOM: true }).decode(yield* fs.readFile(absolutePath));
|