Skip to content

Commit 2830e55

Browse files
committed
fix(plugin-sdk): use truncateUtf16Safe for API declaration text truncation
Replace .slice(0, 1175) with truncateUtf16Safe() to prevent UTF-16 surrogate pair corruption in API baseline text.
1 parent e595a8c commit 2830e55

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/plugin-sdk/api-baseline.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
// API baseline helpers hash public SDK exports for contract drift checks.
21
import { createHash } from "node:crypto";
32
import fs from "node:fs/promises";
43
import path from "node:path";
54
import { fileURLToPath } from "node:url";
5+
// API baseline helpers hash public SDK exports for contract drift checks.
6+
import { truncateUtf16Safe } from "@openclaw/normalization-core/utf16-slice";
67
import ts from "typescript";
78
import {
89
pluginSdkDocMetadata,
@@ -352,7 +353,7 @@ function printNode(
352353
}
353354
const normalizedText = normalizePluginSdkApiDeclarationText(repoRoot, text);
354355
return normalizedText.length > 1200
355-
? `${normalizedText.slice(0, 1175).trimEnd()}\n/* truncated; see source */`
356+
? `${truncateUtf16Safe(normalizedText, 1175).trimEnd()}\n/* truncated; see source */`
356357
: normalizedText;
357358
}
358359

0 commit comments

Comments
 (0)