@ccx-agent/opencode-ccx 0.2.9 → 0.2.11
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 +26 -2
- package/dist/config/schema.d.ts +7 -0
- package/dist/hooks/risk-guard.d.ts +2 -1
- package/dist/index.js +54 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -251,7 +251,21 @@ or `FAIL` with reproduction steps, or `PARTIAL` with what couldn't be verified a
|
|
|
251
251
|
|
|
252
252
|
## Configuration
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
Config is loaded in this order (first hit wins):
|
|
255
|
+
|
|
256
|
+
1. `.opencode/ccx.json` (project-level)
|
|
257
|
+
2. `~/.config/opencode/ccx.json` (global)
|
|
258
|
+
3. built-in defaults
|
|
259
|
+
|
|
260
|
+
Notes:
|
|
261
|
+
- The config loader supports JSON with comments (`//` and `/* ... */`).
|
|
262
|
+
- Project config overrides global config (it does not deep-merge both files).
|
|
263
|
+
|
|
264
|
+
Create one of the following files:
|
|
265
|
+
- `.opencode/ccx.json` (project-level)
|
|
266
|
+
- `~/.config/opencode/ccx.json` (global)
|
|
267
|
+
|
|
268
|
+
Example:
|
|
255
269
|
|
|
256
270
|
```json
|
|
257
271
|
{
|
|
@@ -261,7 +275,14 @@ Create `~/.config/opencode/ccx.json` (global) or `.opencode/ccx.json` (project-l
|
|
|
261
275
|
"output_style": null,
|
|
262
276
|
"verification": {
|
|
263
277
|
"auto_remind": true,
|
|
264
|
-
"min_file_edits": 3
|
|
278
|
+
"min_file_edits": 3,
|
|
279
|
+
"spot_check_min_commands": 2
|
|
280
|
+
},
|
|
281
|
+
"risk_guard": {
|
|
282
|
+
"enforce_high_risk_confirmation": true
|
|
283
|
+
},
|
|
284
|
+
"subagent_orchestration": {
|
|
285
|
+
"explore_min_queries": 5
|
|
265
286
|
}
|
|
266
287
|
}
|
|
267
288
|
```
|
|
@@ -274,6 +295,9 @@ Create `~/.config/opencode/ccx.json` (global) or `.opencode/ccx.json` (project-l
|
|
|
274
295
|
| `output_style` | `string \| null` | `null` | Custom output style name |
|
|
275
296
|
| `verification.auto_remind` | `boolean` | `true` | Auto-nudge verification after edits |
|
|
276
297
|
| `verification.min_file_edits` | `number` | `3` | File edit threshold before nudge |
|
|
298
|
+
| `verification.spot_check_min_commands` | `number` | `2` | Minimum verifier commands to re-run after PASS spot-check |
|
|
299
|
+
| `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` | `5` | Escalate to `ccx-explore` when directed lookup likely needs more than this query count |
|
|
277
301
|
|
|
278
302
|
---
|
|
279
303
|
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export declare const configSchema: z.ZodObject<{
|
|
|
7
7
|
verification: z.ZodDefault<z.ZodObject<{
|
|
8
8
|
auto_remind: z.ZodDefault<z.ZodBoolean>;
|
|
9
9
|
min_file_edits: z.ZodDefault<z.ZodInt>;
|
|
10
|
+
spot_check_min_commands: z.ZodDefault<z.ZodInt>;
|
|
11
|
+
}, z.core.$strip>>;
|
|
12
|
+
risk_guard: z.ZodDefault<z.ZodObject<{
|
|
13
|
+
enforce_high_risk_confirmation: z.ZodDefault<z.ZodBoolean>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
subagent_orchestration: z.ZodDefault<z.ZodObject<{
|
|
16
|
+
explore_min_queries: z.ZodDefault<z.ZodInt>;
|
|
10
17
|
}, z.core.$strip>>;
|
|
11
18
|
}, z.core.$strip>;
|
|
12
19
|
export type OhMyCCAgentConfig = z.infer<typeof configSchema>;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { OhMyCCAgentConfig } from "../config/schema";
|
|
2
|
+
export declare function createRiskGuard(config: OhMyCCAgentConfig): (input: unknown, output: unknown) => Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -13554,7 +13554,14 @@ config(en_default());
|
|
|
13554
13554
|
// src/config/schema.ts
|
|
13555
13555
|
var verificationSchema = exports_external.object({
|
|
13556
13556
|
auto_remind: exports_external.boolean().default(true),
|
|
13557
|
-
min_file_edits: exports_external.int().nonnegative().default(3)
|
|
13557
|
+
min_file_edits: exports_external.int().nonnegative().default(3),
|
|
13558
|
+
spot_check_min_commands: exports_external.int().positive().default(2)
|
|
13559
|
+
});
|
|
13560
|
+
var riskGuardSchema = exports_external.object({
|
|
13561
|
+
enforce_high_risk_confirmation: exports_external.boolean().default(true)
|
|
13562
|
+
});
|
|
13563
|
+
var subagentOrchestrationSchema = exports_external.object({
|
|
13564
|
+
explore_min_queries: exports_external.int().positive().default(5)
|
|
13558
13565
|
});
|
|
13559
13566
|
var configSchema = exports_external.object({
|
|
13560
13567
|
enabled: exports_external.boolean().default(true),
|
|
@@ -13563,7 +13570,14 @@ var configSchema = exports_external.object({
|
|
|
13563
13570
|
output_style: exports_external.string().min(1).nullable().default(null),
|
|
13564
13571
|
verification: verificationSchema.default({
|
|
13565
13572
|
auto_remind: true,
|
|
13566
|
-
min_file_edits: 3
|
|
13573
|
+
min_file_edits: 3,
|
|
13574
|
+
spot_check_min_commands: 2
|
|
13575
|
+
}),
|
|
13576
|
+
risk_guard: riskGuardSchema.default({
|
|
13577
|
+
enforce_high_risk_confirmation: true
|
|
13578
|
+
}),
|
|
13579
|
+
subagent_orchestration: subagentOrchestrationSchema.default({
|
|
13580
|
+
explore_min_queries: 5
|
|
13567
13581
|
})
|
|
13568
13582
|
});
|
|
13569
13583
|
|
|
@@ -14372,7 +14386,9 @@ function buildToolRestrictions(def) {
|
|
|
14372
14386
|
}
|
|
14373
14387
|
return tools;
|
|
14374
14388
|
}
|
|
14375
|
-
function buildSubagentGuidance() {
|
|
14389
|
+
function buildSubagentGuidance(config2) {
|
|
14390
|
+
const exploreMinQueries = config2.subagent_orchestration.explore_min_queries;
|
|
14391
|
+
const spotCheckMinCommands = config2.verification.spot_check_min_commands;
|
|
14376
14392
|
const agentList = SUBAGENT_DEFINITIONS.map((def) => `- **ccx-${def.name}**: ${def.description}`).join(`
|
|
14377
14393
|
`);
|
|
14378
14394
|
return `# Subagent orchestration
|
|
@@ -14386,7 +14402,7 @@ ${agentList}
|
|
|
14386
14402
|
|
|
14387
14403
|
## When to use subagents
|
|
14388
14404
|
|
|
14389
|
-
- 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 clearly
|
|
14405
|
+
- 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.
|
|
14390
14406
|
- 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.
|
|
14391
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.
|
|
14392
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.
|
|
@@ -14398,7 +14414,7 @@ The rule: whenever non-trivial implementation occurs during your turn, an indepe
|
|
|
14398
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.
|
|
14399
14415
|
|
|
14400
14416
|
- On **FAIL**: address the reported issue, then resume the verifier session with the failure details plus your correction. Iterate until PASS.
|
|
14401
|
-
- On **PASS**: perform a spot-check \u2014 re-execute
|
|
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.
|
|
14402
14418
|
- On **PARTIAL**: communicate what passed and what remained unverifiable due to environment constraints.
|
|
14403
14419
|
|
|
14404
14420
|
## Subagent usage rules
|
|
@@ -14424,7 +14440,7 @@ function createConfigHook(config2, directory) {
|
|
|
14424
14440
|
outputStyle: config2.output_style ?? undefined,
|
|
14425
14441
|
disabledSectionIDs: config2.disabled_sections
|
|
14426
14442
|
});
|
|
14427
|
-
const subagentGuidance = buildSubagentGuidance();
|
|
14443
|
+
const subagentGuidance = buildSubagentGuidance(config2);
|
|
14428
14444
|
const mainPrompt = [...systemSections, subagentGuidance].join(`
|
|
14429
14445
|
|
|
14430
14446
|
`);
|
|
@@ -14679,9 +14695,10 @@ Files edited in this session (${editedFilesCount} total): ${editedFiles.join(",
|
|
|
14679
14695
|
return null;
|
|
14680
14696
|
}
|
|
14681
14697
|
const { editedFilesCount } = getVerificationState(sessionID);
|
|
14698
|
+
const spotCheckMinCommands = config2.verification.spot_check_min_commands;
|
|
14682
14699
|
return `# Verification Reminder
|
|
14683
14700
|
|
|
14684
|
-
You have edited ${editedFilesCount} files in this session.
|
|
14701
|
+
You have edited ${editedFilesCount} files in this session. It is recommended to run verification (via ccx-verification subagent) before declaring the task complete. If verifier returns PASS, you must re-run at least ${spotCheckMinCommands} commands from the verifier report and confirm outputs match before reporting completion.`;
|
|
14685
14702
|
}
|
|
14686
14703
|
})
|
|
14687
14704
|
];
|
|
@@ -14874,13 +14891,13 @@ function createIdleCompactionHook(config2, client) {
|
|
|
14874
14891
|
}
|
|
14875
14892
|
|
|
14876
14893
|
// src/hooks/risk-guard.ts
|
|
14877
|
-
var
|
|
14878
|
-
/rm\s+-rf\b/i,
|
|
14879
|
-
/git\s+push\s+--force(?:-with-lease)?\b/i,
|
|
14880
|
-
/git\s+reset\s+--hard\b/i,
|
|
14881
|
-
/drop\s+table\b/i,
|
|
14882
|
-
/truncate\s+table\b/i,
|
|
14883
|
-
/delete\s+from\b/i
|
|
14894
|
+
var RISK_RULES = [
|
|
14895
|
+
{ pattern: /rm\s+-rf\b/i, level: "high", name: "rm-rf" },
|
|
14896
|
+
{ pattern: /git\s+push\s+--force(?:-with-lease)?\b/i, level: "high", name: "git-force-push" },
|
|
14897
|
+
{ pattern: /git\s+reset\s+--hard\b/i, level: "high", name: "git-hard-reset" },
|
|
14898
|
+
{ pattern: /drop\s+table\b/i, level: "high", name: "sql-drop-table" },
|
|
14899
|
+
{ pattern: /truncate\s+table\b/i, level: "high", name: "sql-truncate-table" },
|
|
14900
|
+
{ pattern: /delete\s+from\b/i, level: "medium", name: "sql-delete" }
|
|
14884
14901
|
];
|
|
14885
14902
|
function isRecord4(value) {
|
|
14886
14903
|
return typeof value === "object" && value !== null;
|
|
@@ -14897,24 +14914,41 @@ function collectRiskText(value) {
|
|
|
14897
14914
|
}
|
|
14898
14915
|
return [];
|
|
14899
14916
|
}
|
|
14900
|
-
function
|
|
14917
|
+
function hasExplicitUserConfirmation(value) {
|
|
14918
|
+
if (!isRecord4(value))
|
|
14919
|
+
return false;
|
|
14920
|
+
const metadata = isRecord4(value.metadata) ? value.metadata : undefined;
|
|
14921
|
+
if (!metadata)
|
|
14922
|
+
return false;
|
|
14923
|
+
const confirmation = metadata.riskConfirmation;
|
|
14924
|
+
return confirmation === true || confirmation === "approved";
|
|
14925
|
+
}
|
|
14926
|
+
function createRiskGuard(config2) {
|
|
14901
14927
|
return async (input, output) => {
|
|
14902
14928
|
if (!isRecord4(output)) {
|
|
14903
14929
|
return;
|
|
14904
14930
|
}
|
|
14905
14931
|
const argsText = collectRiskText(output.args).join(`
|
|
14906
14932
|
`);
|
|
14907
|
-
const
|
|
14908
|
-
if (!
|
|
14933
|
+
const matchedRule = RISK_RULES.find((rule) => rule.pattern.test(argsText));
|
|
14934
|
+
if (!matchedRule) {
|
|
14909
14935
|
return;
|
|
14910
14936
|
}
|
|
14911
14937
|
const toolName = isRecord4(input) && typeof input.tool === "string" ? input.tool : "tool";
|
|
14912
|
-
const warning = `Potentially destructive ${toolName} invocation detected. Review arguments carefully before continuing.`;
|
|
14938
|
+
const warning = matchedRule.level === "high" ? `High-risk ${toolName} invocation detected (${matchedRule.name}). Explicit user confirmation is required before execution.` : `Potentially destructive ${toolName} invocation detected (${matchedRule.name}). Review arguments carefully before continuing.`;
|
|
14939
|
+
if (matchedRule.level === "high" && config2.risk_guard.enforce_high_risk_confirmation) {
|
|
14940
|
+
const confirmed = hasExplicitUserConfirmation(input);
|
|
14941
|
+
if (!confirmed) {
|
|
14942
|
+
output.blocked = true;
|
|
14943
|
+
}
|
|
14944
|
+
}
|
|
14913
14945
|
output.warning = warning;
|
|
14914
14946
|
const metadata = isRecord4(output.metadata) ? output.metadata : {};
|
|
14915
14947
|
metadata.riskGuard = {
|
|
14916
14948
|
flagged: true,
|
|
14917
|
-
|
|
14949
|
+
level: matchedRule.level,
|
|
14950
|
+
pattern: matchedRule.pattern.source,
|
|
14951
|
+
name: matchedRule.name
|
|
14918
14952
|
};
|
|
14919
14953
|
output.metadata = metadata;
|
|
14920
14954
|
};
|
|
@@ -27306,7 +27340,7 @@ function createAgentTools() {
|
|
|
27306
27340
|
function createPluginInterface(args) {
|
|
27307
27341
|
const { ctx, config: config3 } = args;
|
|
27308
27342
|
const configHook = createConfigHook(config3, ctx.directory);
|
|
27309
|
-
const riskGuard = createRiskGuard();
|
|
27343
|
+
const riskGuard = createRiskGuard(config3);
|
|
27310
27344
|
const verificationReminder = createVerificationReminder(config3);
|
|
27311
27345
|
const environmentContext = createEnvironmentContext(ctx.directory);
|
|
27312
27346
|
const gitContext = createGitContextHook(ctx.directory);
|
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.11",
|
|
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",
|