@ccx-agent/opencode-ccx 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  export declare const configSchema: z.ZodObject<{
3
3
  enabled: z.ZodDefault<z.ZodBoolean>;
4
+ agent_name: z.ZodDefault<z.ZodString>;
4
5
  disabled_sections: z.ZodDefault<z.ZodArray<z.ZodString>>;
5
6
  disabled_hooks: z.ZodDefault<z.ZodArray<z.ZodString>>;
6
7
  output_style: z.ZodDefault<z.ZodNullable<z.ZodString>>;
@@ -47,10 +48,10 @@ export declare const configSchema: z.ZodObject<{
47
48
  }, z.core.$strip>>;
48
49
  session_workflows: z.ZodDefault<z.ZodObject<{
49
50
  enabled: z.ZodDefault<z.ZodBoolean>;
50
- fork_command: z.ZodDefault<z.ZodString>;
51
- background_command: z.ZodDefault<z.ZodString>;
52
- full_context_command: z.ZodDefault<z.ZodString>;
53
- status_command: z.ZodDefault<z.ZodString>;
51
+ fork_command: z.ZodDefault<z.ZodNullable<z.ZodString>>;
52
+ background_command: z.ZodDefault<z.ZodNullable<z.ZodString>>;
53
+ full_context_command: z.ZodDefault<z.ZodNullable<z.ZodString>>;
54
+ status_command: z.ZodDefault<z.ZodNullable<z.ZodString>>;
54
55
  }, z.core.$strip>>;
55
56
  }, z.core.$strip>>;
56
57
  }, z.core.$strip>;
package/dist/index.js CHANGED
@@ -24214,10 +24214,10 @@ var contextBundleSchema = exports_external.object({
24214
24214
  });
24215
24215
  var sessionWorkflowsSchema = exports_external.object({
24216
24216
  enabled: exports_external.boolean().default(true),
24217
- fork_command: exports_external.string().min(1).default("/ccx-fork"),
24218
- background_command: exports_external.string().min(1).default("/ccx-bg"),
24219
- full_context_command: exports_external.string().min(1).default("/ccx-fullctx"),
24220
- status_command: exports_external.string().min(1).default("/ccx-bg-status")
24217
+ fork_command: exports_external.string().min(1).nullable().default(null),
24218
+ background_command: exports_external.string().min(1).nullable().default(null),
24219
+ full_context_command: exports_external.string().min(1).nullable().default(null),
24220
+ status_command: exports_external.string().min(1).nullable().default(null)
24221
24221
  });
24222
24222
  var subagentOrchestrationSchema = exports_external.object({
24223
24223
  explore_min_queries: exports_external.int().positive().default(3),
@@ -24232,14 +24232,15 @@ var subagentOrchestrationSchema = exports_external.object({
24232
24232
  }),
24233
24233
  session_workflows: sessionWorkflowsSchema.default({
24234
24234
  enabled: true,
24235
- fork_command: "/ccx-fork",
24236
- background_command: "/ccx-bg",
24237
- full_context_command: "/ccx-fullctx",
24238
- status_command: "/ccx-bg-status"
24235
+ fork_command: null,
24236
+ background_command: null,
24237
+ full_context_command: null,
24238
+ status_command: null
24239
24239
  })
24240
24240
  });
24241
24241
  var configSchema = exports_external.object({
24242
24242
  enabled: exports_external.boolean().default(true),
24243
+ agent_name: exports_external.string().min(1).regex(/^[a-z][a-z0-9-]*$/, "agent_name must be lowercase kebab-case").default("ccx"),
24243
24244
  disabled_sections: exports_external.array(exports_external.string()).default([]),
24244
24245
  disabled_hooks: exports_external.array(exports_external.string()).default([]),
24245
24246
  output_style: exports_external.string().min(1).nullable().default(null),
@@ -24286,10 +24287,10 @@ var configSchema = exports_external.object({
24286
24287
  },
24287
24288
  session_workflows: {
24288
24289
  enabled: true,
24289
- fork_command: "/ccx-fork",
24290
- background_command: "/ccx-bg",
24291
- full_context_command: "/ccx-fullctx",
24292
- status_command: "/ccx-bg-status"
24290
+ fork_command: null,
24291
+ background_command: null,
24292
+ full_context_command: null,
24293
+ status_command: null
24293
24294
  }
24294
24295
  })
24295
24296
  });
