github / github/copilot-cli

[FEATURE] Use sparse checkout for plugin installs — only fetch shipping assets, not entire repo

未关闭
#2,399 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:installation area:plugins
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

### Problem Statement

When GitHub Copilot CLI installs a plugin, it performs a full `git clone` of the source repository. This means **every file in the repo** — tests, CI configs, development tooling, documentation source, images, etc. — is downloaded to the user's machine, even though only the plugin directory is a shipping asset.

This has two problems:

1. **Performance**: Full clones are unnecessarily slow and disk-heavy, especially for monorepos or repos with large non-plugin content (media, test fixtures, etc.).

2. **Shipping asset boundary** (more important): Files outside the plugin directory are development artifacts — tests, `.github/` workflows, `.config/`, contributor docs, build scripts, etc. These are **not intended to be distributed to end users**. Fetching them conflates "installing a plugin" with "cloning a development environment." Plugin consumers should only receive what plugin authors intend to ship.

### Proposed Solution

Use Git's **partial clone + sparse checkout** to fetch only the plugin subdirectory:

```bash
# 1. Partial clone — no blobs downloaded yet
git clone --filter=blob:none --sparse --depth=1
cd

# 2. Sparse checkout — only materialize the plugin path
git sparse-checkout set
```

| Flag | Effect |
|---|---|
| `--filter=blob:none` | Partial clone — skips downloading file content until needed |
| `--sparse` | Enables sparse checkout (only root files initially) |
| `--depth=1` | Shallow — only the latest commit, no history |

This is well-supported by GitHub's servers and requires Git 2.25+.

### Alternative Solutions

| Approach | Downside |
|---|---|
| Full clone (status quo) | Downloads non-shipping content; slower |
| `--depth=1` only (shallow clone) | Still downloads all files across the tree |
| Download tarball of subdirectory via GitHub API | Loses git-based update/ref mechanism |

### Additional Context

- Git partial clone + sparse checkout is production-ready and used at scale (e.g., by large monorepos at Microsoft, Google).
- GitHub's servers fully support `--filter=blob:none` and `--filter=tree:0`.
- A corresponding issue has been filed for Claude Code: https://github.com/anthropics/claude-code/issues/40864

贡献指南

打开贡献指南

调研方向

Begin in the plugin installation flow that currently performs a full git clone; trace how the plugin path and Git command errors are handled. Implement and verify shallow partial-clone and sparse-checkout behavior, confirming that only the plugin directory is materialized and unrelated repository files are not fetched.

由索引模型根据 Issue 内容生成。

评估

技术栈
git, shell
领域
cli
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。