@ccx-agent/opencode-ccx 0.2.11 → 0.2.12
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 +39 -17
- package/dist/agents/types.d.ts +1 -0
- package/dist/config/schema.d.ts +3 -0
- package/dist/hooks/chat-message.d.ts +1 -0
- package/dist/hooks/message-transform.d.ts +0 -1
- package/dist/index.js +210 -114
- package/dist/plugin/tool-registry.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Claude Code solved this with a sophisticated behavioral framework — but it's l
|
|
|
23
23
|
|
|
24
24
|
ccx extracts the core behavioral principles from Claude Code's prompt architecture and makes them work in OpenCode — with any model, any provider.
|
|
25
25
|
|
|
26
|
-
It's not a wrapper or a proxy. It's a complete behavioral framework: 8 composable system prompt sections,
|
|
26
|
+
It's not a wrapper or a proxy. It's a complete behavioral framework: 8 composable system prompt sections, 4 default subagents (+ optional coordinator), and 10 runtime hooks that dynamically adapt the agent's behavior every turn.
|
|
27
27
|
|
|
28
28
|
**Before ccx:** Agent writes 200 lines, adds 3 helper files, says "done."
|
|
29
29
|
|
|
@@ -124,15 +124,15 @@ The main agent comes with 8 composable system prompt sections derived from Claud
|
|
|
124
124
|
| **output-efficiency** | Lead with the answer, skip filler, report at milestones not continuously |
|
|
125
125
|
| **environment** | Dynamic workspace context — cwd, git status, platform, shell |
|
|
126
126
|
|
|
127
|
-
###
|
|
127
|
+
### Subagents (Claude-like defaults)
|
|
128
128
|
|
|
129
|
-
| Agent | Mode | Purpose |
|
|
130
|
-
|
|
131
|
-
| **ccx-explore** | read-only | Fast codebase search — parallel glob/grep/read across large repos |
|
|
132
|
-
| **ccx-plan** | read-only | Software architect — produces step-by-step plans with critical file lists |
|
|
133
|
-
| **ccx-verification** | read-only | Adversarial verifier — VERDICT protocol (PASS/FAIL/PARTIAL), runs real commands, catches self-rationalizations |
|
|
134
|
-
| **ccx-general-purpose** | read-write | Multi-strategy worker for tasks outside other specialists |
|
|
135
|
-
| **ccx-coordinator** | orchestrator | Decomposes complex work into Research, Synthesis, Implementation, Verification across parallel workers |
|
|
129
|
+
| Agent | Mode | Default | Purpose |
|
|
130
|
+
|-------|------|---------|---------|
|
|
131
|
+
| **ccx-explore** | read-only | on | Fast codebase search — parallel glob/grep/read across large repos |
|
|
132
|
+
| **ccx-plan** | read-only | on | Software architect — produces step-by-step plans with critical file lists |
|
|
133
|
+
| **ccx-verification** | read-only | on | Adversarial verifier — VERDICT protocol (PASS/FAIL/PARTIAL), runs real commands, catches self-rationalizations |
|
|
134
|
+
| **ccx-general-purpose** | read-write | on | Multi-strategy worker for tasks outside other specialists |
|
|
135
|
+
| **ccx-coordinator** | orchestrator | off | Decomposes complex work into Research, Synthesis, Implementation, Verification across parallel workers. Tool surface is restricted to `task` + `question` |
|
|
136
136
|
|
|
137
137
|
### 10 Runtime Hooks
|
|
138
138
|
|
|
@@ -142,7 +142,7 @@ ccx uses every major hook point in the OpenCode plugin API to dynamically shape
|
|
|
142
142
|
|
|
143
143
|
| Hook | What it does |
|
|
144
144
|
|------|-------------|
|
|
145
|
-
| **config** | Registers the ccx agent +
|
|
145
|
+
| **config** | Registers the ccx agent + enabled subagents (coordinator is opt-in) with their system prompts and tool restrictions |
|
|
146
146
|
| **tool** | Creates agent dispatch tools for the subagent registry |
|
|
147
147
|
|
|
148
148
|
#### Per-Turn Hooks (every LLM call)
|
|
@@ -153,7 +153,7 @@ ccx uses every major hook point in the OpenCode plugin API to dynamically shape
|
|
|
153
153
|
| **chat.params** | Tunes temperature/topP per agent — low for plan/verification (precision), higher for explore (creativity) |
|
|
154
154
|
| **experimental.chat.system.transform** | Dynamically injects project instructions (CLAUDE.md), session context (edited files list), and verification reminders into the system prompt |
|
|
155
155
|
| **tool.definition** | Appends safety rules to bash/edit/write tool descriptions, usage hints to glob/grep/read |
|
|
156
|
-
| **experimental.chat.messages.transform** |
|
|
156
|
+
| **experimental.chat.messages.transform** | Automatically microcompacts older clearable tool outputs (keeps recent 5), trims long tool outputs (>8KB), collapses consecutive reasoning parts to save context |
|
|
157
157
|
|
|
158
158
|
#### Event Hooks (reactive)
|
|
159
159
|
|
|
@@ -174,11 +174,14 @@ ccx was built by studying Claude Code's prompt architecture and adapting its cor
|
|
|
174
174
|
| Claude Code Feature | ccx Implementation |
|
|
175
175
|
|--------------------|--------------------|
|
|
176
176
|
| 8-section system prompt | 8 composable prompt sections, near-identical content |
|
|
177
|
-
|
|
|
178
|
-
|
|
|
177
|
+
| Agent orchestration guidance | Same guidance style: use specialized subagents when appropriate, avoid overuse, avoid duplicate delegated work |
|
|
178
|
+
| Explore escalation threshold | `explore_min_queries=3` default (matches Claude CLI external default) |
|
|
179
|
+
| Coordinator default | Disabled by default, opt-in via config |
|
|
180
|
+
| Verification contract | Configurable. Strict contract is opt-in (`verification.enforce_contract=true`) |
|
|
179
181
|
| VERDICT protocol (PASS/FAIL/PARTIAL) | Identical format and adversarial strategies |
|
|
180
182
|
| Project instructions (CLAUDE.md) | Auto-loaded from CLAUDE.md / .claude/instructions.md / AGENTS.md |
|
|
181
183
|
| Tool safety hints | `tool.definition` hook appends rules to bash/edit/write descriptions |
|
|
184
|
+
| Tool-output microcompact | Older `read/grep/glob/bash/webfetch` results are compacted automatically while preserving recent outputs |
|
|
182
185
|
| Context compaction preservation | Custom compaction prompt via `experimental.session.compacting` |
|
|
183
186
|
| Trust boundary / prompt injection defense | Explicit section in system prompt |
|
|
184
187
|
|
|
@@ -193,6 +196,19 @@ ccx was built by studying Claude Code's prompt architecture and adapting its cor
|
|
|
193
196
|
| Plan mode with user approval gate | Requires TUI integration (experimental) |
|
|
194
197
|
| AST-level bash command analysis | Possible but high complexity cost |
|
|
195
198
|
|
|
199
|
+
### Workflow parity summary (current defaults)
|
|
200
|
+
|
|
201
|
+
With the default ccx config shown below, workflow behavior is aligned to Claude CLI's external/default orchestration style:
|
|
202
|
+
|
|
203
|
+
- subagents are used when needed, not by default for every task
|
|
204
|
+
- broad exploration escalates after directed search becomes insufficient (`explore_min_queries=3`)
|
|
205
|
+
- coordinator-style multi-hop orchestration is off by default
|
|
206
|
+
- recursive subagent delegation is discouraged by default
|
|
207
|
+
- strict mandatory verification contract is off by default (opt-in)
|
|
208
|
+
- when enabled, coordinator runs orchestration-only with a constrained tool surface (`task` + `question`)
|
|
209
|
+
|
|
210
|
+
This is behavior-level parity, not engine-level identity. Engine internals (runtime schedulers, fork execution model, feature-flag infrastructure) are different and remain outside plugin scope.
|
|
211
|
+
|
|
196
212
|
---
|
|
197
213
|
|
|
198
214
|
## The Verification Agent
|
|
@@ -274,7 +290,8 @@ Example:
|
|
|
274
290
|
"disabled_hooks": [],
|
|
275
291
|
"output_style": null,
|
|
276
292
|
"verification": {
|
|
277
|
-
"auto_remind":
|
|
293
|
+
"auto_remind": false,
|
|
294
|
+
"enforce_contract": false,
|
|
278
295
|
"min_file_edits": 3,
|
|
279
296
|
"spot_check_min_commands": 2
|
|
280
297
|
},
|
|
@@ -282,7 +299,9 @@ Example:
|
|
|
282
299
|
"enforce_high_risk_confirmation": true
|
|
283
300
|
},
|
|
284
301
|
"subagent_orchestration": {
|
|
285
|
-
"explore_min_queries":
|
|
302
|
+
"explore_min_queries": 3,
|
|
303
|
+
"coordinator_enabled": false,
|
|
304
|
+
"allow_subagent_delegation": false
|
|
286
305
|
}
|
|
287
306
|
}
|
|
288
307
|
```
|
|
@@ -293,11 +312,14 @@ Example:
|
|
|
293
312
|
| `disabled_sections` | `string[]` | `[]` | Prompt sections to skip (e.g., `["tone-style"]`) |
|
|
294
313
|
| `disabled_hooks` | `string[]` | `[]` | Hooks to disable (e.g., `["risk-guard"]`) |
|
|
295
314
|
| `output_style` | `string \| null` | `null` | Custom output style name |
|
|
296
|
-
| `verification.auto_remind` | `boolean` | `
|
|
315
|
+
| `verification.auto_remind` | `boolean` | `false` | Auto-nudge verification after edits |
|
|
316
|
+
| `verification.enforce_contract` | `boolean` | `false` | Enable strict verification contract wording and reminder logic |
|
|
297
317
|
| `verification.min_file_edits` | `number` | `3` | File edit threshold before nudge |
|
|
298
318
|
| `verification.spot_check_min_commands` | `number` | `2` | Minimum verifier commands to re-run after PASS spot-check |
|
|
299
319
|
| `risk_guard.enforce_high_risk_confirmation` | `boolean` | `true` | Block high-risk commands unless explicit user confirmation is present |
|
|
300
|
-
| `subagent_orchestration.explore_min_queries` | `number` | `
|
|
320
|
+
| `subagent_orchestration.explore_min_queries` | `number` | `3` | Escalate to `ccx-explore` when directed lookup likely needs more than this query count |
|
|
321
|
+
| `subagent_orchestration.coordinator_enabled` | `boolean` | `false` | Register and advertise `ccx-coordinator` subagent |
|
|
322
|
+
| `subagent_orchestration.allow_subagent_delegation` | `boolean` | `false` | Permit subagents to delegate further. When `false`, runtime recursion guard blocks nested `task` delegation from `ccx-*` subagents unless explicit delegation-approval metadata is present |
|
|
301
323
|
|
|
302
324
|
---
|
|
303
325
|
|
package/dist/agents/types.d.ts
CHANGED
package/dist/config/schema.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
6
6
|
output_style: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
7
7
|
verification: z.ZodDefault<z.ZodObject<{
|
|
8
8
|
auto_remind: z.ZodDefault<z.ZodBoolean>;
|
|
9
|
+
enforce_contract: z.ZodDefault<z.ZodBoolean>;
|
|
9
10
|
min_file_edits: z.ZodDefault<z.ZodInt>;
|
|
10
11
|
spot_check_min_commands: z.ZodDefault<z.ZodInt>;
|
|
11
12
|
}, z.core.$strip>>;
|
|
@@ -14,6 +15,8 @@ export declare const configSchema: z.ZodObject<{
|
|
|
14
15
|
}, z.core.$strip>>;
|
|
15
16
|
subagent_orchestration: z.ZodDefault<z.ZodObject<{
|
|
16
17
|
explore_min_queries: z.ZodDefault<z.ZodInt>;
|
|
18
|
+
coordinator_enabled: z.ZodDefault<z.ZodBoolean>;
|
|
19
|
+
allow_subagent_delegation: z.ZodDefault<z.ZodBoolean>;
|
|
17
20
|
}, z.core.$strip>>;
|
|
18
21
|
}, z.core.$strip>;
|
|
19
22
|
export type OhMyCCAgentConfig = z.infer<typeof configSchema>;
|
|
@@ -16,5 +16,6 @@ type ChatMessageOutput = {
|
|
|
16
16
|
[key: string]: unknown;
|
|
17
17
|
}>;
|
|
18
18
|
};
|
|
19
|
+
export declare function getSessionAgent(sessionID: string): string | undefined;
|
|
19
20
|
export declare function createChatMessageHook(_config: OhMyCCAgentConfig): (input: ChatMessageInput, _output: ChatMessageOutput) => Promise<void>;
|
|
20
21
|
export {};
|
|
@@ -11,7 +11,6 @@ type MessageInfo = {
|
|
|
11
11
|
[key: string]: unknown;
|
|
12
12
|
}>;
|
|
13
13
|
};
|
|
14
|
-
export declare function enableMicrocompact(): void;
|
|
15
14
|
export declare function createMessageTransformHook(): (_input: Record<string, unknown>, output: {
|
|
16
15
|
messages: MessageInfo[];
|
|
17
16
|
}) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -13553,7 +13553,8 @@ function date4(params) {
|
|
|
13553
13553
|
config(en_default());
|
|
13554
13554
|
// src/config/schema.ts
|
|
13555
13555
|
var verificationSchema = exports_external.object({
|
|
13556
|
-
auto_remind: exports_external.boolean().default(
|
|
13556
|
+
auto_remind: exports_external.boolean().default(false),
|
|
13557
|
+
enforce_contract: exports_external.boolean().default(false),
|
|
13557
13558
|
min_file_edits: exports_external.int().nonnegative().default(3),
|
|
13558
13559
|
spot_check_min_commands: exports_external.int().positive().default(2)
|
|
13559
13560
|
});
|
|
@@ -13561,7 +13562,9 @@ var riskGuardSchema = exports_external.object({
|
|
|
13561
13562
|
enforce_high_risk_confirmation: exports_external.boolean().default(true)
|
|
13562
13563
|
});
|
|
13563
13564
|
var subagentOrchestrationSchema = exports_external.object({
|
|
13564
|
-
explore_min_queries: exports_external.int().positive().default(
|
|
13565
|
+
explore_min_queries: exports_external.int().positive().default(3),
|
|
13566
|
+
coordinator_enabled: exports_external.boolean().default(false),
|
|
13567
|
+
allow_subagent_delegation: exports_external.boolean().default(false)
|
|
13565
13568
|
});
|
|
13566
13569
|
var configSchema = exports_external.object({
|
|
13567
13570
|
enabled: exports_external.boolean().default(true),
|
|
@@ -13569,7 +13572,8 @@ var configSchema = exports_external.object({
|
|
|
13569
13572
|
disabled_hooks: exports_external.array(exports_external.string()).default([]),
|
|
13570
13573
|
output_style: exports_external.string().min(1).nullable().default(null),
|
|
13571
13574
|
verification: verificationSchema.default({
|
|
13572
|
-
auto_remind:
|
|
13575
|
+
auto_remind: false,
|
|
13576
|
+
enforce_contract: false,
|
|
13573
13577
|
min_file_edits: 3,
|
|
13574
13578
|
spot_check_min_commands: 2
|
|
13575
13579
|
}),
|
|
@@ -13577,7 +13581,9 @@ var configSchema = exports_external.object({
|
|
|
13577
13581
|
enforce_high_risk_confirmation: true
|
|
13578
13582
|
}),
|
|
13579
13583
|
subagent_orchestration: subagentOrchestrationSchema.default({
|
|
13580
|
-
explore_min_queries:
|
|
13584
|
+
explore_min_queries: 3,
|
|
13585
|
+
coordinator_enabled: false,
|
|
13586
|
+
allow_subagent_delegation: false
|
|
13581
13587
|
})
|
|
13582
13588
|
});
|
|
13583
13589
|
|
|
@@ -13653,6 +13659,10 @@ function loadConfig(directory) {
|
|
|
13653
13659
|
}
|
|
13654
13660
|
|
|
13655
13661
|
// src/hooks/chat-message.ts
|
|
13662
|
+
var sessionAgentById = new Map;
|
|
13663
|
+
function getSessionAgent(sessionID) {
|
|
13664
|
+
return sessionAgentById.get(sessionID);
|
|
13665
|
+
}
|
|
13656
13666
|
function createChatMessageHook(_config) {
|
|
13657
13667
|
return async (input, _output) => {
|
|
13658
13668
|
if (!_config.enabled)
|
|
@@ -13660,6 +13670,9 @@ function createChatMessageHook(_config) {
|
|
|
13660
13670
|
const { sessionID, agent } = input;
|
|
13661
13671
|
if (!sessionID)
|
|
13662
13672
|
return;
|
|
13673
|
+
if (agent) {
|
|
13674
|
+
sessionAgentById.set(sessionID, agent);
|
|
13675
|
+
}
|
|
13663
13676
|
if (agent && !agent.startsWith("ccx"))
|
|
13664
13677
|
return;
|
|
13665
13678
|
};
|
|
@@ -13981,6 +13994,7 @@ Tool usage:
|
|
|
13981
13994
|
- "Read" \u2014 when you already know the exact path to examine
|
|
13982
13995
|
- "Bash" \u2014 permitted only for non-mutating operations (ls, git status, git log, git diff, find, grep, cat, head, tail)
|
|
13983
13996
|
- "Bash" is off-limits for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or anything that creates or alters files
|
|
13997
|
+
- Execute the assigned search directly. Delegate again only when the caller explicitly asks for delegation or your instructions explicitly permit it
|
|
13984
13998
|
- Calibrate your search depth according to the thoroughness level the caller requests
|
|
13985
13999
|
- Deliver your findings as a direct text response \u2014 never try to write results to a file
|
|
13986
14000
|
|
|
@@ -14026,8 +14040,9 @@ You will receive a set of requirements and potentially a guiding perspective on
|
|
|
14026
14040
|
- Map the current system structure
|
|
14027
14041
|
- Locate analogous features that can serve as templates
|
|
14028
14042
|
- Walk through the relevant execution flows
|
|
14029
|
-
|
|
14030
|
-
|
|
14043
|
+
- "Bash" is allowed exclusively for non-mutating commands (ls, git status, git log, git diff, find, grep, cat, head, tail)
|
|
14044
|
+
- "Bash" is off-limits for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or anything that creates or modifies files
|
|
14045
|
+
- Execute planning work directly. Delegate again only when the caller explicitly asks for delegation or your instructions explicitly permit it
|
|
14031
14046
|
|
|
14032
14047
|
3. **Architect the Solution**:
|
|
14033
14048
|
- Formulate an implementation strategy aligned with your assigned perspective
|
|
@@ -14072,7 +14087,8 @@ Operating principles:
|
|
|
14072
14087
|
- When analyzing: begin with broad searches, then zoom in. If one search strategy comes up empty, try a different angle.
|
|
14073
14088
|
- Be comprehensive: inspect multiple directories, account for alternative naming styles, and look for related modules.
|
|
14074
14089
|
- NEVER generate new files unless the task strictly demands it. ALWAYS modify an existing file rather than creating a fresh one.
|
|
14075
|
-
- NEVER spontaneously produce documentation files (*.md) or README files. Only generate documentation when the user explicitly asks for it
|
|
14090
|
+
- NEVER spontaneously produce documentation files (*.md) or README files. Only generate documentation when the user explicitly asks for it.
|
|
14091
|
+
- If you are running as a subagent, execute directly. Delegate again only when the caller explicitly asks for delegation or your instructions explicitly permit it.`;
|
|
14076
14092
|
function getGeneralPurposeAgentPrompt() {
|
|
14077
14093
|
return `${SHARED_PREFIX} Once finished, provide a brief summary of what was accomplished and any notable discoveries \u2014 this will be relayed to the user, so focus on the essential takeaways.
|
|
14078
14094
|
|
|
@@ -14100,6 +14116,8 @@ You ARE permitted to write throwaway test harnesses to a temporary directory (/t
|
|
|
14100
14116
|
|
|
14101
14117
|
Inspect what tools are actually available in your session rather than making assumptions. You may have access to browser automation, HTTP fetching, or additional MCP capabilities \u2014 do not neglect tools you failed to check for.
|
|
14102
14118
|
|
|
14119
|
+
Execute verification directly in this session. Delegate again only when the caller explicitly asks for delegation or your instructions explicitly permit it.
|
|
14120
|
+
|
|
14103
14121
|
=== WHAT YOU RECEIVE ===
|
|
14104
14122
|
You will be given: the original task specification, the list of changed files, the implementation approach, and optionally a path to a plan or spec document.
|
|
14105
14123
|
|
|
@@ -14355,29 +14373,48 @@ When a worker reports failure:
|
|
|
14355
14373
|
|
|
14356
14374
|
- Reserve direct answers for simple questions that need no tool invocation.
|
|
14357
14375
|
- For substantial engineering work, operate through workers.
|
|
14376
|
+
- Do not spawn additional coordinator agents. Keep delegation chains shallow and route work to execution-focused workers.
|
|
14358
14377
|
- Do not assign one worker to monitor another worker.
|
|
14359
14378
|
- Do not speculate about results that have not yet arrived.
|
|
14360
14379
|
- After dispatching workers, inform the user what was launched and what remains pending.
|
|
14361
14380
|
- Digest findings before assigning follow-up work.
|
|
14362
14381
|
- Never implement directly when delegation is an option.
|
|
14363
14382
|
|
|
14383
|
+
## Tool Surface (Enforced)
|
|
14384
|
+
|
|
14385
|
+
- Your tool surface is intentionally narrow: use 1) the \`task\` tool to delegate work, and 2) the \`question\` tool only when user input is strictly required.
|
|
14386
|
+
- Do not execute implementation tools directly (Bash/Read/Edit/Write/Glob/Grep/etc.) from coordinator mode.
|
|
14387
|
+
|
|
14364
14388
|
Your operating loop is: comprehend -> decompose -> delegate -> digest -> delegate next phase -> verify -> report.`;
|
|
14365
14389
|
}
|
|
14366
14390
|
var COORDINATOR_AGENT_DEFINITION = {
|
|
14367
14391
|
name: "coordinator",
|
|
14368
14392
|
description: "Task orchestration agent for complex engineering work. Deploy this when a request should be decomposed into research, implementation, and verification phases distributed across multiple worker agents rather than executed by a single agent.",
|
|
14369
|
-
getSystemPrompt: getCoordinatorAgentPrompt
|
|
14393
|
+
getSystemPrompt: getCoordinatorAgentPrompt,
|
|
14394
|
+
allowedTools: ["task", "question"]
|
|
14370
14395
|
};
|
|
14371
14396
|
|
|
14372
14397
|
// src/hooks/config-handler.ts
|
|
14373
|
-
var
|
|
14398
|
+
var BASE_SUBAGENT_DEFINITIONS = [
|
|
14374
14399
|
EXPLORE_AGENT_DEFINITION,
|
|
14375
14400
|
PLAN_AGENT_DEFINITION,
|
|
14376
14401
|
GENERAL_PURPOSE_AGENT_DEFINITION,
|
|
14377
|
-
VERIFICATION_AGENT_DEFINITION
|
|
14378
|
-
COORDINATOR_AGENT_DEFINITION
|
|
14402
|
+
VERIFICATION_AGENT_DEFINITION
|
|
14379
14403
|
];
|
|
14404
|
+
function getEnabledSubagentDefinitions(config2) {
|
|
14405
|
+
if (config2.subagent_orchestration.coordinator_enabled) {
|
|
14406
|
+
return [...BASE_SUBAGENT_DEFINITIONS, COORDINATOR_AGENT_DEFINITION];
|
|
14407
|
+
}
|
|
14408
|
+
return BASE_SUBAGENT_DEFINITIONS;
|
|
14409
|
+
}
|
|
14380
14410
|
function buildToolRestrictions(def) {
|
|
14411
|
+
if (def.allowedTools && def.allowedTools.length > 0) {
|
|
14412
|
+
const tools2 = { "*": false };
|
|
14413
|
+
for (const tool of def.allowedTools) {
|
|
14414
|
+
tools2[tool.toLowerCase()] = true;
|
|
14415
|
+
}
|
|
14416
|
+
return tools2;
|
|
14417
|
+
}
|
|
14381
14418
|
if (!def.disallowedTools || def.disallowedTools.length === 0)
|
|
14382
14419
|
return;
|
|
14383
14420
|
const tools = { "*": true };
|
|
@@ -14389,40 +14426,57 @@ function buildToolRestrictions(def) {
|
|
|
14389
14426
|
function buildSubagentGuidance(config2) {
|
|
14390
14427
|
const exploreMinQueries = config2.subagent_orchestration.explore_min_queries;
|
|
14391
14428
|
const spotCheckMinCommands = config2.verification.spot_check_min_commands;
|
|
14392
|
-
const
|
|
14429
|
+
const enabledSubagents = getEnabledSubagentDefinitions(config2);
|
|
14430
|
+
const agentList = enabledSubagents.map((def) => `- **ccx-${def.name}**: ${def.description}`).join(`
|
|
14393
14431
|
`);
|
|
14432
|
+
const whenToUse = [
|
|
14433
|
+
`- Invoke the **task** tool with subagent_type \`ccx-explore\` for wide-ranging codebase exploration or in-depth research. For targeted lookups (a known file, class, or function name), use Glob or Grep directly \u2014 escalate to ccx-explore only when a simple search falls short or when the task clearly requires more than ${exploreMinQueries} queries.`,
|
|
14434
|
+
"- Invoke the **task** tool with subagent_type `ccx-plan` when an implementation strategy should be designed before any code is written. The plan agent examines the codebase in read-only mode and produces a step-by-step approach with key files identified.",
|
|
14435
|
+
"- Invoke the **task** tool with subagent_type `ccx-general-purpose` for multi-step work that does not fall under any other specialist's domain."
|
|
14436
|
+
];
|
|
14437
|
+
if (config2.subagent_orchestration.coordinator_enabled) {
|
|
14438
|
+
whenToUse.push("- Invoke the **task** tool with subagent_type `ccx-coordinator` for complex tasks best decomposed into research, implementation, and verification phases distributed across multiple workers.");
|
|
14439
|
+
}
|
|
14440
|
+
const subagentUsageRules = [
|
|
14441
|
+
"- Subagents excel at running independent queries concurrently and keeping bulky output out of the main context, but avoid overusing them when the work is simple enough to handle directly.",
|
|
14442
|
+
"- Do NOT redo work that a subagent is already performing \u2014 once you delegate a research task, refrain from executing the same searches yourself.",
|
|
14443
|
+
"- When dispatching subagents, inform the user about what was launched and what results you are awaiting.",
|
|
14444
|
+
"- You may launch several subagents concurrently by issuing multiple task tool calls within a single response."
|
|
14445
|
+
];
|
|
14446
|
+
if (config2.subagent_orchestration.allow_subagent_delegation) {
|
|
14447
|
+
subagentUsageRules.push("- If you are already operating as a subagent, prefer executing directly and keep delegation chains shallow.");
|
|
14448
|
+
} else {
|
|
14449
|
+
subagentUsageRules.push("- If you are already operating as a subagent, execute directly and avoid recursively dispatching more subagents unless the user explicitly requests delegation.");
|
|
14450
|
+
}
|
|
14451
|
+
const verificationSection = config2.verification.enforce_contract ? `## Verification contract
|
|
14452
|
+
|
|
14453
|
+
The rule: whenever non-trivial implementation occurs during your turn, an independent adversarial review must take place before you declare completion \u2014 whether you wrote the code yourself or a subagent did. You are the gatekeeper. Non-trivial is defined as: 3+ file edits, backend/API changes, or infrastructure changes.
|
|
14454
|
+
|
|
14455
|
+
Launch the **task** tool with subagent_type \`ccx-verification\`. Supply the ORIGINAL user task description, the list of changed files, and the approach used. Your own review and commentary do NOT count \u2014 only the verification agent assigns a verdict; you may not self-assign PARTIAL.
|
|
14456
|
+
|
|
14457
|
+
- On **FAIL**: address the reported issue, then resume the verifier session with the failure details plus your correction. Iterate until PASS.
|
|
14458
|
+
- On **PASS**: perform a spot-check \u2014 re-execute at least ${spotCheckMinCommands} commands from the verifier's report and confirm outputs match. If any PASS step lacks a Command run block or the output differs, resume the verifier with the discrepancy.
|
|
14459
|
+
- On **PARTIAL**: communicate what passed and what remained unverifiable due to environment constraints.` : "## Verification guidance\n\nFor significant implementation changes, prefer independent verification with subagent_type `ccx-verification` before reporting completion.";
|
|
14394
14460
|
return `# Subagent orchestration
|
|
14395
14461
|
|
|
14396
|
-
|
|
14462
|
+
Use the \`task\` tool with specialized subagents when the current task clearly matches their role. Subagents are useful for parallelizing independent work and protecting the main context window from bulky output, but they should not be used excessively.
|
|
14397
14463
|
|
|
14398
|
-
|
|
14464
|
+
Avoid duplicate work: once a search or investigation is delegated, do not run the same lookups in parallel from the current agent.
|
|
14399
14465
|
|
|
14400
14466
|
## Available subagents
|
|
14401
14467
|
${agentList}
|
|
14402
14468
|
|
|
14403
14469
|
## When to use subagents
|
|
14404
14470
|
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
- Invoke the **task** tool with subagent_type \`ccx-general-purpose\` for multi-step work that does not fall under any other specialist's domain.
|
|
14408
|
-
- Invoke the **task** tool with subagent_type \`ccx-coordinator\` for complex tasks best decomposed into research, implementation, and verification phases distributed across multiple workers.
|
|
14471
|
+
${whenToUse.join(`
|
|
14472
|
+
`)}
|
|
14409
14473
|
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
The rule: whenever non-trivial implementation occurs during your turn, an independent adversarial review must take place before you declare completion \u2014 whether you wrote the code yourself or a subagent did. You are the gatekeeper. Non-trivial is defined as: 3+ file edits, backend/API changes, or infrastructure changes.
|
|
14413
|
-
|
|
14414
|
-
Launch the **task** tool with subagent_type \`ccx-verification\`. Supply the ORIGINAL user task description, the list of changed files, and the approach used. Your own review and commentary do NOT count \u2014 only the verification agent assigns a verdict; you may not self-assign PARTIAL.
|
|
14415
|
-
|
|
14416
|
-
- On **FAIL**: address the reported issue, then resume the verifier session with the failure details plus your correction. Iterate until PASS.
|
|
14417
|
-
- On **PASS**: perform a spot-check \u2014 re-execute at least ${spotCheckMinCommands} commands from the verifier's report and confirm outputs match. If any PASS step lacks a Command run block or the output differs, resume the verifier with the discrepancy.
|
|
14418
|
-
- On **PARTIAL**: communicate what passed and what remained unverifiable due to environment constraints.
|
|
14474
|
+
${verificationSection}
|
|
14419
14475
|
|
|
14420
14476
|
## Subagent usage rules
|
|
14421
14477
|
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
- When dispatching subagents, inform the user about what was launched and what results you are awaiting.
|
|
14425
|
-
- You may launch several subagents concurrently by issuing multiple task tool calls within a single response.`;
|
|
14478
|
+
${subagentUsageRules.join(`
|
|
14479
|
+
`)}`;
|
|
14426
14480
|
}
|
|
14427
14481
|
function createConfigHook(config2, directory) {
|
|
14428
14482
|
return async (input) => {
|
|
@@ -14450,8 +14504,9 @@ function createConfigHook(config2, directory) {
|
|
|
14450
14504
|
prompt: mainPrompt,
|
|
14451
14505
|
tools: { "*": true }
|
|
14452
14506
|
};
|
|
14507
|
+
const enabledSubagents = getEnabledSubagentDefinitions(config2);
|
|
14453
14508
|
const subagents = {};
|
|
14454
|
-
for (const def of
|
|
14509
|
+
for (const def of enabledSubagents) {
|
|
14455
14510
|
subagents[`ccx-${def.name}`] = {
|
|
14456
14511
|
description: def.description,
|
|
14457
14512
|
mode: "subagent",
|
|
@@ -14578,7 +14633,7 @@ function getFilePath(value) {
|
|
|
14578
14633
|
}
|
|
14579
14634
|
function createVerificationReminder(config2) {
|
|
14580
14635
|
return async (input, _output) => {
|
|
14581
|
-
if (!config2.verification.auto_remind || !isRecord2(input)) {
|
|
14636
|
+
if (!config2.verification.enforce_contract || !config2.verification.auto_remind || !isRecord2(input)) {
|
|
14582
14637
|
return;
|
|
14583
14638
|
}
|
|
14584
14639
|
const sessionID = typeof input.sessionID === "string" ? input.sessionID : undefined;
|
|
@@ -14689,7 +14744,7 @@ Files edited in this session (${editedFilesCount} total): ${editedFiles.join(",
|
|
|
14689
14744
|
resolve: () => {
|
|
14690
14745
|
if (!sessionID)
|
|
14691
14746
|
return null;
|
|
14692
|
-
if (!config2.verification.auto_remind)
|
|
14747
|
+
if (!config2.verification.enforce_contract || !config2.verification.auto_remind)
|
|
14693
14748
|
return null;
|
|
14694
14749
|
if (!requiresVerification(sessionID, config2.verification.min_file_edits)) {
|
|
14695
14750
|
return null;
|
|
@@ -14744,6 +14799,71 @@ function createEnvironmentContext(directory) {
|
|
|
14744
14799
|
};
|
|
14745
14800
|
}
|
|
14746
14801
|
|
|
14802
|
+
// src/hooks/idle-compaction.ts
|
|
14803
|
+
var sessionStates = new Map;
|
|
14804
|
+
var IDLE_THRESHOLD_MS = 30 * 60 * 1000;
|
|
14805
|
+
var MIN_TURNS_BEFORE_COMPACT = 10;
|
|
14806
|
+
function getIdleState(sessionID) {
|
|
14807
|
+
const existing = sessionStates.get(sessionID);
|
|
14808
|
+
if (existing)
|
|
14809
|
+
return existing;
|
|
14810
|
+
const state = {
|
|
14811
|
+
lastIdleTimestamp: 0,
|
|
14812
|
+
turnCount: 0,
|
|
14813
|
+
compactedAt: 0
|
|
14814
|
+
};
|
|
14815
|
+
sessionStates.set(sessionID, state);
|
|
14816
|
+
return state;
|
|
14817
|
+
}
|
|
14818
|
+
function recordSessionIdle(sessionID) {
|
|
14819
|
+
const state = getIdleState(sessionID);
|
|
14820
|
+
state.lastIdleTimestamp = Date.now();
|
|
14821
|
+
}
|
|
14822
|
+
function recordSessionTurn(sessionID) {
|
|
14823
|
+
getIdleState(sessionID).turnCount++;
|
|
14824
|
+
}
|
|
14825
|
+
function shouldCompactOnReturn(sessionID) {
|
|
14826
|
+
const state = getIdleState(sessionID);
|
|
14827
|
+
if (state.lastIdleTimestamp === 0)
|
|
14828
|
+
return false;
|
|
14829
|
+
if (state.turnCount < MIN_TURNS_BEFORE_COMPACT)
|
|
14830
|
+
return false;
|
|
14831
|
+
const idleDuration = Date.now() - state.lastIdleTimestamp;
|
|
14832
|
+
if (idleDuration < IDLE_THRESHOLD_MS)
|
|
14833
|
+
return false;
|
|
14834
|
+
const turnsSinceCompact = state.turnCount - state.compactedAt;
|
|
14835
|
+
return turnsSinceCompact >= MIN_TURNS_BEFORE_COMPACT;
|
|
14836
|
+
}
|
|
14837
|
+
function markCompacted(sessionID) {
|
|
14838
|
+
const state = getIdleState(sessionID);
|
|
14839
|
+
state.compactedAt = state.turnCount;
|
|
14840
|
+
}
|
|
14841
|
+
function createIdleCompactionHook(config2, client) {
|
|
14842
|
+
const typedClient = client;
|
|
14843
|
+
return {
|
|
14844
|
+
onEvent: async (event) => {
|
|
14845
|
+
if (!config2.enabled)
|
|
14846
|
+
return;
|
|
14847
|
+
if (event.type !== "session.idle")
|
|
14848
|
+
return;
|
|
14849
|
+
const sessionID = event.properties?.sessionID;
|
|
14850
|
+
if (!sessionID)
|
|
14851
|
+
return;
|
|
14852
|
+
recordSessionIdle(sessionID);
|
|
14853
|
+
},
|
|
14854
|
+
onChatMessage: async (sessionID) => {
|
|
14855
|
+
if (!config2.enabled)
|
|
14856
|
+
return;
|
|
14857
|
+
if (!shouldCompactOnReturn(sessionID))
|
|
14858
|
+
return;
|
|
14859
|
+
try {
|
|
14860
|
+
await typedClient.session.summarize({ path: { id: sessionID } });
|
|
14861
|
+
markCompacted(sessionID);
|
|
14862
|
+
} catch {}
|
|
14863
|
+
}
|
|
14864
|
+
};
|
|
14865
|
+
}
|
|
14866
|
+
|
|
14747
14867
|
// src/hooks/message-transform.ts
|
|
14748
14868
|
var MAX_TOOL_OUTPUT_LENGTH = 8000;
|
|
14749
14869
|
var TOOL_OUTPUT_TRIM_TO = 4000;
|
|
@@ -14809,87 +14929,14 @@ function collapseConsecutiveReasoningParts(messages) {
|
|
|
14809
14929
|
msg.parts = collapsed;
|
|
14810
14930
|
}
|
|
14811
14931
|
}
|
|
14812
|
-
var microcompactEnabled = false;
|
|
14813
|
-
function enableMicrocompact() {
|
|
14814
|
-
microcompactEnabled = true;
|
|
14815
|
-
}
|
|
14816
14932
|
function createMessageTransformHook() {
|
|
14817
14933
|
return async (_input, output) => {
|
|
14818
|
-
|
|
14819
|
-
microcompactOldToolOutputs(output.messages);
|
|
14820
|
-
microcompactEnabled = false;
|
|
14821
|
-
}
|
|
14934
|
+
microcompactOldToolOutputs(output.messages);
|
|
14822
14935
|
trimLongToolOutputs(output.messages);
|
|
14823
14936
|
collapseConsecutiveReasoningParts(output.messages);
|
|
14824
14937
|
};
|
|
14825
14938
|
}
|
|
14826
14939
|
|
|
14827
|
-
// src/hooks/idle-compaction.ts
|
|
14828
|
-
var sessionStates = new Map;
|
|
14829
|
-
var IDLE_THRESHOLD_MS = 30 * 60 * 1000;
|
|
14830
|
-
var MIN_TURNS_BEFORE_COMPACT = 10;
|
|
14831
|
-
function getIdleState(sessionID) {
|
|
14832
|
-
const existing = sessionStates.get(sessionID);
|
|
14833
|
-
if (existing)
|
|
14834
|
-
return existing;
|
|
14835
|
-
const state = {
|
|
14836
|
-
lastIdleTimestamp: 0,
|
|
14837
|
-
turnCount: 0,
|
|
14838
|
-
compactedAt: 0
|
|
14839
|
-
};
|
|
14840
|
-
sessionStates.set(sessionID, state);
|
|
14841
|
-
return state;
|
|
14842
|
-
}
|
|
14843
|
-
function recordSessionIdle(sessionID) {
|
|
14844
|
-
const state = getIdleState(sessionID);
|
|
14845
|
-
state.lastIdleTimestamp = Date.now();
|
|
14846
|
-
}
|
|
14847
|
-
function recordSessionTurn(sessionID) {
|
|
14848
|
-
getIdleState(sessionID).turnCount++;
|
|
14849
|
-
}
|
|
14850
|
-
function shouldCompactOnReturn(sessionID) {
|
|
14851
|
-
const state = getIdleState(sessionID);
|
|
14852
|
-
if (state.lastIdleTimestamp === 0)
|
|
14853
|
-
return false;
|
|
14854
|
-
if (state.turnCount < MIN_TURNS_BEFORE_COMPACT)
|
|
14855
|
-
return false;
|
|
14856
|
-
const idleDuration = Date.now() - state.lastIdleTimestamp;
|
|
14857
|
-
if (idleDuration < IDLE_THRESHOLD_MS)
|
|
14858
|
-
return false;
|
|
14859
|
-
const turnsSinceCompact = state.turnCount - state.compactedAt;
|
|
14860
|
-
return turnsSinceCompact >= MIN_TURNS_BEFORE_COMPACT;
|
|
14861
|
-
}
|
|
14862
|
-
function markCompacted(sessionID) {
|
|
14863
|
-
const state = getIdleState(sessionID);
|
|
14864
|
-
state.compactedAt = state.turnCount;
|
|
14865
|
-
}
|
|
14866
|
-
function createIdleCompactionHook(config2, client) {
|
|
14867
|
-
const typedClient = client;
|
|
14868
|
-
return {
|
|
14869
|
-
onEvent: async (event) => {
|
|
14870
|
-
if (!config2.enabled)
|
|
14871
|
-
return;
|
|
14872
|
-
if (event.type !== "session.idle")
|
|
14873
|
-
return;
|
|
14874
|
-
const sessionID = event.properties?.sessionID;
|
|
14875
|
-
if (!sessionID)
|
|
14876
|
-
return;
|
|
14877
|
-
recordSessionIdle(sessionID);
|
|
14878
|
-
},
|
|
14879
|
-
onChatMessage: async (sessionID) => {
|
|
14880
|
-
if (!config2.enabled)
|
|
14881
|
-
return;
|
|
14882
|
-
if (!shouldCompactOnReturn(sessionID))
|
|
14883
|
-
return;
|
|
14884
|
-
enableMicrocompact();
|
|
14885
|
-
try {
|
|
14886
|
-
await typedClient.session.summarize({ path: { id: sessionID } });
|
|
14887
|
-
markCompacted(sessionID);
|
|
14888
|
-
} catch {}
|
|
14889
|
-
}
|
|
14890
|
-
};
|
|
14891
|
-
}
|
|
14892
|
-
|
|
14893
14940
|
// src/hooks/risk-guard.ts
|
|
14894
14941
|
var RISK_RULES = [
|
|
14895
14942
|
{ pattern: /rm\s+-rf\b/i, level: "high", name: "rm-rf" },
|
|
@@ -14899,6 +14946,27 @@ var RISK_RULES = [
|
|
|
14899
14946
|
{ pattern: /truncate\s+table\b/i, level: "high", name: "sql-truncate-table" },
|
|
14900
14947
|
{ pattern: /delete\s+from\b/i, level: "medium", name: "sql-delete" }
|
|
14901
14948
|
];
|
|
14949
|
+
var TASK_LAUNCH_TOOL_NAMES = new Set(["task"]);
|
|
14950
|
+
function isGuardedSubagentName(value) {
|
|
14951
|
+
return typeof value === "string" && value.startsWith("ccx-") && value !== "ccx-coordinator";
|
|
14952
|
+
}
|
|
14953
|
+
function hasExplicitDelegationApproval(value) {
|
|
14954
|
+
if (!isRecord4(value))
|
|
14955
|
+
return false;
|
|
14956
|
+
if (value.subagentDelegation === true || value.subagentDelegation === "approved") {
|
|
14957
|
+
return true;
|
|
14958
|
+
}
|
|
14959
|
+
if (value.allow_subagent_delegation === true || value.allowSubagentDelegation === true) {
|
|
14960
|
+
return true;
|
|
14961
|
+
}
|
|
14962
|
+
if (value.ccx_subagent_delegation === true || value.ccxSubagentDelegation === true) {
|
|
14963
|
+
return true;
|
|
14964
|
+
}
|
|
14965
|
+
const metadata = isRecord4(value.metadata) ? value.metadata : undefined;
|
|
14966
|
+
if (!metadata)
|
|
14967
|
+
return false;
|
|
14968
|
+
return metadata.subagentDelegation === true || metadata.subagentDelegation === "approved" || metadata.allow_subagent_delegation === true || metadata.allowSubagentDelegation === true || metadata.ccx_subagent_delegation === true || metadata.ccxSubagentDelegation === true;
|
|
14969
|
+
}
|
|
14902
14970
|
function isRecord4(value) {
|
|
14903
14971
|
return typeof value === "object" && value !== null;
|
|
14904
14972
|
}
|
|
@@ -14928,14 +14996,35 @@ function createRiskGuard(config2) {
|
|
|
14928
14996
|
if (!isRecord4(output)) {
|
|
14929
14997
|
return;
|
|
14930
14998
|
}
|
|
14999
|
+
const toolName = isRecord4(input) && typeof input.tool === "string" ? input.tool.toLowerCase() : "";
|
|
15000
|
+
if (!config2.subagent_orchestration.allow_subagent_delegation && TASK_LAUNCH_TOOL_NAMES.has(toolName)) {
|
|
15001
|
+
const sessionID = isRecord4(input) && typeof input.sessionID === "string" ? input.sessionID : undefined;
|
|
15002
|
+
const directAgent = isRecord4(input) && typeof input.agent === "string" ? input.agent : undefined;
|
|
15003
|
+
const currentAgent = directAgent ?? (sessionID ? getSessionAgent(sessionID) : undefined);
|
|
15004
|
+
const approved = hasExplicitDelegationApproval(input) || hasExplicitDelegationApproval(output.args);
|
|
15005
|
+
if (isGuardedSubagentName(currentAgent) && !approved) {
|
|
15006
|
+
output.blocked = true;
|
|
15007
|
+
output.warning = "Nested subagent delegation is blocked by runtime policy. Execute directly in the current subagent, or provide explicit delegation approval metadata.";
|
|
15008
|
+
const metadata2 = isRecord4(output.metadata) ? output.metadata : {};
|
|
15009
|
+
metadata2.subagentRecursionGuard = {
|
|
15010
|
+
flagged: true,
|
|
15011
|
+
blocked: true,
|
|
15012
|
+
tool: toolName,
|
|
15013
|
+
agent: currentAgent,
|
|
15014
|
+
reason: "nested-subagent-delegation-blocked"
|
|
15015
|
+
};
|
|
15016
|
+
output.metadata = metadata2;
|
|
15017
|
+
return;
|
|
15018
|
+
}
|
|
15019
|
+
}
|
|
14931
15020
|
const argsText = collectRiskText(output.args).join(`
|
|
14932
15021
|
`);
|
|
14933
15022
|
const matchedRule = RISK_RULES.find((rule) => rule.pattern.test(argsText));
|
|
14934
15023
|
if (!matchedRule) {
|
|
14935
15024
|
return;
|
|
14936
15025
|
}
|
|
14937
|
-
const
|
|
14938
|
-
const warning = matchedRule.level === "high" ? `High-risk ${
|
|
15026
|
+
const riskyToolName = isRecord4(input) && typeof input.tool === "string" ? input.tool : "tool";
|
|
15027
|
+
const warning = matchedRule.level === "high" ? `High-risk ${riskyToolName} invocation detected (${matchedRule.name}). Explicit user confirmation is required before execution.` : `Potentially destructive ${riskyToolName} invocation detected (${matchedRule.name}). Review arguments carefully before continuing.`;
|
|
14939
15028
|
if (matchedRule.level === "high" && config2.risk_guard.enforce_high_risk_confirmation) {
|
|
14940
15029
|
const confirmed = hasExplicitUserConfirmation(input);
|
|
14941
15030
|
if (!confirmed) {
|
|
@@ -27304,13 +27393,18 @@ function tool(input) {
|
|
|
27304
27393
|
}
|
|
27305
27394
|
tool.schema = exports_external2;
|
|
27306
27395
|
// src/plugin/tool-registry.ts
|
|
27307
|
-
var
|
|
27308
|
-
COORDINATOR_AGENT_DEFINITION,
|
|
27396
|
+
var BASE_AGENT_DEFINITIONS = [
|
|
27309
27397
|
EXPLORE_AGENT_DEFINITION,
|
|
27310
27398
|
PLAN_AGENT_DEFINITION,
|
|
27311
27399
|
GENERAL_PURPOSE_AGENT_DEFINITION,
|
|
27312
27400
|
VERIFICATION_AGENT_DEFINITION
|
|
27313
27401
|
];
|
|
27402
|
+
function getEnabledAgentDefinitions(config3) {
|
|
27403
|
+
if (config3.subagent_orchestration.coordinator_enabled) {
|
|
27404
|
+
return [...BASE_AGENT_DEFINITIONS, COORDINATOR_AGENT_DEFINITION];
|
|
27405
|
+
}
|
|
27406
|
+
return BASE_AGENT_DEFINITIONS;
|
|
27407
|
+
}
|
|
27314
27408
|
function createAgentTool(definition) {
|
|
27315
27409
|
return tool({
|
|
27316
27410
|
description: definition.description,
|
|
@@ -27321,6 +27415,7 @@ function createAgentTool(definition) {
|
|
|
27321
27415
|
return [
|
|
27322
27416
|
`Agent: ${definition.name}`,
|
|
27323
27417
|
`Read-only: ${definition.readOnly ? "yes" : "no"}`,
|
|
27418
|
+
`Allowed tools: ${(definition.allowedTools ?? []).join(", ") || "all"}`,
|
|
27324
27419
|
`Disallowed tools: ${(definition.disallowedTools ?? []).join(", ") || "none"}`,
|
|
27325
27420
|
"System prompt:",
|
|
27326
27421
|
definition.getSystemPrompt(),
|
|
@@ -27332,7 +27427,8 @@ function createAgentTool(definition) {
|
|
|
27332
27427
|
}
|
|
27333
27428
|
});
|
|
27334
27429
|
}
|
|
27335
|
-
function createAgentTools() {
|
|
27430
|
+
function createAgentTools(config3) {
|
|
27431
|
+
const agentDefinitions = getEnabledAgentDefinitions(config3);
|
|
27336
27432
|
return Object.fromEntries(agentDefinitions.map((definition) => [definition.name, createAgentTool(definition)]));
|
|
27337
27433
|
}
|
|
27338
27434
|
|
|
@@ -27353,7 +27449,7 @@ function createPluginInterface(args) {
|
|
|
27353
27449
|
const idleCompaction = createIdleCompactionHook(config3, ctx.client);
|
|
27354
27450
|
return {
|
|
27355
27451
|
config: configHook,
|
|
27356
|
-
tool: createAgentTools(),
|
|
27452
|
+
tool: createAgentTools(config3),
|
|
27357
27453
|
"tool.execute.before": riskGuard,
|
|
27358
27454
|
"tool.execute.after": async (input, output) => {
|
|
27359
27455
|
await verificationReminder(input, output);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
|
+
import type { OhMyCCAgentConfig } from "../config/schema";
|
|
2
3
|
export type ToolDefinition = ReturnType<typeof tool>;
|
|
3
|
-
export declare function createAgentTools(): Record<string, ToolDefinition>;
|
|
4
|
+
export declare function createAgentTools(config: OhMyCCAgentConfig): Record<string, ToolDefinition>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ccx-agent/opencode-ccx",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Production-grade prompt engineering for OpenCode — disciplined coding, risk-aware actions, adversarial verification",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|