apiskill 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MCP.md +5 -5
- package/README.ja.md +8 -8
- package/README.ko.md +8 -8
- package/README.md +113 -12
- package/README.zh.md +113 -12
- package/dist/assets/{index-CPxVZ06Y.js → index-CV6e3HAP.js} +55 -55
- package/dist/assets/index-slFOragU.css +1 -0
- package/dist/index.html +2 -2
- package/docs/cli.ja.md +1 -1
- package/docs/cli.ko.md +1 -1
- package/docs/cli.md +30 -19
- package/docs/cli.zh.md +30 -19
- package/docs/mcp.ja.md +1 -1
- package/docs/mcp.ko.md +1 -1
- package/docs/mcp.md +3 -1
- package/docs/mcp.zh.md +3 -1
- package/docs/web.ja.md +1 -1
- package/docs/web.ko.md +1 -1
- package/docs/web.md +1 -1
- package/docs/web.zh.md +1 -1
- package/package.json +4 -3
- package/scripts/apiskill-cli.mjs +3 -3
- package/scripts/lib/apiskill-core.mjs +5 -4
- package/scripts/lib/openapi-store.mjs +142 -51
- package/scripts/mcp-server.mjs +2 -2
- package/scripts/test-cli-concurrency.mjs +110 -0
- package/src/App.tsx +12 -0
- package/src/styles.css +12 -3
- package/tsconfig.json +3 -3
- package/dist/assets/index-BeAJ1G-n.css +0 -1
package/MCP.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
The detailed MCP documentation has moved to standalone docs:
|
|
4
4
|
|
|
5
|
-
- [English MCP documentation](docs/mcp.md)
|
|
6
|
-
- [中文 MCP 文档](docs/mcp.zh.md)
|
|
5
|
+
- [English MCP documentation](https://unpkg.com/apiskill@latest/docs/mcp.md)
|
|
6
|
+
- [中文 MCP 文档](https://unpkg.com/apiskill@latest/docs/mcp.zh.md)
|
|
7
7
|
|
|
8
8
|
Project overview:
|
|
9
9
|
|
|
10
|
-
- [README](README.md)
|
|
11
|
-
- [Web app docs](docs/web.md) / [Web 中文文档](docs/web.zh.md)
|
|
12
|
-
- [CLI docs](docs/cli.md) / [CLI 中文文档](docs/cli.zh.md)
|
|
10
|
+
- [README](https://unpkg.com/apiskill@latest/README.md)
|
|
11
|
+
- [Web app docs](https://unpkg.com/apiskill@latest/docs/web.md) / [Web 中文文档](https://unpkg.com/apiskill@latest/docs/web.zh.md)
|
|
12
|
+
- [CLI docs](https://unpkg.com/apiskill@latest/docs/cli.md) / [CLI 中文文档](https://unpkg.com/apiskill@latest/docs/cli.zh.md)
|
package/README.ja.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# API Skill
|
|
2
2
|
|
|
3
|
-
[English](README.md) / [中文](README.zh.md) / [한국어](README.ko.md) / [日本語](README.ja.md)
|
|
3
|
+
[English](https://unpkg.com/apiskill@latest/README.md) / [中文](https://unpkg.com/apiskill@latest/README.zh.md) / [한국어](https://unpkg.com/apiskill@latest/README.ko.md) / [日本語](https://unpkg.com/apiskill@latest/README.ja.md)
|
|
4
4
|
|
|
5
|
-
API Skill は、フロントエンド開発と AI 支援開発のためのローカル OpenAPI/Swagger
|
|
5
|
+
API Skill は、フロントエンド開発と AI 支援開発のためのローカル OpenAPI/Swagger ワークスペースです。人向けの Web ワークスペースと AI Agent 向けの CLI/MCP インターフェースが、同じキャッシュ済み API ドキュメントを共有します。
|
|
6
6
|
|
|
7
|
-
- Web アプリ: API
|
|
8
|
-
- CLI:
|
|
9
|
-
- MCP サーバー: 同じ API
|
|
7
|
+
- Web アプリ: 人が API ドキュメントをインポート、閲覧、検索、確認、テストし、バージョンと API 操作を管理するための画面。
|
|
8
|
+
- CLI: AI Agent や自動化処理がドキュメント状態を確認し、必要な API コンテキストを取得・保守するためのコマンド。
|
|
9
|
+
- MCP サーバー: 同じ API の照会・保守機能を Codex や他の AI Agent クライアントへ公開。
|
|
10
10
|
|
|
11
11
|
## Web アプリの使い方
|
|
12
12
|
|
|
@@ -92,9 +92,9 @@ Agent ワークフローでは MCP が最も効果的です。コーディング
|
|
|
92
92
|
|
|
93
93
|
## ドキュメント
|
|
94
94
|
|
|
95
|
-
- Web アプリ: [English](docs/web.md) / [中文](docs/web.zh.md) / [한국어](docs/web.ko.md) / [日本語](docs/web.ja.md)
|
|
96
|
-
- CLI 設定と使い方: [English](docs/cli.md) / [中文](docs/cli.zh.md) / [한국어](docs/cli.ko.md) / [日本語](docs/cli.ja.md)
|
|
97
|
-
- MCP 設定と使い方: [English](docs/mcp.md) / [中文](docs/mcp.zh.md) / [한국어](docs/mcp.ko.md) / [日本語](docs/mcp.ja.md)
|
|
95
|
+
- Web アプリ: [English](https://unpkg.com/apiskill@latest/docs/web.md) / [中文](https://unpkg.com/apiskill@latest/docs/web.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/web.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/web.ja.md)
|
|
96
|
+
- CLI 設定と使い方: [English](https://unpkg.com/apiskill@latest/docs/cli.md) / [中文](https://unpkg.com/apiskill@latest/docs/cli.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/cli.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/cli.ja.md)
|
|
97
|
+
- MCP 設定と使い方: [English](https://unpkg.com/apiskill@latest/docs/mcp.md) / [中文](https://unpkg.com/apiskill@latest/docs/mcp.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/mcp.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/mcp.ja.md)
|
|
98
98
|
|
|
99
99
|
## データモデル
|
|
100
100
|
|
package/README.ko.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# API Skill
|
|
2
2
|
|
|
3
|
-
[English](README.md) / [中文](README.zh.md) / [한국어](README.ko.md) / [日本語](README.ja.md)
|
|
3
|
+
[English](https://unpkg.com/apiskill@latest/README.md) / [中文](https://unpkg.com/apiskill@latest/README.zh.md) / [한국어](https://unpkg.com/apiskill@latest/README.ko.md) / [日本語](https://unpkg.com/apiskill@latest/README.ja.md)
|
|
4
4
|
|
|
5
|
-
API Skill은 프론트엔드 개발과 AI 보조 코딩을 위한 로컬 OpenAPI/Swagger 작업 공간입니다.
|
|
5
|
+
API Skill은 프론트엔드 개발과 AI 보조 코딩을 위한 로컬 OpenAPI/Swagger 작업 공간입니다. 사람을 위한 Web 작업 공간과 AI Agent를 위한 CLI/MCP 인터페이스가 같은 캐시된 API 문서를 공유합니다.
|
|
6
6
|
|
|
7
|
-
- Web 앱: API 문서를 가져오고, 탐색하고, 검색하고, 검사하고,
|
|
8
|
-
- CLI:
|
|
9
|
-
- MCP 서버: 같은 API
|
|
7
|
+
- Web 앱: 사람이 API 문서를 가져오고, 탐색하고, 검색하고, 검사하고, 테스트하며 버전과 API 작업을 관리합니다.
|
|
8
|
+
- CLI: AI Agent와 자동화 작업이 문서 상태를 확인하고 필요한 API 컨텍스트를 조회하거나 유지 관리합니다.
|
|
9
|
+
- MCP 서버: 같은 API 조회 및 유지 관리 기능을 Codex 또는 다른 AI Agent 클라이언트에 제공합니다.
|
|
10
10
|
|
|
11
11
|
## Web 앱 사용
|
|
12
12
|
|
|
@@ -92,9 +92,9 @@ Agent 워크플로는 MCP에서 가장 큰 이점을 얻습니다. 코딩 agent
|
|
|
92
92
|
|
|
93
93
|
## 문서
|
|
94
94
|
|
|
95
|
-
- Web 앱: [English](docs/web.md) / [中文](docs/web.zh.md) / [한국어](docs/web.ko.md) / [日本語](docs/web.ja.md)
|
|
96
|
-
- CLI 구성 및 사용법: [English](docs/cli.md) / [中文](docs/cli.zh.md) / [한국어](docs/cli.ko.md) / [日本語](docs/cli.ja.md)
|
|
97
|
-
- MCP 구성 및 사용법: [English](docs/mcp.md) / [中文](docs/mcp.zh.md) / [한국어](docs/mcp.ko.md) / [日本語](docs/mcp.ja.md)
|
|
95
|
+
- Web 앱: [English](https://unpkg.com/apiskill@latest/docs/web.md) / [中文](https://unpkg.com/apiskill@latest/docs/web.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/web.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/web.ja.md)
|
|
96
|
+
- CLI 구성 및 사용법: [English](https://unpkg.com/apiskill@latest/docs/cli.md) / [中文](https://unpkg.com/apiskill@latest/docs/cli.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/cli.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/cli.ja.md)
|
|
97
|
+
- MCP 구성 및 사용법: [English](https://unpkg.com/apiskill@latest/docs/mcp.md) / [中文](https://unpkg.com/apiskill@latest/docs/mcp.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/mcp.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/mcp.ja.md)
|
|
98
98
|
|
|
99
99
|
## 데이터 모델
|
|
100
100
|
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# API Skill
|
|
2
2
|
|
|
3
|
-
[English](README.md) / [中文](README.zh.md) / [한국어](README.ko.md) / [日本語](README.ja.md)
|
|
3
|
+
[English](https://unpkg.com/apiskill@latest/README.md) / [中文](https://unpkg.com/apiskill@latest/README.zh.md) / [한국어](https://unpkg.com/apiskill@latest/README.ko.md) / [日本語](https://unpkg.com/apiskill@latest/README.ja.md)
|
|
4
4
|
|
|
5
|
-
API Skill is a local OpenAPI/Swagger workspace for frontend and agent-assisted development. It has
|
|
5
|
+
API Skill is a local OpenAPI/Swagger workspace for frontend and agent-assisted development. It has one human-facing workspace and two agent-facing interfaces that share the same cached API documents:
|
|
6
6
|
|
|
7
|
-
- Web app: import, browse, search, inspect, test, and manually maintain API operations.
|
|
8
|
-
- CLI:
|
|
9
|
-
- MCP server: expose the same
|
|
7
|
+
- Web app, for people: import, browse, search, inspect, test, version, and manually maintain API operations.
|
|
8
|
+
- CLI, for AI agents and automation: check document availability, retrieve focused API context, maintain documents, and start local services with predictable commands.
|
|
9
|
+
- MCP server, for AI agents: expose the same query and maintenance actions directly to Codex or other MCP clients.
|
|
10
10
|
|
|
11
11
|
## Web App Usage
|
|
12
12
|
|
|
@@ -30,15 +30,116 @@ After importing or creating a blank document, use the version selector to switch
|
|
|
30
30
|
|
|
31
31
|
After API document data exists, click Start MOCK Service in the web app or run `apiskill mock` in CLI to start a local random-data MOCK API server from the current interface definitions.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
### AI Agent Quick Start
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
|
|
36
|
+
# 1. Check whether API documentation is ready
|
|
37
|
+
apiskill check
|
|
38
|
+
|
|
39
|
+
# 2. Initialize the cache when no document exists
|
|
40
|
+
apiskill import https://example.com/openapi.json
|
|
41
|
+
apiskill crawl https://example.com/swagger
|
|
42
|
+
apiskill import-file ./openapi.yaml
|
|
43
|
+
apiskill document create --title "My API" --doc-version 1.0.0
|
|
44
|
+
|
|
45
|
+
# 3. Retrieve only the API context needed for the current coding task
|
|
46
|
+
apiskill versions
|
|
47
|
+
apiskill query /api/v1/users --method GET
|
|
48
|
+
|
|
49
|
+
# 4. Start a local random-data API from the active document
|
|
50
|
+
apiskill mock
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
CLI and MCP are primarily designed for AI coding agents. Agents should check the cache first, initialize it only when needed, and query a focused endpoint instead of reading the entire OpenAPI document. Run `apiskill --help` for all CLI commands. In MCP clients, start with `apiskill_check`, use `apiskill_search_endpoints` or `apiskill_query_api` to locate an API, and call `apiskill_help` for the complete tool list.
|
|
54
|
+
|
|
55
|
+
### AI Agent CLI CRUD Protocol
|
|
56
|
+
|
|
57
|
+
Use `--json` on commands that support it and parse the response instead of scraping human-readable output. For an isolated project cache, set `APISKILL_CACHE_DIR` to an absolute writable directory before every CLI call. Without it, the global installation uses `~/.apiskill/cache`.
|
|
58
|
+
|
|
59
|
+
1. Check the cache, then create a blank document when no upstream document exists:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
apiskill check --json
|
|
63
|
+
apiskill document create --title "My API" --doc-version 1.0.0 --description "Local API contract" --json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Read `meta.versionId` from the create response and reuse that exact value for every write. `api create` now defaults to the latest version when `--version` is omitted, but agents should still pass it explicitly so every write targets the intended project document.
|
|
67
|
+
|
|
68
|
+
2. Save an API configuration as `api-config.json`:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"api": {
|
|
73
|
+
"method": "post",
|
|
74
|
+
"path": "/api/v1/users/{id}",
|
|
75
|
+
"summary": "Create user",
|
|
76
|
+
"operationId": "createUser",
|
|
77
|
+
"tags": ["Users"],
|
|
78
|
+
"parameters": [
|
|
79
|
+
{ "name": "id", "location": "path", "required": true, "type": "string" }
|
|
80
|
+
],
|
|
81
|
+
"requestBody": {
|
|
82
|
+
"required": true,
|
|
83
|
+
"contentType": "application/json",
|
|
84
|
+
"fields": [
|
|
85
|
+
{ "name": "name", "type": "string", "required": true },
|
|
86
|
+
{ "name": "email", "type": "string", "format": "email" }
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"responses": [
|
|
90
|
+
{
|
|
91
|
+
"status": "200",
|
|
92
|
+
"description": "User created",
|
|
93
|
+
"contentType": "application/json",
|
|
94
|
+
"fields": [
|
|
95
|
+
{ "name": "success", "type": "boolean", "required": true },
|
|
96
|
+
{ "name": "userId", "type": "string" }
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
37
102
|
```
|
|
38
103
|
|
|
39
|
-
|
|
104
|
+
3. Create, inspect, edit, and delete the operation:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
APISKILL_VERSION_ID="value-from-meta.versionId"
|
|
108
|
+
|
|
109
|
+
apiskill api create --version "$APISKILL_VERSION_ID" --file ./api-config.json --json
|
|
110
|
+
apiskill api list --version "$APISKILL_VERSION_ID" --query user --method POST --json
|
|
111
|
+
apiskill api query POST '/api/v1/users/{id}' --version "$APISKILL_VERSION_ID" --format cli
|
|
112
|
+
|
|
113
|
+
# Edit the returned CLI config and save it as api-config.updated.json.
|
|
114
|
+
# POST and the path below identify the original operation; the file contains its replacement.
|
|
115
|
+
apiskill api edit POST '/api/v1/users/{id}' --version "$APISKILL_VERSION_ID" --file ./api-config.updated.json --json
|
|
116
|
+
|
|
117
|
+
# Use the replacement method/path if the edit changed either value.
|
|
118
|
+
apiskill api delete PATCH '/api/v1/users/{id}' --version "$APISKILL_VERSION_ID" --json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
For a batch of operations, pass the same `APISKILL_VERSION_ID` to every command. For compatibility with older CLI releases, an agent should wait for each write to finish before starting the next one, then verify the final set:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
apiskill api create --version "$APISKILL_VERSION_ID" --file ./users.get.json --json
|
|
125
|
+
apiskill api create --version "$APISKILL_VERSION_ID" --file ./users.create.json --json
|
|
126
|
+
apiskill api create --version "$APISKILL_VERSION_ID" --file ./users.delete.json --json
|
|
127
|
+
apiskill api list --version "$APISKILL_VERSION_ID" --json
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The current CLI also serializes writes to the same cache across processes, so an AI tool that accidentally launches these commands in parallel will not lose earlier operations.
|
|
131
|
+
|
|
132
|
+
Agent rules:
|
|
40
133
|
|
|
41
|
-
|
|
134
|
+
- `api query` defaults to JSON and does not accept `--json`; use `--format cli` for a normalized configuration that can be edited and written back.
|
|
135
|
+
- `api edit ORIGINAL_METHOD ORIGINAL_PATH` locates the old operation. The replacement config may change its method or path.
|
|
136
|
+
- Quote paths containing `{id}` or other shell-sensitive characters.
|
|
137
|
+
- `api list --query` searches operation metadata and parameters, not response field names. Use exact `api query METHOD PATH` when method and path are known.
|
|
138
|
+
- A blank document with zero paths makes `check --json` return `ok: false` until at least one API is added. The document still exists; inspect `versionsCount` and `latestVersion`.
|
|
139
|
+
- Missing operations and invalid commands return a nonzero process exit code. Agents should treat that as failure and inspect stderr.
|
|
140
|
+
- `--config '<json-or-yaml>'` is equivalent to `--file`; files are safer for large or nested configurations.
|
|
141
|
+
- After a batch write, run `api list --version ... --json` and verify that every expected method/path exists before reporting success.
|
|
142
|
+
- OpenAPI identifies an operation by its method/path pair. Creating the same pair again intentionally replaces it; `meta.paths` counts distinct paths, not the total number of operations.
|
|
42
143
|
|
|
43
144
|
## Why This Tool Exists
|
|
44
145
|
|
|
@@ -103,9 +204,9 @@ Agent workflows benefit most from MCP. A coding agent can call `apiskill_search_
|
|
|
103
204
|
|
|
104
205
|
## Documentation
|
|
105
206
|
|
|
106
|
-
- Web app: [English](docs/web.md) / [中文](docs/web.zh.md) / [한국어](docs/web.ko.md) / [日本語](docs/web.ja.md)
|
|
107
|
-
- CLI configuration and usage: [English](docs/cli.md) / [中文](docs/cli.zh.md) / [한국어](docs/cli.ko.md) / [日本語](docs/cli.ja.md)
|
|
108
|
-
- MCP configuration and usage: [English](docs/mcp.md) / [中文](docs/mcp.zh.md) / [한국어](docs/mcp.ko.md) / [日本語](docs/mcp.ja.md)
|
|
207
|
+
- Web app: [English](https://unpkg.com/apiskill@latest/docs/web.md) / [中文](https://unpkg.com/apiskill@latest/docs/web.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/web.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/web.ja.md)
|
|
208
|
+
- CLI configuration and usage: [English](https://unpkg.com/apiskill@latest/docs/cli.md) / [中文](https://unpkg.com/apiskill@latest/docs/cli.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/cli.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/cli.ja.md)
|
|
209
|
+
- MCP configuration and usage: [English](https://unpkg.com/apiskill@latest/docs/mcp.md) / [中文](https://unpkg.com/apiskill@latest/docs/mcp.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/mcp.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/mcp.ja.md)
|
|
109
210
|
|
|
110
211
|
## Data Model
|
|
111
212
|
|
package/README.zh.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# API Skill
|
|
2
2
|
|
|
3
|
-
[English](README.md) / [中文](README.zh.md) / [한국어](README.ko.md) / [日本語](README.ja.md)
|
|
3
|
+
[English](https://unpkg.com/apiskill@latest/README.md) / [中文](https://unpkg.com/apiskill@latest/README.zh.md) / [한국어](https://unpkg.com/apiskill@latest/README.ko.md) / [日本語](https://unpkg.com/apiskill@latest/README.ja.md)
|
|
4
4
|
|
|
5
|
-
API Skill 是一个本地 OpenAPI/Swagger 工作区,面向前端开发和 AI
|
|
5
|
+
API Skill 是一个本地 OpenAPI/Swagger 工作区,面向前端开发和 AI 辅助编码。它提供一个面向人的工作台和两个面向 AI Agent 的接口,并共享同一份本地缓存接口文档:
|
|
6
6
|
|
|
7
|
-
- Web
|
|
8
|
-
- CLI
|
|
9
|
-
- MCP
|
|
7
|
+
- Web 端,主要给人使用:导入、浏览、搜索、查看、测试、版本管理和手动维护接口。
|
|
8
|
+
- CLI,主要给 AI Agent 和自动化任务使用:检查文档状态、按需获取接口上下文、维护文档并启动本地服务。
|
|
9
|
+
- MCP 服务,主要给 AI Agent 使用:把同一套查询和维护能力直接暴露给 Codex 或其他 MCP 客户端。
|
|
10
10
|
|
|
11
11
|
## Web 端使用
|
|
12
12
|
|
|
@@ -30,15 +30,116 @@ npm run dev
|
|
|
30
30
|
|
|
31
31
|
已有 API 文档数据后,可以在 Web 端点击“启动MOCK服务”,或在 CLI 里运行 `apiskill mock`,根据当前接口定义启动本地随机数据 MOCK API 服务。
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
### AI Agent 快速使用
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
|
|
36
|
+
# 1. 检查 API 文档是否可用
|
|
37
|
+
apiskill check
|
|
38
|
+
|
|
39
|
+
# 2. 没有文档时初始化缓存
|
|
40
|
+
apiskill import https://example.com/openapi.json
|
|
41
|
+
apiskill crawl https://example.com/swagger
|
|
42
|
+
apiskill import-file ./openapi.yaml
|
|
43
|
+
apiskill document create --title "My API" --doc-version 1.0.0
|
|
44
|
+
|
|
45
|
+
# 3. 只获取当前开发任务需要的接口上下文
|
|
46
|
+
apiskill versions
|
|
47
|
+
apiskill query /api/v1/users --method GET
|
|
48
|
+
|
|
49
|
+
# 4. 根据当前文档启动本地随机数据接口
|
|
50
|
+
apiskill mock
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
CLI 和 MCP 主要面向 AI 编码 Agent。Agent 应先检查缓存,只在缺少文档时初始化,然后按当前任务精确查询接口,避免每次读取整份 OpenAPI 文档。运行 `apiskill --help` 可以查看全部 CLI 命令;在 MCP 客户端中先调用 `apiskill_check`,再使用 `apiskill_search_endpoints` 或 `apiskill_query_api` 定位接口,调用 `apiskill_help` 可查看完整工具列表。
|
|
54
|
+
|
|
55
|
+
### AI Agent CLI 增删改查协议
|
|
56
|
+
|
|
57
|
+
支持 `--json` 的命令应优先使用 JSON 输出并解析字段,不要抓取人类可读文本。需要按项目隔离缓存时,每次调用前将 `APISKILL_CACHE_DIR` 设置为绝对可写目录;未设置时,全局安装默认使用 `~/.apiskill/cache`。
|
|
58
|
+
|
|
59
|
+
1. 检查缓存;没有上游文档时创建空白文档:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
apiskill check --json
|
|
63
|
+
apiskill document create --title "My API" --doc-version 1.0.0 --description "Local API contract" --json
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
从创建结果读取 `meta.versionId`,后续所有写操作都复用这个精确值。现在 `api create` 省略 `--version` 时会默认写入最新版本,但 Agent 仍应显式传入,确保每次都写入目标项目文档。
|
|
67
|
+
|
|
68
|
+
2. 将接口配置保存为 `api-config.json`:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"api": {
|
|
73
|
+
"method": "post",
|
|
74
|
+
"path": "/api/v1/users/{id}",
|
|
75
|
+
"summary": "创建用户",
|
|
76
|
+
"operationId": "createUser",
|
|
77
|
+
"tags": ["Users"],
|
|
78
|
+
"parameters": [
|
|
79
|
+
{ "name": "id", "location": "path", "required": true, "type": "string" }
|
|
80
|
+
],
|
|
81
|
+
"requestBody": {
|
|
82
|
+
"required": true,
|
|
83
|
+
"contentType": "application/json",
|
|
84
|
+
"fields": [
|
|
85
|
+
{ "name": "name", "type": "string", "required": true },
|
|
86
|
+
{ "name": "email", "type": "string", "format": "email" }
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
"responses": [
|
|
90
|
+
{
|
|
91
|
+
"status": "200",
|
|
92
|
+
"description": "用户创建成功",
|
|
93
|
+
"contentType": "application/json",
|
|
94
|
+
"fields": [
|
|
95
|
+
{ "name": "success", "type": "boolean", "required": true },
|
|
96
|
+
{ "name": "userId", "type": "string" }
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
37
102
|
```
|
|
38
103
|
|
|
39
|
-
|
|
104
|
+
3. 新增、读取、修改并删除接口:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
APISKILL_VERSION_ID="value-from-meta.versionId"
|
|
108
|
+
|
|
109
|
+
apiskill api create --version "$APISKILL_VERSION_ID" --file ./api-config.json --json
|
|
110
|
+
apiskill api list --version "$APISKILL_VERSION_ID" --query user --method POST --json
|
|
111
|
+
apiskill api query POST '/api/v1/users/{id}' --version "$APISKILL_VERSION_ID" --format cli
|
|
112
|
+
|
|
113
|
+
# 修改返回的 CLI 配置并保存为 api-config.updated.json。
|
|
114
|
+
# 下面的 POST 和路径用于定位旧接口,文件中保存替换后的新配置。
|
|
115
|
+
apiskill api edit POST '/api/v1/users/{id}' --version "$APISKILL_VERSION_ID" --file ./api-config.updated.json --json
|
|
116
|
+
|
|
117
|
+
# 如果修改时改变了 method 或 path,删除时使用替换后的值。
|
|
118
|
+
apiskill api delete PATCH '/api/v1/users/{id}' --version "$APISKILL_VERSION_ID" --json
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
批量写入多个接口时,每条命令都必须使用同一个 `APISKILL_VERSION_ID`。为了兼容旧版 CLI,Agent 应等待上一条写命令完成后再执行下一条,最后检查完整接口列表:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
apiskill api create --version "$APISKILL_VERSION_ID" --file ./users.get.json --json
|
|
125
|
+
apiskill api create --version "$APISKILL_VERSION_ID" --file ./users.create.json --json
|
|
126
|
+
apiskill api create --version "$APISKILL_VERSION_ID" --file ./users.delete.json --json
|
|
127
|
+
apiskill api list --version "$APISKILL_VERSION_ID" --json
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
当前版本还会在多个进程之间串行化同一缓存目录的写操作,因此 AI 工具即使意外并行执行这些命令,也不会再丢失先写入的接口。
|
|
131
|
+
|
|
132
|
+
Agent 执行规则:
|
|
40
133
|
|
|
41
|
-
|
|
134
|
+
- `api query` 默认输出 JSON,不支持 `--json`;需要可修改并回写的标准配置时使用 `--format cli`。
|
|
135
|
+
- `api edit ORIGINAL_METHOD ORIGINAL_PATH` 的前两个参数定位旧接口,新配置可以改变 method 或 path。
|
|
136
|
+
- 包含 `{id}` 等 shell 特殊字符的路径必须加引号。
|
|
137
|
+
- `api list --query` 搜索接口元数据和参数,不搜索响应字段名。已知 method 和 path 时使用精确的 `api query METHOD PATH`。
|
|
138
|
+
- 空白文档没有任何 path 时,`check --json` 会返回 `ok: false`,直到至少添加一个 API。文档并未丢失,可检查 `versionsCount` 和 `latestVersion`。
|
|
139
|
+
- 接口不存在或命令参数无效时,进程返回非零退出码。Agent 应视为失败并读取 stderr。
|
|
140
|
+
- `--config '<json-or-yaml>'` 与 `--file` 等效;复杂或嵌套配置优先使用文件,避免 shell 转义错误。
|
|
141
|
+
- 批量写入结束后,执行 `api list --version ... --json`,逐一核对预期的 method/path 均存在,再报告任务成功。
|
|
142
|
+
- OpenAPI 使用 method/path 组合唯一标识接口;再次创建相同组合会按预期替换原接口。`meta.paths` 统计的是不同路径数,不是接口操作总数。
|
|
42
143
|
|
|
43
144
|
## 为什么开发这个工具
|
|
44
145
|
|
|
@@ -103,9 +204,9 @@ Agent 工作流最适合接入 MCP。编码 agent 可以先调用 `apiskill_sear
|
|
|
103
204
|
|
|
104
205
|
## 文档
|
|
105
206
|
|
|
106
|
-
- Web 端:[English](docs/web.md) / [中文](docs/web.zh.md) / [한국어](docs/web.ko.md) / [日本語](docs/web.ja.md)
|
|
107
|
-
- CLI 配置和使用:[English](docs/cli.md) / [中文](docs/cli.zh.md) / [한국어](docs/cli.ko.md) / [日本語](docs/cli.ja.md)
|
|
108
|
-
- MCP 配置和使用:[English](docs/mcp.md) / [中文](docs/mcp.zh.md) / [한국어](docs/mcp.ko.md) / [日本語](docs/mcp.ja.md)
|
|
207
|
+
- Web 端:[English](https://unpkg.com/apiskill@latest/docs/web.md) / [中文](https://unpkg.com/apiskill@latest/docs/web.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/web.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/web.ja.md)
|
|
208
|
+
- CLI 配置和使用:[English](https://unpkg.com/apiskill@latest/docs/cli.md) / [中文](https://unpkg.com/apiskill@latest/docs/cli.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/cli.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/cli.ja.md)
|
|
209
|
+
- MCP 配置和使用:[English](https://unpkg.com/apiskill@latest/docs/mcp.md) / [中文](https://unpkg.com/apiskill@latest/docs/mcp.zh.md) / [한국어](https://unpkg.com/apiskill@latest/docs/mcp.ko.md) / [日本語](https://unpkg.com/apiskill@latest/docs/mcp.ja.md)
|
|
109
210
|
|
|
110
211
|
## 数据模型
|
|
111
212
|
|