Skip to content

Bug: Broken @mariozechner/pi-ai Patch After Upstream Update #118

@daveonkels

Description

@daveonkels

Date: 2026-01-02
Severity: High (Blocks build)
Status: Unresolved
Upstream Issue: https://github.com/steipete/clawdis (not yet reported)

Summary

After pulling the latest updates from the Clawdis main branch (commit fabad7aa), the build fails due to a broken pnpm patch file for the @mariozechner/pi-ai dependency. The patch file fails to apply with "hunk header integrity check failed" error.

Environment

  • Clawdis Version: 2.0.0-beta4
  • Node Version: >=22.12.0 (as per package.json)
  • pnpm Version: 10.23.0
  • Platform: macOS (Darwin 25.2.0)
  • Installation Path: ~/.clawdis-src

Steps to Reproduce

  1. Start with a working Clawdis installation at commit 5c7c1af4
  2. Pull latest updates from upstream:
    git -C ~/.clawdis-src pull origin main
  3. Attempt to install dependencies:
    pnpm --dir ~/.clawdis-src install

Error Output

ERR_PNPM_INVALID_PATCH  Applying patch "/Users/username/.clawdis-src/patches/@mariozechner__pi-ai.patch" failed: hunk header integrity check failed

Root Cause Analysis

The patch file patches/@mariozechner__pi-ai.patch was updated in the upstream pull (88 line changes), but the patch hunks no longer match the actual code in the @mariozechner/[email protected] package from npm.

This suggests:

  1. The patch was regenerated against a different version of the dependency, OR
  2. The dependency version was updated but the patch wasn't regenerated, OR
  3. There's a mismatch between the patch file and the actual package structure

Impact

Build Failures

Without the patch applied, TypeScript compilation fails with 29+ type errors:

src/agents/clawdis-tools.ts(1758,32): error TS2345: Argument of type '"reactions"' is not assignable to parameter of type 'never'.
src/agents/clawdis-tools.ts(1772,32): error TS2345: Argument of type '"reactions"' is not assignable to parameter of type 'never'.
// ... 27 more similar errors
src/tui/message-list.ts(59,11): error TS2552: Cannot find name 'MessageEntry'. Did you mean 'MessageEvent'?

Additional Issues

Also discovered that discord-api-types was missing as an explicit dependency, causing additional build errors:

src/discord/send.ts(2,32): error TS2307: Cannot find module 'discord-api-types/payloads/v10' or its corresponding type declarations.

Workarounds Attempted

❌ Failed Attempts

  1. Remove node_modules and reinstall - Patch still fails
  2. Temporarily remove patch from package.json - Build fails with type errors
  3. Disable noEmitOnError in tsconfig.json - Build still exits with error code
  4. Add missing discord-api-types - Fixed discord errors but core type errors remain
  5. Regenerate patch with pnpm patch - Cannot create workspace because patch application fails

✅ Working Workarounds

Option 1: Use Existing Pre-Update Build (Recommended)

The previous build from commit 5c7c1af4 still works:

# Existing binary works fine
clawdis --version  # → 2.0.0-beta5
clawdis gateway

Pros:

  • No changes needed
  • Fully functional
  • Custom skills load correctly from ~/.clawdis/skills/

Cons:

  • Doesn't include latest features from the update

Option 2: Development Mode with tsx

Run TypeScript directly without compilation:

pnpm --dir ~/.clawdis-src clawdis gateway

Pros:

  • Gets latest code features
  • Bypasses compilation errors

Cons:

  • Slightly slower startup
  • Requires running via pnpm command

Option 3: Rollback to Previous Commit

git -C ~/.clawdis-src reset --hard 5c7c1af4
pnpm --dir ~/.clawdis-src install
pnpm --dir ~/.clawdis-src run build

Pros:

  • Clean, working build

Cons:

  • Loses all updates from the pull

Related Files

  • ~/.clawdis-src/patches/@mariozechner__pi-ai.patch - Broken patch file (3.6KB)
  • ~/.clawdis-src/package.json - Patch configuration (lines 137-140)
  • ~/.clawdis-src/src/agents/clawdis-tools.ts - File with type errors (lines 1758-2235)
  • ~/.clawdis-src/src/discord/send.ts - Missing discord-api-types imports
  • ~/.clawdis-src/src/tui/message-list.ts - Missing MessageEntry type (line 59)

Commits Involved

  • Before: 5c7c1af4 - Working build
  • After: fabad7aa - Broken build (426 files changed, +36,581 insertions, -4,010 deletions)

Temporary Changes Made

To enable workarounds, the following temporary modifications were made:

  1. Added missing dependency:

    pnpm --dir ~/.clawdis-src -w install discord-api-types
    # Added: discord-api-types ^0.38.37
  2. Modified tsconfig.json:

    "noEmitOnError": false  // Changed from true
  3. Modified package.json (reverted):

    • Temporarily removed @mariozechner/pi-ai from patchedDependencies
    • Later restored to preserve patch configuration

Recommendations for Upstream

  1. Regenerate the patch file against the current version of @mariozechner/[email protected]
  2. Add discord-api-types as explicit dependency in package.json
  3. Verify patch application in CI/CD before merging
  4. Document patch purpose - Add comments explaining what the patch fixes

How to Regenerate Patch (For Maintainers)

# Remove the broken patch temporarily from package.json
# Then create a new patch:
pnpm patch @mariozechner/pi-ai
# Edit files in the temporary directory shown
# Save changes:
pnpm patch-commit /path/to/temp/dir

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions