opencode-swarm 7.51.6 → 7.52.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/dist/cli/index.js +10 -2
- package/dist/config/schema.d.ts +24 -1
- package/dist/context-map/capsule-builder.d.ts +128 -0
- package/dist/context-map/capsule-persistence.d.ts +66 -0
- package/dist/context-map/file-summary.d.ts +100 -0
- package/dist/context-map/persistence.d.ts +79 -0
- package/dist/context-map/post-agent-update.d.ts +116 -0
- package/dist/context-map/telemetry.d.ts +119 -0
- package/dist/council/types.d.ts +2 -0
- package/dist/hooks/context-capsule-inject.d.ts +78 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/index.js +2380 -1324
- package/dist/state.d.ts +6 -0
- package/dist/summaries/schema.d.ts +2 -2
- package/dist/tools/convene-council.d.ts +2 -1
- package/dist/tools/submit-phase-council-verdicts.d.ts +2 -1
- package/dist/tools/write-final-council-evidence.d.ts +1 -1
- package/dist/types/context-capsule.d.ts +115 -0
- package/dist/types/context-map.d.ts +124 -0
- package/package.json +1 -1
package/dist/state.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* and delegation chains.
|
|
8
8
|
*/
|
|
9
9
|
import type { OpencodeClient } from '@opencode-ai/sdk';
|
|
10
|
+
import type { CouncilAgent } from './council/types';
|
|
10
11
|
import { type QaGates } from './db/qa-gate-profile.js';
|
|
11
12
|
import { type EnvironmentProfile } from './environment/profile.js';
|
|
12
13
|
import type { EscalationTracker } from './prm/escalation.js';
|
|
@@ -124,6 +125,11 @@ export interface AgentSessionState {
|
|
|
124
125
|
*/
|
|
125
126
|
quorumSize: number;
|
|
126
127
|
}>;
|
|
128
|
+
/**
|
|
129
|
+
* Per-(task,round) required council members for the next submission attempt.
|
|
130
|
+
* Key format: `${taskId}:${roundNumber}`.
|
|
131
|
+
*/
|
|
132
|
+
pendingCouncilRequirements?: Map<string, Set<CouncilAgent>>;
|
|
127
133
|
/** Last gate outcome for deliberation preamble injection */
|
|
128
134
|
lastGateOutcome: {
|
|
129
135
|
gate: string;
|
|
@@ -22,8 +22,8 @@ export declare const MAX_LIST_ITEMS = 5;
|
|
|
22
22
|
/** Verdict vocabulary — mirrors the phase-council gate (APPROVE | CONCERNS | REJECT). */
|
|
23
23
|
export declare const SupervisorVerdictSchema: z.ZodEnum<{
|
|
24
24
|
APPROVE: "APPROVE";
|
|
25
|
-
REJECT: "REJECT";
|
|
26
25
|
CONCERNS: "CONCERNS";
|
|
26
|
+
REJECT: "REJECT";
|
|
27
27
|
}>;
|
|
28
28
|
export type SupervisorVerdict = z.infer<typeof SupervisorVerdictSchema>;
|
|
29
29
|
/** Count whitespace-delimited words in a string. */
|
|
@@ -120,8 +120,8 @@ export declare const ArchitectureSupervisorReportSchema: z.ZodObject<{
|
|
|
120
120
|
phase: z.ZodNumber;
|
|
121
121
|
verdict: z.ZodEnum<{
|
|
122
122
|
APPROVE: "APPROVE";
|
|
123
|
-
REJECT: "REJECT";
|
|
124
123
|
CONCERNS: "CONCERNS";
|
|
124
|
+
REJECT: "REJECT";
|
|
125
125
|
}>;
|
|
126
126
|
findings: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
127
127
|
severity: z.ZodEnum<{
|
|
@@ -29,9 +29,10 @@ export declare const ArgsSchema: z.ZodObject<{
|
|
|
29
29
|
}>;
|
|
30
30
|
verdict: z.ZodEnum<{
|
|
31
31
|
APPROVE: "APPROVE";
|
|
32
|
-
REJECT: "REJECT";
|
|
33
32
|
CONCERNS: "CONCERNS";
|
|
33
|
+
REJECT: "REJECT";
|
|
34
34
|
}>;
|
|
35
|
+
verdictRound: z.ZodOptional<z.ZodNumber>;
|
|
35
36
|
confidence: z.ZodNumber;
|
|
36
37
|
findings: z.ZodArray<z.ZodObject<{
|
|
37
38
|
severity: z.ZodEnum<{
|
|
@@ -15,9 +15,10 @@ export declare const ArgsSchema: z.ZodObject<{
|
|
|
15
15
|
}>;
|
|
16
16
|
verdict: z.ZodEnum<{
|
|
17
17
|
APPROVE: "APPROVE";
|
|
18
|
-
REJECT: "REJECT";
|
|
19
18
|
CONCERNS: "CONCERNS";
|
|
19
|
+
REJECT: "REJECT";
|
|
20
20
|
}>;
|
|
21
|
+
verdictRound: z.ZodOptional<z.ZodNumber>;
|
|
21
22
|
confidence: z.ZodNumber;
|
|
22
23
|
findings: z.ZodArray<z.ZodObject<{
|
|
23
24
|
severity: z.ZodEnum<{
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Capsule Types
|
|
3
|
+
* Role-specific context injection at delegation time for the opencode-swarm plugin.
|
|
4
|
+
* These types define the schema used by the Context Capsule feature to build
|
|
5
|
+
* targeted, role-appropriate context packages for agent delegation.
|
|
6
|
+
*
|
|
7
|
+
* Capsules are generated by the capsule builder and consumed by delegated agents
|
|
8
|
+
* to receive focused, relevant context without re-reading the entire codebase.
|
|
9
|
+
*
|
|
10
|
+
* See issue #1104, FR-003 and FR-004.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Reason a capsule was generated for a delegated agent.
|
|
14
|
+
* Named `CapsuleDelegationReason` to avoid collision with `DelegationReason`
|
|
15
|
+
* in `src/state.ts`, which serves a different purpose (tracking agent
|
|
16
|
+
* interaction history).
|
|
17
|
+
*/
|
|
18
|
+
export type CapsuleDelegationReason = 'new_task' | 'reviewer_rejection_fix' | 'critic_plan_review' | 'test_failure_fix';
|
|
19
|
+
/**
|
|
20
|
+
* Agent roles that can receive context capsules.
|
|
21
|
+
* Each role maps to a different capsule strategy determining
|
|
22
|
+
* which context is included and how it is presented.
|
|
23
|
+
*/
|
|
24
|
+
export type AgentRole = 'coder' | 'reviewer' | 'critic' | 'test_engineer' | 'sme';
|
|
25
|
+
/**
|
|
26
|
+
* A single read policy instruction within a context capsule.
|
|
27
|
+
* Tells the delegated agent whether it can trust the cached summary
|
|
28
|
+
* for a given file or must read the original source directly.
|
|
29
|
+
*/
|
|
30
|
+
export interface ReadPolicyEntry {
|
|
31
|
+
/** Relative file path this policy applies to */
|
|
32
|
+
file_path: string;
|
|
33
|
+
/** Whether the agent can trust the cached summary for this file */
|
|
34
|
+
trust_summary: boolean;
|
|
35
|
+
/** Whether the agent should read the actual file contents */
|
|
36
|
+
read_original: boolean;
|
|
37
|
+
/** Why this policy decision was made (e.g. "summary is stale", "file is small") */
|
|
38
|
+
reason: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Maps an agent role to its capsule construction strategy.
|
|
42
|
+
* Controls how much context is included and which optional
|
|
43
|
+
* sections (rejection history, coverage targets, claims) are added.
|
|
44
|
+
*/
|
|
45
|
+
export interface RoleProfile {
|
|
46
|
+
/** The agent role this profile applies to */
|
|
47
|
+
role: AgentRole;
|
|
48
|
+
/** Strategy name (e.g. "scoped_files_plus_rejection") */
|
|
49
|
+
strategy: string;
|
|
50
|
+
/** Maximum number of files to include in the capsule */
|
|
51
|
+
max_files: number;
|
|
52
|
+
/** Whether to include prior rejection context for fix iterations */
|
|
53
|
+
include_rejection: boolean;
|
|
54
|
+
/** Whether to include coverage targets (relevant for test_engineer) */
|
|
55
|
+
include_coverage: boolean;
|
|
56
|
+
/** Whether to include claimed fix or implementation details */
|
|
57
|
+
include_claims: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Metadata returned by the capsule builder after generating a capsule.
|
|
61
|
+
* Provides diagnostics on cache utilization, staleness detection,
|
|
62
|
+
* and reading recommendations for the consuming agent.
|
|
63
|
+
*/
|
|
64
|
+
export interface CapsuleMetadata {
|
|
65
|
+
/** Whether the capsule was generated successfully */
|
|
66
|
+
success: boolean;
|
|
67
|
+
/** File system path where the capsule was written */
|
|
68
|
+
capsule_path: string;
|
|
69
|
+
/** Estimated token count of the capsule content */
|
|
70
|
+
token_estimate: number;
|
|
71
|
+
/** Number of entries reused from the context map cache */
|
|
72
|
+
cache_hits: number;
|
|
73
|
+
/** Number of entries that required fresh computation */
|
|
74
|
+
cache_misses: number;
|
|
75
|
+
/** Number of stale entries detected during generation */
|
|
76
|
+
stale_entries: number;
|
|
77
|
+
/** Files the agent should still read directly despite summaries */
|
|
78
|
+
recommended_reads: string[];
|
|
79
|
+
/** Files whose cached summaries were sufficient (no direct read needed) */
|
|
80
|
+
skipped_reads: string[];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The full context capsule delivered to a delegated agent.
|
|
84
|
+
* Contains all role-specific context needed for the agent to begin
|
|
85
|
+
* work, including task goals, file scope, prior feedback, and
|
|
86
|
+
* per-file read policies.
|
|
87
|
+
*/
|
|
88
|
+
export interface ContextCapsule {
|
|
89
|
+
/** Task ID this capsule is for (e.g. "1.1", "2.3") */
|
|
90
|
+
task_id: string;
|
|
91
|
+
/** Which agent role receives this capsule */
|
|
92
|
+
agent_role: AgentRole;
|
|
93
|
+
/** Why this capsule was generated */
|
|
94
|
+
delegation_reason: CapsuleDelegationReason;
|
|
95
|
+
/** ISO 8601 timestamp of when the capsule was generated */
|
|
96
|
+
generated_at: string;
|
|
97
|
+
/** Files relevant to this task (the task's file scope) */
|
|
98
|
+
files_in_scope: string[];
|
|
99
|
+
/** What the task aims to accomplish */
|
|
100
|
+
task_goal: string;
|
|
101
|
+
/** Prior rejection reason, if this capsule is for a fix iteration */
|
|
102
|
+
prior_rejection?: string;
|
|
103
|
+
/** What needs to be fixed, if applicable */
|
|
104
|
+
required_fix?: string;
|
|
105
|
+
/** Repository facts relevant to this task */
|
|
106
|
+
relevant_facts: string[];
|
|
107
|
+
/** Review checklist items, included for reviewer capsules */
|
|
108
|
+
review_checklist?: string[];
|
|
109
|
+
/** Coverage targets, included for test_engineer capsules */
|
|
110
|
+
coverage_targets?: string[];
|
|
111
|
+
/** Per-file read policy: which summaries to trust vs which files to read */
|
|
112
|
+
read_policy: ReadPolicyEntry[];
|
|
113
|
+
/** The full markdown content of the capsule */
|
|
114
|
+
content: string;
|
|
115
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context Map Types
|
|
3
|
+
* Durable data model for cross-agent context sharing in the opencode-swarm plugin.
|
|
4
|
+
* These types define the schema used by the Context Map feature to capture
|
|
5
|
+
* file-level summaries, task history, and architectural decisions for
|
|
6
|
+
* efficient context injection across agent interactions.
|
|
7
|
+
*
|
|
8
|
+
* The Context Map is opt-in (enabled=false by default) and uses SHA-256
|
|
9
|
+
* content hashes for file invalidation detection.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Branded type alias for a SHA-256 content hash string.
|
|
13
|
+
* Always a 64-character lowercase hex string produced by hashing file contents.
|
|
14
|
+
*/
|
|
15
|
+
export type ContentHash = string;
|
|
16
|
+
/**
|
|
17
|
+
* Summary of a single source file in the context map.
|
|
18
|
+
* Provides a condensed view of file contents, structure, and metadata
|
|
19
|
+
* to enable efficient cross-agent context sharing without re-reading full files.
|
|
20
|
+
*/
|
|
21
|
+
export interface FileContextEntry {
|
|
22
|
+
/** Relative file path within the project */
|
|
23
|
+
path: string;
|
|
24
|
+
/** SHA-256 hash of file contents for invalidation detection */
|
|
25
|
+
content_hash: ContentHash;
|
|
26
|
+
/** File modification timestamp in milliseconds since epoch (fast pre-check) */
|
|
27
|
+
mtime_ms: number;
|
|
28
|
+
/** Programming language (e.g. "typescript", "javascript", "python") */
|
|
29
|
+
language?: string;
|
|
30
|
+
/** One-to-two sentence description of what this file does */
|
|
31
|
+
purpose: string;
|
|
32
|
+
/** Exported symbol names from this file */
|
|
33
|
+
exports?: string[];
|
|
34
|
+
/** Imported module paths referenced by this file */
|
|
35
|
+
imports?: string[];
|
|
36
|
+
/** Important types, functions, or classes defined in this file */
|
|
37
|
+
key_symbols?: string[];
|
|
38
|
+
/** Observed constraints or rules governing this file's behavior */
|
|
39
|
+
invariants?: string[];
|
|
40
|
+
/** Detected risk factors (complexity, churn, fragility, etc.) */
|
|
41
|
+
risks?: string[];
|
|
42
|
+
/** Related test file paths covering this file */
|
|
43
|
+
tests?: string[];
|
|
44
|
+
/** Task IDs that last accessed or modified this file */
|
|
45
|
+
last_seen_task_ids?: string[];
|
|
46
|
+
/** Natural language summary of file purpose and key behavior */
|
|
47
|
+
summary: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Summary of a completed or in-progress task within the context map.
|
|
51
|
+
* Captures what a task set out to do, what files it touched, and
|
|
52
|
+
* the evidence from reviewer, critic, and test gates.
|
|
53
|
+
*/
|
|
54
|
+
export interface TaskContextSummary {
|
|
55
|
+
/** Unique task identifier (e.g. "1.1", "2.3") */
|
|
56
|
+
task_id: string;
|
|
57
|
+
/** What the task was supposed to accomplish */
|
|
58
|
+
goal: string;
|
|
59
|
+
/** Files modified during the task */
|
|
60
|
+
files_touched: string[];
|
|
61
|
+
/** Natural language description of what was actually implemented */
|
|
62
|
+
implementation_summary?: string;
|
|
63
|
+
/** Reviewer feedback extracted from evidence files */
|
|
64
|
+
reviewer_findings?: string[];
|
|
65
|
+
/** Critic feedback extracted from evidence files */
|
|
66
|
+
critic_findings?: string[];
|
|
67
|
+
/** Test results extracted from evidence files */
|
|
68
|
+
test_findings?: string[];
|
|
69
|
+
/** Final disposition of the task after QA gates */
|
|
70
|
+
final_status: 'pending' | 'approved' | 'rejected' | 'blocked';
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Architectural decision made during a session, captured in the context map.
|
|
74
|
+
* These decisions provide reasoning context for future agents to understand
|
|
75
|
+
* why certain approaches were chosen or rejected.
|
|
76
|
+
*/
|
|
77
|
+
export interface DecisionEntry {
|
|
78
|
+
/** Unique identifier for the decision (e.g. "D1", "D2") */
|
|
79
|
+
id: string;
|
|
80
|
+
/** The actual decision text describing what was decided */
|
|
81
|
+
decision: string;
|
|
82
|
+
/** Rationale explaining why this decision was made */
|
|
83
|
+
rationale: string;
|
|
84
|
+
/** ISO 8601 timestamp of when the decision was recorded */
|
|
85
|
+
timestamp: string;
|
|
86
|
+
/** Related task ID if the decision was made in the context of a specific task */
|
|
87
|
+
task_id?: string;
|
|
88
|
+
/** Related phase number if the decision was phase-scoped */
|
|
89
|
+
phase?: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The top-level context map structure.
|
|
93
|
+
* This is the root object that aggregates file summaries, task history,
|
|
94
|
+
* and architectural decisions into a single durable snapshot.
|
|
95
|
+
* Used for efficient cross-agent context injection without re-reading
|
|
96
|
+
* full source files.
|
|
97
|
+
*/
|
|
98
|
+
export interface ContextMap {
|
|
99
|
+
/** Schema version for forward-compatibility (currently 1) */
|
|
100
|
+
schema_version: 1;
|
|
101
|
+
/** ISO 8601 timestamp of when this context map was generated */
|
|
102
|
+
generated_at: string;
|
|
103
|
+
/** Unique repository identifier for cache invalidation across repos */
|
|
104
|
+
repo_fingerprint: string;
|
|
105
|
+
/** File context entries keyed by relative file path */
|
|
106
|
+
files: Record<string, FileContextEntry>;
|
|
107
|
+
/** Task history entries keyed by task ID */
|
|
108
|
+
task_history: Record<string, TaskContextSummary>;
|
|
109
|
+
/** Architectural decisions recorded during the session */
|
|
110
|
+
decisions: DecisionEntry[];
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Entry tracking a file detected as stale in the context map.
|
|
114
|
+
* Used to identify which files need re-analysis due to content changes
|
|
115
|
+
* since the context map was last generated.
|
|
116
|
+
*/
|
|
117
|
+
export interface ContextMapStaleEntry {
|
|
118
|
+
/** Relative file path of the stale file */
|
|
119
|
+
path: string;
|
|
120
|
+
/** SHA-256 content hash at the time the context map was generated */
|
|
121
|
+
old_hash: ContentHash;
|
|
122
|
+
/** ISO 8601 timestamp of when staleness was detected */
|
|
123
|
+
detected_at: string;
|
|
124
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.52.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",
|