@okfit/engine 0.16.5 → 0.17.0
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/config/layer.js +2 -1
- package/errors.js +1 -15
- package/index.d.ts +4 -17
- package/index.js +2 -2
- package/package.json +11 -11
- package/render/json.js +1 -1
- package/sync/run.js +44 -9
- package/tsdoc-metadata.json +1 -1
- package/version.js +1 -1
package/config/layer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ConfigMalformedError, ConfigPathNotFoundError } from "../errors.js";
|
|
2
2
|
import { AppConfig } from "@effected/app";
|
|
3
|
-
import { ConfigCodecError, ConfigResolver, ConfigValidationError, MergeStrategy
|
|
3
|
+
import { ConfigCodecError, ConfigResolver, ConfigValidationError, MergeStrategy } from "@effected/config-file";
|
|
4
|
+
import { TomlCodec } from "@effected/config-file/toml";
|
|
4
5
|
import { OkfitConfig, OkfitConfigFile } from "@okfit/core";
|
|
5
6
|
import { Cause, Effect, FileSystem, Option, Result } from "effect";
|
|
6
7
|
|
package/errors.js
CHANGED
|
@@ -128,20 +128,6 @@ var ConfigMalformedError = class extends Schema.TaggedError()("ConfigMalformedEr
|
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
/**
|
|
131
|
-
* Issue #140: `sync --staged` stamps the git index with a caller-given
|
|
132
|
-
* instant instead of walking history, but a log group's date must come
|
|
133
|
-
* from a commit, never from that stamp time -- so `runSync` refuses to
|
|
134
|
-
* combine `staged` with log mode rather than write a fabricated date.
|
|
135
|
-
*
|
|
136
|
-
* @public
|
|
137
|
-
*/
|
|
138
|
-
var SyncStagedLogError = class extends Schema.TaggedError()("SyncStagedLogError", {}) {
|
|
139
|
-
[Runtime.errorExitCode] = 64;
|
|
140
|
-
get message() {
|
|
141
|
-
return "--staged cannot run log mode: a log group's date must come from a commit, not from the stamp time; use --only generated and/or --only index";
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
131
|
* `applySyncPlan` found a file its plan would write changed since `planSync`
|
|
146
132
|
* read it, so applying the plan would overwrite an edit the plan never showed.
|
|
147
133
|
* Nothing was written. `paths` are the changed targets (absolute); re-run sync.
|
|
@@ -348,4 +334,4 @@ var MoveError = class extends Schema.TaggedError()("MoveError", {
|
|
|
348
334
|
}
|
|
349
335
|
};
|
|
350
336
|
|
|
351
|
-
export { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError,
|
|
337
|
+
export { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError };
|
package/index.d.ts
CHANGED
|
@@ -173,19 +173,6 @@ export declare class ConfigMalformedError extends ConfigMalformedError_base {
|
|
|
173
173
|
readonly [Runtime.errorExitCode] = 3;
|
|
174
174
|
get message(): string;
|
|
175
175
|
}
|
|
176
|
-
declare const SyncStagedLogError_base: Schema.Class<SyncStagedLogError, Schema.TaggedStruct<"SyncStagedLogError", {}>, import("effect/Cause").YieldableError>;
|
|
177
|
-
/**
|
|
178
|
-
* Issue #140: `sync --staged` stamps the git index with a caller-given
|
|
179
|
-
* instant instead of walking history, but a log group's date must come
|
|
180
|
-
* from a commit, never from that stamp time -- so `runSync` refuses to
|
|
181
|
-
* combine `staged` with log mode rather than write a fabricated date.
|
|
182
|
-
*
|
|
183
|
-
* @public
|
|
184
|
-
*/
|
|
185
|
-
export declare class SyncStagedLogError extends SyncStagedLogError_base {
|
|
186
|
-
readonly [Runtime.errorExitCode] = 64;
|
|
187
|
-
get message(): string;
|
|
188
|
-
}
|
|
189
176
|
declare const SyncPlanStaleError_base: Schema.Class<SyncPlanStaleError, Schema.TaggedStruct<"SyncPlanStaleError", {
|
|
190
177
|
readonly paths: Schema.$Array<Schema.String>;
|
|
191
178
|
}>, import("effect/Cause").YieldableError>;
|
|
@@ -1371,7 +1358,7 @@ export type JsonEnvelope = typeof JsonEnvelope.Type;
|
|
|
1371
1358
|
/**
|
|
1372
1359
|
* K-22's envelope: the ONLY thing stdout carries under `--format json` on an
|
|
1373
1360
|
* infrastructure failure. `exit_code` is `3` for most errors, or `64` for the
|
|
1374
|
-
* usage-tier errors (`
|
|
1361
|
+
* usage-tier errors (`VerifySelectionError` and the like) that carry
|
|
1375
1362
|
* their own `[Runtime.errorExitCode]`.
|
|
1376
1363
|
*
|
|
1377
1364
|
* @public
|
|
@@ -1765,7 +1752,7 @@ interface SyncOptions {
|
|
|
1765
1752
|
readonly dryRun: boolean;
|
|
1766
1753
|
/** Issue #18: log mode's inclusive floor (`YYYY-MM-DD`); default is the newest logged date. */
|
|
1767
1754
|
readonly logSince?: string;
|
|
1768
|
-
/** Issue #140: stamp the concepts in the git index with this instant instead of walking history
|
|
1755
|
+
/** Issue #140: stamp the concepts in the git index with this instant instead of walking history. Issue #295: log mode dates their entries with the same instant. */
|
|
1769
1756
|
readonly staged?: {
|
|
1770
1757
|
readonly at: DateTime.Utc;
|
|
1771
1758
|
};
|
|
@@ -1821,7 +1808,7 @@ interface SyncPlan {
|
|
|
1821
1808
|
*
|
|
1822
1809
|
* @public
|
|
1823
1810
|
*/
|
|
1824
|
-
export declare const planSync: (options: SyncOptions) => Effect.Effect<SyncPlan, BundleLoadError | GeneratedAtError
|
|
1811
|
+
export declare const planSync: (options: SyncOptions) => Effect.Effect<SyncPlan, BundleLoadError | GeneratedAtError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Crypto.Crypto>;
|
|
1825
1812
|
/**
|
|
1826
1813
|
* Performs exactly the writes a {@link SyncPlan} recorded (atomically, in plan
|
|
1827
1814
|
* order), then the `--staged` re-add, and returns the non-dry-run
|
|
@@ -1844,7 +1831,7 @@ export declare const applySyncPlan: (plan: SyncPlan) => Effect.Effect<{
|
|
|
1844
1831
|
*
|
|
1845
1832
|
* @public
|
|
1846
1833
|
*/
|
|
1847
|
-
export declare const runSync: (options: SyncOptions) => Effect.Effect<SyncResult, BundleLoadError | GeneratedAtError |
|
|
1834
|
+
export declare const runSync: (options: SyncOptions) => Effect.Effect<SyncResult, BundleLoadError | GeneratedAtError | SyncPlanStaleError, Git | GitHistory | FileSystem.FileSystem | Path.Path | Crypto.Crypto>;
|
|
1848
1835
|
/** @public */
|
|
1849
1836
|
export declare const SyncModeEnvelope: Schema.Struct<{
|
|
1850
1837
|
readonly selected: Schema.Boolean;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolveBundleRoot, resolveProjectRoot } from "./config/anchor.js";
|
|
2
|
-
import { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError,
|
|
2
|
+
import { ConfigMalformedError, ConfigPathNotFoundError, DocumentPathError, InitOverwriteError, MoveError, QueryConceptNotFoundError, QuerySelectionError, QueryUnknownVocabularyError, SyncPlanStaleError, SyncPublicationConflictError, TargetFailure, TargetResolutionError, VerifyConceptNotFoundError, VerifyNothingToRevokeError, VerifySelectionError, VerifyUnsupportedFrontmatterError } from "./errors.js";
|
|
3
3
|
import { buildConfigLayer, provideConfig } from "./config/layer.js";
|
|
4
4
|
import { DEFAULT_PROFILE_NAME, resolveProjectConfig } from "./config/resolve.js";
|
|
5
5
|
import { runContext } from "./context/run.js";
|
|
@@ -38,4 +38,4 @@ import { changeSince } from "./verify/diff.js";
|
|
|
38
38
|
import { resolveBatchTypes, selectAttestable, selectPickerCandidates, selectStaleCandidates } from "./verify/select.js";
|
|
39
39
|
import { inspectDrift, loadPickerCandidates, loadPreviews, loadStaleCandidates, runRevoke, runRevokeIds, runVerify, runVerifyBatch, runVerifyIds } from "./verify/run.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,
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okfit/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
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": [
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@effect/platform-node": "^4.0.6",
|
|
38
|
-
"@effected/app": "^0.
|
|
39
|
-
"@effected/config-file": "^0.
|
|
38
|
+
"@effected/app": "^0.27.0",
|
|
39
|
+
"@effected/config-file": "^0.20.0",
|
|
40
40
|
"@effected/engine": "^0.8.0",
|
|
41
41
|
"@effected/git": "^0.25.0",
|
|
42
42
|
"@effected/glob": "^0.14.0",
|
|
43
43
|
"@effected/jsonc": "^0.20.0",
|
|
44
|
-
"@effected/markdown": "^0.
|
|
45
|
-
"@effected/schemastore": "^0.26.
|
|
46
|
-
"@effected/store": "^0.
|
|
44
|
+
"@effected/markdown": "^0.23.0",
|
|
45
|
+
"@effected/schemastore": "^0.26.2",
|
|
46
|
+
"@effected/store": "^0.19.0",
|
|
47
47
|
"@effected/toml": "^0.16.0",
|
|
48
|
-
"@effected/walker": "^0.
|
|
49
|
-
"@effected/xdg": "^0.
|
|
50
|
-
"@effected/yaml": "^0.25.
|
|
51
|
-
"@okfit/core": "0.11.
|
|
52
|
-
"@okfit/profiles": "0.
|
|
48
|
+
"@effected/walker": "^0.20.0",
|
|
49
|
+
"@effected/xdg": "^0.15.0",
|
|
50
|
+
"@effected/yaml": "^0.25.1",
|
|
51
|
+
"@okfit/core": "0.11.6",
|
|
52
|
+
"@okfit/profiles": "0.11.0",
|
|
53
53
|
"effect": "^4.0.6"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
package/render/json.js
CHANGED
|
@@ -62,7 +62,7 @@ const JsonEnvelope = Schema.Struct({
|
|
|
62
62
|
/**
|
|
63
63
|
* K-22's envelope: the ONLY thing stdout carries under `--format json` on an
|
|
64
64
|
* infrastructure failure. `exit_code` is `3` for most errors, or `64` for the
|
|
65
|
-
* usage-tier errors (`
|
|
65
|
+
* usage-tier errors (`VerifySelectionError` and the like) that carry
|
|
66
66
|
* their own `[Runtime.errorExitCode]`.
|
|
67
67
|
*
|
|
68
68
|
* @public
|
package/sync/run.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { SyncPlanStaleError
|
|
1
|
+
import { SyncPlanStaleError } from "../errors.js";
|
|
2
2
|
import { writeAtomic } from "./write.js";
|
|
3
3
|
import { syncGenerated } from "./generated.js";
|
|
4
4
|
import { syncIndex } from "./index.js";
|
|
5
5
|
import { logWindow, syncLog, wantsLogEntry } from "./log.js";
|
|
6
6
|
import { Bundle, Derive } from "@okfit/core";
|
|
7
|
-
import { DateTime, Effect, FileSystem, Path, Schema } from "effect";
|
|
7
|
+
import { DateTime, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
8
8
|
import { Derivation } from "@okfit/profiles";
|
|
9
9
|
import { Git } from "@effected/git";
|
|
10
10
|
|
|
@@ -50,24 +50,27 @@ const UNSELECTED = {
|
|
|
50
50
|
*/
|
|
51
51
|
const planSync = Effect.fn("okfit/sync/planSync")(function* (options) {
|
|
52
52
|
const bundle = yield* Bundle.load({ root: options.bundleRoot });
|
|
53
|
-
if (options.staged !== void 0 && options.modes.has("log")) return yield* new SyncStagedLogError({});
|
|
54
53
|
const walked = /* @__PURE__ */ new Map();
|
|
55
54
|
let staged;
|
|
56
55
|
let scope;
|
|
57
56
|
let repoRoot;
|
|
58
57
|
let realPaths;
|
|
58
|
+
let stagedLog;
|
|
59
|
+
let logDirty = false;
|
|
59
60
|
if (options.staged !== void 0) {
|
|
60
61
|
const git = yield* Git;
|
|
61
62
|
const fs = yield* FileSystem.FileSystem;
|
|
62
63
|
const path = yield* Path.Path;
|
|
63
|
-
repoRoot = yield* fs.realPath(yield* git.repoRoot(bundle.root));
|
|
64
|
+
repoRoot = yield* fs.realPath((yield* Derivation.worktreeRoot(bundle.root)) ?? (yield* git.repoRoot(bundle.root)));
|
|
64
65
|
const stagedPaths = new Set(yield* git.stagedChanges(repoRoot));
|
|
65
66
|
const selected = /* @__PURE__ */ new Set();
|
|
66
67
|
const provenanceStaged = /* @__PURE__ */ new Map();
|
|
67
68
|
const resolvedPaths = /* @__PURE__ */ new Map();
|
|
69
|
+
const logProvenance = /* @__PURE__ */ new Map();
|
|
70
|
+
const root = repoRoot;
|
|
68
71
|
for (const [id, concept] of bundle.concepts) {
|
|
69
72
|
const real = yield* fs.realPath(path.join(bundle.root, concept.path));
|
|
70
|
-
const rel = path.relative(
|
|
73
|
+
const rel = path.relative(root, real).split(path.sep).join("/");
|
|
71
74
|
if (!stagedPaths.has(rel)) continue;
|
|
72
75
|
selected.add(id);
|
|
73
76
|
provenanceStaged.set(id, {
|
|
@@ -75,8 +78,24 @@ const planSync = Effect.fn("okfit/sync/planSync")(function* (options) {
|
|
|
75
78
|
at: options.staged.at
|
|
76
79
|
});
|
|
77
80
|
resolvedPaths.set(id, real);
|
|
81
|
+
if (options.modes.has("log")) {
|
|
82
|
+
const inHead = yield* git.show(root, "HEAD", rel).pipe(Effect.catchTag("UnknownRefError", () => Effect.succeed(Option.none())));
|
|
83
|
+
logProvenance.set(id, {
|
|
84
|
+
_tag: "committed",
|
|
85
|
+
at: options.staged.at,
|
|
86
|
+
creating: Option.isNone(inHead)
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (options.modes.has("log")) {
|
|
91
|
+
const logReal = yield* fs.realPath(path.join(bundle.root, "log.md")).pipe(Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(void 0)));
|
|
92
|
+
if (logReal !== void 0) {
|
|
93
|
+
const logRel = path.relative(root, logReal).split(path.sep).join("/");
|
|
94
|
+
logDirty = (yield* git.unstagedChanges(root)).includes(logRel);
|
|
95
|
+
}
|
|
78
96
|
}
|
|
79
97
|
staged = provenanceStaged;
|
|
98
|
+
stagedLog = logProvenance;
|
|
80
99
|
scope = selected;
|
|
81
100
|
realPaths = resolvedPaths;
|
|
82
101
|
} else if (options.modes.has("generated") || options.modes.has("log")) {
|
|
@@ -105,15 +124,31 @@ const planSync = Effect.fn("okfit/sync/planSync")(function* (options) {
|
|
|
105
124
|
...yield* syncIndex(bundle, true, pending),
|
|
106
125
|
migrated: []
|
|
107
126
|
} : UNSELECTED;
|
|
108
|
-
const log = options.modes.has("log") ? {
|
|
109
|
-
|
|
127
|
+
const log = !options.modes.has("log") ? UNSELECTED : logDirty ? {
|
|
128
|
+
selected: true,
|
|
129
|
+
written: [],
|
|
130
|
+
unchanged: [],
|
|
131
|
+
skipped: [{
|
|
132
|
+
id: "log.md",
|
|
133
|
+
reason: "dirty"
|
|
134
|
+
}],
|
|
110
135
|
migrated: []
|
|
111
|
-
} :
|
|
136
|
+
} : {
|
|
137
|
+
...yield* syncLog(bundle, stagedLog ?? walked, true, options.logSince, pending),
|
|
138
|
+
migrated: []
|
|
139
|
+
};
|
|
112
140
|
let restage;
|
|
113
141
|
if (options.staged !== void 0 && repoRoot !== void 0) {
|
|
114
142
|
const path = yield* Path.Path;
|
|
115
143
|
const writtenIds = /* @__PURE__ */ new Set([...generated.written, ...generated.migrated]);
|
|
116
|
-
const
|
|
144
|
+
const fs = yield* FileSystem.FileSystem;
|
|
145
|
+
const realBundle = yield* fs.realPath(bundle.root);
|
|
146
|
+
const reserved = [];
|
|
147
|
+
for (const relative of [...index.written, ...log.written]) {
|
|
148
|
+
const target = path.join(realBundle, relative);
|
|
149
|
+
reserved.push(yield* fs.realPath(target).pipe(Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(target))));
|
|
150
|
+
}
|
|
151
|
+
const files = [...realPaths === void 0 ? [] : Array.from(realPaths.entries()).filter(([id]) => writtenIds.has(id)).map(([, real]) => real), ...reserved];
|
|
117
152
|
if (files.length > 0) restage = {
|
|
118
153
|
repoRoot,
|
|
119
154
|
files
|
package/tsdoc-metadata.json
CHANGED