opencode-swarm 6.17.3 → 6.18.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.
- package/README.md +1 -1
- package/dist/background/queue.d.ts +1 -0
- package/dist/background/trigger.d.ts +1 -1
- package/dist/cli/index.js +4464 -3248
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/reset.d.ts +1 -0
- package/dist/commands/rollback.d.ts +5 -0
- package/dist/commands/simulate.d.ts +5 -0
- package/dist/commands/write_retro.d.ts +1 -0
- package/dist/hooks/co-change-suggester.d.ts +51 -0
- package/dist/hooks/dark-matter-detector.d.ts +38 -0
- package/dist/hooks/guardrails.d.ts +2 -1
- package/dist/hooks/knowledge-curator.d.ts +5 -0
- package/dist/hooks/steering-consumed.d.ts +30 -0
- package/dist/index.js +4101 -2866
- package/dist/session/snapshot-reader.d.ts +29 -0
- package/dist/session/snapshot-writer.d.ts +83 -0
- package/dist/tools/co-change-analyzer.d.ts +2 -0
- package/dist/tools/create-tool.d.ts +15 -0
- package/dist/tools/index.d.ts +4 -3
- package/dist/tools/phase-complete.d.ts +1 -1
- package/dist/tools/sast-scan.d.ts +8 -0
- package/dist/tools/save-plan.d.ts +1 -1
- package/dist/tools/write-retro.d.ts +53 -0
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session snapshot reader for OpenCode Swarm plugin.
|
|
3
|
+
* Reads .swarm/session/state.json and rehydrates swarmState on plugin init.
|
|
4
|
+
*/
|
|
5
|
+
import type { AgentSessionState } from '../state';
|
|
6
|
+
import type { SerializedAgentSession, SnapshotData } from './snapshot-writer';
|
|
7
|
+
/**
|
|
8
|
+
* Deserialize a SerializedAgentSession back to AgentSessionState.
|
|
9
|
+
* Handles Map/Set conversion and migration safety defaults.
|
|
10
|
+
*/
|
|
11
|
+
export declare function deserializeAgentSession(s: SerializedAgentSession): AgentSessionState;
|
|
12
|
+
/**
|
|
13
|
+
* Read the snapshot file from .swarm/session/state.json.
|
|
14
|
+
* Returns null if file doesn't exist, parse fails, or version is wrong.
|
|
15
|
+
* NEVER throws - always returns null on any error.
|
|
16
|
+
*/
|
|
17
|
+
export declare function readSnapshot(directory: string): Promise<SnapshotData | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Rehydrate swarmState from a SnapshotData object.
|
|
20
|
+
* Clears existing maps first, then populates from snapshot.
|
|
21
|
+
* Does NOT touch activeToolCalls or pendingEvents (remain at defaults).
|
|
22
|
+
*/
|
|
23
|
+
export declare function rehydrateState(snapshot: SnapshotData): void;
|
|
24
|
+
/**
|
|
25
|
+
* Load snapshot from disk and rehydrate swarmState.
|
|
26
|
+
* Called on plugin init to restore state from previous session.
|
|
27
|
+
* NEVER throws - swallows any errors silently.
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadSnapshot(directory: string): Promise<void>;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session snapshot writer for OpenCode Swarm plugin.
|
|
3
|
+
* Serializes swarmState to .swarm/session/state.json using atomic write (temp-file + rename).
|
|
4
|
+
*/
|
|
5
|
+
import type { AgentSessionState, DelegationEntry, ToolAggregate } from '../state';
|
|
6
|
+
import { swarmState } from '../state';
|
|
7
|
+
/**
|
|
8
|
+
* Serialized form of AgentSessionState with Map/Set fields converted to plain arrays/objects
|
|
9
|
+
*/
|
|
10
|
+
export interface SerializedAgentSession {
|
|
11
|
+
agentName: string;
|
|
12
|
+
lastToolCallTime: number;
|
|
13
|
+
lastAgentEventTime: number;
|
|
14
|
+
delegationActive: boolean;
|
|
15
|
+
activeInvocationId: number;
|
|
16
|
+
lastInvocationIdByAgent: Record<string, number>;
|
|
17
|
+
windows: Record<string, SerializedInvocationWindow>;
|
|
18
|
+
lastCompactionHint: number;
|
|
19
|
+
architectWriteCount: number;
|
|
20
|
+
lastCoderDelegationTaskId: string | null;
|
|
21
|
+
currentTaskId: string | null;
|
|
22
|
+
gateLog: Record<string, string[]>;
|
|
23
|
+
reviewerCallCount: Record<string, number>;
|
|
24
|
+
lastGateFailure: {
|
|
25
|
+
tool: string;
|
|
26
|
+
taskId: string;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
} | null;
|
|
29
|
+
partialGateWarningsIssuedForTask: string[];
|
|
30
|
+
selfFixAttempted: boolean;
|
|
31
|
+
catastrophicPhaseWarnings: number[];
|
|
32
|
+
lastPhaseCompleteTimestamp: number;
|
|
33
|
+
lastPhaseCompletePhase: number;
|
|
34
|
+
phaseAgentsDispatched: string[];
|
|
35
|
+
qaSkipCount: number;
|
|
36
|
+
qaSkipTaskIds: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Minimal interface for serialized InvocationWindow
|
|
40
|
+
*/
|
|
41
|
+
interface SerializedInvocationWindow {
|
|
42
|
+
id: number;
|
|
43
|
+
agentName: string;
|
|
44
|
+
startedAtMs: number;
|
|
45
|
+
toolCalls: number;
|
|
46
|
+
consecutiveErrors: number;
|
|
47
|
+
hardLimitHit: boolean;
|
|
48
|
+
lastSuccessTimeMs: number;
|
|
49
|
+
recentToolCalls: Array<{
|
|
50
|
+
tool: string;
|
|
51
|
+
argsHash: number;
|
|
52
|
+
timestamp: number;
|
|
53
|
+
}>;
|
|
54
|
+
warningIssued: boolean;
|
|
55
|
+
warningReason: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Snapshot data structure written to disk
|
|
59
|
+
*/
|
|
60
|
+
export interface SnapshotData {
|
|
61
|
+
version: 1;
|
|
62
|
+
writtenAt: number;
|
|
63
|
+
toolAggregates: Record<string, ToolAggregate>;
|
|
64
|
+
activeAgent: Record<string, string>;
|
|
65
|
+
delegationChains: Record<string, DelegationEntry[]>;
|
|
66
|
+
agentSessions: Record<string, SerializedAgentSession>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Convert a live AgentSessionState to its serialized form.
|
|
70
|
+
* Handles missing/undefined Map/Set fields gracefully (migration safety).
|
|
71
|
+
*/
|
|
72
|
+
export declare function serializeAgentSession(s: AgentSessionState): SerializedAgentSession;
|
|
73
|
+
/**
|
|
74
|
+
* Write a snapshot of swarmState to .swarm/session/state.json atomically.
|
|
75
|
+
* Silently swallows errors (non-fatal — never crash the plugin).
|
|
76
|
+
*/
|
|
77
|
+
export declare function writeSnapshot(directory: string, state: typeof swarmState): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Create a snapshot writer hook suitable for use in tool.execute.after.
|
|
80
|
+
* Returns a hook function that writes the current swarmState to disk.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createSnapshotWriterHook(directory: string): (input: unknown, output: unknown) => Promise<void>;
|
|
83
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tool } from '@opencode-ai/plugin';
|
|
1
2
|
import type { SwarmKnowledgeEntry } from '../hooks/knowledge-types.js';
|
|
2
3
|
export interface CoChangeEntry {
|
|
3
4
|
fileA: string;
|
|
@@ -41,3 +42,4 @@ export declare function darkMatterToKnowledgeEntries(pairs: CoChangeEntry[], pro
|
|
|
41
42
|
* Formats dark matter findings as markdown output.
|
|
42
43
|
*/
|
|
43
44
|
export declare function formatDarkMatterOutput(pairs: CoChangeEntry[]): string;
|
|
45
|
+
export declare const co_change_analyzer: ReturnType<typeof tool>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { tool } from '@opencode-ai/plugin';
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a swarm tool.
|
|
4
|
+
* The args type is inferred from what you pass to the tool() call.
|
|
5
|
+
*/
|
|
6
|
+
export interface SwarmToolOptions<Args extends Record<string, unknown>> {
|
|
7
|
+
description: string;
|
|
8
|
+
args: Args;
|
|
9
|
+
execute: (args: Args, directory: string) => Promise<string>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a swarm tool with automatic working directory injection.
|
|
13
|
+
* Wraps the @opencode-ai/plugin/tool factory to always inject `directory` into tool execute callbacks.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createSwarmTool<Args extends Record<string, unknown>>(opts: SwarmToolOptions<Args>): ReturnType<typeof tool>;
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -9,14 +9,14 @@ export { fetchGitingest, type GitingestArgs, gitingest } from './gitingest';
|
|
|
9
9
|
export { imports } from './imports';
|
|
10
10
|
export { lint } from './lint';
|
|
11
11
|
export { phase_complete } from './phase-complete';
|
|
12
|
-
export { save_plan } from './save-plan';
|
|
13
|
-
export type { SavePlanArgs, SavePlanResult } from './save-plan';
|
|
14
12
|
export { pkg_audit } from './pkg-audit';
|
|
15
13
|
export { type PlaceholderFinding, type PlaceholderScanInput, type PlaceholderScanResult, placeholderScan, } from './placeholder-scan';
|
|
16
14
|
export { type PreCheckBatchInput, type PreCheckBatchResult, pre_check_batch, runPreCheckBatch, type ToolResult, } from './pre-check-batch';
|
|
17
15
|
export { type QualityBudgetInput, type QualityBudgetResult, qualityBudget, } from './quality-budget';
|
|
18
16
|
export { retrieve_summary } from './retrieve-summary';
|
|
19
|
-
export { type SastScanFinding, type SastScanInput, type SastScanResult, sastScan, } from './sast-scan';
|
|
17
|
+
export { type SastScanFinding, type SastScanInput, type SastScanResult, sast_scan, sastScan, } from './sast-scan';
|
|
18
|
+
export type { SavePlanArgs, SavePlanResult } from './save-plan';
|
|
19
|
+
export { save_plan } from './save-plan';
|
|
20
20
|
export { type SbomGenerateInput, type SbomGenerateResult, sbom_generate, } from './sbom-generate';
|
|
21
21
|
export { schema_drift } from './schema-drift';
|
|
22
22
|
export { type SecretFinding, type SecretscanResult, secretscan, } from './secretscan';
|
|
@@ -24,3 +24,4 @@ export { symbols } from './symbols';
|
|
|
24
24
|
export { type SyntaxCheckFileResult, type SyntaxCheckInput, type SyntaxCheckResult, syntaxCheck, } from './syntax-check';
|
|
25
25
|
export { test_runner } from './test-runner';
|
|
26
26
|
export { todo_extract } from './todo-extract';
|
|
27
|
+
export { executeWriteRetro, write_retro } from './write-retro';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Phase completion tool for tracking and validating phase completion.
|
|
3
3
|
* Core implementation - gathers data, enforces policy, writes event, resets state.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { ToolDefinition } from '@opencode-ai/plugin/tool';
|
|
6
6
|
/**
|
|
7
7
|
* Arguments for the phase_complete tool
|
|
8
8
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* SAST Scan Tool - Static Application Security Testing
|
|
3
3
|
* Integrates Tier A rules (offline) and optional Semgrep (Tier B)
|
|
4
4
|
*/
|
|
5
|
+
import type { ToolDefinition } from '@opencode-ai/plugin/tool';
|
|
5
6
|
import type { PluginConfig } from '../config';
|
|
6
7
|
import type { EvidenceVerdict } from '../config/evidence-schema';
|
|
7
8
|
export interface SastScanInput {
|
|
@@ -50,3 +51,10 @@ export interface SastScanFinding {
|
|
|
50
51
|
* - Tier B: Semgrep (optional, if available on PATH)
|
|
51
52
|
*/
|
|
52
53
|
export declare function sastScan(input: SastScanInput, directory: string, config?: PluginConfig): Promise<SastScanResult>;
|
|
54
|
+
/**
|
|
55
|
+
* SAST Scan tool - Static Application Security Testing
|
|
56
|
+
* Scans changed files for security vulnerabilities using:
|
|
57
|
+
* - Tier A: Built-in pattern-based rules (always runs)
|
|
58
|
+
* - Tier B: Semgrep (optional, if available on PATH)
|
|
59
|
+
*/
|
|
60
|
+
export declare const sast_scan: ToolDefinition;
|
|
@@ -47,7 +47,7 @@ export declare function detectPlaceholderContent(args: SavePlanArgs): string[];
|
|
|
47
47
|
* @param args - The save plan arguments
|
|
48
48
|
* @returns SavePlanResult with success status and details
|
|
49
49
|
*/
|
|
50
|
-
export declare function executeSavePlan(args: SavePlanArgs): Promise<SavePlanResult>;
|
|
50
|
+
export declare function executeSavePlan(args: SavePlanArgs, fallbackDir?: string): Promise<SavePlanResult>;
|
|
51
51
|
/**
|
|
52
52
|
* Tool definition for save_plan
|
|
53
53
|
*/
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write retro tool for persisting retrospective evidence bundles.
|
|
3
|
+
* Accepts flat retro fields from the Architect and wraps them correctly
|
|
4
|
+
* in a RetrospectiveEvidence entry before calling saveEvidence().
|
|
5
|
+
* This fixes the bug where Architect was writing flat JSON that failed EvidenceBundleSchema.parse().
|
|
6
|
+
*/
|
|
7
|
+
import { type ToolDefinition } from '@opencode-ai/plugin/tool';
|
|
8
|
+
/**
|
|
9
|
+
* Arguments for the write_retro tool
|
|
10
|
+
* User-supplied fields (the Architect provides these)
|
|
11
|
+
*/
|
|
12
|
+
export interface WriteRetroArgs {
|
|
13
|
+
/** The phase number being completed (maps to phase_number in schema) */
|
|
14
|
+
phase: number;
|
|
15
|
+
/** Human-readable phase summary (maps to summary in BaseEvidenceSchema) */
|
|
16
|
+
summary: string;
|
|
17
|
+
/** Count of tasks completed */
|
|
18
|
+
task_count: number;
|
|
19
|
+
/** Task complexity level */
|
|
20
|
+
task_complexity: 'trivial' | 'simple' | 'moderate' | 'complex';
|
|
21
|
+
/** Total number of tool calls in the phase */
|
|
22
|
+
total_tool_calls: number;
|
|
23
|
+
/** Number of coder revisions made */
|
|
24
|
+
coder_revisions: number;
|
|
25
|
+
/** Number of reviewer rejections received */
|
|
26
|
+
reviewer_rejections: number;
|
|
27
|
+
/** Number of test failures encountered */
|
|
28
|
+
test_failures: number;
|
|
29
|
+
/** Number of security findings */
|
|
30
|
+
security_findings: number;
|
|
31
|
+
/** Number of integration issues */
|
|
32
|
+
integration_issues: number;
|
|
33
|
+
/** Optional lessons learned (max 5) */
|
|
34
|
+
lessons_learned?: string[];
|
|
35
|
+
/** Optional top rejection reasons */
|
|
36
|
+
top_rejection_reasons?: string[];
|
|
37
|
+
/** Optional task ID (defaults to retro-{phase}) */
|
|
38
|
+
task_id?: string;
|
|
39
|
+
/** Optional metadata */
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Execute the write_retro tool.
|
|
44
|
+
* Validates input, builds a RetrospectiveEvidence entry, and saves to disk.
|
|
45
|
+
* @param args - The write retro arguments
|
|
46
|
+
* @param directory - Working directory
|
|
47
|
+
* @returns JSON string with success status and details
|
|
48
|
+
*/
|
|
49
|
+
export declare function executeWriteRetro(args: WriteRetroArgs, directory: string): Promise<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Tool definition for write_retro
|
|
52
|
+
*/
|
|
53
|
+
export declare const write_retro: ToolDefinition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.18.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",
|