@github/copilot-sdk 0.1.31 → 0.1.33-unstable.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.
@@ -0,0 +1,61 @@
1
+ # Copilot CLI Extensions
2
+
3
+ Extensions add custom tools, hooks, and behaviors to the Copilot CLI. They run as separate Node.js processes that communicate with the CLI over JSON-RPC via stdio.
4
+
5
+ ## How Extensions Work
6
+
7
+ ```
8
+ ┌─────────────────────┐ JSON-RPC / stdio ┌──────────────────────┐
9
+ │ Copilot CLI │ ◄──────────────────────────────────► │ Extension Process │
10
+ │ (parent process) │ tool calls, events, hooks │ (forked child) │
11
+ │ │ │ │
12
+ │ • Discovers exts │ │ • Registers tools │
13
+ │ • Forks processes │ │ • Registers hooks │
14
+ │ • Routes tool calls │ │ • Listens to events │
15
+ │ • Manages lifecycle │ │ • Uses SDK APIs │
16
+ └─────────────────────┘ └──────────────────────┘
17
+ ```
18
+
19
+ 1. **Discovery**: The CLI scans `.github/extensions/` (project) and the user's copilot config extensions directory for subdirectories containing `extension.mjs`.
20
+ 2. **Launch**: Each extension is forked as a child process with `@github/copilot-sdk` available via an automatic module resolver.
21
+ 3. **Connection**: The extension calls `joinSession()` which establishes a JSON-RPC connection over stdio to the CLI and attaches to the user's current foreground session.
22
+ 4. **Registration**: Tools and hooks declared in the session options are registered with the CLI and become available to the agent.
23
+ 5. **Lifecycle**: Extensions are reloaded on `/clear` (or if the foreground session is replaced) and stopped on CLI exit (SIGTERM, then SIGKILL after 5s).
24
+
25
+ ## File Structure
26
+
27
+ ```
28
+ .github/extensions/
29
+ my-extension/
30
+ extension.mjs ← Entry point (required, must be .mjs)
31
+ ```
32
+
33
+ - Only `.mjs` files are supported (ES modules). The file must be named `extension.mjs`.
34
+ - Each extension lives in its own subdirectory.
35
+ - The `@github/copilot-sdk` import is resolved automatically — you don't install it.
36
+
37
+ ## The SDK
38
+
39
+ Extensions use `@github/copilot-sdk` for all interactions with the CLI:
40
+
41
+ ```js
42
+ import { approveAll } from "@github/copilot-sdk";
43
+ import { joinSession } from "@github/copilot-sdk/extension";
44
+
45
+ const session = await joinSession({
46
+ onPermissionRequest: approveAll,
47
+ tools: [
48
+ /* ... */
49
+ ],
50
+ hooks: {
51
+ /* ... */
52
+ },
53
+ });
54
+ ```
55
+
56
+ The `session` object provides methods for sending messages, logging to the timeline, listening to events, and accessing the RPC API. See the `.d.ts` files in the SDK package for full type information.
57
+
58
+ ## Further Reading
59
+
60
+ - `examples.md` — Practical code examples for tools, hooks, events, and complete extensions
61
+ - `agent-author.md` — Step-by-step workflow for agents authoring extensions programmatically
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "https://github.com/github/copilot-sdk.git"
6
6
  },
7
- "version": "0.1.31",
7
+ "version": "0.1.33-unstable.0",
8
8
  "description": "TypeScript SDK for programmatic control of GitHub Copilot CLI via JSON-RPC",
9
9
  "main": "./dist/index.js",
10
10
  "types": "./dist/index.d.ts",
@@ -70,6 +70,7 @@
70
70
  },
71
71
  "files": [
72
72
  "dist/**/*",
73
+ "docs/**/*",
73
74
  "README.md"
74
75
  ]
75
76
  }