nimble-agent-builder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNimble Agent Builder
Nimble Agent Builder
Build, refine, and publish reusable extraction agents on the Nimble platform. Always finish with executed results or runnable code.
User request: $ARGUMENTS
在Nimble平台上构建、优化并发布可复用的提取agents。始终以执行结果或可运行代码收尾。
用户请求:$ARGUMENTS
Prerequisites
前提条件
Quick check:
nimble --version && echo "${NIMBLE_API_KEY:+API key: set}"If CLI is missing or API key is not set, load for one-time setup (CLI install, API key, MCP server).
rules/setup.md快速检查:
nimble --version && echo "${NIMBLE_API_KEY:+API key: set}"如果缺少CLI或未设置API密钥,请加载进行一次性设置(CLI安装、API密钥、MCP服务器)。
rules/setup.mdStartup check — run this before anything else
启动检查 — 执行任何操作前先运行此步骤
Verify CLI is available:
bash
nimble --version && echo "${NIMBLE_API_KEY:+API key: set}"If CLI and API key are set → proceed with the user's request normally.
If CLI is missing → check if the MCP server is connected as a fallback:
bash
claude mcp list 2>/dev/null | grep -q nimble-mcp-server && echo "MCP: connected" || echo "MCP: not connected"- MCP connected → proceed using MCP tools instead of CLI commands.
- Neither CLI nor MCP available → load for one-time setup (CLI install, API key). CLI is the preferred setup path.
rules/setup.md
验证CLI是否可用:
bash
nimble --version && echo "${NIMBLE_API_KEY:+API key: set}"如果CLI和API密钥已设置 → 正常处理用户请求。
如果缺少CLI → 检查是否已连接MCP服务器作为备选方案:
bash
claude mcp list 2>/dev/null | grep -q nimble-mcp-server && echo "MCP: connected" || echo "MCP: not connected"- MCP已连接 → 使用MCP工具替代CLI命令继续操作。
- CLI和MCP均不可用 → 加载进行一次性设置(CLI安装、API密钥)。CLI是首选设置路径。
rules/setup.md
Skill ecosystem
技能生态系统
nimble-agent-builder and nimble-web-expert work as a pair in the Nimble toolkit:
| Skill | Best for | Key commands |
|---|---|---|
| nimble-agent-builder (this skill) | Build reusable agents — create, refine, and publish named extraction templates with fixed schemas | CLI: |
| nimble-web-expert | Real-time data access — fetch any URL, search, map, crawl, run published agents | |
nimble-agent-builder和nimble-web-expert是Nimble工具集中的一对配套技能:
| 技能 | 适用场景 | 核心命令 |
|---|---|---|
| nimble-agent-builder(本技能) | 构建可复用agents——创建、优化并发布具有固定 schema 的命名提取模板 | CLI: |
| nimble-web-expert | 实时数据访问——获取任意URL、搜索、映射、爬取、运行已发布的agents | |
Stay in nimble-agent-builder for
适合使用nimble-agent-builder的场景
- Generating a new agent for a domain
- Refining or updating an existing agent (add fields, fix selectors, change schema)
- Publishing an agent
- Running a published agent via (CLI)
nimble agent run - Validating agent output quality
- Any task phrased as "build", "refine", "update", "add a field to", "publish"
- 为某个领域生成新的agent
- 优化或更新现有agent(添加字段、修复选择器、修改schema)
- 发布agent
- 通过(CLI)运行已发布的agent
nimble agent run - 验证agent输出质量
- 任何表述为“构建”、“优化”、“更新”、“为……添加字段”、“发布”的任务
When to route to nimble-web-expert
何时转向nimble-web-expert
After publishing an agent — run it directly here via (CLI). Route to nimble-web-expert only when the workflow needs tools this skill doesn't have:
nimble agent run- Need a list of input URLs to feed into the agent? → Switch to nimble-web-expert, run to crawl and generate the input list, then return here to run at scale.
nimble map --url <site> - Need to search for input params? → Switch to nimble-web-expert, run , then return here with the results.
nimble search
When the task is not about building an agent:
- One-off URL fetch, web search, site mapping, bulk crawl → nimble-web-expert
- Tell the user: "This is a direct data access task, not an agent-building task. Use nimble-web-expert for this."
发布agent后——可在此处通过(CLI)直接运行。仅当工作流需要本技能不具备的工具时,才转向nimble-web-expert:
nimble agent run- 需要输入URL列表供agent使用?→ 切换到nimble-web-expert,运行爬取并生成输入列表,然后返回此处大规模运行。
nimble map --url <site> - 需要搜索输入参数?→ 切换到nimble-web-expert,运行,然后将结果带回此处。
nimble search
当任务与构建agent无关时:
- 一次性URL获取、网页搜索、站点映射、批量爬取 → 使用nimble-web-expert
- 告知用户:"这是直接数据访问任务,而非agent构建任务。请使用nimble-web-expert完成此操作。"
When agent generation needs site investigation
当agent生成需要站点调研时
If or cannot produce a working agent because the site's data structure is unknown (wrong selectors, missing XHR patterns, unexpected JS rendering):
nimble_agents_generatenimble_agents_update_from_agentStep 1 — Announce: "I can't generate a reliable agent without investigating the live page first. Spawning a site investigation..."
Step 2 — Spawn a Task agent ():
Task(subagent_type="general-purpose", run_in_background=False)Investigate {url} to find CSS selectors and/or XHR API endpoints needed to extract: {fields_needed}.
Use Playwright to probe the live page:
python3 << 'EOF'
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
api_calls = []
page.on("request", lambda req: api_calls.append(req) if req.resource_type in ("xhr","fetch") else None)
page.goto("{url}")
page.wait_for_timeout(5000)
for sel in ["[data-price]",".price","h1","[data-testid*=title]","[data-testid*=price]",".product-title"]:
el = page.query_selector(sel)
if el: print(f"SELECTOR: {sel!r} -> {el.inner_text()[:80]!r}")
for req in api_calls[:20]:
print(f"XHR: {req.method} {req.url[:120]}")
browser.close()
EOF
Also run a quick nimble extract to check raw rendered HTML:
nimble extract --url "{url}" --render --format markdown | head -100
Return a structured report:
- SELECTORS: working CSS selectors for each required field
- XHR_URLS: any relevant API endpoints found
- RENDER_REQUIRED: yes/no
- SUGGESTED_EXTRACT_COMMAND: the nimble extract command that would work
- NOTES: login walls, pagination, lazy loading, or anything unusual
Do NOT use AskUserQuestion.Step 3 — Use the report to retry agent generation: pass the selector/XHR context and suggested extract command in the call.
nimble_agents_update_sessionStep 4 — If investigation also fails: Tell the user: "This site requires complex browser automation that can't be captured in an agent at this stage. Use nimble-web-expert's Tier 4/5 commands with or to access the data directly."
--browser-action--network-capture如果或无法生成可用的agent,因为站点的数据结构未知(选择器错误、缺少XHR模式、JS渲染不符合预期):
nimble_agents_generatenimble_agents_update_from_agent步骤1 — 告知用户: "在调研实际页面之前,我无法生成可靠的agent。正在启动站点调研……"
步骤2 — 启动Task agent ():
Task(subagent_type="general-purpose", run_in_background=False)Investigate {url} to find CSS selectors and/or XHR API endpoints needed to extract: {fields_needed}.
Use Playwright to probe the live page:
python3 << 'EOF'
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
api_calls = []
page.on("request", lambda req: api_calls.append(req) if req.resource_type in ("xhr","fetch") else None)
page.goto("{url}")
page.wait_for_timeout(5000)
for sel in ["[data-price]",".price","h1","[data-testid*=title]","[data-testid*=price]",".product-title"]:
el = page.query_selector(sel)
if el: print(f"SELECTOR: {sel!r} -> {el.inner_text()[:80]!r}")
for req in api_calls[:20]:
print(f"XHR: {req.method} {req.url[:120]}")
browser.close()
EOF
Also run a quick nimble extract to check raw rendered HTML:
nimble extract --url "{url}" --render --format markdown | head -100
Return a structured report:
- SELECTORS: working CSS selectors for each required field
- XHR_URLS: any relevant API endpoints found
- RENDER_REQUIRED: yes/no
- SUGGESTED_EXTRACT_COMMAND: the nimble extract command that would work
- NOTES: login walls, pagination, lazy loading, or anything unusual
Do NOT use AskUserQuestion.步骤3 — 使用报告重试agent生成:在调用中传入选择器/XHR上下文和建议的extract命令。
nimble_agents_update_session**步骤4 — 如果调研也失败:**告知用户:"该站点需要复杂的浏览器自动化,目前无法通过agent实现。请使用nimble-web-expert的Tier 4/5命令并添加或参数直接访问数据。"
--browser-action--network-captureCore principles
核心原则
- Fastest path to data. Default route: discover agent → get schema → run → display results. Planning and generation are escalation paths.
- Always search existing agents first. Run (CLI) before considering generate. Hard rule.
nimble agent list --limit 100 --search "<domain or vertical>" - Update over generate — always. When a close-match agent exists (same domain/type, even if missing fields or different scope), update it rather than generating from scratch. Updating preserves proven extraction logic and is faster, cheaper, and more reliable. Only generate a new agent when the query returns 0 matches for the target domain. Never offer "Create new agent" as the recommended option when a close match exists.
--search - AskUserQuestion at every decision point in the foreground — no exceptions. Always present the standard prompts shown in each step. Never skip them, never auto-advance without asking. Never present choices as plain numbered lists. Constraints: 2–4 options, header max 12 chars, label 1–5 words. Recommended option goes first with "(Recommended)". Note: Task agents NEVER use AskUserQuestion — all decisions are pre-made before launching the Task.
AskUserQuestion - Schema before run — always. Run (CLI) before
nimble agent get --template-name <name>. Present input parameters and output fields in markdown tables. This applies when switching agents too.nimble agent run - Script generation (Step 2B) is ONLY for large-scale, high-volume tasks. Never generate code for normal interactive requests. Script mode requires ALL of: scale >50 items AND the user explicitly asks for code/script/CSV/batch output. Multi-source requests, dataset requests, and comparison requests do NOT automatically trigger script mode — run them interactively first. The default path is always: discover → run → display results.
- Verify response shape before script generation. Check and
skillsfromentity_type(CLI) to determine REST API response nesting. Seenimble agent get --template-name> "Response shape inference" andreferences/agent-api-reference.md> "Response structure verification".references/sdk-patterns.md - is not a general search tool. It is a SERP analysis agent for rank tracking and SEO analysis. For finding information, use
google_search(CLI). Seenimble search.references/error-recovery.md - All web search MUST use (CLI). Never use
nimble search,WebSearch,WebFetch, orcurl. See Guardrails.wget - Agent creation/update runs in background Task agents. Generation takes 1-3 minutes — run the generate → poll → publish loop as a Task agent so the user isn't blocked. See Delegation model.
- 最快获取数据路径。默认流程:发现agent → 获取schema → 运行 → 显示结果。规划和生成为升级路径。
- 始终先搜索现有agents。在考虑生成之前,运行(CLI)。硬性规则。
nimble agent list --limit 100 --search "<domain or vertical>" - 优先更新而非生成。当存在匹配度较高的agent(相同领域/类型,即使缺少字段或范围不同)时,更新它而非从头生成。更新会保留经过验证的提取逻辑,更快、更便宜、更可靠。仅当查询针对目标领域返回0个匹配结果时,才生成新agent。当存在匹配度较高的agent时,绝不要将“创建新agent”作为推荐选项。
--search - 在每个决策点都使用AskUserQuestion——无例外。始终显示各步骤中的标准提示。绝不跳过,绝不未经询问自动推进。绝不以普通编号列表形式呈现选项。约束:2–4个选项,标题最多12个字符,标签1–5个词。推荐选项排在最前面并标注"(Recommended)"。注意:Task agents绝不使用AskUserQuestion——所有决策在启动Task前已预先确定。
AskUserQuestion - 先确认Schema再运行。运行之前,先运行
nimble agent run(CLI)。以markdown表格形式呈现输入参数和输出字段。切换agents时同样适用。nimble agent get --template-name <name> - 脚本生成(步骤2B)仅适用于大规模、高容量任务。绝不为普通交互式请求生成代码。脚本模式需要同时满足:规模>50条数据 且 用户明确要求代码/脚本/CSV/批量输出。诸如“数据集”、“对比”、“多源”或“2个源”等词汇不会触发脚本模式——先以交互式方式运行。默认路径始终是:发现 → 运行 → 显示结果。
- 生成脚本前验证响应格式。从(CLI)的结果中检查
nimble agent get --template-name和skills,以确定REST API响应的嵌套结构。参见**entity_type** > "Response shape inference"和**references/agent-api-reference.md** > "Response structure verification"。references/sdk-patterns.md - 不是通用搜索工具。它是用于排名跟踪和SEO分析的SERP分析agent。查找信息请使用
google_search(CLI)。参见**nimble search**。references/error-recovery.md - 所有网页搜索必须使用(CLI)。绝不要使用
nimble search、WebSearch、WebFetch或curl。参见Guardrails。wget - agent创建/更新在后台Task agents中运行。生成需要1-3分钟——将生成→轮询→发布循环作为Task agent运行,避免用户被阻塞。参见Delegation model。
Delegation model
委托模型
The foreground conversation orchestrates and presents results. Task agents handle
long-running work (generation, discovery, script generation).
Foreground — direct CLI calls via Bash:
| CLI command | Purpose | Max calls |
|---|---|---|
| Route to existing agent | 1 per domain |
| Display schema before run | 1 per agent |
| Interactive execution (≤5 items) | 1 per item |
| Web search / discovery | As needed |
Task agents — long-running operations:
| Phase | Task agent | Foreground does |
|---|---|---|
Discovery ( | Step 1D | Launch, present report |
Agent create/update ( | Step 3 | Launch, present report |
| Script generation (write code to call existing agent) | Step 2B | Launch, present script |
Agent creation runs in a Task agent because generation takes 1-3 minutes (poll loop).
The Task agent uses CLI commands via Bash. If CLI is unavailable, it falls back to MCP
tools.
For multi-source workflows, launch Task agents sequentially (one per source/phase). Gather reports, then present the combined plan.
前台对话负责编排和呈现结果。Task agents处理长时间运行的工作(生成、发现、脚本生成)。
前台 — 通过Bash直接调用CLI:
| CLI命令 | 用途 | 最大调用次数 |
|---|---|---|
| 转向现有agent | 每个领域1次 |
| 运行前显示schema | 每个agent1次 |
| 交互式执行(≤5条数据) | 每条数据1次 |
| 网页搜索 / 发现 | 按需调用 |
Task agents — 长时间运行的操作:
| 阶段 | Task agent | 前台操作 |
|---|---|---|
发现( | 步骤1D | 启动,呈现报告 |
Agent创建/更新( | 步骤3 | 启动,呈现报告 |
| 脚本生成(编写代码调用现有agent) | 步骤2B | 启动,呈现脚本 |
Agent创建在Task agent中运行,因为生成需要1-3分钟(轮询循环)。
Task agent通过Bash使用CLI命令。如果CLI不可用,则回退到MCP工具。
对于多源工作流,依次启动Task agents(每个源/阶段一个)。收集报告,然后呈现合并后的计划。
CLI commands for Task agents
Task agents可用的CLI命令
All Task agent prompts should include this block so the subagent knows the available commands:
**CLI tools (use via Bash):**
- `nimble agent list --limit 100 --search "<domain or vertical>"` — search agents by domain/vertical
- `nimble agent get --template-name <name>` — get agent schema
- `nimble agent run --agent <name> --params '{...}'` — run an agent
- `nimble agent generate --agent-name <name> --prompt "<prompt>" --url "<url>"` — create/refine agent
- `nimble agent generate --agent-name <name> --from-agent <name> --prompt "<prompt>"` — iterate on existing agent
- `nimble agent get-generation --generation-id <id>` — poll generation status
- `nimble agent publish --agent-name <name> --version-id <id>` — publish agent
- `nimble search --query "<query>"` — web search (deep by default)
- `nimble map --url <url> --limit 50` — discover URL patterns on a site
**MCP fallback (only if CLI is not installed):**
| CLI command | MCP tool |
|---|---|
| `nimble agent generate` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_generate` |
| `nimble agent get-generation` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_status` |
| `nimble agent publish` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_publish` |
**CRITICAL: Prefer CLI for all operations. Use MCP only when CLI is unavailable. NEVER use WebSearch, WebFetch, curl, or wget. NEVER construct MCP endpoint URLs manually.**所有Task agent提示应包含以下块,以便子agent了解可用命令:
**CLI工具(通过Bash使用):**
- `nimble agent list --limit 100 --search "<domain or vertical>"` — 按领域/垂直领域搜索agents
- `nimble agent get --template-name <name>` — 获取agent schema
- `nimble agent run --agent <name> --params '{...}'` — 运行agent
- `nimble agent generate --agent-name <name> --prompt "<prompt>" --url "<url>"` — 创建/优化agent
- `nimble agent generate --agent-name <name> --from-agent <name> --prompt "<prompt>"` — 基于现有agent迭代优化
- `nimble agent get-generation --generation-id <id>` — 轮询生成状态
- `nimble agent publish --agent-name <name> --version-id <id>` — 发布agent
- `nimble search --query "<query>"` — 网页搜索(默认深度搜索)
- `nimble map --url <url> --limit 50` — 发现站点上的URL模式
**MCP备选方案(仅当未安装CLI时使用):**
| CLI命令 | MCP工具 |
|---|---|
| `nimble agent generate` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_generate` |
| `nimble agent get-generation` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_status` |
| `nimble agent publish` | `mcp__plugin_nimble_nimble-mcp-server__nimble_agents_publish` |
**重要提示:优先使用CLI执行所有操作。仅当CLI不可用时才使用MCP。绝不要使用WebSearch、WebFetch、curl或wget。绝不要手动构造MCP端点URL。**Response shapes
响应格式
| Layer | Path | Shape | When used |
|---|---|---|---|
CLI ( | | | Interactive run (Step 2A) |
CLI ( | | | Interactive run (Step 2A) |
| REST API — ecommerce SERP | | | Script generation (Step 2B) |
| REST API — non-ecommerce SERP | | | Script generation (Step 2B) |
| REST API — PDP | | | Script generation (Step 2B) |
Always check / before iterating REST responses.
typeofisinstance| 层级 | 路径 | 格式 | 使用场景 |
|---|---|---|---|
CLI( | | | 交互式运行(步骤2A) |
CLI( | | | 交互式运行(步骤2A) |
| REST API — 电商SERP | | | 脚本生成(步骤2B) |
| REST API — 非电商SERP | | 包含嵌套数组的 | 脚本生成(步骤2B) |
| REST API — PDP | | | 脚本生成(步骤2B) |
遍历REST响应前始终检查/。
typeofisinstanceStep 1: Route
步骤1:路由
From , detect 3 things:
$ARGUMENTS1. Clarity — (default) or
clearneeds-planningOnly when ALL of these are absent: a target URL/site/domain, clear data to extract, a single well-scoped task. Most requests are .
needs-planningclear2. Agent match — run (CLI, Bash). Use the user's named domain/site as the search term (e.g. , , ). This is ALWAYS the first action. For multi-source requests (e.g., "compare Amazon and Walmart prices"), run one search per source. If no match found for a source, route it to Discovery (Step 1D).
nimble agent list --limit 100 --search "<domain or vertical>"--search "amazon"--search "jobs"--search "ecommerce"| Result | Route |
|---|---|
| Exact match | Show schema summary + |
| Close match (same domain/type, missing fields or different scope) | Show schema gaps + |
| 2+ plausible matches | Show table + |
| 0 matches | Launch Discovery Task agent (Step 1D) → results inform Step 3. This is the ONLY case where generating a new agent is appropriate. |
3. Execution mode — (default) or
interactivescriptInteractive is ALWAYS the default. Route to script generation (Step 2B) ONLY when BOTH conditions are met: (a) scale is explicitly >50 items or the user provides a batch input file, AND (b) the user explicitly asks for code, a script, a CSV export, or batch processing. Words like "dataset", "compare", "multi-source", or "2 sources" do NOT trigger script mode — run these interactively. Script generation writes code that calls an existing agent — it does not create new agents. If no agent exists yet, resolve that first (Step 3) before generating a script.
从中检测3项内容:
$ARGUMENTS1. 清晰度 — (默认)或
clearneeds-planning仅当以下所有内容均缺失时才为:目标URL/站点/领域、明确的提取数据、单一范围明确的任务。大多数请求为。
needs-planningclear2. Agent匹配 — 运行(CLI,Bash)。使用用户指定的领域/站点作为搜索词(例如、、)。这始终是第一个操作。对于多源请求(例如“对比亚马逊和沃尔玛的价格”),为每个源运行一次搜索。如果某个源没有匹配结果,将其路由到发现步骤(步骤1D)。
nimble agent list --limit 100 --search "<domain or vertical>"--search "amazon"--search "jobs"--search "ecommerce"| 结果 | 路由 |
|---|---|
| 完全匹配 | 显示schema摘要 + |
| 匹配度较高(相同领域/类型,缺少字段或范围不同) | 显示schema差距 + |
| 2个及以上合理匹配 | 显示表格 + |
| 0个匹配 | 启动发现Task agent(步骤1D)→ 结果用于步骤3。这是唯一适合生成新agent的情况。 |
3. 执行模式 — (默认)或
interactivescript交互式始终为默认模式。仅当同时满足以下两个条件时,才路由到脚本生成(步骤2B):(a) 规模明确>50条数据或用户提供批量输入文件,且 (b) 用户明确要求代码、脚本、CSV导出或批量处理。诸如“数据集”、“对比”、“多源”或“2个源”等词汇不会触发脚本模式——以交互式方式运行这些任务。脚本生成编写调用现有agent的代码——它不创建新agent。如果尚无agent存在,先解决此问题(步骤3)再生成脚本。
Step 1P: Plan mode (rare — only when needs-planning
)
needs-planning步骤1P:规划模式(罕见 — 仅当needs-planning
时)
needs-planning- Clarify — to resolve critical unknowns (max 2 questions). Focus on: what site(s), what data fields, what output format.
AskUserQuestion - Explore — (CLI, once per domain). For unfamiliar domains, launch Discovery Task agents (Step 1D).
nimble agent list --limit 100 --search "<domain>" - Present plan — gap analysis table:
| # | Site / Data Source | Agent | Status |
|---|---|---|---|
| 1 | amazon.com products | amazon-product-details | Existing |
| 2 | walmart.com products | — | Generate |
- Execute — Step 2 for existing agents, Step 3 for generations (as Task agents).
- 澄清 — 使用解决关键未知问题(最多2个问题)。重点:哪些站点、哪些数据字段、什么输出格式。
AskUserQuestion - 探索 — (CLI,每个领域一次)。对于不熟悉的领域,启动发现Task agents(步骤1D)。
nimble agent list --limit 100 --search "<domain>" - 呈现计划 — 差距分析表格:
| # | 站点 / 数据源 | Agent | 状态 |
|---|---|---|---|
| 1 | amazon.com产品 | amazon-product-details | 已存在 |
| 2 | walmart.com产品 | — | 需生成 |
- 执行 — 现有agent使用步骤2,需生成的agent使用步骤3(作为Task agents)。
Step 1D: Discovery (Task agent — for unfamiliar domains)
步骤1D:发现(Task agent — 针对不熟悉的领域)
Launch when returns 0 matches for the target domain and it needs exploration. Runs as . The foreground tells the user: "Exploring {domain} to understand available data..."
nimble agent list --limit 100 --search "<domain>"Task(subagent_type="general-purpose", run_in_background=False)Task prompt template:
Explore {domain} for {user_intent}.
Use the Nimble CLI to discover the site structure and available data:
1. **Map the site** (understand URL patterns and sections):
```bash
nimble map --url "https://{domain}" --limit 50This reveals listing pages, detail pages, site sections, and URL patterns.
- Search for real examples (deep content extraction):
This fetches and extracts full page content from each result, giving you product listings, field structures, and example data.bash
nimble search --query "{domain} {keywords}" --max-results 5
Return a structured report:
- DOMAIN: {domain}
- ESTIMATED_ITEMS: count matching query
- LISTING_URL_PATTERN: e.g., /category/filter?color=green
- DETAIL_URL_PATTERN: e.g., /p/{slug}-{SKU}.html
- AVAILABLE_FIELDS: list of extractable fields (name, price, description, materials, etc.)
- MISSING_FIELDS: fields the user wants but the site doesn't have (e.g., ratings, reviews)
- RECOMMENDED_APPROACH: generate custom agent / use existing agent from {alternative} / combine sources
- SAMPLE_URLS: 2–3 example URLs for agent generation
- LIMITATIONS: login walls, pagination limits, JS rendering, etc.
Do NOT use AskUserQuestion. Do NOT use nimble_find_search_agent, nimble_run_search_agent, or nimble_url_extract.
Do NOT use WebSearch, WebFetch, or any non-Nimble-CLI search/fetch method.
On receiving the report, the foreground conversation:
1. Presents key findings to the user.
2. If data gaps exist (e.g., missing ratings), asks the user via `AskUserQuestion` how to proceed.
3. Routes to Step 3 (generate) with the discovery context, or Step 2 if existing agents cover the need.当针对目标领域返回0个匹配结果且需要探索时启动。以运行。前台告知用户:"正在探索{domain}以了解可用数据……"
nimble agent list --limit 100 --search "<domain>"Task(subagent_type="general-purpose", run_in_background=False)Task提示模板:
针对{user_intent}探索{domain}。
使用Nimble CLI发现站点结构和可用数据:
1. **映射站点**(了解URL模式和板块):
```bash
nimble map --url "https://{domain}" --limit 50这会揭示列表页、详情页、站点板块和URL模式。
- 搜索真实示例(深度内容提取):
这会获取并提取每个结果的完整页面内容,提供产品列表、字段结构和示例数据。bash
nimble search --query "{domain} {keywords}" --max-results 5
返回结构化报告:
- DOMAIN: {domain}
- ESTIMATED_ITEMS: 匹配查询的数量
- LISTING_URL_PATTERN: 例如 /category/filter?color=green
- DETAIL_URL_PATTERN: 例如 /p/{slug}-{SKU}.html
- AVAILABLE_FIELDS: 可提取字段列表(名称、价格、描述、材质等)
- MISSING_FIELDS: 用户需要但站点没有的字段(例如评分、评论)
- RECOMMENDED_APPROACH: 生成自定义agent / 使用{alternative}的现有agent / 合并数据源
- SAMPLE_URLS: 2–3个用于agent生成的示例URL
- LIMITATIONS: 登录墙、分页限制、JS渲染等
请勿使用AskUserQuestion。请勿使用nimble_find_search_agent、nimble_run_search_agent或nimble_url_extract。
请勿使用WebSearch、WebFetch或任何非Nimble-CLI的搜索/获取方法。
收到报告后,前台对话:
1. 向用户呈现关键发现。
2. 如果存在数据差距(例如缺少评分),通过`AskUserQuestion`询问用户如何处理。
3. 根据发现的上下文路由到步骤3(生成),或如果现有agent满足需求则路由到步骤2。Step 2: Run existing agent
步骤2:运行现有agent
Two sub-paths based on execution mode.
根据执行模式分为两个子路径。
2A: Interactive (small scale, display output)
2A:交互式(小规模,显示输出)
2A-1. Run (CLI). Present schema in markdown tables:
nimble agent get --template-name <name>- Input parameters: name, required, type, description, example
- Output fields: key fields from dict
skills
See > "Input Parameter Mapping" for the full format and mapping rules.
references/agent-api-reference.mdinput_properties2A-2. Always confirm before running via :
AskUserQuestionquestion: "Run {agent_name} with these parameters?"
header: "Confirm"
options:
- label: "Run agent (Recommended)"
description: "Execute {agent_name} with {summary of inferred parameters}"
- label: "Change parameters"
description: "Adjust input parameters before running"
- label: "Create new agent"
description: "Create a custom agent instead (Step 3)"2A-3. Run (CLI). Present results as markdown table. Always ask what to do next:
nimble agent run --agent <name> --params '{...}'question: "What next?"
header: "Next step"
options:
- label: "Done"
description: "Finish with these results"
- label: "Run again"
description: "Re-run with different parameters"Do NOT offer script generation as a next step unless the user explicitly mentions needing large-scale extraction (>50 items) or batch processing. Script generation is not a natural follow-up to interactive runs.
Bulk (2–5 URLs): Run per URL, aggregate results, handle individual failures without aborting. See > "Interactive batch extraction".
references/batch-patterns.md2A-1. 运行(CLI)。以markdown表格形式呈现schema:
nimble agent get --template-name <name>- 输入参数: 名称、是否必填、类型、描述、示例
- 输出字段: 字典中的关键字段
skills
参见**** > "Input Parameter Mapping"获取完整的格式和映射规则。
references/agent-api-reference.mdinput_properties2A-2. 运行前始终通过确认:
AskUserQuestionquestion: "使用这些参数运行{agent_name}?"
header: "确认"
options:
- label: "运行agent(推荐)"
description: "使用{推断参数摘要}执行{agent_name}"
- label: "修改参数"
description: "运行前调整输入参数"
- label: "创建新agent"
description: "改为创建自定义agent(步骤3)"2A-3. 运行(CLI)。以markdown表格形式呈现结果。始终询问下一步操作:
nimble agent run --agent <name> --params '{...}'question: "下一步做什么?"
header: "下一步"
options:
- label: "完成"
description: "结束并保留这些结果"
- label: "重新运行"
description: "使用不同参数重新运行"除非用户明确提及需要大规模提取(>50条数据)或批量处理,否则不要将脚本生成作为下一步选项。脚本生成不是交互式运行的自然后续操作。
批量处理(2–5个URL): 逐个URL运行,汇总结果,处理单个失败而不中止。参见**** > "Interactive batch extraction"。
references/batch-patterns.md2B: Script generation (ONLY for large-scale, high-volume tasks)
2B:脚本生成(仅适用于大规模、高容量任务)
This step is ONLY reached when the user explicitly needs to process >50 items at scale or requests batch code/script generation. Normal requests — even multi-source or "dataset" requests — are handled interactively via Step 2A. Writes a runnable script that calls an existing Nimble agent at scale via the SDK/REST API. This does NOT create new agents — the agent must already exist. Runs as a Task agent. The foreground infers language, launches the agent, and presents the generated script for confirmation.
2B-1. Infer language from project context (foreground, before launching):
| Project file | Language |
|---|---|
| Python |
| TypeScript/Node |
| Go (REST API) |
| None of the above | Default to Python |
2B-2. Launch script generation Task agent: .
Task(subagent_type="general-purpose", run_in_background=False)Task prompt template:
Write a {language} script that calls existing Nimble agent(s) at scale via SDK/REST API.
**Use the Nimble CLI to inspect agent schemas (via Bash, NOT MCP):**
```bash
nimble agent get --template-name <agent_name>This returns the full input/output schema for the agent.
CRITICAL: Use CLI (Bash) for all Nimble operations. NEVER use WebSearch, WebFetch, curl, or wget. NEVER construct MCP endpoint URLs manually.
Existing agents to call: {agent_names}
User intent: {user_prompt}
Output format: {csv/json/etc}
Scale: {number of items/queries}
This is SCRIPT GENERATION — writing code that calls existing agents. Do NOT create new agents
(no nimble_agents_generate/update/publish). The agents listed above already exist.
Steps:
- Run (CLI) for each agent to inspect input_properties and skills.
nimble agent get --template-name <agent> - Read the reference files:
- (Python) or
references/sdk-patterns.md(other languages)references/rest-api-patterns.md - (for multi-store normalization)
references/batch-patterns.md
- Write a complete, ready-to-run script with:
- Smoke test first — validate a single query before full batch. Abort on failure.
- Progress reporting — compact single-line status after each poll cycle.
- Pagination handling for large result sets.
- Multi-store field normalization (if applicable).
- Output to {format}.
- Incremental file writes for large pipelines (50+ jobs).
Return the complete script and a brief summary of:
- Agent schemas used (input params, key output fields)
- Normalization mappings (if multi-store)
- Total estimated API calls
Do NOT use AskUserQuestion. Do NOT use nimble_find_search_agent or nimble_run_search_agent.
Do NOT call nimble_agents_generate, nimble_agents_update_from_agent, nimble_agents_update_session, or nimble_agents_publish.
Do NOT use WebSearch, WebFetch, bash curl, or any non-MCP search/fetch method.
**2B-3.** Present the generated script and confirm execution via `AskUserQuestion` (foreground):
question: "Run this script?"
header: "Confirm"
options:
- label: "Run script (Recommended)" description: "Execute the generated script"
- label: "Edit first" description: "Review and modify the script before running"
**No agent validation step here.** The 50-input validation flow (Step 3) is only for agent creation/update. Script generation uses an existing, already-validated agent — just write the script and run it.仅当用户明确需要处理>50条数据或请求批量代码/脚本生成时,才进入此步骤。普通请求——即使是多源或“数据集”请求——通过步骤2A以交互式方式处理。编写可运行的脚本,通过SDK/REST API大规模调用现有的Nimble agent。此步骤不创建新agent——agent必须已存在。以Task agent运行。前台推断语言,启动agent,并呈现生成的脚本供确认。
2B-1. 根据项目上下文推断语言(前台,启动前):
| 项目文件 | 语言 |
|---|---|
| Python |
| TypeScript/Node |
| Go(REST API) |
| 以上均无 | 默认使用Python |
2B-2. 启动脚本生成Task agent:。
Task(subagent_type="general-purpose", run_in_background=False)Task提示模板:
编写{language}脚本,通过SDK/REST API大规模调用现有的Nimble agent(s)。
**使用Nimble CLI检查agent schemas(通过Bash,而非MCP):**
```bash
nimble agent get --template-name <agent_name>这会返回agent的完整输入/输出schema。
重要提示:使用CLI(Bash)执行所有Nimble操作。绝不要使用WebSearch、WebFetch、curl或wget。绝不要手动构造MCP端点URL。
要调用的现有agents: {agent_names}
用户意图: {user_prompt}
输出格式: {csv/json/etc}
规模: {数据/查询数量}
这是脚本生成——编写调用现有agents的代码。请勿创建新agents
(不要使用nimble_agents_generate/update/publish)。上述列出的agents已存在。
步骤:
- 为每个agent运行(CLI)以检查input_properties和skills。
nimble agent get --template-name <agent> - 阅读参考文件:
- (Python)或
references/sdk-patterns.md(其他语言)references/rest-api-patterns.md - (用于多商店标准化)
references/batch-patterns.md
- 编写完整的可运行脚本,包含:
- 先进行冒烟测试——在全量批量处理前验证单个查询。失败则中止。
- 进度报告——每个轮询周期后显示简洁的单行状态。
- 处理大型结果集的分页。
- 多商店字段标准化(如适用)。
- 输出到{format}。
- 大型管道(50+任务)的增量文件写入。
返回完整脚本和简要摘要:
- 使用的agent schemas(输入参数、关键输出字段)
- 标准化映射(如多商店)
- 预估的总API调用次数
请勿使用AskUserQuestion。请勿使用nimble_find_search_agent或nimble_run_search_agent。
请勿调用nimble_agents_generate、nimble_agents_update_from_agent、nimble_agents_update_session或nimble_agents_publish。
请勿使用WebSearch、WebFetch、bash curl或任何非MCP的搜索/获取方法。
**2B-3.** 呈现生成的脚本并通过`AskUserQuestion`确认执行(前台):
question: "运行此脚本?"
header: "确认"
options:
- label: "运行脚本(推荐)" description: "执行生成的脚本"
- label: "先编辑" description: "运行前查看并修改脚本"
**此处无需agent验证步骤**。50条输入的验证流程(步骤3)仅适用于agent创建/更新。脚本生成使用已存在且已验证的agent——只需编写并运行脚本即可。Step 3: Update existing agent or create new (on the Nimble platform)
步骤3:更新现有agent或创建新agent(在Nimble平台上)
Updates an existing agent (preferred) or creates a new one on Nimble's platform. Default to update when a close-match agent was found in Step 1 — pass the existing agent name to the Task agent so it uses instead of . Only create a new agent when Step 1 returned 0 matches. This is NOT code/script generation — it creates/modifies an extraction definition callable via Step 2A or 2B. ALWAYS runs as a Task agent ().
nimble_agents_update_from_agentnimble_agents_generaterun_in_background=False更新现有agent(首选)或在Nimble平台上创建新agent。当步骤1中找到匹配度较高的agent时,默认选择更新——将现有agent名称传递给Task agent,使其使用而非。仅当步骤1返回0个匹配结果时才创建新agent。此步骤不是代码/脚本生成——它创建/修改提取定义,可通过步骤2A或2B调用。始终以Task agent运行()。
nimble_agents_update_from_agentnimble_agents_generaterun_in_background=False3-1. Create a stable session_id
(UUID v4).
session_id3-1. 创建稳定的session_id
(UUID v4)。
session_id3-2. Ask the user ONCE (foreground only — agent creation/update ONLY, never for script generation):
3-2. 询问用户一次(仅前台——仅agent创建/更新,绝不用于脚本生成):
question: "Run refinement-validation before publishing?"
header: "Validate"
options:
- label: "Yes, validate (Recommended)"
description: "Discovery → generate → validate 50 inputs (80% pass) → publish. Auto-retries on failure."
- label: "No, generate only"
description: "Generate → publish immediately without validation testing"question: "发布前运行优化验证?"
header: "验证"
options:
- label: "是,验证(推荐)"
description: "发现 → 生成 → 验证50条输入(通过率80%)→ 发布。失败时自动重试。"
- label: "否,仅生成"
description: "生成后立即发布,不进行验证测试"3-3. Launch Task agent
3-3. 启动Task agent
Set to the user's choice. Launch using the prompt template from (includes MCP tool registry, lifecycle phases, and all rules). Tell the user: "Agent generation started. I'll report results when complete."
refine_validateTask(subagent_type="general-purpose", run_in_background=False, max_turns=50)references/generate-update-and-publish.mdThe Task agent executes a closed-loop lifecycle: Discovery → Create/Update → Poll → Validate → Publish → Report. On failure, it auto-triggers an update loop (max 2 cycles, 15-minute wall-clock timeout). See the reference file for complete details.
将设置为用户的选择。使用****中的提示模板启动(包含MCP工具注册表、生命周期阶段和所有规则)。告知用户:"Agent生成已启动。完成后我会报告结果。"
refine_validatereferences/generate-update-and-publish.mdTask(subagent_type="general-purpose", run_in_background=False, max_turns=50)Task agent执行闭环生命周期:发现 → 创建/更新 → 轮询 → 验证 → 发布 → 报告。失败时自动触发更新循环(最多2个周期,15分钟时钟超时)。详见参考文件。
3-4. Present report
3-4. 呈现报告
When the Task agent completes, present the report. On success, route to Step 2A or 2B. On failure after max cycles, offer:
question: "Agent validation did not reach 80% pass rate. How to proceed?"
header: "Next step"
options:
- label: "Publish anyway"
description: "Publish with current pass rate ({rate}%)"
- label: "Update agent"
description: "Provide specific instructions to refine the agent"Task agent完成后,呈现报告。成功则路由到步骤2A或2B。达到最大周期后失败,则提供:
question: "Agent验证未达到80%通过率。如何处理?"
header: "下一步"
options:
- label: "仍然发布"
description: "按当前通过率({rate}%)发布"
- label: "更新agent"
description: "提供具体指令优化agent"Step 4: Final response
步骤4:最终响应
End with a concise summary table:
| Field | Value |
|---|---|
| Agent(s) used | |
| Source | Existing / Generated |
| Records extracted | count |
| Output | Displayed / |
Include the extraction results (or top N if large).
以简洁的摘要表格结束:
| 字段 | 值 |
|---|---|
| 使用的Agent(s) | |
| 来源 | 已存在 / 已生成 |
| 提取记录数 | 数量 |
| 输出 | 已显示 / |
包含提取结果(如果结果较多则显示前N条)。
Additional references
附加参考文件
Load reference files only during large-scale script generation (Step 2B) or agent creation (Step 3). Do NOT load these for interactive runs (Step 2A) — MCP tool schemas are sufficient.
For script generation (Step 2B) only:
- — Running agents, async endpoint, batch pipelines, incremental file writes.
references/sdk-patterns.md - — REST API patterns for TypeScript, Node, curl, and other non-Python languages.
references/rest-api-patterns.md - — Multi-store comparison, normalization, interactive batch, codegen walkthrough.
references/batch-patterns.md
For agent creation/update (Step 3) only:
- — Full agent creation/update lifecycle: discovery, creation, polling, SDK validation (50 inputs, 80% threshold), publish, reporting, update loop.
references/generate-update-and-publish.md
General (any step, load as needed):
- — MCP tools reference plus input parameter mapping.
references/agent-api-reference.md - — Error handling and recovery patterns.
references/error-recovery.md
仅在**大规模脚本生成(步骤2B)**或agent创建(步骤3)期间加载参考文件。交互式运行(步骤2A)请勿加载这些文件——MCP工具schema已足够。
仅适用于脚本生成(步骤2B):
- — 运行agents、异步端点、批量管道、增量文件写入。
references/sdk-patterns.md - — TypeScript、Node、curl和其他非Python语言的REST API模式。
references/rest-api-patterns.md - — 多商店对比、标准化、交互式批量处理、代码生成演练。
references/batch-patterns.md
仅适用于agent创建/更新(步骤3):
- — 完整的agent创建/更新生命周期:发现、创建、轮询、SDK验证(50条输入,80%阈值)、发布、报告、更新循环。
references/generate-update-and-publish.md
通用(任何步骤,按需加载):
- — MCP工具参考及输入参数映射。
references/agent-api-reference.md - — 错误处理和恢复模式。
references/error-recovery.md
Guardrails
防护规则
- Agent creation/update runs in Task agents. Generation takes 1-3 minutes — use a background Task agent for the generate → poll → publish loop. See Delegation model.
- All operations use CLI (Bash). MCP tools are a fallback only when CLI is unavailable.
- All web search MUST use (CLI). NEVER use
nimble search,WebSearch,WebFetch, orcurl— in foreground or Task agents.wget - Every Task agent prompt MUST include the CLI commands block (see Delegation model).
- Never use ,
nimble_find_search_agent, or any WSA template tools.nimble_run_search_agent - Update state machine: use to iterate on existing agents. Each iteration creates a new generation to poll.
nimble agent generate --from-agent - Hard 429 rule. On quota errors: stop, report exhaustion. Do not retry or switch tools.
- Published agents are automatically forked when updated. UBCT-based agents cannot be updated — generate a new one instead.
- Never load SDK/batch references for interactive runs (Step 2A). CLI output from is sufficient. Load references only for Step 2B (script generation) and Step 3 (agent creation).
nimble agent get --template-name - Present results in markdown tables. Never show raw JSON.
- Agent创建/更新在Task agents中运行。生成需要1-3分钟——使用后台Task agent处理生成→轮询→发布循环。参见Delegation model。
- 所有操作使用CLI(Bash)。仅当CLI不可用时才使用MCP工具作为备选。
- 所有网页搜索必须使用(CLI)。绝不要在前台或Task agents中使用
nimble search、WebSearch、WebFetch或curl。wget - 每个Task agent提示必须包含CLI命令块(参见Delegation model)。
- 绝不要使用、
nimble_find_search_agent或任何WSA模板工具。nimble_run_search_agent - 更新状态机: 使用迭代现有agents。每次迭代创建新的生成版本以供轮询。
nimble agent generate --from-agent - 严格的429规则。遇到配额错误时:停止,报告配额耗尽。不要重试或切换工具。
- 更新已发布的agents时会自动创建分支。基于UBCT的agents无法更新——请生成新的agent。
- 交互式运行(步骤2A)绝不要加载SDK/批量参考文件。的CLI输出已足够。仅在步骤2B(脚本生成)和步骤3(agent创建)期间加载参考文件。
nimble agent get --template-name - 以markdown表格形式呈现结果。绝不要显示原始JSON。