@okfit/core 0.12.1 → 0.13.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/Actor.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Wildcard, WildcardOptions } from "@effected/glob";
1
2
  import { Schema } from "effect";
2
3
 
3
4
  // src/Actor.ts
@@ -11,11 +12,10 @@ const form = (actor) => {
11
12
  return prefix === "human" ? "human" : prefix === "process" ? "process" : "other";
12
13
  };
13
14
  const GLOB_RE = /[*?]/u;
14
- const ESCAPE_RE = /[.+^${}()|[\]\\/]/gu;
15
15
  /** `*` is any run of non-whitespace, `?` one non-whitespace character; everything else is literal. */
16
- const patternRegExp = (pattern) => new RegExp(`^${[...pattern].map((char) => char === "*" ? "\\S*" : char === "?" ? "\\S" : char.replace(ESCAPE_RE, "\\$&")).join("")}$`, "iu");
16
+ const NOCASE = WildcardOptions.make({ nocase: true });
17
17
  const isPattern = (value) => GLOB_RE.test(value);
18
- const matches = (actor, pattern) => patternRegExp(pattern).test(actor);
18
+ const matches = (actor, pattern) => Wildcard.matches(pattern, actor, NOCASE);
19
19
  const allowed = (actor, humans) => humans.length === 0 || humans.some((pattern) => matches(actor, pattern));
20
20
  /**
21
21
  * Branded, pattern-checked actor codec with prefix classification statics.
package/Bundle.js CHANGED
@@ -5,13 +5,12 @@ import { IndexDocument } from "./IndexDocument.js";
5
5
  import { detectFence } from "./internal/fence.js";
6
6
  import { decodeConcept } from "./internal/frontmatter.js";
7
7
  import { toFileOffset } from "./internal/position.js";
8
- import { basename, dirname } from "./internal/posixPath.js";
9
8
  import { OPTIONS, parseIndex, parseLog } from "./internal/reserved.js";
10
9
  import { DEFAULT_PRUNE, walk } from "./internal/walk.js";
11
10
  import { LogDocument } from "./LogDocument.js";
12
11
  import { Effect, FileSystem, Option, Path, Result, Schema } from "effect";
13
12
  import { FrontmatterDecodeError, MarkdownDocument, YamlFrontmatter } from "@effected/markdown";
14
- import { DescendError } from "@effected/walker";
13
+ import { DescendError, PosixPath } from "@effected/walker";
15
14
  import { YamlParseError } from "@effected/yaml";
16
15
 
17
16
  // src/Bundle.ts
@@ -101,7 +100,7 @@ const diagnostic = (file, code, severity, message, range) => Diagnostic.make(ran
101
100
  const blockRange = (text, node) => DiagnosticRange.fromOffset(text, node.position.start.offset, node.position.end.offset - node.position.start.offset);
102
101
  /** Group A's `dirname` returns `"."` for a bundle-root file; `LoadedBundle` keys the root `""`. */
103
102
  const directoryKey = (relativePath) => {
104
- const dir = dirname(relativePath);
103
+ const dir = PosixPath.dirname(relativePath);
105
104
  return dir === "." ? "" : dir;
106
105
  };
107
106
  /** Decode a captured YAML block; a failure is one `frontmatter-unparseable` with a file-mapped range (D-14). */
