@coocarecloud/openclaw 0.0.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.
@@ -0,0 +1,207 @@
1
+ #!/bin/bash
2
+ # OpenClaw Standalone - macOS/Linux Packaging Script
3
+ # Usage: bash scripts/package-unix.sh
4
+ # Requires: Node.js 22+ installed on the build machine
5
+
6
+ set -euo pipefail
7
+
8
+ OPENCLAW_PKG="${OPENCLAW_PKG:-@coocarecloud/openclaw}"
9
+ OUTPUT_DIR="${OUTPUT_DIR:-output}"
10
+ SCRIPT_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
11
+
12
+ test_changelog_exports() {
13
+ local build_root="$1"
14
+ local interactive_mode="$build_root/node_modules/@mariozechner/pi-coding-agent/dist/modes/interactive/interactive-mode.js"
15
+ local changelog_file="$build_root/node_modules/@mariozechner/pi-coding-agent/dist/utils/changelog.js"
16
+
17
+ [ -f "$interactive_mode" ] || { echo "ERROR: Missing interactive-mode.js: $interactive_mode"; exit 1; }
18
+ [ -f "$changelog_file" ] || { echo "ERROR: Missing changelog.js: $changelog_file"; exit 1; }
19
+
20
+ if grep -Eq 'getChangelogPath|getNewEntries|parseChangelog' "$interactive_mode"; then
21
+ for export_name in getChangelogPath getNewEntries parseChangelog; do
22
+ if ! grep -Eq "export[[:space:]]+function[[:space:]]+${export_name}\\b" "$changelog_file"; then
23
+ echo "ERROR: changelog.js missing export: $export_name"
24
+ exit 1
25
+ fi
26
+ done
27
+ fi
28
+ }
29
+
30
+ cd "$SCRIPT_ROOT"
31
+
32
+ # --- Detect platform ---
33
+ OS="$(uname -s)"
34
+ ARCH="$(uname -m)"
35
+
36
+ case "$OS" in
37
+ Darwin) PLATFORM_OS="mac" ;;
38
+ Linux) PLATFORM_OS="linux" ;;
39
+ *) echo "Unsupported OS: $OS"; exit 1 ;;
40
+ esac
41
+
42
+ case "$ARCH" in
43
+ x86_64|amd64) PLATFORM_ARCH="x64" ;;
44
+ aarch64|arm64) PLATFORM_ARCH="arm64" ;;
45
+ armv7l) PLATFORM_ARCH="armv7l" ;;
46
+ *) echo "Unsupported arch: $ARCH"; exit 1 ;;
47
+ esac
48
+
49
+ PLATFORM="${PLATFORM_OS}-${PLATFORM_ARCH}"
50
+ BUILD_DIR="build/${PLATFORM}"
51
+
52
+ echo "=== OpenClaw Standalone Packager ==="
53
+ echo "Platform: $PLATFORM"
54
+ echo "Package: $OPENCLAW_PKG"
55
+ echo ""
56
+
57
+ # --- 1. Validate Node.js ---
58
+ echo "=== Step 1: Validating Node.js ==="
59
+ NODE_VERSION="$(node --version 2>/dev/null || true)"
60
+ if [ -z "$NODE_VERSION" ]; then
61
+ echo "ERROR: Node.js not found. Please install Node.js 22+ first."
62
+ exit 1
63
+ fi
64
+ NODE_PATH="$(which node)"
65
+ echo "Node.js version: $NODE_VERSION"
66
+ echo "Node.js binary: $NODE_PATH"
67
+
68
+ # --- 2. Clean & create build directory ---
69
+ echo ""
70
+ echo "=== Step 2: Preparing build directory ==="
71
+ rm -rf "$BUILD_DIR"
72
+ mkdir -p "$BUILD_DIR"
73
+
74
+ # --- 3. Install OpenClaw ---
75
+ echo ""
76
+ echo "=== Step 3: Installing $OPENCLAW_PKG ==="
77
+ pushd "$BUILD_DIR" > /dev/null
78
+
79
+ # Create minimal package.json
80
+ echo '{ "name": "openclaw-standalone-build", "private": true }' > package.json
81
+
82
+ # Install with optional deps, use China mirror
83
+ npm install "$OPENCLAW_PKG" \
84
+ --registry https://registry.npmmirror.com \
85
+ --include=optional \
86
+ 2>&1 | tail -5
87
+
88
+ popd > /dev/null
89
+
90
+ # --- 3b. Patch: create missing changelog.js stub (upstream bug in @mariozechner/pi-coding-agent) ---
91
+ CHANGELOG_STUB="$BUILD_DIR/node_modules/@mariozechner/pi-coding-agent/dist/utils/changelog.js"
92
+ if [ ! -f "$CHANGELOG_STUB" ]; then
93
+ echo "Patching: creating missing changelog.js stub"
94
+ mkdir -p "$(dirname "$CHANGELOG_STUB")"
95
+ cat > "$CHANGELOG_STUB" <<'EOF'
96
+ export function getChangelogPath() { return null }
97
+ export function parseChangelog() { return [] }
98
+ export function getNewEntries() { return [] }
99
+ EOF
100
+ fi
101
+ test_changelog_exports "$BUILD_DIR"
102
+
103
+ # --- 4. Copy Node.js binary ---
104
+ echo ""
105
+ echo "=== Step 4: Copying Node.js runtime ==="
106
+ cp "$NODE_PATH" "$BUILD_DIR/node"
107
+ chmod +x "$BUILD_DIR/node"
108
+ echo "Copied node binary to build directory"
109
+
110
+ # --- 5. Copy shim ---
111
+ echo ""
112
+ echo "=== Step 5: Creating CLI shim ==="
113
+ cp "shims/openclaw" "$BUILD_DIR/openclaw"
114
+ chmod +x "$BUILD_DIR/openclaw"
115
+
116
+ # --- 6. Get version info ---
117
+ echo ""
118
+ echo "=== Step 6: Reading version info ==="
119
+ PKG_JSON="$BUILD_DIR/node_modules/@coocarecloud/openclaw/package.json"
120
+ if [ ! -f "$PKG_JSON" ]; then
121
+ PKG_JSON="$BUILD_DIR/node_modules/openclaw/package.json"
122
+ fi
123
+ VERSION="$(node -e "console.log(require('$PKG_JSON').version)")"
124
+ echo "OpenClaw version: $VERSION"
125
+
126
+ cat > "$BUILD_DIR/VERSION" <<EOF
127
+ openclaw_version=$VERSION
128
+ node_version=$NODE_VERSION
129
+ platform=$PLATFORM
130
+ build_date=$(date -u '+%Y-%m-%d %H:%M:%S UTC')
131
+ EOF
132
+
133
+ # --- 7. Clean up unnecessary files ---
134
+ echo ""
135
+ echo "=== Step 7: Cleaning up unnecessary files ==="
136
+ BEFORE_SIZE=$(du -sm "$BUILD_DIR/node_modules" | cut -f1)
137
+
138
+ # Remove unnecessary files
139
+ find "$BUILD_DIR/node_modules" -type f \( \
140
+ -name "*.ts" -not -name "*.d.ts" -o \
141
+ -name "*.map" -o \
142
+ -name "*.md" -o \
143
+ -name "CHANGELOG*" -o \
144
+ -name "HISTORY*" -o \
145
+ -name "AUTHORS*" -o \
146
+ -name "CONTRIBUTORS*" -o \
147
+ -name ".npmignore" -o \
148
+ -name ".eslintrc*" -o \
149
+ -name ".prettierrc*" -o \
150
+ -name "tsconfig*.json" -o \
151
+ -name "Makefile" -o \
152
+ -name ".editorconfig" -o \
153
+ -name ".travis.yml" \
154
+ \) -delete 2>/dev/null || true
155
+
156
+ # Remove unnecessary directories
157
+ find "$BUILD_DIR/node_modules" -type d \( \
158
+ -name "test" -o \
159
+ -name "tests" -o \
160
+ -name "__tests__" -o \
161
+ -name "spec" -o \
162
+ -name "specs" -o \
163
+ -name "example" -o \
164
+ -name "examples" -o \
165
+ -name ".github" -o \
166
+ -name ".circleci" \
167
+ \) -exec rm -rf {} + 2>/dev/null || true
168
+
169
+ AFTER_SIZE=$(du -sm "$BUILD_DIR/node_modules" | cut -f1)
170
+ echo "Cleaned: ${BEFORE_SIZE}MB -> ${AFTER_SIZE}MB (saved $((BEFORE_SIZE - AFTER_SIZE))MB)"
171
+
172
+ # Remove build package.json
173
+ rm -f "$BUILD_DIR/package.json" "$BUILD_DIR/package-lock.json"
174
+ test_changelog_exports "$BUILD_DIR"
175
+
176
+ # --- 8. Create tar.gz archive ---
177
+ echo ""
178
+ echo "=== Step 8: Creating tar.gz archive ==="
179
+ mkdir -p "$OUTPUT_DIR"
180
+ ARCHIVE_NAME="openclaw-${VERSION}-${PLATFORM}.tar.gz"
181
+ ARCHIVE_PATH="$OUTPUT_DIR/$ARCHIVE_NAME"
182
+
183
+ # Rename to 'openclaw' for clean extraction
184
+ mv "$BUILD_DIR" "build/openclaw"
185
+ tar -czf "$ARCHIVE_PATH" -C "build" "openclaw"
186
+ mv "build/openclaw" "$BUILD_DIR"
187
+
188
+ ARCHIVE_SIZE=$(du -sm "$ARCHIVE_PATH" | cut -f1)
189
+ echo "Created: $ARCHIVE_PATH (${ARCHIVE_SIZE}MB)"
190
+
191
+ # --- 9. Generate checksum ---
192
+ echo ""
193
+ echo "=== Step 9: Generating checksum ==="
194
+ if command -v sha256sum &>/dev/null; then
195
+ sha256sum "$ARCHIVE_PATH" > "$ARCHIVE_PATH.sha256"
196
+ elif command -v shasum &>/dev/null; then
197
+ shasum -a 256 "$ARCHIVE_PATH" > "$ARCHIVE_PATH.sha256"
198
+ fi
199
+ echo "Checksum: $(cat "$ARCHIVE_PATH.sha256")"
200
+
201
+ # --- Summary ---
202
+ echo ""
203
+ echo "=== Build Complete ==="
204
+ echo "Version: $VERSION"
205
+ echo "Platform: $PLATFORM"
206
+ echo "Output: $OUTPUT_DIR/"
207
+ ls -lh "$OUTPUT_DIR/"
@@ -0,0 +1,206 @@
1
+ # OpenClaw Standalone - Windows x64 Packaging Script
2
+ # Usage: powershell -ExecutionPolicy Bypass -File scripts/package-win.ps1
3
+ # Requires: Node.js 22+ installed on the build machine
4
+
5
+ param(
6
+ [string]$OpenClawPkg = "@coocarecloud/openclaw",
7
+ [string]$OutputDir = "output",
8
+ [string]$BuildDir = "build\win-x64",
9
+ [switch]$SkipInstaller
10
+ )
11
+
12
+ $ErrorActionPreference = "Stop"
13
+
14
+ $SCRIPT_ROOT = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
15
+ Set-Location $SCRIPT_ROOT
16
+
17
+ function Test-ChangelogExports {
18
+ param([string]$BuildRoot)
19
+
20
+ $interactiveMode = Join-Path $BuildRoot 'node_modules\@mariozechner\pi-coding-agent\dist\modes\interactive\interactive-mode.js'
21
+ $changelogFile = Join-Path $BuildRoot 'node_modules\@mariozechner\pi-coding-agent\dist\utils\changelog.js'
22
+
23
+ if (-not (Test-Path $interactiveMode)) {
24
+ throw "Missing interactive-mode.js: $interactiveMode"
25
+ }
26
+ if (-not (Test-Path $changelogFile)) {
27
+ throw "Missing changelog.js: $changelogFile"
28
+ }
29
+
30
+ $interactiveContent = Get-Content $interactiveMode -Raw
31
+ if ($interactiveContent -match 'getChangelogPath|getNewEntries|parseChangelog') {
32
+ $changelogContent = Get-Content $changelogFile -Raw
33
+ foreach ($exportName in @('getChangelogPath', 'getNewEntries', 'parseChangelog')) {
34
+ if ($changelogContent -notmatch ("export\\s+function\\s+" + [regex]::Escape($exportName) + "\\b")) {
35
+ throw "changelog.js missing export: $exportName"
36
+ }
37
+ }
38
+ }
39
+ }
40
+
41
+ # --- 1. Validate Node.js ---
42
+ Write-Host "=== Step 1: Validating Node.js ===" -ForegroundColor Cyan
43
+ $nodeVersion = & node --version 2>$null
44
+ if (-not $nodeVersion) {
45
+ Write-Error "Node.js not found. Please install Node.js 22+ first."
46
+ exit 1
47
+ }
48
+ Write-Host "Node.js version: $nodeVersion"
49
+ $nodePath = (Get-Command node).Source
50
+ Write-Host "Node.js binary: $nodePath"
51
+
52
+ # --- 2. Clean & create build directory ---
53
+ Write-Host "`n=== Step 2: Preparing build directory ===" -ForegroundColor Cyan
54
+ if (Test-Path $BuildDir) {
55
+ Remove-Item -Recurse -Force $BuildDir
56
+ }
57
+ New-Item -ItemType Directory -Force -Path $BuildDir | Out-Null
58
+
59
+ # --- 3. Install OpenClaw into build directory ---
60
+ Write-Host "`n=== Step 3: Installing $OpenClawPkg ===" -ForegroundColor Cyan
61
+ Push-Location $BuildDir
62
+
63
+ # Create a minimal package.json to allow local install
64
+ @'
65
+ { "name": "openclaw-standalone-build", "private": true }
66
+ '@ | Set-Content -Path "package.json" -Encoding UTF8
67
+
68
+ # Install with all optional dependencies, use China mirror for faster CI
69
+ $npmArgs = @("install", $OpenClawPkg, "--registry", "https://registry.npmmirror.com", "--include=optional")
70
+ Write-Host "Running: npm $($npmArgs -join ' ')"
71
+ & npm @npmArgs
72
+ if ($LASTEXITCODE -ne 0) {
73
+ Write-Error "npm install failed with exit code $LASTEXITCODE"
74
+ exit 1
75
+ }
76
+ Pop-Location
77
+
78
+ # --- 3b. Patch: create missing changelog.js stub (upstream bug in @mariozechner/pi-coding-agent) ---
79
+ $changelogStub = "$BuildDir\node_modules\@mariozechner\pi-coding-agent\dist\utils\changelog.js"
80
+ if (-not (Test-Path $changelogStub)) {
81
+ Write-Host "Patching: creating missing changelog.js stub" -ForegroundColor Yellow
82
+ $stubDir = Split-Path $changelogStub
83
+ if (-not (Test-Path $stubDir)) { New-Item -ItemType Directory -Force -Path $stubDir | Out-Null }
84
+ @'
85
+ export function getChangelogPath() { return null }
86
+ export function parseChangelog() { return [] }
87
+ export function getNewEntries() { return [] }
88
+ '@ | Set-Content -Path $changelogStub -Encoding UTF8
89
+ }
90
+ Test-ChangelogExports $BuildDir
91
+
92
+ # --- 4. Copy Node.js binary ---
93
+ Write-Host "`n=== Step 4: Copying Node.js runtime ===" -ForegroundColor Cyan
94
+ Copy-Item $nodePath "$BuildDir\node.exe"
95
+ Write-Host "Copied node.exe to build directory"
96
+
97
+ # --- 5. Copy shim ---
98
+ Write-Host "`n=== Step 5: Creating CLI shim ===" -ForegroundColor Cyan
99
+ Copy-Item "shims\openclaw.cmd" "$BuildDir\openclaw.cmd"
100
+
101
+ # --- 6. Get version info ---
102
+ Write-Host "`n=== Step 6: Reading version info ===" -ForegroundColor Cyan
103
+ $pkgJsonPath = "$BuildDir\node_modules\@coocarecloud\openclaw\package.json"
104
+ if (-not (Test-Path $pkgJsonPath)) {
105
+ # Fallback: try without scope
106
+ $pkgJsonPath = "$BuildDir\node_modules\openclaw\package.json"
107
+ }
108
+ $pkgJson = Get-Content $pkgJsonPath -Raw | ConvertFrom-Json
109
+ $version = $pkgJson.version
110
+ Write-Host "OpenClaw version: $version"
111
+
112
+ # Write VERSION file
113
+ @"
114
+ openclaw_version=$version
115
+ node_version=$nodeVersion
116
+ platform=win-x64
117
+ build_date=$(Get-Date -Format "yyyy-MM-dd HH:mm:ss UTC" -AsUTC)
118
+ "@ | Set-Content -Path "$BuildDir\VERSION" -Encoding UTF8
119
+
120
+ # --- 7. Remove unnecessary files to reduce size ---
121
+ Write-Host "`n=== Step 7: Cleaning up unnecessary files ===" -ForegroundColor Cyan
122
+ $cleanPatterns = @(
123
+ "*.md", "*.ts", "*.map", "*.d.ts",
124
+ "CHANGELOG*", "HISTORY*", "AUTHORS*", "CONTRIBUTORS*",
125
+ ".npmignore", ".eslintrc*", ".prettierrc*", "tsconfig*.json",
126
+ "Makefile", "Gruntfile*", "Gulpfile*",
127
+ ".travis.yml", ".github", ".circleci",
128
+ "test", "tests", "__tests__", "spec", "specs",
129
+ "example", "examples", "doc", "docs",
130
+ ".editorconfig", ".jshintrc", ".flowconfig"
131
+ )
132
+ $savedMB = 0
133
+ foreach ($pattern in $cleanPatterns) {
134
+ $items = Get-ChildItem -Path "$BuildDir\node_modules" -Recurse -Filter $pattern -ErrorAction SilentlyContinue
135
+ foreach ($item in $items) {
136
+ $savedMB += $item.Length / 1MB
137
+ Remove-Item -Recurse -Force $item.FullName -ErrorAction SilentlyContinue
138
+ }
139
+ }
140
+ Write-Host ("Cleaned up ~{0:N1} MB of unnecessary files" -f $savedMB)
141
+
142
+ # Remove build package.json (not needed in final package)
143
+ Remove-Item "$BuildDir\package.json" -Force -ErrorAction SilentlyContinue
144
+ Remove-Item "$BuildDir\package-lock.json" -Force -ErrorAction SilentlyContinue
145
+ Test-ChangelogExports $BuildDir
146
+
147
+ # --- 8. Create zip archive ---
148
+ Write-Host "`n=== Step 8: Creating zip archive ===" -ForegroundColor Cyan
149
+ New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null
150
+ $zipName = "openclaw-$version-win-x64.zip"
151
+ $zipPath = Join-Path $OutputDir $zipName
152
+
153
+ if (Test-Path $zipPath) { Remove-Item $zipPath -Force }
154
+
155
+ # Rename build dir to 'openclaw' for clean extraction
156
+ $finalDir = "build\openclaw"
157
+ if (Test-Path $finalDir) { Remove-Item -Recurse -Force $finalDir }
158
+ Rename-Item $BuildDir "openclaw"
159
+ Compress-Archive -Path $finalDir -DestinationPath $zipPath -CompressionLevel Optimal
160
+ # Rename back
161
+ Rename-Item $finalDir "win-x64"
162
+
163
+ $zipSize = (Get-Item $zipPath).Length / 1MB
164
+ Write-Host ("Created: $zipPath ({0:N1} MB)" -f $zipSize) -ForegroundColor Green
165
+
166
+ # --- 9. Build Inno Setup installer (optional) ---
167
+ if (-not $SkipInstaller) {
168
+ Write-Host "`n=== Step 9: Building Inno Setup installer ===" -ForegroundColor Cyan
169
+ $iscc = Get-Command "ISCC" -ErrorAction SilentlyContinue
170
+ if (-not $iscc) {
171
+ # Try common Inno Setup paths
172
+ $issLocations = @(
173
+ "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe",
174
+ "$env:ProgramFiles\Inno Setup 6\ISCC.exe",
175
+ "${env:ProgramFiles(x86)}\Inno Setup 5\ISCC.exe"
176
+ )
177
+ foreach ($loc in $issLocations) {
178
+ if (Test-Path $loc) {
179
+ $iscc = @{ Source = $loc }
180
+ break
181
+ }
182
+ }
183
+ }
184
+
185
+ if ($iscc) {
186
+ $issScript = "installer\setup.iss"
187
+ & $iscc.Source "/DAppVersion=$version" "/DSourceDir=$SCRIPT_ROOT\build\win-x64" "/DOutputDir=$SCRIPT_ROOT\$OutputDir" $issScript
188
+ if ($LASTEXITCODE -eq 0) {
189
+ Write-Host "Installer created successfully!" -ForegroundColor Green
190
+ } else {
191
+ Write-Warning "Inno Setup compilation failed (exit code: $LASTEXITCODE). Zip archive is still available."
192
+ }
193
+ } else {
194
+ Write-Warning "Inno Setup not found. Skipping installer creation. Zip archive is still available."
195
+ Write-Host "Install Inno Setup from: https://jrsoftware.org/isdl.php"
196
+ }
197
+ }
198
+
199
+ # --- Summary ---
200
+ Write-Host "`n=== Build Complete ===" -ForegroundColor Green
201
+ Write-Host "Version: $version"
202
+ Write-Host "Platform: win-x64"
203
+ Write-Host "Output: $OutputDir\"
204
+ Get-ChildItem $OutputDir | ForEach-Object {
205
+ Write-Host (" {0} ({1:N1} MB)" -f $_.Name, ($_.Length / 1MB))
206
+ }
package/shims/openclaw ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
3
+ exec "$SCRIPT_DIR/node" "$SCRIPT_DIR/node_modules/@coocarecloud/openclaw/openclaw.mjs" "$@"
@@ -0,0 +1,4 @@
1
+ @echo off
2
+ setlocal
3
+ set "SCRIPT_DIR=%~dp0"
4
+ "%SCRIPT_DIR%node.exe" "%SCRIPT_DIR%node_modules\@coocarecloud\openclaw\openclaw.mjs" %*