|
| 1 | +# Migrate To Apifox Skill Implementation Plan |
| 2 | + |
| 3 | +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| 4 | +
|
| 5 | +**Goal:** Create a personal agent skill for migrating API documentation from project source code, OpenAPI, Postman, or Swagger into Apifox project JSON. |
| 6 | + |
| 7 | +**Architecture:** The skill lives under `/Users/lxhtt/.agents/skills/migrate-to-apifox`. `SKILL.md` gives the workflow and trigger rules, `APIFOX_FORMAT.md` records the observed Apifox project shape from `/Users/lxhtt/Downloads/schema-test.apifox.json`, and `scripts/validate-apifox.js` performs deterministic structure checks. |
| 8 | + |
| 9 | +**Tech Stack:** Markdown skill instructions, Apifox project JSON, Node.js validation script using only built-in modules. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +### Task 1: Skill instructions and format reference |
| 14 | + |
| 15 | +**Files:** |
| 16 | +- Create: `/Users/lxhtt/.agents/skills/migrate-to-apifox/SKILL.md` |
| 17 | +- Create: `/Users/lxhtt/.agents/skills/migrate-to-apifox/APIFOX_FORMAT.md` |
| 18 | +- Create: `/Users/lxhtt/.agents/skills/migrate-to-apifox/scripts/validate-apifox.js` |
| 19 | + |
| 20 | +- [x] **Step 1: Inspect Apifox sample** |
| 21 | + |
| 22 | +Run: |
| 23 | + |
| 24 | +```bash |
| 25 | +python3 -m json.tool /Users/lxhtt/Downloads/schema-test.apifox.json >/tmp/schema-test.pretty.json |
| 26 | +``` |
| 27 | + |
| 28 | +Expected: command exits 0 and reveals root collections such as `apiCollection`, `webSocketCollection`, and `schemaCollection`. |
| 29 | + |
| 30 | +- [x] **Step 2: Write `SKILL.md`** |
| 31 | + |
| 32 | +Include triggers for Apifox migration, source-code extraction, OpenAPI, Swagger, and Postman conversion. Keep the file under 100 lines and link to `APIFOX_FORMAT.md`. |
| 33 | + |
| 34 | +- [x] **Step 3: Write `APIFOX_FORMAT.md`** |
| 35 | + |
| 36 | +Document the project root shape, HTTP API item shape, WebSocket API item shape, schema item shape, and migration rules that prevent WebSocket APIs from being represented as HTTP `GET`. |
| 37 | + |
| 38 | +- [x] **Step 4: Write validation script** |
| 39 | + |
| 40 | +Create `scripts/validate-apifox.js` with checks for: |
| 41 | + |
| 42 | +- root `$schema.app === "apifox"` |
| 43 | +- at least one of `apiCollection`, `webSocketCollection`, or `schemaCollection` |
| 44 | +- HTTP APIs have lowercase `method`; `api.type` may be omitted in Apifox samples and defaults to HTTP |
| 45 | +- webhook items under `apiCollection` are accepted with `api.type === "webhook"` |
| 46 | +- WebSocket APIs have no `method`; `api.type` may be omitted in Apifox samples or set to `websocket` |
| 47 | +- schema items carry `schema.jsonSchema` |
| 48 | + |
| 49 | +- [x] **Step 5: Validate the skill artifacts** |
| 50 | + |
| 51 | +Run: |
| 52 | + |
| 53 | +```bash |
| 54 | +node /Users/lxhtt/.agents/skills/migrate-to-apifox/scripts/validate-apifox.js /Users/lxhtt/Downloads/schema-test.apifox.json |
| 55 | +node /Users/lxhtt/.agents/skills/migrate-to-apifox/scripts/validate-apifox.js MCServerLauncher.Daemon/.Resources/Docs/apifox.json |
| 56 | +python3 - <<'PY' |
| 57 | +from pathlib import Path |
| 58 | +p = Path('/Users/lxhtt/.agents/skills/migrate-to-apifox/SKILL.md') |
| 59 | +print(len(p.read_text().splitlines())) |
| 60 | +PY |
| 61 | +git diff --check |
| 62 | +``` |
| 63 | + |
| 64 | +Expected: validation commands exit 0, `SKILL.md` stays below 100 lines, and `git diff --check` exits 0. |
| 65 | + |
| 66 | +## Changelog |
| 67 | + |
| 68 | +- Created this plan for the `migrate-to-apifox` personal skill. |
| 69 | +- Added `migrate-to-apifox` with a concise `SKILL.md`, an Apifox format reference, and a Node.js validation script. |
| 70 | +- Validated the script against `/Users/lxhtt/Downloads/schema-test.apifox.json` and `MCServerLauncher.Daemon/.Resources/Docs/apifox.json`. |
| 71 | +- Expanded the skill from a narrow HTTP/WebSocket/schema migration helper into a full Apifox project migration skill covering raw socket services, Socket.IO, MCP, custom endpoint protocols, reusable components, auth, tests, and environments. |
| 72 | +- Added strict native validation after Apifox imported a generated daemon project with zero recognized APIs. The fix aligns WebSocket items with Apifox's native export shape by omitting `api.type`, while still forbidding `api.method`, and checks HTTP API metadata required by native project imports. |
| 73 | +- Updated the daemon Apifox export to match `/Users/lxhtt/Downloads/pingws.json`: WebSocket APIs are nested under `根目录 -> WebSocket actions`, payloads are stored in `api.requestBody.message`, and `api.parameters` carries query/path/cookie/header buckets. |
| 74 | +- Updated the daemon Apifox export and skill rules so WebSocket action `api.path` no longer embeds `{{wsUrl}}?token={{token}}`; the environment owns the WebSocket base URL and `token` is documented in `api.parameters.query`. |
| 75 | +- Updated dynamic value and native-variable rules: WebSocket request IDs use Apifox dynamic values such as `{{$string.uuid}}`, environment/global variables use native `name` fields, and shared daemon token auth lives in root `commonParameters.parameters.query`. |
| 76 | +- Updated daemon Apifox guidance so the project homepage explains how to obtain MainToken, `globalVariables` no longer duplicates `baseUrl` or `wsUrl`, environment variables no longer carry `token`, `permissions`, or `expires`, and users are directed to edit environment management -> global parameters -> Query -> `token`. |
0 commit comments