opencode-swarm 6.25.9 → 6.27.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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/cli/index.js CHANGED
@@ -14510,6 +14510,57 @@ var init_manager = __esm(() => {
14510
14510
  };
14511
14511
  });
14512
14512
 
14513
+ // src/config/plan-schema.ts
14514
+ var TaskStatusSchema, TaskSizeSchema, PhaseStatusSchema, MigrationStatusSchema, TaskSchema, PhaseSchema, PlanSchema;
14515
+ var init_plan_schema = __esm(() => {
14516
+ init_zod();
14517
+ TaskStatusSchema = exports_external.enum([
14518
+ "pending",
14519
+ "in_progress",
14520
+ "completed",
14521
+ "blocked"
14522
+ ]);
14523
+ TaskSizeSchema = exports_external.enum(["small", "medium", "large"]);
14524
+ PhaseStatusSchema = exports_external.enum([
14525
+ "pending",
14526
+ "in_progress",
14527
+ "complete",
14528
+ "completed",
14529
+ "blocked"
14530
+ ]);
14531
+ MigrationStatusSchema = exports_external.enum([
14532
+ "native",
14533
+ "migrated",
14534
+ "migration_failed"
14535
+ ]);
14536
+ TaskSchema = exports_external.object({
14537
+ id: exports_external.string(),
14538
+ phase: exports_external.number().int().min(1),
14539
+ status: TaskStatusSchema.default("pending"),
14540
+ size: TaskSizeSchema.default("small"),
14541
+ description: exports_external.string().min(1),
14542
+ depends: exports_external.array(exports_external.string()).default([]),
14543
+ acceptance: exports_external.string().optional(),
14544
+ files_touched: exports_external.array(exports_external.string()).default([]),
14545
+ evidence_path: exports_external.string().optional(),
14546
+ blocked_reason: exports_external.string().optional()
14547
+ });
14548
+ PhaseSchema = exports_external.object({
14549
+ id: exports_external.number().int().min(1),
14550
+ name: exports_external.string().min(1),
14551
+ status: PhaseStatusSchema.default("pending"),
14552
+ tasks: exports_external.array(TaskSchema).default([])
14553
+ });
14554
+ PlanSchema = exports_external.object({
14555
+ schema_version: exports_external.literal("1.0.0"),
14556
+ title: exports_external.string().min(1),
14557
+ swarm: exports_external.string().min(1),
14558
+ current_phase: exports_external.number().int().min(1).optional(),
14559
+ phases: exports_external.array(PhaseSchema).min(1),
14560
+ migration_status: MigrationStatusSchema.optional()
14561
+ });
14562
+ });
14563
+
14513
14564
  // node_modules/graceful-fs/polyfills.js
