DIY PC 录入:在 Notion 中自动化硬件库存 - Openclaw Skills

作者:互联网

2026-03-25

AI教程

什么是 DIY PC 录入?

DIY PC 录入是一项技术工作流,旨在弥合原始硬件购买数据与有序的 Notion 库存系统之间的鸿沟。作为 Openclaw Skills 生态系统的核心组件,它允许开发人员和爱好者粘贴来自 Discord 收据或规格列表的文本,随后智能体将其分类为特定类别,如存储、机箱或核心电脑组件。

通过利用 2025-09-03 版本的 Notion data_sources API,此技能可管理复杂的数据转换,包括通过网络搜索进行规格丰富以及智能更新(upsert)逻辑。它确保您的硬件数据库保持准确和最新,无需手动录入的繁琐过程。

下载入口:https://github.com/openclaw/skills/tree/main/skills/nextaltair/openclaw-skill-diy-pc-ingest

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install openclaw-skill-diy-pc-ingest

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 openclaw-skill-diy-pc-ingest。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

DIY PC 录入 应用场景

  • 粘贴 Discord 购买收据以自动更新硬件日志。
  • 将圆点列表形式的电脑规格转换为结构化的 Notion 数据库行。
  • 在多个互联的库存表之间同步新购买的硬件。
  • 使用序列号和健康状态跟踪丰富存储设备的元数据。
DIY PC 录入 工作原理
  1. 智能体读取原始输入文本,并根据组件类型识别目标 Notion 表。
  2. 使用尽力而为的方法提取字段,如果存在日语列名则优先处理。
  3. 该技能执行网络搜索以丰富技术规格,如插槽数量、接口和外形尺寸。
  4. 如果缺失序列号等关键标识符,智能体会提出后续问题以避免数据歧义。
  5. 验证后的数据被格式化为 JSONL 记录,并由专用的 JavaScript 执行脚本处理。
  6. 脚本执行 upsert 操作,通过主键匹配现有行,以修补缺失数据或创建新条目。

DIY PC 录入 配置指南

要将其集成到您的 Openclaw Skills 集合中,请按以下步骤操作:

  1. 复制示例配置文件:
cp skills/diy-pc-ingest/references/config.example.json ~/.config/diy-pc-ingest/config.json
  1. 使用您特定的 Notion data_source_iddatabase_id 值更新 config.json
  2. 将您的 Notion 集成令牌配置为环境变量:
export NOTION_API_KEY='your_integration_token_here'
  1. 确保已安装 Node.js 以执行内部的 scripts/notion_apply_records.js 实用程序。

DIY PC 录入 数据架构与分类体系

该技能使用特定的主键规则在四个规范的 Notion 目标中组织数据,用于记录匹配:

目标表 主键规则 内容类型
机箱 (Enclosure) 显示名称 USB/RAID 外壳、底座和插槽数量
存储 (Storage) 序列号 HDD、SSD、NVMe 详情及健康状态
电脑配置 (PCConfig) 名称 + 购买日期 CPU、GPU、内存和核心系统组件
电脑输入 (PCInput) 标题 通用硬件笔记和杂项日志
name: diy-pc-ingest
description: Ingest pasted PC parts purchase/config text (Discord message receipts, bullet lists) into Notion DIY_PC tables (PCConfig, ストレージ, エンクロージャー, PCInput). Use when the user pastes raw purchase logs/spec notes and wants the AI to classify, enrich via web search, ask follow-up questions for unknowns, and then upsert rows into the correct Notion data sources using the 2025-09-03 data_sources API.

diy-pc-ingest

Setup (required)

This skill is intended to be shared. Do not hardcode your Notion IDs or token in the skill.

  1. Copy the example config:
  • skills/diy-pc-ingest/references/config.example.json~/.config/diy-pc-ingest/config.json
  1. Fill in your Notion targets (IDs):
  • notion.targets.*.data_source_id (for schema/query)
  • notion.targets.*.database_id (for creating pages)
  1. Provide a Notion integration token (choose one):
  • env: NOTION_API_KEY (recommended)
  • or ~/.config/notion/api_key (legacy local path)
  • or inline notion.api_key in config.json (not recommended if you publish/share configs)

