@agentplugins/adapter-copilot 0.1.0
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/README.md +46 -0
- package/dist/index.d.mts +238 -0
- package/dist/index.d.ts +238 -0
- package/dist/index.js +618 -0
- package/dist/index.mjs +593 -0
- package/package.json +52 -0
package/README.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @agentplugins/adapter-copilot
|
|
2
|
+
|
|
3
|
+
> AgentPlugins platform adapter for [GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/plugins-finding-installing).
|
|
4
|
+
|
|
5
|
+
Compiles a universal `PluginManifest` into the Copilot CLI plugin layout: `plugin.json` manifest, `hooks.json` hook wiring, and MCP server configuration. Inline handlers are wrapped as command scripts that the host invokes.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @agentplugins/adapter-copilot
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Typically installed transitively via [`@agentplugins/cli`](https://www.npmjs.com/package/@agentplugins/cli).
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { createCopilotAdapter } from '@agentplugins/adapter-copilot';
|
|
19
|
+
|
|
20
|
+
const adapter = createCopilotAdapter();
|
|
21
|
+
const output = await adapter.compile(manifest);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or via the CLI:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx agentplugins build --target copilot
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Output shape
|
|
31
|
+
|
|
32
|
+
A successful build writes to `dist/copilot/`:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
dist/copilot/
|
|
36
|
+
├── plugin.json
|
|
37
|
+
├── hooks/
|
|
38
|
+
│ └── hooks.json
|
|
39
|
+
└── .mcp.json
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Install with: `copilot plugin install ./dist/copilot`
|
|
43
|
+
|
|
44
|
+
## License
|
|
45
|
+
|
|
46
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { PlatformAdapter, TargetPlatform, UniversalHookName, HandlerType, PluginManifest, ValidationIssue, AdapterOutput } from '@agentplugins/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @agentplugins/adapter-copilot
|
|
5
|
+
*
|
|
6
|
+
* GitHub Copilot CLI platform adapter for the AgentPlugins plugin system.
|
|
7
|
+
*
|
|
8
|
+
* This adapter compiles AgentPlugins {@link PluginManifest} objects into the
|
|
9
|
+
* multi-file layout expected by the Copilot CLI runtime:
|
|
10
|
+
*
|
|
11
|
+
* - plugin.json – top-level manifest (strict validation, metadata)
|
|
12
|
+
* - hooks.json – hook bindings with optional matcher filters
|
|
13
|
+
* - skills/<name>/SKILL.md – declarative skill documentation
|
|
14
|
+
* - .mcp.json – MCP server configuration (when applicable)
|
|
15
|
+
*
|
|
16
|
+
* ## Supported hooks (11 / 20 universal hooks)
|
|
17
|
+
* Copilot supports 13 binding points; we map 11 distinct universal hooks to
|
|
18
|
+
* them. The remaining 9 universal hooks are explicitly unsupported.
|
|
19
|
+
*
|
|
20
|
+
* | Universal hook | Copilot event | Notes |
|
|
21
|
+
* |-----------------------|-----------------------|-------|
|
|
22
|
+
* | sessionStart | sessionStart | |
|
|
23
|
+
* | sessionEnd | sessionEnd | |
|
|
24
|
+
* | userPromptSubmit | userPromptSubmitted | |
|
|
25
|
+
* | preToolUse | preToolUse | FAIL-CLOSED: errors/timeouts deny the tool call |
|
|
26
|
+
* | postToolUse | postToolUse | |
|
|
27
|
+
* | postToolUseFailure | postToolUseFailure | |
|
|
28
|
+
* | permissionRequest | permissionRequest | |
|
|
29
|
+
* | subagentStart | subagentStart | |
|
|
30
|
+
* | subagentStop | agentStop | Copilot has no "subagentStop" — agentStop is the closest semantic match |
|
|
31
|
+
* | preCompact | preCompact | |
|
|
32
|
+
* | notification | notification | Fire-and-forget |
|
|
33
|
+
*
|
|
34
|
+
* ## Supported handlers
|
|
35
|
+
* | Handler type | Details |
|
|
36
|
+
* |--------------|---------|
|
|
37
|
+
* | command | bash or powershell scripts executed in a subshell |
|
|
38
|
+
* | http | POST requests sent to a configured endpoint |
|
|
39
|
+
* | prompt | Inline prompt template; **only allowed for sessionStart** |
|
|
40
|
+
*
|
|
41
|
+
* ## Runtime constraints
|
|
42
|
+
* - **preToolUse fail-closed**: any error or timeout during a `preToolUse`
|
|
43
|
+
* hook causes the tool invocation to be denied. This is a security feature.
|
|
44
|
+
* - **30 s hook timeout**: hooks that do not respond within 30 s are treated
|
|
45
|
+
* as failed (for preToolUse this means the tool call is rejected).
|
|
46
|
+
* - **10 KB additionalContext cap**: the combined size of all
|
|
47
|
+
* `additionalContext` objects passed to a hook must not exceed 10 KB.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/** Shape of a single hook entry in Copilot's `hooks.json`. */
|
|
51
|
+
interface CopilotHookEntry {
|
|
52
|
+
/** Copilot event name (e.g. "preToolUse"). */
|
|
53
|
+
event: string;
|
|
54
|
+
/** Path to the handler script/binary or HTTP URL. */
|
|
55
|
+
handler: string;
|
|
56
|
+
/** Handler type discriminator. */
|
|
57
|
+
type: "command" | "http" | "prompt";
|
|
58
|
+
/** Optional matcher filter (e.g. toolName for preToolUse). */
|
|
59
|
+
matcher?: {
|
|
60
|
+
/** Field to match on (e.g. "toolName"). */
|
|
61
|
+
field: string;
|
|
62
|
+
/** Regex or literal value to match (e.g. "Bash" or "Edit|Write"). */
|
|
63
|
+
value: string;
|
|
64
|
+
};
|
|
65
|
+
/** Whether Copilot should wait for a response (default true except notification). */
|
|
66
|
+
awaitResponse?: boolean;
|
|
67
|
+
/** Timeout in seconds (default 30, max 30). */
|
|
68
|
+
timeout?: number;
|
|
69
|
+
/** Whether an error denies the operation (true for preToolUse). */
|
|
70
|
+
failClosed?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** Shape of the top-level `plugin.json` manifest. */
|
|
73
|
+
interface CopilotPluginManifest {
|
|
74
|
+
/** Schema version. */
|
|
75
|
+
schemaVersion: string;
|
|
76
|
+
/** Plugin identifier. */
|
|
77
|
+
id: string;
|
|
78
|
+
/** Human-readable name. */
|
|
79
|
+
name: string;
|
|
80
|
+
/** Plugin description. */
|
|
81
|
+
description?: string;
|
|
82
|
+
/** Semantic version. */
|
|
83
|
+
version: string;
|
|
84
|
+
/** Whether strict validation is enabled (default true). */
|
|
85
|
+
strict?: boolean;
|
|
86
|
+
/** Maximum additionalContext size in bytes. */
|
|
87
|
+
maxAdditionalContextBytes?: number;
|
|
88
|
+
/** Default hook timeout in seconds. */
|
|
89
|
+
hookTimeoutSeconds?: number;
|
|
90
|
+
/** Author / publisher information. */
|
|
91
|
+
author?: string;
|
|
92
|
+
/** Homepage URL. */
|
|
93
|
+
homepage?: string;
|
|
94
|
+
/** License identifier. */
|
|
95
|
+
license?: string;
|
|
96
|
+
/** Tags for discovery. */
|
|
97
|
+
tags?: string[];
|
|
98
|
+
/** Paths to hook definitions (relative to plugin.json). */
|
|
99
|
+
hooks?: string;
|
|
100
|
+
/** Paths to skill directories (relative to plugin.json). */
|
|
101
|
+
skills?: string[];
|
|
102
|
+
/** MCP server configuration file path. */
|
|
103
|
+
mcp?: string;
|
|
104
|
+
}
|
|
105
|
+
/** Shape of `.mcp.json` when the plugin exposes MCP servers. */
|
|
106
|
+
interface CopilotMcpConfig {
|
|
107
|
+
/** Schema version for MCP config. */
|
|
108
|
+
schemaVersion: string;
|
|
109
|
+
/** List of MCP server connections. */
|
|
110
|
+
servers: CopilotMcpServer[];
|
|
111
|
+
}
|
|
112
|
+
/** A single MCP server entry. */
|
|
113
|
+
interface CopilotMcpServer {
|
|
114
|
+
/** Server identifier. */
|
|
115
|
+
id: string;
|
|
116
|
+
/** Display name. */
|
|
117
|
+
name: string;
|
|
118
|
+
/** Transport type. */
|
|
119
|
+
transport: "stdio" | "sse" | "http";
|
|
120
|
+
/** Command to launch (for stdio). */
|
|
121
|
+
command?: string;
|
|
122
|
+
/** Arguments for the command (for stdio). */
|
|
123
|
+
args?: string[];
|
|
124
|
+
/** URL endpoint (for sse / http). */
|
|
125
|
+
url?: string;
|
|
126
|
+
/** Environment variables to set. */
|
|
127
|
+
env?: Record<string, string>;
|
|
128
|
+
}
|
|
129
|
+
/** A compiled skill descriptor in `skills/<name>/SKILL.md` format. */
|
|
130
|
+
interface CopilotSkillDescriptor {
|
|
131
|
+
/** Skill name. */
|
|
132
|
+
name: string;
|
|
133
|
+
/** Skill description. */
|
|
134
|
+
description: string;
|
|
135
|
+
/** Input parameters the skill accepts. */
|
|
136
|
+
parameters?: Array<{
|
|
137
|
+
name: string;
|
|
138
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
139
|
+
description?: string;
|
|
140
|
+
required?: boolean;
|
|
141
|
+
}>;
|
|
142
|
+
/** Example usage prompts. */
|
|
143
|
+
examples?: string[];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* GitHub Copilot CLI platform adapter.
|
|
147
|
+
*
|
|
148
|
+
* Converts AgentPlugins {@link PluginManifest} objects into the file layout
|
|
149
|
+
* expected by the Copilot CLI runtime:
|
|
150
|
+
*
|
|
151
|
+
* ```
|
|
152
|
+
* .plugin/
|
|
153
|
+
* plugin.json – manifest
|
|
154
|
+
* hooks.json – hook bindings
|
|
155
|
+
* skills/
|
|
156
|
+
* <skill>/
|
|
157
|
+
* SKILL.md – declarative skill docs
|
|
158
|
+
* .mcp.json – MCP configuration (optional)
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @implements {PlatformAdapter}
|
|
162
|
+
*/
|
|
163
|
+
declare class CopilotAdapter implements PlatformAdapter {
|
|
164
|
+
/** Platform identifier. */
|
|
165
|
+
readonly name: TargetPlatform;
|
|
166
|
+
/** Human-readable display name. */
|
|
167
|
+
readonly displayName: string;
|
|
168
|
+
/** Universal hooks supported by this adapter. */
|
|
169
|
+
readonly supportedHooks: readonly UniversalHookName[];
|
|
170
|
+
/** Handler types understood by Copilot CLI. */
|
|
171
|
+
readonly supportedHandlers: readonly HandlerType[];
|
|
172
|
+
/** Path to the generated manifest file. */
|
|
173
|
+
readonly manifestPath: string;
|
|
174
|
+
/** Manifest format (JSON). */
|
|
175
|
+
readonly manifestFormat: "json" | "toml";
|
|
176
|
+
/**
|
|
177
|
+
* Validate a {@link PluginManifest} for Copilot CLI compatibility.
|
|
178
|
+
*
|
|
179
|
+
* Checks performed:
|
|
180
|
+
* 1. Only supported hooks are referenced.
|
|
181
|
+
* 2. Handler types are within the supported set.
|
|
182
|
+
* 3. Command handlers specify shell (bash/powershell) and script/command.
|
|
183
|
+
* 4. HTTP handlers use POST (the only method Copilot sends).
|
|
184
|
+
* 5. Prompt handlers are only used on `sessionStart`.
|
|
185
|
+
* 6. additionalContext does not exceed 10 KB.
|
|
186
|
+
* 7. Hook timeouts do not exceed 30 seconds.
|
|
187
|
+
* 8. preToolUse hooks are encouraged to specify a matcher.
|
|
188
|
+
* 9. All referenced skills have required fields (name, description).
|
|
189
|
+
*
|
|
190
|
+
* @param plugin – the plugin manifest to validate
|
|
191
|
+
* @returns array of validation issues (empty if fully valid)
|
|
192
|
+
*/
|
|
193
|
+
validate(plugin: PluginManifest): ValidationIssue[];
|
|
194
|
+
/**
|
|
195
|
+
* Compile a {@link PluginManifest} into the Copilot CLI file layout.
|
|
196
|
+
*
|
|
197
|
+
* Produces:
|
|
198
|
+
* - `plugin.json` – top-level manifest with metadata and file references
|
|
199
|
+
* - `hooks.json` – hook bindings mapped to Copilot event names
|
|
200
|
+
* - `skills/<name>/SKILL.md` – one file per skill
|
|
201
|
+
* - `.mcp.json` – MCP server configuration (if MCP servers are defined)
|
|
202
|
+
*
|
|
203
|
+
* @param plugin – the validated plugin manifest
|
|
204
|
+
* @returns {@link AdapterOutput} containing all generated files
|
|
205
|
+
*/
|
|
206
|
+
compile(plugin: PluginManifest): AdapterOutput;
|
|
207
|
+
/**
|
|
208
|
+
* Build an MCP server configuration object from the plugin manifest.
|
|
209
|
+
*
|
|
210
|
+
* If the plugin defines MCP servers (in `plugin.mcpServers`), they are
|
|
211
|
+
* converted into Copilot's `.mcp.json` format.
|
|
212
|
+
*
|
|
213
|
+
* @param plugin – the plugin manifest
|
|
214
|
+
* @returns MCP config object, or `null` if no MCP servers are defined
|
|
215
|
+
*/
|
|
216
|
+
private buildMcpConfig;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Singleton instance of the Copilot CLI adapter.
|
|
220
|
+
*
|
|
221
|
+
* Import this directly to validate and compile plugins for the
|
|
222
|
+
* GitHub Copilot CLI platform:
|
|
223
|
+
*
|
|
224
|
+
* ```ts
|
|
225
|
+
* import { copilotAdapter } from "@agentplugins/adapter-copilot";
|
|
226
|
+
*
|
|
227
|
+
* const issues = copilotAdapter.validate(myPlugin);
|
|
228
|
+
* if (issues.length === 0) {
|
|
229
|
+
* const output = copilotAdapter.compile(myPlugin);
|
|
230
|
+
* // output.files contains plugin.json, hooks.json, skills, etc.
|
|
231
|
+
* }
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
declare const copilotAdapter: CopilotAdapter;
|
|
235
|
+
/** Factory function for creating a new Copilot adapter instance. */
|
|
236
|
+
declare function createCopilotAdapter(): PlatformAdapter;
|
|
237
|
+
|
|
238
|
+
export { CopilotAdapter, type CopilotHookEntry, type CopilotMcpConfig, type CopilotMcpServer, type CopilotPluginManifest, type CopilotSkillDescriptor, copilotAdapter, createCopilotAdapter };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { PlatformAdapter, TargetPlatform, UniversalHookName, HandlerType, PluginManifest, ValidationIssue, AdapterOutput } from '@agentplugins/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @agentplugins/adapter-copilot
|
|
5
|
+
*
|
|
6
|
+
* GitHub Copilot CLI platform adapter for the AgentPlugins plugin system.
|
|
7
|
+
*
|
|
8
|
+
* This adapter compiles AgentPlugins {@link PluginManifest} objects into the
|
|
9
|
+
* multi-file layout expected by the Copilot CLI runtime:
|
|
10
|
+
*
|
|
11
|
+
* - plugin.json – top-level manifest (strict validation, metadata)
|
|
12
|
+
* - hooks.json – hook bindings with optional matcher filters
|
|
13
|
+
* - skills/<name>/SKILL.md – declarative skill documentation
|
|
14
|
+
* - .mcp.json – MCP server configuration (when applicable)
|
|
15
|
+
*
|
|
16
|
+
* ## Supported hooks (11 / 20 universal hooks)
|
|
17
|
+
* Copilot supports 13 binding points; we map 11 distinct universal hooks to
|
|
18
|
+
* them. The remaining 9 universal hooks are explicitly unsupported.
|
|
19
|
+
*
|
|
20
|
+
* | Universal hook | Copilot event | Notes |
|
|
21
|
+
* |-----------------------|-----------------------|-------|
|
|
22
|
+
* | sessionStart | sessionStart | |
|
|
23
|
+
* | sessionEnd | sessionEnd | |
|
|
24
|
+
* | userPromptSubmit | userPromptSubmitted | |
|
|
25
|
+
* | preToolUse | preToolUse | FAIL-CLOSED: errors/timeouts deny the tool call |
|
|
26
|
+
* | postToolUse | postToolUse | |
|
|
27
|
+
* | postToolUseFailure | postToolUseFailure | |
|
|
28
|
+
* | permissionRequest | permissionRequest | |
|
|
29
|
+
* | subagentStart | subagentStart | |
|
|
30
|
+
* | subagentStop | agentStop | Copilot has no "subagentStop" — agentStop is the closest semantic match |
|
|
31
|
+
* | preCompact | preCompact | |
|
|
32
|
+
* | notification | notification | Fire-and-forget |
|
|
33
|
+
*
|
|
34
|
+
* ## Supported handlers
|
|
35
|
+
* | Handler type | Details |
|
|
36
|
+
* |--------------|---------|
|
|
37
|
+
* | command | bash or powershell scripts executed in a subshell |
|
|
38
|
+
* | http | POST requests sent to a configured endpoint |
|
|
39
|
+
* | prompt | Inline prompt template; **only allowed for sessionStart** |
|
|
40
|
+
*
|
|
41
|
+
* ## Runtime constraints
|
|
42
|
+
* - **preToolUse fail-closed**: any error or timeout during a `preToolUse`
|
|
43
|
+
* hook causes the tool invocation to be denied. This is a security feature.
|
|
44
|
+
* - **30 s hook timeout**: hooks that do not respond within 30 s are treated
|
|
45
|
+
* as failed (for preToolUse this means the tool call is rejected).
|
|
46
|
+
* - **10 KB additionalContext cap**: the combined size of all
|
|
47
|
+
* `additionalContext` objects passed to a hook must not exceed 10 KB.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/** Shape of a single hook entry in Copilot's `hooks.json`. */
|
|
51
|
+
interface CopilotHookEntry {
|
|
52
|
+
/** Copilot event name (e.g. "preToolUse"). */
|
|
53
|
+
event: string;
|
|
54
|
+
/** Path to the handler script/binary or HTTP URL. */
|
|
55
|
+
handler: string;
|
|
56
|
+
/** Handler type discriminator. */
|
|
57
|
+
type: "command" | "http" | "prompt";
|
|
58
|
+
/** Optional matcher filter (e.g. toolName for preToolUse). */
|
|
59
|
+
matcher?: {
|
|
60
|
+
/** Field to match on (e.g. "toolName"). */
|
|
61
|
+
field: string;
|
|
62
|
+
/** Regex or literal value to match (e.g. "Bash" or "Edit|Write"). */
|
|
63
|
+
value: string;
|
|
64
|
+
};
|
|
65
|
+
/** Whether Copilot should wait for a response (default true except notification). */
|
|
66
|
+
awaitResponse?: boolean;
|
|
67
|
+
/** Timeout in seconds (default 30, max 30). */
|
|
68
|
+
timeout?: number;
|
|
69
|
+
/** Whether an error denies the operation (true for preToolUse). */
|
|
70
|
+
failClosed?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/** Shape of the top-level `plugin.json` manifest. */
|
|
73
|
+
interface CopilotPluginManifest {
|
|
74
|
+
/** Schema version. */
|
|
75
|
+
schemaVersion: string;
|
|
76
|
+
/** Plugin identifier. */
|
|
77
|
+
id: string;
|
|
78
|
+
/** Human-readable name. */
|
|
79
|
+
name: string;
|
|
80
|
+
/** Plugin description. */
|
|
81
|
+
description?: string;
|
|
82
|
+
/** Semantic version. */
|
|
83
|
+
version: string;
|
|
84
|
+
/** Whether strict validation is enabled (default true). */
|
|
85
|
+
strict?: boolean;
|
|
86
|
+
/** Maximum additionalContext size in bytes. */
|
|
87
|
+
maxAdditionalContextBytes?: number;
|
|
88
|
+
/** Default hook timeout in seconds. */
|
|
89
|
+
hookTimeoutSeconds?: number;
|
|
90
|
+
/** Author / publisher information. */
|
|
91
|
+
author?: string;
|
|
92
|
+
/** Homepage URL. */
|
|
93
|
+
homepage?: string;
|
|
94
|
+
/** License identifier. */
|
|
95
|
+
license?: string;
|
|
96
|
+
/** Tags for discovery. */
|
|
97
|
+
tags?: string[];
|
|
98
|
+
/** Paths to hook definitions (relative to plugin.json). */
|
|
99
|
+
hooks?: string;
|
|
100
|
+
/** Paths to skill directories (relative to plugin.json). */
|
|
101
|
+
skills?: string[];
|
|
102
|
+
/** MCP server configuration file path. */
|
|
103
|
+
mcp?: string;
|
|
104
|
+
}
|
|
105
|
+
/** Shape of `.mcp.json` when the plugin exposes MCP servers. */
|
|
106
|
+
interface CopilotMcpConfig {
|
|
107
|
+
/** Schema version for MCP config. */
|
|
108
|
+
schemaVersion: string;
|
|
109
|
+
/** List of MCP server connections. */
|
|
110
|
+
servers: CopilotMcpServer[];
|
|
111
|
+
}
|
|
112
|
+
/** A single MCP server entry. */
|
|
113
|
+
interface CopilotMcpServer {
|
|
114
|
+
/** Server identifier. */
|
|
115
|
+
id: string;
|
|
116
|
+
/** Display name. */
|
|
117
|
+
name: string;
|
|
118
|
+
/** Transport type. */
|
|
119
|
+
transport: "stdio" | "sse" | "http";
|
|
120
|
+
/** Command to launch (for stdio). */
|
|
121
|
+
command?: string;
|
|
122
|
+
/** Arguments for the command (for stdio). */
|
|
123
|
+
args?: string[];
|
|
124
|
+
/** URL endpoint (for sse / http). */
|
|
125
|
+
url?: string;
|
|
126
|
+
/** Environment variables to set. */
|
|
127
|
+
env?: Record<string, string>;
|
|
128
|
+
}
|
|
129
|
+
/** A compiled skill descriptor in `skills/<name>/SKILL.md` format. */
|
|
130
|
+
interface CopilotSkillDescriptor {
|
|
131
|
+
/** Skill name. */
|
|
132
|
+
name: string;
|
|
133
|
+
/** Skill description. */
|
|
134
|
+
description: string;
|
|
135
|
+
/** Input parameters the skill accepts. */
|
|
136
|
+
parameters?: Array<{
|
|
137
|
+
name: string;
|
|
138
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
139
|
+
description?: string;
|
|
140
|
+
required?: boolean;
|
|
141
|
+
}>;
|
|
142
|
+
/** Example usage prompts. */
|
|
143
|
+
examples?: string[];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* GitHub Copilot CLI platform adapter.
|
|
147
|
+
*
|
|
148
|
+
* Converts AgentPlugins {@link PluginManifest} objects into the file layout
|
|
149
|
+
* expected by the Copilot CLI runtime:
|
|
150
|
+
*
|
|
151
|
+
* ```
|
|
152
|
+
* .plugin/
|
|
153
|
+
* plugin.json – manifest
|
|
154
|
+
* hooks.json – hook bindings
|
|
155
|
+
* skills/
|
|
156
|
+
* <skill>/
|
|
157
|
+
* SKILL.md – declarative skill docs
|
|
158
|
+
* .mcp.json – MCP configuration (optional)
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @implements {PlatformAdapter}
|
|
162
|
+
*/
|
|
163
|
+
declare class CopilotAdapter implements PlatformAdapter {
|
|
164
|
+
/** Platform identifier. */
|
|
165
|
+
readonly name: TargetPlatform;
|
|
166
|
+
/** Human-readable display name. */
|
|
167
|
+
readonly displayName: string;
|
|
168
|
+
/** Universal hooks supported by this adapter. */
|
|
169
|
+
readonly supportedHooks: readonly UniversalHookName[];
|
|
170
|
+
/** Handler types understood by Copilot CLI. */
|
|
171
|
+
readonly supportedHandlers: readonly HandlerType[];
|
|
172
|
+
/** Path to the generated manifest file. */
|
|
173
|
+
readonly manifestPath: string;
|
|
174
|
+
/** Manifest format (JSON). */
|
|
175
|
+
readonly manifestFormat: "json" | "toml";
|
|
176
|
+
/**
|
|
177
|
+
* Validate a {@link PluginManifest} for Copilot CLI compatibility.
|
|
178
|
+
*
|
|
179
|
+
* Checks performed:
|
|
180
|
+
* 1. Only supported hooks are referenced.
|
|
181
|
+
* 2. Handler types are within the supported set.
|
|
182
|
+
* 3. Command handlers specify shell (bash/powershell) and script/command.
|
|
183
|
+
* 4. HTTP handlers use POST (the only method Copilot sends).
|
|
184
|
+
* 5. Prompt handlers are only used on `sessionStart`.
|
|
185
|
+
* 6. additionalContext does not exceed 10 KB.
|
|
186
|
+
* 7. Hook timeouts do not exceed 30 seconds.
|
|
187
|
+
* 8. preToolUse hooks are encouraged to specify a matcher.
|
|
188
|
+
* 9. All referenced skills have required fields (name, description).
|
|
189
|
+
*
|
|
190
|
+
* @param plugin – the plugin manifest to validate
|
|
191
|
+
* @returns array of validation issues (empty if fully valid)
|
|
192
|
+
*/
|
|
193
|
+
validate(plugin: PluginManifest): ValidationIssue[];
|
|
194
|
+
/**
|
|
195
|
+
* Compile a {@link PluginManifest} into the Copilot CLI file layout.
|
|
196
|
+
*
|
|
197
|
+
* Produces:
|
|
198
|
+
* - `plugin.json` – top-level manifest with metadata and file references
|
|
199
|
+
* - `hooks.json` – hook bindings mapped to Copilot event names
|
|
200
|
+
* - `skills/<name>/SKILL.md` – one file per skill
|
|
201
|
+
* - `.mcp.json` – MCP server configuration (if MCP servers are defined)
|
|
202
|
+
*
|
|
203
|
+
* @param plugin – the validated plugin manifest
|
|
204
|
+
* @returns {@link AdapterOutput} containing all generated files
|
|
205
|
+
*/
|
|
206
|
+
compile(plugin: PluginManifest): AdapterOutput;
|
|
207
|
+
/**
|
|
208
|
+
* Build an MCP server configuration object from the plugin manifest.
|
|
209
|
+
*
|
|
210
|
+
* If the plugin defines MCP servers (in `plugin.mcpServers`), they are
|
|
211
|
+
* converted into Copilot's `.mcp.json` format.
|
|
212
|
+
*
|
|
213
|
+
* @param plugin – the plugin manifest
|
|
214
|
+
* @returns MCP config object, or `null` if no MCP servers are defined
|
|
215
|
+
*/
|
|
216
|
+
private buildMcpConfig;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Singleton instance of the Copilot CLI adapter.
|
|
220
|
+
*
|
|
221
|
+
* Import this directly to validate and compile plugins for the
|
|
222
|
+
* GitHub Copilot CLI platform:
|
|
223
|
+
*
|
|
224
|
+
* ```ts
|
|
225
|
+
* import { copilotAdapter } from "@agentplugins/adapter-copilot";
|
|
226
|
+
*
|
|
227
|
+
* const issues = copilotAdapter.validate(myPlugin);
|
|
228
|
+
* if (issues.length === 0) {
|
|
229
|
+
* const output = copilotAdapter.compile(myPlugin);
|
|
230
|
+
* // output.files contains plugin.json, hooks.json, skills, etc.
|
|
231
|
+
* }
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
declare const copilotAdapter: CopilotAdapter;
|
|
235
|
+
/** Factory function for creating a new Copilot adapter instance. */
|
|
236
|
+
declare function createCopilotAdapter(): PlatformAdapter;
|
|
237
|
+
|
|
238
|
+
export { CopilotAdapter, type CopilotHookEntry, type CopilotMcpConfig, type CopilotMcpServer, type CopilotPluginManifest, type CopilotSkillDescriptor, copilotAdapter, createCopilotAdapter };
|