typespec-create-api-plugin

oleh github

Hasilkan plugin API TypeSpec untuk Microsoft 365 Copilot dengan operasi REST, autentikasi, dan Kartu Adaptif. Membangun proyek TypeSpec lengkap dengan definisi agen (main.tsp) dan operasi API (actions.tsp) sesuai konvensi Microsoft 365 Copilot. Mendukung empat mode autentikasi: API publik, header kunci API, OAuth2 dengan alur kode otorisasi, dan referensi auth terdaftar. Menyertakan dialog konfirmasi opsional untuk operasi destruktif dan templat Kartu Adaptif untuk...

npx skills add https://github.com/github/awesome-copilot --skill typespec-create-api-plugin

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

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

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)

    // No @useAuth decorator needed
    
  2. API Key

    @useAuth(ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">)
    
  3. OAuth2

    @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

    @useAuth(Auth)
    
    @authReferenceId("registration-id-here")
    model Auth is ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">
    

Function Capabilities

Confirmation Dialog

@capabilities(#{
  confirmation: #{
    type: "AdaptiveCard",
    title: "Confirm Action",
    body: """
    Are you sure you want to perform this action?
      * **Parameter**: {{ function.parameters.paramName }}
    """
  }
})

Adaptive Card Response

@card(#{
  dataPath: "$.items",
  title: "$.title",
  url: "$.link",
  file: "cards/card.json"
})

Reasoning & Response Instructions

@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

Lebih banyak skill dari github

console-rendering
github
Instruksi untuk menggunakan sistem rendering konsol berbasis tag struct di Go
official
acquire-codebase-knowledge
github
Gunakan keterampilan ini ketika pengguna secara eksplisit meminta untuk memetakan, mendokumentasikan, atau mempelajari basis kode yang sudah ada. Aktifkan untuk perintah seperti "petakan basis kode ini", "dokumentasikan…
official
acreadiness-assess
github
Run the AgentRC readiness assessment on the current repository and produce a static HTML dashboard at reports/index.html. Wraps `npx github:microsoft/agentrc…
official
acreadiness-generate-instructions
github
Menghasilkan file instruksi agen AI yang disesuaikan melalui perintah instruksi AgentRC. Menghasilkan .github/copilot-instructions.md (default, direkomendasikan untuk Copilot di VS…
official
acreadiness-policy
github
Bantu pengguna memilih, menulis, atau menerapkan kebijakan AgentRC. Kebijakan menyesuaikan penilaian kesiapan dengan menonaktifkan pemeriksaan yang tidak relevan, mengganti dampak/tingkat, mengatur…
official
add-educational-comments
github
Tambahkan komentar edukatif ke file kode untuk mengubahnya menjadi sumber belajar yang efektif. Menyesuaikan kedalaman penjelasan dan nada dengan tiga tingkat pengetahuan yang dapat dikonfigurasi: pemula, menengah, dan mahir. Secara otomatis meminta file jika tidak ada yang disediakan, dengan pencocokan daftar bernomor untuk pemilihan cepat. Memperluas file hingga 125% hanya menggunakan komentar edukatif (batas keras: 400 baris baru; 300 untuk file di atas 1.000 baris). Mempertahankan encoding file, gaya indentasi, kebenaran sintaks, dan...
official
adobe-illustrator-scripting
github
Menulis, men-debug, dan mengoptimalkan skrip otomatisasi Adobe Illustrator menggunakan ExtendScript (JavaScript/JSX). Gunakan saat membuat atau memodifikasi skrip yang memanipulasi…
official
agent-governance
github
Kebijakan deklaratif, klasifikasi intensi, dan jejak audit untuk mengontrol akses dan perilaku alat agen AI. Kebijakan tata kelola yang dapat dikomposisikan mendefinisikan alat yang diizinkan/diblokir, filter konten, batas kecepatan, dan persyaratan persetujuan — disimpan sebagai konfigurasi, bukan kode. Klasifikasi intensi semantik mendeteksi perintah berbahaya (eksfiltrasi data, eskalasi hak istimewa, injeksi perintah) sebelum eksekusi alat menggunakan sinyal berbasis pola. Dekorator tata kelola tingkat alat memberlakukan kebijakan pada fungsi...
official