Repository Context
发布时间:2026/9/13 9:04:17 作者:尧图编辑部 阅读量:1,286

Repository Context【免费下载链接】ArchonThe first open-source harness builder for AI coding. Make AI coding deterministic and repeatable.项目地址: https://gitcode.com/GitHub_Trending/archon3/ArchonCurrent repo: !gh repo view --json nameWithOwner -q .nameWithOwner 2/dev/null || echo unknownOpen issues: !gh issue list --state open --json number --jq length 2/dev/null || echo ?Existing labels: !gh label list --json name -q .[].name 2/dev/null | head -20 || echo none found这是**技能加载期的预处理**而非工具调用命令的 stdout 会在模型看到提示词之前替换占位符且每条都带 || echo 兜底保证即使 gh 未登录或无网络技能也能带着unknown这类占位值继续运行。效果是 agent 启动时就直接握有真实仓库名、开放 Issue 数量、现有标签体系前 20 个——它拿到的是数据而不是请自己去查的指令。 ## 四、范围解析$ARGUMENTS 的四种取值 技能通过 $ARGUMENTS 接收用户输入并在 Scope 一节定义了确定性的解析规则 | 参数 | 行为 | |------|------| | 空 | 只处理未打标签的 Issue默认 | | unlabeled | 只处理没有任何标签的 Issue | | all | 处理所有开放 Issue | | N | 处理指定单个 Issue如 67 | | N-M | 处理闭区间范围内的 Issue如 60-67 | 这与 frontmatter 中 argument-hint: [unlabeled|all|N|N-M] 的提示完全对应用户在斜杠菜单里就能看到合法用法。 ## 五、四步执行流程从标签体系到摘要输出 SKILL.md 的 Process 一节定义了严格的四步流水线 ### 第 1 步拉取标签体系 bash gh label label list --json name,description注意原文的命令是gh label list --json name,description——先理解标签分类法taxonomy再做任何分类。标签按 type、effort、priority、area 四类组织且规则明确要求Do not hardcode labels — always fetch current labels first, they may change不要硬编码标签——总是先拉取当前标签它们可能变化。第 2 步拉取目标 Issue按 Scope 表确定范围后对每个 Issue 拉取完整正文gh issue view {number} --json number,title,body,labels这里呼应了 Rules 中Check issue body — titles alone arent enough context只看标题不够必须读正文的要求。第 3 步逐个 Issue 分类并打标对每个 Issue仔细阅读标题和完整正文必要时用Glob、Grep、Read探索代码库理解受影响的代码分类一个 type、一个 effort、一个 priority、一个或多个 area追踪与其他 Issue 的关系重复、相关、阻塞应用标签gh issue edit {number} --add-label type,effort/level,P#,area.domain两条幂等性规则保证可重复执行已有完整标签type effort priority area 齐全的 Issue 直接跳过部分打标的 Issue 只补缺失的类别且绝不删除已有标签Respect existing labels。第 4 步输出分诊摘要流程的终点是一份结构化 Markdown 摘要模板在文档中完整给出## Triage Summary | Issue | Title | Labels Applied | Reasoning | |-------|-------|----------------|-----------| | #67 | ... | bug, effort/low, P1, core.config | ... | **Totals:** - Issues triaged: X - Already labeled (skipped): Y - By priority: P0(n), P1(n), P2(n), P3(n) ## Relationships Discovered | Issues | Relationship | Notes | |--------|--------------|-------| | #61, #62 | Related | Both involve config/logging UX |由于context: fork的存在只有这份摘要会流回主会话——取 Issue、读代码、打标签的全部中间过程在主对话中不可见。规则清单Rules文档末尾的五条规则是分类质量的约束条件值得逐条记住不硬编码标签——标签体系随时可能变化尊重已有标签——只增不删必须读 Issue 正文——标题不足以判断善用代码库——判断 Issue 关系需要看清模块如何连接时就去Grep/Read拿不准就在摘要中标注——宁可标记模糊不要猜测。六、纵深解析triage-agent 如何承载怎么做技能回答做什么范围、参数、上下文Agent 回答怎么做人格、工具、护栏。triage-agent.md 的 frontmatter 展示了三层设计--- name: triage-agent description: | Specialized agent for triaging GitHub issues. Fetches issues, reads the codebase for context, and applies type/effort/priority/area labels via gh CLI. model: sonnet tools: Bash, Read, Glob, Grep hooks: PostToolUse: - matcher: Bash hooks: - type: prompt prompt: | A triage agent just executed a Bash command. Here is the tool call context: $ARGUMENTS If this was a gh issue edit --add-label command, verify: 1. Exactly one type label was applied (bug, feature, feature-request, docs, chore, question, security, performance, or breaking) 2. Exactly one effort label (effort/low, effort/medium, or effort/high) 3. Exactly one priority label (P0, P1, P2, or P3) 4. At least one area label If this was NOT a label command (e.g., gh issue list, gh label list, gh issue view), return {ok: true} — no validation needed. Return {ok: true} if valid or not a label command. Return {ok: false, reason: ...} if a label command is missing required categories. statusMessage: Validating label application... ---六.1 标签分类法四类别的完整定义Agent 正文给出了标签体系的权威定义这也是第 3 步分类动作的评分标准Type四选一共 9 个值标签含义bug行为错误、违反原则、静默失败feature已计划的新能力feature-request需要评审的外部建议docs文档chore维护、重构、CIquestion需要澄清security安全问题performance性能问题breaking引入破坏性变更Effort三选一标签判据effort/low单文件或单函数、隔离变更effort/medium少量文件、单一领域、需要一定协调effort/high横切多个领域、需要设计决策Priority四选一P0关键、阻塞最先做、P1高优先尽快处理、P2backlog有空再做、P3锦上添花。Area一个或多个映射到代码库的模块/领域如core.config——这正是第 3 步中允许用Grep/Read探索代码库来看清模块如何连接的价值所在。Agent 正文还强调了一条领域经验Silent failures are bugs — if something fails silently, its broken behavior静默失败即 bug——静默失败就是损坏的行为以及关系检测的四种类型Duplicate同一问题不同表述、Related不同问题共享上下文、Blocking一个必须先修、Supersedes宽泛问题涵盖狭窄问题。六.2 Prompt HookLLM 作为标签完整性的护栏Agent 的 PostToolUse hook 是整个 triage 链路中最有技术含量的一环它把校验从事后人工检查变成了每一次打标动作的内联门禁触发时机每次 agent 执行Bash工具后matcher: Bash校验方式type: prompt把工具调用上下文$ARGUMENTS占位符发送给一个 LLM 做单轮评估LLM 必须返回{ok: true}放行或{ok: false, reason: ...}拦截校验内容若是gh issue edit --add-label命令则验证四个类别齐全——恰好一个 type、恰好一个 effort、恰好一个 priority、至少一个 area智能过滤非标签命令gh issue list、gh label list、gh issue view直接返回{ok: true}避免误报。校验失败时LLM 返回的 reason如 Missing effort label会作为反馈交给 agentagent 在下个 Issue 之前自行修正打标操作。教学指南将其归类为四种 hook handler 中最适合语义校验的一种——因为判断标签类别是否齐全需要理解意图而非简单的模式匹配Hook 类型机制拦截方式command执行 shell 脚本退出码 2http向 URL POST JSONJSON 响应promptLLM 单轮评估默认 Haiku{ok: false}agent派生带 Read/Grep/Glob 的子 agent 验证条件子 agent 判定statusMessage: Validating label application...则让这次 LLM 校验在用户界面上有可见的进度提示验证了 hook 确实处于执行链路中。从源码结构看Agent 侧的tools: Bash, Read, Glob, Grep与技能侧的allowed-tools: Bash(gh *), Read, Glob, Grep形成了双层约束技能层用通配符把 Bash 收窄到gh子命令Agent 层声明工具人格——两层各自独立生效。七、组合模式技能与 Agent 的职责切分part2 工作坊指南 的 Feature 7 一节给出了这张链路图的运行视角User invokes /triage 42 │ ▼ ┌─────────────────────┐ │ SKILL.md │ context: fork agent: triage-agent │ (entry point) │ 注入仓库上下文!command │ │ allowed-tools 限制为 gh CLI 只读 └────────┬────────────┘ │ fork 进隔离上下文 ▼ ┌─────────────────────┐ │ triage-agent.md │ 自定义 agent带 PostToolUse prompt hook │ │ 校验每条 gh issue edit 命令 │ │ model: sonnet └────────┬────────────┘ │ ▼ 摘要返回主会话 中间工具调用全部丢弃教学指南对此模式的核心论断是Skills definewhatto do (scope, context, arguments). Agents definehowto do it (persona, tools, guardrails). Separating them makes both composable — the same agent could be used by multiple skills.技能定义做什么范围、上下文、参数Agent 定义怎么做人格、工具、护栏。分离使两者都可组合——同一个 agent 可被多个技能复用。分诊规则标签分类法、分类判据沉淀在 Agent 中范围逻辑$ARGUMENTS解析、Scope 表沉淀在技能中任一侧演进都不需要改动另一侧。指南还给出了从旧命令到技能 Agent组合的对比表可作为评估自研自动化脚本是否值得升级的参照维度旧命令.claude/commands/.../triage.md新技能 Agent执行方式内联污染主上下文Forked隔离上下文窗口校验无Prompt hook 校验每次打标工具访问全部 Bash 命令仅Bash(gh *)——无任意 shellAgent 人格通用带领域知识的分诊专家上下文成本全部 Issue 数据留在对话中只有摘要返回八、实操要点与适用前提在当前仓库中体验该技能的完整流程参考 part2 指南 的 Feature 7 演示步骤前置条件已配置好的 Claude Code 环境工作坊要求 v2.1.63与已认证的 GitHub CLIgh且当前目录为目标仓库若所有 Issue 均已打标可先创建测试 Issuegh issue create --title chore: clean up unused utility functions in packages/core/src/utils/ --body Several utility functions in the core utils module appear unused after recent refactoring. Should audit and remove dead code to reduce surface area.触发分诊按 Scope 表选择参数/triage # 默认只处理未打标签的 Issue /triage 42 # 处理单个 Issue /triage 60-67 # 处理闭区间 /triage all # 处理所有开放 Issue【免费下载链接】ArchonThe first open-source harness builder for AI coding. Make AI coding deterministic and repeatable.项目地址: https://gitcode.com/GitHub_Trending/archon3/Archon创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考