14514
14565
  var require_polyfills = __commonJS((exports, module) => {
14515
14566
  var constants = __require("constants");
@@ -16030,57 +16081,6 @@ var require_proper_lockfile = __commonJS((exports, module) => {
16030
16081
  module.exports.checkSync = checkSync;
16031
16082
  });
16032
16083
 
16033
- // src/config/plan-schema.ts
16034
- var TaskStatusSchema, TaskSizeSchema, PhaseStatusSchema, MigrationStatusSchema, TaskSchema, PhaseSchema, PlanSchema;
16035
- var init_plan_schema = __esm(() => {
16036
- init_zod();
16037
- TaskStatusSchema = exports_external.enum([
16038
- "pending",
16039
- "in_progress",
16040
- "completed",
16041
- "blocked"
16042
- ]);
16043
- TaskSizeSchema = exports_external.enum(["small", "medium", "large"]);
16044
- PhaseStatusSchema = exports_external.enum([
16045
- "pending",
16046
- "in_progress",
16047
- "complete",
16048
- "completed",
16049
- "blocked"
16050
- ]);
16051
- MigrationStatusSchema = exports_external.enum([
16052
- "native",
16053
- "migrated",
16054
- "migration_failed"
16055
- ]);
16056
- TaskSchema = exports_external.object({
16057
- id: exports_external.string(),
16058
- phase: exports_external.number().int().min(1),
16059
- status: TaskStatusSchema.default("pending"),
16060
- size: TaskSizeSchema.default("small"),
16061
- description: exports_external.string().min(1),
16062
- depends: exports_external.array(exports_external.string()).default([]),
16063
- acceptance: exports_external.string().optional(),
16064
- files_touched: exports_external.array(exports_external.string()).default([]),
16065
- evidence_path: exports_external.string().optional(),
16066
- blocked_reason: exports_external.string().optional()
16067
- });
16068
- PhaseSchema = exports_external.object({
16069
- id: exports_external.number().int().min(1),
16070
- name: exports_external.string().min(1),
16071
- status: PhaseStatusSchema.default("pending"),
16072
- tasks: exports_external.array(TaskSchema).default([])
16073
- });
16074
- PlanSchema = exports_external.object({
16075
- schema_version: exports_external.literal("1.0.0"),
16076
- title: exports_external.string().min(1),
16077
- swarm: exports_external.string().min(1),
16078
- current_phase: exports_external.number().int().min(1).optional(),
16079
- phases: exports_external.array(PhaseSchema).min(1),
16080
- migration_status: MigrationStatusSchema.optional()
16081
- });
16082
- });
16083
-
16084
16084
  // src/plan/manager.ts
16085
16085
  import { renameSync as renameSync2, unlinkSync } from "fs";
16086
16086
  import * as path7 from "path";
@@ -17421,6 +17421,7 @@ async function handleArchiveCommand(directory, args) {
17421
17421
  init_manager();
17422
17422
 
17423
17423
  // src/state.ts
17424
+ init_plan_schema();
17424
17425
  var swarmState = {
17425
17426
  activeToolCalls: new Map,
17426
17427
  toolAggregates: new Map,
@@ -17429,6 +17430,17 @@ var swarmState = {
17429
17430
  pendingEvents: 0,
17430
17431
  agentSessions: new Map
17431
17432
  };
17433
+ function getAgentSession(sessionId) {
17434
+ return swarmState.agentSessions.get(sessionId);
17435
+ }
17436
+ function hasActiveTurboMode() {
17437
+ for (const [_sessionId, session] of swarmState.agentSessions) {
17438
+ if (session.turboMode === true) {
17439
+ return true;
17440
+ }
17441
+ }
17442
+ return false;
17443
+ }
17432
17444
 
17433
17445
  // src/commands/benchmark.ts
17434
17446
  init_utils();
@@ -30954,6 +30966,7 @@ function serializeAgentSession(s) {
30954
30966
  architectWriteCount: s.architectWriteCount ?? 0,
30955
30967
  lastCoderDelegationTaskId: s.lastCoderDelegationTaskId ?? null,
30956
30968
  currentTaskId: s.currentTaskId ?? null,
30969
+ turboMode: s.turboMode ?? false,
30957
30970
  gateLog,
30958
30971
  reviewerCallCount,
30959
30972
  lastGateFailure: s.lastGateFailure ?? null,
@@ -35639,7 +35652,8 @@ async function getStatusData(directory, agents) {
35639
35652
  completedTasks: completedTasks2,
35640
35653
  totalTasks: totalTasks2,
35641
35654
  agentCount: agentCount2,
35642
- isLegacy: false
35655
+ isLegacy: false,
35656
+ turboMode: hasActiveTurboMode()
35643
35657
  };
35644
35658
  }
35645
35659
  const planContent = await readSwarmFileAsync(directory, "plan.md");
@@ -35650,7 +35664,8 @@ async function getStatusData(directory, agents) {
35650
35664
  completedTasks: 0,
35651
35665
  totalTasks: 0,
35652
35666
  agentCount: Object.keys(agents).length,
35653
- isLegacy: true
35667
+ isLegacy: true,
35668
+ turboMode: hasActiveTurboMode()
35654
35669
  };
35655
35670
  }
35656
35671
  const currentPhase = extractCurrentPhase(planContent) || "Unknown";
@@ -35664,7 +35679,8 @@ async function getStatusData(directory, agents) {
35664
35679
  completedTasks,
35665
35680
  totalTasks,
35666
35681
  agentCount,
35667
- isLegacy: true
35682
+ isLegacy: true,
35683
+ turboMode: hasActiveTurboMode()
35668
35684
  };
35669
35685
  }
35670
35686
  function formatStatusMarkdown(status) {
@@ -35675,6 +35691,9 @@ function formatStatusMarkdown(status) {
35675
35691
  `**Tasks**: ${status.completedTasks}/${status.totalTasks} complete`,
35676
35692
  `**Agents**: ${status.agentCount} registered`
35677
35693
  ];
35694
+ if (status.turboMode) {
35695
+ lines.push("", `**TURBO MODE**: active`);
35696
+ }
35678
35697
  return lines.join(`
35679
35698
  `);
35680
35699
  }
@@ -35710,6 +35729,32 @@ No active swarm plan found. Nothing to sync.`;
35710
35729
  `);
35711
35730
  }
