opencode-copilot-delegate 0.6.0 → 0.7.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 +10 -0
- package/dist/index.js +47 -20
- package/dist/lib/normalize-tool-arg-schemas.d.ts +11 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# opencode-copilot-delegate
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3f8b78e: Surface per-parameter `.describe()` text to the host runtime by patching each tool arg schema with a `_zod.toJSONSchema` override.
|
|
8
|
+
|
|
9
|
+
OpenCode's tool catalog renders plugin schemas via the host's bundled zod, which lives in a different module instance from the plugin's zod and cannot see the plugin-side `.describe()` metadata registry. The override delegates serialization back to the plugin-local zod so descriptions survive intact, mirroring the pattern shipped by `@cortexkit/opencode-magic-context` and `@cortexkit/aft-opencode`.
|
|
10
|
+
|
|
11
|
+
Also pins `zod` as a direct dependency (`^4.3.0`) with a matching `overrides` entry to keep this repo's dependency tree on a single zod version, resolving a TS2883 unportable-inferred-type error from two zod trees coexisting at build time. The `overrides` field is local to this repo's installs only; npm ignores it for downstream consumers, so external plugin authors importing this package may still see a different transitive zod from their OpenCode host. Also reverts the prior schema-chain reorder since the override makes ordering irrelevant.
|
|
12
|
+
|
|
3
13
|
## 0.6.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -9356,6 +9356,33 @@ async function killProcessTree(pid) {
|
|
|
9356
9356
|
await fkill(-pid, options);
|
|
9357
9357
|
}
|
|
9358
9358
|
|
|
9359
|
+
// src/lib/normalize-tool-arg-schemas.ts
|
|
9360
|
+
import { tool } from "@opencode-ai/plugin/tool";
|
|
9361
|
+
function stripRootJsonSchemaFields(jsonSchema) {
|
|
9362
|
+
const { $schema: _schema, ...rest } = jsonSchema;
|
|
9363
|
+
return rest;
|
|
9364
|
+
}
|
|
9365
|
+
function attachJsonSchemaOverride(schema) {
|
|
9366
|
+
const internals = schema._zod;
|
|
9367
|
+
if (!internals || typeof internals.toJSONSchema === "function")
|
|
9368
|
+
return;
|
|
9369
|
+
internals.toJSONSchema = () => {
|
|
9370
|
+
const original = internals.toJSONSchema;
|
|
9371
|
+
delete internals.toJSONSchema;
|
|
9372
|
+
try {
|
|
9373
|
+
return stripRootJsonSchemaFields(tool.schema.toJSONSchema(schema));
|
|
9374
|
+
} finally {
|
|
9375
|
+
internals.toJSONSchema = original;
|
|
9376
|
+
}
|
|
9377
|
+
};
|
|
9378
|
+
}
|
|
9379
|
+
function normalizeToolArgSchemas(toolDefinition) {
|
|
9380
|
+
for (const schema of Object.values(toolDefinition.args)) {
|
|
9381
|
+
attachJsonSchemaOverride(schema);
|
|
9382
|
+
}
|
|
9383
|
+
return toolDefinition;
|
|
9384
|
+
}
|
|
9385
|
+
|
|
9359
9386
|
// src/runtime/orphan-reaper.ts
|
|
9360
9387
|
import { spawn as spawn2 } from "child_process";
|
|
9361
9388
|
import { readdir, readFile, unlink, writeFile } from "fs/promises";
|
|
@@ -9687,7 +9714,7 @@ async function removePidEntry(filePath, pid) {
|
|
|
9687
9714
|
}
|
|
9688
9715
|
|
|
9689
9716
|
// src/tools/cancel.ts
|
|
9690
|
-
import { tool } from "@opencode-ai/plugin/tool";
|
|
9717
|
+
import { tool as tool2 } from "@opencode-ai/plugin/tool";
|
|
9691
9718
|
|
|
9692
9719
|
// src/runtime/task-registry.ts
|
|
9693
9720
|
import { randomUUID } from "crypto";
|
|
@@ -9737,10 +9764,10 @@ var TOOL_DESCRIPTION = [
|
|
|
9737
9764
|
].join(`
|
|
9738
9765
|
`);
|
|
9739
9766
|
function createCancelTool() {
|
|
9740
|
-
return
|
|
9767
|
+
return tool2({
|
|
9741
9768
|
description: TOOL_DESCRIPTION,
|
|
9742
9769
|
args: {
|
|
9743
|
-
task_id:
|
|
9770
|
+
task_id: tool2.schema.string().describe("The task ID returned by `copilot_delegate(...)`. Format: `cpl_<...>`. Required. Idempotent \u2014 non-running task IDs return `{ cancelled: false, was_running: false }` without error.")
|
|
9744
9771
|
},
|
|
9745
9772
|
async execute(args) {
|
|
9746
9773
|
const task = getTask(args.task_id);
|
|
@@ -9754,7 +9781,7 @@ function createCancelTool() {
|
|
|
9754
9781
|
}
|
|
9755
9782
|
|
|
9756
9783
|
// src/tools/delegate.ts
|
|
9757
|
-
import { tool as
|
|
9784
|
+
import { tool as tool3 } from "@opencode-ai/plugin/tool";
|
|
9758
9785
|
|
|
9759
9786
|
// src/runtime/notify.ts
|
|
9760
9787
|
var inFlightCounters = new Map;
|
|
@@ -10073,15 +10100,15 @@ var TOOL_DESCRIPTION2 = [
|
|
|
10073
10100
|
].join(`
|
|
10074
10101
|
`);
|
|
10075
10102
|
function createDelegateTool(options) {
|
|
10076
|
-
return
|
|
10103
|
+
return tool3({
|
|
10077
10104
|
description: `${TOOL_DESCRIPTION2}${options.description}`,
|
|
10078
10105
|
args: {
|
|
10079
|
-
prompt:
|
|
10080
|
-
agent:
|
|
10081
|
-
model:
|
|
10082
|
-
add_dir:
|
|
10083
|
-
allow_tool:
|
|
10084
|
-
deny_tool:
|
|
10106
|
+
prompt: tool3.schema.string().min(1).describe("The instruction Copilot should execute. The prompt body is the entire user-visible task; Copilot owns the planning, tool selection, and execution. Required and must be non-empty. Visible in `ps` output (upstream limitation) \u2014 never include secrets, tokens, or PII."),
|
|
10107
|
+
agent: tool3.schema.string().optional().describe("Agent name (without .md extension) to use for this task. Must match a discovered agent file in `~/.copilot/agents` or `.github/agents`. The list of currently discovered agents appears at the bottom of this tool description; an empty list means no agents are discoverable and `agent` must be omitted. Omit to use the Copilot CLI default."),
|
|
10108
|
+
model: tool3.schema.string().optional().describe("Override the default model for this task. Accepts any model string Copilot CLI recognizes \u2014 for example `claude-opus-4.7`, `claude-sonnet-4.7`, or `gpt-5`. Omit to use the user's configured default."),
|
|
10109
|
+
add_dir: tool3.schema.string().array().optional().describe('Additional repository paths to grant Copilot access to (multi-repo workflows). Each entry becomes a `--add-dir <path>` flag. Use absolute paths. Examples: `["/Users/me/repo-a", "/Users/me/repo-b"]`.'),
|
|
10110
|
+
allow_tool: tool3.schema.string().array().optional().describe('Copilot tool patterns to allow during this task. Each entry becomes an `--allow-tool <pattern>` flag. Examples: `"shell(*)"`, `"edit"`, `"fetch"`. See the Copilot CLI docs for the full pattern syntax. Layered with `deny_tool` when both are present.'),
|
|
10111
|
+
deny_tool: tool3.schema.string().array().optional().describe('Copilot tool patterns to deny during this task. Each entry becomes a `--deny-tool <pattern>` flag. Examples: `"shell(rm)"`, `"shell(curl)"`. Use to harden a task by blocking dangerous operations even if `allow_tool` would permit them.')
|
|
10085
10112
|
},
|
|
10086
10113
|
async execute(args, ctx) {
|
|
10087
10114
|
const runningCount = getAllTasks().filter((task2) => task2.status === "running").length;
|
|
@@ -10160,7 +10187,7 @@ function createDelegateTool(options) {
|
|
|
10160
10187
|
}
|
|
10161
10188
|
|
|
10162
10189
|
// src/tools/output.ts
|
|
10163
|
-
import { tool as
|
|
10190
|
+
import { tool as tool4 } from "@opencode-ai/plugin/tool";
|
|
10164
10191
|
|
|
10165
10192
|
// src/runtime/envelope.ts
|
|
10166
10193
|
function extractFinalMessage(events) {
|
|
@@ -10278,12 +10305,12 @@ var TOOL_DESCRIPTION3 = [
|
|
|
10278
10305
|
].join(`
|
|
10279
10306
|
`);
|
|
10280
10307
|
function createOutputTool() {
|
|
10281
|
-
return
|
|
10308
|
+
return tool4({
|
|
10282
10309
|
description: TOOL_DESCRIPTION3,
|
|
10283
10310
|
args: {
|
|
10284
|
-
task_id:
|
|
10285
|
-
block:
|
|
10286
|
-
timeout_ms:
|
|
10311
|
+
task_id: tool4.schema.string().describe("The task ID returned by `copilot_delegate(...)`. Format: `cpl_<...>`. Required."),
|
|
10312
|
+
block: tool4.schema.boolean().optional().describe("If the task is still running, wait for completion up to `timeout_ms` before returning. Default `false` \u2014 returns immediately with the current state. Set to `true` only when the agent has nothing else to do but wait."),
|
|
10313
|
+
timeout_ms: tool4.schema.number().int().min(0).max(MAX_TIMEOUT_MS).optional().describe("Maximum wait in milliseconds when `block` is `true`. Default 30000. Range 0\u2013120000 (the upper cap protects the OpenCode session from a single hung delegation). For long research tasks, prefer multiple non-blocking calls over a long block.")
|
|
10287
10314
|
},
|
|
10288
10315
|
async execute(args) {
|
|
10289
10316
|
if (!isValidTaskId(args.task_id)) {
|
|
@@ -10348,14 +10375,14 @@ var CopilotDelegate = async ({ client, directory }) => {
|
|
|
10348
10375
|
} catch {}
|
|
10349
10376
|
return {
|
|
10350
10377
|
tool: {
|
|
10351
|
-
copilot_delegate: createDelegateTool({
|
|
10378
|
+
copilot_delegate: normalizeToolArgSchemas(createDelegateTool({
|
|
10352
10379
|
client,
|
|
10353
10380
|
description: delegateDescription,
|
|
10354
10381
|
directory,
|
|
10355
10382
|
pidFilePath: currentInstancePath
|
|
10356
|
-
}),
|
|
10357
|
-
copilot_output: createOutputTool(),
|
|
10358
|
-
copilot_cancel: createCancelTool()
|
|
10383
|
+
})),
|
|
10384
|
+
copilot_output: normalizeToolArgSchemas(createOutputTool()),
|
|
10385
|
+
copilot_cancel: normalizeToolArgSchemas(createCancelTool())
|
|
10359
10386
|
}
|
|
10360
10387
|
};
|
|
10361
10388
|
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@opencode-ai/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Walks a tool definition's `args` map and patches each schema with a
|
|
4
|
+
* JSON Schema override (see {@link attachJsonSchemaOverride}). Mutates and
|
|
5
|
+
* returns the same definition for fluent composition:
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const tool = normalizeToolArgSchemas(createDelegateTool({...}))
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeToolArgSchemas<TDefinition extends Pick<ToolDefinition, 'args'>>(toolDefinition: TDefinition): TDefinition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-copilot-delegate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "OpenCode plugin that delegates tasks to GitHub Copilot CLI as background subprocesses",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -58,6 +58,10 @@
|
|
|
58
58
|
"publish-changesets": "bun run build && changeset publish"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"fkill": "10.0.3"
|
|
61
|
+
"fkill": "10.0.3",
|
|
62
|
+
"zod": "^4.3.0"
|
|
63
|
+
},
|
|
64
|
+
"overrides": {
|
|
65
|
+
"zod": "^4.3.0"
|
|
62
66
|
}
|
|
63
67
|
}
|