typespec-create-api-plugin — скилл GitHub Copilot: установка
Создаёт TypeSpec-плагин для Microsoft 365 Copilot, который вызывает внешний REST API. Подходит, когда нужны операции, авторизация и карточки ответов.
npx skills add github/awesome-copilot --skill typespec-create-api-plugin -a claude-codeЧто делает typespec-create-api-plugin
Скилл сначала уточняет адрес и назначение API, нужные CRUD-операции, способ авторизации, подтверждения и необходимость Adaptive Cards. Затем он готовит main.tsp с описанием агента и actions.tsp с маршрутами, HTTP-методами, параметрами и моделями ответов.
Для API доступны публичный доступ, API key, OAuth2 и зарегистрированная ссылка авторизации. Для опасных действий можно добавить диалог подтверждения, а результаты со списками вывести через Adaptive Cards и cards/card.json. Ставить стоит командам, которые описывают REST-интеграции Microsoft 365 Copilot на TypeSpec; для API без Copilot-плагина этот скилл лишний.
Какие задачи решает
- описать REST-операции в
actions.tsp - создать
main.tspс определением агента - подключить API key или OAuth2
- добавить подтверждение перед удалением данных
- вывести список результатов через Adaptive Cards
Примеры запросов агенту
- Создай TypeSpec-плагин для API с базовым URL и операциями CRUD.
- Добавь OAuth2 в `actions.tsp` и операции `listProjects` и `createTicket`.
- Сделай Adaptive Card в `cards/card.json` для ответа со списком элементов.
Как установить typespec-create-api-plugin
1Через Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill typespec-create-api-plugin -a claude-code2Вручную: положить файлы
~/.claude/skills/typespec-create-api-plugin/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/typespec-create-api-plugin/
Вручную: положить файлы
.agents/skills/typespec-create-api-plugin/SKILL.mdДля всех проектов — ~/.agents/skills/
Вручную: положить файлы
.cursor/skills/typespec-create-api-plugin/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1Через Skills CLI (Vercel)
npx skills add github/awesome-copilot --skill typespec-create-api-plugin2GitHub CLI
gh skill install github/awesome-copilot typespec-create-api-plugin3Вручную: положить файлы
.github/skills/typespec-create-api-plugin/SKILL.mdКомандой платформы
gemini skills install https://github.com/github/awesome-copilot --path skills/typespec-create-api-pluginВручную: положить файлы
.devin/skills/typespec-create-api-plugin/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
Похожие
Вопросы о typespec-create-api-plugin
Как установить typespec-create-api-plugin в GitHub Copilot?
Выполните npx skills add github/awesome-copilot --skill typespec-create-api-plugin. Также доступна команда gh skill install github/awesome-copilot typespec-create-api-plugin.
Что делает typespec-create-api-plugin?
Скилл генерирует файлы TypeSpec для плагина Microsoft 365 Copilot, который работает с внешним REST API. Он создаёт описание агента, операции API и модели данных.
Какие способы авторизации поддерживает скилл?
Можно оставить API публичным, использовать API key, OAuth2 или зарегистрированную ссылку авторизации. Способ выбирают по требованиям подключаемого API.
Исходный текст
SKILL.md · MIT
---
name: typespec-create-api-plugin
description: 'Generate a TypeSpec API plugin with REST operations, authentication, and Adaptive Cards for Microsoft 365 Copilot'
---
# Create TypeSpec API Plugin
Create a complete TypeSpec API plugin for Microsoft 365 Copilot that integrates with external REST APIs.
## Requirements
Generate TypeSpec files with:
### main.tsp - Agent Definition
```typescript
import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
import "./actions.tsp";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
using TypeSpec.M365.Copilot.Actions;
@agent({
name: "[Agent Name]",
description: "[Description]"
})
@instructions("""
[Instructions for using the API operations]
""")
namespace [AgentName] {
// Reference operations from actions.tsp
op operation1 is [APINamespace].operationName;
}
```
### actions.tsp - API Operations
```typescript
import "@typespec/http";
import "@microsoft/typespec-m365-copilot";
using TypeSpec.Http;
using TypeSpec.M365.Copilot.Actions;
@service
@actions(#{
nameForHuman: "[API Display Name]",
descriptionForModel: "[Model description]",
descriptionForHuman: "[User description]"
})
@server("[API_BASE_URL]", "[API Name]")
@useAuth([AuthType]) // Optional
namespace [APINamespace] {
@route("[/path]")
@get
@action
op operationName(
@path param1: string,
@query param2?: string
): ResponseModel;
model ResponseModel {
// Response structure
}
}
```
## Authentication Options
Choose based on API requirements:
1. **No Authentication** (Public APIs)
```typescript
// No @useAuth decorator needed
```
2. **API Key**
```typescript
@useAuth(ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">)
```
3. **OAuth2**
```typescript
@useAuth(OAuth2Auth<[{
type: OAuth2FlowType.authorizationCode;
authorizationUrl: "https://oauth.example.com/authorize";
tokenUrl: "https://oauth.example.com/token";
refreshUrl: "https://oauth.example.com/token";
scopes: ["read", "write"];
}]>)
```
4. **Registered Auth Reference**
```typescript
@useAuth(Auth)
@authReferenceId("registration-id-here")
model Auth is ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">
```
## Function Capabilities
### Confirmation Dialog
```typescript
@capabilities(#{
confirmation: #{
type: "AdaptiveCard",
title: "Confirm Action",
body: """
Are you sure you want to perform this action?
* **Parameter**: {{ function.parameters.paramName }}
"""
}
})
```
### Adaptive Card Response
```typescript
@card(#{
dataPath: "$.items",
title: "$.title",
url: "$.link",
file: "cards/card.json"
})
```
### Reasoning & Response Instructions
```typescript
@reasoning("""
Consider user's context when calling this operation.
Prioritize recent items over older ones.
""")
@responding("""
Present results in a clear table format with columns: ID, Title, Status.
Include a summary count at the end.
""")
```
## Best Practices
1. **Operation Names**: Use clear, action-oriented names (listProjects, createTicket)
2. **Models**: Define TypeScript-like models for requests and responses
3. **HTTP Methods**: Use appropriate verbs (@get, @post, @patch, @delete)
4. **Paths**: Use RESTful path conventions with @route
5. **Parameters**: Use @path, @query, @header, @body appropriately
6. **Descriptions**: Provide clear descriptions for model understanding
7. **Confirmations**: Add for destructive operations (delete, update critical data)
8. **Cards**: Use for rich visual responses with multiple data items
## Workflow
Ask the user:
1. What is the API base URL and purpose?
2. What operations are needed (CRUD operations)?
3. What authentication method does the API use?
4. Should confirmations be required for any operations?
5. Do responses need Adaptive Cards?
Then generate:
- Complete `main.tsp` with agent definition
- Complete `actions.tsp` with API operations and models
- Optional `cards/card.json` if Adaptive Cards are needed
© github · MIT · github/awesome-copilot