Skip to content

Commit 4e833ed

Browse files
committed
fix: adapt changelog.js patch for upstream OpenClaw 2026.5.6 compatibility
- changelog.js patch is now a conditional safety net (pi-coding-agent 0.73.0+ ships valid exports) - fix undefined Test-ChangelogExports call in package-win.ps1 - all three build scripts (win/unix/CI) updated consistently
1 parent 233f060 commit 4e833ed

3 files changed

Lines changed: 34 additions & 16 deletions

File tree

.github/workflows/build.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,18 @@ jobs:
207207
EOF
208208
209209
# ===== Patch upstream bugs =====
210-
- name: Patch missing changelog.js (upstream bug in @mariozechner/pi-coding-agent)
210+
- name: Patch missing changelog.js (safety net for @mariozechner/pi-coding-agent < 0.73.0)
211211
shell: bash
212212
run: |
213213
STUB="build/${{ matrix.platform }}/node_modules/@mariozechner/pi-coding-agent/dist/utils/changelog.js"
214214
NEEDS_PATCH=false
215-
if [ ! -f "$STUB" ]; then
216-
NEEDS_PATCH=true
217-
elif ! grep -q 'export function getChangelogPath' "$STUB" 2>/dev/null; then
218-
NEEDS_PATCH=true
215+
# Only check if the pi-coding-agent package is actually installed
216+
if [ -d "$(dirname "$STUB")" ]; then
217+
if [ ! -f "$STUB" ]; then
218+
NEEDS_PATCH=true
219+
elif ! grep -q 'export function getChangelogPath' "$STUB" 2>/dev/null; then
220+
NEEDS_PATCH=true
221+
fi
219222
fi
220223
if [ "$NEEDS_PATCH" = true ]; then
221224
echo "Patching: creating/replacing changelog.js stub"
@@ -225,8 +228,11 @@ jobs:
225228
export function parseChangelog() { return [] }
226229
export function getNewEntries() { return [] }
227230
STUBEOF
231+
else
232+
echo "changelog.js exports OK (no patch needed)"
228233
fi
229234
235+
230236
# ===== Cleanup to reduce size =====
231237
# IMPORTANT: Never clean files inside the openclaw package itself (openclaw/ or @qingchencloud/openclaw-zh/).
232238
# Its dist/ contains Vite/Rollup chunks with hash names (history-CMXy8eH-.js, changelog-*.js, etc.)

scripts/package-unix.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,16 @@ npm install "$OPENCLAW_PKG" \
7171
popd > /dev/null
7272

7373
# --- 3b. Patch: ensure changelog.js has required exports (upstream bug in @mariozechner/pi-coding-agent) ---
74+
# NOTE: As of pi-coding-agent 0.73.0+ this file ships with valid exports.
75+
# We keep this as a safety net for older transitive versions.
7476
CHANGELOG_STUB="$BUILD_DIR/node_modules/@mariozechner/pi-coding-agent/dist/utils/changelog.js"
7577
NEEDS_PATCH=false
76-
if [ ! -f "$CHANGELOG_STUB" ]; then
77-
NEEDS_PATCH=true
78-
elif ! grep -q 'export function getChangelogPath' "$CHANGELOG_STUB" 2>/dev/null; then
79-
NEEDS_PATCH=true
78+
if [ -d "$(dirname "$CHANGELOG_STUB")" ]; then
79+
if [ ! -f "$CHANGELOG_STUB" ]; then
80+
NEEDS_PATCH=true
81+
elif ! grep -q 'export function getChangelogPath' "$CHANGELOG_STUB" 2>/dev/null; then
82+
NEEDS_PATCH=true
83+
fi
8084
fi
8185
if [ "$NEEDS_PATCH" = true ]; then
8286
echo "Patching: creating/replacing changelog.js stub"
@@ -86,8 +90,9 @@ export function getChangelogPath() { return null }
8690
export function parseChangelog() { return [] }
8791
export function getNewEntries() { return [] }
8892
EOF
93+
else
94+
echo "changelog.js exports OK (no patch needed)"
8995
fi
90-
echo "changelog.js stub is in place"
9196

9297
# --- 4. Copy Node.js binary ---
9398
echo ""

scripts/package-win.ps1

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ if ($LASTEXITCODE -ne 0) {
5252
Pop-Location
5353

5454
# --- 3b. Patch: ensure changelog.js has required exports (upstream bug in @mariozechner/pi-coding-agent) ---
55+
# NOTE: As of pi-coding-agent 0.73.0+ this file ships with valid exports.
56+
# We keep this as a safety net for older transitive versions.
5557
$changelogStub = "$BuildDir\node_modules\@mariozechner\pi-coding-agent\dist\utils\changelog.js"
56-
$needsPatch = -not (Test-Path $changelogStub)
57-
if (-not $needsPatch) {
58-
$existingContent = Get-Content $changelogStub -Raw -ErrorAction SilentlyContinue
59-
if ($existingContent -notmatch 'export\s+function\s+getChangelogPath') {
58+
$needsPatch = $false
59+
if (Test-Path (Split-Path $changelogStub)) {
60+
if (-not (Test-Path $changelogStub)) {
6061
$needsPatch = $true
62+
} else {
63+
$existingContent = Get-Content $changelogStub -Raw -ErrorAction SilentlyContinue
64+
if ($existingContent -notmatch 'export\s+function\s+getChangelogPath') {
65+
$needsPatch = $true
66+
}
6167
}
6268
}
6369
if ($needsPatch) {
@@ -69,8 +75,9 @@ export function getChangelogPath() { return null }
6975
export function parseChangelog() { return [] }
7076
export function getNewEntries() { return [] }
7177
'@ | Set-Content -Path $changelogStub -Encoding UTF8
78+
} else {
79+
Write-Host "changelog.js exports OK (no patch needed)"
7280
}
73-
Write-Host "changelog.js stub is in place"
7481

7582
# --- 4. Copy Node.js binary ---
7683
Write-Host "`n=== Step 4: Copying Node.js runtime ===" -ForegroundColor Cyan
@@ -133,7 +140,7 @@ Write-Host ("Cleaned up ~{0:N1} MB of unnecessary files" -f $savedMB)
133140
# Remove build package.json (not needed in final package)
134141
Remove-Item "$BuildDir\package.json" -Force -ErrorAction SilentlyContinue
135142
Remove-Item "$BuildDir\package-lock.json" -Force -ErrorAction SilentlyContinue
136-
Test-ChangelogExports $BuildDir
143+
# (changelog.js patch verification handled in step 3b)
137144

138145
# --- 8. Create zip archive ---
139146
Write-Host "`n=== Step 8: Creating zip archive ===" -ForegroundColor Cyan

0 commit comments

Comments
 (0)