35712
35731
 
35732
+ // src/commands/turbo.ts
35733
+ async function handleTurboCommand(_directory, args, sessionID) {
35734
+ if (!sessionID || sessionID.trim() === "") {
35735
+ return "Error: No active session context. Turbo Mode requires an active session. Use /swarm turbo from within an OpenCode session, or start a session first.";
35736
+ }
35737
+ const session = getAgentSession(sessionID);
35738
+ if (!session) {
35739
+ return "Error: No active session. Turbo Mode requires an active session to operate.";
35740
+ }
35741
+ const arg = args[0]?.toLowerCase();
35742
+ let newTurboMode;
35743
+ let feedback;
35744
+ if (arg === "on") {
35745
+ newTurboMode = true;
35746
+ feedback = "Turbo Mode enabled";
35747
+ } else if (arg === "off") {
35748
+ newTurboMode = false;
35749
+ feedback = "Turbo Mode disabled";
35750
+ } else {
35751
+ newTurboMode = !session.turboMode;
35752
+ feedback = newTurboMode ? "Turbo Mode enabled" : "Turbo Mode disabled";
35753
+ }
35754
+ session.turboMode = newTurboMode;
35755
+ return feedback;
35756
+ }
35757
+
35713
35758
  // src/tools/write-retro.ts
35714
35759
  init_manager();
