feat: patch-based custom fork system with 4 patches#1
Conversation
Add the complete infrastructure for maintaining custom patches on top of upstream sipeed/picoclaw, following a patch-based fork workflow instead of a long-lived divergent fork. Structure: - UPSTREAM.conf: pins upstream repo, tag (v0.2.3), and SHA - patches/: directory for .patch files (applied in lexicographic order) - PATCHES.md: human + AI-readable registry of patch intent and risk - scripts/apply-patches.sh: clone upstream + apply all patches - scripts/generate-patches.sh: export commits as format-patch files - scripts/upgrade-upstream.sh: test patches against a new upstream tag - scripts/ai-regenerate-patch.sh: Claude Code-powered patch regeneration - .github/workflows/patch-ci.yml: validate patches on push/PR - .github/workflows/upstream-watch.yml: daily cron to detect new releases Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…em prompt Add SOPs (Standard Operating Procedures) as a first-class concept: - Add sops/ directory with README.md to the default workspace template, so new installations include the SOP folder structure out of the box. - Add SOP instructions as rule sipeed#5 in the agent system prompt, making the agent check for and follow relevant SOPs before executing any task. - Add SOPs path to the workspace directory listing in the identity block. This hardcodes SOP-aware behavior into the agent rather than relying on per-user memory.md configuration, ensuring consistent SOP-driven execution across all installations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add the generated .patch file and update PATCHES.md with the intent, scope, and risk documentation for the SOP framework patch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The exec tool's safety guard was overly aggressive, blocking normal shell
features (command substitution, variable expansion, heredocs, eval, source)
and standard dev tools (git push, ssh, chmod, kill) making the tool
nearly unusable when workspace restriction was enabled.
Changes:
- Remove deny patterns for shell features: $(), ${}, backticks, heredocs,
eval, source — these are core shell functionality, not security threats
- Remove deny patterns for dev tools: git push, ssh, chmod, chown, kill,
pkill, killall — normal operations that should not be blocked
- Add safe system path prefixes (/usr/, /bin/, /sbin/, /lib/, /opt/,
/tmp/, /proc/, /sys/, plus macOS paths) so commands referencing system
tools and binaries are not blocked by workspace boundary checks
- Update tests to reflect the relaxed deny list and add new tests for
system paths and shell features being allowed
Security is preserved through:
- Destructive commands still blocked (rm -rf, disk wipe, shutdown, etc.)
- Remote code execution still blocked (curl|sh, wget|sh, $(curl..))
- Privilege escalation still blocked (sudo)
- System/global package installs still blocked
- Container operations still blocked (docker run/exec)
- Workspace boundary still enforced for working directory and file tools
- Path traversal (../) still blocked
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add the generated .patch file and update PATCHES.md with intent, scope, and risk documentation for the exec guard relaxation patch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add cloud-based automated patch regeneration for upstream upgrades: - patch-autofix.yml: full pipeline that tries patches against new tag, invokes Claude Agent SDK to regenerate failures, validates, and creates PR - ai-regenerate-patch-ci.mjs: Node.js script using Agent SDK for headless CI patch regeneration (replaces CLI-based approach) - scripts/package.json: declares @anthropic-ai/claude-agent-sdk dependency - upstream-watch.yml: now triggers patch-autofix.yml instead of patch-ci.yml Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SubagentManager was created with an empty ToolRegistry and SetTools() was never called, causing all subagent tool invocations to fail with "tool not found". This was a regression from the multi-agent refactor. Fix: clone the parent agent's tool registry into the subagent manager after creation but before spawn/spawn_status registration — giving subagents access to file, exec, web, and other tools while preventing recursive subagent spawning. - Add ToolRegistry.Clone() for independent shallow copies - Call subagentManager.SetTools(agent.Tools.Clone()) in registerSharedTools - Add tests for Clone isolation, empty clone, and hidden tool state Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (23)
📝 WalkthroughWalkthroughThis pull request introduces an automated upstream patch management system consisting of three new GitHub Actions workflows (upstream monitoring, patch validation, and auto-fix), AI-powered patch regeneration via Claude Agent SDK, configuration infrastructure, and Go code enhancements for SOP framework integration, execution guard relaxation, and subagent tool isolation. Changes
Sequence DiagramsequenceDiagram
participant Scheduler as Scheduler (Daily)
participant UpstreamWatch as upstream-watch.yml
participant GithubAPI as GitHub API
participant PatchAutofix as patch-autofix.yml
participant Upstream as Upstream Repo
participant ClaudeAgent as Claude Agent SDK
participant PatchValidation as patch-ci.yml
participant PRSystem as PR Creation
Scheduler->>UpstreamWatch: Trigger daily
UpstreamWatch->>Upstream: Fetch latest tag
UpstreamWatch->>UpstreamWatch: Compare CURRENT vs LATEST
alt New release detected
UpstreamWatch->>GithubAPI: Trigger patch-autofix.yml
UpstreamWatch->>GithubAPI: Create tracking issue
end
GithubAPI->>PatchAutofix: Invoke with new_tag
PatchAutofix->>Upstream: Clone at new tag
PatchAutofix->>PatchAutofix: Apply patches sequentially
alt All patches apply
PatchAutofix->>PatchAutofix: Update UPSTREAM.conf
PatchAutofix->>PRSystem: Create upgrade PR (clean)
else Patches fail
PatchAutofix->>ClaudeAgent: Request regeneration
ClaudeAgent->>PatchAutofix: Return regenerated patch
PatchAutofix->>PatchValidation: Validate patch
alt Validation succeeds
PatchAutofix->>PatchAutofix: Update UPSTREAM.conf
PatchAutofix->>PRSystem: Create PR (AI-generated label)
else Validation fails
PatchAutofix->>PRSystem: Create PR (needs-review label)
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can enable review details to help with troubleshooting, context usage and more.Enable the |
Summary
Complete patch-based fork management system for maintaining custom modifications on top of upstream
sipeed/picoclaw, following the git-patches masterclass methodology.Infrastructure
6f30436)apply-patches.sh,generate-patches.sh,upgrade-upstream.sh,ai-regenerate-patch.shpatch-ci.yml(validation),upstream-watch.yml(daily cron),patch-autofix.yml(AI auto-fix)Patches
add-sop-frameworkrelax-exec-guardci-autofix-agent-sdkfix-subagent-toolsPatch 004 upstream PR
Test plan
pkg/toolsandpkg/agentpackages build cleanlyscripts/apply-patches.shANTHROPIC_API_KEYsecret — test after merge🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Chores