pp-instacart
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseInstacart - Printing Press CLI
Instacart - Printing Press CLI
Prerequisites: Install the CLI
前提条件:安装CLI
This skill drives the binary. You must verify the CLI is installed before invoking any command from this skill. If it is missing, install it first:
instacart-pp-cli- Install via the Printing Press installer:
bash
npx -y @mvanhorn/printing-press install instacart --cli-only - Verify:
instacart-pp-cli --version - Ensure (or
$GOPATH/bin) is on$HOME/go/bin.$PATH
If the install fails (no Node, offline, etc.), fall back to a direct Go install (requires Go 1.23+):
npxbash
go install github.com/mvanhorn/printing-press-library/library/commerce/instacart/cmd/instacart-pp-cli@latestIf reports "command not found" after install, the install step did not put the binary on . Do not proceed with skill commands until verification succeeds.
--version$PATH此技能驱动二进制文件。在调用此技能的任何命令之前,您必须确认CLI已安装。如果未安装,请先进行安装:
instacart-pp-cli- 通过Printing Press安装程序安装:
bash
npx -y @mvanhorn/printing-press install instacart --cli-only - 验证安装:
instacart-pp-cli --version - 确保(或
$GOPATH/bin)已添加到$HOME/go/bin环境变量中。$PATH
如果安装失败(无Node环境、离线等情况),可改用Go直接安装(要求Go 1.23+版本):
npxbash
go install github.com/mvanhorn/printing-press-library/library/commerce/instacart/cmd/instacart-pp-cli@latest如果安装后执行提示“command not found”,说明安装步骤未将二进制文件添加到中。请在验证成功前不要执行技能命令。
--version$PATHWhen to Use This CLI
何时使用此CLI
Reach for this when a user wants:
- Add a product to an Instacart cart by natural language ("add lemon sorbet to QFC")
- Add something they have bought before ("add my usual milk to Safeway")
- Show, search, or compare their active carts across retailers
- List or search their own Instacart order history
- Run an Instacart flow from a script, cron job, or agent loop
Do not reach for this if the user wants to actually check out. This CLI adds items to your cart; you still complete checkout in the Instacart app or web UI.
当用户有以下需求时,可使用此工具:
- 通过自然语言将商品添加到Instacart购物车(例如“add lemon sorbet to QFC”)
- 添加之前购买过的商品(例如“add my usual milk to Safeway”)
- 查看、搜索或对比跨零售商的活跃购物车
- 列出或搜索个人Instacart订单历史
- 从脚本、定时任务或Agent循环中执行Instacart流程
如果用户想要完成结账操作,则不建议使用此工具。此CLI仅负责将商品添加到购物车;结账仍需在Instacart应用或网页端完成。
Unique Capabilities
独特功能
History-first add
add优先基于历史记录的「添加」操作
addConfidence rules:
- FTS5 match in your local purchased_items at that retailer
- Purchased within the last 365 days
- Was in stock on the last purchase
Falls through to today's live-search behavior when any condition fails. Pass to force live search.
--no-historyEvery successful (history-resolved or live-resolved) writes back to so the signal gets warmer without a full re-sync.
addpurchased_itemsadd匹配度判定规则:
- 在该零售商的本地已购商品库中通过FTS5匹配成功
- 购买时间在过去365天内
- 上次购买时商品处于在售状态
当任一条件不满足时,会自动切换为实时搜索模式。可添加参数强制使用实时搜索。
--no-history所有成功的「添加」操作(无论是基于历史记录还是实时搜索)都会写入,无需完全同步即可优化后续匹配的准确性。
purchased_itemsOne-command history backfill
一键历史记录回填
Typing "backfill my instacart orders" (or similar, see Argument Parsing) kicks off a Chrome-MCP-driven flow that walks the user's logged-in Instacart tab, extracts their order history into JSONL, and imports it into the local DB. After backfill, resolves from real purchase history instead of live-search guesses.
addPrimary path: Chrome MCP. Fallback: paste three JS files into DevTools by hand.
Full walkthrough below under "Backfill Flow". Reference docs with more detail:
- — Chrome MCP flow
docs/backfill-walkthrough.md - — manual DevTools flow
docs/backfill-devtools-fallback.md
history listhistory searchhistory statsInstacart does not expose a clean order-history GraphQL op, so the legacy command cannot work. See for why.
history syncdocs/solutions/best-practices/instacart-orders-no-clean-graphql-op.md输入“backfill my instacart orders”(或类似表述,详见参数解析)即可启动由Chrome-MCP驱动的流程,该流程会读取用户已登录的Instacart标签页,将订单历史提取为JSONL格式并导入本地数据库。回填完成后,命令将基于真实购买历史而非实时搜索猜测来匹配商品。
add主要路径:Chrome MCP。备选方案:手动将三个JS文件粘贴到DevTools中。
完整流程说明请查看下方「回填流程」章节。详细参考文档:
- — Chrome MCP流程
docs/backfill-walkthrough.md - — 手动DevTools流程
docs/backfill-devtools-fallback.md
history listhistory searchhistory statsInstacart未提供清晰的订单历史GraphQL操作接口,因此旧版命令无法正常工作。详情请查看。
history syncdocs/solutions/best-practices/instacart-orders-no-clean-graphql-op.mdNatural-language add
add自然语言「添加」操作
Resolves a product from free-text via Instacart's own three-call GraphQL chain (ShopCollectionScoped -> Autosuggestions -> Items) and fires . No browser automation.
UpdateCartItemsMutationWhen Instacart rejects a candidate with (autosuggest occasionally surfaces a product that is not addable at your active cart's shop), automatically retries up to 3 ranked candidates before giving up. In output a successful retry sets and includes an array listing the rejected item ids. When history-first resolution hits the same error, falls through to live search and reports .
notFoundBasketProductadd--jsonretry_count > 0attemptsaddresolved_via: "history->live"通过Instacart自身的三次GraphQL调用链(ShopCollectionScoped -> Autosuggestions -> Items)将自由文本解析为商品,并执行操作。无需浏览器自动化。
UpdateCartItemsMutation当Instacart返回错误(自动补全偶尔会推荐当前购物车所属店铺无法添加的商品)时,命令会自动重试最多3个排名靠前的候选商品,直至成功或失败。使用输出时,成功重试会显示,并包含数组列出被拒绝的商品ID。当基于历史记录的匹配遇到相同错误时,命令会切换为实时搜索模式,并标记。
notFoundBasketProductadd--jsonretry_count > 0attemptsaddresolved_via: "history->live"Multi-retailer carts
carts多零售商购物车管理
carts listcarts listCommand Reference
命令参考
Authentication:
- - extract session cookies from Chrome
instacart auth login - - show current session state
instacart auth status - - clear saved cookies
instacart auth logout - - paste cookie JSON manually (fallback for newer macOS Chrome)
instacart auth paste - - load cookies from a browser-use export JSON
instacart auth import-file <path>
Cart operations:
- - add a product by natural language
instacart add <retailer> <query...> - - skip the history-first resolver
instacart add <retailer> <query...> --no-history - - add by exact Instacart item id
instacart add --item-id <id> <retailer> - - show current cart contents at a retailer
instacart cart show <retailer> - - remove an item from a cart
instacart cart remove <item-id> <retailer> - - list every active cart across retailers
instacart carts list
Discovery:
- - search products at a retailer
instacart search <query> --store <retailer> - - list retailers available at your address
instacart retailers list - - cache one retailer locally
instacart retailers show <slug>
Purchase history:
- - load a JSONL order dump into the local DB (the working path)
instacart history import <path> - - read from stdin, JSON output for agent pipelines
instacart history import - --json - - preview counts without writing
instacart history import <path> --dry-run - - top purchased items by count + recency
instacart history list - - filter + paginate
instacart history list --store <retailer> --limit 20 - - FTS search your purchase history
instacart history search <query> - - scoped FTS search
instacart history search <query> --store <retailer> - - counts + per-retailer state
instacart history stats
Maintenance:
- - health check: config, store, ops, history, session, live ping
instacart doctor - - refresh the GraphQL operation hash cache
instacart capture - - merge fresh hashes from the community registry
instacart capture --remote - - show the operation-hash cache state
instacart ops list
认证相关:
- - 从Chrome中提取会话Cookie
instacart auth login - - 显示当前会话状态
instacart auth status - - 清除已保存的Cookie
instacart auth logout - - 手动粘贴Cookie JSON(适用于新版macOS Chrome的备选方案)
instacart auth paste - - 从浏览器导出的JSON文件加载Cookie
instacart auth import-file <path>
购物车操作:
- - 通过自然语言添加商品
instacart add <retailer> <query...> - - 跳过基于历史记录的解析
instacart add <retailer> <query...> --no-history - - 通过精确的Instacart商品ID添加
instacart add --item-id <id> <retailer> - - 显示指定零售商的当前购物车内容
instacart cart show <retailer> - - 从购物车中移除指定商品
instacart cart remove <item-id> <retailer> - - 列出所有零售商的活跃购物车
instacart carts list
发现功能:
- - 在指定零售商处搜索商品
instacart search <query> --store <retailer> - - 列出您所在地址支持的零售商
instacart retailers list - - 将指定零售商信息缓存到本地
instacart retailers show <slug>
购买历史:
- - 将JSONL格式的订单转储文件加载到本地数据库(工作路径)
instacart history import <path> - - 从标准输入读取数据,输出JSON格式用于Agent流水线
instacart history import - --json - - 预览导入数量但不写入数据库
instacart history import <path> --dry-run - - 按购买次数和最近度显示最常购买的商品
instacart history list - - 筛选并分页显示
instacart history list --store <retailer> --limit 20 - - 全文搜索购买历史
instacart history search <query> - - 按零售商筛选全文搜索
instacart history search <query> --store <retailer> - - 显示订单统计数据及各零售商状态
instacart history stats
维护相关:
- - 健康检查:配置、店铺、操作、历史记录、会话、实时连接
instacart doctor - - 更新GraphQL操作哈希缓存
instacart capture - - 从社区注册表合并最新哈希值
instacart capture --remote - - 显示操作哈希缓存状态
instacart ops list
Recipes
使用示例
First-time setup
首次设置
bash
instacart auth login # extract cookies from Chrome
instacart doctor # verify auth + live ping
instacart capture # seed built-in op hashesThen backfill history (optional but recommended; unlocks history-first ):
addTell the agent: "backfill my instacart orders"
The skill drives the rest. See the "Backfill Flow" section below.
bash
instacart auth login # 从Chrome提取Cookie
instacart doctor # 验证认证及实时连接
instacart capture # 初始化内置操作哈希然后回填历史记录(可选但推荐;解锁基于历史记录的优先「添加」功能):
告知Agent:"backfill my instacart orders"
技能会引导完成后续步骤。请查看下方「回填流程」章节。
Add something you buy all the time
添加常购商品
bash
instacart add safeway "oat milk" # resolves via local history if you have bought it beforeLook for in the output. If you see , the FTS match did not pass the confidence check; check to see what is actually in your history.
via historyvia liveinstacart history search "oat milk" --store safewaybash
instacart add safeway "oat milk" # 如果您之前购买过,会基于本地历史记录解析输出中会显示。如果显示,说明全文搜索匹配未通过置信度检查;可执行查看历史记录中的实际商品。
via historyvia liveinstacart history search "oat milk" --store safewayForce a fresh live search
强制实时搜索
bash
instacart add safeway "oat milk" --no-history --dry-run --json--dry-run --jsonresolved_viabash
instacart add safeway "oat milk" --no-history --dry-run --json--dry-run --jsonresolved_viaDaily top-up from recent history
从近期历史记录一键补货
bash
instacart history list --store safeway --limit 20 --json | jq -r '.[].name' \
| while read item; do instacart add safeway "$item" --yes --json; donebash
instacart history list --store safeway --limit 20 --json | jq -r '.[].name' \
| while read item; do instacart add safeway "$item" --yes --json; doneAuth Setup
认证设置
Requires a logged-in Instacart session in Chrome. The CLI extracts cookies via kooky (no credential handling on our side). If Chrome is locked or you are on a system kooky cannot read:
bash
instacart auth paste # paste the full cookie JSON manually
instacart auth import-file <path>Session lives at (0600).
~/.config/instacart/session.json要求Chrome中已登录Instacart会话。CLI通过kooky提取Cookie(我们不处理任何凭证)。如果Chrome已锁定或kooky无法读取系统Cookie:
bash
instacart auth paste # 手动粘贴完整的Cookie JSON
instacart auth import-file <path>会话存储在(权限0600)。
~/.config/instacart/session.jsonAgent Mode
Agent模式
The CLI is agent-native by default. Pass on any command for machine-readable output. previews without firing the mutation and surfaces which resolver (, , or ) would have fired.
--json--dry-runaddhistoryliveitem-idadd- : one of
resolved_via,history,live(history pick was rejected, live retry succeeded), orhistory->live.item-id - : how many candidates were rejected before the winner.
retry_countwhen the first pick landed.0 - : present only when
attempts, array ofretry_count > 0for each rejected candidate.{item_id, name, error_type} - On exhaustion (exit 5): JSON envelope with ,
error,retailer,query, and aattemptsnaming the concrete next step (hintthensearch, or retry withadd --item-id).--no-history
CLI默认支持Agent调用。在任何命令后添加参数即可获取机器可读的输出。参数可预览「添加」操作但不执行变更,并显示会触发的解析器(、或)。
--json--dry-runhistoryliveitem-idadd- : 取值为
resolved_via、history、live(历史记录匹配被拒绝,实时搜索重试成功)或history->live。item-id - : 成功匹配前被拒绝的候选商品数量。首次匹配成功时为
retry_count。0 - : 仅当
attempts时存在,包含每个被拒绝候选商品的retry_count > 0数组。{item_id, name, error_type} - 当所有候选商品都失败(退出码5):JSON输出包含、
error、retailer、query字段,以及attempts字段给出具体下一步操作建议(先hint再search,或添加add --item-id重试)。--no-history
Filtering output
输出筛选
--selectbash
instacart-pp-cli <command> --agent --select id,name
instacart-pp-cli <command> --agent --select items.id,items.owner.nameUse this to narrow huge payloads to the fields you actually need — critical for deeply nested API responses.
--selectbash
instacart-pp-cli <command> --agent --select id,name
instacart-pp-cli <command> --agent --select items.id,items.owner.name使用此参数可将庞大的响应数据缩小到实际需要的字段——这对深度嵌套的API响应至关重要。
Response envelope
响应信封
Data-layer commands wrap output in . Parse for data and to know whether it's or local. The summary is printed to stderr only when stdout is a TTY; piped/agent consumers see pure JSON on stdout.
{"meta": {...}, "results": <data>}.results.meta.sourceliveN results (live)数据层命令会将输出包裹在结构中。解析字段获取数据,字段表示数据来源是(实时)还是本地。当标准输出为TTY时,摘要会打印到标准错误输出;管道或Agent调用时,标准输出仅显示纯JSON。
{"meta": {...}, "results": <data>}.results.meta.sourceliveN results (live)Exit Codes
退出码
| Code | Meaning |
|---|---|
| 0 | Success |
| 2 | Usage error |
| 3 | Auth missing or rejected |
| 4 | Resource not found |
| 5 | API error / conflict |
| 7 | Rate limited or transient network |
| 代码 | 含义 |
|---|---|
| 0 | 成功 |
| 2 | 使用错误 |
| 3 | 认证缺失或被拒绝 |
| 4 | 资源未找到 |
| 5 | API错误/冲突 |
| 7 | 速率限制或临时网络问题 |
Argument Parsing
参数解析
Given a free-form natural-language request:
- Empty, , or
help-> run--helpinstacart --help - Starts with -> CLI install; ends with
install-> MCP installmcp - Matches a backfill intent -> run the Backfill Flow below. Trigger phrases include: "backfill my orders", "backfill my history", "sync my instacart history", "sync my instacart orders", "download my order history", "save my instacart history locally", "pull in my past orders", "import my recent orders".
- Anything else -> map to the best subcommand and run with when invoked from an agent
--json
对于自由格式的自然语言请求:
- 空请求、或
help-> 执行--helpinstacart --help - 以开头 -> 安装CLI;以
install结尾 -> 安装MCPmcp - 匹配回填意图 -> 执行下方的回填流程。触发短语包括:"backfill my orders"、"backfill my history"、"sync my instacart history"、"sync my instacart orders"、"download my order history"、"save my instacart history locally"、"pull in my past orders"、"import my recent orders"。
- 其他请求 -> 映射到最合适的子命令,当由Agent调用时自动添加参数
--json
Backfill Flow
回填流程
Drive this when the user hits a backfill intent. Read via WebFetch for the full procedure; summary below.
docs/backfill-walkthrough.mdSetup check:
- Confirm is on PATH. If not, install:
instacart-pp-cli.go install github.com/mvanhorn/printing-press-library/library/commerce/instacart/cmd/instacart-pp-cli@latest - Probe . If the tool is unavailable, route to the DevTools fallback: fetch
mcp__claude-in-chrome__tabs_context_mcpand walk the user through it. Stop.docs/backfill-devtools-fallback.md - Run . If orders > 0, this is a top-up run; the resume state will skip already-dumped orders automatically.
instacart-pp-cli history stats --agent
Chrome MCP loop:
- WebFetch the three JS files (cache each in the current session):
https://raw.githubusercontent.com/mvanhorn/printing-press-library/main/library/commerce/instacart/docs/dumper.jshttps://raw.githubusercontent.com/mvanhorn/printing-press-library/main/library/commerce/instacart/docs/extract-one.jshttps://raw.githubusercontent.com/mvanhorn/printing-press-library/main/library/commerce/instacart/docs/export-jsonl.js
- Open or reuse a tab at . If the dumper returns
https://www.instacart.com/store/account/orders, ask the user to pick a profile in the tab, then re-run.profile_picker: true - Inject via
dumper.js. Read backmcp__claude-in-chrome__javascript_toolandtotal_ids.pending_extract - For each order ID in the pending set, navigate to then inject
/store/orders/<id>. Report progress to the user every 10 orders.extract-one.js - When pending reaches 0, inject . It downloads
export-jsonl.jsto the user's default Downloads folder.instacart-orders.jsonl - Run in a Bash tool. Show the summary JSON to the user.
instacart-pp-cli history import ~/Downloads/instacart-orders.jsonl --agent - Verify: . Offer a follow-up sanity check:
instacart-pp-cli history stats --agentand flaginstacart-pp-cli add <retailer> "<something they've bought>" --dry-run --jsonwhen it appears.resolved_via: "history"
Error surfaces worth translating for the user:
- Extractor on every order -> Instacart rotated their web bundle. Report the observed cache keys and point at the rotation-recovery section of the walkthrough doc.
cache_key_missing - Dumper reports fewer IDs than the user expected -> probably on a multi-profile account; ensure the selected profile is the one with purchase history.
- shows 0 orders imported -> the JSONL is empty (only skip records). Re-run the extractor loop with fresh tabs.
history import
当用户触发回填意图时执行此流程。通过WebFetch查看获取完整步骤;以下是摘要:
docs/backfill-walkthrough.md设置检查:
- 确认已在PATH中。如果未安装,执行:
instacart-pp-cli。go install github.com/mvanhorn/printing-press-library/library/commerce/instacart/cmd/instacart-pp-cli@latest - 检查工具是否可用。如果不可用,切换到DevTools备选方案:获取
mcp__claude-in-chrome__tabs_context_mcp并引导用户完成手动操作。停止流程。docs/backfill-devtools-fallback.md - 执行。如果订单数>0,说明是增量回填;恢复状态会自动跳过已导出的订单。
instacart-pp-cli history stats --agent
Chrome MCP循环:
- WebFetch获取三个JS文件(在当前会话中缓存):
https://raw.githubusercontent.com/mvanhorn/printing-press-library/main/library/commerce/instacart/docs/dumper.jshttps://raw.githubusercontent.com/mvanhorn/printing-press-library/main/library/commerce/instacart/docs/extract-one.jshttps://raw.githubusercontent.com/mvanhorn/printing-press-library/main/library/commerce/instacart/docs/export-jsonl.js
- 打开或复用标签页。如果dumper返回
https://www.instacart.com/store/account/orders,请用户在标签页中选择一个账户,然后重新执行。profile_picker: true - 通过注入
mcp__claude-in-chrome__javascript_tool。读取返回的dumper.js和total_ids。pending_extract - 对于每个待提取的订单ID,导航到并注入
/store/orders/<id>。每处理10个订单向用户报告进度。extract-one.js - 当待提取订单数为0时,注入。该文件会将
export-jsonl.js下载到用户默认的下载文件夹。instacart-orders.jsonl - 在Bash工具中执行。将摘要JSON显示给用户。
instacart-pp-cli history import ~/Downloads/instacart-orders.jsonl --agent - 验证:执行。提供后续 sanity check:
instacart-pp-cli history stats --agent,当出现instacart-pp-cli add <retailer> "<用户常购商品>" --dry-run --json时标记成功。resolved_via: "history"
需要向用户解释的错误场景:
- 每个订单都返回提取器错误 -> Instacart更新了网页资源包。向用户报告检测到的缓存键,并引导查看流程文档中的资源包更新恢复章节。
cache_key_missing - Dumper返回的ID数量少于用户预期 -> 可能是多账户;确保选择的账户包含购买历史。
- 显示0个订单导入 -> JSONL文件为空(仅包含跳过记录)。使用新标签页重新执行提取循环。
history import
Direct Use
直接使用
- Check installed:
which instacart-pp-cli - Check auth:
instacart doctor - Capture GraphQL hashes:
instacart capture - (Optional but recommended) Backfill history — run the Backfill Flow above. Unlocks history-first resolution.
add - Run your command with if invoked from an agent
--json
- 检查是否安装:
which instacart-pp-cli - 检查认证状态:
instacart doctor - 获取GraphQL哈希:
instacart capture - (可选但推荐)回填历史记录 — 执行上述回填流程。解锁基于历史记录的优先「添加」解析功能。
- 如果由Agent调用,执行命令时添加参数
--json