35715
35760
  async function executeWriteRetro(args, directory) {
@@ -35864,6 +35909,7 @@ var HELP_TEXT = [
35864
35909
  "- `/swarm knowledge migrate` \u2014 Migrate knowledge entries to the current format",
35865
35910
  '- `/swarm promote "<lesson>" | --category <cat> | --from-swarm <id> \u2014 Manually promote lesson to hive knowledge',
35866
35911
  "- `/swarm handoff` \u2014 Prepare state for clean model switch (new session)",
35912
+ "- `/swarm turbo [on|off]` \u2014 Toggle Turbo Mode for the active session (default: toggle)",
35867
35913
  "- `/swarm write-retro <json>` \u2014 Write a retrospective evidence bundle for a completed phase"
35868
35914
  ].join(`
35869
35915
  `);
@@ -36126,6 +36172,11 @@ Run "bunx opencode-swarm --help" for a list of commands.`);
36126
36172
  console.log(result);
36127
36173
  return 0;
36128
36174
  }
36175
+ case "turbo": {
36176
+ const result = await handleTurboCommand(cwd, args.slice(1), "");
36177
+ console.log(result);
36178
+ return 0;
36179
+ }
36129
36180
  case "knowledge": {
36130
36181
  const knowledgeSubcmd = args[1];
36131
36182
  if (knowledgeSubcmd === "migrate") {
@@ -24,6 +24,7 @@ export { handleSimulateCommand } from './simulate';
24
24
  export { handleSpecifyCommand } from './specify';
25
25
  export { handleStatusCommand } from './status';
26
26
  export { handleSyncPlanCommand } from './sync-plan';
27
+ export { handleTurboCommand } from './turbo';
27
28
  export { handleWriteRetroCommand } from './write_retro';
28
29
  /**
29
30
  * Creates a command.execute.before handler for /swarm commands.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for Task 3.12: Turbo Mode command registration in src/commands/index.ts
3
+ * Verifies import, export, help text, and switch case routing for /swarm turbo
4
+ */
5
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for Task 3.13: Empty sessionID handling in handleTurboCommand
3
+ * Tests the CLI wiring fix where empty sessionID returns proper error message
4
+ */
5
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Handles the /swarm turbo command.
3
+ * Toggles Turbo Mode on or off for the active session.
4
+ *
5
+ * @param directory - Project directory (unused but kept for consistency with other commands)
6
+ * @param args - Optional argument: "on" | "off" | undefined (toggle behavior)
7
+ * @param sessionID - Session ID for accessing active session state
8
+ * @returns Feedback message about Turbo Mode state
9
+ */
10
+ export declare function handleTurboCommand(_directory: string, args: string[], sessionID: string): Promise<string>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Regression Tests for Task 4: Turbo Mode Integration
3
+ *
4
+ * These tests verify that Turbo Mode is correctly integrated across all surfaces:
5
+ * 1. /swarm turbo command toggles turboMode correctly
6
+ * 2. checkReviewerGate bypasses Stage B when turboMode is active AND task is not Tier 3
7
+ * 3. Evidence records include turbo flag when recorded under turboMode
8
+ * 4. Architect prompt includes TURBO MODE ACTIVE banner when active
9
+ * 5. Status output shows TURBO MODE indicator when active
10
+ */
11
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for Task 3.11: handleTurboCommand function
3
+ * Tests the /swarm turbo command toggle functionality
4
+ */
5
+ export {};
@@ -6,8 +6,8 @@ export declare const EvidenceTypeSchema: z.ZodEnum<{
6
6
  diff: "diff";
7
7
  quality_budget: "quality_budget";
8
8
  placeholder: "placeholder";
9
- review: "review";
10
9
  test: "test";
10
+ review: "review";
11
11
  approval: "approval";
12
12
  note: "note";
13
13
  retrospective: "retrospective";
@@ -31,8 +31,8 @@ export declare const BaseEvidenceSchema: z.ZodObject<{
31
31
  diff: "diff";
32
32
  quality_budget: "quality_budget";
33
33
  placeholder: "placeholder";
34
- review: "review";
35
34
  test: "test";
35
+ review: "review";
36
36
  approval: "approval";
37
37
  note: "note";
38
38
  retrospective: "retrospective";
@@ -69,8 +69,8 @@ export declare const ReviewEvidenceSchema: z.ZodObject<{
69
69
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
70
70
  type: z.ZodLiteral<"review">;
71
71
  risk: z.ZodEnum<{
72
- low: "low";
73
72
  medium: "medium";
73
+ low: "low";
74
74
  high: "high";
75
75
  critical: "critical";
76
76
  }>;
@@ -295,8 +295,8 @@ export declare const SastEvidenceSchema: z.ZodObject<{
295
295
  findings: z.ZodDefault<z.ZodArray<z.ZodObject<{
296
296
  rule_id: z.ZodString;
297
297
  severity: z.ZodEnum<{
298
- low: "low";
299
298
  medium: "medium";
299
+ low: "low";
300
300
  high: "high";
301
301
  critical: "critical";
302
302
  }>;
@@ -447,8 +447,8 @@ export declare const EvidenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
447
447
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
448
448
  type: z.ZodLiteral<"review">;
449
449
  risk: z.ZodEnum<{
450
- low: "low";
451
450
  medium: "medium";
451
+ low: "low";
452
452
  high: "high";
453
453
  critical: "critical";
454
454
  }>;
@@ -657,8 +657,8 @@ export declare const EvidenceSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
657
657
  findings: z.ZodDefault<z.ZodArray<z.ZodObject<{
658
658
  rule_id: z.ZodString;
659
659
  severity: z.ZodEnum<{
660
- low: "low";
661
660
  medium: "medium";
661
+ low: "low";
662
662
  high: "high";
663
663
  critical: "critical";
664
664
  }>;
@@ -806,8 +806,8 @@ export declare const EvidenceBundleSchema: z.ZodObject<{
806
806
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
807
807
  type: z.ZodLiteral<"review">;
808
808
  risk: z.ZodEnum<{
809
- low: "low";
810
809
  medium: "medium";
810
+ low: "low";
811
811
  high: "high";
812
812
  critical: "critical";
813
813
  }>;
@@ -1016,8 +1016,8 @@ export declare const EvidenceBundleSchema: z.ZodObject<{
1016
1016
  findings: z.ZodDefault<z.ZodArray<z.ZodObject<{
1017
1017
  rule_id: z.ZodString;
1018
1018
  severity: z.ZodEnum<{
1019
- low: "low";
1020
1019
  medium: "medium";
1020
+ low: "low";
1021
1021
  high: "high";
1022
1022
  critical: "critical";
1023
1023
  }>;
@@ -19,6 +19,7 @@ export interface TaskEvidence {
19
19
  taskId: string;
20
20
  required_gates: string[];
21
21
  gates: Record<string, GateEvidence>;
22
+ turbo?: boolean;
22
23
  }
23
24
  export declare const DEFAULT_REQUIRED_GATES: string[];
24
25
  /**
@@ -50,13 +51,13 @@ export declare function expandRequiredGates(existingGates: string[], newAgentTyp
50
51
  * If file exists: merges gate entry, expands required_gates via expandRequiredGates.
51
52
  * Atomic write: temp file + rename.
52
53
  */
53
- export declare function recordGateEvidence(directory: string, taskId: string, gate: string, sessionId: string): Promise<void>;
54
+ export declare function recordGateEvidence(directory: string, taskId: string, gate: string, sessionId: string, turbo?: boolean): Promise<void>;
54
55
  /**
55
56
  * Sets or expands required_gates WITHOUT recording a gate pass.
56
57
  * Used when non-gate agents are dispatched (coder, explorer, sme, etc.).
57
58
  * Creates evidence file if it doesn't exist yet.
58
59
  */
59
- export declare function recordAgentDispatch(directory: string, taskId: string, agentType: string): Promise<void>;
60
+ export declare function recordAgentDispatch(directory: string, taskId: string, agentType: string, turbo?: boolean): Promise<void>;
60
61
  /**
61
62
  * Returns the TaskEvidence for a task, or null if file missing or parse error.
62
63
  * Never throws.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Adversarial security tests for getEvidenceTaskId plan.json fallback.
3
+ *
4
+ * Tests security-hardened fallback mechanism that reads .swarm/plan.json only after
5
+ * exhausting live task state. Focuses on attack vectors:
6
+ * - Path traversal via plan.json path
7
+ * - Malformed durable state (JSON bombs, circular refs)
8
+ * - Invalid directory inputs
9
+ * - Oversized/hostile inputs
10
+ * - Boundary violations
11
+ * - Symlink attacks
12
+ */
13
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for getEvidenceTaskId plan.json fallback behavior.
3
+ * Verifies durable task ID recovery from .swarm/plan.json when in-memory state is empty.
4
+ */
5
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tests for Task 3.16: Propagate turboMode through evidence recording
3
+ *
4
+ * This verifies that when a session has turboMode enabled, the turbo flag is
5
+ * recorded in the evidence JSON files for all agent delegations (reviewer,
6
+ * test_engineer, docs, designer, critic, explorer, sme, coder).
7
+ */
8
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};