@okfit/engine 0.20.6 → 0.21.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 +1 -1
- package/config/resolve.js +2 -2
- package/edits/FrontmatterEdits.js +3 -3
- package/errors.js +3 -2
- package/index.d.ts +20 -5
- package/init/scaffold.js +1 -1
- package/move/references.js +1 -1
- package/move/run.js +6 -6
- package/overlay/documents.js +1 -1
- package/package.json +8 -8
- package/platform.js +1 -1
- package/query/ConceptQuery.js +1 -1
- package/render/context.js +8 -0
- package/render/graph.js +1 -1
- package/render/json.js +3 -3
- package/render/move.js +1 -1
- package/render/query.js +3 -3
- package/render/stale.js +1 -1
- package/render/sync.js +1 -1
- package/render/verify.js +3 -3
- package/session/BundleSession.js +4 -3
- package/session/range.js +1 -1
- package/sync/generated.js +4 -4
- package/sync/index.js +1 -1
- package/sync/log.js +1 -1
- package/sync/publication.js +4 -4
- package/sync/run.js +23 -8
- package/sync/staged.js +73 -0
- package/sync/write.js +1 -1
- package/targets/resolve.js +4 -4
- package/trust/run.js +1 -1
- package/validate/resources.js +12 -3
- package/validate/run.js +6 -3
- package/validate/surfaces.js +4 -4
- package/validate/untracked.js +117 -0
- package/verify/diff.js +1 -1
- package/verify/integrity.js +3 -3
- package/verify/locate.js +1 -1
- package/verify/revoke.js +2 -2
- package/verify/run.js +5 -5
- package/verify/select.js +1 -1
- package/version.js +1 -1
package/config/layer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ConfigMalformedError, ConfigPathNotFoundError } from "../errors.js";
|
|
2
1
|
import { AppConfig } from "@effected/app";
|
|
3
2
|
import { ConfigCodecError, ConfigResolver, ConfigValidationError, MergeStrategy } from "@effected/config-file";
|
|
4
3
|
import { TomlCodec } from "@effected/config-file/toml";
|
|
5
4
|
import { OkfitConfig, OkfitConfigFile } from "@okfit/core";
|
|
6
5
|
import { Cause, Effect, FileSystem, Option, Result } from "effect";
|
|
6
|
+
import { ConfigMalformedError, ConfigPathNotFoundError } from "../errors.js";
|
|
7
7
|
|
|
8
8
|
// src/config/layer.ts
|
|
9
9
|
/**
|
package/config/resolve.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { resolveBundleRoot, resolveProjectRoot } from "./anchor.js";
|
|
2
1
|
import { OKF_SPEC_VERSION, OkfitConfig, OkfitConfigFile } from "@okfit/core";
|
|
3
|
-
import { Console, Effect, Option, Path } from "effect";
|
|
4
2
|
import { Profiles } from "@okfit/profiles";
|
|
3
|
+
import { Console, Effect, Option, Path } from "effect";
|
|
4
|
+
import { resolveBundleRoot, resolveProjectRoot } from "./anchor.js";
|
|
5
5
|
|
|
6
6
|
// src/config/resolve.ts
|
|
7
7
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { MarkdownDocument, MarkdownEdit } from "@effected/markdown";
|
|
2
|
+
import { DiagnosticRange } from "@okfit/core";
|
|
3
|
+
import { Effect, Result, Runtime, Schema } from "effect";
|
|
1
4
|
import { formatDigest, locateIntegrity, spliceIntegrityVerified } from "../verify/integrity.js";
|
|
2
5
|
import { documentNewline, locate, locateTopLevelScalar, stripBom } from "../verify/locate.js";
|
|
3
6
|
import { orderVerifyEdits, splice, spliceTopLevelScalar } from "../verify/splice.js";
|
|
4
|
-
import { DiagnosticRange } from "@okfit/core";
|
|
5
|
-
import { Effect, Result, Runtime, Schema } from "effect";
|
|
6
|
-
import { MarkdownDocument, MarkdownEdit } from "@effected/markdown";
|
|
7
7
|
|
|
8
8
|
// src/edits/FrontmatterEdits.ts
|
|
9
9
|
/**
|
package/errors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Runtime, Schema } from "effect";
|
|
2
1
|
import { ErrorText } from "@effected/kit";
|
|
2
|
+
import { Runtime, Schema } from "effect";
|
|
3
3
|
|
|
4
4
|
// src/errors.ts
|
|
5
5
|
/**
|
|
@@ -264,9 +264,10 @@ var QueryConceptNotFoundError = class extends Schema.TaggedError()("QueryConcept
|
|
|
264
264
|
*
|
|
265
265
|
* @public
|
|
266
266
|
*/
|
|
267
|
-
var QuerySelectionError = class extends Schema.TaggedError()("QuerySelectionError", { reason: Schema.Literals(["verified-conflict"]) }) {
|
|
267
|
+
var QuerySelectionError = class extends Schema.TaggedError()("QuerySelectionError", { reason: Schema.Literals(["verified-conflict", "browse-needs-terminal"]) }) {
|
|
268
268
|
[Runtime.errorExitCode] = 64;
|
|
269
269
|
get message() {
|
|
270
|
+
if (this.reason === "browse-needs-terminal") return "run in a terminal to browse interactively; use okfit query list/get/neighbors";
|
|
270
271
|
return "query list takes --verified or --unverified, not both";
|
|
271
272
|
}
|
|
272
273
|
};
|
package/index.d.ts
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
|
-
import { AppDirs, AppDirs as AppDirs$1, Xdg, Xdg as Xdg$1, XdgEnvError } from "@effected/xdg";
|
|
8
7
|
import { Actor, BundleLoadError, ConceptId, Diagnostic, DiagnosticRange, DiagnosticSeverity, GraphLink, GraphNode, GraphNodeKind, LinkGraph, LoadedBundle, LoadedConcept, OkfitConfig, OkfitConfigFile, PathField, StaleConcept, Status, ValidationReport } from "@okfit/core";
|
|
9
8
|
import { Context, DateTime, Effect, FileSystem, Layer, Option, Path, PlatformError, Result, Runtime, Schema } from "effect";
|
|
9
|
+
import { AppDirs, AppDirs as AppDirs$1, Xdg, Xdg as Xdg$1, XdgEnvError } from "@effected/xdg";
|
|
10
10
|
import { ConfigReadError } from "@effected/config-file";
|
|
11
|
-
import { ConceptSignal, DriftReason, GeneratedAtError, GitHistory, GitHistoryError, IntegrityState, Layout, Profile, ProfileDiagnostic } from "@okfit/profiles";
|
|
11
|
+
import { ConceptOutsideRepositoryError, ConceptSignal, DriftReason, GeneratedAtError, GitHistory, GitHistoryError, IntegrityState, Layout, Profile, ProfileDiagnostic } from "@okfit/profiles";
|
|
12
12
|
import { FrontmatterWriteError, MarkdownEdit, MarkdownParseError } from "@effected/markdown";
|
|
13
13
|
import { YamlParseError } from "@effected/yaml";
|
|
14
14
|
import { Digest } from "effect/crypto";
|
|
@@ -284,7 +284,7 @@ export declare class QueryConceptNotFoundError extends QueryConceptNotFoundError
|
|
|
284
284
|
get message(): string;
|
|
285
285
|
}
|
|
286
286
|
declare const QuerySelectionError_base: Schema.Class<QuerySelectionError, Schema.TaggedStruct<"QuerySelectionError", {
|
|
287
|
-
readonly reason: Schema.Literals<readonly ["verified-conflict"]>;
|
|
287
|
+
readonly reason: Schema.Literals<readonly ["verified-conflict", "browse-needs-terminal"]>;
|
|
288
288
|
}>, import("effect/Cause").YieldableError>;
|
|
289
289
|
/**
|
|
290
290
|
* `okfit query list` was given contradictory selection flags. Exit 64: a
|
|
@@ -1080,11 +1080,18 @@ export type ContextTrust = typeof ContextTrust.Type;
|
|
|
1080
1080
|
* stamped by {@link contextEnvelope} itself -- callers cannot pass or fake
|
|
1081
1081
|
* it (okfit #137).
|
|
1082
1082
|
*
|
|
1083
|
+
* `cli_version` is the `@okfit/cli` version that printed the envelope
|
|
1084
|
+
* (`CLI_VERSION`), `null` when the envelope was built outside the CLI (the
|
|
1085
|
+
* MCP `describe_vocabulary` tool). The agent plugin's SessionStart hook
|
|
1086
|
+
* compares it to the minimum CLI it expects and treats a missing or `null`
|
|
1087
|
+
* value as an outdated CLI (okfit #221).
|
|
1088
|
+
*
|
|
1083
1089
|
* @public
|
|
1084
1090
|
*/
|
|
1085
1091
|
export declare const ContextEnvelope: Schema.Struct<{
|
|
1086
1092
|
readonly schema: Schema.Literal<1>;
|
|
1087
1093
|
readonly config_schema_version: Schema.String;
|
|
1094
|
+
readonly cli_version: Schema.NullOr<Schema.String>;
|
|
1088
1095
|
readonly project_root: Schema.String;
|
|
1089
1096
|
readonly bundle_root: Schema.String;
|
|
1090
1097
|
readonly config_path: Schema.NullOr<Schema.String>;
|
|
@@ -1143,6 +1150,8 @@ export declare const contextEnvelope: (input: {
|
|
|
1143
1150
|
readonly indexPath: string;
|
|
1144
1151
|
readonly indexExists: boolean;
|
|
1145
1152
|
readonly config: OkfitConfig;
|
|
1153
|
+
/** The running `@okfit/cli` version; absent (an MCP caller) becomes `null` on the wire. */
|
|
1154
|
+
readonly cliVersion?: string;
|
|
1146
1155
|
/** Present only under `--trust`; absent becomes `null` on the wire. */
|
|
1147
1156
|
readonly trust?: ContextTrust;
|
|
1148
1157
|
}) => ContextEnvelope;
|
|
@@ -2245,7 +2254,7 @@ interface RevalidateResult {
|
|
|
2245
2254
|
*
|
|
2246
2255
|
* @public
|
|
2247
2256
|
*/
|
|
2248
|
-
type RevalidateError = BundleLoadError | GitHistoryError | GitCommandError | UnknownRefError | PlatformError.PlatformError;
|
|
2257
|
+
type RevalidateError = BundleLoadError | GitHistoryError | GitCommandError | UnknownRefError | ConceptOutsideRepositoryError | PlatformError.PlatformError;
|
|
2249
2258
|
/** @public */
|
|
2250
2259
|
interface WatchedFilesOutcome {
|
|
2251
2260
|
/** A config discovery file changed: re-resolve config and replace this session. */
|
|
@@ -2466,6 +2475,12 @@ interface RunOptions {
|
|
|
2466
2475
|
* `severity === "off"`, but no longer on this flag.
|
|
2467
2476
|
*/
|
|
2468
2477
|
readonly skipProvenance?: boolean;
|
|
2478
|
+
/**
|
|
2479
|
+
* Issue #279: skip the git-backed `resource-ignored` / `resource-untracked`
|
|
2480
|
+
* lint. `skipProvenance` implies it; the LSP's `BundleSession` sets it on
|
|
2481
|
+
* every tier. Defaults to `false`.
|
|
2482
|
+
*/
|
|
2483
|
+
readonly skipUntracked?: boolean;
|
|
2469
2484
|
}
|
|
2470
2485
|
/** @public */
|
|
2471
2486
|
interface RunResult {
|
|
@@ -2506,7 +2521,7 @@ interface RunResult {
|
|
|
2506
2521
|
*
|
|
2507
2522
|
* @public
|
|
2508
2523
|
*/
|
|
2509
|
-
export declare const run: (options: RunOptions) => Effect.Effect<RunResult, BundleLoadError | GitHistoryError | GitCommandError | UnknownRefError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Git | GitHistory | Digest.Digest>;
|
|
2524
|
+
export declare const run: (options: RunOptions) => Effect.Effect<RunResult, BundleLoadError | GitHistoryError | GitCommandError | UnknownRefError | ConceptOutsideRepositoryError | PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Git | GitHistory | Digest.Digest>;
|
|
2510
2525
|
/**
|
|
2511
2526
|
* What changed in a concept file since a human last verified it.
|
|
2512
2527
|
*
|
package/init/scaffold.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { MarkdownDocument, MarkdownFrontmatter, MarkdownParseOptions, YamlFrontmatter } from "@effected/markdown";
|
|
1
2
|
import { Concept, ConceptId, Derive, LoadedConcept, OKF_SPEC_VERSION } from "@okfit/core";
|
|
2
3
|
import { Effect, Option, Schema } from "effect";
|
|
3
|
-
import { MarkdownDocument, MarkdownFrontmatter, MarkdownParseOptions, YamlFrontmatter } from "@effected/markdown";
|
|
4
4
|
|
|
5
5
|
// src/init/scaffold.ts
|
|
6
6
|
/** `.config/okfit.toml`, relative to the project root (C-10). @public */
|
package/move/references.js
CHANGED
package/move/run.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import { MarkdownEdit } from "@effected/markdown";
|
|
3
|
+
import { relativeWithin } from "@effected/walker";
|
|
4
|
+
import { Bundle, ConceptId } from "@okfit/core";
|
|
5
|
+
import { Trust } from "@okfit/profiles";
|
|
6
|
+
import { Effect, FileSystem, Option, Path } from "effect";
|
|
1
7
|
import { MoveError } from "../errors.js";
|
|
2
8
|
import { writeAtomic } from "../sync/write.js";
|
|
3
9
|
import { Targets } from "../targets/resolve.js";
|
|
4
10
|
import { referencesOf, rewriteReference } from "./references.js";
|
|
5
|
-
import { Bundle, ConceptId } from "@okfit/core";
|
|
6
|
-
import { Effect, FileSystem, Option, Path } from "effect";
|
|
7
|
-
import { Trust } from "@okfit/profiles";
|
|
8
|
-
import { MarkdownEdit } from "@effected/markdown";
|
|
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`;
|
package/overlay/documents.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Effect, FileSystem, Path, Result } from "effect";
|
|
1
2
|
import { DocumentPathError } from "../errors.js";
|
|
2
3
|
import { OverlayDocuments, makeOverlayFileSystem } from "./layer.js";
|
|
3
|
-
import { Effect, FileSystem, Path, Result } from "effect";
|
|
4
4
|
|
|
5
5
|
// src/overlay/documents.ts
|
|
6
6
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okfit/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.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,11 +35,11 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@effect/platform-node": "4.1.4",
|
|
38
|
-
"@effected/app": "0.
|
|
39
|
-
"@effected/config-file": "0.
|
|
38
|
+
"@effected/app": "0.34.0",
|
|
39
|
+
"@effected/config-file": "0.29.0",
|
|
40
40
|
"@effected/files": "0.3.0",
|
|
41
41
|
"@effected/git": "0.32.0",
|
|
42
|
-
"@effected/glob": "0.
|
|
42
|
+
"@effected/glob": "0.23.0",
|
|
43
43
|
"@effected/jsonc": "0.25.0",
|
|
44
44
|
"@effected/kit": "0.14.0",
|
|
45
45
|
"@effected/markdown": "0.29.0",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"@effected/source": "0.5.0",
|
|
48
48
|
"@effected/store": "0.25.0",
|
|
49
49
|
"@effected/toml": "0.20.0",
|
|
50
|
-
"@effected/walker": "0.
|
|
51
|
-
"@effected/xdg": "0.
|
|
50
|
+
"@effected/walker": "0.30.0",
|
|
51
|
+
"@effected/xdg": "0.22.0",
|
|
52
52
|
"@effected/yaml": "0.30.0",
|
|
53
|
-
"@okfit/core": "0.
|
|
54
|
-
"@okfit/profiles": "0.
|
|
53
|
+
"@okfit/core": "0.14.0",
|
|
54
|
+
"@okfit/profiles": "0.15.0",
|
|
55
55
|
"effect": "4.1.4"
|
|
56
56
|
},
|
|
57
57
|
"engines": {
|
package/platform.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Layer } from "effect";
|
|
2
1
|
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
|
|
3
2
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
4
3
|
import { AppDirs, Xdg } from "@effected/xdg";
|
|
4
|
+
import { Layer } from "effect";
|
|
5
5
|
|
|
6
6
|
// src/platform.ts
|
|
7
7
|
/**
|
package/query/ConceptQuery.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { QueryConceptNotFoundError, QueryUnknownVocabularyError } from "../errors.js";
|
|
2
1
|
import { ConceptId, Derive, Graph } from "@okfit/core";
|
|
3
2
|
import { Effect, Option } from "effect";
|
|
3
|
+
import { QueryConceptNotFoundError, QueryUnknownVocabularyError } from "../errors.js";
|
|
4
4
|
|
|
5
5
|
// src/query/ConceptQuery.ts
|
|
6
6
|
const byId = (a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0;
|
package/render/context.js
CHANGED
|
@@ -84,11 +84,18 @@ const ContextTrust = Schema.Struct({
|
|
|
84
84
|
* stamped by {@link contextEnvelope} itself -- callers cannot pass or fake
|
|
85
85
|
* it (okfit #137).
|
|
86
86
|
*
|
|
87
|
+
* `cli_version` is the `@okfit/cli` version that printed the envelope
|
|
88
|
+
* (`CLI_VERSION`), `null` when the envelope was built outside the CLI (the
|
|
89
|
+
* MCP `describe_vocabulary` tool). The agent plugin's SessionStart hook
|
|
90
|
+
* compares it to the minimum CLI it expects and treats a missing or `null`
|
|
91
|
+
* value as an outdated CLI (okfit #221).
|
|
92
|
+
*
|
|
87
93
|
* @public
|
|
88
94
|
*/
|
|
89
95
|
const ContextEnvelope = Schema.Struct({
|
|
90
96
|
schema: Schema.Literal(1),
|
|
91
97
|
config_schema_version: Schema.String,
|
|
98
|
+
cli_version: Schema.NullOr(Schema.String),
|
|
92
99
|
project_root: Schema.String,
|
|
93
100
|
bundle_root: Schema.String,
|
|
94
101
|
config_path: Schema.NullOr(Schema.String),
|
|
@@ -112,6 +119,7 @@ const ContextEnvelope = Schema.Struct({
|
|
|
112
119
|
const contextEnvelope = (input) => ({
|
|
113
120
|
schema: 1,
|
|
114
121
|
config_schema_version: CONFIG_SCHEMA_VERSION,
|
|
122
|
+
cli_version: input.cliVersion ?? null,
|
|
115
123
|
project_root: input.projectRoot,
|
|
116
124
|
bundle_root: input.bundleRoot,
|
|
117
125
|
config_path: input.configPath,
|
package/render/graph.js
CHANGED
package/render/json.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { ErrorText } from "@effected/kit";
|
|
2
|
+
import { DiagnosticRange, DiagnosticSeverity } from "@okfit/core";
|
|
3
|
+
import { Runtime, Schema } from "effect";
|
|
1
4
|
import { ENGINE_VERSION } from "../version.js";
|
|
2
5
|
import { DistributionField as DistributionField$1 } from "./distribution.js";
|
|
3
6
|
import { tally } from "./exit.js";
|
|
4
7
|
import { sort } from "./sort.js";
|
|
5
|
-
import { DiagnosticRange, DiagnosticSeverity } from "@okfit/core";
|
|
6
|
-
import { Runtime, Schema } from "effect";
|
|
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,8 +1,8 @@
|
|
|
1
|
-
import { ENGINE_VERSION } from "../version.js";
|
|
2
|
-
import { DistributionField } from "./distribution.js";
|
|
3
1
|
import { Derive, GraphNodeKind, Status } from "@okfit/core";
|
|
4
|
-
import { Schema } from "effect";
|
|
5
2
|
import { DriftReason } from "@okfit/profiles";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { ENGINE_VERSION } from "../version.js";
|
|
5
|
+
import { DistributionField } from "./distribution.js";
|
|
6
6
|
|
|
7
7
|
// src/render/query.ts
|
|
8
8
|
/**
|
package/render/stale.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DateTime, Schema } from "effect";
|
|
1
2
|
import { ENGINE_VERSION } from "../version.js";
|
|
2
3
|
import { DistributionField } from "./distribution.js";
|
|
3
|
-
import { DateTime, Schema } from "effect";
|
|
4
4
|
|
|
5
5
|
// src/render/stale.ts
|
|
6
6
|
/** One entry of the `items` array. @public */
|
package/render/sync.js
CHANGED
package/render/verify.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ENGINE_VERSION } from "../version.js";
|
|
2
|
-
import { DistributionField } from "./distribution.js";
|
|
3
1
|
import { Status } from "@okfit/core";
|
|
4
|
-
import { Schema } from "effect";
|
|
5
2
|
import { DriftReason } from "@okfit/profiles";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { ENGINE_VERSION } from "../version.js";
|
|
5
|
+
import { DistributionField } from "./distribution.js";
|
|
6
6
|
|
|
7
7
|
// src/render/verify.ts
|
|
8
8
|
/**
|
package/session/BundleSession.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { Graph } from "@okfit/core";
|
|
2
|
+
import { Context, Effect, FileSystem, Option, Path, Ref, Semaphore } from "effect";
|
|
1
3
|
import { PROJECT_CONFIG_NAMES } from "../init/scaffold.js";
|
|
2
4
|
import { OverlayDocuments, makeOverlayFileSystem } from "../overlay/layer.js";
|
|
3
5
|
import { collect, sort } from "../render/sort.js";
|
|
4
6
|
import { run } from "../validate/run.js";
|
|
5
7
|
import { diffDiagnostics, groupByFile } from "./diff.js";
|
|
6
8
|
import { withFallbackRange } from "./range.js";
|
|
7
|
-
import { Graph } from "@okfit/core";
|
|
8
|
-
import { Context, Effect, FileSystem, Option, Path, Ref, Semaphore } from "effect";
|
|
9
9
|
|
|
10
10
|
// src/session/BundleSession.ts
|
|
11
11
|
const CONFIG_BASENAMES = new Set(PROJECT_CONFIG_NAMES.map((name) => name.slice(name.lastIndexOf("/") + 1)));
|
|
@@ -35,7 +35,8 @@ var BundleSession = class BundleSession extends Context.Service()("@okfit/engine
|
|
|
35
35
|
config: options.config,
|
|
36
36
|
profile: options.profile,
|
|
37
37
|
now: revalidate.now,
|
|
38
|
-
skipProvenance: revalidate.tier === "edit"
|
|
38
|
+
skipProvenance: revalidate.tier === "edit",
|
|
39
|
+
skipUntracked: true
|
|
39
40
|
}).pipe(Effect.provideService(FileSystem.FileSystem, fileSystem), Effect.provideContext(context));
|
|
40
41
|
const rendered = sort(collect(result.report.conformance, result.report.lint, result.profileDiagnostics).map((diagnostic) => withFallbackRange(result.bundle, diagnostic)));
|
|
41
42
|
const next = groupByFile(rendered);
|
package/session/range.js
CHANGED
package/sync/generated.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import { MarkdownEdit } from "@effected/markdown";
|
|
2
|
+
import { Timestamp } from "@okfit/core";
|
|
3
|
+
import { Derivation, PUBLICATION_TYPE } from "@okfit/profiles";
|
|
4
|
+
import { Effect, FileSystem, Path, Schema } from "effect";
|
|
1
5
|
import { FrontmatterEdits } from "../edits/FrontmatterEdits.js";
|
|
2
6
|
import { locateIntegrity, locateLegacyBodySha256, removeLine, spliceIntegrityGenerated } from "../verify/integrity.js";
|
|
3
7
|
import { detectNewline, locateGenerated, locateGeneratedBlock, stripBom } from "../verify/locate.js";
|
|
4
8
|
import { mergeSameOffset, spliceGenerated, spliceGeneratedBlock } from "../verify/splice.js";
|
|
5
9
|
import { writeAtomic } from "./write.js";
|
|
6
|
-
import { Timestamp } from "@okfit/core";
|
|
7
|
-
import { Effect, FileSystem, Path, Schema } from "effect";
|
|
8
|
-
import { Derivation, PUBLICATION_TYPE } from "@okfit/profiles";
|
|
9
|
-
import { MarkdownEdit } from "@effected/markdown";
|
|
10
10
|
|
|
11
11
|
// src/sync/generated.ts
|
|
12
12
|
/**
|
package/sync/index.js
CHANGED
package/sync/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { writeAtomic } from "./write.js";
|
|
2
1
|
import { Derive } from "@okfit/core";
|
|
3
2
|
import { DateTime, Effect, FileSystem, Path } from "effect";
|
|
3
|
+
import { writeAtomic } from "./write.js";
|
|
4
4
|
|
|
5
5
|
// src/sync/log.ts
|
|
6
6
|
const byTitle = (a, b) => a.title < b.title ? -1 : a.title > b.title ? 1 : 0;
|
package/sync/publication.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { writeAtomic } from "./write.js";
|
|
1
|
+
import { MarkdownEdit } from "@effected/markdown";
|
|
3
2
|
import { Bundle, ConceptId } from "@okfit/core";
|
|
4
|
-
import { Effect, Option, Path, Runtime, Schema } from "effect";
|
|
5
3
|
import { Derivation, PUBLICATION_TYPE, Publications } from "@okfit/profiles";
|
|
6
|
-
import {
|
|
4
|
+
import { Effect, Option, Path, Runtime, Schema } from "effect";
|
|
5
|
+
import { FrontmatterEdits, UnsupportedFrontmatterError } from "../edits/FrontmatterEdits.js";
|
|
6
|
+
import { writeAtomic } from "./write.js";
|
|
7
7
|
|
|
8
8
|
// src/sync/publication.ts
|
|
9
9
|
/**
|
package/sync/run.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { Git } from "@effected/git";
|
|
2
|
+
import { relativeWithin } from "@effected/walker";
|
|
3
|
+
import { Bundle, Derive } from "@okfit/core";
|
|
4
|
+
import { ConceptOutsideRepositoryError, Derivation } from "@okfit/profiles";
|
|
5
|
+
import { DateTime, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
1
6
|
import { SyncPlanStaleError } from "../errors.js";
|
|
2
7
|
import { syncGenerated } from "./generated.js";
|
|
3
8
|
import { syncIndex } from "./index.js";
|
|
4
9
|
import { logWindow, syncLog, wantsLogEntry } from "./log.js";
|
|
10
|
+
import { committedView } from "./staged.js";
|
|
5
11
|
import { writeAtomic } from "./write.js";
|
|
6
|
-
import { Bundle, Derive } from "@okfit/core";
|
|
7
|
-
import { DateTime, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
8
|
-
import { Derivation } from "@okfit/profiles";
|
|
9
|
-
import { Git } from "@effected/git";
|
|
10
12
|
|
|
11
13
|
// src/sync/run.ts
|
|
12
14
|
/**
|
|
@@ -57,6 +59,7 @@ const planSync = Effect.fn("okfit/sync/planSync")(function* (options) {
|
|
|
57
59
|
let realPaths;
|
|
58
60
|
let stagedLog;
|
|
59
61
|
let logDirty = false;
|
|
62
|
+
let indexView = bundle;
|
|
60
63
|
if (options.staged !== void 0) {
|
|
61
64
|
const git = yield* Git;
|
|
62
65
|
const fs = yield* FileSystem.FileSystem;
|
|
@@ -68,9 +71,16 @@ const planSync = Effect.fn("okfit/sync/planSync")(function* (options) {
|
|
|
68
71
|
const resolvedPaths = /* @__PURE__ */ new Map();
|
|
69
72
|
const logProvenance = /* @__PURE__ */ new Map();
|
|
70
73
|
const root = repoRoot;
|
|
74
|
+
const conceptRels = /* @__PURE__ */ new Map();
|
|
71
75
|
for (const [id, concept] of bundle.concepts) {
|
|
72
76
|
const real = yield* fs.realPath(path.join(bundle.root, concept.path));
|
|
73
|
-
const
|
|
77
|
+
const relOption = yield* relativeWithin(root, real, { missing: "refuse" });
|
|
78
|
+
if (Option.isNone(relOption)) return yield* new ConceptOutsideRepositoryError({
|
|
79
|
+
file: real,
|
|
80
|
+
root
|
|
81
|
+
});
|
|
82
|
+
const rel = relOption.value;
|
|
83
|
+
conceptRels.set(id, rel);
|
|
74
84
|
if (!stagedPaths.has(rel)) continue;
|
|
75
85
|
selected.add(id);
|
|
76
86
|
provenanceStaged.set(id, {
|
|
@@ -90,10 +100,15 @@ const planSync = Effect.fn("okfit/sync/planSync")(function* (options) {
|
|
|
90
100
|
if (options.modes.has("log")) {
|
|
91
101
|
const logReal = yield* fs.realPath(path.join(bundle.root, "log.md")).pipe(Effect.catchReason("PlatformError", "NotFound", () => Effect.succeed(void 0)));
|
|
92
102
|
if (logReal !== void 0) {
|
|
93
|
-
const
|
|
94
|
-
|
|
103
|
+
const logRelOption = yield* relativeWithin(root, logReal, { missing: "refuse" });
|
|
104
|
+
if (Option.isNone(logRelOption)) return yield* new ConceptOutsideRepositoryError({
|
|
105
|
+
file: logReal,
|
|
106
|
+
root
|
|
107
|
+
});
|
|
108
|
+
logDirty = (yield* git.unstagedChanges(root)).includes(logRelOption.value);
|
|
95
109
|
}
|
|
96
110
|
}
|
|
111
|
+
if (options.modes.has("index")) indexView = yield* committedView(bundle, root, conceptRels, stagedPaths);
|
|
97
112
|
staged = provenanceStaged;
|
|
98
113
|
stagedLog = logProvenance;
|
|
99
114
|
scope = selected;
|
|
@@ -121,7 +136,7 @@ const planSync = Effect.fn("okfit/sync/planSync")(function* (options) {
|
|
|
121
136
|
})
|
|
122
137
|
} : UNSELECTED;
|
|
123
138
|
const index = options.modes.has("index") ? {
|
|
124
|
-
...yield* syncIndex(
|
|
139
|
+
...yield* syncIndex(indexView, true, pending),
|
|
125
140
|
migrated: []
|
|
126
141
|
} : UNSELECTED;
|
|
127
142
|
const log = !options.modes.has("log") ? UNSELECTED : logDirty ? {
|
package/sync/staged.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Git } from "@effected/git";
|
|
2
|
+
import { Bundle, LoadedBundle } from "@okfit/core";
|
|
3
|
+
import { Effect, FileSystem, Option, Path } from "effect";
|
|
4
|
+
|
|
5
|
+
// src/sync/staged.ts
|
|
6
|
+
/**
|
|
7
|
+
* Issue #142: the committed view of a bundle for `--staged` index mode. A
|
|
8
|
+
* pre-commit hook renders `index.md` into the commit, so the listing must come
|
|
9
|
+
* from the index, not the working tree: an untracked concept is absent, a
|
|
10
|
+
* concept removed with `git rm --cached` is absent, and a tracked concept with
|
|
11
|
+
* unstaged edits renders its indexed title and description. A concept deleted
|
|
12
|
+
* from the working tree but still in the index is loaded from its blob.
|
|
13
|
+
*
|
|
14
|
+
* `rels` maps each working-tree concept to its repo-relative physical path;
|
|
15
|
+
* `stagedPaths` are concepts whose working tree is what gets committed (the
|
|
16
|
+
* generated mode restages them whole), so they need no blob read.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
const committedView = Effect.fn("okfit/sync/committedView")(function* (bundle, repoRoot, rels, stagedPaths) {
|
|
21
|
+
const git = yield* Git;
|
|
22
|
+
const fs = yield* FileSystem.FileSystem;
|
|
23
|
+
const path = yield* Path.Path;
|
|
24
|
+
const realBundle = yield* fs.realPath(bundle.root);
|
|
25
|
+
const prefix = path.relative(repoRoot, realBundle).split(path.sep).join("/");
|
|
26
|
+
const entries = yield* git.lsFiles(repoRoot, { pathspec: [prefix === "" ? "." : prefix] });
|
|
27
|
+
const indexed = new Set(entries.filter((entry) => entry.stage === 0).map((entry) => entry.path));
|
|
28
|
+
const unstaged = new Set(yield* git.unstagedChanges(repoRoot));
|
|
29
|
+
const kept = /* @__PURE__ */ new Map();
|
|
30
|
+
const fromBlob = /* @__PURE__ */ new Set();
|
|
31
|
+
const known = /* @__PURE__ */ new Set();
|
|
32
|
+
for (const [id, concept] of bundle.concepts) {
|
|
33
|
+
const rel = rels.get(id);
|
|
34
|
+
if (rel === void 0) continue;
|
|
35
|
+
known.add(rel);
|
|
36
|
+
if (!indexed.has(rel)) continue;
|
|
37
|
+
kept.set(id, concept);
|
|
38
|
+
if (unstaged.has(rel) && !stagedPaths.has(rel)) fromBlob.add(concept.path);
|
|
39
|
+
}
|
|
40
|
+
const workingFiles = new Set(bundle.files);
|
|
41
|
+
const strip = prefix === "" ? "" : `${prefix}/`;
|
|
42
|
+
for (const rel of indexed) {
|
|
43
|
+
if (!rel.endsWith(".md") || known.has(rel) || !rel.startsWith(strip)) continue;
|
|
44
|
+
const local = rel.slice(strip.length);
|
|
45
|
+
if (!workingFiles.has(local)) fromBlob.add(local);
|
|
46
|
+
}
|
|
47
|
+
if (fromBlob.size > 0) {
|
|
48
|
+
const parsed = yield* Effect.scoped(Effect.gen(function* () {
|
|
49
|
+
const tmp = yield* fs.makeTempDirectoryScoped({ prefix: "okfit-index-" });
|
|
50
|
+
for (const local of fromBlob) {
|
|
51
|
+
const blob = yield* git.show(repoRoot, "", strip + local);
|
|
52
|
+
if (Option.isNone(blob)) continue;
|
|
53
|
+
const target = path.join(tmp, local);
|
|
54
|
+
yield* fs.makeDirectory(path.dirname(target), { recursive: true });
|
|
55
|
+
yield* fs.writeFileString(target, blob.value);
|
|
56
|
+
}
|
|
57
|
+
return yield* Bundle.load({ root: tmp });
|
|
58
|
+
}));
|
|
59
|
+
for (const [id, concept] of parsed.concepts) kept.set(id, concept);
|
|
60
|
+
}
|
|
61
|
+
const directories = /* @__PURE__ */ new Set();
|
|
62
|
+
for (const concept of kept.values()) {
|
|
63
|
+
const slash = concept.path.lastIndexOf("/");
|
|
64
|
+
directories.add(slash === -1 ? "" : concept.path.slice(0, slash));
|
|
65
|
+
}
|
|
66
|
+
return LoadedBundle.make({
|
|
67
|
+
...bundle,
|
|
68
|
+
concepts: kept,
|
|
69
|
+
directories: [...directories].sort()
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export { committedView };
|
package/sync/write.js
CHANGED
package/targets/resolve.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { TargetResolutionError } from "../errors.js";
|
|
2
|
-
import { relativeInside } from "./inside.js";
|
|
3
|
-
import { ConceptId } from "@okfit/core";
|
|
4
|
-
import { Effect, FileSystem, Option, Path } from "effect";
|
|
5
1
|
import { posix } from "node:path";
|
|
6
2
|
import { EditDistance } from "@effected/source";
|
|
3
|
+
import { ConceptId } from "@okfit/core";
|
|
4
|
+
import { Effect, FileSystem, Option, Path } from "effect";
|
|
5
|
+
import { TargetResolutionError } from "../errors.js";
|
|
6
|
+
import { relativeInside } from "./inside.js";
|
|
7
7
|
|
|
8
8
|
// src/targets/resolve.ts
|
|
9
9
|
const suggest = (arg, bundle) => {
|
package/trust/run.js
CHANGED
package/validate/resources.js
CHANGED
|
@@ -42,6 +42,16 @@ const resourceValuesOf = (concept) => {
|
|
|
42
42
|
return values;
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
+
* The absolute filesystem candidates a literal `resource` value may resolve to,
|
|
46
|
+
* in D-23 order: a leading `/` is bundle-root-relative; otherwise file-relative
|
|
47
|
+
* first, then (for a bare path with no `./` or `../` prefix) bundle-root-relative.
|
|
48
|
+
* The caller has already ruled out descriptors.
|
|
49
|
+
*/
|
|
50
|
+
const resourceCandidates = (bundle, concept, value, path) => {
|
|
51
|
+
const stripped = stripSuffix(value);
|
|
52
|
+
return stripped.startsWith("/") ? [path.join(bundle.root, stripped.slice(1))] : [path.resolve(bundle.root, path.dirname(concept.path), stripped), ...stripped.startsWith("./") || stripped.startsWith("../") ? [] : [path.resolve(bundle.root, stripped)]];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
45
55
|
* D-24's `resource`/`sources[].resource` value resolves to nothing in the
|
|
46
56
|
* bundle for every non-descriptor value on every concept (issue #106). A
|
|
47
57
|
* `resource` is a descriptor (a URL, a scope description, or a glob
|
|
@@ -65,8 +75,7 @@ const lintResources = (bundle, config) => Effect.gen(function* () {
|
|
|
65
75
|
const diagnostics = [];
|
|
66
76
|
for (const [, concept] of bundle.concepts) for (const { value, path: fieldPath } of resourceValuesOf(concept)) {
|
|
67
77
|
if (isDescriptor(value)) continue;
|
|
68
|
-
const
|
|
69
|
-
const candidates = stripped.startsWith("/") ? [path.join(bundle.root, stripped.slice(1))] : [path.resolve(bundle.root, path.dirname(concept.path), stripped), ...stripped.startsWith("./") || stripped.startsWith("../") ? [] : [path.resolve(bundle.root, stripped)]];
|
|
78
|
+
const candidates = resourceCandidates(bundle, concept, value, path);
|
|
70
79
|
let exists = false;
|
|
71
80
|
for (const candidate of candidates) if (yield* fs.exists(candidate)) {
|
|
72
81
|
exists = true;
|
|
@@ -85,4 +94,4 @@ const lintResources = (bundle, config) => Effect.gen(function* () {
|
|
|
85
94
|
return diagnostics;
|
|
86
95
|
});
|
|
87
96
|
|
|
88
|
-
export { GLOB_RE, lintResources };
|
|
97
|
+
export { GLOB_RE, isDescriptor, lintResources, resourceCandidates, resourceValuesOf, stripSuffix };
|
package/validate/run.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { lintResources } from "./resources.js";
|
|
2
|
-
import { lintSurfaces } from "./surfaces.js";
|
|
3
1
|
import { Bundle, OkfitConfig, Validate } from "@okfit/core";
|
|
4
|
-
import { Context, Effect, Option } from "effect";
|
|
5
2
|
import { Provenance, Publications, Trust } from "@okfit/profiles";
|
|
3
|
+
import { Context, Effect, Option } from "effect";
|
|
4
|
+
import { lintResources } from "./resources.js";
|
|
5
|
+
import { lintSurfaces } from "./surfaces.js";
|
|
6
|
+
import { lintUntrackedResources } from "./untracked.js";
|
|
6
7
|
|
|
7
8
|
// src/validate/run.ts
|
|
8
9
|
/**
|
|
@@ -62,6 +63,7 @@ const run = (options) => Effect.gen(function* () {
|
|
|
62
63
|
const signals = yield* Trust.signals(bundle, options.config, options.now);
|
|
63
64
|
const drift = yield* Trust.lint(bundle, options.config, options.now, signals);
|
|
64
65
|
const resources = yield* lintResources(bundle, options.config);
|
|
66
|
+
const untracked = options.skipProvenance === true || options.skipUntracked === true ? [] : yield* lintUntrackedResources(bundle, options.config);
|
|
65
67
|
const publications = Option.exists(options.profile, (profile) => profile.name === "software-project") ? yield* Publications.lint(bundle, options.config) : [];
|
|
66
68
|
const surfaces = yield* lintSurfaces(bundle, options.config);
|
|
67
69
|
return {
|
|
@@ -73,6 +75,7 @@ const run = (options) => Effect.gen(function* () {
|
|
|
73
75
|
...provenance,
|
|
74
76
|
...drift,
|
|
75
77
|
...resources,
|
|
78
|
+
...untracked,
|
|
76
79
|
...publications,
|
|
77
80
|
...surfaces
|
|
78
81
|
]
|
package/validate/surfaces.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GlobPattern } from "@effected/glob";
|
|
2
|
+
import { descend } from "@effected/walker";
|
|
2
3
|
import { Diagnostic, DiagnosticRange, OkfitConfig } from "@okfit/core";
|
|
3
|
-
import { Effect, FileSystem, Path, Result } from "effect";
|
|
4
4
|
import { SURFACE_TYPE } from "@okfit/profiles";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { Effect, FileSystem, Path, Result } from "effect";
|
|
6
|
+
import { GLOB_RE } from "./resources.js";
|
|
7
7
|
|
|
8
8
|
// src/validate/surfaces.ts
|
|
9
9
|
/**
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Git } from "@effected/git";
|
|
2
|
+
import { Diagnostic, DiagnosticRange, OkfitConfig } from "@okfit/core";
|
|
3
|
+
import { Effect, FileSystem, Path } from "effect";
|
|
4
|
+
import { isDescriptor, resourceCandidates, resourceValuesOf } from "./resources.js";
|
|
5
|
+
|
|
6
|
+
// src/validate/untracked.ts
|
|
7
|
+
/**
|
|
8
|
+
* Classifies repo-relative paths (all existing on disk) against ONE repository:
|
|
9
|
+
* a path inside a registered submodule is delegated to that submodule's own
|
|
10
|
+
* index (recursing for nested submodules); the submodule path itself is
|
|
11
|
+
* tracked (it is a gitlink); everything else costs one `Git.lsFiles` and at
|
|
12
|
+
* most one `Git.checkIgnore` for the whole batch. A directory is tracked when
|
|
13
|
+
* the index lists at least one file under it. A submodule that cannot be
|
|
14
|
+
* queried counts as tracked, since the superproject tracks the submodule path
|
|
15
|
+
* itself.
|
|
16
|
+
*/
|
|
17
|
+
const classify = (git, repoRoot, rels, join) => Effect.gen(function* () {
|
|
18
|
+
const result = /* @__PURE__ */ new Map();
|
|
19
|
+
const submodules = yield* git.submoduleStatus(repoRoot).pipe(Effect.orElseSucceed(() => []));
|
|
20
|
+
const own = [];
|
|
21
|
+
const nested = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const rel of rels) {
|
|
23
|
+
const sub = submodules.find((entry) => rel === entry.path || rel.startsWith(`${entry.path}/`));
|
|
24
|
+
if (sub === void 0) own.push(rel);
|
|
25
|
+
else if (rel === sub.path) result.set(rel, "tracked");
|
|
26
|
+
else {
|
|
27
|
+
const bucket = nested.get(sub.path) ?? [];
|
|
28
|
+
bucket.push(rel);
|
|
29
|
+
nested.set(sub.path, bucket);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
for (const [subPath, bucket] of nested) {
|
|
33
|
+
const inner = yield* classify(git, join(repoRoot, subPath), bucket.map((rel) => rel.slice(subPath.length + 1)), join);
|
|
34
|
+
for (const rel of bucket) result.set(rel, inner.get(rel.slice(subPath.length + 1)) ?? "tracked");
|
|
35
|
+
}
|
|
36
|
+
if (own.length === 0) return result;
|
|
37
|
+
const entries = yield* git.lsFiles(repoRoot, { pathspec: own }).pipe(Effect.option);
|
|
38
|
+
if (entries._tag === "None") {
|
|
39
|
+
for (const rel of own) result.set(rel, "tracked");
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
const indexed = entries.value.map((entry) => entry.path);
|
|
43
|
+
const notTracked = own.filter((rel) => !indexed.some((p) => p === rel || p.startsWith(`${rel}/`)));
|
|
44
|
+
for (const rel of own) if (!notTracked.includes(rel)) result.set(rel, "tracked");
|
|
45
|
+
if (notTracked.length === 0) return result;
|
|
46
|
+
const ignored = yield* git.checkIgnore(repoRoot, notTracked).pipe(Effect.option);
|
|
47
|
+
const ignoredSet = new Set(ignored._tag === "Some" ? ignored.value : []);
|
|
48
|
+
for (const rel of notTracked) result.set(rel, ignoredSet.has(rel) ? "ignored" : "untracked");
|
|
49
|
+
return result;
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Issue #279: a `resource` or `sources[].resource` literal path that exists on
|
|
53
|
+
* disk but would not exist in a clean checkout. `resource-ignored` flags a
|
|
54
|
+
* gitignored file; `resource-untracked` flags a file git does not track yet
|
|
55
|
+
* (never raised once the file is staged, since the index lists it). Scope is
|
|
56
|
+
* the literal `resource` / `sources[].resource` values `lintResources` walks:
|
|
57
|
+
* descriptors and globs are skipped, and a missing file stays
|
|
58
|
+
* `source-resource-missing`'s. A bundle outside a git repository is skipped,
|
|
59
|
+
* as is everything when both codes are `off` (no filesystem or git access).
|
|
60
|
+
* The git queries are batched: one `lsFiles` and at most one `checkIgnore` per
|
|
61
|
+
* repository, with submodules resolved against their own index.
|
|
62
|
+
*
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
const lintUntrackedResources = (bundle, config) => Effect.gen(function* () {
|
|
66
|
+
const ignoredSeverity = OkfitConfig.severityFor(config, "resource-ignored");
|
|
67
|
+
const untrackedSeverity = OkfitConfig.severityFor(config, "resource-untracked");
|
|
68
|
+
if (ignoredSeverity === "off" && untrackedSeverity === "off") return [];
|
|
69
|
+
const fs = yield* FileSystem.FileSystem;
|
|
70
|
+
const path = yield* Path.Path;
|
|
71
|
+
const git = yield* Git;
|
|
72
|
+
const targets = [];
|
|
73
|
+
for (const [, concept] of bundle.concepts) for (const { value, path: fieldPath } of resourceValuesOf(concept)) {
|
|
74
|
+
if (isDescriptor(value)) continue;
|
|
75
|
+
for (const candidate of resourceCandidates(bundle, concept, value, path)) {
|
|
76
|
+
if (!(yield* fs.exists(candidate))) continue;
|
|
77
|
+
const real = yield* fs.realPath(candidate);
|
|
78
|
+
targets.push({
|
|
79
|
+
concept,
|
|
80
|
+
value,
|
|
81
|
+
fieldPath,
|
|
82
|
+
real
|
|
83
|
+
});
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (targets.length === 0) return [];
|
|
88
|
+
const top = yield* git.repoRoot(yield* fs.realPath(bundle.root)).pipe(Effect.catchTag("NotARepositoryError", () => Effect.succeed(void 0)));
|
|
89
|
+
if (top === void 0) return [];
|
|
90
|
+
const topReal = yield* fs.realPath(top);
|
|
91
|
+
const relOf = (real) => {
|
|
92
|
+
const rel = path.relative(topReal, real);
|
|
93
|
+
return rel === "" || rel.startsWith("..") || path.isAbsolute(rel) ? void 0 : rel.split(path.sep).join("/");
|
|
94
|
+
};
|
|
95
|
+
const rels = [...new Set(targets.flatMap((t) => relOf(t.real) ?? []))];
|
|
96
|
+
if (rels.length === 0) return [];
|
|
97
|
+
const states = yield* classify(git, topReal, rels, (...parts) => path.join(...parts));
|
|
98
|
+
const diagnostics = [];
|
|
99
|
+
for (const target of targets) {
|
|
100
|
+
const rel = relOf(target.real);
|
|
101
|
+
const state = rel === void 0 ? "tracked" : states.get(rel) ?? "tracked";
|
|
102
|
+
if (state === "tracked") continue;
|
|
103
|
+
const severity = state === "ignored" ? ignoredSeverity : untrackedSeverity;
|
|
104
|
+
if (severity === "off") continue;
|
|
105
|
+
const range = DiagnosticRange.forFrontmatterPath(target.concept.document, target.fieldPath);
|
|
106
|
+
diagnostics.push(Diagnostic.make({
|
|
107
|
+
file: target.concept.path,
|
|
108
|
+
code: state === "ignored" ? "resource-ignored" : "resource-untracked",
|
|
109
|
+
severity,
|
|
110
|
+
message: state === "ignored" ? `Resource "${target.value}" exists locally but is gitignored, so other checkouts will not have it; restate the reasoning in the concept instead of citing it` : `Resource "${target.value}" exists locally but is not tracked by git yet; add it to the index or stop citing it`,
|
|
111
|
+
...range === void 0 ? {} : { range }
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
return diagnostics;
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
export { lintUntrackedResources };
|
package/verify/diff.js
CHANGED
package/verify/integrity.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { hasMergeKey, parseTopLevelMapping } from "./locate.js";
|
|
2
|
-
import { Integrity } from "@okfit/core";
|
|
3
|
-
import { Effect, Option, Schema } from "effect";
|
|
4
1
|
import { MarkdownEdit } from "@effected/markdown";
|
|
5
2
|
import { YamlAlias, YamlMap, YamlScalar, YamlSeq } from "@effected/yaml";
|
|
3
|
+
import { Integrity } from "@okfit/core";
|
|
4
|
+
import { Effect, Option, Schema } from "effect";
|
|
5
|
+
import { hasMergeKey, parseTopLevelMapping } from "./locate.js";
|
|
6
6
|
|
|
7
7
|
// src/verify/integrity.ts
|
|
8
8
|
const decodeIntegrity = Schema.decodeUnknownOption(Integrity);
|
package/verify/locate.js
CHANGED
package/verify/revoke.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { hasMergeKey, parseTopLevelMapping } from "./locate.js";
|
|
2
|
-
import { Effect } from "effect";
|
|
3
1
|
import { YamlAlias, YamlMap, YamlScalar, YamlSeq } from "@effected/yaml";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { hasMergeKey, parseTopLevelMapping } from "./locate.js";
|
|
4
4
|
|
|
5
5
|
// src/verify/revoke.ts
|
|
6
6
|
const byActor = (actor) => (map) => map.items.some((entry) => entry.key instanceof YamlScalar && entry.key.value === "by" && entry.value instanceof YamlScalar && entry.value.value === actor);
|
package/verify/run.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { AtomicFile } from "@effected/files";
|
|
2
|
+
import { MarkdownEdit } from "@effected/markdown";
|
|
3
|
+
import { Bundle, ConceptId, Derive, Timestamp } from "@okfit/core";
|
|
4
|
+
import { Derivation, Trust } from "@okfit/profiles";
|
|
5
|
+
import { DateTime, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
1
6
|
import { VerifyConceptNotFoundError, VerifyContentUnhashableError, VerifyNothingToRevokeError, VerifyUnsupportedFrontmatterError } from "../errors.js";
|
|
2
7
|
import { changeSince } from "./diff.js";
|
|
3
8
|
import { locateIntegrity, removeIntegrityVerified, spliceIntegrityVerified } from "./integrity.js";
|
|
@@ -5,11 +10,6 @@ import { documentNewline, locate, locateTopLevelScalar, locateVerifiedAt, stripB
|
|
|
5
10
|
import { locateVerifiedEntries } from "./revoke.js";
|
|
6
11
|
import { resolveBatchTypes, selectAttestable, selectPickerCandidates, selectStaleCandidates } from "./select.js";
|
|
7
12
|
import { orderVerifyEdits, quoteLike, splice, spliceTopLevelScalar } from "./splice.js";
|
|
8
|
-
import { Bundle, ConceptId, Derive, Timestamp } from "@okfit/core";
|
|
9
|
-
import { DateTime, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
10
|
-
import { Derivation, Trust } from "@okfit/profiles";
|
|
11
|
-
import { MarkdownEdit } from "@effected/markdown";
|
|
12
|
-
import { AtomicFile } from "@effected/files";
|
|
13
13
|
|
|
14
14
|
// src/verify/run.ts
|
|
15
15
|
/**
|
package/verify/select.js
CHANGED