@ccx-agent/opencode-ccx 0.2.13 → 0.3.2
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 +53 -10
- package/dist/config/schema.d.ts +21 -0
- package/dist/hooks/bash-analyzer.d.ts +13 -0
- package/dist/hooks/ssrf-guard.d.ts +15 -0
- package/dist/hooks/tool-definition.d.ts +2 -1
- package/dist/index.js +11925 -279
- package/dist/prompts/project-instructions.d.ts +11 -0
- package/dist/prompts/tool-hints.d.ts +9 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -151,15 +151,15 @@ ccx uses every major hook point in the OpenCode plugin API to dynamically shape
|
|
|
151
151
|
|------|-------------|
|
|
152
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
|
-
| **experimental.chat.system.transform** | Dynamically injects project instructions (CLAUDE.md), session context (edited files list), and verification reminders into the system prompt |
|
|
155
|
-
| **tool.definition** |
|
|
154
|
+
| **experimental.chat.system.transform** | Dynamically injects project instructions (CLAUDE.md tree, global CCX.md), session context (edited files list), and verification reminders into the system prompt |
|
|
155
|
+
| **tool.definition** | Injects detailed per-tool usage notes, preferred alternatives, parallelism guidance, and safety rules for `bash` / `read` / `edit` / `write` / `glob` / `grep` / `webfetch` / `task` / `todowrite` |
|
|
156
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** |
|
|
162
|
+
| **tool.execute.before** | Three stages: (1) Context-Bundle injects cwd / git snapshot / recently changed files into `task` tool args so subagents share a baseline; (2) SSRF Guard pre-checks `webfetch` URLs against private, link-local, and cloud-metadata ranges (incl. IPv4-mapped IPv6) with async DNS resolution; (3) Risk Guard runs AST-level bash analysis to flag `rm -rf`, critical-path deletion, `find -delete`, pipe-to-shell, `git push --force`, `kubectl delete`, `terraform apply -auto-approve`, SQL `DROP`/`DELETE`-without-WHERE, and other destructive patterns — including wrapper unwrap (`sudo`/`xargs`/`env`) |
|
|
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
|
|
|
@@ -192,8 +192,10 @@ ccx was built by studying Claude Code's prompt architecture and adapting its cor
|
|
|
192
192
|
| Coordinator default | Disabled by default, opt-in via config |
|
|
193
193
|
| Verification contract | Configurable. Strict contract is opt-in (`verification.enforce_contract=true`) |
|
|
194
194
|
| VERDICT protocol (PASS/FAIL/PARTIAL) | Identical format and adversarial strategies |
|
|
195
|
-
| Project instructions (CLAUDE.md) |
|
|
196
|
-
|
|
|
195
|
+
| Project instructions (CLAUDE.md) | Recursive upward discovery from cwd, merging every `CLAUDE.md` / `.claude/instructions.md` / `AGENTS.md` along the path plus a global `~/.config/opencode/ccx/CCX.md` (root-first ordering, budget-capped) |
|
|
196
|
+
| AST-level bash command analysis | Full AST inspection via `bash-parser` with wrapper unwrap (`sudo` / `xargs` / `env`), critical-path detection, `find -delete` / pipe-to-shell / eval-curl / `dd` to block device / `mkfs` / SQL DROP/DELETE-without-WHERE / `git push --force` / `kubectl delete` / `terraform apply -auto-approve` rules, plus user-level allow/block lists |
|
|
197
|
+
| SSRF defense for fetch tools | Pre-flight guard blocking private (10/8, 172.16/12, 192.168/16), CGNAT (100.64/10), link-local (169.254/16), IPv6 ULA (fc00::/7), link-local (fe80::/10), IPv4-mapped IPv6, and non-http(s) schemes; async DNS resolution with 2s timeout |
|
|
198
|
+
| Tool safety hints | `tool.definition` hook injects detailed per-tool usage notes, parallelism rules, git safety protocol, and preferred-alternative guidance for 9 tools (`bash` / `read` / `edit` / `write` / `glob` / `grep` / `webfetch` / `task` / `todowrite`) |
|
|
197
199
|
| Tool-output microcompact | Older `read/grep/glob/bash/webfetch` results are compacted automatically while preserving recent outputs |
|
|
198
200
|
| Context compaction preservation | Custom compaction prompt via `experimental.session.compacting` |
|
|
199
201
|
| Trust boundary / prompt injection defense | Explicit section in system prompt |
|
|
@@ -207,7 +209,6 @@ ccx was built by studying Claude Code's prompt architecture and adapting its cor
|
|
|
207
209
|
| Fork mode (shared prompt cache across subagents) | Engine-level session management |
|
|
208
210
|
| AI-powered safety classifier (YOLO mode) | Would require LLM call in hook, adds latency |
|
|
209
211
|
| Plan mode with user approval gate | Requires TUI integration (experimental) |
|
|
210
|
-
| AST-level bash command analysis | Possible but high complexity cost |
|
|
211
212
|
|
|
212
213
|
### Workflow parity summary (current defaults)
|
|
213
214
|
|
|
@@ -221,6 +222,7 @@ With the default ccx config shown below, workflow behavior is aligned to Claude
|
|
|
221
222
|
- when enabled, coordinator runs orchestration-only with a constrained tool surface (`task` + `question`)
|
|
222
223
|
- 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
224
|
- 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
|
|
225
|
+
- bash AST analysis, SSRF pre-flight check, recursive CLAUDE.md discovery, and detailed per-tool hints are on by default and can be toggled per-field in `ccx.json`
|
|
224
226
|
|
|
225
227
|
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
228
|
|
|
@@ -311,7 +313,28 @@ Example:
|
|
|
311
313
|
"spot_check_min_commands": 2
|
|
312
314
|
},
|
|
313
315
|
"risk_guard": {
|
|
314
|
-
"enforce_high_risk_confirmation": true
|
|
316
|
+
"enforce_high_risk_confirmation": true,
|
|
317
|
+
"ast_analysis": true,
|
|
318
|
+
"extra_blocked_commands": [],
|
|
319
|
+
"extra_allowed_commands": []
|
|
320
|
+
},
|
|
321
|
+
"ssrf_guard": {
|
|
322
|
+
"enabled": true,
|
|
323
|
+
"allow_loopback": true,
|
|
324
|
+
"extra_blocked_hosts": [],
|
|
325
|
+
"extra_allowed_hosts": []
|
|
326
|
+
},
|
|
327
|
+
"project_instructions": {
|
|
328
|
+
"enabled": true,
|
|
329
|
+
"recursive": true,
|
|
330
|
+
"global_file": true,
|
|
331
|
+
"max_depth": 8,
|
|
332
|
+
"max_total_bytes": 64000,
|
|
333
|
+
"filenames": ["CLAUDE.md", ".claude/instructions.md", "AGENTS.md"]
|
|
334
|
+
},
|
|
335
|
+
"tool_hints": {
|
|
336
|
+
"enabled": true,
|
|
337
|
+
"disabled_tools": []
|
|
315
338
|
},
|
|
316
339
|
"subagent_orchestration": {
|
|
317
340
|
"explore_min_queries": 3,
|
|
@@ -346,6 +369,21 @@ Example:
|
|
|
346
369
|
| `verification.min_file_edits` | `number` | `3` | File edit threshold before nudge |
|
|
347
370
|
| `verification.spot_check_min_commands` | `number` | `2` | Minimum verifier commands to re-run after PASS spot-check |
|
|
348
371
|
| `risk_guard.enforce_high_risk_confirmation` | `boolean` | `true` | Block high-risk commands unless explicit user confirmation is present |
|
|
372
|
+
| `risk_guard.ast_analysis` | `boolean` | `true` | Run AST-level bash inspection (wrapper unwrap, flag semantics, critical-path detection). Disable to fall back to a narrower inspection of bash-only tool inputs |
|
|
373
|
+
| `risk_guard.extra_blocked_commands` | `string[]` | `[]` | Additional command names always flagged as high-risk (e.g., `["kubectl", "helm"]`) |
|
|
374
|
+
| `risk_guard.extra_allowed_commands` | `string[]` | `[]` | Command names to skip entirely (useful for per-project overrides) |
|
|
375
|
+
| `ssrf_guard.enabled` | `boolean` | `true` | Pre-check `webfetch` URLs and block private/link-local/cloud-metadata targets |
|
|
376
|
+
| `ssrf_guard.allow_loopback` | `boolean` | `true` | Allow `127.0.0.1` / `::1` / `localhost` for local dev servers |
|
|
377
|
+
| `ssrf_guard.extra_blocked_hosts` | `string[]` | `[]` | Hostnames (or IP literals) to always block |
|
|
378
|
+
| `ssrf_guard.extra_allowed_hosts` | `string[]` | `[]` | Hostnames (or IP literals) to allow even if they land in a private range — useful for internal infrastructure the agent legitimately needs to reach |
|
|
379
|
+
| `project_instructions.enabled` | `boolean` | `true` | Load project instruction files (CLAUDE.md / AGENTS.md / etc.) into the system prompt |
|
|
380
|
+
| `project_instructions.recursive` | `boolean` | `true` | Walk upwards from the working directory and merge every instruction file along the way. When `false`, only the current directory is inspected |
|
|
381
|
+
| `project_instructions.global_file` | `boolean` | `true` | Also load `~/.config/opencode/ccx/CCX.md` (or `instructions.md` / `CLAUDE.md` in the same directory) as a user-level preference file |
|
|
382
|
+
| `project_instructions.max_depth` | `number` | `8` | Maximum number of parent directories to scan during recursive discovery |
|
|
383
|
+
| `project_instructions.max_total_bytes` | `number` | `64000` | Total byte budget for the assembled instruction section. Later (more specific) files are prioritized; the tail is truncated when the budget is exceeded |
|
|
384
|
+
| `project_instructions.filenames` | `string[]` | `["CLAUDE.md", ".claude/instructions.md", "AGENTS.md"]` | Filenames to look for at each directory level |
|
|
385
|
+
| `tool_hints.enabled` | `boolean` | `true` | Append detailed per-tool usage notes to tool descriptions at startup |
|
|
386
|
+
| `tool_hints.disabled_tools` | `string[]` | `[]` | Tool names that should receive no hint (e.g., `["bash"]` if you prefer the raw description) |
|
|
349
387
|
| `subagent_orchestration.explore_min_queries` | `number` | `3` | Escalate to `ccx-explore` when directed lookup likely needs more than this query count |
|
|
350
388
|
| `subagent_orchestration.coordinator_enabled` | `boolean` | `false` | Register and advertise `ccx-coordinator` subagent |
|
|
351
389
|
| `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 |
|
|
@@ -368,11 +406,15 @@ Example:
|
|
|
368
406
|
ccx/
|
|
369
407
|
├── src/
|
|
370
408
|
│ ├── index.ts # Plugin entry — composes everything
|
|
371
|
-
│ ├── prompts/ #
|
|
409
|
+
│ ├── prompts/ # System prompt sections + composer
|
|
410
|
+
│ │ ├── tool-hints.ts # Detailed per-tool usage guidance
|
|
411
|
+
│ │ └── project-instructions.ts # Recursive CLAUDE.md + global CCX.md loader
|
|
372
412
|
│ ├── agents/ # 5 subagent definitions with tailored prompts
|
|
373
|
-
│ ├── hooks/ #
|
|
413
|
+
│ ├── hooks/ # Runtime hooks
|
|
374
414
|
│ │ ├── config-handler.ts # Agent registration
|
|
375
|
-
│ │ ├──
|
|
415
|
+
│ │ ├── bash-analyzer.ts # AST-level bash risk rules
|
|
416
|
+
│ │ ├── risk-guard.ts # Destructive command detection (AST-powered)
|
|
417
|
+
│ │ ├── ssrf-guard.ts # Pre-flight URL/host SSRF check for webfetch
|
|
376
418
|
│ │ ├── context-bundle.ts # Inject cwd/git/recent-files into task tool args
|
|
377
419
|
│ │ ├── session-workflows.ts # /ccx-fork, /ccx-bg, /ccx-fullctx, /ccx-bg-status commands
|
|
378
420
|
│ │ ├── bg-tasks.ts # Background task lifecycle registry
|
|
@@ -385,6 +427,7 @@ ccx/
|
|
|
385
427
|
│ │ ├── tool-definition.ts # Tool description enhancement
|
|
386
428
|
│ │ └── message-transform.ts # Message history optimization
|
|
387
429
|
│ ├── config/ # Zod schema + JSONC config loader
|
|
430
|
+
│ ├── types/ # Local .d.ts for untyped dependencies (bash-parser)
|
|
388
431
|
│ └── plugin/ # OpenCode plugin interface + agent tool registry
|
|
389
432
|
├── .github/workflows/
|
|
390
433
|
│ └── publish.yml # Auto-publish to npm on tag push
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -12,6 +12,27 @@ export declare const configSchema: z.ZodObject<{
|
|
|
12
12
|
}, z.core.$strip>>;
|
|
13
13
|
risk_guard: z.ZodDefault<z.ZodObject<{
|
|
14
14
|
enforce_high_risk_confirmation: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
ast_analysis: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
extra_blocked_commands: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
17
|
+
extra_allowed_commands: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
ssrf_guard: z.ZodDefault<z.ZodObject<{
|
|
20
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
21
|
+
allow_loopback: z.ZodDefault<z.ZodBoolean>;
|
|
22
|
+
extra_blocked_hosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
23
|
+
extra_allowed_hosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
project_instructions: z.ZodDefault<z.ZodObject<{
|
|
26
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
27
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
28
|
+
global_file: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
+
max_depth: z.ZodDefault<z.ZodInt>;
|
|
30
|
+
max_total_bytes: z.ZodDefault<z.ZodInt>;
|
|
31
|
+
filenames: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
32
|
+
}, z.core.$strip>>;
|
|
33
|
+
tool_hints: z.ZodDefault<z.ZodObject<{
|
|
34
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
35
|
+
disabled_tools: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
15
36
|
}, z.core.$strip>>;
|
|
16
37
|
subagent_orchestration: z.ZodDefault<z.ZodObject<{
|
|
17
38
|
explore_min_queries: z.ZodDefault<z.ZodInt>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type RiskLevel = "high" | "medium" | "low";
|
|
2
|
+
export type RiskFinding = {
|
|
3
|
+
level: RiskLevel;
|
|
4
|
+
name: string;
|
|
5
|
+
message: string;
|
|
6
|
+
command: string;
|
|
7
|
+
};
|
|
8
|
+
export type AnalyzerOptions = {
|
|
9
|
+
extraBlockedCommands?: string[];
|
|
10
|
+
extraAllowedCommands?: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare function analyzeBashCommand(source: string, options?: AnalyzerOptions): RiskFinding[];
|
|
13
|
+
export declare function pickHighestFinding(findings: RiskFinding[]): RiskFinding | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OhMyCCAgentConfig } from "../config/schema";
|
|
2
|
+
export declare function isBlockedAddress(address: string, allowLoopback: boolean): boolean;
|
|
3
|
+
type UrlInspection = {
|
|
4
|
+
url: string;
|
|
5
|
+
reason: string;
|
|
6
|
+
blocked: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type SsrfGuardOptions = {
|
|
9
|
+
allowLoopback: boolean;
|
|
10
|
+
extraBlockedHosts: Set<string>;
|
|
11
|
+
extraAllowedHosts: Set<string>;
|
|
12
|
+
};
|
|
13
|
+
export declare function inspectUrl(url: string, options: SsrfGuardOptions): Promise<UrlInspection>;
|
|
14
|
+
export declare function createSsrfGuard(config: OhMyCCAgentConfig): (input: unknown, output: unknown) => Promise<void>;
|
|
15
|
+
export {};
|