From 034f00e2e75edb8d442739785a7efa89eb1a1c92 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 12 Jan 2026 15:44:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=20IoT=20SIM=20=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=A8=A1=E5=9D=97=E6=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=92=8C=E6=95=B0=E6=8D=AE=E5=BA=93=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 IoT 核心业务表:运营商、IoT 卡、设备、号卡、套餐、订单等 - 添加分佣系统表:分佣规则、分佣记录、运营商结算等 - 添加轮询和流量管理表:轮询配置、流量使用记录等 - 添加财务和系统管理表:佣金提现、换卡申请等 - 实现完整的 GORM 模型和常量定义 - 添加数据库迁移脚本和详细文档 - 集成 OpenSpec 工作流工具(opsx 命令和 skills) Co-Authored-By: Claude Sonnet 4.5 --- .claude/commands/opsx/apply.md | 154 +++ .claude/commands/opsx/archive.md | 175 +++ .claude/commands/opsx/continue.md | 110 ++ .claude/commands/opsx/ff.md | 91 ++ .claude/commands/opsx/new.md | 69 ++ .claude/commands/opsx/sync.md | 134 +++ .claude/skills/openspec-apply-change/SKILL.md | 152 +++ .../skills/openspec-archive-change/SKILL.md | 126 ++ .../skills/openspec-continue-change/SKILL.md | 108 ++ .claude/skills/openspec-ff-change/SKILL.md | 89 ++ .claude/skills/openspec-new-change/SKILL.md | 68 ++ .claude/skills/openspec-sync-specs/SKILL.md | 132 +++ docs/iot-sim-management/分佣系统说明.md | 940 +++++++++++++++ docs/iot-sim-management/实施总结.md | 491 ++++++++ docs/iot-sim-management/数据模型总结.md | 658 +++++++++++ docs/iot-sim-management/表结构详细说明.md | 1020 +++++++++++++++++ docs/iot-sim-management/轮询机制说明.md | 776 +++++++++++++ go.mod | 2 +- internal/iot/model/carrier.go | 20 + internal/iot/model/commission.go | 164 +++ internal/iot/model/data_usage.go | 20 + internal/iot/model/device.go | 31 + internal/iot/model/financial.go | 70 ++ internal/iot/model/iot_card.go | 39 + internal/iot/model/number_card.go | 25 + internal/iot/model/order.go | 35 + internal/iot/model/package.go | 107 ++ internal/iot/model/polling.go | 28 + internal/iot/model/system.go | 45 + ..._create_iot_sim_management_tables.down.sql | 38 + ...05_create_iot_sim_management_tables.up.sql | 841 ++++++++++++++ .../.openspec.yaml | 2 + .../2026-01-12-iot-sim-management/design.md | 964 ++++++++++++++++ .../2026-01-12-iot-sim-management/proposal.md | 113 ++ .../specs/iot-agent-commission/spec.md | 328 ++++++ .../specs/iot-card/spec.md | 291 +++++ .../specs/iot-device/spec.md | 311 +++++ .../specs/iot-number-card/spec.md | 160 +++ .../specs/iot-order/spec.md | 233 ++++ .../specs/iot-package/spec.md | 211 ++++ .../2026-01-12-iot-sim-management/tasks.md | 441 +++++++ openspec/specs/iot-agent-commission/spec.md | 346 ++++++ openspec/specs/iot-card/spec.md | 304 +++++ openspec/specs/iot-device/spec.md | 325 ++++++ openspec/specs/iot-number-card/spec.md | 175 +++ openspec/specs/iot-order/spec.md | 248 ++++ openspec/specs/iot-package/spec.md | 226 ++++ pkg/constants/iot.go | 240 ++++ 48 files changed, 11675 insertions(+), 1 deletion(-) create mode 100644 .claude/commands/opsx/apply.md create mode 100644 .claude/commands/opsx/archive.md create mode 100644 .claude/commands/opsx/continue.md create mode 100644 .claude/commands/opsx/ff.md create mode 100644 .claude/commands/opsx/new.md create mode 100644 .claude/commands/opsx/sync.md create mode 100644 .claude/skills/openspec-apply-change/SKILL.md create mode 100644 .claude/skills/openspec-archive-change/SKILL.md create mode 100644 .claude/skills/openspec-continue-change/SKILL.md create mode 100644 .claude/skills/openspec-ff-change/SKILL.md create mode 100644 .claude/skills/openspec-new-change/SKILL.md create mode 100644 .claude/skills/openspec-sync-specs/SKILL.md create mode 100644 docs/iot-sim-management/分佣系统说明.md create mode 100644 docs/iot-sim-management/实施总结.md create mode 100644 docs/iot-sim-management/数据模型总结.md create mode 100644 docs/iot-sim-management/表结构详细说明.md create mode 100644 docs/iot-sim-management/轮询机制说明.md create mode 100644 internal/iot/model/carrier.go create mode 100644 internal/iot/model/commission.go create mode 100644 internal/iot/model/data_usage.go create mode 100644 internal/iot/model/device.go create mode 100644 internal/iot/model/financial.go create mode 100644 internal/iot/model/iot_card.go create mode 100644 internal/iot/model/number_card.go create mode 100644 internal/iot/model/order.go create mode 100644 internal/iot/model/package.go create mode 100644 internal/iot/model/polling.go create mode 100644 internal/iot/model/system.go create mode 100644 migrations/000005_create_iot_sim_management_tables.down.sql create mode 100644 migrations/000005_create_iot_sim_management_tables.up.sql create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/.openspec.yaml create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/design.md create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/proposal.md create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/specs/iot-agent-commission/spec.md create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/specs/iot-card/spec.md create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/specs/iot-device/spec.md create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/specs/iot-number-card/spec.md create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/specs/iot-order/spec.md create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/specs/iot-package/spec.md create mode 100644 openspec/changes/archive/2026-01-12-iot-sim-management/tasks.md create mode 100644 openspec/specs/iot-agent-commission/spec.md create mode 100644 openspec/specs/iot-card/spec.md create mode 100644 openspec/specs/iot-device/spec.md create mode 100644 openspec/specs/iot-number-card/spec.md create mode 100644 openspec/specs/iot-order/spec.md create mode 100644 openspec/specs/iot-package/spec.md create mode 100644 pkg/constants/iot.go diff --git a/.claude/commands/opsx/apply.md b/.claude/commands/opsx/apply.md new file mode 100644 index 0000000..4f1b61d --- /dev/null +++ b/.claude/commands/opsx/apply.md @@ -0,0 +1,154 @@ +--- +name: OPSX: Apply +description: Implement tasks from an OpenSpec change (Experimental) +category: Workflow +tags: [workflow, artifacts, experimental] +--- + +Implement tasks from an OpenSpec change. + +**Input**: Optionally specify `--change ` after `/opsx:apply`. If omitted, MUST prompt for available changes. + +**Steps** + +1. **If no change name provided, prompt for selection** + + Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select. + + Show changes that are implementation-ready (have tasks artifact). + Include the schema used for each change if available. + Mark changes with incomplete tasks as "(In Progress)". + + **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose. + +2. **Check status to understand the schema** + ```bash + openspec status --change "" --json + ``` + Parse the JSON to understand: + - `schemaName`: The workflow being used (e.g., "spec-driven", "tdd") + - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others) + +3. **Get apply instructions** + + ```bash + openspec instructions apply --change "" --json + ``` + + This returns: + - Context file paths (varies by schema) + - Progress (total, complete, remaining) + - Task list with status + - Dynamic instruction based on current state + + **Handle states:** + - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue` + - If `state: "all_done"`: congratulate, suggest archive + - Otherwise: proceed to implementation + +4. **Read context files** + + Read the files listed in `contextFiles` from the apply instructions output. + The files depend on the schema being used: + - **spec-driven**: proposal, specs, design, tasks + - **tdd**: spec, tests, implementation, docs + - Other schemas: follow the contextFiles from CLI output + +5. **Show current progress** + + Display: + - Schema being used + - Progress: "N/M tasks complete" + - Remaining tasks overview + - Dynamic instruction from CLI + +6. **Implement tasks (loop until done or blocked)** + + For each pending task: + - Show which task is being worked on + - Make the code changes required + - Keep changes minimal and focused + - Mark task complete in the tasks file: `- [ ]` → `- [x]` + - Continue to next task + + **Pause if:** + - Task is unclear → ask for clarification + - Implementation reveals a design issue → suggest updating artifacts + - Error or blocker encountered → report and wait for guidance + - User interrupts + +7. **On completion or pause, show status** + + Display: + - Tasks completed this session + - Overall progress: "N/M tasks complete" + - If all done: suggest archive + - If paused: explain why and wait for guidance + +**Output During Implementation** + +``` +## Implementing: (schema: ) + +Working on task 3/7: +[...implementation happening...] +✓ Task complete + +Working on task 4/7: +[...implementation happening...] +✓ Task complete +``` + +**Output On Completion** + +``` +## Implementation Complete + +**Change:** +**Schema:** +**Progress:** 7/7 tasks complete ✓ + +### Completed This Session +- [x] Task 1 +- [x] Task 2 +... + +All tasks complete! Ready to archive this change. +``` + +**Output On Pause (Issue Encountered)** + +``` +## Implementation Paused + +**Change:** +**Schema:** +**Progress:** 4/7 tasks complete + +### Issue Encountered + + +**Options:** +1.