@@ -24362,7 +24363,25 @@ function loadConfig(directory) {
24362
24363
  const defaults = configSchema.parse({});
24363
24364
  const projectConfigPath = join(directory, CONFIG_RELATIVE_PATH);
24364
24365
  const userConfigPath = join(homedir(), ".config", "opencode", "ccx.json");
24365
- return readConfigFile(projectConfigPath) ?? readConfigFile(userConfigPath) ?? defaults;
24366
+ const loaded = readConfigFile(projectConfigPath) ?? readConfigFile(userConfigPath) ?? defaults;
24367
+ return resolveAgentNameDerivedDefaults(loaded);
24368
+ }
24369
+ function resolveAgentNameDerivedDefaults(config2) {
24370
+ const { agent_name } = config2;
24371
+ const sw = config2.subagent_orchestration.session_workflows;
24372
+ return {
24373
+ ...config2,
24374
+ subagent_orchestration: {
24375
+ ...config2.subagent_orchestration,
24376
+ session_workflows: {
24377
+ ...sw,
24378
+ fork_command: sw.fork_command ?? `/${agent_name}-fork`,
24379
+ background_command: sw.background_command ?? `/${agent_name}-bg`,
24380
+ full_context_command: sw.full_context_command ?? `/${agent_name}-fullctx`,
24381
+ status_command: sw.status_command ?? `/${agent_name}-bg-status`
24382
+ }
24383
+ }
24384
+ };
24366
24385
  }
24367
24386
 
24368
24387
  // src/hooks/chat-message.ts
@@ -24380,7 +24399,7 @@ function createChatMessageHook(_config) {
24380
24399
  if (agent) {
24381
24400
  sessionAgentById.set(sessionID, agent);
24382
24401
  }
24383
- if (agent && !agent.startsWith("ccx"))
24402
+ if (agent && !agent.startsWith(_config.agent_name))
24384
24403
  return;
24385
24404
  };
24386
24405
  }
