# rbtools - Doramagic AI Context Pack

> 定位：安装前体验与判断资产。它帮助宿主 AI 有一个好的开始，但不代表已经安装、执行或验证目标项目。

## 充分原则

- **充分原则，不是压缩原则**：AI Context Pack 应该充分到让宿主 AI 在开工前理解项目价值、能力边界、使用入口、风险和证据来源；它可以分层组织，但不以最短摘要为目标。
- **压缩策略**：只压缩噪声和重复内容，不压缩会影响判断和开工质量的上下文。

## 给宿主 AI 的使用方式

你正在读取 Doramagic 为 rbtools 编译的 AI Context Pack。请把它当作开工前上下文：帮助用户理解适合谁、能做什么、如何开始、哪些必须安装后验证、风险在哪里。不要声称你已经安装、运行或执行了目标项目。

## Claim 消费规则

- **事实来源**：Repo Evidence + Claim/Evidence Graph；Human Wiki 只提供显著性、术语和叙事结构。
- **事实最低状态**：`supported`
- `supported`：可以作为项目事实使用，但回答中必须引用 claim_id 和证据路径。
- `weak`：只能作为低置信度线索，必须要求用户继续核实。
- `inferred`：只能用于风险提示或待确认问题，不能包装成项目事实。
- `unverified`：不得作为事实使用，应明确说证据不足。
- `contradicted`：必须展示冲突来源，不得替用户强行选择一个版本。

## 它最适合谁

- **想在安装前理解开源项目价值和边界的用户**：当前证据主要来自项目文档。 证据：`README.md` Claim：`clm_0002` supported 0.86

## 它能做什么

- **项目知识预览**（可做安装前预览）：项目可被阅读和解释，但当前证据不足以确认可安装能力或运行入口。 证据：`README.md`, `contrib/P4V/README.md`, `rbtools/__init__.py`, `rbtools/api/__init__.py` 等 Claim：`clm_0001` supported 0.86

## 怎么开始

- 项目证据中没有稳定 Quick Start 命令；此项应留空，而不是由 Doramagic 编造。

## 继续前判断卡

- **当前建议**：先做 Prompt Preview
- **为什么**：当前信息足以做安装前体验，但真实兼容性、输出质量或风险边界还不能直接相信。

### 30 秒判断

- **现在怎么做**：先做 Prompt Preview
- **最小安全下一步**：先跑 Prompt Preview
- **先别相信**：真实输出质量不能在安装前相信。
- **继续会触碰**：宿主 AI 上下文

### 现在可以相信

- **适合人群线索：想在安装前理解开源项目价值和边界的用户**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0002` supported 0.86
- **能力存在：项目知识预览**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`README.md`, `contrib/P4V/README.md`, `rbtools/__init__.py`, `rbtools/api/__init__.py` 等 Claim：`clm_0001` supported 0.86

### 现在还不能相信

- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。
- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。
- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。
- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。
- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。
- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。

### 继续会触碰什么

- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。

### 最小安全下一步

- **先跑 Prompt Preview**：用安装前交互式试用判断工作方式是否匹配，不需要授权或改环境。（适用：任何项目都适用，尤其是输出质量未知时。）
- **安装后只验证一个最小任务**：先验证加载、兼容、输出质量和回滚，再决定是否深用。（适用：准备从试用进入真实工作流时。）

### 退出方式

- **保留安装前状态**：记录原始宿主配置和项目状态，后续才能判断是否可恢复。
- **如果没有回滚路径，不进入主力环境**：不可回滚是继续前阻断项，不应靠信任或运气继续。

## 哪些只能预览

- 解释项目适合谁和能做什么
- 基于项目文档演示典型对话流程
- 帮助用户判断是否值得安装或继续研究

## 哪些必须安装后验证

- 真实安装 Skill、插件或 CLI
- 执行脚本、修改本地文件或访问外部服务
- 验证真实输出质量、性能和兼容性

## 边界与风险判断卡

- **把安装前预览误认为真实运行**：用户可能高估项目已经完成的配置、权限和兼容性验证。 处理方式：明确区分 prompt_preview_can_do 与 runtime_required。 Claim：`clm_0003` inferred 0.45
- **待确认**：真实安装后是否与用户当前宿主 AI 版本兼容？。原因：兼容性只能通过实际宿主环境验证。
- **待确认**：项目输出质量是否满足用户具体任务？。原因：安装前预览只能展示流程和边界，不能替代真实评测。

## 开工前工作上下文

### 加载顺序

- 先读取 how_to_use.host_ai_instruction，建立安装前判断资产的边界。
- 读取 claim_graph_summary，确认事实来自 Claim/Evidence Graph，而不是 Human Wiki 叙事。
- 再读取 intended_users、capabilities 和 quick_start_candidates，判断用户是否匹配。
- 需要执行具体任务时，优先查 role_skill_index，再查 evidence_index。
- 遇到真实安装、文件修改、网络访问、性能或兼容性问题时，转入 risk_card 和 boundaries.runtime_required。

### 任务路由

- **项目知识预览**：先基于 role_skill_index / evidence_index 帮用户挑选可用角色、Skill 或工作流。 边界：可做安装前 Prompt 体验。 证据：`README.md`, `contrib/P4V/README.md`, `rbtools/__init__.py`, `rbtools/api/__init__.py` 等 Claim：`clm_0001` supported 0.86

### 上下文规模

- 文件总数：373
- 重要文件覆盖：40/373
- 证据索引条目：63
- 角色 / Skill 条目：2

### 证据不足时的处理

- **missing_evidence**：说明证据不足，要求用户提供目标文件、README 段落或安装后验证记录；不要补全事实。
- **out_of_scope_request**：说明该任务超出当前 AI Context Pack 证据范围，并建议用户先查看 Human Manual 或真实安装后验证。
- **runtime_request**：给出安装前检查清单和命令来源，但不要替用户执行命令或声称已执行。
- **source_conflict**：同时展示冲突来源，标记为待核实，不要强行选择一个版本。

## Prompt Recipes

### 适配判断

- 目标：判断这个项目是否适合用户当前任务。
- 预期输出：适配结论、关键理由、证据引用、安装前可预览内容、必须安装后验证内容、下一步建议。

```text
请基于 rbtools 的 AI Context Pack，先问我 3 个必要问题，然后判断它是否适合我的任务。回答必须包含：适合谁、能做什么、不能做什么、是否值得安装、证据来自哪里。所有项目事实必须引用 evidence_refs、source_paths 或 claim_id。
```

### 安装前体验

- 目标：让用户在安装前感受核心工作流，同时避免把预览包装成真实能力或营销承诺。
- 预期输出：一段带边界标签的体验剧本、安装后验证清单和谨慎建议；不含真实运行承诺或强营销表述。

```text
请把 rbtools 当作安装前体验资产，而不是已安装工具或真实运行环境。

