opencode-swarm 3.1.0 → 3.1.1

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.
Files changed (2) hide show
  1. package/dist/index.js +35 -24
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14902,8 +14902,11 @@ function createAllSMEAgents(getModel, loadPrompt) {
14902
14902
  }
14903
14903
 
14904
14904
  // src/agents/index.ts
14905
- function getModelForAgent(agentName, swarmAgents) {
14906
- const baseAgentName = agentName.includes("_") ? agentName.substring(agentName.indexOf("_") + 1) : agentName;
14905
+ function getModelForAgent(agentName, swarmAgents, swarmPrefix) {
14906
+ let baseAgentName = agentName;
14907
+ if (swarmPrefix && agentName.startsWith(`${swarmPrefix}_`)) {
14908
+ baseAgentName = agentName.substring(swarmPrefix.length + 1);
14909
+ }
14907
14910
  const explicit = swarmAgents?.[baseAgentName]?.model;
14908
14911
  if (explicit)
14909
14912
  return explicit;
@@ -14921,16 +14924,22 @@ function getModelForAgent(agentName, swarmAgents) {
14921
14924
  }
14922
14925
  return DEFAULT_MODELS[baseAgentName] ?? DEFAULT_MODELS.default;
14923
14926
  }
14924
- function isAgentDisabled(agentName, swarmAgents) {
14925
- const baseAgentName = agentName.includes("_") ? agentName.substring(agentName.indexOf("_") + 1) : agentName;
14927
+ function isAgentDisabled(agentName, swarmAgents, swarmPrefix) {
14928
+ let baseAgentName = agentName;
14929
+ if (swarmPrefix && agentName.startsWith(`${swarmPrefix}_`)) {
14930
+ baseAgentName = agentName.substring(swarmPrefix.length + 1);
14931
+ }
14926
14932
  return swarmAgents?.[baseAgentName]?.disabled === true;
14927
14933
  }
14928
- function getTemperatureOverride(agentName, swarmAgents) {
14929
- const baseAgentName = agentName.includes("_") ? agentName.substring(agentName.indexOf("_") + 1) : agentName;
14934
+ function getTemperatureOverride(agentName, swarmAgents, swarmPrefix) {
14935
+ let baseAgentName = agentName;
14936
+ if (swarmPrefix && agentName.startsWith(`${swarmPrefix}_`)) {
14937
+ baseAgentName = agentName.substring(swarmPrefix.length + 1);
14938
+ }
14930
14939
  return swarmAgents?.[baseAgentName]?.temperature;
14931
14940
  }
14932
- function applyOverrides(agent, swarmAgents) {
14933
- const tempOverride = getTemperatureOverride(agent.name, swarmAgents);
14941
+ function applyOverrides(agent, swarmAgents, swarmPrefix) {
14942
+ const tempOverride = getTemperatureOverride(agent.name, swarmAgents, swarmPrefix);
14934
14943
  if (tempOverride !== undefined) {
14935
14944
  agent.config.temperature = tempOverride;
14936
14945
  }
@@ -14940,11 +14949,12 @@ function createSwarmAgents(swarmId, swarmConfig, isDefault) {
14940
14949
  const agents = [];
14941
14950
  const swarmAgents = swarmConfig.agents;
14942
14951
  const prefix = isDefault ? "" : `${swarmId}_`;
14943
- const getModel = (name) => getModelForAgent(name, swarmAgents);
14952
+ const swarmPrefix = isDefault ? undefined : swarmId;
14953
+ const getModel = (baseName) => getModelForAgent(baseName, swarmAgents, swarmPrefix);
14944
14954
  const getPrompts = (name) => loadAgentPrompt(name);
14945
14955
  const prefixName = (name) => `${prefix}${name}`;
14946
14956
  const subagentNames = ALL_SUBAGENT_NAMES.map((name) => `@${prefix}${name}`).join(" ");
14947
- if (!isAgentDisabled("architect", swarmAgents)) {
14957
+ if (!isAgentDisabled("architect", swarmAgents, swarmPrefix)) {
14948
14958
  const architectPrompts = getPrompts("architect");
14949
14959
  const architect = createArchitectAgent(getModel("architect"), architectPrompts.prompt, architectPrompts.appendPrompt);
14950
14960
  architect.name = prefixName("architect");
@@ -14953,44 +14963,45 @@ function createSwarmAgents(swarmId, swarmConfig, isDefault) {
14953
14963
  architect.description = `[${swarmName}] ${architect.description}`;
14954
14964
  architect.config.prompt = architect.config.prompt?.replace(/@explorer/g, `@${prefix}explorer`).replace(/@coder/g, `@${prefix}coder`).replace(/@test_engineer/g, `@${prefix}test_engineer`).replace(/@security_reviewer/g, `@${prefix}security_reviewer`).replace(/@auditor/g, `@${prefix}auditor`).replace(/@sme_(\w+)/g, `@${prefix}sme_$1`);
14955
14965
  }
14956
- agents.push(applyOverrides(architect, swarmAgents));
14966
+ agents.push(applyOverrides(architect, swarmAgents, swarmPrefix));
14957
14967
  }
14958
- if (!isAgentDisabled("explorer", swarmAgents)) {
14968
+ if (!isAgentDisabled("explorer", swarmAgents, swarmPrefix)) {
14959
14969
  const explorerPrompts = getPrompts("explorer");
14960
14970
  const explorer = createExplorerAgent(getModel("explorer"), explorerPrompts.prompt, explorerPrompts.appendPrompt);
14961
14971
  explorer.name = prefixName("explorer");
14962
- agents.push(applyOverrides(explorer, swarmAgents));
14972
+ agents.push(applyOverrides(explorer, swarmAgents, swarmPrefix));
14963
14973
  }
14964
14974
  const smeAgents = createAllSMEAgents(getModel, getPrompts);
14965
14975
  for (const sme of smeAgents) {
14966
- if (!isAgentDisabled(sme.name, swarmAgents)) {
14967
- sme.name = prefixName(sme.name);
14968
- agents.push(applyOverrides(sme, swarmAgents));
14976
+ if (!isAgentDisabled(sme.name, swarmAgents, swarmPrefix)) {
14977
+ const baseName = sme.name;
14978
+ sme.name = prefixName(baseName);
14979
+ agents.push(applyOverrides(sme, swarmAgents, swarmPrefix));
14969
14980
  }
14970
14981
  }
14971
- if (!isAgentDisabled("coder", swarmAgents)) {
14982
+ if (!isAgentDisabled("coder", swarmAgents, swarmPrefix)) {
14972
14983
  const coderPrompts = getPrompts("coder");
14973
14984
  const coder = createCoderAgent(getModel("coder"), coderPrompts.prompt, coderPrompts.appendPrompt);
14974
14985
  coder.name = prefixName("coder");
14975
- agents.push(applyOverrides(coder, swarmAgents));
14986
+ agents.push(applyOverrides(coder, swarmAgents, swarmPrefix));
14976
14987
  }
14977
- if (!isAgentDisabled("security_reviewer", swarmAgents)) {
14988
+ if (!isAgentDisabled("security_reviewer", swarmAgents, swarmPrefix)) {
14978
14989
  const securityPrompts = getPrompts("security_reviewer");
14979
14990
  const security = createSecurityReviewerAgent(getModel("security_reviewer"), securityPrompts.prompt, securityPrompts.appendPrompt);
14980
14991
  security.name = prefixName("security_reviewer");
14981
- agents.push(applyOverrides(security, swarmAgents));
14992
+ agents.push(applyOverrides(security, swarmAgents, swarmPrefix));
14982
14993
  }
14983
- if (!isAgentDisabled("auditor", swarmAgents)) {
14994
+ if (!isAgentDisabled("auditor", swarmAgents, swarmPrefix)) {
14984
14995
  const auditorPrompts = getPrompts("auditor");
14985
14996
  const auditor = createAuditorAgent(getModel("auditor"), auditorPrompts.prompt, auditorPrompts.appendPrompt);
14986
14997
  auditor.name = prefixName("auditor");
14987
- agents.push(applyOverrides(auditor, swarmAgents));
14998
+ agents.push(applyOverrides(auditor, swarmAgents, swarmPrefix));
14988
14999
  }
14989
- if (!isAgentDisabled("test_engineer", swarmAgents)) {
15000
+ if (!isAgentDisabled("test_engineer", swarmAgents, swarmPrefix)) {
14990
15001
  const testPrompts = getPrompts("test_engineer");
14991
15002
  const testEngineer = createTestEngineerAgent(getModel("test_engineer"), testPrompts.prompt, testPrompts.appendPrompt);
14992
15003
  testEngineer.name = prefixName("test_engineer");
14993
- agents.push(applyOverrides(testEngineer, swarmAgents));
15004
+ agents.push(applyOverrides(testEngineer, swarmAgents, swarmPrefix));
14994
15005
  }
14995
15006
  return agents;
14996
15007
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",