# Dismantle

> Dismantle excellent projects into reusable parts for the partlib. Use when user says "拆解这个项目", "提取零件", "dismantle", "拆模块", or points at a project and wants to e

- Skill: `nierehv/dismantle` (Agent Skill, multi-file: 5 files)
- Install (CLI): `npx get-skill add nierehv/dismantle`
- Raw SKILL.md: https://api.skillmd.com/api/skills/nierehv/dismantle/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: NierEHV (https://skillmd.com/u/nierehv)
- Updated: 2026-12-02
- Page: https://skillmd.com/skills/nierehv/dismantle

---

---
name: dismantle
description: Dismantle excellent projects into reusable parts for the partlib. Use when user says "拆解这个项目", "提取零件", "dismantle", "拆模块", or points at a project and wants to extract reusable components. Follows the 5-phase SOP: assess → dissect → extract → verify → archive.
---

# Dismantle Project — 拆解项目零件

将优秀项目拆解为零件的标准流程。

## 快速开始

用户说"拆解这个项目"或"提取零件"时自动触发。

**零件库位置**: `C:\Users\NIERGAM\Desktop\partlib`

## 五阶段流程

```
评估 → 解剖 → 抽离 → 验证 → 归档
```

每阶段结束**必须等待用户确认**才进入下一阶段。

### 阶段1: 评估

**目标**: 列出所有候选模块，判定独立性。

关键操作:
```
1. 读 package.json + README + LICENSE
2. 用 find/Glob 列出 src/ 顶层目录
3. 对每个候选目录，grep 统计外部 import 数
4. 按 N 判定独立性: 0-5高 / 6-15中 / 16-30低 / >30放弃
5. 检查 LICENSE — 硬排除: 无许可、AGPL、CC-BY-NC
```

产出: `layer-0-raw/<项目名>/ASSESSMENT.md`

### 阶段2: 解剖

**目标**: 精确分析单个模块的依赖图。

关键操作:
```
1. 逐文件读取模块内所有 .ts/.tsx 文件
2. 提取所有 import 语句，分为三类:
   - 内部: ./xxx → 跟着走
   - 项目: ../../xxx → 需评估处理方案
   - 外部: npm包 → 正常声明
3. 对每个"项目"依赖分类: 复制/移除/接口化
4. 统计工作量，评级 ⭐ ~ ⭐⭐⭐⭐
```

产出: `layer-0-raw/<项目名>/<模块名>/DEPENDENCY_MAP.md`

### 阶段3: 抽离

**目标**: 剥离模块，解耦，形成独立包。

```
1. 确定零件在8大类目中的位置
2. 用 cp 或 Write 复制文件到 partlib/<分类>/<零件名>/src/
3. 按优先级处理依赖: A复制工具文件 → B移除业务耦合 → C接口化
4. 修正所有 import 路径为零件内相对路径
5. 写 src/index.ts (唯一公共API)
6. 写 UPSTREAM.md (每个文件的来源映射)
7. 运行 grep 横切检查: 无外部引用、无硬编码路径
```

### 阶段4: 验证

**目标**: 证明零件可独立使用。

```
1. 写 __tests__/smoke.test.ts (每个公开API至少调用一次)
2. 运行 npx bun test
3. 横切检查: grep "from '..\/" — 只允许模块内相对路径
```

### 阶段5: 归档

```
1. 更新 INDEX.md
2. 记录上游快照到 layer-0-raw/
3. 汇报完成
```

## 分类树

```
00-界面/    01-交互/    02-通信/    03-数据/
04-管线/    05-运行时/  06-工具链/  07-Agent/
08-协议/
```

详细 SOP 见 [REFERENCE.md](REFERENCE.md)，实战案例见 [EXAMPLES.md](EXAMPLES.md)。

