librarian

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Use this skill when the user points you to a remote git repository (GitHub/GitLab/Bitbucket URLs,
git@...
, or
owner/repo
shorthand).
The goal is to keep a reusable local checkout that is:
  • stable (predictable path)
  • up to date (periodic fetch + fast-forward when safe)
  • efficient (partial clone with
    --filter=blob:none
    , no repeated full clones)
当用户向你提供远程git仓库(GitHub/GitLab/Bitbucket链接、
git@...
格式地址或
owner/repo
简写形式)时,使用此技能。
目标是维护一个可复用的本地检出副本,需满足:
  • 稳定(路径可预测)
  • 最新(定期拉取,在安全情况下进行快进合并)
  • 高效(使用
    --filter=blob:none
    进行部分克隆,避免重复完整克隆)

Cache location

缓存位置

Repositories are stored at:
~/.cache/checkouts/<host>/<org>/<repo>
Example:
github.com/mitsuhiko/minijinja
~/.cache/checkouts/github.com/mitsuhiko/minijinja
仓库存储在以下路径:
~/.cache/checkouts/<host>/<org>/<repo>
示例:
github.com/mitsuhiko/minijinja
~/.cache/checkouts/github.com/mitsuhiko/minijinja

Command

命令

bash
bash checkout.sh <repo> --path-only
Examples:
bash
bash checkout.sh mitsuhiko/minijinja --path-only
bash checkout.sh github.com/mitsuhiko/minijinja --path-only
bash checkout.sh https://github.com/mitsuhiko/minijinja --path-only
The script will:
  1. Parse the repo reference into host/org/repo.
  2. Clone if missing.
  3. Reuse existing checkout if present.
  4. Fetch from
    origin
    when stale (default interval: 300s).
  5. Attempt a fast-forward merge if the checkout is clean and has an upstream.
bash
bash checkout.sh <repo> --path-only
示例:
bash
bash checkout.sh mitsuhiko/minijinja --path-only
bash checkout.sh github.com/mitsuhiko/minijinja --path-only
bash checkout.sh https://github.com/mitsuhiko/minijinja --path-only
脚本会执行以下操作:
  1. 将仓库引用解析为host/org/repo格式。
  2. 若仓库不存在则克隆。
  3. 若已有检出副本则复用。
  4. 当副本过期时(默认间隔:300秒),从
    origin
    拉取更新。
  5. 若检出副本干净且有上游分支,则尝试快进合并。

Update strategy

更新策略

  • Default behavior is throttled refresh (every 5 minutes) to avoid unnecessary network calls.
  • Force immediate refresh with:
bash
bash checkout.sh <repo> --force-update --path-only
  • 默认行为是限流刷新(每5分钟一次),避免不必要的网络请求。
  • 使用以下命令强制立即刷新:
bash
bash checkout.sh <repo> --force-update --path-only

Recommended workflow

推荐工作流程

  1. Resolve repository path via
    checkout.sh --path-only
    .
  2. Use that path for searching, reading, and analysis.
  3. On later references to the same repo, call
    checkout.sh
    again; it will find and update the cached checkout.
  1. 通过
    checkout.sh --path-only
    解析仓库路径。
  2. 使用该路径进行搜索、读取和分析操作。
  3. 后续再次引用同一仓库时,再次调用
    checkout.sh
    ;脚本会找到并更新缓存的检出副本。

If edits are needed

若需要编辑内容

Prefer not to edit directly in the shared cache. Create a separate worktree or copy from the cached checkout for task-specific modifications.
建议不要直接在共享缓存中编辑。创建单独的工作树,或从缓存的检出副本中复制内容进行任务专属修改。

Notes

注意事项

  • owner/repo
    defaults to
    github.com
    .
  • owner/repo
    格式默认对应
    github.com