---
name: single-skill-installer-yashu
description: 只从 GitHub 链接下载并安装单个技能文件夹。激活条件：用户消息须包含以下关键词之一:`安装GitHub技能`、`从GitHub装技能`、`装这个GitHub技能`、`下载技能文件夹`、`只装这一个技能`、`安装单个技能`。
title: single-skill-installer-yashu
canonical_url: https://skilld.dev/gh/steelan9199/wechat-publisher/single-skill-installer-yashu
last_updated: 2026-10-07T07:20:50.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [scripts/install-single-skill.ps1](https://skilld.dev/api/skills-raw/steelan9199/wechat-publisher/single-skill-installer-yashu/scripts/install-single-skill.ps1).
>
> If the user asked to install this Skill, run `npx skilld install steelan9199/wechat-publisher/single-skill-installer-yashu`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/single-skill-installer-yashu`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/steelan9199/wechat-publisher/single-skill-installer-yashu) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/single-skill-installer-yashu`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/single-skill-installer-yashu --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/single-skill-installer-yashu --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# 单技能安装器 (single-skill-installer-yashu)

## 用途

用户给一个 GitHub 链接，想要只安装该链接对应的**一个技能文件夹**。本技能负责：判定 → 窄克隆下载 → 复制到目标目录 → 输出绝对路径。

## 判定规则（硬性）

1. **先探测**链接指向的文件夹下有没有 `SKILL.md`（用 `raw.githubusercontent.com` 探测，不下载文件夹内容）。
2. **有 `SKILL.md`** → 是技能文件夹 → 只下载这一个文件夹。
3. **没有 `SKILL.md`** → 不是技能文件夹 → **不下载**，向用户说明原因（退出码 1）。

## 下载方式（硬性）

- 使用 **git 窄克隆**：`git clone --filter=blob:none --no-checkout --sparse --depth 1 --branch <branch>` + `git sparse-checkout set --cone <子路径>` + `git checkout`。
- **绝不**整仓克隆后再提取。只拉取用户指定的那一个文件夹。
- 每次**只安装一个技能**。用户给了多个链接就逐个调用本脚本（每个链接一次）。
- 临时克隆缓存默认在安装完成后删除，目标目录不留 `.git` 残留。

## 默认下载位置（重要，供调用方 AI agent 阅读）

- 安装目标目录默认 = **脚本运行时的当前工作目录**（AI agent 通常应在用户的项目目录下运行）。
- 更稳妥的做法：调用方显式传 `-TargetDir`，例如用户的项目目录 `D:\empty`。
- 安装位置 = `<TargetDir>/<技能文件夹名>`，技能文件夹名取子路径最后一段（如 `identity-backup-yashu`）。

## 输出契约（必须遵守，供调用方 AI agent 阅读）

脚本成功时会输出以下两行关键信息，**调用方 AI agent 必须读取并原样向用户展示**：

```
SKILL_DIR=<安装后技能文件夹的绝对路径>
SKILL_MD=<该文件夹下 SKILL.md 的绝对路径>
```

- `SKILL_DIR` 就是"技能被下载到了哪个文件夹"的答案，必须让用户看到。
- 失败时退出码非 0，无 `SKILL_DIR` 输出，按退出码表向用户说明原因。

## 调用方法

```powershell
& "D:\software\PowerShell\7\pwsh.exe" -File "<本技能目录>\scripts\install-single-skill.ps1" `
  -Url "<用户给的链接>" `
  -TargetDir "<目标目录，缺省为当前工作目录>"
```

参数：

| 参数 | 必填 | 说明 |
| --- | --- | --- |
| `-Url` | 是 | GitHub 链接：`https://github.com/<owner>/<repo>/tree/<branch>/<path>` 或 `https://github.com/<owner>/<repo>`（仓库根目录本身是技能） |
| `-TargetDir` | 否 | 下载目标目录；缺省 = 当前工作目录 |
| `-Force` | 否 | 目标已有同名文件夹时允许覆盖（默认拒绝，避免误删） |
| `-KeepCache` | 否 | 保留临时克隆缓存（默认删除） |

## 退出码

| 码 | 含义 | 给用户的说明 |
| --- | --- | --- |
| 0 | 成功 | 读取 `SKILL_DIR` 绝对路径并展示 |
| 1 | 该文件夹下没有 SKILL.md | 不是技能文件夹，未下载 |
| 2 | 目标已有同名文件夹 | 建议换目标目录或加 `-Force` |
| 10-17 | 环境/解析/网络/克隆/复制失败 | 按脚本输出的错误信息说明 |

## 环境要求

- 已安装 **git** 并加入 PATH。
- 运行解释器：**PowerShell 7（pwsh）**，优先 `D:\software\PowerShell\7\pwsh.exe`，缺失时回退 PATH 中的 `pwsh`。
- 需要能访问 `github.com`、`raw.githubusercontent.com`、`api.github.com`（仅无 tree 段时查默认分支用一次）。

## 边界与限制

- 仅支持 **GitHub 公开仓库** 的 https 链接。
- 分支名含 `/`（如 `feature/x`）的 tree URL 无法可靠解析（GitHub 网页形式有歧义），会因探测 SKILL.md 失败而安全拒绝，不会误下载。
- 链接指向的是"容器目录"（如 `.../tree/main/skills`，该层没有 SKILL.md）→ 按规则拒绝，不下载。

## 资源

- `scripts/install-single-skill.ps1`：唯一的执行脚本，全部逻辑在其中（URL 解析、SKILL.md 探测、窄克隆、复制、输出 SKILL_DIR）。