Notes:

  • This skill uses Notion-Version 2025-09-03 by default.
  • Targets are read at runtime from config; see references/config.example.json.

Canonical Notion targets

Use data_sources endpoints for schema/query, and pages endpoint for row creation.

(IDs are intentionally not included in this public skill. They live in your local config.)

Workflow (A: user pastes raw text)

  1. Read the pasted text and decide target table per item:

    • エンクロージャー: USB/RAID/HDDケース/ドック、ベイ数、JAN/型番、"安全な取り外し"表示名。
    • ストレージ: HDD/SSD/NVMe/SATA/容量/シリアル/健康状態。
    • PCConfig: CPU/GPU/RAM/PSU/MB/ケース/冷却/NIC/キャプチャ等。
  2. Extract fields (best-effort). Prefer Japanese column names as they exist in each table.

  3. Enrich specs using web_search/web_fetch when it reduces user work (e.g., bay count, interface, capacity, form factor). Keep it minimal; don’t overfill.

  4. Ask follow-up questions only for fields needed to avoid ambiguity or bad joins.

    • ストレージ: Serial missing → ask for serial (or confirm creating as “暫定/シリアル不明”).
    • エンクロージャー: ベイ数 or USB/Thunderbolt/LAN unclear → ask.
    • PCConfig: Identifier/型番 missing but needed to match existing row → ask.
  5. Upsert into Notion using scripts/notion_apply_records.js:

    • Provide JSONL records (one per item) on stdin.
    • Script will:
      • find an existing row by key (see below)
      • patch only missing fields unless overwrite=true
      • otherwise create a new row
  6. Report results (created/updated/skipped) and link any created rows.

Upsert keys (rules)

  • ストレージ: シリアル (exact) is the primary key. If the existing row was created without serial, allow a safe fallback match by title + (optional) 購入日/価格(円) to support post-fill of serial/health/scan-date.
  • エンクロージャー: 取り外し表示名 (exact) else title/name.
  • PCConfig: (Name + Purchase Date) を複合キーとして扱う(exact)。重複ヒット時は書き込まず質問。
  • If a key collides with multiple rows, do not write; ask user.

JSONL input format for the apply script

Each line is a JSON object:

{"target":"enclosure","title":"RATOC RS-EC32-R5G","properties":{"種別":"USBケース","接続":"USB","ベイ数":2,"普段つないでるPC":"RECRYZEN","購入日":"2026-01-18","購入店":"PCワンズ","価格(円)":8977,"取り外し表示名":"RS-EC32-R5G","メモ":"JAN: 4949090752191"}}

Optional control fields (for cleanup / manual fixes):

  • page_id (or id): update this Notion page directly (bypasses upsert matching)
  • archive: true: archive the page (useful for de-dup)
  • overwrite: true: allow overwriting existing values (including clearing with null)

Optional behavior flags:

  • mirror_to_pcconfig: true (only for target=storage): also create/update a pcconfig row for the installed component.
    • requires: 現在の接続先PC, 購入日, Name

Targets: enclosure | storage | pcconfig | pcinput

Property value encoding:

  • select/status: string name
  • rich_text: string
  • number: number
  • date: YYYY-MM-DD
  • checkbox: boolean
  • relation: array of page_ids (advanced; avoid unless needed)

Notes

  • Always use Notion-Version 2025-09-03.
  • Prefer POST /v1/data_sources/{id}/query over /databases/{id}/query.
  • Relation schema updates require relation.data_source_id (not database_id).

Note (implementation)

  • JS implementation is the default: scripts/notion_apply_records.js
  • Legacy Python implementation is kept for reference: scripts/_deprecated/notion_apply_records.py