ghost-repo-context

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Repository Context Builder

仓库上下文构建工具

You gather repository context by detecting projects, summarizing their architecture, and writing the results to
repo.md
. Do all work yourself — do not spawn subagents or delegate.
你将通过检测项目、总结其架构并将结果写入
repo.md
来收集仓库上下文信息。所有工作需独立完成——不要生成子代理或委托任务。

Inputs

输入参数

Parse these from
$ARGUMENTS
(key=value pairs):
  • repo_path: path to the repository root
  • cache_dir: path to the cache directory (defaults to
    ~/.ghost/repos/<repo_id>/cache
    )
$ARGUMENTS
If
cache_dir
is not provided, compute it:
bash
repo_name=$(basename "$(pwd)") && remote_url=$(git remote get-url origin 2>/dev/null || pwd) && short_hash=$(printf '%s' "$remote_url" | git hash-object --stdin | cut -c1-8) && repo_id="${repo_name}-${short_hash}" && cache_dir="$HOME/.ghost/repos/${repo_id}/cache" && echo "cache_dir=$cache_dir"
$ARGUMENTS
(键=值对)中解析以下参数:
  • repo_path:仓库根目录的路径
  • cache_dir:缓存目录的路径(默认值为
    ~/.ghost/repos/<repo_id>/cache
$ARGUMENTS
如果未提供
cache_dir
,则按以下方式计算:
bash
repo_name=$(basename "$(pwd)") && remote_url=$(git remote get-url origin 2>/dev/null || pwd) && short_hash=$(printf '%s' "$remote_url" | git hash-object --stdin | cut -c1-8) && repo_id="${repo_name}-${short_hash}" && cache_dir="$HOME/.ghost/repos/${repo_id}/cache" && echo "cache_dir=$cache_dir"

Tool Restrictions

工具限制

Do NOT use WebFetch or WebSearch. All work must use only local files in the repository.
请勿使用WebFetch或WebSearch工具。所有工作必须仅使用仓库中的本地文件。

Setup

初始化设置

Discover this skill's own directory so you can reference agent files:
bash
skill_dir=$(find . -path '*/skills/repo-context/SKILL.md' 2>/dev/null | head -1 | xargs dirname)
echo "skill_dir=$skill_dir"

找到此技能的自身目录,以便引用代理文件:
bash
skill_dir=$(find . -path '*/skills/repo-context/SKILL.md' 2>/dev/null | head -1 | xargs dirname)
echo "skill_dir=$skill_dir"

Check Cache First

优先检查缓存

Check if
<cache_dir>/repo.md
already exists. If it does, skip everything and return:
Repository context is at: <cache_dir>/repo.md
If it does not exist, run
mkdir -p <cache_dir>
and continue.

检查
<cache_dir>/repo.md
是否已存在。如果存在,跳过所有步骤并返回:
Repository context is at: <cache_dir>/repo.md
如果不存在,运行
mkdir -p <cache_dir>
并继续。

Workflow

工作流程

  1. Detect Projects — Read
    <skill_dir>/detector.md
    and follow its instructions against
    <repo_path>
    . Save the full detection output (project details needed for step 2). If detection finds no projects, write a minimal
    repo.md
    noting "No projects detected" and skip to step 4.
  2. Summarize Each Project — Read
    <skill_dir>/summarizer.md
    . For EACH project detected in step 1, follow the summarizer instructions using that project's details (id, type, base_path, languages, frameworks, dependency_files, extensions, evidence). Collect the summary for each project. If summarization fails for a project, note it as "summary unavailable" and continue with remaining projects.
  3. Write repo.md — Combine detection and summary results into
    <cache_dir>/repo.md
    using the format in
    <skill_dir>/template-repo.md
    . For each project include:
    • Detection: ID, Type, Base Path, Languages, Frameworks, Dependency Files, Extensions, Evidence
    • Summary: Architectural summary, Sensitive Data Types, Business Criticality, Component Map, Evidence
  4. Validate — Read
    <cache_dir>/repo.md
    back and verify it contains the expected sections from
    <skill_dir>/template-repo.md
    (e.g., project entries with Detection and Summary fields). If the file is missing or malformed, retry the write once before reporting an error.
  5. Output — Return:
    Repository context is at: <cache_dir>/repo.md
  1. 检测项目 — 读取
    <skill_dir>/detector.md
    并按照其中的说明对
    <repo_path>
    执行操作。保存完整的检测输出(步骤2需要项目详情)。如果未检测到任何项目,写入一个极简版的
    repo.md
    ,注明“未检测到项目”,然后跳至步骤4。
  2. 总结每个项目 — 读取
    <skill_dir>/summarizer.md
    。针对步骤1中检测到的每个项目,使用该项目的详情(id、类型、基础路径、语言、框架、依赖文件、扩展名、证据)按照总结工具的说明执行操作。收集每个项目的总结信息。如果某个项目的总结失败,注明“总结不可用”并继续处理剩余项目。
  3. 写入repo.md — 将检测和总结结果合并到
    <cache_dir>/repo.md
    中,使用
    <skill_dir>/template-repo.md
    中的格式。每个项目需包含:
    • 检测信息:ID、类型、基础路径、语言、框架、依赖文件、扩展名、证据
    • 总结信息:架构总结、敏感数据类型、业务关键性、组件图谱、证据
  4. 验证 — 重新读取
    <cache_dir>/repo.md
    并验证其包含
    <skill_dir>/template-repo.md
    中的预期章节(例如,包含检测和总结字段的项目条目)。如果文件缺失或格式错误,重试一次写入操作后再报告错误。
  5. 输出 — 返回:
    Repository context is at: <cache_dir>/repo.md