@@ -130,7 +129,7 @@ const loadMarkdown = (file, text) => Effect.gen(function* () {
130
129
  }
131
130
  const document = parsed.success;
132
131
  const dir = directoryKey(file);
133
- if (reserved && basename(file) === "log.md") {
132
+ if (reserved && PosixPath.basename(file) === "log.md") {
134
133
  const result = parseLog({
135
134
  file,
136
135
  dir,
package/ConceptId.js CHANGED
@@ -1,9 +1,9 @@
1
- import { basename } from "./internal/posixPath.js";
2
1
  import { Option, Schema } from "effect";
2
+ import { PosixPath } from "@effected/walker";
3
3
 
4
4
  // src/ConceptId.ts
5
5
  const RESERVED_BASENAMES = /* @__PURE__ */ new Set(["index.md", "log.md"]);
6
- const isReservedFile = (path) => RESERVED_BASENAMES.has(basename(path));
6
+ const isReservedFile = (path) => RESERVED_BASENAMES.has(PosixPath.basename(path));
7
7
  const fromPath = (path) => {
8
8
  if (isReservedFile(path) || !path.endsWith(".md")) return Option.none();
9
9
  return Option.some(path.slice(0, -3));
package/Derive.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Actor } from "./Actor.js";
2
2
  import { indexDocument, logEntry } from "./internal/templates.js";
3
3
  import { DateTime, Schema } from "effect";
4
+ import { PosixPath } from "@effected/walker";
4
5
 
5
6
  // src/Derive.ts
6
7
  /** Trust tier from `verified` (OKF 0.2 §5.3): none maps to unverified; only non-human maps to machine-confirmed; any `human:` maps to human-reviewed. @public */
@@ -17,8 +18,11 @@ const Staleness = Schema.Literals([
17
18
  ]);
18
19
  const compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
19
20
  const oneLine = (text) => text.replace(/\s+/g, " ").trim();
20
- const basename = (path) => path.slice(path.lastIndexOf("/") + 1);
21
- const dirnameOf = (path) => path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "";
21
+ /** The bundle-relative directory of `path`; `""` for a file at the bundle root. */
22
+ const dirnameOf = (path) => {
23
+ const dir = PosixPath.dirname(path);
24
+ return dir === "." ? "" : dir;
25
+ };
22
26
  const relativeTarget = (dir, path) => dir !== "" && path.startsWith(`${dir}/`) ? path.slice(dir.length + 1) : path;
23
27
  /** Pure derivations (D-10, D-36): trust tier, status, staleness against a supplied instant, index/log rendering. @public */
24
28
  var Derive = class Derive {
@@ -59,7 +63,7 @@ var Derive = class Derive {
59
63
  return out.sort((a, b) => compare(a.id, b.id));
60
64
  };
61
65
  /** Frontmatter `title`, else the file name without `.md` (OKF 0.2 §4.1). */
62
- static title = (concept) => concept.frontmatter.title ?? basename(concept.path).replace(/\.md$/, "");
66
+ static title = (concept) => concept.frontmatter.title ?? PosixPath.basename(concept.path).replace(/\.md$/, "");
63
67
  /** One H1 per `type` (sorted), entries sorted by title, then `# Subdirectories` (D-36; spec §8). */
64
68
  static renderIndex = (dir, concepts, options = {}) => {
65
69
  const groups = /* @__PURE__ */ new Map();
package/README.md CHANGED
@@ -23,7 +23,7 @@ const program = Effect.gen(function* () {
23
23
  });
24
24
  ```
25
25
 
26
- `Bundle.load` needs `FileSystem` and `Path`; `OkfitConfig.read` needs `FileSystem`. Loading never fails on content: bad files become `Diagnostic`s. `Graph.fromBundle` treats a path-valued field or link whose target, resolved from its concept's directory, lands outside the bundle root as an external reference: no graph node and no `broken-links` diagnostic, exactly like a URL. `OkfitConfig` decodes the spec 4.2 TOML shape; unknown top-level keys are kept in `extensions` and reported by `Validate.lint` as `config-unknown-key`. `lifecycle.default_stale_after` accepts `90d`, `12h`, `2w`, or `"90 days"`. `OkfitConfig.merge` deep-merges tables; arrays and scalars in `override` replace wholesale. Apply `DEFAULTS < profile < file` yourself. `OkfitConfigFile` is the service tag; the CLI provides its layer. `okfitConfigDocumentFields` is `okfitConfigFields` minus `extensions` (wire bookkeeping no human writes), with an open rest so unknown top-level keys stay permitted while every declared table stays closed; it is the single source `@okfit/engine`'s `lib/configs/schemastore.config.ts` builds the published JSON Schema (`schemas/1.0/config.json`) from via `@effected/schemastore-cli`, and carries no annotations of its own beyond what each field already declares in `OkfitConfig.ts`. The document's `HostedSchema` identity (`okfitConfigSchemaHost`, the same `$id` `okfit init` stamps into a fresh config's `#:schema` directive) lives in `@okfit/engine`, not here — core stays free of a runtime `@effected/schemastore` dependency. The `[lint]` table's seventeen keys include `generated_at_drift` (default `"warn"`), which fires when a committed concept's `generated.at` no longer matches the instant its body was last changed AND is not otherwise authoritative (issue #19: a stamp recorded during the unchanged-body run survives a squash/rebase merge) — computed by `okfit sync`/`okfit validate`, never by core itself.
26
+ `Bundle.load` needs `FileSystem` and `Path`; `OkfitConfig.read` needs `FileSystem`. Loading never fails on content: bad files become `Diagnostic`s. `Graph.fromBundle` treats a path-valued field or link whose target, resolved from its concept's directory, lands outside the bundle root as an external reference: no graph node and no `broken-links` diagnostic, exactly like a URL. `OkfitConfig` decodes the spec 4.2 TOML shape; unknown top-level keys are kept in `extensions` and reported by `Validate.lint` as `config-unknown-key`. `lifecycle.default_stale_after` accepts `90d`, `12h`, `2w`, or `"90 days"`. `OkfitConfig.merge` deep-merges tables; arrays and scalars in `override` replace wholesale. Apply `DEFAULTS < profile < file` yourself. `OkfitConfigFile` is the service tag; the CLI provides its layer. `okfitConfigDocumentFields` is `okfitConfigFields` minus `extensions` (wire bookkeeping no human writes), with an open rest so unknown top-level keys stay permitted while every declared table stays closed; it is the single source `@okfit/engine`'s `lib/configs/schemastore.config.ts` builds the published JSON Schema (`schemas/1.0/config.json`) from via `effected schema`, and carries no annotations of its own beyond what each field already declares in `OkfitConfig.ts`. The document's `HostedSchema` identity (`okfitConfigSchemaHost`, the same `$id` `okfit init` stamps into a fresh config's `#:schema` directive) lives in `@okfit/engine`, not here — core stays free of a runtime `@effected/schemastore` dependency. The `[lint]` table's seventeen keys include `generated_at_drift` (default `"warn"`), which fires when a committed concept's `generated.at` no longer matches the instant its body was last changed AND is not otherwise authoritative (issue #19: a stamp recorded during the unchanged-body run survives a squash/rebase merge) — computed by `okfit sync`/`okfit validate`, never by core itself.
27
27
 
28
28
  ## License
29
29
 
package/internal/fence.js CHANGED
@@ -1,17 +1,16 @@
1
+ import { FrontmatterSource } from "@effected/markdown";
2
+
1
3
  // src/internal/fence.ts
2
- const LINE_BREAK = /\r\n|\r|\n/;
3
4
  /**
4
- * Core's own fence check, run before the markdown parser because the parser treats an
5
- * unclosed fence as no frontmatter (effected-markdown.md section 2). Line 0 must be
6
- * exactly `---`; the block closes at the first later line that is exactly `---`.
5
+ * Core's fence check, run before the markdown parser because the parser treats an unclosed fence as
6
+ * no frontmatter (effected-markdown.md section 2). The fence state is `FrontmatterSource.split`'s;
7
+ * core recognizes only the `---` YAML fence (D-13), so a `+++` or `---json` fence reads as absent.
7
8
  *
8
9
  * @public
9
10
  */
10
11
  const detectFence = (text) => {
11
- const lines = text.split(LINE_BREAK);
12
- if (lines[0] !== "---") return "absent";
13
- for (let index = 1; index < lines.length; index += 1) if (lines[index] === "---") return "closed";
14
- return "unclosed";
12
+ const split = FrontmatterSource.split(text);
13
+ return split.fenceFormat === void 0 || split.fenceFormat === "yaml" ? split.fence ?? "absent" : "absent";
15
14
  };
16
15
 
17
16
  export { detectFence };
package/internal/links.js CHANGED
@@ -1,6 +1,6 @@
1
- import { basename, dirname, join, normalize } from "./posixPath.js";
2
1
  import { findFrontmatterPathSpan } from "./yamlPathSpan.js";
3
2
  import { Option } from "effect";
3
+ import { PosixPath } from "@effected/walker";
4
4
 
5
5
  // src/internal/links.ts
6
6
  const SCHEME_RE = /^[a-z][a-z0-9+.-]+:/i;
@@ -20,7 +20,7 @@ const percentDecode = (raw) => {
20
20
  }
21
21
  };
22
22
  const isReserved = (path) => {
23
- const name = basename(path);
23
+ const name = PosixPath.basename(path);
24
24
  return name === "index.md" || name === "log.md";
25
25
  };
26
26
  const escapes = (path) => path === ".." || path.startsWith("../");
@@ -48,7 +48,7 @@ const lookup = (candidate, index, via) => {
48
48
  if (path === "." || path === "") return void 0;
49
49
  const direct = existing(path, index, via);
50
50
  if (direct !== void 0) return direct;
51
- return basename(path).includes(".") ? void 0 : existing(`${path}.md`, index, via);
51
+ return PosixPath.basename(path).includes(".") ? void 0 : existing(`${path}.md`, index, via);
52
52
  };
53
53
  const missing = (candidate, via) => ({
54
54
  _tag: "node",
@@ -64,17 +64,17 @@ const resolveTarget = (from, raw, index) => {
64
64
  if (target === "") return { _tag: "self" };
65
65
  if (target.startsWith("/")) {
66
66
  const rooted = target.slice(1);
67
- const candidate = rooted === "" ? "index.md" : normalize(rooted);
67
+ const candidate = rooted === "" ? "index.md" : PosixPath.normalize(rooted);
68
68
  if (escapes(candidate)) return { _tag: "external" };
69
69
  return lookup(candidate, index, "rooted") ?? missing(candidate, "rooted");
70
70
  }
71
71
  const relative = target.startsWith("./") || target.startsWith("../");
72
- const fileRelative = join(dirname(from), target);
72
+ const fileRelative = PosixPath.join(PosixPath.dirname(from), target);
73
73
  if (escapes(fileRelative)) return { _tag: "external" };
74
74
  const hitB = lookup(fileRelative, index, "file");
75
75
  if (hitB !== void 0) return hitB;
76
76
  if (!relative) {
77
- const rootRelative = normalize(target);
77
+ const rootRelative = PosixPath.normalize(target);
78
78
  if (escapes(rootRelative)) return { _tag: "external" };
79
79
  const hitC = lookup(rootRelative, index, "root");
80
80
  if (hitC !== void 0) return hitC;
@@ -2,19 +2,11 @@ import { Actor } from "../Actor.js";
2
2
  import { Derive } from "../Derive.js";
3
3
  import { Diagnostic, DiagnosticRange } from "../Diagnostic.js";
4
4
  import { frontmatterPathRange } from "./frontmatter.js";
5
- import { DateTime, Option } from "effect";
5
+ import { DateTime } from "effect";
6
+ import { EditDistance } from "@effected/source";
6
7
 
7
8
  // src/internal/lintRules.ts
8
- const FOOTNOTE_RE = /\[\^([^\]\s]+)\]/g;
9
- /** A footnote definition: the label at a line start, followed by a colon. */
10
- const FOOTNOTE_DEFINITION_RE = /^\[\^([^\]\s]+)\]:/gm;
11
9
  const present = (raw, key) => Object.hasOwn(raw, key) && raw[key] !== null;
12
- /**
13
- * Source spans of every inline code span and code block, so a footnote-shaped
14
- * token inside backticks is read as literal text (issue #67).
15
- */
16
- const codeSpansOf = (concept) => concept.document.findAll((node) => node.type === "inlineCode" || node.type === "code").map((node) => [node.position.start.offset, node.position.end.offset]);
17
- const insideAny = (spans, offset) => spans.some(([start, end]) => offset >= start && offset < end);
18
10
  const diagnostic = (file, code, severity, message, range) => Diagnostic.make({
19
11
  file,
20
12
  code,
@@ -126,20 +118,36 @@ const stale = perConcept("stale", (concept, context) => context.now !== void 0 &
126
118
  message: `Concept is stale since ${DateTime.formatIso(concept.frontmatter.stale_after)}`,
127
119
  path: ["stale_after"]
128
120
  }] : []);
121
+ /**
122
+ * Every footnote label a concept uses, once each in source order, with the offset of its first
123
+ * `[^label]` marker: resolved references, definitions and the markers the parser rejected for want
124
+ * of a definition. A marker in a code span or block, or an escaped one, is literal text and absent.
125
+ */
126
+ const footnoteLabelsOf = (concept) => {
127
+ const markers = [...concept.document.findAll((node) => node.type === "footnoteReference" || node.type === "footnoteDefinition").flatMap((node) => node.type === "footnoteReference" || node.type === "footnoteDefinition" ? [{
128
+ label: node.label ?? node.identifier,
129
+ offset: node.position.start.offset
130
+ }] : []), ...concept.document.unresolvedFootnoteReferences.map((marker) => ({
131
+ label: marker.label,
132
+ offset: marker.position.start.offset
133
+ }))].sort((left, right) => left.offset - right.offset);
134
+ const seen = /* @__PURE__ */ new Set();
135
+ const first = [];
136
+ for (const marker of markers) {
137
+ if (seen.has(marker.label)) continue;
138
+ seen.add(marker.label);
139
+ first.push(marker);
140
+ }
141
+ return first;
142
+ };
129
143
  const footnoteSourceUnknown = rule("footnote-source-unknown", (context, severity) => {
130
144
  const out = [];
131
145
  for (const concept of context.bundle.concepts.values()) {
132
146
  const ids = new Set((concept.frontmatter.sources ?? []).flatMap((s) => s.id === void 0 ? [] : [s.id]));
133
147
  if (ids.size === 0) continue;
134
- const source = concept.document.source;
135
- const start = Option.getOrUndefined(concept.document.frontmatter)?.position.end.offset ?? 0;
136
- const code = codeSpansOf(concept);
137
- const seen = /* @__PURE__ */ new Set();
138
- for (const match of source.slice(start).matchAll(FOOTNOTE_RE)) {
139
- const label = match[1];
140
- if (label === void 0 || ids.has(label) || seen.has(label) || insideAny(code, start + match.index)) continue;
141
- seen.add(label);
142
- const range = DiagnosticRange.fromOffset(source, start + match.index, match[0].length);
148
+ for (const { label, offset } of footnoteLabelsOf(concept)) {
149
+ if (ids.has(label)) continue;
150
+ const range = DiagnosticRange.fromOffset(concept.document.source, offset, label.length + 3);
143
151
  out.push(diagnostic(concept.path, "footnote-source-unknown", severity, `Footnote label "${label}" must equal a sources[].id exactly (declared: ${[...ids].join(", ")})`, range));
144
152
  }
145
153
  }
@@ -149,59 +157,18 @@ const footnoteUndefined = rule("footnote-undefined", (context, severity) => {
149
157
  const out = [];
150
158
  for (const concept of context.bundle.concepts.values()) {
151
159
  const source = concept.document.source;
152
- const start = Option.getOrUndefined(concept.document.frontmatter)?.position.end.offset ?? 0;
153
- const body = source.slice(start);
154
- const code = codeSpansOf(concept);
155
- const defined = new Set([...body.matchAll(FOOTNOTE_DEFINITION_RE)].flatMap((m) => m[1] === void 0 || insideAny(code, start + m.index) ? [] : [m[1]]));
156
160
  const seen = /* @__PURE__ */ new Set();
157
- for (const match of body.matchAll(FOOTNOTE_RE)) {
158
- const label = match[1];
159
- if (label === void 0 || defined.has(label) || seen.has(label) || insideAny(code, start + match.index)) continue;
160
- seen.add(label);
161
- const range = DiagnosticRange.fromOffset(source, start + match.index, match[0].length);
162
- out.push(diagnostic(concept.path, "footnote-undefined", severity, `Footnote "${label}" is referenced but has no [^${label}]: definition`, range));
161
+ for (const marker of concept.document.unresolvedFootnoteReferences) {
162
+ if (seen.has(marker.label)) continue;
163
+ seen.add(marker.label);
164
+ const { start, end } = marker.position;
165
+ out.push(diagnostic(concept.path, "footnote-undefined", severity, `Footnote "${marker.label}" is referenced but has no [^${marker.label}]: definition`, DiagnosticRange.fromOffset(source, start.offset, end.offset - start.offset)));
163
166
  }
164
167
  }
165
168
  return out;
166
169
  });
167
- /** GitHub-style heading slug: lowercase, punctuation dropped, spaces to hyphens, duplicates suffixed `-1`, `-2`, ... */
168
- const headingSlugs = (concept) => {
169
- const seen = /* @__PURE__ */ new Map();
170
- const slugs = [];
171
- for (const heading of concept.document.headings) {
172
- const base = heading.text.toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu, "").trim().replace(/\s+/g, "-");
173
- const count = seen.get(base) ?? 0;
174
- seen.set(base, count + 1);
175
- slugs.push(count === 0 ? base : `${base}-${count}`);
176
- }
177
- return slugs;
178
- };
179
- /** Levenshtein distance (two-row DP). */
180
- const editDistance = (a, b) => {
181
- let previous = Array.from({ length: b.length + 1 }, (_, index) => index);
182
- for (let i = 1; i <= a.length; i++) {
183
- const current = [i];
184
- for (let j = 1; j <= b.length; j++) {
185
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
186
- current[j] = Math.min((previous[j] ?? 0) + 1, (current[j - 1] ?? 0) + 1, (previous[j - 1] ?? 0) + cost);
187
- }
188
- previous = current;
189
- }
190
- return previous[b.length] ?? 0;
191
- };
192
170
  /** The closest slug within max(2, ⌊|fragment| / 3⌋) edits, ties to the earliest heading; else undefined. */
193
- const nearestSlug = (fragment, slugs) => {
194
- const limit = Math.max(2, Math.floor(fragment.length / 3));
195
- let best;
196
- for (const slug of slugs) {
197
- const distance = editDistance(fragment, slug);
198
- if (distance <= limit && (best === void 0 || distance < best.distance)) best = {
199
- slug,
200
- distance
201
- };
202
- }
203
- return best?.slug;
204
- };
171
+ const nearestSlug = (fragment, slugs) => EditDistance.suggest(fragment, slugs, { maxDistance: Math.max(2, Math.floor(fragment.length / 3)) })[0];
205
172
  const candidateHint = (fragment, slugs) => {
206
173
  if (slugs.length === 0) return "it has no headings";
207
174
  const near = nearestSlug(fragment, slugs);
@@ -231,7 +198,7 @@ const brokenLinks = rule("broken-links", (context, severity) => {
231
198
  const slugsOf = (id, target) => {
232
199
  const cached = slugCache.get(id);
233
200
  if (cached !== void 0) return cached;
234
- const slugs = headingSlugs(target);
201
+ const slugs = target.document.headingSlugs;
235
202
  slugCache.set(id, slugs);
236
203
  return slugs;
237
204
  };
@@ -1,18 +1,12 @@
1
+ import { FrontmatterSource } from "@effected/markdown";
2
+
1
3
  // src/internal/position.ts
2
- const LF = 10;
3
- const CR = 13;
4
4
  /**
5
- * File offset of the first frontmatter value character: the opening fence
6
- * plus its terminator (`\r\n` counts two, `\n` or `\r` one). Only meaningful
7
- * when `text` starts with the fence.
5
+ * Map a `YamlDiagnostic.offset` or `YamlNode.offset` inside the frontmatter value to a whole-file
6
+ * offset. Only meaningful when `text` opens a closed frontmatter block.
8
7
  *
9
8
  * @public
10
9
  */
11
- const frontmatterValueStart = (text) => {
12
- const afterFence = 3;
13
- return afterFence + (text.charCodeAt(afterFence) === CR && text.charCodeAt(4) === LF ? 2 : 1);
14
- };
15
- /** Map a `YamlDiagnostic.offset` or `YamlNode.offset` inside the frontmatter value to a whole-file offset. @public */
16
- const toFileOffset = (text, yamlOffset) => frontmatterValueStart(text) + yamlOffset;
10
+ const toFileOffset = (text, yamlOffset) => (FrontmatterSource.split(text).frontmatter?.valueStart ?? 0) + yamlOffset;
17
11
 
18
- export { frontmatterValueStart, toFileOffset };
12
+ export { toFileOffset };
package/internal/walk.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { GlobPattern, GlobPatternOptions } from "@effected/glob";
1
2
  import { Effect } from "effect";
2
3
  import { descend } from "@effected/walker";
3
- import { GlobPattern, GlobPatternOptions } from "@effected/glob";
4
4
 
5
5
  // src/internal/walk.ts
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okfit/core",
3
- "version": "0.12.1",
3
+ "version": "0.13.1",
4
4
  "private": false,
5
5
  "description": "Spec-level Open Knowledge Format (OKF) v0.2 schemas, bundle loading, graph, derivation, and validation for Effect.",
6
6
  "keywords": [
@@ -37,15 +37,15 @@
37
37
  "./package.json": "./package.json"
38
38
  },
39
39
  "peerDependencies": {
40
- "@effected/config-file": "^0.24.0",
41
- "@effected/glob": "^0.18.0",
42
- "@effected/jsonc": "^0.23.0",
43
- "@effected/markdown": "^0.26.0",
44
- "@effected/schemastore": "^0.29.0",
45
- "@effected/source": "^0.3.0",
46
- "@effected/toml": "^0.19.0",
47
- "@effected/walker": "^0.25.0",
48
- "@effected/yaml": "^0.28.0",
40
+ "@effected/config-file": "^0.26.0",
41
+ "@effected/glob": "^0.20.0",
42
+ "@effected/jsonc": "^0.24.0",
43
+ "@effected/markdown": "^0.28.0",
44
+ "@effected/schemastore": "^0.31.0",
45
+ "@effected/source": "^0.4.0",
46
+ "@effected/toml": "^0.19.1",
47
+ "@effected/walker": "^0.26.0",
48
+ "@effected/yaml": "^0.29.0",
49
49
  "effect": "~4.1.2"
50
50
  },
51
51
  "engines": {
@@ -1,52 +0,0 @@
1
- // src/internal/posixPath.ts
2
- const SLASH = 47;
3
- /**
4
- * Collapse `.`/`..` and repeated slashes. Relative input keeps leading `..`
5
- * (the caller classifies bundle escapes); absolute input clamps at the root.
6
- * A trailing slash survives; `""` is `"."`.
7
- *
8
- * @public
9
- */
10
- const normalize = (path) => {
11
- if (path.length === 0) return ".";
12
- const isAbsolute = path.charCodeAt(0) === SLASH;
13
- const trailingSeparator = path.charCodeAt(path.length - 1) === SLASH;
14
- const segments = [];
15
- for (const segment of path.split("/")) {
16
- if (segment.length === 0 || segment === ".") continue;
17
- if (segment === "..") {
18
- if (segments.length > 0 && segments[segments.length - 1] !== "..") segments.pop();
19
- else if (!isAbsolute) segments.push("..");
20
- continue;
21
- }
22
- segments.push(segment);
23
- }
24
- let result = segments.join("/");
25
- if (result.length === 0 && !isAbsolute) result = ".";
26
- if (result.length > 0 && trailingSeparator) result += "/";
27
- return isAbsolute ? `/${result}` : result;
28
- };
29
- /** Join non-empty segments with `/` and normalize; no segments is `"."`. @public */
30
- const join = (...paths) => {
31
- const joined = paths.filter((segment) => segment.length > 0).join("/");
32
- return joined.length === 0 ? "." : normalize(joined);
33
- };
34
- /** Directory part of `path`: `"."` for a bare name, `"/"` for a root-level absolute path. @public */
35
- const dirname = (path) => {
36
- let end = path.length;
37
- while (end > 1 && path.charCodeAt(end - 1) === SLASH) end--;
38
- const trimmed = path.slice(0, end);
39
- const index = trimmed.lastIndexOf("/");
40
- if (index === -1) return ".";
41
- if (index === 0) return "/";
42
- return trimmed.slice(0, index);
43
- };
44
- /** Last segment of `path` with trailing slashes stripped; `""` for `""` or `"/"`. @public */
45
- const basename = (path) => {
46
- let end = path.length;
47
- while (end > 0 && path.charCodeAt(end - 1) === SLASH) end--;
48
- const trimmed = path.slice(0, end);
49
- return trimmed.slice(trimmed.lastIndexOf("/") + 1);
50
- };
51
-
52
- export { basename, dirname, join, normalize };