opencode-swarm 7.17.3 → 7.17.4

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/dist/cli/index.js CHANGED
@@ -34,7 +34,7 @@ var package_default;
34
34
  var init_package = __esm(() => {
35
35
  package_default = {
36
36
  name: "opencode-swarm",
37
- version: "7.17.3",
37
+ version: "7.17.4",
38
38
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
39
39
  main: "dist/index.js",
40
40
  types: "dist/index.d.ts",
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ var package_default;
33
33
  var init_package = __esm(() => {
34
34
  package_default = {
35
35
  name: "opencode-swarm",
36
- version: "7.17.3",
36
+ version: "7.17.4",
37
37
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
38
38
  main: "dist/index.js",
39
39
  types: "dist/index.d.ts",
@@ -70821,7 +70821,7 @@ var init_curator_drift = __esm(() => {
70821
70821
  var exports_project_context = {};
70822
70822
  __export(exports_project_context, {
70823
70823
  buildProjectContext: () => buildProjectContext,
70824
- _internals: () => _internals49,
70824
+ _internals: () => _internals50,
70825
70825
  LANG_BACKEND_DETECTION_TIMEOUT_MS: () => LANG_BACKEND_DETECTION_TIMEOUT_MS
70826
70826
  });
70827
70827
  import * as fs110 from "node:fs";
@@ -70905,7 +70905,7 @@ function selectLintCommand(backend, directory) {
70905
70905
  return null;
70906
70906
  }
70907
70907
  async function buildProjectContext(directory) {
70908
- const backend = await _internals49.pickBackend(directory);
70908
+ const backend = await _internals50.pickBackend(directory);
70909
70909
  if (!backend)
70910
70910
  return null;
70911
70911
  const ctx = emptyProjectContext();
@@ -70936,16 +70936,16 @@ async function buildProjectContext(directory) {
70936
70936
  if (backend.prompts.reviewerChecklist.length > 0) {
70937
70937
  ctx.REVIEWER_CHECKLIST = bulletList(backend.prompts.reviewerChecklist);
70938
70938
  }
70939
- const profiles = _internals49.pickedProfiles(directory);
70939
+ const profiles = _internals50.pickedProfiles(directory);
70940
70940
  if (profiles.length > 1) {
70941
70941
  ctx.PROJECT_CONTEXT_SECONDARY_LANGUAGES = profiles.slice(1).map((p) => p.id).join(", ");
70942
70942
  }
70943
70943
  return ctx;
70944
70944
  }
70945
- var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals49;
70945
+ var LANG_BACKEND_DETECTION_TIMEOUT_MS = 300, _internals50;
70946
70946
  var init_project_context = __esm(() => {
70947
70947
  init_dispatch();
70948
- _internals49 = {
70948
+ _internals50 = {
70949
70949
  pickBackend,
70950
70950
  pickedProfiles
70951
70951
  };
@@ -102445,6 +102445,7 @@ var write_drift_evidence = createSwarmTool({
102445
102445
  // src/tools/write-final-council-evidence.ts
102446
102446
  init_zod();
102447
102447
  init_loader();
102448
+ import { randomUUID as randomUUID9 } from "node:crypto";
102448
102449
  import fs107 from "node:fs";
102449
102450
  import path135 from "node:path";
102450
102451
  init_utils2();
@@ -102481,6 +102482,90 @@ var ArgsSchema6 = exports_external.object({
102481
102482
  function normalizeFinalVerdict(verdict) {
102482
102483
  return verdict === "APPROVE" ? "approved" : "rejected";
102483
102484
  }
102485
+ var replacementLocks = new Map;
102486
+ var _internals49 = {
102487
+ loadPluginConfig,
102488
+ synthesizeFinalCouncilAdvisory,
102489
+ loadPlan,
102490
+ derivePlanId,
102491
+ validateSwarmPath
102492
+ };
102493
+ function getErrnoCode(error93) {
102494
+ return error93 && typeof error93 === "object" ? error93.code : undefined;
102495
+ }
102496
+ async function replaceEvidenceFile(tempPath, finalPath) {
102497
+ const previous = replacementLocks.get(finalPath)?.catch(() => {});
102498
+ let release;
102499
+ const current = new Promise((resolve51) => {
102500
+ release = resolve51;
102501
+ });
102502
+ replacementLocks.set(finalPath, current);
102503
+ if (previous) {
102504
+ await previous;
102505
+ }
102506
+ try {
102507
+ await replaceEvidenceFileLocked(tempPath, finalPath);
102508
+ } finally {
102509
+ release();
102510
+ if (replacementLocks.get(finalPath) === current) {
102511
+ replacementLocks.delete(finalPath);
102512
+ }
102513
+ }
102514
+ }
102515
+ async function replaceEvidenceFileLocked(tempPath, finalPath) {
102516
+ try {
102517
+ await fs107.promises.rename(tempPath, finalPath);
102518
+ return;
102519
+ } catch (error93) {
102520
+ const code = getErrnoCode(error93);
102521
+ if (!["EEXIST", "EPERM", "EACCES"].includes(code ?? "")) {
102522
+ throw error93;
102523
+ }
102524
+ }
102525
+ const backupPath = `${finalPath}.${randomUUID9()}.bak`;
102526
+ let backupCreated = false;
102527
+ try {
102528
+ try {
102529
+ await fs107.promises.rename(finalPath, backupPath);
102530
+ backupCreated = true;
102531
+ } catch (error93) {
102532
+ if (getErrnoCode(error93) !== "ENOENT") {
102533
+ throw error93;
102534
+ }
102535
+ }
102536
+ try {
102537
+ await fs107.promises.rename(tempPath, finalPath);
102538
+ } catch (error93) {
102539
+ if (backupCreated) {
102540
+ if (!await restoreEvidenceBackup(backupPath, finalPath)) {
102541
+ await fs107.promises.rm(backupPath, { force: true }).catch(() => {});
102542
+ }
102543
+ backupCreated = false;
102544
+ }
102545
+ throw error93;
102546
+ }
102547
+ if (backupCreated) {
102548
+ await fs107.promises.rm(backupPath, { force: true }).catch(() => {});
102549
+ backupCreated = false;
102550
+ }
102551
+ } finally {
102552
+ await fs107.promises.rm(tempPath, { force: true }).catch(() => {});
102553
+ }
102554
+ }
102555
+ async function restoreEvidenceBackup(backupPath, finalPath) {
102556
+ try {
102557
+ await fs107.promises.rename(backupPath, finalPath);
102558
+ return true;
102559
+ } catch {
102560
+ try {
102561
+ await fs107.promises.copyFile(backupPath, finalPath);
102562
+ await fs107.promises.rm(backupPath, { force: true }).catch(() => {});
102563
+ return true;
102564
+ } catch {
102565
+ return false;
102566
+ }
102567
+ }
102568
+ }
102484
102569
  async function executeWriteFinalCouncilEvidence(args2, directory) {
102485
102570
  const parsed = ArgsSchema6.safeParse(args2);
102486
102571
  if (!parsed.success) {
@@ -102494,7 +102579,7 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
102494
102579
  }, null, 2);
102495
102580
  }
102496
102581
  const input = parsed.data;
102497
- const config3 = loadPluginConfig(directory);
102582
+ const config3 = _internals49.loadPluginConfig(directory);
102498
102583
  const requiredMembers = FINAL_COUNCIL_MEMBERS.length;
102499
102584
  const distinctMembers = new Set(input.verdicts.map((v) => v.agent));
102500
102585
  const membersVoted = [...distinctMembers];
@@ -102509,9 +102594,27 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
102509
102594
  quorumRequired: requiredMembers
102510
102595
  }, null, 2);
102511
102596
  }
102512
- const synthesis = synthesizeFinalCouncilAdvisory(input.projectSummary.trim(), input.verdicts, input.roundNumber ?? 1, config3.council);
102513
- const plan = await loadPlan(directory);
102514
- const planId = plan ? derivePlanId(plan) : "unknown";
102597
+ let synthesis;
102598
+ try {
102599
+ synthesis = _internals49.synthesizeFinalCouncilAdvisory(input.projectSummary.trim(), input.verdicts, input.roundNumber ?? 1, config3.council);
102600
+ } catch (error93) {
102601
+ return JSON.stringify({
102602
+ success: false,
102603
+ phase: input.phase,
102604
+ message: error93 instanceof Error ? error93.message : "Failed to synthesize final council evidence"
102605
+ }, null, 2);
102606
+ }
102607
+ let planId = "unknown";
102608
+ try {
102609
+ const plan = await _internals49.loadPlan(directory);
102610
+ planId = plan ? _internals49.derivePlanId(plan) : "unknown";
102611
+ } catch (error93) {
102612
+ return JSON.stringify({
102613
+ success: false,
102614
+ phase: input.phase,
102615
+ message: error93 instanceof Error ? error93.message : "Failed to load project plan"
102616
+ }, null, 2);
102617
+ }
102515
102618
  const normalizedVerdict = normalizeFinalVerdict(synthesis.overallVerdict);
102516
102619
  const evidenceEntry = {
102517
102620
  type: "final-council",
@@ -102537,7 +102640,7 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
102537
102640
  const relativePath = path135.join("evidence", filename);
102538
102641
  let validatedPath;
102539
102642
  try {
102540
- validatedPath = validateSwarmPath(directory, relativePath);
102643
+ validatedPath = _internals49.validateSwarmPath(directory, relativePath);
102541
102644
  } catch (error93) {
102542
102645
  return JSON.stringify({
102543
102646
  success: false,
@@ -102551,9 +102654,9 @@ async function executeWriteFinalCouncilEvidence(args2, directory) {
102551
102654
  const evidenceDir = path135.dirname(validatedPath);
102552
102655
  try {
102553
102656
  await fs107.promises.mkdir(evidenceDir, { recursive: true });
102554
- const tempPath = path135.join(evidenceDir, `.${filename}.tmp`);
102657
+ const tempPath = path135.join(evidenceDir, `.${filename}.${randomUUID9()}.tmp`);
102555
102658
  await fs107.promises.writeFile(tempPath, JSON.stringify(evidenceContent, null, 2), "utf-8");
102556
- await fs107.promises.rename(tempPath, validatedPath);
102659
+ await replaceEvidenceFile(tempPath, validatedPath);
102557
102660
  return JSON.stringify({
102558
102661
  success: true,
102559
102662
  phase: input.phase,
@@ -7,7 +7,12 @@
7
7
  */
8
8
  import type { ToolDefinition } from '@opencode-ai/plugin/tool';
9
9
  import { z } from 'zod';
10
+ import { loadPluginConfig } from '../config/loader';
11
+ import { synthesizeFinalCouncilAdvisory } from '../council/council-service';
10
12
  import type { CouncilMemberVerdict } from '../council/types';
13
+ import { validateSwarmPath } from '../hooks/utils';
14
+ import { loadPlan } from '../plan/manager.js';
15
+ import { derivePlanId } from '../plan/utils.js';
11
16
  export declare const ArgsSchema: z.ZodObject<{
12
17
  phase: z.ZodNumber;
13
18
  projectSummary: z.ZodString;
@@ -55,6 +60,13 @@ export interface WriteFinalCouncilEvidenceArgs {
55
60
  /** Collected verdicts from critic, reviewer, sme, test_engineer, explorer */
56
61
  verdicts: CouncilMemberVerdict[];
57
62
  }
63
+ export declare const _internals: {
64
+ loadPluginConfig: typeof loadPluginConfig;
65
+ synthesizeFinalCouncilAdvisory: typeof synthesizeFinalCouncilAdvisory;
66
+ loadPlan: typeof loadPlan;
67
+ derivePlanId: typeof derivePlanId;
68
+ validateSwarmPath: typeof validateSwarmPath;
69
+ };
58
70
  /**
59
71
  * Execute the write_final_council_evidence tool.
60
72
  * Validates input, synthesizes project-scoped council evidence, and writes it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.17.3",
3
+ "version": "7.17.4",
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",