请严格输出四段：
1. 先问我 3 个必要问题。
2. 给出一段“体验剧本”：用 [安装前可预览]、[必须安装后验证]、[证据不足] 三种标签展示它可能如何引导工作流。
3. 给出安装后验证清单：列出哪些能力只有真实安装、真实宿主加载、真实项目运行后才能确认。
4. 给出谨慎建议：只能说“值得继续研究/试装”“先补充信息后再判断”或“不建议继续”，不得替项目背书。

硬性边界：
- 不要声称已经安装、运行、执行测试、修改文件或产生真实结果。
- 不要写“自动适配”“确保通过”“完美适配”“强烈建议安装”等承诺性表达。
- 如果描述安装后的工作方式，必须使用“如果安装成功且宿主正确加载 Skill，它可能会……”这种条件句。
- 体验剧本只能写成“示例台词/假设流程”：使用“可能会询问/可能会建议/可能会展示”，不要写“已写入、已生成、已通过、正在运行、正在生成”。
- Prompt Preview 不负责给安装命令；如用户准备试装，只能提示先阅读 Quick Start 和 Risk Card，并在隔离环境验证。
- 所有项目事实必须来自 supported claim、evidence_refs 或 source_paths；inferred/unverified 只能作风险或待确认项。

```

### 角色 / Skill 选择

- 目标：从项目里的角色或 Skill 中挑选最匹配的资产。
- 预期输出：候选角色或 Skill 列表，每项包含适用场景、证据路径、风险边界和是否需要安装后验证。

```text
请读取 role_skill_index，根据我的目标任务推荐 3-5 个最相关的角色或 Skill。每个推荐都要说明适用场景、可能输出、风险边界和 evidence_refs。
```

### 风险预检

- 目标：安装或引入前识别环境、权限、规则冲突和质量风险。
- 预期输出：环境、权限、依赖、许可、宿主冲突、质量风险和未知项的检查清单。

```text
请基于 risk_card、boundaries 和 quick_start_candidates，给我一份安装前风险预检清单。不要替我执行命令，只说明我应该检查什么、为什么检查、失败会有什么影响。
```

### 宿主 AI 开工指令

- 目标：把项目上下文转成一次对话开始前的宿主 AI 指令。
- 预期输出：一段边界明确、证据引用明确、适合复制给宿主 AI 的开工前指令。

```text
请基于 rbtools 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。
```

## 角色 / Skill 索引

- 共索引 2 个角色 / Skill / 项目文档条目。

- **Testing RBTools**（project_doc）：RBTools - Command Line Tools for Review Board ============================================= 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`README.md`
- **Readme**（project_doc）：P4V Custom Tools for RBTools ============================ 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`contrib/P4V/README.md`

## 证据索引

- 共索引 63 条证据。

- **Testing RBTools**（documentation）：RBTools - Command Line Tools for Review Board ============================================= 证据：`README.md`
- **Readme**（documentation）：P4V Custom Tools for RBTools ============================ 证据：`contrib/P4V/README.md`
- **Init**（source_file）：VERSION: tuple int, int, int, int, str, int, bool = \ def get version string - str ⋮---- version = f'{major}.{minor}' ⋮---- def get package version - str ⋮---- """Return the version as a Python package version string. Returns: str: The version number as used in a Python package. """ ⋮---- tag = 'a' ⋮---- tag = 'b' ⋮---- def is release - bool version info = VERSION :-1 version = get package version 证据：`rbtools/__init__.py`
- **Init**（source_file）：DiffResource = DiffItemResource DraftDiffResource = DiffItemResource FileDiffResource = FileDiffItemResource ReviewRequestResource = ReviewRequestItemResource all = autodoc excludes = all 证据：`rbtools/api/resource/__init__.py`
- **Archived Review Request**（source_file）：@resource mimetype 'application/vnd.reviewboard.org.archived-review-request' class ArchivedReviewRequestItemResource BaseArchivedObjectItemResource ⋮---- @resource mimetype 'application/vnd.reviewboard.org.archived-review-requests' class ArchivedReviewRequestListResource ⋮---- url = f'{self. links "self" "href" }{review request id}/' 证据：`rbtools/api/resource/archived_review_request.py`
- **Base Review**（source_file）：class BaseReviewItemResource ItemResource ⋮---- body bottom: str body bottom text type: TextType body top: str body top text type: TextType force text type: TextType public: bool publish and archive: bool publish to owner only: bool ship it: bool text type: TextType 证据：`rbtools/api/resource/base_review.py`
- **Base Review Request**（source_file）：class BaseReviewRequestItemResource ItemResource ⋮---- branch: str bugs closed: ResourceListField str commit id: str depends on: ResourceListField ReviewRequestItemResource description: str description text type: TextType extra data: ResourceExtraDataField last updated: str summary: str target groups: ResourceListField target people: ResourceListField ResourceLinkField UserItemResource testing done: str testing done text type: TextType 证据：`rbtools/api/resource/base_review_request.py`
- **Muted Review Request**（source_file）：@resource mimetype 'application/vnd.reviewboard.org.muted-review-request' class MutedReviewRequestItemResource BaseArchivedObjectItemResource ⋮---- @resource mimetype 'application/vnd.reviewboard.org.archived-review-requests' class MutedReviewRequestListResource ⋮---- url = f'{self. links "self" "href" }{review request id}/' 证据：`rbtools/api/resource/muted_review_request.py`
- **Remote Repository**（source_file）：@resource mimetype 'application/vnd.reviewboard.org.remote-repository' class RemoteRepositoryItemResource ItemResource ⋮---- id: str mirror path: str None name: str owner: str path: str scm type: str class RemoteRepositoryGetListParams BaseGetListParams, total=False ⋮---- filter type: str ⋮---- owner type: str ⋮---- @resource mimetype 'application/vnd.reviewboard.org.remote-repositories' class RemoteRepositoryListResource ListResource RemoteRepositoryItemResource ⋮---- httprequest params name map: ClassVar Mapping str, str = { 证据：`rbtools/api/resource/remote_repository.py`
- **Repository**（source_file）：@resource mimetype 'application/vnd.reviewboard.org.repository' class RepositoryItemResource ItemResource ⋮---- bug tracker: str extra data: ResourceExtraDataField id: int mirror path: str name: str path: str requires basedir: bool requires change number: bool supports post commit: bool tool: str visible: bool None ⋮---- class RepositoryGetListParams BaseGetListParams, total=False ⋮---- hosting service: str ⋮---- name or path: str ⋮---- q: str show invisible: bool ⋮---- username: str ⋮---- @resource mimetype 'application/vnd.reviewboard.org.repositories' class RepositoryListResource ListResource RepositoryItemResource ⋮---- httprequest params name map: ClassVar Mapping str, str = { 证据：`rbtools/api/resource/repository.py`
- **Review**（source_file）：@resource mimetype 'application/vnd.reviewboard.org.review' class ReviewItemResource BaseReviewItemResource class AllReviewsGetListParams BaseGetListParams, total=False ⋮---- last updated from: str last updated to: str public: bool repository: str review group: str user: str ⋮---- @resource mimetype 'application/vnd.reviewboard.org.reviews' class ReviewListResource ListResource ReviewItemResource ⋮---- httprequest params name map: ClassVar dict str, str = { 证据：`rbtools/api/resource/review.py`
- **Review Request**（source_file）：@resource mimetype 'application/vnd.reviewboard.org.review-request' class ReviewRequestItemResource BaseReviewRequestItemResource ⋮---- approval failure: str None approved: bool blocks: ResourceListField ReviewRequestItemResource changenum: int None close description: str close description text type: TextType created with history: bool id: int issue dropped count: int issue open count: int issue resolved count: int issue verifying count: int latest diff: ResourceLinkField DiffItemResource None public: bool ship it count: int status: Literal 'discarded', 'pending', 'submitted' time added: str ⋮---- @property def absolute url self - str ⋮---- base url = self. url.split '/api/' 0 ⋮---- @proper… 证据：`rbtools/api/resource/review_request.py`
- **Watched Review Request**（source_file）：@resource mimetype 'application/vnd.reviewboard.org.watched-review-request' class WatchedReviewRequestItemResource ItemResource ⋮---- @resource mimetype 'application/vnd.reviewboard.org.watched-review-requests' class WatchedReviewRequestListResource 证据：`rbtools/api/resource/watched_review_request.py`
- **Init**（source_file）：class Transport ⋮---- def logout self - None ⋮---- def disable cache self - None def has session cookie self - bool 证据：`rbtools/api/transport/__init__.py`
- **Verify that options specific to an SCM Client have not been misused.**（source_file）：logger = logging.getLogger name SCMCLIENTS = None class PatchAuthor ClassMovedMixin, class PatchResult ClassMovedMixin, def load scmclients config, options ⋮---- SCMCLIENTS = {} ⋮---- scmclient = scmclient cls config=config, ⋮---- scmclient ids = ⋮---- repository url = getattr options, 'repository url', None scmclient errors = {} scan result = scan scmclients for path ⋮---- scmclient = scan result.scmclient ⋮---- dep errors = scan result.dependency errors ⋮---- scmclient errors = scan result.scmclient errors candidate scmclient names: list str = ⋮---- Verify that options specific to an SCM Client have not been misused. ⋮---- all = autodoc excludes = 证据：`rbtools/clients/__init__.py`
- **Repository**（source_file）：class RepositoryInfo ⋮---- path: str Sequence str None base path: str None local path: str None ⋮---- def repr self - str def str self - str ⋮---- base path = '/%s' % base path 证据：`rbtools/clients/base/repository.py`
- **Init**（source_file）：logger = logging.getLogger name CommandExit = CommandExit CommandError = CommandError ParseError = ParseError RB MAIN = RB MAIN ⋮---- entry points: EntryPoints None ⋮---- entry points = ⋮---- entry points = None ⋮---- entry points = importlib metadata.entry points ⋮---- autodoc excludes = 证据：`rbtools/commands/__init__.py`
- **Init**（source_file）：all = autodoc excludes = all 证据：`rbtools/commands/base/__init__.py`
- **: The name of the command.**（source_file）：RB MAIN = 'rbt' class LogLevelFilter logging.Filter class SmartHelpFormatter argparse.HelpFormatter ⋮---- lines: list str = ⋮---- class BaseCommand ⋮---- """Base class for RBTools commands. This class will handle retrieving the configuration, and parsing command line options. usage is a list of usage strings each showing a use case. These should not include the main rbt command or the command name; they will be added automatically. Version Changed: 5.0: This moved from :py:mod: rbtools.commands to :py:mod: rbtools.commands.base.commands . """ : The name of the command. : : Type: : str name: ClassVar str = '' : The author of the command. ⋮---- author: ClassVar str = '' : A short description… 证据：`rbtools/commands/base/commands.py`
- **Output**（source_file）：ForceStringFunc: TypeAlias = Callable ..., AnyStr class Newline ⋮---- def bytes self - bytes def str self - str newline = Newline class JSONOutput ⋮---- raw: JSONDict output stream: TextIO ⋮---- items = self.raw key ⋮---- def print to stream self - None class OutputWrapper Generic AnyStr ⋮---- output stream: IO AnyStr None force str: ForceStringFunc ⋮---- def new line self - None 证据：`rbtools/commands/base/output.py`
- **The Review Board server is an old version pre-2.0 that**（source_file）：class Land BaseCommand ⋮---- name = 'land' author = 'The Review Board Project' needs api = True needs scm client = True needs repository = True args = ' ' option list = ⋮---- patch command = RB MAIN, 'patch' ⋮---- result = run process patch command, ignore errors=True ⋮---- """Determine if the review request is land-able. A review request can be landed if it is approved or, if the Review Board server does not keep track of approval, if the review request has a ship-it count. This function returns the error with landing the review request or None if it can be landed. Args: review request rbtools.api.resource.ReviewRequestItemResource : The review request containing the change to land. """ ⋮-… 证据：`rbtools/commands/land.py`
- **If we're updating an existing review request, queue up a patch**（source_file）：T = TypeVar ' T' class SquashedDiff NamedTuple ⋮---- diff: bytes parent diff: bytes base commit id: str base dir: str commit id: str changenum: str None review request extra data: JSONDict class DiffHistoryEntry TypedDict ⋮---- author date: str author email: str author name: str ⋮---- commit message: str committer date: NotRequired str committer email: NotRequired str committer name: NotRequired str ⋮---- parent id: str class DiffHistory NamedTuple ⋮---- entries: Sequence DiffHistoryEntry ⋮---- validation info: Sequence str cumulative diff: bytes ⋮---- class Post BaseCommand ⋮---- name = 'post' author = 'The Review Board Project' description = 'Uploads diffs to create and update review requ… 证据：`rbtools/commands/post.py`
- **Review**（source_file）：class ReviewSubCommand BaseSubCommand ⋮---- needs api = True create review if missing = True def get review draft self - ReviewItemResource ⋮---- options = self.options review request id = options.review request id ⋮---- review request = self.api root.get review request ⋮---- review draft = self.api root.get review draft ⋮---- review draft = None ⋮---- reviews = review request.get reviews review draft = reviews.create ⋮---- class AddCommentSubCommand ReviewSubCommand ⋮---- option list = def add comment self, text type def main self class AddDiffComment AddCommentSubCommand ⋮---- name = 'add-diff-comment' help text = 'Add a comment to a diff as part of a draft review.' option list = AddComme… 证据：`rbtools/commands/review.py`
- **Setup Completion**（source_file）：class SetupCompletion BaseCommand ⋮---- name = 'setup-completion' author = 'The Review Board Project' description = 'Output RBTools auto-completion code for bash or zsh.' args = ' ' ⋮---- shell = os.environ.get 'SHELL' ⋮---- shell = os.path.basename shell shell = shell.lower ⋮---- script = 证据：`rbtools/commands/setup_completion.py`
- **Go through each matching repo and prompt for a selection. If a**（source_file）：class SetupRepo BaseCommand ⋮---- name = 'setup-repo' author = 'The Review Board Project' description = 'Configure an existing repository to point to a Review ' args = '' option list = ⋮---- """Interactively prompt to select a matching repository. The user is prompted to choose a matching repository found on the Review Board server. Args: local tool name str : The local name of the detected tool. server tool names str : A comma-separated list of potentially matching SCMTool names in the Review Board server. repository paths list or str, optional : A list of potential paths to match for the repository. api root rbtools.api.resource.RootResource : The root resource for the Review Board server… 证据：`rbtools/commands/setup_repo.py`
- **Status**（source_file）：class Status BaseCommand ⋮---- name = 'status' author = 'The Review Board Project' description = 'Output a list of your pending review requests.' needs api = True args = ' review-request revision ' option list = TAB SIZE = 3 PADDING = 5 HEX RE = re.compile r'\\x 0-9a-fA-f {2} ' def tabulate self, review requests ⋮---- """Print review request summary and status in a table. Args: review requests list of dict : A list that contains statistics about each review request. """ ⋮---- has branches = False has bookmarks = False table = tt.Texttable get terminal size .columns header = 'Status', 'Review Request' ⋮---- has branches = True ⋮---- has bookmarks = True ⋮---- row = summary = { ⋮---- def get… 证据：`rbtools/commands/status.py`
- **Init**（source_file）：all = autodoc excludes = all 证据：`rbtools/config/__init__.py`
- **Init**（source_file）：all = autodoc excludes = all 证据：`rbtools/diffs/tools/base/__init__.py`
- **Commands**（source_file）：DEFAULT OPTIONS MAP = { STAMP STRING FORMAT = 'Reviewed at %s' class AlreadyStampedError Exception def extract commit message review request ⋮---- info = summary = review request.summary description = review request.description testing done = review request.testing done ⋮---- def build rbtools cmd argv options, options map=DEFAULT OPTIONS MAP ⋮---- argv = ⋮---- option value = getattr options, option key, None ⋮---- def stamp commit with review url revisions, review request url, tool ⋮---- commit message = tool.get raw commit message revisions stamp string = STAMP STRING FORMAT % review request url ⋮---- new message = commit message.rstrip + '\n\n' + stamp string 证据：`rbtools/utils/commands.py`
- **Filesystem**（source_file）：logger = logging.getLogger name iter exes in path cache: dict str, bool = {} tempfiles: list str = tempdirs = ⋮---- names: list str = ⋮---- cache = iter exes in path cache ⋮---- path = os.path.join dirname, name ⋮---- found = cache path ⋮---- found = os.path.exists path ⋮---- def cleanup tempfiles - None ⋮---- tmpdir = make tempdir tmpfile = os.path.join tmpdir, filename ⋮---- tmpfile = fp.name ⋮---- """Create a temporary directory and return the path. By default, the path will be stored in a list for cleanup when calling :py:func: cleanup tempfiles . Version Changed: 3.0: Added track . Args: parent str, optional : An optional parent directory to create the path in. track bool, optional : W… 证据：`rbtools/utils/filesystem.py`
- **Repository**（source_file）：query: RepositoryGetListParams = { ⋮---- server tool names = tool.get server tool names capabilities ⋮---- repository paths = repository paths ⋮---- repositories = api root.get repositories query ⋮---- repository = repositories 0 ⋮---- all repositories = api root.get repositories query ⋮---- all repositories = repositories ⋮---- repository = get repository resource 证据：`rbtools/utils/repository.py`
- **Compute a score based on a diff of the text fields. The score**（source_file）：logger = logging.getLogger name def get draft or current value field name, review request ⋮---- fields = review request.draft 0 ⋮---- fields = review request ⋮---- def get revisions tool, cmd args ⋮---- revisions = tool.parse revision spec cmd args ⋮---- revisions = None ⋮---- only fields = ⋮---- get kwargs = {} ⋮---- only fields = 'id,commit id,changenum,status,url,absolute url' change id = revisions 'tip' ⋮---- change id = change id.split ':', 1 1 optional args = {} ⋮---- user = get user api client, api root, auth required=True ⋮---- review requests = api root.get review requests repository=repository id, ⋮---- count = review requests.total results ⋮---- review request = review requests 0… 证据：`rbtools/utils/review_request.py`
- **Source Tree**（source_file）：logger = logging.getLogger name ⋮---- @dataclass class SCMClientScanCandidate ⋮---- scmclient: BaseSCMClient local path: str None = None ⋮---- @dataclass class SCMClientScanResult ⋮---- scmclient: BaseSCMClient None local path: str None repository info: RepositoryInfo None candidates: SCMClientScanCandidateList dependency errors: SCMClientScanDependencyErrors scmclient errors: SCMClientScanErrors ⋮---- @property def found self - bool ⋮---- scmclient id = scmclient cls.scmclient id ⋮---- scmclient = cache scmclient id ⋮---- scmclient = None ⋮---- scmclient = scmclient cls scmclient kwargs ⋮---- scmclient cache: SCMClientCache = {} candidates: SCMClientScanCandidateList = errors: SCMClientSca… 证据：`rbtools/utils/source_tree.py`
- **Init**（source_file）：TestSCMClientType co = TypeVar ' TestSCMClientType co', TestSCMClientOptions: TypeAlias = dict str, Any class SCMClientTestCase Generic TestSCMClientType co , ⋮---- DEFAULT SCMCLIENT OPTIONS: Final TestSCMClientOptions = { scmclient cls: type TestSCMClientType co None = None default scmclient options: TestSCMClientOptions = {} default scmclient caps: dict str, Any = {} checkout dir: str None = None ⋮---- @classmethod def setUpClass cls ⋮---- @classmethod def tearDownClass cls ⋮---- def setUp self ⋮---- cmd options = self.options ⋮---- client = self.scmclient cls options=cmd options, client kwargs ⋮---- format patterns: Mapping bytes, bytes = { date re = re.compile new date = ⋮---- diff = di… 证据：`rbtools/clients/tests/__init__.py`
- **Test Base Output**（source_file）：class JSONOutputTests TestCase ⋮---- def test add self - None ⋮---- output = JSONOutput io.StringIO ⋮---- def test append self - None def test append with invalid key self - None def test append with non list self - None ⋮---- message = ⋮---- def test add error self - None def test add warning self - None def test print to stream self - None ⋮---- buf = io.StringIO output = JSONOutput buf ⋮---- value = buf.getvalue ⋮---- class OutputWrapperTests TestCase ⋮---- def test bytes write self - None ⋮---- buf = io.BytesIO output = OutputWrapper bytes buf ⋮---- result = buf.getvalue ⋮---- def test bytes write with end self - None def test bytes write with end empty self - None ⋮---- """Testing Outp… 证据：`rbtools/commands/tests/test_base_output.py`
- **Test Post**（source_file）：class BasePostCommandTests CommandTestsMixin Post , TestCase ⋮---- command cls = Post def create post command self, fields=None, args=None, kwargs ⋮---- command = self.create command args=args, kwargs ⋮---- class PostCommandTests BasePostCommandTests ⋮---- def test post one extra fields self ⋮---- post = self.create command args= '--field', 'foo=bar' ⋮---- def test post multiple extra fields self ⋮---- post = self.create command args= ⋮---- def test native fields through extra fields self def test wrong argument entry self ⋮---- post = self.create command args= '--field', 'description' message = ⋮---- def test multiple delimiter self def test arg field set again by custom fields self def te… 证据：`rbtools/commands/tests/test_post.py`
- **Test Setup Completion**（source_file）：class SetupCompletionTest CommandTestsMixin SetupCompletion , TestCase ⋮---- command cls = SetupCompletion def test with bash self - None ⋮---- result = self.run command args= 'bash' ⋮---- def test with zsh self - None ⋮---- result = self.run command args= 'zsh' ⋮---- result = self.run command ⋮---- def test with json self - None ⋮---- result = self.run command args= '--json', 'zsh' ⋮---- json data = result 'json' ⋮---- def test with shell unknown self - None 证据：`rbtools/commands/tests/test_setup_completion.py`
- **Test Setup Repo**（source_file）：class SetupRepoTest CommandTestsMixin, TestCase ⋮---- command cls = SetupRepo def test prompt rb repository repos found self ⋮---- def setup transport transport setup = self.create command setup transport func=setup transport api root = setup.get api self.DEFAULT SERVER URL 1 ⋮---- output = setup.prompt rb repository ⋮---- def test prompt rb repository no repos found self ⋮---- setup = self.create command ⋮---- def test generate config file self ⋮---- test path = os.path.join os.getcwd , '.reviewboardrc' ⋮---- def test generate config file contents self ⋮---- config lines = fp.readlines ⋮---- def test server options self ⋮---- setup = self.create command options = setup.options ⋮---- def te… 证据：`rbtools/commands/tests/test_setup_repo.py`
- **Init**（source_file）：all = autodoc excludes = all 证据：`rbtools/testing/__init__.py`
- **Payloads**（source_file）：class LinkExpansionType object ⋮---- LIST = 1 ITEM = 2 class ResourcePayloadFactory object ⋮---- DEFAULT CAPABILITIES = { ITEM LINK NAME MAP = { LIST LINK NAME MAP = { def init self, server url ⋮---- expanded payload = ⋮---- expanded payload = expanded payload ⋮---- def make mimetype self, name, payload format='json' def make item response payload self, object payload, item key=None ⋮---- payload = { ⋮---- def make list response payload self, url, list key, items ⋮---- server url = self.server url url = self. make api url '' links = self. make item links ⋮---- def make api info object data self, root payload ⋮---- """Return new repository resource data. Args: repository id int, optional : T… 证据：`rbtools/testing/api/payloads.py`
- **Transport**（source_file）：logger = logging.getLogger name class URLMapTransport Transport ⋮---- payload factory = ResourcePayloadFactory self.url ⋮---- @property def capabilities self - dict str, Any ⋮---- url = self. normalize api url url node = dict { ⋮---- response payload = self.payload factory.make item response payload url info = self.add url ⋮---- def add list url self, url, list key, item mimetype, headers={}, kwargs ⋮---- def add root url self, kwargs - dict str, Any ⋮---- root object data = self.payload factory.make root object data kwargs root info = self.add item url root object data root payload = root info 'node' 'payload' ⋮---- payload factory = self.payload factory obj data = payload factory.make rep… 证据：`rbtools/testing/api/transport.py`
- **Commands**（source_file）：CommandT = TypeVar ' CommandT', bound=BaseCommand class RunCommandResult TypedDict, Generic CommandT ⋮---- command: CommandT exit code: int str None json: dict str, Any stderr: bytes stdout: bytes class CommandTestsMixin kgb.SpyAgency, Generic CommandT ⋮---- command cls: type CommandT None = None needs temp home = True DEFAULT SERVER URL = 'https://reviews.example.com/' ⋮---- args = command = self. create command common args=args, kwargs argv = self. build command argv args=args, parser = command.create arg parser argv ⋮---- stdout = io.BytesIO stderr = io.BytesIO command = self. create command common stdout=stdout, ⋮---- exit code = 0 ⋮---- exit code = e.code ⋮---- command kwargs = { comma… 证据：`rbtools/testing/commands.py`
- **Transport**（source_file）：class TestTransport Transport ⋮---- cache enabled: bool ⋮---- def execute request method self, method, args, kwargs ⋮---- request = method args, kwargs ⋮---- def get root self ⋮---- def disable cache self - None 证据：`rbtools/testing/transport.py`
- **Test Filesystem**（source_file）：class FilesystemTests TestCase ⋮---- def test make tempfile self ⋮---- filename = make tempfile ⋮---- def test make tempfile with prefix self ⋮---- filename = make tempfile prefix='supertest-' ⋮---- def test make tempfile with suffix self ⋮---- filename = make tempfile suffix='.xyz' ⋮---- def test make tempfile with filename self ⋮---- filename = make tempfile filename='TEST123' ⋮---- parent dir = os.path.dirname filename ⋮---- def test make empty files self ⋮---- tmpdir = make tempdir ⋮---- fname = os.path.join tmpdir, 'file' 证据：`rbtools/utils/tests/test_filesystem.py`
- **Test Repository**（source_file）：REPO1 = { REPO2 = { REPO3 = { MATCH URL BASE = class RepositoryMatchTests kgb.SpyAgency, TestCase ⋮---- payloads = { def setUp self ⋮---- @self.spy for urlopen def urlopen url, kwargs ⋮---- url = url.get full url ⋮---- payload = self.payloads url ⋮---- def test find matching server repository with path match self def test find matching server repository with mirror path match self def test find matching server repository with multiple matches self def test find matching server repository no match self 证据：`rbtools/utils/tests/test_repository.py`
- **Test Review Request**（source_file）：class FindReviewRequestMatchesTests TestCase ⋮---- def test with empty self def test without options self def test with commit id match self def test with commit id match with draft self def test with commit id no match self def test with scmclient match bool self ⋮---- class MySCMClient BaseSCMClient ⋮---- def test with scmclient match none self def test with scmclient match bool and draft self def test with summary match self def test with summary match and draft self def test with description match self def test with description match and draft self def test with summary description fuzzy match self def test with summary description fuzzy match and draft self def test with summary descri… 证据：`rbtools/utils/tests/test_review_request.py`
- **Check the candidates.**（source_file）：class ScanSCMClientsForPathTests kgb.SpyAgency, TestCase ⋮---- def test with single match self ⋮---- tempdir = make tempdir git dir = os.path.realpath os.path.join tempdir, 'my-repo.git' ⋮---- scan result = scan scmclients for path ⋮---- repository info = scan result.repository info ⋮---- Check the candidates. ⋮---- candidate = scan result.candidates 0 ⋮---- def test with no match self ⋮---- """Testing scan scmclients for path with single match""" ⋮---- def test with nested repos self ⋮---- hg dir = os.path.realpath os.path.join tempdir, 'hg-repo' git dir = os.path.join hg dir, 'git-repo' ⋮---- candidate = scan result.candidates 1 ⋮---- def test with nested repos and scmclient ids match sel… 证据：`rbtools/utils/tests/test_source_tree.py`
- **git-ls-files --others --exclude-from=.git/info/exclude**（source_file）：git-ls-files --others --exclude-from=.git/info/exclude Lines that start with ' ' are comments. For a project mostly in C, the following would be a good set of exclude patterns uncomment them if you want to use them : 证据：`.gitignore`
- **.mailmap**（source_file）：Beth Rennie Beth Rennie Beth Rennie 证据：`.mailmap`
- **.reviewboardrc**（source_file）：REVIEWBOARD URL = 'https://reviews.reviewboard.org' REPOSITORY = 'RBTools' REPOSITORY TYPE = 'git' BRANCH = 'master' TRACKING BRANCH = 'origin/%s' % BRANCH LAND DEST BRANCH = BRANCH 证据：`.reviewboardrc`
- **.Travis**（source_file）：language: python sudo: required python: - 2.6 - 2.7 env: - SVN=1.6 - SVN=1.7 - SVN=1.8 before install: - pip install --upgrade pip - if "$SVN" = "1.7" ; then sudo add-apt-repository -y ppa:svn/ppa; sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key A2F4C039; fi - if "$SVN" = "1.8" ; then sudo add-apt-repository -y ppa:dominik-stadler/subversion-1.8; sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 29E526FC; fi - sudo apt-get update -qq - sudo apt-get install libapr1 libaprutil1 libapr1-dev libaprutil1-dev libsvn-dev subversion install: - python setup.py develop - pip install -r dev-requirements.txt script: - nosetests -v notifications: slack: on success: :change on fai… 证据：`.travis.yml`
- **Authors**（source_file）：Christian Hammond David Trowbridge Steven MacLeod 证据：`AUTHORS`
- **Copying**（source_file）：Copyright c 2007-2010 Christian Hammond Copyright c 2007-2010 David Trowbridge 证据：`COPYING`
- **Install**（source_file）：To install rbtools, simply run the following as root: 证据：`INSTALL`
- **Manifest**（source_file）：graft contrib graft docs graft rbtools 证据：`MANIFEST.in`
- **Makefile**（source_file）：develop: pip install --no-build-isolation -e . pip install --no-build-isolation -r dev-requirements.txt 证据：`Makefile`
- **News**（source_file）：Release notes for RBTools can be found in the reviewboard tree under docs/releasenotes/rbtools/. 证据：`NEWS`
- **Dev Requirements**（source_file）：kgb~=7.3.0 mercurial pytest pytest-env 证据：`dev-requirements.txt`
- **Doc Requirements**（source_file）：beanbag-docutils~=2.0 Sphinx~=7.4 sphinx-tabs~=3.4.7 证据：`doc-requirements.txt`
- **importlib.metadata compatibility import.**（source_file）：build-system requires = 'setuptools =74' build-backend = 'setuptools.build meta' 证据：`pyproject.toml`
- 其余 3 条证据见 `AI_CONTEXT_PACK.json` 或 `EVIDENCE_INDEX.json`。

## 宿主 AI 必须遵守的规则

- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`README.md`, `contrib/P4V/README.md`, `rbtools/__init__.py`
- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`README.md`, `contrib/P4V/README.md`, `rbtools/__init__.py`

## 用户开工前应该回答的问题

- 你准备在哪个宿主 AI 或本地环境中使用它？
- 你只是想先体验工作流，还是准备真实安装？
- 你最在意的是安装成本、输出质量、还是和现有规则的冲突？

## 验收标准

- 所有能力声明都能回指到 evidence_refs 中的文件路径。
- AI_CONTEXT_PACK.md 没有把预览包装成真实运行。
- 用户能在 3 分钟内看懂适合谁、能做什么、如何开始和风险边界。

---

## Doramagic Context Augmentation

下面内容用于强化 Repomix/AI Context Pack 主体。Human Manual 只提供阅读骨架；踩坑日志会被转成宿主 AI 必须遵守的工作约束。

## Human Manual 骨架

使用规则：这里只是项目阅读路线和显著性信号，不是事实权威。具体事实仍必须回到 repo evidence / Claim Graph。

宿主 AI 硬性规则：
- 不得把页标题、章节顺序、摘要或 importance 当作项目事实证据。
- 解释 Human Manual 骨架时，必须明确说它只是阅读路线/显著性信号。
- 能力、安装、兼容性、运行状态和风险判断必须引用 repo evidence、source path 或 Claim Graph。

- **项目概述与安装**：importance `high`
  - source_paths: README.md, INSTALL, pyproject.toml, setup.cfg, MANIFEST.in
- **命令行工具 rbt 与子命令**：importance `high`
  - source_paths: rbtools/commands/main.py, rbtools/commands/post.py, rbtools/commands/diff.py, rbtools/commands/land.py, rbtools/commands/patch.py
- **SCM 客户端架构与支持矩阵**：importance `high`
  - source_paths: rbtools/clients/base/scmclient.py, rbtools/clients/base/registry.py, rbtools/clients/base/repository.py, rbtools/clients/git.py, rbtools/clients/mercurial.py
- **Python API、配置系统与扩展机制**：importance `high`
  - source_paths: rbtools/api/client.py, rbtools/api/transport/sync.py, rbtools/api/request.py, rbtools/api/cache.py, rbtools/api/capabilities.py

## Repo Inspection Evidence / 源码检查证据

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `b2fbc9e40945491a7d093d1b81009f48b772db78`
- inspected_files: `pyproject.toml`, `README.md`, `docs/rbtools/redirects.json`, `docs/rbtools/conf.py`, `docs/releasenotes/conf.py`, `docs/rbtools/_ext/rbt_commands.py`, `docs/rbtools/_ext/__init__.py`, `docs/releasenotes/_ext/extralinks.py`

宿主 AI 硬性规则：
- 没有 repo_clone_verified=true 时，不得声称已经读过源码。
- 没有 repo_inspection_verified=true 时，不得把 README/docs/package 文件判断写成事实。
- 没有 quick_start_verified=true 时，不得声称 Quick Start 已跑通。

## Doramagic Pitfall Constraints / 踩坑约束

这些规则来自 Doramagic 发现、验证或编译过程中的项目专属坑点。宿主 AI 必须把它们当作工作约束，而不是普通说明文字。

### Constraint 1: 能力判断依赖假设

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: 将假设转成下游验证清单。
- Why it matters: 假设不成立时，用户拿不到承诺的能力。
- Evidence: capability.assumptions | github_repo:285969 | https://github.com/reviewboard/rbtools | README/documentation is current enough for a first validation pass.
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 2: 维护活跃度未知

- Trigger: 未记录 last_activity_observed。
- Host AI rule: 补 GitHub 最近 commit、release、issue/PR 响应信号。
- Why it matters: 新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- Evidence: evidence.maintainer_signals | github_repo:285969 | https://github.com/reviewboard/rbtools | last_activity_observed missing
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

- Trigger: no_demo
- Evidence: downstream_validation.risk_items | github_repo:285969 | https://github.com/reviewboard/rbtools | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 4: 存在评分风险

- Trigger: no_demo
- Why it matters: 风险会影响是否适合普通用户安装。
- Evidence: risks.scoring_risks | github_repo:285969 | https://github.com/reviewboard/rbtools | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 5: issue/PR 响应质量未知

- Trigger: issue_or_pr_quality=unknown。
- Host AI rule: 抽样最近 issue/PR，判断是否长期无人处理。
- Why it matters: 用户无法判断遇到问题后是否有人维护。
- Evidence: evidence.maintainer_signals | github_repo:285969 | https://github.com/reviewboard/rbtools | issue_or_pr_quality=unknown
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 6: 发布节奏不明确

- Trigger: release_recency=unknown。
- Host AI rule: 确认最近 release/tag 和 README 安装命令是否一致。
- Why it matters: 安装命令和文档可能落后于代码，用户踩坑概率升高。
- Evidence: evidence.maintainer_signals | github_repo:285969 | https://github.com/reviewboard/rbtools | release_recency=unknown
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。