@@ -25106,15 +25125,16 @@ function buildSubagentGuidance(config2) {
25106
25125
  const exploreMinQueries = config2.subagent_orchestration.explore_min_queries;
25107
25126
  const spotCheckMinCommands = config2.verification.spot_check_min_commands;
25108
25127
  const enabledSubagents = getEnabledSubagentDefinitions(config2);
25109
- const agentList = enabledSubagents.map((def) => `- **ccx-${def.name}**: ${def.description}`).join(`
25128
+ const agentPrefix = config2.agent_name;
25129
+ const agentList = enabledSubagents.map((def) => `- **${agentPrefix}-${def.name}**: ${def.description}`).join(`
25110
25130
  `);
25111
25131
  const whenToUse = [
25112
- `- 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.`,
25113
- "- 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.",
25114
- "- Invoke the **task** tool with subagent_type `ccx-general-purpose` for multi-step work that does not fall under any other specialist's domain."
25132
+ `- Invoke the **task** tool with subagent_type \`${agentPrefix}-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 ${agentPrefix}-explore only when a simple search falls short or when the task clearly requires more than ${exploreMinQueries} queries.`,
25133
+ `- Invoke the **task** tool with subagent_type \`${agentPrefix}-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.`,
25134
+ `- Invoke the **task** tool with subagent_type \`${agentPrefix}-general-purpose\` for multi-step work that does not fall under any other specialist's domain.`
25115
25135
  ];
25116
25136
  if (config2.subagent_orchestration.coordinator_enabled) {
25117
- 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.");
25137
+ whenToUse.push(`- Invoke the **task** tool with subagent_type \`${agentPrefix}-coordinator\` for complex tasks best decomposed into research, implementation, and verification phases distributed across multiple workers.`);
25118
25138
  }
25119
25139
  const subagentUsageRules = [
25120
25140
  "- 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.",
@@ -25131,11 +25151,13 @@ function buildSubagentGuidance(config2) {
25131
25151
 
25132
25152
  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.
25133
25153
 
25134
- 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.
25154
+ Launch the **task** tool with subagent_type \`${agentPrefix}-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.
25135
25155
 
25136
25156
  - On **FAIL**: address the reported issue, then resume the verifier session with the failure details plus your correction. Iterate until PASS.
25137
25157
  - 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.
25138
- - 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.";
25158
+ - On **PARTIAL**: communicate what passed and what remained unverifiable due to environment constraints.` : `## Verification guidance
25159
+
25160
+ For significant implementation changes, prefer independent verification with subagent_type \`${agentPrefix}-verification\` before reporting completion.`;
25139
25161
  return `# Subagent orchestration
25140
25162
 
25141
25163
  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.
@@ -25177,7 +25199,8 @@ function createConfigHook(config2, directory) {
25177
25199
  const mainPrompt = [...systemSections, subagentGuidance].join(`
25178
25200
 
25179
25201
  `);
25180
- const ccx = {
25202
+ const agentName = config2.agent_name;
25203
+ const primaryAgent = {
25181
25204
  description: "CCX Agent \u2014 disciplined coding, risk-aware actions, verification-driven workflow with subagent orchestration.",
25182
25205
  mode: "primary",
25183
25206
  prompt: mainPrompt,
@@ -25186,7 +25209,7 @@ function createConfigHook(config2, directory) {
25186
25209
  const enabledSubagents = getEnabledSubagentDefinitions(config2);
25187
25210
  const subagents = {};
25188
25211
  for (const def of enabledSubagents) {
25189
- subagents[`ccx-${def.name}`] = {
25212
+ subagents[`${agentName}-${def.name}`] = {
25190
25213
  description: def.description,
25191
25214
  mode: "subagent",
25192
25215
  prompt: def.getSystemPrompt(),
@@ -25195,11 +25218,11 @@ function createConfigHook(config2, directory) {
25195
25218
  }
25196
25219
  input.agent = {
25197
25220
  ...existingAgents,
25198
- ccx,
25221
+ [agentName]: primaryAgent,
25199
25222
  ...subagents
25200
25223
  };
25201
25224
  if (!input.default_agent) {
25202
- input.default_agent = "ccx";
25225
+ input.default_agent = agentName;
25203
25226
  }
25204
25227
  };
25205
25228
  }
@@ -25579,7 +25602,8 @@ function createVerificationReminder(config2) {
25579
25602
  if (TASK_TOOL_NAMES2.has(toolName)) {
25580
25603
  const rawArgs = isRecord3(input.args) ? input.args : {};
25581
25604
  const subagentType = typeof rawArgs.subagent_type === "string" ? rawArgs.subagent_type.toLowerCase() : typeof rawArgs.subagentType === "string" ? rawArgs.subagentType.toLowerCase() : "";
25582
- if (subagentType === "ccx-verification" || subagentType === "verification") {
25605
+ const verificationSubagent = `${config2.agent_name}-verification`;
25606
+ if (subagentType === verificationSubagent || subagentType === "verification") {
25583
25607
  getSessionState(sessionID).verificationTriggered = true;
25584
25608
  }
25585
25609
  return;
@@ -25664,7 +25688,7 @@ Files edited in this session (${editedFilesCount} total): ${editedFiles.join(",
25664
25688
  const spotCheckMinCommands = config2.verification.spot_check_min_commands;
25665
25689
  return `# Verification Reminder
25666
25690
 
25667
- 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.`;
25691
+ You have edited ${editedFilesCount} files in this session. It is recommended to run verification (via ${config2.agent_name}-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.`;
25668
25692
  }
25669
25693
  })
25670
25694
  ];
