- Add HERETEK_FORK.md with fork strategy and upstream sync workflow - Add CHANGELOG_HERETEK.md tracking all Heretek-specific changes - Create patches/ directory with README documentation - Generate Phase 1 patch files: - a2a-protocol-infrastructure.patch - agent-lifecycle-steward-primary.patch - approval-system-liberation.patch - Add patch management scripts: - patch-apply.sh - Apply all patches from .patchestoo - patch-create.sh - Create new patches from diffs - patch-status.sh - Show patch application status - upstream-sync.sh - Sync with upstream repository - Add .patchestoo file listing patches in order - Update package.json with patch-related npm scripts - Add postinstall hook for automatic patch application Phase 1 fixes include: - A2A Protocol infrastructure (Redis messaging, Gateway, WebSocket bridge) - Agent lifecycle improvements (auto-registration, heartbeat, /agent-status) - Approval system liberation (auto-apply patches, approval bypass)
Heretek Patch Management
This directory contains patch files for maintaining Heretek-specific modifications while preserving upstream compatibility.
Overview
The patch system allows Heretek to:
- Apply bug fixes and features on top of upstream OpenClaw
- Easily rebase onto new upstream versions
- Track and manage Heretek-specific changes
- Contribute fixes back to upstream when appropriate
Quick Start
Applying Patches
Patches are automatically applied during npm install via the postinstall hook.
Manual application:
./scripts/patch-apply.sh
Creating a New Patch
# Create patch from modified files
./scripts/patch-create.sh <patch-name> <file-path>
# Example:
./scripts/patch-create.sh my-fix gateway/openclaw-gateway.js
Checking Patch Status
./scripts/patch-status.sh
Patch Files
| Patch File | Description | Category |
|---|---|---|
a2a-protocol-infrastructure.patch |
A2A messaging, Gateway, Redis bridge | Bug Fix |
agent-lifecycle-steward-primary.patch |
Agent registration, heartbeat, steward config | Bug Fix |
approval-system-liberation.patch |
Approval bypass, safety section removal | Heretek Feature |
Patch Format
All patches use unified diff format:
--- a/path/to/file.js
+++ b/path/to/file.js
@@ -1,5 +1,6 @@
// Modified line
+// New line added
// Unchanged line
-// Removed line
+// Replaced line
.patchestoo File
The .patchestoo file at the repository root lists patches in the order they should be applied:
patches/a2a-protocol-infrastructure.patch
patches/agent-lifecycle-steward-primary.patch
patches/approval-system-liberation.patch
Patch Categories
Bug Fixes
Patches that fix broken functionality. These should be contributed back to upstream.
a2a-protocol-infrastructure.patchagent-lifecycle-steward-primary.patch
Heretek Features
Patches specific to Heretek's deployment or requirements.
approval-system-liberation.patch
Workflow
1. Making Changes
- Modify files as needed
- Test thoroughly
- Create patch:
./scripts/patch-create.sh <patch-name> <file-path>
2. Applying Patches
- Fresh checkout or after upstream sync
- Run:
./scripts/patch-apply.sh
3. Checking Status
./scripts/patch-status.sh
Output shows:
- ✅ Applied patches
- ❌ Failed patches
- ⚠️ Patches with warnings
4. Upstream Sync
-
Fetch upstream:
git fetch upstream -
Rebase:
git rebase upstream/main -
Resolve conflicts if any
-
Re-apply patches:
./scripts/patch-apply.sh -
Regenerate patches if needed:
./scripts/patch-create.sh <patch-name> <file-path>
Troubleshooting
Patch Failed to Apply
-
Check if file exists:
ls -la <file-path> -
Check patch format:
cat patches/<patch-name>.patch -
Try manual application:
patch -p1 < patches/<patch-name>.patch -
If still failing, regenerate patch:
./scripts/patch-create.sh <patch-name> <file-path>
Conflicts After Upstream Sync
-
Identify conflicting patches:
./scripts/patch-status.sh -
Manually resolve conflicts in affected files
-
Regenerate patches:
./scripts/patch-create.sh <patch-name> <file-path>
Best Practices
- Keep patches focused - Each patch should address a single issue or feature
- Document changes - Include clear commit messages and comments
- Test thoroughly - Always test after applying patches
- Contribute upstream - Submit bug fixes to upstream when possible
- Version patches - Include version info in patch names for major changes
Scripts Reference
| Script | Description |
|---|---|
scripts/patch-apply.sh |
Apply all patches from .patchestoo |
scripts/patch-create.sh |
Create a new patch from diff |
scripts/patch-status.sh |
Show patch application status |
scripts/upstream-sync.sh |
Sync with upstream repository |
Related Documentation
HERETEK_FORK.md- Fork strategy and upstream syncCHANGELOG_HERETEK.md- Heretek-specific changelogDEBUG_A2A.md- A2A protocol debug reportDEBUG_AGENT_LIFECYCLE.md- Agent lifecycle debug report