@openclaw/diffs 2026.7.1 → 2026.7.2-beta.2
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/README.md +0 -8
- package/dist/assets/viewer-runtime.js +31 -31
- package/dist/index.js +30 -85
- package/npm-shrinkwrap.json +2 -2
- package/openclaw.plugin.json +1 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -18,7 +18,8 @@ import { readFiniteNumberParam } from "openclaw/plugin-sdk/param-readers";
|
|
|
18
18
|
import { Type } from "typebox";
|
|
19
19
|
import { chromium } from "playwright-core";
|
|
20
20
|
import { parsePatchFiles, resolveLanguage } from "@pierre/diffs";
|
|
21
|
-
import {
|
|
21
|
+
import { preloadDiffHTML } from "@pierre/diffs/ssr";
|
|
22
|
+
import { escapeHtml } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
22
23
|
//#region extensions/diffs/src/types.ts
|
|
23
24
|
const DIFF_LAYOUTS = ["unified", "split"];
|
|
24
25
|
const DIFF_MODES = [
|
|
@@ -284,15 +285,15 @@ function normalizeTtlSeconds(ttlSeconds) {
|
|
|
284
285
|
return Math.min(Math.max(Math.floor(ttlSeconds), 1), 21600);
|
|
285
286
|
}
|
|
286
287
|
function resolveDiffImageRenderOptions(params) {
|
|
287
|
-
const format = normalizeFileFormat(params.fileFormat ?? params.
|
|
288
|
-
const qualityOverrideProvided = params.fileQuality !== void 0
|
|
289
|
-
const qualityPreset = normalizeFileQuality$1(params.fileQuality ?? params.
|
|
288
|
+
const format = normalizeFileFormat(params.fileFormat ?? params.defaults.fileFormat);
|
|
289
|
+
const qualityOverrideProvided = params.fileQuality !== void 0;
|
|
290
|
+
const qualityPreset = normalizeFileQuality$1(params.fileQuality ?? params.defaults.fileQuality);
|
|
290
291
|
const profile = DEFAULT_IMAGE_QUALITY_PROFILES[qualityPreset];
|
|
291
292
|
return {
|
|
292
293
|
format,
|
|
293
294
|
qualityPreset,
|
|
294
|
-
scale: normalizeFileScale(params.fileScale
|
|
295
|
-
maxWidth: normalizeFileMaxWidth(params.fileMaxWidth
|
|
295
|
+
scale: normalizeFileScale(params.fileScale, qualityOverrideProvided ? profile.scale : params.defaults.fileScale),
|
|
296
|
+
maxWidth: normalizeFileMaxWidth(params.fileMaxWidth, qualityOverrideProvided ? profile.maxWidth : params.defaults.fileMaxWidth),
|
|
296
297
|
maxPixels: profile.maxPixels
|
|
297
298
|
};
|
|
298
299
|
}
|
|
@@ -1482,11 +1483,6 @@ const bundledLanguagesBase = Object.fromEntries(bundledLanguagesInfo.map((langua
|
|
|
1482
1483
|
function getBundledLanguageAliases(language) {
|
|
1483
1484
|
return "aliases" in language ? language.aliases : [];
|
|
1484
1485
|
}
|
|
1485
|
-
const bundledLanguagesAlias = Object.fromEntries(bundledLanguagesInfo.flatMap((language) => getBundledLanguageAliases(language).map((alias) => [alias, language.import])));
|
|
1486
|
-
({
|
|
1487
|
-
...bundledLanguagesBase,
|
|
1488
|
-
...bundledLanguagesAlias
|
|
1489
|
-
});
|
|
1490
1486
|
//#endregion
|
|
1491
1487
|
//#region extensions/diffs/src/language-hints.ts
|
|
1492
1488
|
const BASE_DIFF_VIEWER_LANGUAGE_HINTS = [
|
|
@@ -1590,9 +1586,6 @@ var DiffRenderInputError = class extends Error {
|
|
|
1590
1586
|
function escapeCssString(value) {
|
|
1591
1587
|
return value.replaceAll("\\", "\\\\").replaceAll("\"", "\\\"");
|
|
1592
1588
|
}
|
|
1593
|
-
function escapeHtml(value) {
|
|
1594
|
-
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
1595
|
-
}
|
|
1596
1589
|
function escapeJsonScript(value) {
|
|
1597
1590
|
return JSON.stringify(value).replaceAll("<", "\\u003c");
|
|
1598
1591
|
}
|
|
@@ -2008,19 +2001,18 @@ async function renderBeforeAfterDiff(input, options, target) {
|
|
|
2008
2001
|
});
|
|
2009
2002
|
const preloadOptions = viewerOptions ?? imageOptions;
|
|
2010
2003
|
if (!preloadOptions) throw new Error(`Unsupported diff render target: ${target}`);
|
|
2011
|
-
const
|
|
2004
|
+
const normalizedPayload = await normalizeDiffViewerPayloadLanguages({
|
|
2005
|
+
prerenderedHTML: await preloadDiffHTMLWithFallback({
|
|
2006
|
+
oldFile,
|
|
2007
|
+
newFile,
|
|
2008
|
+
options: preloadOptions
|
|
2009
|
+
}),
|
|
2012
2010
|
oldFile,
|
|
2013
2011
|
newFile,
|
|
2014
|
-
options: preloadOptions
|
|
2015
|
-
});
|
|
2016
|
-
const normalizedPayload = await normalizeDiffViewerPayloadLanguages({
|
|
2017
|
-
prerenderedHTML: preloadResult.prerenderedHTML,
|
|
2018
|
-
oldFile: preloadResult.oldFile,
|
|
2019
|
-
newFile: preloadResult.newFile,
|
|
2020
2012
|
options: preloadOptions,
|
|
2021
2013
|
langs: collectDiffPayloadLanguageHints({
|
|
2022
|
-
oldFile
|
|
2023
|
-
newFile
|
|
2014
|
+
oldFile,
|
|
2015
|
+
newFile
|
|
2024
2016
|
})
|
|
2025
2017
|
}, { languagePackAvailable });
|
|
2026
2018
|
const viewerPayload = viewerOptions ? {
|
|
@@ -2063,15 +2055,14 @@ async function renderPatchDiff(input, options, target) {
|
|
|
2063
2055
|
stats: computeFileDiffStats(fileDiff)
|
|
2064
2056
|
}));
|
|
2065
2057
|
const sections = await Promise.all(files.map(async (fileDiff, index) => {
|
|
2066
|
-
const preloadResult = await preloadFileDiffWithFallback({
|
|
2067
|
-
fileDiff,
|
|
2068
|
-
options: preloadOptions
|
|
2069
|
-
});
|
|
2070
2058
|
const normalizedPayload = await normalizeDiffViewerPayloadLanguages({
|
|
2071
|
-
prerenderedHTML:
|
|
2072
|
-
|
|
2059
|
+
prerenderedHTML: await preloadDiffHTMLWithFallback({
|
|
2060
|
+
fileDiff,
|
|
2061
|
+
options: preloadOptions
|
|
2062
|
+
}),
|
|
2063
|
+
fileDiff,
|
|
2073
2064
|
options: preloadOptions,
|
|
2074
|
-
langs: collectDiffPayloadLanguageHints({ fileDiff
|
|
2065
|
+
langs: collectDiffPayloadLanguageHints({ fileDiff })
|
|
2075
2066
|
}, { languagePackAvailable });
|
|
2076
2067
|
const viewerPayload = viewerOptions ? {
|
|
2077
2068
|
...normalizedPayload,
|
|
@@ -2134,27 +2125,12 @@ async function renderDiffDocument(input, options, target = "both") {
|
|
|
2134
2125
|
function shouldFallbackToClientHydration(error) {
|
|
2135
2126
|
return error instanceof TypeError && error.message.includes("needs an import attribute of \"type: json\"");
|
|
2136
2127
|
}
|
|
2137
|
-
async function
|
|
2138
|
-
try {
|
|
2139
|
-
return await preloadFileDiff(params);
|
|
2140
|
-
} catch (error) {
|
|
2141
|
-
if (!shouldFallbackToClientHydration(error)) throw error;
|
|
2142
|
-
return {
|
|
2143
|
-
fileDiff: params.fileDiff,
|
|
2144
|
-
prerenderedHTML: ""
|
|
2145
|
-
};
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
async function preloadMultiFileDiffWithFallback(params) {
|
|
2128
|
+
async function preloadDiffHTMLWithFallback(params) {
|
|
2149
2129
|
try {
|
|
2150
|
-
return await
|
|
2130
|
+
return await preloadDiffHTML(params);
|
|
2151
2131
|
} catch (error) {
|
|
2152
2132
|
if (!shouldFallbackToClientHydration(error)) throw error;
|
|
2153
|
-
return
|
|
2154
|
-
oldFile: params.oldFile,
|
|
2155
|
-
newFile: params.newFile,
|
|
2156
|
-
prerenderedHTML: ""
|
|
2157
|
-
};
|
|
2133
|
+
return "";
|
|
2158
2134
|
}
|
|
2159
2135
|
}
|
|
2160
2136
|
//#endregion
|
|
@@ -2199,30 +2175,6 @@ const DiffsToolSchema = Type.Object({
|
|
|
2199
2175
|
minimum: 640,
|
|
2200
2176
|
maximum: 2400
|
|
2201
2177
|
}),
|
|
2202
|
-
/** @deprecated Use fileQuality. */
|
|
2203
|
-
imageQuality: Type.Optional(stringEnum(DIFF_IMAGE_QUALITY_PRESETS, {
|
|
2204
|
-
description: "Deprecated alias for fileQuality.",
|
|
2205
|
-
deprecated: true
|
|
2206
|
-
})),
|
|
2207
|
-
/** @deprecated Use fileFormat. */
|
|
2208
|
-
imageFormat: Type.Optional(stringEnum(DIFF_OUTPUT_FORMATS, {
|
|
2209
|
-
description: "Deprecated alias for fileFormat.",
|
|
2210
|
-
deprecated: true
|
|
2211
|
-
})),
|
|
2212
|
-
/** @deprecated Use fileScale. */
|
|
2213
|
-
imageScale: optionalFiniteNumberSchema({
|
|
2214
|
-
description: "Deprecated alias for fileScale.",
|
|
2215
|
-
deprecated: true,
|
|
2216
|
-
minimum: 1,
|
|
2217
|
-
maximum: 4
|
|
2218
|
-
}),
|
|
2219
|
-
/** @deprecated Use fileMaxWidth. */
|
|
2220
|
-
imageMaxWidth: optionalFiniteNumberSchema({
|
|
2221
|
-
description: "Deprecated alias for fileMaxWidth.",
|
|
2222
|
-
deprecated: true,
|
|
2223
|
-
minimum: 640,
|
|
2224
|
-
maximum: 2400
|
|
2225
|
-
}),
|
|
2226
2178
|
expandUnchanged: Type.Optional(Type.Boolean({ description: "Expand unchanged sections instead of collapsing them." })),
|
|
2227
2179
|
ttlSeconds: optionalFiniteNumberSchema({
|
|
2228
2180
|
description: "Artifact lifetime in seconds. Default: 1800. Maximum: 21600.",
|
|
@@ -2257,13 +2209,13 @@ function createDiffsTool(params) {
|
|
|
2257
2209
|
const layout = normalizeLayout(toolParams.layout, params.defaults.layout);
|
|
2258
2210
|
const expandUnchanged = toolParams.expandUnchanged === true;
|
|
2259
2211
|
const ttlSeconds = readFiniteNumberParam(rawRecord, "ttlSeconds") ?? params.defaults.ttlSeconds;
|
|
2260
|
-
const fileScale = readFiniteNumberParam(rawRecord, "fileScale")
|
|
2261
|
-
const fileMaxWidth = readFiniteNumberParam(rawRecord, "fileMaxWidth")
|
|
2212
|
+
const fileScale = readFiniteNumberParam(rawRecord, "fileScale");
|
|
2213
|
+
const fileMaxWidth = readFiniteNumberParam(rawRecord, "fileMaxWidth");
|
|
2262
2214
|
const ttlMs = normalizeTtlMs(ttlSeconds);
|
|
2263
2215
|
const image = resolveDiffImageRenderOptions({
|
|
2264
2216
|
defaults: params.defaults,
|
|
2265
|
-
fileFormat: normalizeOutputFormat(toolParams.fileFormat
|
|
2266
|
-
fileQuality: normalizeFileQuality(toolParams.fileQuality
|
|
2217
|
+
fileFormat: normalizeOutputFormat(toolParams.fileFormat),
|
|
2218
|
+
fileQuality: normalizeFileQuality(toolParams.fileQuality),
|
|
2267
2219
|
fileScale,
|
|
2268
2220
|
fileMaxWidth
|
|
2269
2221
|
});
|
|
@@ -2383,8 +2335,7 @@ function createDiffsTool(params) {
|
|
|
2383
2335
|
}],
|
|
2384
2336
|
details: {
|
|
2385
2337
|
...baseDetails,
|
|
2386
|
-
fileError: errorMessage
|
|
2387
|
-
imageError: errorMessage
|
|
2338
|
+
fileError: errorMessage
|
|
2388
2339
|
}
|
|
2389
2340
|
};
|
|
2390
2341
|
}
|
|
@@ -2415,18 +2366,12 @@ function buildArtifactDetails(params) {
|
|
|
2415
2366
|
return {
|
|
2416
2367
|
...params.baseDetails,
|
|
2417
2368
|
filePath: params.artifactFile.path,
|
|
2418
|
-
imagePath: params.artifactFile.path,
|
|
2419
2369
|
path: params.artifactFile.path,
|
|
2420
2370
|
fileBytes: params.artifactFile.bytes,
|
|
2421
|
-
imageBytes: params.artifactFile.bytes,
|
|
2422
|
-
format: params.image.format,
|
|
2423
2371
|
fileFormat: params.image.format,
|
|
2424
2372
|
fileQuality: params.image.qualityPreset,
|
|
2425
|
-
imageQuality: params.image.qualityPreset,
|
|
2426
2373
|
fileScale: params.image.scale,
|
|
2427
|
-
|
|
2428
|
-
fileMaxWidth: params.image.maxWidth,
|
|
2429
|
-
imageMaxWidth: params.image.maxWidth
|
|
2374
|
+
fileMaxWidth: params.image.maxWidth
|
|
2430
2375
|
};
|
|
2431
2376
|
}
|
|
2432
2377
|
function buildFileArtifactMessage(params) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/diffs",
|
|
3
|
-
"version": "2026.7.
|
|
3
|
+
"version": "2026.7.2-beta.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/diffs",
|
|
9
|
-
"version": "2026.7.
|
|
9
|
+
"version": "2026.7.2-beta.2",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@pierre/diffs": "1.2.12",
|
|
12
12
|
"@shikijs/langs": "4.3.0",
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/diffs",
|
|
3
|
-
"version": "2026.7.
|
|
3
|
+
"version": "2026.7.2-beta.2",
|
|
4
4
|
"description": "OpenClaw read-only diff viewer plugin and file renderer for agents.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"minHostVersion": ">=2026.4.30"
|
|
26
26
|
},
|
|
27
27
|
"compat": {
|
|
28
|
-
"pluginApi": ">=2026.7.
|
|
28
|
+
"pluginApi": ">=2026.7.2-beta.2"
|
|
29
29
|
},
|
|
30
30
|
"assetScripts": {
|
|
31
31
|
"build": "node ../../scripts/build-diffs-viewer-runtime.mjs curated"
|
|
32
32
|
},
|
|
33
33
|
"build": {
|
|
34
|
-
"openclawVersion": "2026.7.
|
|
34
|
+
"openclawVersion": "2026.7.2-beta.2",
|
|
35
35
|
"staticAssets": [
|
|
36
36
|
{
|
|
37
37
|
"source": "./assets/viewer-runtime.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"skills/**"
|
|
56
56
|
],
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"openclaw": ">=2026.7.
|
|
58
|
+
"openclaw": ">=2026.7.2-beta.2"
|
|
59
59
|
},
|
|
60
60
|
"peerDependenciesMeta": {
|
|
61
61
|
"openclaw": {
|