ghost-repo-context
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRepository Context Builder
仓库上下文构建工具
You gather repository context by detecting projects, summarizing their architecture, and writing the results to . Do all work yourself — do not spawn subagents or delegate.
repo.md你将通过检测项目、总结其架构并将结果写入来收集仓库上下文信息。所有工作需独立完成——不要生成子代理或委托任务。
repo.mdInputs
输入参数
Parse these from (key=value pairs):
$ARGUMENTS- repo_path: path to the repository root
- cache_dir: path to the cache directory (defaults to )
~/.ghost/repos/<repo_id>/cache
$ARGUMENTS
If is not provided, compute it:
cache_dirbash
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_dirbash
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 already exists. If it does, skip everything and return:
<cache_dir>/repo.mdRepository context is at: <cache_dir>/repo.mdIf it does not exist, run and continue.
mkdir -p <cache_dir>检查是否已存在。如果存在,跳过所有步骤并返回:
<cache_dir>/repo.mdRepository context is at: <cache_dir>/repo.md如果不存在,运行并继续。
mkdir -p <cache_dir>Workflow
工作流程
-
Detect Projects — Readand follow its instructions against
<skill_dir>/detector.md. Save the full detection output (project details needed for step 2). If detection finds no projects, write a minimal<repo_path>noting "No projects detected" and skip to step 4.repo.md -
Summarize Each Project — Read. 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.
<skill_dir>/summarizer.md -
Write repo.md — Combine detection and summary results intousing the format in
<cache_dir>/repo.md. For each project include:<skill_dir>/template-repo.md- Detection: ID, Type, Base Path, Languages, Frameworks, Dependency Files, Extensions, Evidence
- Summary: Architectural summary, Sensitive Data Types, Business Criticality, Component Map, Evidence
-
Validate — Readback and verify it contains the expected sections from
<cache_dir>/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.<skill_dir>/template-repo.md -
Output — Return:
Repository context is at: <cache_dir>/repo.md
-
检测项目 — 读取并按照其中的说明对
<skill_dir>/detector.md执行操作。保存完整的检测输出(步骤2需要项目详情)。如果未检测到任何项目,写入一个极简版的<repo_path>,注明“未检测到项目”,然后跳至步骤4。repo.md -
总结每个项目 — 读取。针对步骤1中检测到的每个项目,使用该项目的详情(id、类型、基础路径、语言、框架、依赖文件、扩展名、证据)按照总结工具的说明执行操作。收集每个项目的总结信息。如果某个项目的总结失败,注明“总结不可用”并继续处理剩余项目。
<skill_dir>/summarizer.md -
写入repo.md — 将检测和总结结果合并到中,使用
<cache_dir>/repo.md中的格式。每个项目需包含:<skill_dir>/template-repo.md- 检测信息:ID、类型、基础路径、语言、框架、依赖文件、扩展名、证据
- 总结信息:架构总结、敏感数据类型、业务关键性、组件图谱、证据
-
验证 — 重新读取并验证其包含
<cache_dir>/repo.md中的预期章节(例如,包含检测和总结字段的项目条目)。如果文件缺失或格式错误,重试一次写入操作后再报告错误。<skill_dir>/template-repo.md -
输出 — 返回:
Repository context is at: <cache_dir>/repo.md