@agent-facets/adapter-claude-code 0.3.0 → 0.4.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.
Files changed (2) hide show
  1. package/dist/index.mjs +21 -4
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -6,6 +6,22 @@ import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
6
6
  var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
7
7
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
8
8
  //#endregion
9
+ //#region ../../common/src/text.ts
10
+ /**
11
+ * Small text-normalization helpers used across packages that parse
12
+ * user-authored files. Lives in `common` so core front-matter parsing and
13
+ * the adapter SDK's asset-fs helpers can share one definition — Windows
14
+ * line endings or a stray BOM shouldn't cause divergent behavior across
15
+ * readers.
16
+ */
17
+ /**
18
+ * Strip a leading UTF-8 BOM and convert any `\r\n` / `\r` line endings to
19
+ * `\n`. Idempotent. Returns the string unchanged if already normalized.
20
+ */
21
+ function normalizeLineEndings(raw) {
22
+ return raw.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
23
+ }
24
+ //#endregion
9
25
  //#region ../../../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/identity.js
10
26
  var require_identity = /* @__PURE__ */ __commonJSMin(((exports) => {
11
27
  const ALIAS = Symbol.for("yaml.alias");
@@ -6651,17 +6667,18 @@ function assembleAssetContent(body, metadata) {
6651
6667
  * or an equivalent well-tested parser is the right fix.
6652
6668
  */
6653
6669
  function splitAssetContent(raw) {
6654
- const match = raw.match(FRONT_MATTER_RE);
6655
- if (!match) return { content: raw };
6670
+ const normalized = normalizeLineEndings(raw);
6671
+ const match = normalized.match(FRONT_MATTER_RE);
6672
+ if (!match) return { content: normalized };
6656
6673
  try {
6657
6674
  const parsed = (0, import_dist.parse)(match[1] ?? "");
6658
6675
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) return {
6659
6676
  content: match[2] ?? "",
6660
6677
  metadata: parsed
6661
6678
  };
6662
- return { content: raw };
6679
+ return { content: normalized };
6663
6680
  } catch {
6664
- return { content: raw };
6681
+ return { content: normalized };
6665
6682
  }
6666
6683
  }
6667
6684
  //#endregion
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "https://github.com/agent-facets/facets",
6
6
  "directory": "packages/adapters/claude-code"
7
7
  },
8
- "version": "0.3.0",
8
+ "version": "0.4.1",
9
9
  "type": "module",
10
10
  "files": [
11
11
  "dist"
@@ -24,7 +24,7 @@
24
24
  "test": "bun test"
25
25
  },
26
26
  "devDependencies": {
27
- "@agent-facets/adapter": "0.3.0",
27
+ "@agent-facets/adapter": "0.4.1",
28
28
  "@types/bun": "1.3.11",
29
29
  "arktype": "2.2.0",
30
30
  "tsdown": "^0.21.9",