generate-connectivity-knowledge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGenerate Connectivity Knowledge
生成连接知识
This skill produces the connectivity knowledge a Mule HTTP-Connector flow needs in order to integrate with a SaaS that has no dedicated Mule connector in Exchange. It walks three stages — research the API, generate an OpenAPI 3.0 spec, validate every operation against the live service — and writes a self-contained folder at containing , , and a placeholder .
connectivity-schema/<apiName>/api-reference.md<apiName>.yamlconfig.propertiesbuild-mule-integrationget_latest_connector.sh此 skill 生成 Mule HTTP-Connector flow 集成 Exchange 中没有专用 Mule connector 的 SaaS 所需的连接知识。它依次执行三个阶段——研究 API、生成 OpenAPI 3.0 规范、针对实时服务验证每个操作——并写入一个自包含文件夹 ,其中包含 、 和占位文件 。
connectivity-schema/<apiName>/api-reference.md<apiName>.yamlconfig.properties当 未找到适合某个系统的 connector 时, 会在其 Step 3a(HTTP-fallback 分支)中调用此 skill。随后,flow 生成器读取生成的知识,使用正确的认证、分页和实体结构连接 HTTP Request 操作。
get_latest_connector.shbuild-mule-integrationWho consumes the output
谁会使用输出
- Phase 2 — uses
build-mule-integration's Authentication, Rate Limits, Use Cases, and Entity Reference sections to generate HTTP Request configs and DataWeave transforms.api-reference.md - The user, post-merge — is a real OpenAPI 3.0 spec they can publish to Exchange or feed into other tooling.
<apiName>.yaml
Every artifact this skill produces should serve at least one of those consumers. If a piece of information helps neither construct a request, validate a response, wire a dependency, nor collect credentials, it does not belong here.
- Phase 2——使用
build-mule-integration中的 Authentication、Rate Limits、Use Cases 和 Entity Reference 部分生成 HTTP Request 配置与 DataWeave 转换。api-reference.md - 合并后的用户——是一份真实的 OpenAPI 3.0 规范,可发布到 Exchange 或供其他工具使用。
<apiName>.yaml
此 skill 生成的每项产物都应至少服务于上述一个使用方。如果某项信息既不能帮助构造请求、验证响应、连接依赖,也不能帮助收集凭据,就不应将其保留在这里。
Autonomy principle
自主执行原则
The research and spec-generation stages run autonomously — no user prompts. The live-validation stage runs autonomously except for four mandatory pause points:
- Credential collection — when does not exist or lacks required keys, the skill creates it with placeholders, asks the user to fill it in, and waits. Mandatory — do NOT skip validation, write a placeholder report, or proceed without credentials.
config.properties - Entity IDs — when an operation requires references to existing entities, the skill asks the user to provide them.
- Destructive operation confirmation — before executing DELETE or destructive PUT, the skill warns the user about consequences and asks for confirmation.
- Unresolvable failures — after the validation loop completes, if any operations failed, the skill asks the user how to proceed (retry / keep / remove / cancel).
Auth failures (401/403) halt the loop immediately and present a halt report; that is not an interactive pause, the loop simply stops.
Everything else — operation selection, request construction, execution, schema comparison, error handling, retries — happens silently. The user sees a compact progress line and the final result.
研究和规范生成阶段自主执行,不需要用户提示。实时验证阶段也会自主执行,但有四个必须暂停的节点:
- 收集凭据——当 不存在或缺少必需键时,skill 会创建带占位值的文件,要求用户填写并等待。必须执行——不要跳过验证、编写占位报告,也不要在未获得凭据的情况下继续。
config.properties - 实体 ID——当某个操作要求引用现有实体时,skill 会要求用户提供相应 ID。
- 破坏性操作确认——执行 DELETE 或破坏性 PUT 前,skill 会警告用户操作后果并请求确认。
- 无法解决的故障——验证循环完成后,如果仍有操作失败,skill 会询问用户如何继续(重试/保留/移除/取消)。
认证失败(401/403)会立即终止循环并显示终止报告;这不是交互式暂停,而是直接停止循环。
其他所有事项——操作选择、请求构造、执行、schema 比较、错误处理和重试——都会静默完成。用户只会看到一条精简的进度信息和最终结果。
Credential Security — MANDATORY
凭据安全——强制要求
These rules apply throughout the entire workflow. Violating them is a critical failure.
- NEVER read, display, echo, log, or reason about credential values from .
config.properties - To verify a credential key exists, use — this returns a count (0 or 1), not the value.
grep -c '^KEY_NAME=' config.properties - To inject credentials into commands, use inline shell substitution:
curl. The value flows through the shell but never enters conversation context.$(grep '^KEY_NAME=' config.properties | cut -d'=' -f2-) - If a curl command's output accidentally contains credentials (e.g., in error messages), do NOT repeat that output. Summarize the result without the sensitive content.
以下规则适用于整个工作流。违反这些规则属于严重故障。
- 绝不读取、显示、回显、记录或推断 中的凭据值。
config.properties - 要确认凭据键是否存在,请使用 。它只返回数量(0 或 1),不会返回值。
grep -c '^KEY_NAME=' config.properties - 要将凭据注入 命令,请使用内联 shell 替换:
curl。值会流经 shell,但不会进入对话上下文。$(grep '^KEY_NAME=' config.properties | cut -d'=' -f2-) - 如果 curl 命令的输出意外包含凭据(例如出现在错误消息中),不要重复该输出。请在不包含敏感内容的情况下概括结果。
Workflow
工作流
INPUTS → DOC_DISCOVERY → PRIMARY_ENDPOINTS → PRIMARY_ENTITIES → CRUD_COMPLETION
→ DEPENDENCY_ANALYSIS → SECONDARY_CRUD → ACTION_PLAN → DEEP_RESEARCH
→ API_REFERENCE_CONSOLIDATION → OPENAPI_SPEC_GENERATION
→ VALIDATION_PREREQUISITES → VALIDATION_LOOP → FINAL_REPORTExecute the steps below in order. Do not skip ahead — every step depends on the output of the previous one.
INPUTS → DOC_DISCOVERY → PRIMARY_ENDPOINTS → PRIMARY_ENTITIES → CRUD_COMPLETION
→ DEPENDENCY_ANALYSIS → SECONDARY_CRUD → ACTION_PLAN → DEEP_RESEARCH
→ API_REFERENCE_CONSOLIDATION → OPENAPI_SPEC_GENERATION
→ VALIDATION_PREREQUISITES → VALIDATION_LOOP → FINAL_REPORT按顺序执行以下步骤。不要跳步——每个步骤都依赖上一步的输出。
Step 1: Inputs
Step 1:输入
Parse the following from or ask the user if missing:
$ARGUMENTS- — the SaaS platform / API name in kebab-case (e.g.,
apiName,canva-lms,jira). This becomes the subfolder undercodaand the OpenAPI filename.connectivity-schema/ - — one or more concrete operations the integration needs. Examples:
useCases- "Get the newest courses and notify on new ones"
- "Retrieve a Jira ticket and update its status"
- (optional) — directory where output files are written. Defaults to
Project Folder. Resolve<workspaceRoot>/connectivity-schema/<apiName>/to the active VS Code workspace, or to the current working directory if no workspace is open.<workspaceRoot> - (optional) — one or more URLs pointing to the API documentation. When provided (e.g., from a calling skill), these are used directly in Step 2 instead of searching.
documentation
Verify items 1–2 are present. If either is missing, ask the user. Do not proceed without them.
Throughout the rest of this skill, refers to the resolved Project Folder. Create it if it does not yet exist.
{PROJECT_FOLDER}从 解析以下内容;如有缺失则询问用户:
$ARGUMENTS- ——SaaS 平台/API 名称,采用 kebab-case 格式(例如
apiName、canva-lms、jira)。它将用作coda下的子文件夹名称以及 OpenAPI 文件名。connectivity-schema/ - ——集成所需的一项或多项具体操作。例如:
useCases- “获取最新课程并在新课程出现时通知”
- “检索 Jira 工单并更新其状态”
- Project Folder(可选)——写入输出文件的目录。默认为 。将
<workspaceRoot>/connectivity-schema/<apiName>/解析为当前 VS Code workspace;如果没有打开的 workspace,则使用当前工作目录。<workspaceRoot> - documentation(可选)——一个或多个指向 API 文档的 URL。提供后(例如由调用方 skill 提供),Step 2 将直接使用这些 URL,而不是进行搜索。
确认第 1~2 项存在。如果缺少任意一项,则询问用户。没有这两项时不要继续。
在此 skill 的后续步骤中, 指解析后的 Project Folder。如果该目录尚不存在,则创建它。
{PROJECT_FOLDER}Step 2: Documentation Discovery
Step 2:文档发现
Find the API documentation the agent will read during research.
If documentation URLs were provided in Step 1: WebFetch each URL to confirm it is accessible and contains endpoint documentation. If all provided URLs are valid, use them as your documentation sources and skip to the selection step (4 below). Only fall through to WebSearch if the provided URLs are inaccessible or lack endpoint documentation.
- WebSearch for the API's official documentation. Search for:
- Official REST API reference (e.g., )
"{apiName} REST API reference" - OpenAPI / Swagger specification (e.g., )
"{apiName} OpenAPI spec" - Developer portal or API explorer
- Official REST API reference (e.g.,
- Prioritize machine-readable sources — OpenAPI specs and structured REST references are more useful than blog posts or tutorials because they contain exact field types, required/optional markers, and schema definitions that downstream agents need.
- Select the most authoritative sources and document your selections with reasoning. Typically you need two sources: the human-readable API reference (for context and examples) and a machine-readable spec (for exact schemas).
- WebFetch the selected documentation pages to confirm they are accessible and contain endpoint documentation. If a source is broken or unhelpful, find an alternative.
Do not proceed until you have at least one confirmed, accessible documentation source.
Read → "Step 2: Documentation Discovery" for a worked example.
references/examples.md找到 Agent 在研究期间将读取的 API 文档。
**如果 Step 1 中提供了 documentation URL:**使用 WebFetch 访问每个 URL,确认其可访问且包含端点文档。如果所有提供的 URL 均有效,则将其作为文档源并跳到选择步骤(下面的第 4 步)。仅当提供的 URL 无法访问或缺少端点文档时,才回退到 WebSearch。
- 使用 WebSearch 查找 API 的官方文档。搜索:
- 官方 REST API 参考文档(例如 )
"{apiName} REST API reference" - OpenAPI/Swagger 规范(例如 )
"{apiName} OpenAPI spec" - 开发者门户或 API Explorer
- 官方 REST API 参考文档(例如
- 优先选择机器可读来源——OpenAPI 规范和结构化 REST 参考文档比博客文章或教程更有用,因为它们包含准确的字段类型、必需/可选标记以及下游 Agent 所需的 schema 定义。
- 选择最权威的来源并记录选择理由。通常需要两个来源:便于阅读的 API 参考文档(用于上下文和示例)以及机器可读规范(用于准确的 schema)。
- 使用 WebFetch 访问选定的文档页面,确认其可访问且包含端点文档。如果来源损坏或没有帮助,则寻找替代来源。
在至少确认一个可访问的文档源之前,不要继续。
阅读 → “Step 2: Documentation Discovery”,查看完整示例。
references/examples.mdStep 3: Primary Endpoint Identification
Step 3:主要端点识别
Map each use case to specific API endpoints. These are the endpoints the user explicitly asked for.
CRITICAL — Use-Case Filtering. This skill produces a MINIMAL spec that covers the user's use cases plus ONE connectivity-test endpoint (added in Step 11). Do NOT include every endpoint the API offers. The goal is the smallest faithful spec, not a comprehensive catalog.
For each use case, read the confirmed API documentation and identify:
| Column | What to capture | Why (downstream consumer) |
|---|---|---|
| Use Case Action | What the endpoint does | Context for spec generation |
| Method | HTTP method (GET, POST, PUT, DELETE) | Spec generation builds OpenAPI operations |
| Path | Exact path with parameter placeholders | Spec generation + validation construct URLs |
| Path Parameters | Parameter names and types | Spec generation needs types for OpenAPI path items |
| Has Body | Whether the endpoint accepts a request body | Validation needs to know if it should send a body |
| Content Type | Usually | Spec generation populates content type |
Build a mapping table with exactly these columns:
| Use Case Action | Method | Path | Path Parameters | Has Body | Content Type |
|---|---|---|---|---|---|
| ... | GET | /resource/{id} | id (string) | No | application/json |If a use case maps to multiple endpoints (e.g., updating a Jira ticket status requires the Transitions API, not a simple PUT), include all of them and note the deviation.
If a use case cannot be mapped to an endpoint, flag it and explain why.
Do not proceed until every use case is mapped to at least one endpoint.
Read → "Step 3: Primary Endpoint Identification" for a worked example.
references/examples.md将每个用例映射到具体 API 端点。这些是用户明确要求的端点。
**关键——用例筛选。**此 skill 生成的是覆盖用户用例及一个连通性测试端点(在 Step 11 中添加)的最小规范。不要包含 API 提供的所有端点。目标是生成最小且忠实于需求的规范,而不是完整目录。
对于每个用例,读取已确认的 API 文档并识别:
| 用例操作 | 方法 | 路径 | 路径参数 | 是否有请求体 | 内容类型 |
|---|---|---|---|---|---|
| 端点执行的操作 | GET、POST、PUT、DELETE | 带参数占位符的精确路径 | 参数名称和类型 | 端点是否接受请求体 | 通常为 application/json |
建立映射表时必须使用且仅使用以下列:
| Use Case Action | Method | Path | Path Parameters | Has Body | Content Type |
|---|---|---|---|---|---|
| ... | GET | /resource/{id} | id (string) | No | application/json |如果一个用例映射到多个端点(例如,更新 Jira 工单状态需要 Transitions API,而不是简单的 PUT),请包含所有相关端点并注明偏差。
如果无法将某个用例映射到端点,请将其标记出来并说明原因。
在每个用例至少映射到一个端点之前,不要继续。
阅读 → “Step 3: Primary Endpoint Identification”,查看完整示例。
references/examples.mdStep 4: Primary Entity Extraction
Step 4:主要实体提取
Identify the entities that primary endpoints operate on and note their identifiers.
The identifier field is critical for the validation loop in Step 13. When it creates a test entity, it needs to know which field in the response contains the ID to use in subsequent requests. Get this right.
Build a table with exactly these columns:
| Entity | Identifier Field | Alt Identifier | Role |
|---|---|---|---|
| Issue | id (string) | key (string, PROJ-123) | Primary |
| Project | id (string) | key (string, PROJ) | Secondary (dependency) |CRUD coverage gaps don't need a separate table — Step 5's CRUD catalog tracks which operations came from the use case vs. CRUD completion via the column.
SourceDo not proceed until all primary entities are identified with their identifier fields.
识别主要端点所操作的实体,并记录其标识符。
标识符字段对于 Step 13 的验证循环至关重要。当循环创建测试实体时,需要知道响应中的哪个字段包含后续请求要使用的 ID。必须准确识别。
建立映射表时必须使用且仅使用以下列:
| Entity | Identifier Field | Alt Identifier | Role |
|---|---|---|---|
| Issue | id (string) | key (string, PROJ-123) | Primary |
| Project | id (string) | key (string, PROJ) | Secondary (dependency) |CRUD 覆盖缺口不需要单独的表——Step 5 的 CRUD 目录会通过 列跟踪哪些操作来自用例,哪些通过 CRUD 补全获得。
Source在识别所有主要实体及其标识符字段之前,不要继续。
Step 5: CRUD Completion
Step 5:CRUD 补全
For each primary entity, find endpoints for the missing CRUD operations. The validation loop needs these to manage test data:
- Create → — create test entities before running the use case
test-setup - List/Search → — verify operations worked
test-validation - Delete → — clean up after tests
test-cleanup - Read/Update → fill out the CRUD surface if endpoints exist
Build a table with these columns:
| Column | What to capture |
|---|---|
| Operation | Create, Read, Update, Delete, List |
| Method | HTTP method |
| Path | Exact path with parameter placeholders |
| Path Parameters | Parameter names and types |
| Has Body | Boolean |
| Lifecycle Purpose | |
If a CRUD operation does not exist in the API (e.g., no Delete endpoint), document it explicitly — the validation loop needs to know this affects cleanup strategy.
Do not proceed until CRUD gaps are filled for every primary entity.
对于每个主要实体,找到缺失 CRUD 操作对应的端点。验证循环需要这些操作来管理测试数据:
- Create → ——在运行用例前创建测试实体
test-setup - List/Search → ——验证操作是否成功
test-validation - Delete → ——测试后进行清理
test-cleanup - Read/Update → 如果存在相应端点,则补全 CRUD 能力
建立包含以下列的表格:
| 列 | 记录内容 |
|---|---|
| 操作 | Create、Read、Update、Delete、List |
| 方法 | HTTP 方法 |
| 路径 | 带参数占位符的精确路径 |
| 路径参数 | 参数名称和类型 |
| 是否有请求体 | 布尔值 |
| 生命周期用途 | |
如果 API 中不存在某个 CRUD 操作(例如没有 Delete 端点),请明确记录——验证循环需要知道这会影响清理策略。
在补全每个主要实体的所有 CRUD 缺口之前,不要继续。
Step 6: Dependency Analysis
Step 6:依赖分析
Identify entities that primary entities require to exist. This is the most important phase for the validation loop — it determines operation ordering, test-data creation chains, and which entities must be set up before testing can begin.
识别主要实体所要求存在的实体。这是验证循环最重要的阶段——它决定操作顺序、测试数据创建链,以及测试开始前必须设置哪些实体。
The Mandatory Dependency Test
强制依赖测试
For each entity referenced by a primary entity, apply this test:
"Will the API return an error if I create the primary entity WITHOUT providing a reference to this entity?"
- YES → Secondary entity — include it. The validation loop must create this before creating the primary entity.
- NO → Excluded — optional relationship, skip it.
对于主要实体引用的每个实体,应用以下测试:
“如果创建主实体时未提供对此实体的引用,API 是否会返回错误?”
- 是 → Secondary entity——包含它。验证循环必须先创建此实体,再创建主要实体。
- 否 → Excluded——这是可选关系,跳过它。
Capture reference field detail
记录引用字段详情
For each mandatory dependency, record:
| Column | What to capture | Why |
|---|---|---|
| Referenced entity | The dependency entity name | Validation needs to know what to create |
| Required field | The exact JSON field path (e.g., | Validation needs to populate this field in create requests |
| Reference format | Whether it uses ID or key | Validation needs to know which identifier to extract from the dependency's create response |
| Decision | SECONDARY ENTITY / PRE-EXISTING / EXCLUDED | Determines next steps |
对于每个强制依赖,记录:
| 列 | 记录内容 | 原因 |
|---|---|---|
| 被引用实体 | 依赖实体名称 | 验证需要知道要创建什么 |
| 必需字段 | 精确的 JSON 字段路径(例如 | 验证需要在 create 请求中填充该字段 |
| 引用格式 | 使用 ID 还是 key | 验证需要知道从依赖实体的 create 响应中提取哪个标识符 |
| 决策 | SECONDARY ENTITY/PRE-EXISTING/EXCLUDED | 决定后续步骤 |
Pre-existing dependencies
预先存在的依赖
Some mandatory fields reference system-managed entities that cannot be created or deleted via the API (e.g., issue types, priorities, statuses in Jira). These are not secondary entities — tests discover valid values instead of creating them. For each pre-existing dependency, record the List/Get endpoint that returns valid values.
某些强制字段引用由系统管理且无法通过 API 创建或删除的实体(例如 Jira 中的 issue type、priority 和 status)。这些实体不是 Secondary entity;测试应发现有效值,而不是创建它们。对于每个预先存在的依赖,记录返回有效值的 List/Get 端点。
Walk the tree recursively
递归遍历依赖树
Secondary entities may themselves have mandatory dependencies. Apply the same test recursively until you reach entities that can be created standalone (no mandatory dependencies).
Secondary entity 本身也可能具有强制依赖。递归应用相同测试,直到找到可独立创建的实体(没有强制依赖)。
Build the dependency diagram
构建依赖图
Create a Mermaid diagram showing the dependency tree. Use solid arrows for mandatory dependencies and dashed arrows for pre-existing dependencies. Include the field reference on each arrow.
创建 Mermaid 图,展示依赖树。强制依赖使用实线箭头,预先存在的依赖使用虚线箭头。每条箭头都要包含字段引用。
Document all decisions
记录所有决策
Log every inclusion, exclusion, and pre-existing classification with reasoning. The workflow is fully autonomous — these decisions need to be reviewable after completion.
Do not proceed until the full dependency tree is mapped and all decisions are documented.
记录每一个纳入、排除和预先存在的分类及其理由。工作流完全自主执行,因此这些决策需要在完成后可审查。
在映射完整依赖树并记录所有决策之前,不要继续。
Step 7: Secondary Entity CRUD
Step 7:Secondary Entity CRUD
For each secondary entity identified in Step 6, discover full CRUD endpoints. The validation loop needs these to:
- Create the dependency chain bottom-up (e.g., create Project before Issue)
- Delete the dependency chain top-down (e.g., delete Issue before Project)
Use the same table format as Step 5 (CRUD Completion), including lifecycle purpose labels and identifier fields for each secondary entity.
Do not proceed until all secondary entities have full CRUD endpoint catalogs.
对于 Step 6 中识别的每个 Secondary entity,发现完整的 CRUD 端点。验证循环需要这些端点来:
- 自底向上创建依赖链(例如,先创建 Project,再创建 Issue)
- 自顶向下删除依赖链(例如,先删除 Issue,再删除 Project)
使用与 Step 5 相同的表格格式,包括生命周期用途标签和每个 Secondary entity 的标识符字段。
在所有 Secondary entity 都拥有完整 CRUD 端点目录之前,不要继续。
Step 8: Action Plan
Step 8:行动计划
Consolidate all findings into a structured action plan organized by downstream consumer. This is the final output of the discovery and planning phases.
按下游使用方组织并整合所有发现。这是发现和规划阶段的最终输出。
Structure the action plan with these sections
行动计划结构
1. For Spec Generation (Step 11)
- Primary endpoint catalog — these become OpenAPI operations. Use this table format:
| Use Case Action | Method | Path | Path Parameters | Has Body | Content Type |
|---|---|---|---|---|---|
| {action} | {method} | {path} | {params or —} | {Yes/No} | {content type} |- Entity list with identifier fields — these become schema definitions
2. For Live Validation (Steps 12–13)
- Full CRUD endpoint catalog (primary + secondary) with lifecycle purpose labels — the validation loop uses endpoints to create test data,
test-setupto delete ittest-cleanup - Dependency graph with field references (Mermaid diagram) — determines operation ordering
- Creation order (bottom-up) and deletion order (top-down) — use inline arrow notation () on a single line per order (e.g.,
→), not numbered listsCreate A → Create B → Create C - Pre-existing dependencies with discovery endpoints — the validation loop calls these to get valid values instead of trying to create
- Decision log — consolidate ALL dependency decisions (included as secondary, pre-existing, excluded) with reasoning into a single table so the validation loop can review why each entity was or was not included
3. For Credential Collection (Step 12)
- Auth scheme identified from documentation (if discoverable at this stage): type (Bearer, API Key, Basic, OAuth), required credential keys, header format
- If auth details are not yet clear, note this as a gap for deep research in Step 9
4. Research Plan
- Research order: secondary entities first (bottom of dependency tree), then primary. This way, when documenting a primary entity, its dependency details are already known.
- Scope: total entities to research, total endpoints discovered
- Excluded entities with reasoning
1. 供规范生成使用(Step 11)
- 主要端点目录——这些将成为 OpenAPI 操作。使用此表格格式:
| Use Case Action | Method | Path | Path Parameters | Has Body | Content Type |
|---|---|---|---|---|---|
| {action} | {method} | {path} | {params or —} | {Yes/No} | {content type} |- 带标识符字段的实体列表——这些将成为 schema 定义
2. 供实时验证使用(Steps 12~13)
- 完整 CRUD 端点目录(主要实体 + Secondary entity),带生命周期用途标签——验证循环使用 端点创建测试数据,并使用
test-setup删除测试数据test-cleanup - 带字段引用的依赖图(Mermaid 图)——决定操作顺序
- 创建顺序(自底向上)和删除顺序(自顶向下)——每种顺序在单行中使用内联箭头表示(),例如
→,不要使用编号列表Create A → Create B → Create C - 带发现端点的预先存在依赖——验证循环调用这些端点获取有效值,而不是尝试创建
- 决策日志——将所有依赖决策(纳入为 Secondary entity、预先存在、排除)及其理由整合为单个表格,供验证循环审查为何包含或排除某个实体
3. 供凭据收集使用(Step 12)
- 从文档中识别出的认证方案(如果在此阶段可以发现):类型(Bearer、API Key、Basic、OAuth)、必需凭据键、header 格式
- 如果认证详情尚不明确,将其记录为 Step 9 深度研究需要解决的缺口
4. 研究计划
- 研究顺序:先研究 Secondary entity(依赖树底部),然后研究主要实体。这样在记录主要实体时,其依赖详情已经明确。
- 范围:要研究的实体总数、已发现的端点总数
- 排除的实体及其理由
Write the action plan
编写行动计划
Save the action plan to using the Write tool. This file persists the discovery work for the deep research phase (Step 9).
{PROJECT_FOLDER}/action-plan.mdRead → "Step 8: Action Plan" for a complete worked example.
references/examples.md使用 Write 工具将行动计划保存到 。此文件会保留发现阶段的成果,供 Step 9 深度研究使用。
{PROJECT_FOLDER}/action-plan.md阅读 → “Step 8: Action Plan”,查看完整示例。
references/examples.mdStep 9: Deep Research
Step 9:深度研究
For each entity in the research plan, read the API documentation and document detailed schemas, fields, and behaviors that downstream consumers need to construct requests, validate responses, wire dependencies, and collect credentials.
Input: The action plan from Step 8 () provides the research order, endpoint catalog, dependency graph, and documentation sources confirmed in Step 2.
{PROJECT_FOLDER}/action-plan.mdDocumentation source priority: Use the OpenAPI spec (if available from Step 2) as the primary source for request/response schemas and field details — it has exact types, required/optional markers, and schema definitions. Use the human-readable API reference as a supplement for pagination patterns, rate-limit behavior, side effects, and behavioral details not captured in the spec. If no OpenAPI spec is available, use human-readable docs for everything.
Critical: Copy field names, types, and constraints exactly from the documentation. Do not infer or guess field details.
对于研究计划中的每个实体,读取 API 文档,并记录下游使用方构造请求、验证响应、连接依赖和收集凭据所需的详细 schema、字段和行为。
**输入:**Step 8 中的行动计划()提供研究顺序、端点目录、依赖图以及 Step 2 中已确认的文档来源。
{PROJECT_FOLDER}/action-plan.md**文档来源优先级:**如果 Step 2 中找到了 OpenAPI 规范,则将其作为请求/响应 schema 和字段详情的主要来源,因为它包含准确的类型、必需/可选标记及 schema 定义。将便于阅读的 API 参考文档作为补充,用于获取分页模式、速率限制行为、副作用,以及规范中未记录的行为详情。如果不存在 OpenAPI 规范,则全部使用便于阅读的文档。
**关键:**准确复制文档中的字段名称、类型和约束。不要推断或猜测字段详情。
Processing Order
处理顺序
Follow the Research Plan section from the action plan:
- Research API-level notes first (auth scheme and rate limits — these apply globally)
- Document pre-existing entities next (lightweight treatment — discovery schema only)
- Research secondary entities in bottom-up order (bottom of dependency tree first)
- Research primary entities last
Write each entity's research to the output file immediately after completing it. Do not accumulate all research in conversation before writing.
遵循行动计划中的 Research Plan 部分:
- 首先研究 API 级说明——认证方案和速率限制适用于整个 API
- 接下来研究预先存在的实体——采用轻量级处理,仅记录发现 schema
- 按自底向上的顺序研究 Secondary entity——先处理依赖树底部
- 最后研究主要实体
每完成一个实体的研究,立即将其写入输出文件。不要先在对话中累积所有研究内容再统一写入。
API-Level Notes
API 级说明
Before researching individual entities, document two API-level categories. WebFetch the API's authentication and rate-limiting documentation pages.
| Item | What to capture | Why (downstream consumer) |
|---|---|---|
| Auth type | Bearer, Basic, API Key, OAuth | Credential collection needs the injection pattern |
| Header format | Exact header name and value pattern | Validation constructs request headers |
| Required credentials | Credential key names | Credential collection prompts the user |
| Base URL | URL pattern (with variable parts noted) | Validation constructs request URLs |
| Global rate limits | Requests per second/minute | Validation paces requests |
| 429 behavior | Retry-After header? Body format? | Validation implements backoff |
| Retry strategy | Recommended approach | Validation retries failed requests |
研究单个实体之前,记录两类 API 级说明。使用 WebFetch 访问 API 的认证和速率限制文档页面。
| 项目 | 记录内容 | 原因(下游使用方) |
|---|---|---|
| 认证类型 | Bearer、Basic、API Key、OAuth | 凭据收集需要注入模式 |
| Header 格式 | 精确的 header 名称和值模式 | 验证用于构造请求 header |
| 必需凭据 | 凭据键名称 | 凭据收集用于提示用户 |
| Base URL | URL 模式(注明可变部分) | 验证用于构造请求 URL |
| 全局速率限制 | 每秒/每分钟请求数 | 验证用于控制请求节奏 |
| 429 行为 | 是否有 Retry-After header?body 格式是什么? | 验证用于实现退避 |
| 重试策略 | 推荐方式 | 验证用于重试失败请求 |
Pre-Existing Entity Treatment
预先存在的实体处理
Pre-existing entities (identified as PRE-EXISTING in the dependency analysis) are system-managed and cannot be created or deleted via the API. Tests discover valid values instead of creating them.
For each pre-existing entity, document only:
- The discovery endpoint's response schema — what fields come back from the List/Get endpoint
- The field to extract — which field the downstream consumer needs (e.g., ,
id) and its typename
Skip request schemas (no Create/Update), field catalog, entity references, pagination, and side effects for pre-existing entities.
在依赖分析中被标记为 PRE-EXISTING 的实体由系统管理,无法通过 API 创建或删除。测试应发现有效值,而不是创建这些实体。
对于每个预先存在的实体,仅记录:
- 发现端点的响应 schema——List/Get 端点返回哪些字段
- 要提取的字段——下游使用方需要哪个字段(例如 、
id)及其类型name
跳过请求 schema(没有 Create/Update)、字段目录、实体引用、分页和副作用。
Per-Entity Deep Research
单实体深度研究
For each secondary and primary entity, research and document the following 6 categories. Auth scheme and rate limits are API-level — do not repeat them per entity.
对于每个 Secondary entity 和主要实体,研究并记录以下 6 个类别。认证方案和速率限制属于 API 级信息,不要在每个实体中重复。
Category 1: Request Schemas
类别 1:请求 Schema
For each operation that accepts a request body (typically Create and Update), document the exact request structure.
| Item | What to capture |
|---|---|
| Operation | Create, Update, or other body-accepting operation |
| Content-Type | |
| Minimal request body | Smallest valid request (required fields only) |
| Full request body | All fields including optional |
Format each operation as:
**Create — POST `/path`**
Content-Type: application/json
Minimal request body (required fields only):
{json}
Full request body (all fields):
{json}If an operation does not accept a body (e.g., DELETE), skip it in this section.
对于每个接受请求体的操作(通常是 Create 和 Update),记录确切的请求结构。
| 项目 | 记录内容 |
|---|---|
| 操作 | Create、Update 或其他接受请求体的操作 |
| Content-Type | |
| 最小请求体 | 仅包含必需字段的最小有效请求 |
| 完整请求体 | 包含可选字段在内的所有字段 |
按照以下格式记录每个操作:
**Create — POST `/path`**
Content-Type: application/json
Minimal request body (required fields only):
{json}
Full request body (all fields):
{json}如果操作不接受请求体(例如 DELETE),在此节中跳过。
Category 2: Response Schemas
类别 2:响应 Schema
For each operation, document the response structure including status code.
| Item | What to capture |
|---|---|
| Operation | Create, Read, List, Delete, etc. |
| Success status code | 200, 201, 204, etc. |
| Response body | Exact JSON structure (or "No response body" for 204) |
| Identifier location | Where the entity ID appears in the response |
Format each operation as:
**Read — GET `/path/{id}` → 200**
{json}
**Create — POST `/path` → 201**
{json}
**Delete — DELETE `/path/{id}` → 204**
No response body.For List operations, show the response envelope (wrapper structure with pagination fields) and one item in the collection.
对于每个操作,记录响应结构,包括状态码。
| 项目 | 记录内容 |
|---|---|
| 操作 | Create、Read、List、Delete 等 |
| 成功状态码 | 200、201、204 等 |
| 响应体 | 精确的 JSON 结构;对于 204 则写为“No response body” |
| 标识符位置 | 实体 ID 在响应中的位置 |
按照以下格式记录每个操作:
**Read — GET `/path/{id}` → 200**
{json}
**Create — POST `/path` → 201**
{json}
**Delete — DELETE `/path/{id}` → 204**
No response body.对于 List 操作,展示响应封装结构(包含分页字段)以及集合中的一个元素。
Category 3: Field Catalog
类别 3:字段目录
A consolidated table of all fields across all operations. This is the single source of truth for field details.
| Column | What to capture |
|---|---|
| Field | JSON path (e.g., |
| Type | string, number, boolean, array, object, or enum |
| Required for | Which operations require this field (Create, Update, both, or —) |
| Constraints | Max length, format pattern, allowed enum values |
| Default | Default value if field is omitted, or — |
Build the table:
| Field | Type | Required for | Constraints | Default |
|---|---|---|---|---|
| `name` | string | Create | max 255 chars | — |
| `status` | enum | — | `active`, `inactive` | `active` |For enum fields, list all valid values. If the enum has more than 10 values, list representative values and note "see API docs for full list."
建立一个整合所有操作中全部字段的表格。这是字段详情的唯一事实来源。
| 列 | 记录内容 |
|---|---|
| 字段 | JSON 路径(例如 |
| 类型 | string、number、boolean、array、object 或 enum |
| 必需于 | 哪些操作需要此字段(Create、Update、两者,或 —) |
| 约束 | 最大长度、格式模式、允许的 enum 值 |
| 默认值 | 省略字段时的默认值,或 — |
建立如下表格:
| Field | Type | Required for | Constraints | Default |
|---|---|---|---|---|
| `name` | string | Create | max 255 chars | — |
| `status` | enum | — | `active`, `inactive` | `active` |对于 enum 字段,列出所有有效值。如果 enum 超过 10 个值,则列出代表性值并注明“参见 API 文档获取完整列表”。
Category 4: Entity References
类别 4:实体引用
Document how this entity references other entities. This enriches the dependency analysis from Step 6 with field-level detail that the validation loop needs to wire dependencies.
| Column | What to capture |
|---|---|
| Field | The field path that holds the reference (e.g., |
| Referenced Entity | The entity being referenced |
| Reference Format | ID, key, name, or compound |
| Mandatory | Yes / No / Pre-existing |
Build the table:
| Field | Referenced Entity | Reference Format | Mandatory |
|---|---|---|---|
| `fields.project.id` | Project | ID (string) | Yes |
| `fields.assignee.accountId` | User | Account ID (string) | No |记录此实体如何引用其他实体。这会从字段层面丰富 Step 6 的依赖分析,为验证循环提供必要信息。
| 列 | 记录内容 |
|---|---|
| 字段 | 保存引用的字段路径(例如 |
| 被引用实体 | 被引用的实体 |
| 引用格式 | ID、key、name 或复合形式 |
| 强制 | Yes/No/Pre-existing |
建立如下表格:
| Field | Referenced Entity | Reference Format | Mandatory |
|---|---|---|---|
| `fields.project.id` | Project | ID (string) | Yes |
| `fields.assignee.accountId` | User | Account ID (string) | No |Category 5: Pagination
类别 5:分页
Document how List/Search endpoints handle pagination. If the entity has no List endpoint, write "No list endpoint — pagination not applicable."
CRITICAL PAGINATION DETECTION ORDER:
- ALWAYS check for cursor-based pagination FIRST — look for: ,
continuation,continuation_token,next_cursor,cursor,after,before,next_page_token(when it's a token/string, not numeric).offset - Distinguish offset vs cursor: Offset uses NUMERIC values (0, 10, 20...). If a parameter named contains TOKEN/STRING values like
offset, it's cursor-based, NOT offset."eyJ0eXAi..." - Some APIs include both cursor tokens AND page metadata (page_count, page_number) in responses — the actual pagination mechanism is cursor-based. Always use cursor-based when a continuation/cursor token exists.
- Only use page-based pagination if documentation explicitly shows "page" parameters AND no cursor indicators exist.
- Each endpoint has EXACTLY ONE pagination type. NEVER mix types.
- Search documentation for to find official patterns.
"{apiName} pagination"
For each List endpoint, document using this exact structured format:
**List — GET `/path`**
- **Pagination type:** offset | cursor | page | timestamp | none
- **Items field:** {dot-notation path to items array, e.g., "data", "results", "values"}Then include ONLY the fields for the applicable type:
For cursor:
- **Cursor param:** {query parameter name, e.g., "cursor", "after", "nextToken"}
- **Reference type:** marker | uri
- **Reference expression:** {dot-notation path to next cursor value, e.g., "pagination.nextCursor"}- Use when the response contains a cursor VALUE (token/string).
marker - Use when the response contains a complete URL for the next page.
uri - NEVER use any other value for reference type — only or
marker.uri
For offset:
- **Offset param:** {query parameter name, e.g., "startAt", "offset"} — must be NUMERIC
- **Initial offset value:** {number, typically 0}For page:
- **Page number param:** {query parameter name, e.g., "page", "pageNumber"}
- **Initial page number:** {number, typically 0 or 1}For timestamp:
- **Timestamp param:** {query parameter name, e.g., "since", "after"}记录 List/Search 端点如何处理分页。如果实体没有 List 端点,则写“No list endpoint — pagination not applicable.”。
关键分页检测顺序:
- 始终先检查基于游标的分页——查找:、
continuation、continuation_token、next_cursor、cursor、after、before、next_page_token(当它是 token/字符串而不是数值时)。offset - 区分 offset 与 cursor:Offset 使用数值(0、10、20……)。如果名为 的参数包含 token/字符串值(例如
offset),则它属于 cursor,而不是 offset。"eyJ0eXAi..." - 某些 API 的响应同时包含 cursor token 和分页元数据(page_count、page_number)——实际分页机制仍是 cursor。只要存在 continuation/cursor token,就始终使用 cursor。
- 只有在文档明确显示 参数且不存在 cursor 指标时,才使用基于页面的分页。
page - 每个端点必须且只能有一种分页类型。绝不混用不同类型。
- 搜索文档 以查找官方分页模式。
"{apiName} pagination"
对于每个 List 端点,使用以下精确结构化格式:
**List — GET `/path`**
- **Pagination type:** offset | cursor | page | timestamp | none
- **Items field:** {dot-notation path to items array, e.g., "data", "results", "values"}然后仅包含适用类型的字段:
对于 cursor:
- **Cursor param:** {query parameter name, e.g., "cursor", "after", "nextToken"}
- **Reference type:** marker | uri
- **Reference expression:** {dot-notation path to next cursor value, e.g., "pagination.nextCursor"}- 当响应包含 cursor 值(token/字符串)时,使用 。
marker - 当响应包含下一页的完整 URL 时,使用 。
uri - 绝不使用其他值作为引用类型——只能是 或
marker。uri
对于 offset:
- **Offset param:** {query parameter name, e.g., "startAt", "offset"} — must be NUMERIC
- **Initial offset value:** {number, typically 0}对于 page:
- **Page number param:** {query parameter name, e.g., "page", "pageNumber"}
- **Initial page number:** {number, typically 0 or 1}对于 timestamp:
- **Timestamp param:** {query parameter name, e.g., "since", "after"}Category 6: Side Effects & Behaviors
类别 6:副作用与行为
Document behaviors that affect how downstream agents construct, execute, or validate operations. For each item, write the behavior or "none" if not applicable.
- **Delete behavior:** hard delete / soft delete / archive / deactivate / no delete endpoint
- **Cascade on delete:** deleting this entity also deletes {children} / no cascade
- **Immutable fields:** {field list} cannot be changed after creation / none
- **Async operations:** {operation} returns 202, poll {url} for completion / none
- **Conditional requirements:** {field} required only when {condition} / none
- **Non-standard patterns:** {any API-specific quirks, e.g., status changes via transitions}记录会影响下游 Agent 构造、执行或验证操作的行为。对于每个项目,写明行为;如不适用则写“none”。
- **Delete behavior:** hard delete / soft delete / archive / deactivate / no delete endpoint
- **Cascade on delete:** deleting this entity also deletes {children} / no cascade
- **Immutable fields:** {field list} cannot be changed after creation / none
- **Async operations:** {operation} returns 202, poll {url} for completion / none
- **Conditional requirements:** {field} required only when {condition} / none
- **Non-standard patterns:** {any API-specific quirks, e.g., status changes via transitions}Write the deep research
写入深度研究
Save the deep research to using the Write tool. Write each entity's section immediately after researching it — do not accumulate all research before writing.
{PROJECT_FOLDER}/api-reference.mdStructure the file as:
markdown
undefined使用 Write 工具将深度研究保存到 。每完成一个实体部分就立即写入——不要先累积所有研究内容再统一写入。
{PROJECT_FOLDER}/api-reference.md按以下结构组织文件:
markdown
undefined{Service} API Reference — Deep Research
{Service} API Reference — Deep Research
API-Level Notes
API-Level Notes
{auth scheme + rate limits}
{auth scheme + rate limits}
Pre-Existing Entities
Pre-Existing Entities
{Entity} [PRE-EXISTING]
{Entity} [PRE-EXISTING]
{discovery schema only}
{discovery schema only}
Secondary Entities
Secondary Entities
{Entity} [SECONDARY]
{Entity} [SECONDARY]
{6 categories}
{6 categories}
Primary Entities
Primary Entities
{Entity} [PRIMARY]
{Entity} [PRIMARY]
{6 categories}
**Do not proceed until every entity in the research plan has been documented with all applicable categories.**
---{6 categories}
**在研究计划中的每个实体都记录完所有适用类别之前,不要继续。**
---Step 10: api-reference.md Consolidation
Step 10:合并 api-reference.md
Consolidate the action plan (Step 8) and deep research (Step 9) into a single, self-contained . After this step, downstream consumers (the OpenAPI generator in Step 11, the validation loop in Steps 12–13, the calling skill) need only this one file — they should never need to read .
api-reference.mdbuild-mule-integrationaction-plan.md将行动计划(Step 8)和深度研究(Step 9)整合为单个自包含的 。完成此步骤后,下游使用方——Step 11 的 OpenAPI 生成器、Steps 12~13 的验证循环,以及调用方 skill——只需读取这一个文件,不应再需要读取 。
api-reference.mdbuild-mule-integrationaction-plan.mdInputs
输入
- from Step 8
{PROJECT_FOLDER}/action-plan.md - from Step 9 (the deep research file)
{PROJECT_FOLDER}/api-reference.md
- Step 8 的
{PROJECT_FOLDER}/action-plan.md - Step 9 的 (深度研究文件)
{PROJECT_FOLDER}/api-reference.md
Steps
步骤
-
Readand extract:
action-plan.md- Use case endpoint table (from §1 For Spec Generation)
- Full CRUD endpoint catalog (from §2 For Live Validation)
- Mermaid dependency graph (from §2)
- Creation order and deletion order (from §2)
- Pre-existing dependencies table (from §2)
- Decision log table (from §2)
- Auth scheme details (from §3 For Credential Collection)
- Documentation source URL (from the header)
-
Read(Step 9 deep research) and note:
api-reference.md- API-Level Notes content (Auth Scheme + Rate Limits) — this will become the top-level Authentication and Rate Limits sections
- All entity sections (Pre-Existing, Secondary, Primary) with their full category detail
-
Write the finalfollowing the exact template below. Use the Write tool to overwrite the Step 9 file with the consolidated output.
api-reference.md
-
读取,提取:
action-plan.md- 用例端点表(来自 §1 For Spec Generation)
- 完整 CRUD 端点目录(来自 §2 For Live Validation)
- Mermaid 依赖图(来自 §2)
- 创建顺序和删除顺序(来自 §2)
- 预先存在依赖表(来自 §2)
- 决策日志表(来自 §2)
- 认证方案详情(来自 §3 For Credential Collection)
- 文档来源 URL(来自 header)
-
读取(Step 9 深度研究文件),记录:
api-reference.md- API-Level Notes 内容(Auth Scheme + Rate Limits)——它将成为顶层 Authentication 和 Rate Limits 部分
- 所有实体部分(Pre-Existing、Secondary、Primary)及其完整类别详情
-
使用 Write 工具,按照下面的精确模板覆盖 Step 9 文件,写入最终的。
api-reference.md
Output template
输出模板
Write the final with exactly this structure:
api-reference.mdmarkdown
undefined按照以下精确结构写入最终 :
api-reference.mdmarkdown
undefined{Service} API Reference
{Service} API Reference
Overview
Overview
- Service: {apiName}
- API Version: {version from documentation, e.g., "v3", "v1", "2023-08-01"}
- Base URL: {base URL from API-Level Notes}
- Documentation: {primary documentation URL from action plan header}
- Service: {apiName}
- API Version: {version from documentation, e.g., "v3", "v1", "2023-08-01"}
- Base URL: {base URL from API-Level Notes}
- Documentation: {primary documentation URL from action plan header}
Authentication
Authentication
- Type: {Bearer / Basic / API Key / OAuth}
- Header format: {exact header pattern, e.g., }
Authorization: Basic base64({email}:{api_token}) - Required credentials: {credential key names, e.g., ,
BASIC_USERNAME} {include any additional auth details from the deep research — alternative auth methods, transport requirements, test mode info}BASIC_PASSWORD
- Type: {Bearer / Basic / API Key / OAuth}
- Header format: {exact header pattern, e.g., }
Authorization: Basic base64({email}:{api_token}) - Required credentials: {credential key names, e.g., ,
BASIC_USERNAME} {include any additional auth details from the deep research — alternative auth methods, transport requirements, test mode info}BASIC_PASSWORD
Rate Limits & Constraints
Rate Limits & Constraints
{Rate Limits content from Step 9 API-Level Notes — copy the full detail including global limits, burst limits, 429 behavior, retry strategy, endpoint-specific limits}
{Rate Limits content from Step 9 API-Level Notes — copy the full detail including global limits, burst limits, 429 behavior, retry strategy, endpoint-specific limits}
Use Cases
Use Cases
{endpoint table from action plan §1, copied exactly:}
| Use Case Action | Method | Path | Path Parameters | Has Body | Content Type |
|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... |
{include any deviation notes from the action plan}
{endpoint table from action plan §1, copied exactly:}
| Use Case Action | Method | Path | Path Parameters | Has Body | Content Type |
|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... |
{include any deviation notes from the action plan}
Entity Dependency Graph
Entity Dependency Graph
{Mermaid diagram from action plan §2, copied exactly}
- Creation order: {bottom-up arrow notation from action plan}
- Deletion order: {top-down arrow notation from action plan}
Pre-existing dependencies (discover, don't create):
{pre-existing dependencies table from action plan §2, or "None — all mandatory dependencies can be created and deleted via the API." if no pre-existing deps}
Decision log:
{decision log table from action plan §2, copied exactly}
{Mermaid diagram from action plan §2, copied exactly}
- Creation order: {bottom-up arrow notation from action plan}
- Deletion order: {top-down arrow notation from action plan}
Pre-existing dependencies (discover, don't create):
{pre-existing dependencies table from action plan §2, or "None — all mandatory dependencies can be created and deleted via the API." if no pre-existing deps}
Decision log:
{decision log table from action plan §2, copied exactly}
Full CRUD Endpoint Catalog
Full CRUD Endpoint Catalog
{CRUD catalog table from action plan §2, copied exactly:}
| Entity | Operation | Method | Path | Lifecycle Purpose | Source |
|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... |
{CRUD catalog table from action plan §2, copied exactly:}
| Entity | Operation | Method | Path | Lifecycle Purpose | Source |
|---|---|---|---|---|---|
| ... | ... | ... | ... | ... | ... |
Entity Reference
Entity Reference
Pre-Existing Entities
Pre-Existing Entities
{Entity} [PRE-EXISTING]
{Entity} [PRE-EXISTING]
{discovery schema only — copied from Step 9}
{discovery schema only — copied from Step 9}
Secondary Entities
Secondary Entities
{Entity} [SECONDARY]
{Entity} [SECONDARY]
{all 6 categories — copied from Step 9}
{all 6 categories — copied from Step 9}
Primary Entities
Primary Entities
{Entity} [PRIMARY]
{Entity} [PRIMARY]
{all 6 categories — copied from Step 9}
undefined{all 6 categories — copied from Step 9}
undefinedHeading level adjustment
标题级别调整
Step 9 writes entity sections with these heading levels:
- ,
## Pre-Existing Entities,## Secondary Entities## Primary Entities ### {Entity} [TYPE]#### Category N: {name}
In the final output, these live under the parent, so demote each by one level:
## Entity Reference- ,
### Pre-Existing Entities,### Secondary Entities### Primary Entities #### {Entity} [TYPE]##### Category N: {name}
Step 9 使用以下标题级别写入实体部分:
- 、
## Pre-Existing Entities、## Secondary Entities## Primary Entities ### {Entity} [TYPE]#### Category N: {name}
在最终输出中,这些内容位于 父级之下,因此每个标题都下调一级:
## Entity Reference- 、
### Pre-Existing Entities、### Secondary Entities### Primary Entities #### {Entity} [TYPE]##### Category N: {name}
What NOT to include in Entity Reference
Entity Reference 中不应包含的内容
Do not include (Auth Scheme + Rate Limits) in the Entity Reference section — that content has been extracted into the top-level Authentication and Rate Limits sections. The Entity Reference section starts directly with (or if there are no pre-existing entities).
## API-Level Notes### Pre-Existing Entities### Secondary Entities不要在 Entity Reference 部分包含 (Auth Scheme + Rate Limits),因为这些内容已提取到顶层 Authentication 和 Rate Limits 部分。Entity Reference 部分直接从 开始;如果没有预先存在的实体,则从 开始。
## API-Level Notes### Pre-Existing Entities### Secondary EntitiesVerification checklist
验证清单
Before completing this step, verify the final contains:
api-reference.md- Title is (no "Deep Research" suffix)
# {Service} API Reference - Overview section with base URL
- Authentication section with type, header format, required credentials
- Rate Limits & Constraints section
- Use Cases table with all use cases from input
- Entity Dependency Graph with Mermaid diagram
- Creation order and deletion order (inline arrow notation)
- Pre-existing dependencies table (or "None" statement)
- Decision log table
- Full CRUD Endpoint Catalog with lifecycle labels
- Entity Reference section contains every entity from Step 9
- All 6 per-entity categories preserved for each secondary and primary entity
- Pre-existing entities have discovery-only treatment (no request schemas, field catalogs)
- No duplicated API-Level Notes in Entity Reference
Do not proceed until all checklist items pass.
完成此步骤前,验证最终 包含:
api-reference.md- 标题为 ,没有“Deep Research”后缀
# {Service} API Reference - 包含 Base URL 的 Overview 部分
- 包含类型、header 格式和必需凭据的 Authentication 部分
- Rate Limits & Constraints 部分
- 包含输入中所有用例的 Use Cases 表
- 包含 Mermaid 图的 Entity Dependency Graph
- 使用内联箭头表示的创建顺序和删除顺序
- 预先存在的依赖表(或“None”说明)
- 决策日志表
- 带生命周期标签的 Full CRUD Endpoint Catalog
- Entity Reference 部分包含 Step 9 中的每个实体
- 每个 Secondary entity 和主要实体的全部 6 个实体类别均已保留
- 预先存在的实体仅采用发现型处理方式(无请求 schema、字段目录)
- Entity Reference 中没有重复的 API-Level Notes
在所有清单项都通过之前,不要继续。
Step 11: OpenAPI 3.0 Spec Generation
Step 11:生成 OpenAPI 3.0 规范
Read the consolidated from Step 10 and produce a complete OpenAPI 3.0 specification at . The spec must accurately reflect every operation, schema, parameter, and authentication requirement documented in the api-reference, and nothing more.
api-reference.md{PROJECT_FOLDER}/<apiName>.yaml读取 Step 10 合并后的 ,在 生成完整的 OpenAPI 3.0 规范。该规范必须准确反映 中记录的所有操作、schema、参数和认证要求,不得包含额外内容。
api-reference.md{PROJECT_FOLDER}/<apiName>.yamlapi-referenceRequirements
要求
- OpenAPI version 3.0.x.
- Complete section:
infoending with "API", semvertitle(e.g.,version), and a one-sentence imperative1.0.0.description - section with the base URL (including the API version prefix if the API uses one).
servers - section with ONLY the endpoints documented in
paths's Use Cases table — do NOT add endpoints beyond what the research discovered.api-reference.md - section with: authentication schemes from §Authentication, reusable schemas for request/response bodies, common parameters, error responses.
components - For each endpoint: complete parameter definitions (path, query, header, body), full response schemas with data types, error responses (4xx, 5xx), authentication requirements.
- Add ONE connectivity-test endpoint if the API has an obvious lightweight "ping" endpoint (e.g., ,
GET /me). This single extra operation gives Step 12's prerequisites a way to verify credentials before the full loop runs. If the API has no such endpoint, do not invent one — Step 12 will use the first GET inGET /healthinstead.paths
- OpenAPI 版本为 3.0.x。
- 完整的 部分:标题以“API”结尾,版本使用 semver(例如
info),并提供一句祈使句式1.0.0。description - 部分包含 base URL(如果 API 使用版本前缀,也要包含)。
servers - 部分仅包含
paths的 Use Cases 表中记录的端点——不要添加研究结果之外的端点。api-reference.md - 部分包含:来自 §Authentication 的认证方案、可复用的请求/响应 body schema、公共参数和错误响应。
components - 对每个端点提供完整的参数定义(path、query、header、body)、带数据类型的完整响应 schema、错误响应(4xx、5xx)和认证要求。
- 如果 API 存在明显轻量的“ping”端点(例如 、
GET /me),则添加一个连通性测试端点。这个额外操作为 Step 12 的前置检查提供了一种在完整循环前验证凭据的方法。如果 API 没有此类端点,不要自行虚构——Step 12 将改用GET /health中第一个 GET。paths
CRITICAL Path and Versioning Rules
关键路径和版本规则
- API version (e.g., ) MUST be in
/v3, NOT in endpoint paths.servers[].url - Remove ALL API version prefixes from endpoint paths.
- Endpoint paths MUST NOT end with a trailing slash.
Correct:
yaml
servers:
- url: https://api.example.com/v3
paths:
/users:
get: ...
/users/{id}:
get: ...Incorrect:
yaml
servers:
- url: https://api.example.com
paths:
/v3/users:
get: ...
/users/{id}/:
get: ...- API 版本(例如 )必须位于
/v3中,而不是端点路径中。servers[].url - 从所有端点路径中移除 API 版本前缀。
- 端点路径不得以尾部斜杠结尾。
正确:
yaml
servers:
- url: https://api.example.com/v3
paths:
/users:
get: ...
/users/{id}:
get: ...错误:
yaml
servers:
- url: https://api.example.com
paths:
/v3/users:
get: ...
/users/{id}/:
get: ...Other rules
其他规则
- Every operation has a unique in camelCase (e.g.,
operationId,listCourses).getCourseById - Every operation has a (imperative voice, one sentence).
description - Every operation has at least one request example and at least one response example.
- Every property in every schema has a .
description - Strings with constrained values use (no naked strings).
enum - fields are explicit on every object schema where applicable.
required - Path and query parameters have descriptions and types.
Write the file with the Write tool. Do NOT show the spec to the user — proceed to Step 12 immediately.
- 每个操作都有唯一的 camelCase (例如
operationId、listCourses)。getCourseById - 每个操作都有 ,使用祈使语气且仅包含一个句子。
description - 每个操作至少包含一个请求示例和一个响应示例。
- 每个 schema 中的每个属性都有 。
description - 受约束的字符串使用 ,不要使用无约束字符串。
enum - 所有适用的对象 schema 都显式声明 字段。
required - Path 和 query 参数都有描述和类型。
使用 Write 工具写入文件。不要向用户显示该规范——立即进入 Step 12。
Step 12: Live Validation — Prerequisites
Step 12:实时验证——前置条件
Before entering the per-operation validation loop, verify four prerequisites in order. If any fails, report the specific problem and stop. Do not narrate each check unless it fails.
进入逐操作验证循环前,按顺序验证四项前置条件。如果任何一项失败,请报告具体问题并停止。除非检查失败,否则不要逐项叙述。
1. OpenAPI Spec File
1. OpenAPI 规范文件
- Read .
{PROJECT_FOLDER}/<apiName>.yaml - Verify it is valid YAML.
- Verify it contains an key with a value starting with
openapi(OpenAPI 3.x).3. - Verify contains at least one operation.
paths - Count the total number of operations — this is M, the denominator in the progress line ().
N/M
- 读取 。
{PROJECT_FOLDER}/<apiName>.yaml - 验证它是有效的 YAML。
- 验证它包含 键,且值以
openapi开头(OpenAPI 3.x)。3. - 验证 至少包含一个操作。
paths - 统计操作总数——这是进度行中 的分母 M。
N/M
2. api-reference.md
api-reference.md2. api-reference.md
api-reference.md- Read .
{PROJECT_FOLDER}/api-reference.md - Verify it contains these sections: Authentication, Entity Dependency Graph, Full CRUD Endpoint Catalog, Entity Reference.
- Read the Authentication section and extract:
- Auth type (e.g., Bearer token, Basic, API Key)
- Header format (e.g., )
Authorization: Bearer <TOKEN> - Required credential key name(s) (e.g., )
CODA_API_TOKEN - For API Key auth: injection location — header name (e.g., ) or query parameter name(s) (e.g.,
X-API-Key,key)token
- 读取 。
{PROJECT_FOLDER}/api-reference.md - 验证它包含以下部分:Authentication、Entity Dependency Graph、Full CRUD Endpoint Catalog、Entity Reference。
- 读取 Authentication 部分并提取:
- 认证类型(例如 Bearer token、Basic、API Key)
- Header 格式(例如 )
Authorization: Bearer <TOKEN> - 必需凭据键名称(例如 )
CODA_API_TOKEN - 对于 API Key 认证:注入位置——header 名称(例如 )或 query 参数名称(例如
X-API-Key、key)token
3. config.properties
config.properties3. config.properties
config.propertiesCheck whether exists.
{PROJECT_FOLDER}/config.propertiesIf the file does NOT exist — create it:
-
Take the credential key name(s) extracted in step 2 (e.g.,, or
CODA_API_TOKENandTRELLO_API_KEY).TRELLO_API_TOKEN -
Generate a placeholder value for each key by lower-casing the key name, replacing underscores with hyphens, and wrapping withand
your-(e.g.,-here→CODA_API_TOKEN).your-coda-api-token-here -
Createwith one
{PROJECT_FOLDER}/config.propertiesline per credential:KEY=placeholderbashprintf '%s\n' 'CODA_API_TOKEN=your-coda-api-token-here' > {PROJECT_FOLDER}/config.propertiesFor multiple keys, write all lines in one command:bashprintf '%s\n' 'TRELLO_API_KEY=your-trello-api-key-here' 'TRELLO_API_TOKEN=your-trello-api-token-here' > {PROJECT_FOLDER}/config.properties -
Report to the user and wait:
Created config.properties with placeholder credentials: CODA_API_TOKEN=your-coda-api-token-here Please replace the placeholder value(s) with real credentials and let me know when ready.▸ WAIT — Do not proceed until the user confirms the credentials are in place. -
Once the user confirms, proceed to verify keys below.
Verify keys (runs after file creation + user confirmation, or immediately if the file already existed):
-
For each credential key identified in step 2, verify the key exists:bash
grep -c '^CREDENTIAL_KEY=' {PROJECT_FOLDER}/config.propertiesThe result must be. Do NOT read or display the value.1
检查 是否存在。
{PROJECT_FOLDER}/config.properties如果文件不存在——创建它:
-
获取步骤 2 中提取的凭据键名称(例如,或
CODA_API_TOKEN和TRELLO_API_KEY)。TRELLO_API_TOKEN -
为每个键生成占位值:将键名称转为小写,把下划线替换为连字符,并用和
your-包裹(例如-here→CODA_API_TOKEN)。your-coda-api-token-here -
创建,每个凭据使用一行
{PROJECT_FOLDER}/config.properties:KEY=placeholderbashprintf '%s\n' 'CODA_API_TOKEN=your-coda-api-token-here' > {PROJECT_FOLDER}/config.properties如果有多个键,在一条命令中写入所有行:bashprintf '%s\n' 'TRELLO_API_KEY=your-trello-api-key-here' 'TRELLO_API_TOKEN=your-trello-api-token-here' > {PROJECT_FOLDER}/config.properties -
向用户报告并等待:
Created config.properties with placeholder credentials: CODA_API_TOKEN=your-coda-api-token-here Please replace the placeholder value(s) with real credentials and let me know when ready.▸ 等待——在用户确认凭据已就位之前,不要继续。 -
用户确认后,继续执行下面的键验证。
验证键(文件创建并经用户确认后执行,或文件原本已存在时立即执行):
-
对于步骤 2 中识别的每个凭据键,验证该键是否存在:bash
grep -c '^CREDENTIAL_KEY=' {PROJECT_FOLDER}/config.properties结果必须为。不要读取或显示其值。1
4. Base URL
4. Base URL
- Read the Overview section of and extract the
api-reference.mdvalue (e.g.,Base URL).https://coda.io/apis/v1 - Verify it starts with or
https://.http://
- 读取 的 Overview 部分,并提取 Base URL 值(例如
api-reference.md)。https://coda.io/apis/v1 - 验证其以 或
https://开头。http://
Prerequisites check
前置条件检查
Verify all four silently. If all pass, proceed to Step 13 without narrating each check. If any fails, report the specific problem to the user and stop.
▸ STOP — Do not proceed to Step 13 until ALL four prerequisites pass.
静默验证全部四项。如果全部通过,不叙述各项检查,直接进入 Step 13。如果任何一项失败,向用户报告具体问题并停止。
▸ 停止——在所有四项前置条件都通过之前,不要进入 Step 13。
Step 13: Live Validation — Loop
Step 13:实时验证——循环
After prerequisites pass, set up the iteration loop before processing individual operations.
前置条件通过后,在处理单个操作前先设置迭代循环。
Enumerate operations
枚举操作
Walk the object in the OpenAPI spec in document order. For each path, for each HTTP method defined on that path (GET, POST, PUT, PATCH, DELETE), record as one operation. Build an ordered list of all operations. Total count = M.
paths(method, path)按文档顺序遍历 OpenAPI 规范中的 对象。对于每个路径,以及该路径上定义的每种 HTTP 方法(GET、POST、PUT、PATCH、DELETE),将 记录为一个操作。构建全部操作的有序列表。总数为 M。
paths(method, path)Collect entity IDs upfront
提前收集实体 ID
Before entering the loop, scan all operations in the enumerated list for path parameters. For each unique path parameter name:
- Cross-reference with the Entity Reference section of to determine which entity the parameter refers to.
api-reference.md - Build a deduplicated set of .
(parameter_name, entity_type, description)
If the set is non-empty, prompt the user once for all values:
The operations in this spec require the following entity IDs:
- `docId` (string) — references a Doc entity. Used by 8 operations. Please provide an existing Doc ID.
- `pageIdOrName` (string) — references a Page entity. Used by 4 operations. Please provide an existing Page ID or name.Store the provided values for reuse during the loop. If no operations have path parameters, skip this step.
进入循环前,扫描枚举列表中的所有操作,查找 path 参数。对于每个唯一的 path 参数名称:
- 与 的 Entity Reference 部分交叉核对,确定该参数指向哪个实体。
api-reference.md - 构建去重后的 集合。
(parameter_name, entity_type, description)
如果集合非空,只向用户提示一次,一次性收集所有值:
The operations in this spec require the following entity IDs:
- `docId` (string) — references a Doc entity. Used by 8 operations. Please provide an existing Doc ID.
- `pageIdOrName` (string) — references a Page entity. Used by 4 operations. Please provide an existing Page ID or name.存储提供的值,以便在循环中重复使用。如果没有操作包含 path 参数,则跳过此步骤。
Loop counters
循环计数器
Initialize: , , , , , , .
completed = 0passed = 0fixed = 0failed = 0skipped = 0auth_halted = falseany_2xx_seen = falseFor each operation in the enumerated list, in order, reset the per-operation retry state:
- — incremented every time a curl request is executed for this operation.
attempt_count = 0 - — after each attempt, append:
retry_history = [].{ attempt_number, status_code, error_summary, fix_applied_if_any } - — the
last_failure_signature = nullpair from the most recent failed attempt.(status_code, error_message_key)
Then execute, per operation:
- Set the current operation to .
(method, path) - Operation Analysis — Step 13.1.
- Request Execution and Response Validation — Step 13.2.
- If is true, exit the loop immediately — do NOT proceed to steps 5–9. Jump to Step 14.
auth_halted - Increment .
completed - Classify the result (,
passed,fixed, orfailed) and update the corresponding counter.skipped - Emit the progress line: — append
Validation: {completed}/{M} | passed {X} | fixed {Y} | failed {Z}only when| skipped {S}.skipped > 0 - If the operation failed, emit a detail line: .
✗ {METHOD} {path} {status_code} — {reason} - Proceed to the next operation.
After all operations are processed (or the loop is halted by an auth failure), proceed to Step 14 (Final Report).
▸ STOP — Do not enter the loop until all entity IDs are collected (if any were needed).
初始化:、、、、、、。
completed = 0passed = 0fixed = 0failed = 0skipped = 0auth_halted = falseany_2xx_seen = false按顺序处理每个操作,并为该操作重置重试状态:
- ——每次执行该操作的 curl 请求时递增。
attempt_count = 0 - ——每次尝试后追加:
retry_history = []。{ attempt_number, status_code, error_summary, fix_applied_if_any } - ——最近一次失败尝试的
last_failure_signature = null对。(status_code, error_message_key)
然后按操作执行:
- 将当前操作设为 。
(method, path) - 操作分析——Step 13.1。
- 请求执行与响应验证——Step 13.2。
- 如果 为 true,立即退出循环——不要继续执行第 5~9 步。转到 Step 14。
auth_halted - 递增 。
completed - 分类结果(、
passed、fixed或failed),并更新对应计数器。skipped - 输出进度行:——仅当
Validation: {completed}/{M} | passed {X} | fixed {Y} | failed {Z}时追加skipped > 0。| skipped {S} - 如果操作失败,输出详情行:。
✗ {METHOD} {path} {status_code} — {reason} - 继续处理下一个操作。
处理完所有操作后,或循环因认证失败而停止后,进入 Step 14(最终报告)。
▸ 停止——在收集完所有需要的实体 ID 之前,不要进入循环。
Step 13.1 — Operation Analysis
Step 13.1——操作分析
Read the current operation from the loop and extract everything needed to construct an HTTP request.
13.1.1 — Identify the current operation. The operation's is already determined by the enumeration.
(method, path)13.1.2 — Extract the operation definition. From the spec:
- HTTP method (GET, POST, PUT, DELETE, PATCH).
- Path template (e.g., ).
/docs/{docId}/pages/{pageIdOrName} - Path parameters — for each: name, type, required (yes/no).
- Query parameters — for each: name, type, required, default value.
- Request body schema — if the method has a definition (typically POST, PUT, PATCH). Extract required fields and their types.
requestBody - Expected success response — the 2XX status code declared in the spec's section (e.g.,
responses,200,201). If multiple 2XX codes exist, note all of them.202 - Response body schema — the schema under . If the schema uses
responses.{status}.content.application/json.schema, resolve the reference by looking up$refin the spec. If no response body is defined (e.g., 204), note "no body."components/schemas/{name} - Security requirements — which security scheme the operation uses (from the operation-level or spec-level field).
security
13.1.3 — Substitute entity IDs. For each path parameter in the current operation, substitute the stored value into the path template. If a path parameter was not collected during enumeration (an unexpected parameter), ask the user for it now. If the operation has no path parameters, skip this sub-step.
13.1.4 — Verify readiness. Before proceeding, verify internally that the operation definition is fully extracted and all required entity IDs have been provided.
从循环中读取当前操作,提取构造 HTTP 请求所需的全部信息。
**13.1.1——识别当前操作。**循环已经确定该操作的 。
(method, path)**13.1.2——提取操作定义。**从规范中提取:
- HTTP 方法(GET、POST、PUT、DELETE、PATCH)。
- 路径模板(例如 )。
/docs/{docId}/pages/{pageIdOrName} - Path 参数——每个参数的名称、类型、是否必需。
- Query 参数——每个参数的名称、类型、是否必需、默认值。
- 请求体 schema——如果方法包含 定义(通常是 POST、PUT、PATCH),提取必需字段及其类型。
requestBody - 预期成功响应——规范 部分中声明的 2XX 状态码(例如
responses、200、201)。如果存在多个 2XX 状态码,请全部记录。202 - 响应体 schema——下的 schema。如果 schema 使用
responses.{status}.content.application/json.schema,通过查找规范中的$ref解析引用。如果没有定义响应体(例如 204),则记录“no body”。components/schemas/{name} - 安全要求——该操作使用的安全方案(来自操作级或规范级 字段)。
security
**13.1.3——替换实体 ID。**对于当前操作中的每个 path 参数,将存储的值替换到路径模板中。如果某个 path 参数未在枚举期间收集(意外参数),现在询问用户。如果没有 path 参数,则跳过此子步骤。
**13.1.4——验证就绪状态。**继续之前,在内部验证是否已完整提取操作定义,并已提供所有必需实体 ID。
Step 13.2 — Request Execution and Response Validation
Step 13.2——请求执行与响应验证
Construct the HTTP request, execute it against the live SaaS, and validate the response.
构造 HTTP 请求,针对实时 SaaS 执行,并验证响应。
13.2.1 — Construct the curl command
13.2.1——构造 curl 命令
Build the curl command from the operation definition.
URL. Combine the base URL with the path template, substituting path parameters with user-provided values.
Example: .
https://coda.io/apis/v1/docs/AbCDeFGH/pages/canvas-abc123Method. Use the flag (e.g., , ).
-X-X GET-X POSTAuthentication header. Construct based on the auth type from . Use shell substitution to inject the credential from :
api-reference.mdconfig.properties-
Bearer token:bash
-H "Authorization: Bearer $(grep '^CODA_API_TOKEN=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)" -
Basic auth:bash
-H "Authorization: Basic $(echo -n "$(grep '^API_USER=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-):$(grep '^API_PASS=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)" | base64)" -
API Key (header):bash
-H "{header_name}: $(grep '^API_KEY=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)" -
API Key (query parameter): Append the credential as a URL query parameter. Usefor the first parameter,
?for subsequent ones:&bash"https://api.example.com/endpoint?{param_name}=$(grep '^API_KEY=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)"For APIs requiring multiple query-parameter credentials (e.g., separateandkeyparams):tokenbash"https://api.example.com/endpoint?key=$(grep '^TRELLO_API_KEY=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)&token=$(grep '^TRELLO_API_TOKEN=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)"If the URL already has query parameters (from 13.1.2 required query params), append with.&
Content-Type header. (include for all requests).
-H "Content-Type: application/json"Request body. If the operation requires a body (POST, PUT, PATCH), construct a minimal JSON payload using only the required fields from the spec's request body schema. Use realistic placeholder values matching the field types and constraints. Pass via .
-d '{...}'Response capture. Add to suppress progress output, append the HTTP status code on the last line, and dump response headers to a temporary file for inspection when needed (e.g., on 429 responses).
-s -w "\n%{http_code}" -D /tmp/validation_headers.txtRetry-After根据操作定义构造 curl 命令。
**URL。**将 base URL 与路径模板结合,并把 path 参数替换为用户提供的值。
例如:。
https://coda.io/apis/v1/docs/AbCDeFGH/pages/canvas-abc123**方法。**使用 标志(例如 、)。
-X-X GET-X POST**认证 header。**根据 中的认证类型进行构造。使用 shell 替换从 注入凭据:
api-reference.mdconfig.properties-
Bearer token:bash
-H "Authorization: Bearer $(grep '^CODA_API_TOKEN=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)" -
Basic auth:bash
-H "Authorization: Basic $(echo -n "$(grep '^API_USER=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-):$(grep '^API_PASS=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)" | base64)" -
API Key(header):bash
-H "{header_name}: $(grep '^API_KEY=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)" -
**API Key(query 参数):**将凭据作为 URL query 参数追加。第一个参数使用,后续参数使用
?:&bash"https://api.example.com/endpoint?{param_name}=$(grep '^API_KEY=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)"如果 API 需要多个 query 参数凭据(例如独立的和key参数):tokenbash"https://api.example.com/endpoint?key=$(grep '^TRELLO_API_KEY=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)&token=$(grep '^TRELLO_API_TOKEN=' {PROJECT_FOLDER}/config.properties | cut -d'=' -f2-)"如果 URL 已经包含 query 参数(来自 13.1.2 中的必需 query 参数),则使用追加。&
Content-Type header。(所有请求都包含)。
-H "Content-Type: application/json"**请求体。**如果操作需要请求体(POST、PUT、PATCH),则使用规范请求体 schema 中仅包含必需字段的字段,构造最小 JSON payload。使用符合字段类型和约束的合理占位值。通过 传入。
-d '{...}'**响应捕获。**添加 ,以抑制进度输出,在最后一行附加 HTTP 状态码,并将响应 header 写入临时文件,以便在需要时检查(例如 429 响应中的 )。
-s -w "\n%{http_code}" -D /tmp/validation_headers.txtRetry-After13.2.2 — Destructive operation confirmation
13.2.2——破坏性操作确认
Before executing the curl command, check whether the current operation is destructive:
- DELETE (any entity) — always destructive.
- PUT that replaces an entire entity — destructive (overwrites existing state).
PATCH operations are NOT considered destructive — they apply partial updates and are generally safe. POST (create) operations are NOT destructive — they create new entities, not modify existing ones.
If the operation IS destructive:
-
Warn the user before executing:
⚠️ Destructive operation: {METHOD} {path} This will {consequence} the {entity_type} with ID `{entity_id}`. This action may not be reversible. Proceed? (yes / skip)Whereis:{consequence}- DELETE → "permanently delete"
- PUT → "overwrite all fields of"
-
If the user says "yes" (or equivalent affirmative) → proceed to 13.2.3 and execute the request.
-
If the user says "skip" (or equivalent negative) → do NOT execute the request. Classify the operation as skipped. Increment thecounter. Emit a progress line with a skip detail:
skipped⏭ {METHOD} {path} skipped — user declined destructive operationProceed directly to 13.2.7. Do not count this as a failure.
If the operation is NOT destructive, proceed to 13.2.3 without any prompt.
执行 curl 命令前,检查当前操作是否具有破坏性:
- DELETE(任何实体)——始终属于破坏性操作。
- PUT——会替换整个实体,属于破坏性操作(覆盖现有状态)。
PATCH 操作不被视为破坏性操作——它们执行部分更新,通常是安全的。POST(create)操作也不具有破坏性——它们创建新实体,不会修改现有实体。
如果操作具有破坏性:
-
执行前警告用户:
⚠️ Destructive operation: {METHOD} {path} This will {consequence} the {entity_type} with ID `{entity_id}`. This action may not be reversible. Proceed? (yes / skip)其中:{consequence}- DELETE → “permanently delete”
- PUT → “overwrite all fields of”
-
如果用户回答“yes”或等效肯定表达 → 继续执行 13.2.3 并发出请求。
-
如果用户回答“skip”或等效否定表达 → 不要执行请求。将操作分类为 skipped。递增计数器。输出带跳过详情的进度行:
skipped⏭ {METHOD} {path} skipped — user declined destructive operation直接进入 13.2.7。不要将其计为失败。
如果操作不具有破坏性,则无需提示,直接进入 13.2.3。
13.2.3 — Execute the request
13.2.3——执行请求
Run the curl command via the Bash tool. The shell substitution resolves the credential inline — the actual value never appears in conversation context.
Increment for the current operation. After parsing the response (13.2.4), if non-2XX: append an entry to (attempt_number, status_code, error_summary, fix_applied_if_any) and update with .
attempt_countretry_historylast_failure_signature(status_code, key error details from response body)通过 Bash 工具运行 curl 命令。shell 替换会内联解析凭据——实际值绝不会出现在对话上下文中。
递增当前操作的 。解析响应(13.2.4)后,如果状态不是 2XX:追加一条 (attempt_number、status_code、error_summary、fix_applied_if_any),并使用 更新 。
attempt_countretry_history(status_code, 响应体中的关键错误详情)last_failure_signature13.2.4 — Parse the response
13.2.4——解析响应
From the curl output:
- Status code: the last line of output (from ).
-w "\n%{http_code}" - Response body: all lines except the last. If empty, the response has no body.
- Response headers: available in if needed by error handlers (e.g.,
/tmp/validation_headers.txtfor 429 responses).Retry-After
Verify the status code is in the 2XX range (200–299). If the status code IS 2XX, set — this tracks that the credentials worked at least once during this session. If the status code is NOT 2XX, proceed to 13.2.5 (error response schema check) before recording the result.
any_2xx_seen = true从 curl 输出中获取:
- **状态码:**输出的最后一行(来自 )。
-w "\n%{http_code}" - **响应体:**除最后一行外的所有行。如果为空,则响应没有 body。
- **响应 header:**如有需要,可从 获取,供错误处理器使用(例如处理 429 响应时的
/tmp/validation_headers.txt)。Retry-After
验证状态码处于 2XX 范围(200~299)。如果状态码为 2XX,将 ——用于跟踪凭据在本次会话中至少成功使用过一次。如果状态码不是 2XX,在记录结果前进入 13.2.5(错误响应 schema 检查)。
any_2xx_seen = true13.2.5 — Error response schema check (non-2XX only)
13.2.5——错误响应 Schema 检查(仅非 2XX)
Before classifying the error, check whether the error response body matches the error schema defined in the spec:
- Look up the error response schema in the spec for the actual status code: . If no schema is defined for this specific status code, also check for a
responses.{status_code}.content.application/json.schemaresponse schema.default - If no error schema exists in the spec → skip schema checking.
- If an error schema exists and the response has a body → compare the error body against the schema using the same comparison logic from 13.2.7 Branch A (steps 1–6).
- If mismatches are found → apply the same auto-fix strategies from 13.2.7 to correct the error schema in the spec. Write the updated spec to disk and log the fixes.
- No re-validation is needed for error schemas — the error itself still stands. The agent is only correcting the spec's description of the error response format.
After error schema checking, proceed to 13.2.6 to classify and handle the error.
分类错误之前,检查错误响应体是否匹配规范中定义的错误 schema:
- 在规范中查找实际状态码对应的错误响应 schema:。如果未为该具体状态码定义 schema,也检查
responses.{status_code}.content.application/json.schema响应 schema。default - 如果规范中没有错误 schema → 跳过 schema 检查。
- 如果存在错误 schema 且响应有 body → 使用与 13.2.7 Branch A(步骤 1~6)相同的比较逻辑,将错误 body 与 schema 比较。
- 如果发现不匹配 → 应用 13.2.7 中相同的自动修复策略修正错误 schema。将更新后的规范写入磁盘并记录修复。
- 无需重新验证错误 schema——错误本身仍然存在。Agent 只是修正规范对错误响应格式的描述。
完成错误 schema 检查后,进入 13.2.6,分类并处理错误。
13.2.6 — Error cause handling (non-2XX only)
13.2.6——错误原因处理(仅非 2XX)
Determine the appropriate action based on the status code.
401/403 — Authorization/Permission Error. The credentials are invalid, expired, or lack permissions. The agent cannot fix credentials autonomously — this is a blocking exception that halts the entire validation loop.
-
Classify the failure context:
- If → permanent auth failure (wrong credentials or insufficient permissions).
any_2xx_seen == false - If → mid-session token expiration (credentials worked before but have now expired).
any_2xx_seen == true
- If
-
Record the auth failure:
- Set .
auth_halted = true - Note the current operation and the status code (401 or 403).
(method, path) - Note the failure context (permanent or mid-session).
- Set
-
Emit a halted progress line:
Validation: {completed}/{M} | passed {X} | fixed {Y} | failed {Z} | AUTH HALTED ⛔ {METHOD} {path} {status_code} — {reason from response body}Use(not⛔) to visually distinguish auth halts from normal failures.✗ -
Do NOT incrementor
completed— the operation was not fully processed.failed -
Do NOT proceed to 13.2.7 or 13.2.8.
-
Return to the validation loop, which checksand exits to Step 14.
auth_halted
5XX (500–599) — Server Error. The SaaS service is unavailable or experiencing server-side issues. This is not a problem with the spec or the request — the agent cannot fix it.
- Classify as failed with reason "server error ({status_code})" (e.g., "server error (503)").
- Do NOT retry the operation.
- Skip 13.2.7 and proceed directly to 13.2.8 to record the result.
404 — Not Found (entity ID remediation). The endpoint requires a reference to an existing entity, but the entity was not found. This typically means the entity ID provided during upfront collection is wrong, stale, or refers to a deleted entity.
-
Identify the suspect path parameter(s):
- Extract all path parameters from the current operation's path template.
- For each path parameter, note the value currently substituted (from the stored entity ID map).
- If the path has multiple parameters, use the response body to infer which entity was not found. If the response body does not indicate which parameter is wrong, suspect the most specific (deepest-nested) parameter first.
-
Ask the user for a corrected entity ID:If one parameter is clearly suspect:
404 Not Found — {METHOD} {path} The API returned 404, which means the entity referenced by `{suspect_param}` (current value: `{current_value}`) was not found. Please provide a valid {entity_type} ID for `{suspect_param}`:If multiple path parameters might be wrong:404 Not Found — {METHOD} {path} The API returned 404. The following entity IDs may be incorrect: - `{param1}` (current value: `{value1}`) — {entity_type_1} - `{param2}` (current value: `{value2}`) — {entity_type_2} Please provide corrected values (or confirm if a value is correct): -
Update stored entity IDs: after the user provides corrected value(s), update the stored entity ID map so that all subsequent operations using the same parameter name(s) will use the corrected value(s).
-
Reconstruct and retry:
- Rebuild the curl command from 13.2.1 using the corrected entity ID(s).
- If the operation is destructive (DELETE or PUT), re-trigger the 13.2.2 destructive operation confirmation before executing.
- Execute the rebuilt curl command (13.2.3) and parse the response (13.2.4).
-
Evaluate the retry result:
- 2XX response → the corrected ID worked. Proceed to 13.2.7 for schema validation as normal.
- 404 again (same error) → classify as failed with reason "404 — entity not found (user-provided ID also not found)". Do NOT ask the user again. Proceed to 13.2.8.
- Different non-2XX error → pass the new error through 13.2.5 and 13.2.6 as if it were the initial response.
-
Retry limit: one user-interactive retry per 404. If the retry itself returns 404, fail immediately.
400 — Bad Request (three-tier remediation). The request was rejected by the API due to malformed syntax, missing fields, or invalid values. The agent attempts autonomous remediation through three escalating tiers. No user interaction — this is fully autonomous. All retries within this handler are subject to the retry strategy below. Before each re-execution of 13.2.3, verify and run the progress gate.
attempt_count < 10- Tier 1 — Error message diagnosis:
- Parse the error response body for actionable details (e.g., "field X is required", "invalid value for parameter Y", "unknown field Z").
- If the message identifies a specific field, constraint, or format issue:
- Fix the request accordingly (add missing field, correct a value, remove an invalid field).
- Re-execute the curl command (13.2.3) and parse the response (13.2.4).
- 2XX → proceed to 13.2.7 (schema validation).
- Still 400 → check progress gate. If no progress, classify as failed and proceed to 13.2.8. If progress, escalate to Tier 2.
- Different non-2XX → pass through 13.2.5 and 13.2.6 for the new error code. The 400 tier sequence does NOT continue.
- If the message is NOT actionable → skip directly to Tier 2 without retrying.
- Tier 2 — consultation:
api-reference.md- Read the relevant sections of :
api-reference.md- Entity Reference for the entity being operated on — required fields, field types, enum values, constraints.
- CRUD Endpoint Catalog for the current endpoint — request body format, required parameters.
- Compare the current request against the documented requirements.
- Identify discrepancies and reconstruct the request to match the documented format.
- Re-execute the curl command (13.2.3) and parse the response (13.2.4).
- 2XX → proceed to 13.2.7.
- Still 400 → check progress gate. If no progress, classify as failed and proceed to 13.2.8. If progress, escalate to Tier 3.
- Different non-2XX → pass through 13.2.5 and 13.2.6 for the new error code.
- Read the relevant sections of
- Tier 3 — Official API documentation research:
- Use WebSearch and/or WebFetch to find the official SaaS API documentation for this endpoint.
- Look for: required fields, field format/constraints, valid values, API-specific validation rules not captured in .
api-reference.md - Apply any discovered fixes to the request.
- Re-execute the curl command (13.2.3) and parse the response (13.2.4).
- 2XX → proceed to 13.2.7.
- Still 400 → classify as failed with reason "400 — {error message} (all remediation tiers exhausted)". Proceed to 13.2.8.
- Different non-2XX → pass through 13.2.5 and 13.2.6 for the new error code.
429 — Too Many Requests (Rate Limit). The API is rate-limiting requests. The agent waits and retries autonomously — no user interaction.
- Check for header:
Retry-After- Read and look for a
/tmp/validation_headers.txtheader (case-insensitive).Retry-After - If present as an integer (e.g., ) → wait duration is that many seconds.
Retry-After: 5 - If present as an HTTP date → compute seconds until that time. If the date is in the past, treat as 0.
- Cap: if the computed wait exceeds 120 seconds, cap at 120 seconds.
- If no header is present → use exponential backoff (step 2).
Retry-After
- Read
- Exponential backoff (when no header):
Retry-After- First 429: wait 2 seconds.
- Second consecutive 429: wait 4 seconds.
- Third consecutive 429: wait 8 seconds.
- Continue doubling, capped at 120 seconds per wait.
- Wait and retry:
- Execute via Bash to wait the computed duration.
sleep {seconds} - Re-execute the same curl command (13.2.3) and parse the response (13.2.4).
- Execute
- Evaluate the retry result:
- 2XX → rate limit cleared. Proceed to 13.2.7 for schema validation.
- 429 again → still rate-limited. Repeat from step 1.
- Different non-2XX → pass through 13.2.5 and 13.2.6 for the new status code. The 429 retry sequence does NOT continue.
- Progress gate exception: repeated 429s bypass the progress gate. Before each retry, verify .
attempt_count < 10 - Exhaustion: if the absolute ceiling (10 attempts) is reached and the response is still 429, classify as failed with reason "429 — rate-limited (retry limit reached after {N} attempts)". Proceed to 13.2.8.
- Silent operation: do NOT emit progress lines during 429 waits. Only emit the final result when the operation completes.
All other non-2XX status codes (e.g., 409 Conflict, 422 Unprocessable Entity, 405 Method Not Allowed). Same three-tier remediation as 400. Tier 1 examines error-code-specific guidance:
- 409 Conflict: look for resource name/ID conflicts — change the conflicting value.
- 422 Unprocessable Entity: look for field-level validation failures — correct the field.
- 405 Method Not Allowed: check for an response header listing valid methods — correct the HTTP method.
Allow
Tiers 2 and 3 are identical to 400.
根据状态码确定适当操作。
**401/403——认证/权限错误。**凭据无效、已过期或缺少权限。Agent 无法自主修复凭据——这是一个会终止整个验证循环的阻断性异常。
-
分类失败上下文:
- 如果 → 永久认证失败(凭据错误或权限不足)。
any_2xx_seen == false - 如果 → 会话中 token 过期(凭据此前有效,但现在已过期)。
any_2xx_seen == true
- 如果
-
记录认证失败:
- 设置 。
auth_halted = true - 记录当前操作 和状态码(401 或 403)。
(method, path) - 记录失败上下文(永久或会话中过期)。
- 设置
-
输出终止进度行:
Validation: {completed}/{M} | passed {X} | fixed {Y} | failed {Z} | AUTH HALTED ⛔ {METHOD} {path} {status_code} — {reason from response body}使用而不是⛔,以直观区分认证终止和普通失败。✗ -
不要递增或
completed——该操作未被完整处理。failed -
不要继续执行 13.2.7 或 13.2.8。
-
返回验证循环;循环检查到后退出并进入 Step 14。
auth_halted
**5XX(500~599)——服务器错误。**SaaS 服务不可用或出现服务端问题。这不是规范或请求的问题,Agent 无法修复。
- 分类为 failed,理由为“server error ({status_code})”(例如“server error (503)”)。
- 不要重试该操作。
- 跳过 13.2.7,直接进入 13.2.8 记录结果。
**404——Not Found(实体 ID 修复)。**端点要求引用现有实体,但未找到该实体。这通常意味着提前收集的实体 ID 错误、已失效,或指向已删除的实体。
-
识别可疑 path 参数:
- 从当前操作的路径模板中提取所有 path 参数。
- 对每个 path 参数,记录当前替换进去的值(来自已存储的实体 ID 映射)。
- 如果路径包含多个参数,使用响应 body 判断哪个实体未找到。如果响应 body 未明确指出哪个参数有误,优先怀疑最具体(嵌套最深)的参数。
-
要求用户提供修正后的实体 ID:如果可以明确识别一个可疑参数:
404 Not Found — {METHOD} {path} The API returned 404, which means the entity referenced by `{suspect_param}` (current value: `{current_value}`) was not found. Please provide a valid {entity_type} ID for `{suspect_param}`:如果多个 path 参数可能有误:404 Not Found — {METHOD} {path} The API returned 404. The following entity IDs may be incorrect: - `{param1}` (current value: `{value1}`) — {entity_type_1} - `{param2}` (current value: `{value2}`) — {entity_type_2} Please provide corrected values (or confirm if a value is correct): -
**更新已存储的实体 ID:**用户提供修正值后,更新实体 ID 映射,使后续使用相同参数名称的所有操作都采用修正值。
-
重新构造并重试:
- 使用修正后的实体 ID,按照 13.2.1 重新构造 curl 命令。
- 如果操作具有破坏性(DELETE 或 PUT),在执行前重新触发 13.2.2 破坏性操作确认。
- 执行重新构造的 curl 命令(13.2.3)并解析响应(13.2.4)。
-
评估重试结果:
- 2XX 响应 → 修正后的 ID 有效。像正常流程一样进入 13.2.7 进行 schema 验证。
- 再次返回 404(同一错误) → 分类为 failed,理由为“404 — entity not found (user-provided ID also not found)”。不要再次询问用户。进入 13.2.8。
- 返回不同的非 2XX 错误 → 将新错误传递给 13.2.5 和 13.2.6,像处理初始响应一样处理。
-
**重试上限:**每个 404 只允许一次用户交互式重试。如果重试仍返回 404,立即失败。
**400——Bad Request(三级修复)。**API 因语法错误、字段缺失或值无效而拒绝请求。Agent 通过三级递进策略自主修复。此过程无需用户交互,完全自主执行。本处理器内的所有重试均受下述重试策略约束。每次重新执行 13.2.3 前,验证 并运行进度门控。
attempt_count < 10- 第 1 级——错误消息诊断:
- 解析错误响应 body,寻找可操作详情(例如“field X is required”“invalid value for parameter Y”“unknown field Z”)。
- 如果消息明确指出某个字段、约束或格式问题:
- 相应修正请求(添加缺失字段、修正值、删除无效字段)。
- 重新执行 curl 命令(13.2.3)并解析响应(13.2.4)。
- 2XX → 进入 13.2.7(schema 验证)。
- 仍为 400 → 检查进度门控。如果没有进展,分类为 failed 并进入 13.2.8。如果有进展,则升级到第 2 级。
- 出现不同的非 2XX 错误 → 将新错误传递给 13.2.5 和 13.2.6。400 级处理序列不再继续。
- 如果消息不可操作 → 不重试,直接进入第 2 级。
- 第 2 级——查阅 :
api-reference.md- 读取相关部分:
- Entity Reference,查看被操作实体的必需字段、字段类型、enum 值和约束。
- CRUD Endpoint Catalog,查看当前端点的请求 body 格式和必需参数。
- 将当前请求与记录的规范要求进行比较。
- 识别差异,并重新构造请求以匹配记录的格式。
- 重新执行 curl 命令(13.2.3)并解析响应(13.2.4)。
- 2XX → 进入 13.2.7。
- 仍为 400 → 检查进度门控。如果没有进展,分类为 failed 并进入 13.2.8。如果有进展,则升级到第 3 级。
- 出现不同的非 2XX 错误 → 将新错误传递给 13.2.5 和 13.2.6。
- 读取相关部分:
- 第 3 级——研究官方 API 文档:
- 使用 WebSearch 和/或 WebFetch 查找该端点的官方 SaaS API 文档。
- 查找:必需字段、字段格式/约束、有效值,以及 中未捕获的 API 专属验证规则。
api-reference.md - 应用发现的修正。
- 重新执行 curl 命令(13.2.3)并解析响应(13.2.4)。
- 2XX → 进入 13.2.7。
- 仍为 400 → 分类为 failed,理由为“400 — {error message} (all remediation tiers exhausted)”。进入 13.2.8。
- 出现不同的非 2XX 错误 → 将新错误传递给 13.2.5 和 13.2.6。
**429——Too Many Requests(速率限制)。**API 正在限制请求速率。Agent 会自主等待并重试,无需用户交互。
- 检查 Retry-After header:
- 读取 ,查找
/tmp/validation_headers.txtheader(不区分大小写)。Retry-After - 如果它是整数(例如 )→ 等待对应秒数。
Retry-After: 5 - 如果它是 HTTP 日期 → 计算到该时间点的秒数。如果日期已过去,则视为 0。
- **上限:**如果计算出的等待时间超过 120 秒,则限制为 120 秒。
- 如果没有 header → 使用指数退避(步骤 2)。
Retry-After
- 读取
- 指数退避(没有 Retry-After header 时):
- 第一次 429:等待 2 秒。
- 连续第二次 429:等待 4 秒。
- 连续第三次 429:等待 8 秒。
- 继续翻倍,但每次等待上限为 120 秒。
- 等待并重试:
- 通过 Bash 执行 ,等待计算出的时长。
sleep {seconds} - 重新执行相同的 curl 命令(13.2.3)并解析响应(13.2.4)。
- 通过 Bash 执行
- 评估重试结果:
- 2XX → 速率限制已解除。进入 13.2.7 进行 schema 验证。
- 再次返回 429 → 仍受速率限制。从步骤 1 重新开始。
- 出现不同的非 2XX 错误 → 将新错误传递给 13.2.5 和 13.2.6。429 重试序列不再继续。
- **进度门控例外:**重复的 429 绕过进度门控。每次重试前,验证 。
attempt_count < 10 - **耗尽:**如果达到绝对上限(10 次尝试)后仍返回 429,分类为 failed,理由为“429 — rate-limited (retry limit reached after {N} attempts)”。进入 13.2.8。
- **静默操作:**429 等待期间不要输出进度行。仅在操作完成时输出最终结果。
**所有其他非 2XX 状态码(例如 409 Conflict、422 Unprocessable Entity、405 Method Not Allowed)。**采用与 400 相同的三级修复策略。第 1 级检查错误码专属指引:
- **409 Conflict:**查找资源名称/ID 冲突——修改冲突值。
- **422 Unprocessable Entity:**查找字段级验证失败——修正字段。
- **405 Method Not Allowed:**检查列出有效方法的 响应 header——修正 HTTP 方法。
Allow
第 2 级和第 3 级与 400 相同。
Retry strategy
重试策略
This unified framework governs all retry scenarios in 13.2. Individual error handlers (400, 429, others) and schema auto-fix (13.2.7) reference it for retry decisions.
Failure signature. A pair of . Key error details = the primary error message or error code from the response body, ignoring dynamic content like timestamps, request IDs, or trace IDs. Two failures are "the same" when both status code AND key error details match; "different" when either differs.
(HTTP status code, key error details)Progress gate. Before any handler re-executes 13.2.3, compare the current failure signature to :
last_failure_signature- Different = forward progress. Allow retry (subject to ceiling).
- Same = no progress. Stop retrying immediately — classify as failed (unresolvable) and proceed to 13.2.8.
429 exception. Repeated 429 responses bypass the progress gate. A 429 is a transient condition (the rate limit is active), not a persistent failure.
Absolute ceiling. Maximum 10 total attempts per operation (1 initial + up to 9 retries). The is shared across ALL handlers for the same operation. Before any re-execution of 13.2.3, check . If the ceiling is reached, stop immediately regardless of progress.
attempt_countattempt_count < 10Exhaustion behavior. When retries stop — whether by progress gate (same failure) or by absolute ceiling — mark the operation as failed (unresolvable) and include:
- Total .
attempt_count - Whether stopped by "no progress" (progress gate) or "retry limit reached" (ceiling).
- The full .
retry_history
Proceed to 13.2.8 with the failure classification.
此统一框架管理 13.2 中的所有重试场景。单个错误处理器(400、429、其他)和 schema 自动修复(13.2.7)均引用此策略进行重试决策。
**失败签名。**一个 对。关键错误详情 = 响应 body 中的主要错误消息或错误码,忽略时间戳、请求 ID、trace ID 等动态内容。当状态码和关键错误详情都相同时,两次失败视为“相同”;任意一项不同时,则视为“不同”。
(HTTP status code, key error details)**进度门控。**任何处理器重新执行 13.2.3 前,将当前失败签名与 比较:
last_failure_signature- 不同 = 取得进展。允许重试(受上限约束)。
- 相同 = 没有进展。立即停止重试——分类为 failed(无法解决),进入 13.2.8。
**429 例外。**重复的 429 响应绕过进度门控。429 是一种瞬时状况(速率限制当前生效),而不是持续性故障。
**绝对上限。**每个操作最多执行 10 次(1 次初始尝试 + 最多 9 次重试)。 由同一操作的所有处理器共享。每次重新执行 13.2.3 前,检查 。如果达到上限,无论是否有进展都立即停止。
attempt_countattempt_count < 10**耗尽行为。**当重试停止时——无论是进度门控判定“相同”,还是达到绝对上限——将操作标记为 failed(无法解决),并包含:
- 总计 。
attempt_count - 停止原因:“没有进展”(进度门控)或“达到重试上限”(上限)。
- 完整的 。
retry_history
进入 13.2.8 记录失败分类。
13.2.7 — Validate the response
13.2.7——验证响应
Branch based on whether the response has a body.
Branch A: 2XX response WITH body. Compare the actual response JSON against the spec's response schema:
- Parse the response body as JSON. If parsing fails, report "Response is not valid JSON" and stop.
- Resolve the spec schema. Read the response schema for the matched status code from the spec. If it uses , follow the reference to
$refand expand it. Continue resolving any nestedcomponents/schemas/{name}references.$ref - Compare fields. For each field in the response:
- Check if the field is defined in the spec schema's .
properties - If defined, check that the JSON type matches the schema type:
- ↔ string
string - or
integer↔ numbernumber - ↔ boolean
boolean - ↔ array
array - ↔ object
object
- If the field is NOT in the schema, note it as an extra field.
- Check if the field is defined in the spec schema's
- Check required fields. For each field in the schema's array, verify the field exists in the response. If missing, note it as a missing required field.
required - Check nested objects (one level). For fields of type that have a
objectdefinition in the schema, repeat steps 3–4 on the nested object.properties - Check arrays. For fields of type , verify the response value is an array. If the schema defines
array, compare the first array element against theitemsschema (if the array is non-empty).items - Determine result:
- If NO mismatches found → classify as passed. Proceed to 13.2.8.
- If mismatches found → apply the auto-fix strategies below, then re-validate.
Auto-fix strategies (Branch A only):
| Mismatch Type | Fix Strategy |
|---|---|
| Type mismatch — spec declares a different type than the response returns | Update the property's |
| Extra field — field present in the response but not in the spec schema | Add the field to the schema's |
Missing required field — spec lists a field in | Remove the field from the schema's |
| Structural mismatch — nested object/array shape differs from spec | Update the spec schema to match the actual structure. |
Apply ALL fixes for the current set of mismatches in one pass. Modify definitions (not inline response schemas) so fixes propagate to all operations that reference the same schema via . Write the updated spec to disk using the Edit tool. Log each fix applied: .
components/schemas/{name}$ref{schema_name}.{field_path}: {mismatch_type} — {description of change}Re-validate after auto-fix:
- Re-execute the same curl command from 13.2.3 (always use a fresh response).
- Parse the response using 13.2.4 logic.
- If the response is still 2XX, repeat the schema comparison (Branch A steps 1–6) using the updated spec schema.
- Evaluate:
- No mismatches → classify as fixed. Proceed to 13.2.8.
- Mismatches remain but are different from the previous attempt → forward progress. Apply additional fixes and re-validate.
- Mismatches remain and are identical → no progress. Classify as failed with reason "schema mismatch (auto-fix unsuccessful)". Proceed to 13.2.8.
- Non-2XX response on re-validation → classify as failed with the error status code and reason. Proceed to 13.2.8.
- Schema auto-fix retries share with the error handlers — do not exceed 10 total attempts.
attempt_count
Branch B: 2XX response with NO body.
- Validate that the actual HTTP status code matches the expected status code from the spec.
- If it matches → classify as passed.
- If it does not match → classify as failed with reason "status code mismatch" (report actual vs. expected).
根据响应是否有 body 选择分支。
**分支 A:2XX 响应且包含 body。**将实际响应 JSON 与规范的响应 schema 比较:
- 将响应 body 解析为 JSON。如果解析失败,报告“Response is not valid JSON”并停止。
- **解析规范 schema。**从规范中读取匹配状态码的响应 schema。如果使用 ,跟随引用找到
$ref并展开。继续解析所有嵌套components/schemas/{name}引用。$ref - **比较字段。**对于响应中的每个字段:
- 检查该字段是否已在规范 schema 的 中定义。
properties - 如果已定义,检查 JSON 类型是否与 schema 类型匹配:
- ↔ string
string - 或
integer↔ numbernumber - ↔ boolean
boolean - ↔ array
array - ↔ object
object
- 如果字段不在 schema 中,则记录为额外字段。
- 检查该字段是否已在规范 schema 的
- 检查必需字段。对于 schema 数组中的每个字段,验证响应中是否存在该字段。如果缺失,记录为缺少必需字段。
required - **检查嵌套对象(一层)。**对于类型为 且 schema 中定义了
object的字段,对嵌套对象重复步骤 3~4。properties - **检查数组。**对于类型为 的字段,验证响应值是数组。如果 schema 定义了
array,且数组非空,则将第一个数组元素与itemsschema 比较。items - 确定结果:
- 如果未发现不匹配 → 分类为 passed。进入 13.2.8。
- 如果发现不匹配 → 应用下面的自动修复策略,然后重新验证。
自动修复策略(仅分支 A):
| 不匹配类型 | 修复策略 |
|---|---|
| 类型不匹配——规范声明的类型与响应实际类型不同 | 将规范 schema 中该属性的 |
| 额外字段——响应中存在该字段,但规范 schema 中没有 | 将该字段添加到 schema 的 |
| 缺少必需字段——规范列出了该字段,但响应未返回 | 从 schema 的 |
| 结构不匹配——嵌套对象/数组结构与规范不同 | 更新规范 schema,使其匹配实际结构。 |
对当前一组不匹配应用所有修复,一次完成。修改 定义(而不是内联响应 schema),使修复能够传播到通过 引用同一 schema 的所有操作。使用 Edit 工具将更新后的规范写入磁盘。记录每项已应用修复:。
components/schemas/{name}$ref{schema_name}.{field_path}: {mismatch_type} — {description of change}自动修复后重新验证:
- 重新执行 13.2.3 中相同的 curl 命令(始终使用全新响应)。
- 使用 13.2.4 的逻辑解析响应。
- 如果响应仍为 2XX,使用更新后的规范 schema 重复 schema 比较(分支 A 步骤 1~6)。
- 评估:
- 没有不匹配 → 分类为 fixed。进入 13.2.8。
- 仍有不匹配,但与上次尝试不同 → 取得进展。应用额外修复并重新验证。
- 仍有不匹配,且与上次完全相同 → 没有进展。分类为 failed,理由为“schema mismatch (auto-fix unsuccessful)”。进入 13.2.8。
- 重新验证时返回非 2XX 响应 → 分类为 failed,并附上错误状态码和理由。进入 13.2.8。
- Schema 自动修复重试与错误处理器共享 ——总尝试次数不得超过 10 次。
attempt_count
分支 B:2XX 响应且没有 body。
- 验证实际 HTTP 状态码是否与规范中的预期状态码匹配。
- 如果匹配 → 分类为 passed。
- 如果不匹配 → 分类为 failed,理由为“status code mismatch”(报告实际值和预期值)。
13.2.8 — Record the result and emit progress
13.2.8——记录结果并输出进度
Classify the outcome:
- passed — 2XX response, schema matched (or no body, status matched). Includes operations that succeeded after 404 entity ID correction.
- fixed — 2XX response, schema did not match initially, but the agent auto-fixed the spec and re-validation succeeded.
- failed — non-2XX response after all remediation, OR 2XX response where schema auto-fix could not resolve all mismatches after retries.
- skipped — user declined to execute a destructive operation after the 13.2.2 confirmation prompt.
Auth failures (401/403) do not reach this step — they halt the loop from 13.2.6 and are reported in Step 14.
Emit a progress line to the user:
Validation: 1/5 | passed 1 | fixed 0 | failed 0
Validation: 2/5 | passed 1 | fixed 0 | failed 1
✗ POST /docs/{docId}/pages 400 — missing required field: name (3 attempts)
Validation: 3/5 | passed 2 | fixed 0 | failed 1Rules:
- One progress line per completed operation.
- Detail line ONLY for failed operations (during the loop). When , append
attempt_count > 1.({attempt_count} attempts) - Record the for failed ops and the fix summary for fixed ops — Step 14 may emit them in the final report.
retry_history - Fixed operations count as successes in the progress — no detail line in the loop.
- Do NOT print detail lines while the agent is still attempting remediation.
After recording the result, return to the loop to process the next operation. If this was the last operation, proceed to Step 14.
对结果进行分类:
- passed——2XX 响应,schema 匹配(或没有 body 且状态码匹配)。包括在修正 404 实体 ID 后成功的操作。
- fixed——2XX 响应,最初 schema 不匹配,但 Agent 自动修复规范后重新验证成功。
- failed——所有修复完成后仍返回非 2XX 响应,或者 2XX 响应的 schema 自动修复经过重试后仍无法解决所有不匹配。
- skipped——用户在 13.2.2 确认提示后拒绝执行破坏性操作。
认证失败(401/403)不会进入此步骤——它们会在 13.2.6 终止循环,并在 Step 14 中报告。
向用户输出进度行:
Validation: 1/5 | passed 1 | fixed 0 | failed 0
Validation: 2/5 | passed 1 | fixed 0 | failed 1
✗ POST /docs/{docId}/pages 400 — missing required field: name (3 attempts)
Validation: 3/5 | passed 2 | fixed 0 | failed 1规则:
- 每个已完成操作输出一行进度。
- 循环期间只为失败操作输出详情行。当 时,追加
attempt_count > 1。({attempt_count} attempts) - 为失败操作记录 ,为已修复操作记录修复摘要——Step 14 可能会在最终报告中输出这些信息。
retry_history - Fixed 操作在进度中计为成功——循环中不输出详情行。
- Agent 仍在尝试修复期间,不要输出详情行。
记录结果后,返回循环处理下一个操作。如果是最后一个操作,则进入 Step 14。
Step 14: Final Report and Knowledge Ready
Step 14:最终报告与知识就绪
This step executes after all operations in the validation loop have been processed, or after an auth failure halts the loop early.
所有操作都完成验证后,或认证失败提前终止循环后,执行此步骤。
Auth failure — loop halted early
认证失败——循环提前终止
If is true, present the auth failure report instead of the normal summary.
auth_haltedPermanent auth failure ():
any_2xx_seen == falseAuth failure — validation halted.
⛔ {METHOD} {path} {status_code} — {reason}
The API returned {status_code} on the first operation attempted. The credentials in
config.properties may be invalid or lack permissions for this API.
Please verify the credentials and re-run validation.Mid-session token expiration ():
any_2xx_seen == trueAuth failure — validation halted after {completed}/{M} operations.
⛔ {METHOD} {path} {status_code} — {reason}
Completed before failure: passed {X}, fixed {Y}, failed {Z}
The first {completed} operations were processed, but operation {completed+1} returned {status_code}.
This likely indicates the API token has expired mid-session.
Please refresh the token in config.properties and re-run validation.
The agent will re-validate all operations from the beginning.After the auth failure report, stop. Do not present the normal summary or ask "Would you like to retry?"
如果 为 true,显示认证失败报告,而不是普通摘要。
auth_halted永久认证失败():
any_2xx_seen == falseAuth failure — validation halted.
⛔ {METHOD} {path} {status_code} — {reason}
The API returned {status_code} on the first operation attempted. The credentials in
config.properties may be invalid or lack permissions for this API.
Please verify the credentials and re-run validation.会话中 token 过期():
any_2xx_seen == trueAuth failure — validation halted after {completed}/{M} operations.
⛔ {METHOD} {path} {status_code} — {reason}
Completed before failure: passed {X}, fixed {Y}, failed {Z}
The first {completed} operations were processed, but operation {completed+1} returned {status_code}.
This likely indicates the API token has expired mid-session.
Please refresh the token in config.properties and re-run validation.
The agent will re-validate all operations from the beginning.显示认证失败报告后停止。不要显示普通摘要,也不要询问“Would you like to retry?”。
Normal completion
正常完成
Present a summary line followed by detail lines for fixed, failed, and skipped operations. Passed operations get no detail line. Append only when .
| skipped {S}skipped > 0Detail line ordering: fixed operations first (✔), then failed (✗), then skipped (⏭).
Validation complete: 5/5 | passed 2 | fixed 1 | failed 1 | skipped 1
✔ GET /docs/{docId} fixed — Doc.owner: type mismatch (object → string), Doc.sourceDoc: structural mismatch (string → object)
✗ POST /docs/{docId}/pages 400 — missing required field: name (3 attempts)
⏭ DELETE /docs/{docId} skipped — user declined destructive operationDetail line rules:
- Fixed (✔): . When
✔ {METHOD} {path} fixed — {fix_summary}, appendattempt_count > 1.({attempt_count} attempts) - Failed (✗): . When
✗ {METHOD} {path} {status_code} — {reason}, appendattempt_count > 1.({attempt_count} attempts) - Skipped (⏭): .
⏭ {METHOD} {path} skipped — user declined destructive operation
If there are failed operations (not counting skipped), present the summary and ask the user how to proceed:
{N} operation(s) could not be validated. How would you like to proceed?
1. Provide additional information so I can retry the failed operations
2. Keep the failed operations in the spec as-is (no changes to their definitions)
3. Remove the failed operations from the spec and proceed with the corrected spec
4. Cancel — stop the validation processWhen the user selects an option:
- Option 1: Present the for each failed operation so the user understands what was already tried. Accept the user's additional information, then re-run validation for just the failed operations. After re-validation, present an updated summary and repeat the decision flow if failures remain.
retry_history - Option 2: Pass the spec forward as-is. Auto-fixes applied during validation are already written to disk.
- Option 3: Remove the failed operations from the spec's object using the Edit tool. Write the updated spec to disk.
paths - Option 4: Stop. Do not pass the spec forward.
For options 1–3, after the spec is finalized, confirm the output:
Knowledge ready: {PROJECT_FOLDER}
- api-reference.md
- {apiName}.yaml
- config.propertiesIf all operations passed, were fixed, or were skipped (i.e., ), report the summary and confirm the output without further user interaction:
failed == 0Knowledge ready: {PROJECT_FOLDER}
- api-reference.md
- {apiName}.yaml
- config.propertiesThe caller (typically Step 3a) reads to inform HTTP-Connector configuration and DataWeave transforms; is the corrected, validation-tested OpenAPI spec.
build-mule-integrationapi-reference.md<apiName>.yaml显示摘要行,然后显示 fixed、failed 和 skipped 操作的详情行。Passed 操作不显示详情行。仅当 时追加 。
skipped > 0| skipped {S}详情行顺序:先显示 fixed 操作(✔),然后是 failed(✗),最后是 skipped(⏭)。
Validation complete: 5/5 | passed 2 | fixed 1 | failed 1 | skipped 1
✔ GET /docs/{docId} fixed — Doc.owner: type mismatch (object → string), Doc.sourceDoc: structural mismatch (string → object)
✗ POST /docs/{docId}/pages 400 — missing required field: name (3 attempts)
⏭ DELETE /docs/{docId} skipped — user declined destructive operation详情行规则:
- Fixed(✔):。当
✔ {METHOD} {path} fixed — {fix_summary}时,追加attempt_count > 1。({attempt_count} attempts) - Failed(✗):。当
✗ {METHOD} {path} {status_code} — {reason}时,追加attempt_count > 1。({attempt_count} attempts) - Skipped(⏭):。
⏭ {METHOD} {path} skipped — user declined destructive operation
如果存在失败操作(不包括 skipped),显示摘要并询问用户如何继续:
{N} operation(s) could not be validated. How would you like to proceed?
1. Provide additional information so I can retry the failed operations
2. Keep the failed operations in the spec as-is (no changes to their definitions)
3. Remove the failed operations from the spec and proceed with the corrected spec
4. Cancel — stop the validation process用户选择某个选项时:
- **选项 1:**显示每个失败操作的 ,让用户了解已经尝试过的处理方式。接受用户的补充信息,然后仅对失败操作重新运行验证。重新验证后,显示更新后的摘要;如果仍有失败,则重复决策流程。
retry_history - **选项 2:**按原样继续使用规范。验证期间应用的自动修复已经写入磁盘。
- **选项 3:**使用 Edit 工具从规范的 对象中删除失败操作。将更新后的规范写入磁盘。
paths - **选项 4:**停止。不要继续传递规范。
对于选项 1~3,规范最终确定后,确认输出:
Knowledge ready: {PROJECT_FOLDER}
- api-reference.md
- {apiName}.yaml
- config.properties如果所有操作均通过、已修复或已跳过(即 ),显示摘要并确认输出,无需进一步用户交互:
failed == 0Knowledge ready: {PROJECT_FOLDER}
- api-reference.md
- {apiName}.yaml
- config.properties调用方(通常是 Step 3a)读取 ,以获取 HTTP-Connector 配置和 DataWeave 转换所需信息; 则是经过修正和验证测试的 OpenAPI 规范。
build-mule-integrationapi-reference.md<apiName>.yaml