@@ -26306,8 +26330,9 @@ function pickHighestFinding(findings) {
26306
26330
  var TASK_LAUNCH_TOOL_NAMES = new Set(["task"]);
26307
26331
  var BASH_TOOL_NAMES = new Set(["bash", "shell", "sh", "exec"]);
26308
26332
  var SQL_TOOL_NAMES = new Set(["sql", "query", "db", "database"]);
26309
- function isGuardedSubagentName(value) {
26310
- return typeof value === "string" && value.startsWith("ccx-") && value !== "ccx-coordinator";
26333
+ function isGuardedSubagentName(value, agentName) {
26334
+ const prefix = `${agentName}-`;
26335
+ return typeof value === "string" && value.startsWith(prefix) && value !== `${agentName}-coordinator`;
26311
26336
  }
26312
26337
  function hasExplicitDelegationApproval(value) {
26313
26338
  if (!isRecord5(value))
@@ -26387,7 +26412,7 @@ function createRiskGuard(config2) {
26387
26412
  const directAgent = isRecord5(input) && typeof input.agent === "string" ? input.agent : undefined;
26388
26413
  const currentAgent = directAgent ?? (sessionID ? getSessionAgent(sessionID) : undefined);
26389
26414
  const approved = hasExplicitDelegationApproval(input) || hasExplicitDelegationApproval(output.args);
26390
- if (isGuardedSubagentName(currentAgent) && !approved) {
26415
+ if (isGuardedSubagentName(currentAgent, config2.agent_name) && !approved) {
26391
26416
  output.blocked = true;
26392
26417
  output.warning = "Nested subagent delegation is blocked by runtime policy. Execute directly in the current subagent, or provide explicit delegation approval metadata.";
26393
26418
  const metadata2 = isRecord5(output.metadata) ? output.metadata : {};
@@ -26602,7 +26627,7 @@ function buildForkChildDirective(args2) {
26602
26627
  "You are a ccx fork-child. You have inherited the full parent session context above.",
26603
26628
  "Rules:",
26604
26629
  "1. Treat the inherited conversation as background. Do NOT re-introduce yourself.",
26605
- "2. Do NOT fork again. Never invoke /ccx-fork or /ccx-fullctx from within this session.",
26630
+ `2. Do NOT fork again. Never invoke ${args2.forkCommand} or ${args2.fullContextCommand} from within this session.`,
26606
26631
  "3. Focus strictly on the directive below. Report back concisely.",
26607
26632
  `Parent session: ${args2.parentSessionID}`,
26608
26633
  agentLine,
@@ -26676,7 +26701,7 @@ async function handleFork(client, sessionID, rest) {
26676
26701
  }
26677
26702
  }
26678
26703
  async function dispatchBackgroundPrompt(args2) {
26679
- const { client, targetSessionID, parentSessionID, agent, prompt, fullContext } = args2;
26704
+ const { client, targetSessionID, parentSessionID, agent, prompt, fullContext, forkCommand, fullContextCommand } = args2;
26680
26705
  if (!client.session?.promptAsync) {
26681
26706
  return {
26682
26707
  ok: false,
@@ -26692,7 +26717,7 @@ async function dispatchBackgroundPrompt(args2) {
26692
26717
  prompt,
26693
26718
  fullContext
26694
26719
  });
26695
- const directive = fullContext ? buildForkChildDirective({ agent, prompt, parentSessionID }) : prompt;
26720
+ const directive = fullContext ? buildForkChildDirective({ agent, prompt, parentSessionID, forkCommand, fullContextCommand }) : prompt;
26696
26721
  try {
26697
26722
  await client.session.promptAsync({
26698
26723
  path: { id: targetSessionID },
@@ -26720,7 +26745,7 @@ async function dispatchBackgroundPrompt(args2) {
26720
26745
  };
26721
26746
  }
26722
26747
  }
26723
- async function handleBackground(client, sessionID, rest) {
26748
+ async function handleBackground(client, sessionID, rest, commands) {
26724
26749
  const { agent, prompt } = parseAgentAndPrompt(rest);
26725
26750
  if (!prompt) {
26726
26751
  return { ok: false, text: "Background prompt requires a non-empty prompt body." };
@@ -26731,10 +26756,12 @@ async function handleBackground(client, sessionID, rest) {
26731
26756
  parentSessionID: sessionID,
26732
26757
  agent,
26733
26758
  prompt,
26734
- fullContext: false
26759
+ fullContext: false,
26760
+ forkCommand: commands.forkCommand,
26761
+ fullContextCommand: commands.fullContextCommand
26735
26762
  });
26736
26763
  }
26737
- async function handleFullContext(client, sessionID, rest) {
26764
+ async function handleFullContext(client, sessionID, rest, commands) {
26738
26765
  if (!client.session?.fork || !client.session.promptAsync) {
26739
26766
  return {
26740
26767
  ok: false,
@@ -26776,7 +26803,9 @@ async function handleFullContext(client, sessionID, rest) {
26776
26803
  parentSessionID: sessionID,
26777
26804
  agent,
26778
26805
  prompt,
26779
- fullContext: true
26806
+ fullContext: true,
26807
+ forkCommand: commands.forkCommand,
26808
+ fullContextCommand: commands.fullContextCommand
26780
26809
  });
26781
26810
  }
26782
26811
  async function refreshBgTaskStatus(client, task) {
@@ -26858,32 +26887,36 @@ function createSessionWorkflowsHook(args2) {
26858
26887
  return;
26859
26888
  if (!output?.parts)
26860
26889
  return;
26890
+ const forkCommand = workflows.fork_command ?? `/${config2.agent_name}-fork`;
26891
+ const backgroundCommand = workflows.background_command ?? `/${config2.agent_name}-bg`;
26892
+ const fullContextCommand = workflows.full_context_command ?? `/${config2.agent_name}-fullctx`;
26893
+ const statusCommand = workflows.status_command ?? `/${config2.agent_name}-bg-status`;
26861
26894
  const text = joinTextParts(output.parts);
26862
26895
  if (!text)
26863
26896
  return;
26864
- const forkLine = findCommandLine(text, workflows.fork_command);
26865
- const backgroundLine = findCommandLine(text, workflows.background_command);
26866
- const fullContextLine = findCommandLine(text, workflows.full_context_command);
26867
- const statusLine = findCommandLine(text, workflows.status_command);
26897
+ const forkLine = findCommandLine(text, forkCommand);
26898
+ const backgroundLine = findCommandLine(text, backgroundCommand);
26899
+ const fullContextLine = findCommandLine(text, fullContextCommand);
26900
+ const statusLine = findCommandLine(text, statusCommand);
26868
26901
  if (!forkLine && !backgroundLine && !fullContextLine && !statusLine)
26869
26902
  return;
26870
26903
  if (forkLine) {
26871
- const rest = forkLine.slice(workflows.fork_command.length);
26904
+ const rest = forkLine.slice(forkCommand.length);
26872
26905
  const status = await handleFork(client, input.sessionID, rest);
26873
26906
  appendStatusPart(output, status.text);
26874
26907
  }
26875
26908
  if (backgroundLine) {
26876
- const rest = backgroundLine.slice(workflows.background_command.length);
26877
- const status = await handleBackground(client, input.sessionID, rest);
26909
+ const rest = backgroundLine.slice(backgroundCommand.length);
26910
+ const status = await handleBackground(client, input.sessionID, rest, { forkCommand, fullContextCommand });
26878
26911
  appendStatusPart(output, status.text);
26879
26912
  }
26880
26913
  if (fullContextLine) {
26881
- const rest = fullContextLine.slice(workflows.full_context_command.length);
26882
- const status = await handleFullContext(client, input.sessionID, rest);
26914
+ const rest = fullContextLine.slice(fullContextCommand.length);
26915
+ const status = await handleFullContext(client, input.sessionID, rest, { forkCommand, fullContextCommand });
26883
26916
  appendStatusPart(output, status.text);
26884
26917
  }
26885
26918
  if (statusLine) {
26886
- const rest = statusLine.slice(workflows.status_command.length);
26919
+ const rest = statusLine.slice(statusCommand.length);
26887
26920
  const status = await handleStatus(client, input.sessionID, rest);
26888
26921
  appendStatusPart(output, status.text);
26889
26922
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccx-agent/opencode-ccx",
3
- "version": "0.3.4",
3
+ "version": "0.4.0",
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",