@ccx-agent/opencode-ccx 0.2.11 → 0.2.13
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 +85 -21
- package/dist/agents/types.d.ts +1 -0
- package/dist/config/schema.d.ts +17 -0
- package/dist/hooks/bg-tasks.d.ts +29 -0
- package/dist/hooks/chat-message.d.ts +1 -0
- package/dist/hooks/context-bundle.d.ts +5 -0
- package/dist/hooks/message-transform.d.ts +0 -1
- package/dist/hooks/session-workflows.d.ts +25 -0
- package/dist/index.js +822 -133
- 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,17 +124,17 @@ 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
|
+
### 12 Runtime Hooks
|
|
138
138
|
|
|
139
139
|
ccx uses every major hook point in the OpenCode plugin API to dynamically shape agent behavior:
|
|
140
140
|
|
|
@@ -142,27 +142,40 @@ 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)
|
|
149
149
|
|
|
150
150
|
| Hook | What it does |
|
|
151
151
|
|------|-------------|
|
|
152
|
-
| **chat.message** | Tracks file edits across the session for verification threshold detection |
|
|
152
|
+
| **chat.message** | Tracks file edits across the session for verification threshold detection, and routes inline session-workflow commands (`/ccx-fork`, `/ccx-bg`, `/ccx-fullctx`, `/ccx-bg-status`) |
|
|
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
|
|
|
160
160
|
| Hook | What it does |
|
|
161
161
|
|------|-------------|
|
|
162
|
-
| **tool.execute.before** | Risk Guard
|
|
162
|
+
| **tool.execute.before** | Two stages: (1) Context-Bundle injects cwd / git snapshot / recently changed files into `task` tool args so subagents share a baseline; (2) Risk Guard flags `rm -rf`, `git push --force`, `DROP TABLE`, and other destructive patterns |
|
|
163
163
|
| **tool.execute.after** | Tracks file edits, feeds the dynamic verification reminder system |
|
|
164
164
|
| **experimental.session.compacting** | Customizes context compaction to preserve: original task, implementation plan, edited files, verification status, architectural decisions |
|
|
165
165
|
|
|
166
|
+
#### Session Workflow Commands
|
|
167
|
+
|
|
168
|
+
ccx exposes inline commands inside any chat message. They drive the underlying OpenCode session APIs directly so you can branch, dispatch, and replay work without waiting for the main agent to finish its turn:
|
|
169
|
+
|
|
170
|
+
| Command | Backed by | Purpose |
|
|
171
|
+
|---------|-----------|---------|
|
|
172
|
+
| `/ccx-fork [messageID]` | `POST /session/{id}/fork` | Fork the current session at the latest message (or at an explicit `messageID`) for what-if branching |
|
|
173
|
+
| `/ccx-bg [agent] <prompt>` | `POST /session/{id}/prompt_async` | Queue a background prompt against the current session, optionally targeting a specific agent |
|
|
174
|
+
| `/ccx-fullctx <agent> <prompt>` | `POST /session/{id}/fork` + `POST /session/{id}/prompt_async` | Create a fork-child session that inherits full parent context, then dispatch the subtask asynchronously to the named agent |
|
|
175
|
+
| `/ccx-bg-status [taskID]` | in-memory task registry + `GET /session/{id}/message` | Show recent background tasks, or inspect one task and refresh its running/completed/failed state |
|
|
176
|
+
|
|
177
|
+
All commands are opt-in via `subagent_orchestration.session_workflows.enabled` and the literals are configurable.
|
|
178
|
+
|
|
166
179
|
---
|
|
167
180
|
|
|
168
181
|
## Claude Code Alignment
|
|
@@ -174,11 +187,14 @@ ccx was built by studying Claude Code's prompt architecture and adapting its cor
|
|
|
174
187
|
| Claude Code Feature | ccx Implementation |
|
|
175
188
|
|--------------------|--------------------|
|
|
176
189
|
| 8-section system prompt | 8 composable prompt sections, near-identical content |
|
|
177
|
-
|
|
|
178
|
-
|
|
|
190
|
+
| Agent orchestration guidance | Same guidance style: use specialized subagents when appropriate, avoid overuse, avoid duplicate delegated work |
|
|
191
|
+
| Explore escalation threshold | `explore_min_queries=3` default (matches Claude CLI external default) |
|
|
192
|
+
| Coordinator default | Disabled by default, opt-in via config |
|
|
193
|
+
| Verification contract | Configurable. Strict contract is opt-in (`verification.enforce_contract=true`) |
|
|
179
194
|
| VERDICT protocol (PASS/FAIL/PARTIAL) | Identical format and adversarial strategies |
|
|
180
195
|
| Project instructions (CLAUDE.md) | Auto-loaded from CLAUDE.md / .claude/instructions.md / AGENTS.md |
|
|
181
196
|
| Tool safety hints | `tool.definition` hook appends rules to bash/edit/write descriptions |
|
|
197
|
+
| Tool-output microcompact | Older `read/grep/glob/bash/webfetch` results are compacted automatically while preserving recent outputs |
|
|
182
198
|
| Context compaction preservation | Custom compaction prompt via `experimental.session.compacting` |
|
|
183
199
|
| Trust boundary / prompt injection defense | Explicit section in system prompt |
|
|
184
200
|
|
|
@@ -193,6 +209,21 @@ ccx was built by studying Claude Code's prompt architecture and adapting its cor
|
|
|
193
209
|
| Plan mode with user approval gate | Requires TUI integration (experimental) |
|
|
194
210
|
| AST-level bash command analysis | Possible but high complexity cost |
|
|
195
211
|
|
|
212
|
+
### Workflow parity summary (current defaults)
|
|
213
|
+
|
|
214
|
+
With the default ccx config shown below, workflow behavior is aligned to Claude CLI's external/default orchestration style:
|
|
215
|
+
|
|
216
|
+
- subagents are used when needed, not by default for every task
|
|
217
|
+
- broad exploration escalates after directed search becomes insufficient (`explore_min_queries=3`)
|
|
218
|
+
- coordinator-style multi-hop orchestration is off by default
|
|
219
|
+
- recursive subagent delegation is discouraged by default
|
|
220
|
+
- strict mandatory verification contract is off by default (opt-in)
|
|
221
|
+
- when enabled, coordinator runs orchestration-only with a constrained tool surface (`task` + `question`)
|
|
222
|
+
- every dispatched subagent receives an automatically injected context bundle (cwd / git snapshot / recently changed files) so it starts from the same baseline as the parent
|
|
223
|
+
- inline `/ccx-fork`, `/ccx-bg`, `/ccx-fullctx`, and `/ccx-bg-status` commands let users branch sessions, queue background prompts, dispatch full-context fork subtasks, and inspect async task state
|
|
224
|
+
|
|
225
|
+
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.
|
|
226
|
+
|
|
196
227
|
---
|
|
197
228
|
|
|
198
229
|
## The Verification Agent
|
|
@@ -274,7 +305,8 @@ Example:
|
|
|
274
305
|
"disabled_hooks": [],
|
|
275
306
|
"output_style": null,
|
|
276
307
|
"verification": {
|
|
277
|
-
"auto_remind":
|
|
308
|
+
"auto_remind": false,
|
|
309
|
+
"enforce_contract": false,
|
|
278
310
|
"min_file_edits": 3,
|
|
279
311
|
"spot_check_min_commands": 2
|
|
280
312
|
},
|
|
@@ -282,7 +314,23 @@ Example:
|
|
|
282
314
|
"enforce_high_risk_confirmation": true
|
|
283
315
|
},
|
|
284
316
|
"subagent_orchestration": {
|
|
285
|
-
"explore_min_queries":
|
|
317
|
+
"explore_min_queries": 3,
|
|
318
|
+
"coordinator_enabled": false,
|
|
319
|
+
"allow_subagent_delegation": false,
|
|
320
|
+
"context_bundle": {
|
|
321
|
+
"enabled": true,
|
|
322
|
+
"include_cwd": true,
|
|
323
|
+
"include_git": true,
|
|
324
|
+
"include_recent_files": true,
|
|
325
|
+
"max_recent_files": 8
|
|
326
|
+
},
|
|
327
|
+
"session_workflows": {
|
|
328
|
+
"enabled": true,
|
|
329
|
+
"fork_command": "/ccx-fork",
|
|
330
|
+
"background_command": "/ccx-bg",
|
|
331
|
+
"full_context_command": "/ccx-fullctx",
|
|
332
|
+
"status_command": "/ccx-bg-status"
|
|
333
|
+
}
|
|
286
334
|
}
|
|
287
335
|
}
|
|
288
336
|
```
|
|
@@ -293,11 +341,24 @@ Example:
|
|
|
293
341
|
| `disabled_sections` | `string[]` | `[]` | Prompt sections to skip (e.g., `["tone-style"]`) |
|
|
294
342
|
| `disabled_hooks` | `string[]` | `[]` | Hooks to disable (e.g., `["risk-guard"]`) |
|
|
295
343
|
| `output_style` | `string \| null` | `null` | Custom output style name |
|
|
296
|
-
| `verification.auto_remind` | `boolean` | `
|
|
344
|
+
| `verification.auto_remind` | `boolean` | `false` | Auto-nudge verification after edits |
|
|
345
|
+
| `verification.enforce_contract` | `boolean` | `false` | Enable strict verification contract wording and reminder logic |
|
|
297
346
|
| `verification.min_file_edits` | `number` | `3` | File edit threshold before nudge |
|
|
298
347
|
| `verification.spot_check_min_commands` | `number` | `2` | Minimum verifier commands to re-run after PASS spot-check |
|
|
299
348
|
| `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` | `
|
|
349
|
+
| `subagent_orchestration.explore_min_queries` | `number` | `3` | Escalate to `ccx-explore` when directed lookup likely needs more than this query count |
|
|
350
|
+
| `subagent_orchestration.coordinator_enabled` | `boolean` | `false` | Register and advertise `ccx-coordinator` subagent |
|
|
351
|
+
| `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 |
|
|
352
|
+
| `subagent_orchestration.context_bundle.enabled` | `boolean` | `true` | Inject a shared context bundle (cwd, git snapshot, recently changed files) into `task` tool args before execution |
|
|
353
|
+
| `subagent_orchestration.context_bundle.include_cwd` | `boolean` | `true` | Include the working directory in the injected bundle |
|
|
354
|
+
| `subagent_orchestration.context_bundle.include_git` | `boolean` | `true` | Include the per-session git snapshot in the injected bundle |
|
|
355
|
+
| `subagent_orchestration.context_bundle.include_recent_files` | `boolean` | `true` | Include `git ls-files --modified --others` output in the injected bundle |
|
|
356
|
+
| `subagent_orchestration.context_bundle.max_recent_files` | `number` | `8` | Cap the number of recent files included in the bundle |
|
|
357
|
+
| `subagent_orchestration.session_workflows.enabled` | `boolean` | `true` | Enable inline session workflow commands (fork, background, full-context) in user messages |
|
|
358
|
+
| `subagent_orchestration.session_workflows.fork_command` | `string` | `/ccx-fork` | Command literal that triggers `session.fork`. Optional argument: explicit `messageID` to fork at |
|
|
359
|
+
| `subagent_orchestration.session_workflows.background_command` | `string` | `/ccx-bg` | Command literal that triggers `session.promptAsync`. Usage: `/ccx-bg [agent] <prompt>` |
|
|
360
|
+
| `subagent_orchestration.session_workflows.full_context_command` | `string` | `/ccx-fullctx` | Command literal that forks the session and dispatches a full-context subtask via `session.fork` + `session.promptAsync`. Usage: `/ccx-fullctx <agent> <prompt>` |
|
|
361
|
+
| `subagent_orchestration.session_workflows.status_command` | `string` | `/ccx-bg-status` | Command literal that lists background tasks or shows status for one task ID |
|
|
301
362
|
|
|
302
363
|
---
|
|
303
364
|
|
|
@@ -309,9 +370,12 @@ ccx/
|
|
|
309
370
|
│ ├── index.ts # Plugin entry — composes everything
|
|
310
371
|
│ ├── prompts/ # 8 system prompt sections + composer
|
|
311
372
|
│ ├── agents/ # 5 subagent definitions with tailored prompts
|
|
312
|
-
│ ├── hooks/ #
|
|
373
|
+
│ ├── hooks/ # 12 runtime hooks
|
|
313
374
|
│ │ ├── config-handler.ts # Agent registration
|
|
314
375
|
│ │ ├── risk-guard.ts # Destructive command detection
|
|
376
|
+
│ │ ├── context-bundle.ts # Inject cwd/git/recent-files into task tool args
|
|
377
|
+
│ │ ├── session-workflows.ts # /ccx-fork, /ccx-bg, /ccx-fullctx, /ccx-bg-status commands
|
|
378
|
+
│ │ ├── bg-tasks.ts # Background task lifecycle registry
|
|
315
379
|
│ │ ├── verification-reminder.ts # Edit tracking + nudge
|
|
316
380
|
│ │ ├── environment-context.ts # Session environment capture
|
|
317
381
|
│ │ ├── dynamic-system-prompt.ts # Per-turn system prompt injection
|
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,22 @@ 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>;
|
|
20
|
+
context_bundle: z.ZodDefault<z.ZodObject<{
|
|
21
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
include_cwd: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
+
include_git: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
+
include_recent_files: z.ZodDefault<z.ZodBoolean>;
|
|
25
|
+
max_recent_files: z.ZodDefault<z.ZodInt>;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
session_workflows: z.ZodDefault<z.ZodObject<{
|
|
28
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
+
fork_command: z.ZodDefault<z.ZodString>;
|
|
30
|
+
background_command: z.ZodDefault<z.ZodString>;
|
|
31
|
+
full_context_command: z.ZodDefault<z.ZodString>;
|
|
32
|
+
status_command: z.ZodDefault<z.ZodString>;
|
|
33
|
+
}, z.core.$strip>>;
|
|
17
34
|
}, z.core.$strip>>;
|
|
18
35
|
}, z.core.$strip>;
|
|
19
36
|
export type OhMyCCAgentConfig = z.infer<typeof configSchema>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type BgTaskStatus = "queued" | "running" | "completed" | "failed";
|
|
2
|
+
export type BgTaskRecord = {
|
|
3
|
+
id: string;
|
|
4
|
+
parentSessionID: string;
|
|
5
|
+
targetSessionID: string;
|
|
6
|
+
requestMessageID: string;
|
|
7
|
+
agent?: string;
|
|
8
|
+
prompt: string;
|
|
9
|
+
status: BgTaskStatus;
|
|
10
|
+
createdAt: number;
|
|
11
|
+
startedAt?: number;
|
|
12
|
+
finishedAt?: number;
|
|
13
|
+
error?: string;
|
|
14
|
+
fullContext: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare function createBgTask(args: {
|
|
17
|
+
parentSessionID: string;
|
|
18
|
+
targetSessionID: string;
|
|
19
|
+
requestMessageID: string;
|
|
20
|
+
agent?: string;
|
|
21
|
+
prompt: string;
|
|
22
|
+
fullContext: boolean;
|
|
23
|
+
}): BgTaskRecord;
|
|
24
|
+
export declare function markBgTaskRunning(id: string): void;
|
|
25
|
+
export declare function markBgTaskFailed(id: string, error: string): void;
|
|
26
|
+
export declare function markBgTaskCompleted(id: string): void;
|
|
27
|
+
export declare function getBgTask(id: string): BgTaskRecord | undefined;
|
|
28
|
+
export declare function listBgTasksForSession(sessionID: string): BgTaskRecord[];
|
|
29
|
+
export declare function formatBgTaskLine(task: BgTaskRecord): string;
|
|
@@ -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>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OhMyCCAgentConfig } from "../config/schema";
|
|
2
|
+
type ChatMessageInput = {
|
|
3
|
+
sessionID: string;
|
|
4
|
+
agent?: string;
|
|
5
|
+
model?: {
|
|
6
|
+
providerID: string;
|
|
7
|
+
modelID: string;
|
|
8
|
+
};
|
|
9
|
+
messageID?: string;
|
|
10
|
+
};
|
|
11
|
+
type ChatMessageOutput = {
|
|
12
|
+
message: Record<string, unknown>;
|
|
13
|
+
parts: Array<{
|
|
14
|
+
type: string;
|
|
15
|
+
text?: string;
|
|
16
|
+
[key: string]: unknown;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
export declare const FORK_CHILD_MARKER_BEGIN = "<ccx-fork-child>";
|
|
20
|
+
export declare const FORK_CHILD_MARKER_END = "</ccx-fork-child>";
|
|
21
|
+
export declare function createSessionWorkflowsHook(args: {
|
|
22
|
+
config: OhMyCCAgentConfig;
|
|
23
|
+
client: unknown;
|
|
24
|
+
}): (input: ChatMessageInput, output: ChatMessageOutput) => Promise<void>;
|
|
25
|
+
export {};
|