opencode-copilot-delegate 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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +108 -0
- package/dist/discovery/agents.d.ts +10 -0
- package/dist/discovery/description.d.ts +2 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9917 -0
- package/dist/lib/ansi.d.ts +1 -0
- package/dist/lib/kill-tree.d.ts +1 -0
- package/dist/runtime/envelope.d.ts +58 -0
- package/dist/runtime/jsonl-parser.d.ts +24 -0
- package/dist/runtime/notify.d.ts +63 -0
- package/dist/runtime/subprocess.d.ts +23 -0
- package/dist/runtime/task-registry.d.ts +22 -0
- package/dist/tools/cancel.d.ts +9 -0
- package/dist/tools/delegate.d.ts +26 -0
- package/dist/tools/output.d.ts +13 -0
- package/package.json +65 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# opencode-copilot-delegate
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- bea3f57: Initial v0.1.0 bootstrap: package scaffold, TypeScript config, and `src/` module structure for the OpenCode Copilot delegate plugin.
|
|
8
|
+
- f85c8d8: Add LLM-driven integration tests covering the three plugin tools end-to-end. A real OpenCode session driven via `opencode run` and a paid LLM model invokes `copilot_delegate`, `copilot_output`, and `copilot_cancel` against real Copilot subprocesses, with assertions on the textual response. Three scenarios cover task-id format from `copilot_delegate`, the `unknown` status path through `copilot_output` for a nonexistent task id, and `copilot_cancel` against a running delegation.
|
|
9
|
+
|
|
10
|
+
Tests run against `opencode/minimax-m2.5` by default (override with `OPENCODE_TEST_MODEL`). The describe block is gated on either `GH_TOKEN` or `COPILOT_PAT` being set; when neither is present, the suite skips cleanly so `bun test` stays green on dev machines without a Copilot PAT. Per-test isolation uses `OPENCODE_CONFIG_DIR` pointed at an empty temp dir to skip the developer's globally-configured plugins, and `OPENCODE_CONFIG_CONTENT` to register the plugin's own `dist/index.js` as a `file://` plugin in each test session.
|
|
11
|
+
|
|
12
|
+
- 79d1f09: Add JSONL parser and envelope builder for Copilot CLI output processing
|
|
13
|
+
|
|
14
|
+
- `parseJsonlLine()` normalizes Copilot CLI JSONL events into typed `ParsedEvent` objects with defensive handling of malformed input
|
|
15
|
+
- `buildEnvelope()` folds parsed events into the structured `copilot_output` response shape with graceful degradation for missing fields
|
|
16
|
+
- Live JSONL fixtures captured from `copilot` CLI v1.0.34 for regression testing
|
|
17
|
+
|
|
18
|
+
- de20762: Document the upstream `ps`/prompt-visibility caveat, the absence of a subprocess lifetime cap, and the `0.x` versioning policy in the README. Correct the notification-injection description to match the implementation (`client.session.prompt` with `noReply`, not `promptAsync`).
|
|
19
|
+
- a23e15f: Add automated release pipeline. A new `Release` workflow runs after the `CI` workflow succeeds on `main`, opens a "Version Packages" pull request via `changesets/action` when changesets are pending, and publishes to npm via OIDC trusted publishing once that PR merges. Adds `@changesets/cli` as a development dependency and the `version-changesets` and `publish-changesets` scripts to drive the version-bump and publish steps.
|
|
20
|
+
- 6fd4c6d: Add subprocess wrapper, task registry, notification injection, and agent discovery
|
|
21
|
+
|
|
22
|
+
- Subprocess spawning with line-buffered JSONL parsing, auth token env precedence, and abort-based cancellation via fkill process group kills
|
|
23
|
+
- In-memory task registry with cleanup-all lifecycle
|
|
24
|
+
- Notification injection using noReply semantics with per-session in-flight counters
|
|
25
|
+
- Agent discovery scanning builtin, user, and repo directories with override semantics
|
|
26
|
+
- ANSI escape sequence stripping for clean error/message text
|
|
27
|
+
|
|
28
|
+
- fcc52ac: Wire copilot_delegate, copilot_output, and copilot_cancel tools into the plugin entrypoint with subprocess lifecycle management, notification injection, and structured error handling.
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 842fcd6: Add Renovate configuration and workflow for automated dependency updates.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Marcus R. Brown
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# opencode-copilot-delegate
|
|
2
|
+
|
|
3
|
+
An [OpenCode](https://opencode.ai) plugin that delegates tasks to [GitHub Copilot CLI](https://docs.github.com/en/copilot/how-tos/copilot-cli) as background subprocesses.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This plugin registers three tools in OpenCode:
|
|
8
|
+
|
|
9
|
+
- **`copilot_delegate`** — Spawn `copilot -p` as a background subprocess. Returns a `task_id` immediately so the parent agent never blocks.
|
|
10
|
+
- **`copilot_output`** — Retrieve the structured result envelope for a completed or running delegation.
|
|
11
|
+
- **`copilot_cancel`** — Cancel a running delegation with SIGTERM → SIGKILL escalation.
|
|
12
|
+
|
|
13
|
+
When the subprocess completes, a `<system-reminder>` notification is injected into the parent session via `client.session.prompt` with `noReply: false` for the first notification per session and `noReply: true` for subsequent ones, so the agent sees the result without an unbounded reply chain.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
// opencode.json
|
|
19
|
+
{
|
|
20
|
+
"plugin": ["opencode-copilot-delegate"]
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Requires the `copilot` CLI to be on `PATH`. Install via:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
# npm (recommended)
|
|
28
|
+
npm install -g @github/copilot
|
|
29
|
+
|
|
30
|
+
# Homebrew
|
|
31
|
+
brew install copilot-cli
|
|
32
|
+
|
|
33
|
+
# Install script (CI-friendly)
|
|
34
|
+
curl -fsSL https://gh.io/copilot-install | bash
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Authentication
|
|
38
|
+
|
|
39
|
+
The plugin passes through your existing Copilot CLI auth. Token precedence:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
COPILOT_GITHUB_TOKEN > GH_TOKEN > GITHUB_TOKEN > ~/.copilot/auth
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The plugin logs the resolved auth source (not the token value) at delegation start.
|
|
46
|
+
|
|
47
|
+
## Tools
|
|
48
|
+
|
|
49
|
+
### `copilot_delegate`
|
|
50
|
+
|
|
51
|
+
| Arg | Type | Description |
|
|
52
|
+
|-----|------|-------------|
|
|
53
|
+
| `prompt` | `string` | Required. The prompt to send to Copilot. |
|
|
54
|
+
| `agent` | `string?` | Optional. Copilot agent name (see tool description for available agents). |
|
|
55
|
+
| `model` | `string?` | Optional. Model override (e.g. `claude-haiku-4.5`). |
|
|
56
|
+
| `add_dir` | `string[]?` | Optional. Additional directories to allow Copilot to read. |
|
|
57
|
+
| `allow_tool` | `string[]?` | Optional. Tool patterns to allow. |
|
|
58
|
+
| `deny_tool` | `string[]?` | Optional. Tool patterns to deny. |
|
|
59
|
+
|
|
60
|
+
Returns `{ task_id: string }` — a `cpl_`-prefixed UUID.
|
|
61
|
+
|
|
62
|
+
### `copilot_output`
|
|
63
|
+
|
|
64
|
+
| Arg | Type | Description |
|
|
65
|
+
|-----|------|-------------|
|
|
66
|
+
| `task_id` | `string` | Required. Task ID from `copilot_delegate`. |
|
|
67
|
+
| `block` | `boolean?` | Optional. Wait for completion before returning. Default `false`. |
|
|
68
|
+
| `timeout_ms` | `number?` | Optional. Max wait ms when `block: true`. Default `30000`, max `120000`. |
|
|
69
|
+
|
|
70
|
+
Returns a structured envelope with `status`, `final_message`, `tokens`, `tool_calls_summary`, and more.
|
|
71
|
+
|
|
72
|
+
### `copilot_cancel`
|
|
73
|
+
|
|
74
|
+
| Arg | Type | Description |
|
|
75
|
+
|-----|------|-------------|
|
|
76
|
+
| `task_id` | `string` | Required. Task ID to cancel. |
|
|
77
|
+
|
|
78
|
+
Returns `{ cancelled: boolean; was_running: boolean }`.
|
|
79
|
+
|
|
80
|
+
## Scope Boundary
|
|
81
|
+
|
|
82
|
+
Task state is in-memory inside a single OpenCode process. Calling `copilot_output` from a different OpenCode process returns `{ status: 'unknown', error: 'task_id not found in this OpenCode process' }`. Cross-process sharing is deferred to a future version.
|
|
83
|
+
|
|
84
|
+
## Known Limitations (v0.1.x)
|
|
85
|
+
|
|
86
|
+
- **Orphaned subprocesses:** If OpenCode crashes mid-delegation, the `copilot` subprocess becomes orphaned. A PID-file reaper is planned for v1.x.
|
|
87
|
+
- **Prompt visibility in `ps`:** The `copilot` CLI accepts the prompt as a command-line argument, which means the full prompt text appears in `ps` output for any user on the host. This is an upstream Copilot CLI behavior. Avoid delegating prompts that contain secrets or PII; pass sensitive material via files, env vars, or `--secret-env-vars` instead.
|
|
88
|
+
- **No subprocess lifetime cap:** A hung `copilot` subprocess stays in the registry as `running` indefinitely. Cancel manually via `copilot_cancel`. A configurable timeout is planned for v1.x.
|
|
89
|
+
|
|
90
|
+
## Versioning
|
|
91
|
+
|
|
92
|
+
Releases under `0.x` are unstable and may include breaking changes between minor versions. Pin to an exact version in production:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"opencode-copilot-delegate": "0.1.0"
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
`1.0.0` will be cut once the public surface stabilizes.
|
|
101
|
+
|
|
102
|
+
## Privacy
|
|
103
|
+
|
|
104
|
+
This plugin collects **zero telemetry**. It does not phone home, track usage, or log to remote services. All logging goes through `client.app.log(...)`, which OpenCode handles locally per its own settings. The resolved auth token value is never logged — only the auth source name.
|
|
105
|
+
|
|
106
|
+
## License
|
|
107
|
+
|
|
108
|
+
MIT © [Marcus R. Brown](https://mrbro.dev)
|
package/dist/index.d.ts
ADDED