opencode-swarm 6.20.2 → 6.21.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.
- package/README.md +63 -1
- package/dist/cli/index.js +4 -2
- package/dist/config/constants.d.ts +14 -0
- package/dist/index.js +786 -343
- package/dist/state.d.ts +42 -0
- package/dist/tools/declare-scope.d.ts +49 -0
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/tool-names.d.ts +1 -1
- package/dist/tools/update-task-status.d.ts +15 -0
- package/package.json +1 -1
package/dist/state.d.ts
CHANGED
|
@@ -33,6 +33,11 @@ export interface DelegationEntry {
|
|
|
33
33
|
to: string;
|
|
34
34
|
timestamp: number;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Per-task workflow state for gate progression tracking.
|
|
38
|
+
* Transitions must be forward-only: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
|
|
39
|
+
*/
|
|
40
|
+
export type TaskWorkflowState = 'idle' | 'coder_delegated' | 'pre_check_passed' | 'reviewer_run' | 'tests_run' | 'complete';
|
|
36
41
|
/**
|
|
37
42
|
* Represents per-session state for guardrail tracking.
|
|
38
43
|
* Budget fields (toolCallCount, consecutiveErrors, etc.) have moved to InvocationWindow.
|
|
@@ -81,6 +86,23 @@ export interface AgentSessionState {
|
|
|
81
86
|
qaSkipCount: number;
|
|
82
87
|
/** Task IDs skipped without QA (for audit trail), reset when reviewer/test_engineer fires */
|
|
83
88
|
qaSkipTaskIds: string[];
|
|
89
|
+
/** Per-task workflow state — taskId → current state */
|
|
90
|
+
taskWorkflowStates: Map<string, TaskWorkflowState>;
|
|
91
|
+
/** Last gate outcome for deliberation preamble injection */
|
|
92
|
+
lastGateOutcome: {
|
|
93
|
+
gate: string;
|
|
94
|
+
taskId: string;
|
|
95
|
+
passed: boolean;
|
|
96
|
+
timestamp: number;
|
|
97
|
+
} | null;
|
|
98
|
+
/** Declared file scope for current coder task (null = no scope declared) */
|
|
99
|
+
declaredCoderScope: string[] | null;
|
|
100
|
+
/** Last scope violation message (null = no violation) */
|
|
101
|
+
lastScopeViolation: string | null;
|
|
102
|
+
/** Flag for one-shot scope violation warning injection in messagesTransform */
|
|
103
|
+
scopeViolationDetected?: boolean;
|
|
104
|
+
/** Files modified by the current coder task (populated by guardrails toolBefore/toolAfter, reset on new coder delegation) */
|
|
105
|
+
modifiedFilesThisCoderTask: string[];
|
|
84
106
|
/** Timestamp of most recent phase completion */
|
|
85
107
|
lastPhaseCompleteTimestamp: number;
|
|
86
108
|
/** Phase number of most recent phase completion */
|
|
@@ -209,3 +231,23 @@ export declare function pruneOldWindows(sessionId: string, maxAgeMs?: number, ma
|
|
|
209
231
|
* @param agentName - Agent name to record (will be normalized)
|
|
210
232
|
*/
|
|
211
233
|
export declare function recordPhaseAgentDispatch(sessionId: string, agentName: string): void;
|
|
234
|
+
/**
|
|
235
|
+
* Advance a task's workflow state. Validates forward-only transitions.
|
|
236
|
+
* Throws 'INVALID_TASK_STATE_TRANSITION: [taskId] [current] → [requested]' on illegal transition.
|
|
237
|
+
*
|
|
238
|
+
* Valid forward order: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
|
|
239
|
+
*
|
|
240
|
+
* @param session - The agent session state
|
|
241
|
+
* @param taskId - The task identifier
|
|
242
|
+
* @param newState - The requested new state
|
|
243
|
+
*/
|
|
244
|
+
export declare function advanceTaskState(session: AgentSessionState, taskId: string, newState: TaskWorkflowState): void;
|
|
245
|
+
/**
|
|
246
|
+
* Get the current workflow state for a task.
|
|
247
|
+
* Returns 'idle' if no entry exists.
|
|
248
|
+
*
|
|
249
|
+
* @param session - The agent session state
|
|
250
|
+
* @param taskId - The task identifier
|
|
251
|
+
* @returns Current task workflow state
|
|
252
|
+
*/
|
|
253
|
+
export declare function getTaskState(session: AgentSessionState, taskId: string): TaskWorkflowState;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declare scope tool for setting the file scope for coder delegations.
|
|
3
|
+
* Implements FR-010: Declare coder scope before delegation.
|
|
4
|
+
* This tool must be called before delegating to mega_coder to enable scope containment checking.
|
|
5
|
+
*/
|
|
6
|
+
import { type ToolDefinition } from '@opencode-ai/plugin/tool';
|
|
7
|
+
/**
|
|
8
|
+
* Arguments for the declare_scope tool
|
|
9
|
+
*/
|
|
10
|
+
export interface DeclareScopeArgs {
|
|
11
|
+
taskId: string;
|
|
12
|
+
files: string[];
|
|
13
|
+
whitelist?: string[];
|
|
14
|
+
working_directory?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result from executing declare_scope
|
|
18
|
+
*/
|
|
19
|
+
export interface DeclareScopeResult {
|
|
20
|
+
success: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
taskId?: string;
|
|
23
|
+
fileCount?: number;
|
|
24
|
+
errors?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validate that taskId matches the required format (N.M or N.M.P).
|
|
28
|
+
* @param taskId - The task ID to validate
|
|
29
|
+
* @returns Error message if invalid, undefined if valid
|
|
30
|
+
*/
|
|
31
|
+
export declare function validateTaskIdFormat(taskId: string): string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Validate file entries for security concerns.
|
|
34
|
+
* @param files - Array of file paths to validate
|
|
35
|
+
* @returns Array of error messages, empty if all valid
|
|
36
|
+
*/
|
|
37
|
+
export declare function validateFiles(files: string[]): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Execute the declare_scope tool.
|
|
40
|
+
* Validates the taskId and files, then sets the declared scope on all active architect sessions.
|
|
41
|
+
* @param args - The declare scope arguments
|
|
42
|
+
* @param fallbackDir - Fallback directory for plan lookup
|
|
43
|
+
* @returns DeclareScopeResult with success status and details
|
|
44
|
+
*/
|
|
45
|
+
export declare function executeDeclareScope(args: DeclareScopeArgs, fallbackDir?: string): Promise<DeclareScopeResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Tool definition for declare_scope
|
|
48
|
+
*/
|
|
49
|
+
export declare const declare_scope: ToolDefinition;
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { build_check } from './build-check';
|
|
2
2
|
export { checkpoint } from './checkpoint';
|
|
3
3
|
export { complexity_hotspots } from './complexity-hotspots';
|
|
4
|
+
export { declare_scope } from './declare-scope';
|
|
4
5
|
export { type DiffErrorResult, type DiffResult, diff } from './diff';
|
|
5
6
|
export { detect_domains } from './domain-detector';
|
|
6
7
|
export { evidence_check } from './evidence-check';
|
|
@@ -23,6 +24,6 @@ export { type SecretFinding, type SecretscanResult, secretscan, } from './secret
|
|
|
23
24
|
export { symbols } from './symbols';
|
|
24
25
|
export { type SyntaxCheckFileResult, type SyntaxCheckInput, type SyntaxCheckResult, syntaxCheck, } from './syntax-check';
|
|
25
26
|
export { test_runner } from './test-runner';
|
|
26
|
-
export { type UpdateTaskStatusArgs, type UpdateTaskStatusResult, executeUpdateTaskStatus, update_task_status, } from './update-task-status';
|
|
27
27
|
export { todo_extract } from './todo-extract';
|
|
28
|
+
export { executeUpdateTaskStatus, type UpdateTaskStatusArgs, type UpdateTaskStatusResult, update_task_status, } from './update-task-status';
|
|
28
29
|
export { executeWriteRetro, write_retro } from './write-retro';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Used for constants and agent setup references.
|
|
4
4
|
*/
|
|
5
5
|
/** Union type of all valid tool names */
|
|
6
|
-
export type ToolName = 'diff' | 'syntax_check' | 'placeholder_scan' | 'imports' | 'lint' | 'secretscan' | 'sast_scan' | 'build_check' | 'pre_check_batch' | 'quality_budget' | 'symbols' | 'complexity_hotspots' | 'schema_drift' | 'todo_extract' | 'evidence_check' | 'sbom_generate' | 'checkpoint' | 'pkg_audit' | 'test_runner' | 'detect_domains' | 'gitingest' | 'retrieve_summary' | 'extract_code_blocks' | 'phase_complete' | 'save_plan' | 'update_task_status' | 'write_retro';
|
|
6
|
+
export type ToolName = 'diff' | 'syntax_check' | 'placeholder_scan' | 'imports' | 'lint' | 'secretscan' | 'sast_scan' | 'build_check' | 'pre_check_batch' | 'quality_budget' | 'symbols' | 'complexity_hotspots' | 'schema_drift' | 'todo_extract' | 'evidence_check' | 'sbom_generate' | 'checkpoint' | 'pkg_audit' | 'test_runner' | 'detect_domains' | 'gitingest' | 'retrieve_summary' | 'extract_code_blocks' | 'phase_complete' | 'save_plan' | 'update_task_status' | 'write_retro' | 'declare_scope';
|
|
7
7
|
/** Readonly array of all tool names */
|
|
8
8
|
export declare const TOOL_NAMES: readonly ToolName[];
|
|
9
9
|
/** Set for O(1) tool name validation */
|
|
@@ -34,6 +34,21 @@ export declare function validateStatus(status: string): string | undefined;
|
|
|
34
34
|
* @returns Error message if invalid, undefined if valid
|
|
35
35
|
*/
|
|
36
36
|
export declare function validateTaskId(taskId: string): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Result from checking reviewer gate presence
|
|
39
|
+
*/
|
|
40
|
+
export interface ReviewerGateResult {
|
|
41
|
+
blocked: boolean;
|
|
42
|
+
reason: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Check if a task has passed required QA gates using the state machine.
|
|
46
|
+
* Requires the task to be in 'tests_run' or 'complete' state, which means
|
|
47
|
+
* both reviewer delegation and test_engineer runs have been recorded.
|
|
48
|
+
* @param taskId - The task ID to check gate state for
|
|
49
|
+
* @returns ReviewerGateResult indicating whether the gate is blocked
|
|
50
|
+
*/
|
|
51
|
+
export declare function checkReviewerGate(taskId: string): ReviewerGateResult;
|
|
37
52
|
/**
|
|
38
53
|
* Execute the update_task_status tool.
|
|
39
54
|
* Validates the task_id and status, then updates the task status in the plan.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.21.0",
|
|
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",
|