{
  "schema_version": 1,
  "type": "skill",
  "slug": "process-datasheets",
  "title": "Process Datasheets (Batch)",
  "brief": "Batch-process datasheets from the shared queue. Claims items, parses PDFs into wiki markdown, publishes to the Adom Wiki, and loops until a time budget expires or the queue is empty.",
  "version": "1.0.0",
  "tags": [],
  "license": "MIT",
  "source_path": "SKILL.md",
  "readme": "---\nname: process-datasheets\ndescription: \"Batch-process datasheets from the shared queue. Claims items, parses PDFs into wiki markdown, publishes to the Adom Wiki, and loops until a time budget expires or the queue is empty. Use with: /process-datasheets --until 17:00\"\nuser-invocable: true\n---\n\n# Process Datasheets\n\nBatch-process datasheets from the shared parsing queue. Claims the next highest-priority item, parses it using the datasheet-parser workflow, publishes to the Adom Wiki, then loops until time runs out or the queue is empty.\n\n## Prerequisites\n\n- `datasheet-queue` MCP server configured (provides `claim_datasheet`, `submit_result`, `release_datasheet`, `fail_datasheet`, `check_time_budget`, `heartbeat_datasheet` tools)\n- `poppler-utils` and `imagemagick` installed\n- `adom-wiki` CLI available\n\n## Usage\n\n```\n/process-datasheets --until 17:00\n/process-datasheets --until 17:00 --interval 30m\n/process-datasheets --count 3\n```\n\n### Arguments\n\n- `--until <HH:MM or ISO>` — Stop processing at this time (default: 1 hour from now)\n- `--count <N>` — Process at most N datasheets then stop\n- `--interval <Nm>` — (For use with `/loop`) Pause between runs; the skill processes one item per invocation when this is set\n\n## Agent Identity\n\nDetermine your agent ID from the container hostname:\n\n```bash\nAGENT_ID=$(hostname)\n```\n\nUse this as `agent_id` in all MCP tool calls.\n\n## Workflow\n\n### Step 0: Parse Arguments\n\nExtract `--until`, `--count`, and `--interval` from the skill arguments. Defaults:\n- `until`: 1 hour from now\n- `count`: unlimited\n- `interval`: not set (process continuously)\n\n### Step 1: Check Time Budget\n\nBefore claiming anything, verify there's time left:\n\n```\ncheck_time_budget({ stop_time: \"<until value>\", min_minutes_needed: 10 })\n```\n\nIf `continue` is false, **stop immediately** — do not claim an item you can't finish.\n\n### Step 2: Claim Next Datasheet\n\n```\nclaim_datasheet({ agent_id: \"<AGENT_ID>\" })\n```\n\nIf the queue is empty, stop — there's nothing to do.\n\nSave the returned `item.id`, `item.part_name`, and `item.pdf_url` for the next steps.\n\n### Step 3: Parse the Datasheet\n\nFollow the **datasheet-parser** skill workflow (Steps 1–7):\n\n1. **Download the PDF** — use `item.pdf_url` if provided, otherwise WebSearch for it\n2. **Extract text** with `pdftotext`\n3. **Extract and classify images** with `pdfimages`\n4. **Optimize images** for web upload (resize, compress)\n5. **Generate wiki markdown** — structured `.md` matching the wiki renderer format\n6. **Prepare metadata JSON** — manufacturer, part number, packages, etc.\n7. **Publish to wiki** — `adom-wiki page publish` + metadata API call + asset uploads\n\n**During long parses**, send a heartbeat every 10 minutes to prevent claim timeout:\n\n```\nheartbeat_datasheet({ item_id: <id>, agent_id: \"<AGENT_ID>\" })\n```\n\n### Step 4: Submit Result\n\nAfter successful publish:\n\n```\nsubmit_result({ item_id: <id>, agent_id: \"<AGENT_ID>\", wiki_slug: \"datasheets/<partname>\" })\n```\n\n### Step 5: Handle Failures\n\nIf parsing fails at any step:\n\n- **Recoverable** (network timeout, temp file issue) → release back to queue:\n  ```\n  release_datasheet({ item_id: <id>, agent_id: \"<AGENT_ID>\" })\n  ```\n\n- **Permanent** (corrupt PDF, no extractable data, part doesn't exist) → mark failed:\n  ```\n  fail_datasheet({ item_id: <id>, agent_id: \"<AGENT_ID>\", reason: \"Detailed error description\" })\n  ```\n\n### Step 6: Loop or Stop\n\nAfter completing (or failing) one datasheet:\n\n1. Decrement `--count` if set. If count reaches 0, **stop**.\n2. If `--interval` is set, **stop** (the `/loop` scheduler will re-invoke).\n3. Call `check_time_budget` again. If `continue` is false, **stop**.\n4. If the queue had items and time remains, **go back to Step 2**.\n\n## Error Recovery\n\n| Situation | Action |\n|-----------|--------|\n| PDF download fails (404, timeout) | `fail_datasheet` with reason |\n| `pdftotext` produces no output | `fail_datasheet` — likely a scanned/image PDF |\n| `adom-wiki page publish` fails | `release_datasheet` — might be a transient wiki issue |\n| Agent crashes mid-parse | Queue auto-releases after 30min timeout |\n| Time budget expired mid-parse | `release_datasheet` — let another agent finish later |\n\n## Example Session\n\n```\n> /process-datasheets --until 17:00\n\nChecking time budget... 2h 45m remaining, 8 items pending.\n\nClaiming next datasheet...\n  Claimed #5 — STM32F103 [P10]\n  PDF: https://www.st.com/resource/en/datasheet/stm32f103c8.pdf\n\nDownloading PDF... done (1.2MB)\nExtracting text... done (45 pages)\nExtracting images... 23 images found\nClassifying and optimizing... 12 key diagrams selected\nGenerating wiki markdown... done\nPublishing to wiki... done (datasheets/stm32f103)\nUploading 12 diagram assets... done\n\nSubmitted result for #5.\n\nChecking time budget... 2h 12m remaining, 7 items pending.\nClaiming next datasheet...\n  Claimed #8 — ESP32-S3 [P20]\n  ...\n```\n\n## Scheduling\n\n### Pattern A: Single session with /loop\n\n```\n/loop 30m /process-datasheets --until 17:00 --interval 30m\n```\n\nEvery 30 minutes, the skill claims and processes one item. Stops when the clock hits 17:00.\n\n### Pattern B: Scheduled task (persistent)\n\n```\n/schedule every 30 minutes /process-datasheets --until 17:00 --interval 30m\n```\n\nSurvives session restarts. Each trigger processes one item.\n\n### Pattern C: Continuous until done\n\n```\n/process-datasheets --until 17:00\n```\n\nProcesses items back-to-back until time runs out or the queue is empty.\n\n## MCP Server Configuration\n\nUsers add this to their `.mcp.json` or settings:\n\n```json\n{\n  \"mcpServers\": {\n    \"datasheet-queue\": {\n      \"url\": \"https://6kgcmtonzymg.adom.cloud/mcp\"\n    }\n  }\n}\n```\n",
  "author": {
    "name": "Kyle Bergstedt",
    "email": "kyle@adom.inc"
  },
  "visibility": {
    "public": true
  },
  "hero": null,
  "sample_prompts": [],
  "discovery_triggers": [],
  "discovery_pitch": null,
  "metadata": {},
  "created_at": "2026-05-28T05:30:04.872Z",
  "updated_at": "2026-05-28T05:30:04.872Z",
  "sub_skills": [],
  "parent_app": null,
  "org": "adom"
}