# Pdlc Relate

> 管理 feature 关系链（set/query/impact/orphans/rebuild/validate）

- **Type:** Skill
- **Install:** `agentstack add skill-kanfu-panda-pdlc-skills-pdlc-relate`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [kanfu-panda](https://agentstack.voostack.com/s/kanfu-panda)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [kanfu-panda](https://github.com/kanfu-panda)
- **Source:** https://github.com/kanfu-panda/pdlc-skills/tree/main/skills/pdlc-relate
- **Website:** https://kanfu-panda.github.io/pdlc/

## Install

```sh
agentstack add skill-kanfu-panda-pdlc-skills-pdlc-relate
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Feature 关系链管理

管理 PDLC feature 之间的关系链。维护反向索引 `docs/.pdlc-state/_relations.json` 和全局图 `docs/.pdlc-state/_graph.md`。

## 段一：执行子命令

从 `$ARGUMENTS` 解析子命令：

### `set    [target-fid...]`
为 feature `` 添加 `` 关系，指向一或多个目标。
1. 读 `docs/.pdlc-state/.json`；**若无 `relations` 块**（旧状态文件 / Phase 1 关系块可选），先初始化六类空块（`extends`/`depends_on`/`supersedes`/`resolves`/`conflicts_with`/`relates_to`），再在 `relations.` 数组追加目标（去重）
2. 若 `` 是对称类型（conflicts_with / relates_to）→ 同时在每个目标的 `.json` 镜像写入
3. 写回后调用本命令 `rebuild` 流程刷新 `_relations.json` + `_graph.md`

### `query `
显示 `` 的全部关系（出边 + 从 `_relations.json` 读入边）。

### `impact ` ⭐ 杀手锏
分析改动 `` 的影响半径。读 `_relations.json`：
- 🔴 **直接影响**（depth 1 入边）：直接 extends / depends_on 本 feature 的，必须协调
- 🟡 **间接影响**（depth ≥2 传递入边）：通过中间 feature 传递依赖的，应 review
- 🟢 **历史**（指向 terminal-state feature 的边 / resolves 的缺陷）：仅审计
输出树状结构 + 建议（先 review 哪些 PRD / 是否该新建 supersedes feature 而非就地改）。

### `orphans`
列出 `_relations.json` 中 inbound + outbound 均为空的 feature（可能是孤立 / 死代码候选）。

### `rebuild`
扫描所有 `docs/.pdlc-state/.json` 的 `relations` 块 + 文档追溯头的 `关系:` 行，重建：
- `_relations.json`：nodes（id→name/stage/terminal）+ edges（flat 有向列表）+ index（每节点预计算 inbound/outbound）
- `_graph.md`：mermaid 图，边样式按类型区分（supersedes 虚线 / conflicts_with 粗线 / 其余实线），顶部加 ``

### `validate`
按 `relations.md` 的校验规则检查：悬空引用 / 自引用 / extends·depends_on 成环 / 矛盾对 / 对称一致性。报告问题清单。

## 段二：自检（强制）

### 关系链自检清单

- [ ] `_relations.json` 是合法 JSON（`jq . ` 通过）
- [ ] 所有 edge 的 from/to ID 在 nodes 中存在（无悬空）
- [ ] 对称类型（conflicts_with / relates_to）两端互含
- [ ] extends / depends_on 无环
- [ ] `_graph.md` 含 `AUTO-GENERATED` 头且 mermaid 语法成对闭合
- [ ] set 操作的目标 ID 格式合法（F/B 开头）

## 段三：修复（单次，不递归）

- 可自动修复（对称缺失补镜像 / index 不一致 → 重跑 rebuild）→ 直接修
- 无法自动修复（真实的循环依赖 / 用户意图矛盾）→ 记录到报告，提示人工介入

## 段四：交接

> **状态机豁免**：本命令非 feature-scoped（不推进单个 feature 的阶段），不更新 `.json` 的 history，只维护关系索引文件。同 `/pdlc-changelog`。

**本命令的 handoff 输出：**

```
✅ 关系操作完成： 
📦 已更新：docs/.pdlc-state/_relations.json + _graph.md
👉 下一步：/pdlc-relate impact  查影响 | /pdlc-status 看全景
```

---

**关系操作**: $ARGUMENTS

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [kanfu-panda](https://github.com/kanfu-panda)
- **Source:** [kanfu-panda/pdlc-skills](https://github.com/kanfu-panda/pdlc-skills)
- **License:** MIT
- **Homepage:** https://kanfu-panda.github.io/pdlc/

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-kanfu-panda-pdlc-skills-pdlc-relate
- Seller: https://agentstack.voostack.com/s/kanfu-panda
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
