Token导航 LogoToken导航TokenDH.com
研究检索只读github未标认证来源可访问许可证需确认审计通过

1k-patching-native-modules1k 修补本机模块

Agent Skill

1k-patching-native-modules 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,257

周安装

54

GitHub Stars

2,415

下载量

441
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:1k-patching-native-modules(1k 修补本机模块)
来源仓库:https://github.com/onekeyhq/app-monorepo
仓库路径:skills/1k-patching-native-modules
安装命令:
npx skills add https://github.com/onekeyhq/app-monorepo --skill 1k-patching-native-modules
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/onekeyhq/app-monorepo --skill 1k-patching-native-modules

简介

该技能专为处理原生模块崩溃问题设计, 可自动解析 EXC_BAD_ACCESS 或 SIGABRT 等异常日志。

  • 核心能力包括提取关键崩溃信息、定位问题函数、修复代码缺陷并清理构建产物。
  • 使用方式遵循六步工作流:分析日志→定位Bug→修复代码→清理构建→生成补丁→提交PR。
  • 安装前需确认权限范围及是否触发联网或文件操作。

SKILL.md

Patching Native Modules

Follow this workflow to analyze crash logs, fix native module bugs, and generate patches.

Workflow Overview

1. Analyze Crash Log → 2. Locate Bug → 3. Fix Code → 4. Clean Build Artifacts → 5. Generate Patch → 6. Commit & PR

Step 1: Analyze Crash Log

iOS Crash (EXC_BAD_ACCESS / KERN_INVALID_ADDRESS)

Key information to extract:

  • Exception type: EXC_BAD_ACCESS, SIGABRT, etc.
  • Stack trace: Identify the crashing function
  • Memory address: Helps identify nil pointer issues
  • Library: Which native module is crashing

Example crash pattern:

EXC_BAD_ACCESS: KERN_INVALID_ADDRESS at 0x3c61c1a3b0d0
 objc_msgSend in unknown file
 -[SDWebImageManager cacheKeyForURL:context:]  ← Crashing function
 -[SDWebImageManager loadImageWithURL:options:context:progress:completed:]

Android Crash (NullPointerException / OOM)

Look for:

  • Exception class: NullPointerException, OutOfMemoryError
  • Stack trace: Java/Kotlin method chain
  • Thread info: Main thread vs background

Step 2: Locate the Bug

Find native module source

# iOS (Swift/Objective-C)
ls node_modules/<package>/ios/

# Android (Kotlin/Java)
ls node_modules/<package>/android/src/main/java/

Common crash causes

Crash TypeCommon CauseFix Pattern
EXC_BAD_ACCESSNil pointer dereferenceAdd guard let check
KERN_INVALID_ADDRESSAccessing deallocated memoryUse weak references
NullPointerExceptionNull object accessAdd null check
OutOfMemoryErrorLarge image/data processingAdd size limits

Step 3: Fix the Code

iOS (Swift) - Nil Check Pattern

// Before (crashes when uri is nil)
imageManager.loadImage(with: source.uri, ...)

// After (safe)
guard let sourceUri = source.uri, !sourceUri.absoluteString.isEmpty else {
  onError(["error": "Image source URI is nil or empty"])
  return
}
imageManager.loadImage(with: sourceUri, ...)

Android (Kotlin) - Null Check Pattern

// Before
val uri = source.uri
loadImage(uri)

// After
val uri = source.uri ?: return
if (uri.toString().isEmpty()) return
loadImage(uri)

Step 4: Clean Build Artifacts (CRITICAL)

Before generating patch, MUST clean Android build cache:

# Remove Android build artifacts to avoid polluting the patch
rm -rf node_modules/<package>/android/build

# For expo-image specifically:
rm -rf node_modules/expo-image/android/build

Why this matters:

  • Android build generates .class, .jar, binary files
  • These pollute the patch file (can grow to 5000+ lines)
  • patch-package will include these unwanted files

Step 5: Generate Patch

# Generate patch file
npx patch-package <package-name>

# Example:
npx patch-package expo-image

Patch file location: patches/<package-name>+<version>.patch

Verify patch content

# Check patch doesn't include unwanted files
grep -c "android/build" patches/<package-name>*.patch
# Should return 0

# View actual changes
head -100 patches/<package-name>*.patch

Step 6: Commit & Create PR

# Stage patch file
git add patches/<package-name>*.patch

# Commit with descriptive message
git commit -m "fix(ios): prevent EXC_BAD_ACCESS crash in <package> when <condition>

Add guard checks in <package> native layer to prevent crash when <scenario>.

Fixes Sentry issue #XXXXX"

# Create PR
gh pr create --title "fix(ios): <description>" --base x

Common Packages & Their Native Locations

PackageiOS SourceAndroid Source
expo-imagenode_modules/expo-image/ios/node_modules/expo-image/android/src/
react-nativenode_modules/react-native/React/node_modules/react-native/ReactAndroid/
@react-native-async-storage/async-storagenode_modules/@react-native-async-storage/async-storage/ios/...android/src/
react-native-reanimatednode_modules/react-native-reanimated/ios/...android/src/

Existing Patches Reference

Check existing patches for patterns:

ls patches/
cat patches/expo-image+3.0.10.patch

Troubleshooting

Patch file too large

# Clean all build artifacts
rm -rf node_modules/<package>/android/build
rm -rf node_modules/<package>/ios/build
rm -rf node_modules/<package>/.gradle

# Regenerate
npx patch-package <package>

Patch not applying

# Check package version matches
cat node_modules/<package>/package.json | grep version

# Rename patch if version changed
mv patches/<package>+old.patch patches/<package>+new.patch

Swift/Kotlin syntax help

Swift guard let:

guard let value = optionalValue else {
  return  // Must exit scope
}
// value is now non-optional

Kotlin null check:

val value = nullableValue ?: return
// value is now non-null

Related Files

  • Patches directory: patches/
  • expo-image iOS: node_modules/expo-image/ios/ImageView.swift
  • expo-image Android: node_modules/expo-image/android/src/main/java/expo/modules/image/

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.23%
按下载量换算147

Claude

31.66%
按下载量换算140

Cursor

18.55%
按下载量换算82

Gemini CLI

8.78%
按下载量换算39

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills