opencode-swarm 7.41.0 → 7.42.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/dist/agents/architect.d.ts +16 -1
- package/dist/agents/critic.d.ts +2 -1
- package/dist/cli/index.js +40 -5
- package/dist/config/constants.d.ts +2 -2
- package/dist/config/schema.d.ts +39 -0
- package/dist/hooks/knowledge-curator.d.ts +3 -1
- package/dist/index.js +1340 -898
- package/dist/summaries/aggregate.d.ts +22 -0
- package/dist/summaries/schema.d.ts +148 -0
- package/dist/summaries/store.d.ts +51 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/summarize-work.d.ts +7 -0
- package/dist/tools/tool-names.d.ts +1 -1
- package/dist/tools/write-architecture-supervisor-evidence.d.ts +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase-level aggregation of per-agent work summaries (issue #893, Chunk B).
|
|
3
|
+
*
|
|
4
|
+
* Deterministic, cheap rollup that runs in the non-blocking phase-monitor hook: it reads
|
|
5
|
+
* the agent summaries for a completed phase, unions their decisions/risks/violations, and
|
|
6
|
+
* surfaces cross-agent contradictions (a constraint one agent observed but another
|
|
7
|
+
* violated). The result is written as a raw sidecar that the architecture-supervisor
|
|
8
|
+
* critic reviews in Chunk C. No LLM call here — keeps the hook fast and side-effect-light.
|
|
9
|
+
*/
|
|
10
|
+
import { type PhaseArchitectureSummary } from './schema';
|
|
11
|
+
export interface AggregatePhaseOptions {
|
|
12
|
+
/** Override the timestamp source (tests). */
|
|
13
|
+
now?: () => string;
|
|
14
|
+
/** Word cap for the rollup summary text. */
|
|
15
|
+
maxPhaseSummaryWords?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Aggregate all agent summaries for `phase` into a PhaseArchitectureSummary and persist
|
|
19
|
+
* it as a sidecar. Returns the summary, or null when there are no agent summaries for the
|
|
20
|
+
* phase (nothing to roll up — the sidecar is not written in that case).
|
|
21
|
+
*/
|
|
22
|
+
export declare function aggregatePhaseSummary(directory: string, phase: number, options?: AggregatePhaseOptions): Promise<PhaseArchitectureSummary | null>;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schemas and helpers for the hierarchical architecture-summary system (issue #893).
|
|
3
|
+
*
|
|
4
|
+
* Three tiers roll up task -> phase -> project:
|
|
5
|
+
* - AgentWorkSummary: short, structured "what I did" emitted by each worker/architect
|
|
6
|
+
* at task completion (stored as a `note` evidence entry, payload under metadata).
|
|
7
|
+
* - PhaseArchitectureSummary: cheap-model compression of all agent summaries in a phase
|
|
8
|
+
* (written as a raw sidecar, like phase-council.json).
|
|
9
|
+
* - ArchitectureSupervisorReport: the expensive read-only critic's verdict over the
|
|
10
|
+
* compressed summaries (also a raw sidecar so top-level fields survive).
|
|
11
|
+
*
|
|
12
|
+
* Caps are enforced by truncation (not rejection) to match the repo's lenient evidence
|
|
13
|
+
* style; callers use the normalize* helpers before validation and surface a `truncated`
|
|
14
|
+
* flag in metadata.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
export declare const SUMMARY_SCHEMA_VERSION = "1.0.0";
|
|
18
|
+
/** Default caps (config can lower these per-feature; schemas use them as hard bounds). */
|
|
19
|
+
export declare const MAX_AGENT_SUMMARY_WORDS = 100;
|
|
20
|
+
export declare const MAX_PHASE_SUMMARY_WORDS = 250;
|
|
21
|
+
export declare const MAX_LIST_ITEMS = 5;
|
|
22
|
+
/** Verdict vocabulary — mirrors the phase-council gate (APPROVE | CONCERNS | REJECT). */
|
|
23
|
+
export declare const SupervisorVerdictSchema: z.ZodEnum<{
|
|
24
|
+
APPROVE: "APPROVE";
|
|
25
|
+
REJECT: "REJECT";
|
|
26
|
+
CONCERNS: "CONCERNS";
|
|
27
|
+
}>;
|
|
28
|
+
export type SupervisorVerdict = z.infer<typeof SupervisorVerdictSchema>;
|
|
29
|
+
/** Count whitespace-delimited words in a string. */
|
|
30
|
+
export declare function countWords(text: string): number;
|
|
31
|
+
/** Truncate to `maxWords`, appending an ellipsis marker when content was dropped. */
|
|
32
|
+
export declare function truncateWords(text: string, maxWords: number): {
|
|
33
|
+
text: string;
|
|
34
|
+
truncated: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** Cap an array to `maxItems`, reporting whether anything was dropped. */
|
|
37
|
+
export declare function capArray<T>(items: T[], maxItems: number): {
|
|
38
|
+
items: T[];
|
|
39
|
+
truncated: boolean;
|
|
40
|
+
};
|
|
41
|
+
export declare const AgentWorkSummarySchema: z.ZodObject<{
|
|
42
|
+
schema_version: z.ZodLiteral<"1.0.0">;
|
|
43
|
+
phase: z.ZodNumber;
|
|
44
|
+
task_id: z.ZodOptional<z.ZodString>;
|
|
45
|
+
session_id: z.ZodString;
|
|
46
|
+
agent: z.ZodString;
|
|
47
|
+
parent_agent: z.ZodOptional<z.ZodString>;
|
|
48
|
+
summary: z.ZodString;
|
|
49
|
+
key_decisions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
50
|
+
constraints_observed: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
51
|
+
constraints_violated: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
52
|
+
assumptions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
53
|
+
risks: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
54
|
+
files_touched: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
+
evidence_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
56
|
+
created_at: z.ZodString;
|
|
57
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
export type AgentWorkSummary = z.infer<typeof AgentWorkSummarySchema>;
|
|
60
|
+
/**
|
|
61
|
+
* Raw, pre-validation fields a caller supplies. Caps are applied here, then the result
|
|
62
|
+
* is validated against AgentWorkSummarySchema. Returns the normalized summary plus a
|
|
63
|
+
* `truncated` flag aggregated across all fields.
|
|
64
|
+
*/
|
|
65
|
+
export interface AgentWorkSummaryInput {
|
|
66
|
+
phase: number;
|
|
67
|
+
task_id?: string;
|
|
68
|
+
session_id: string;
|
|
69
|
+
agent: string;
|
|
70
|
+
parent_agent?: string;
|
|
71
|
+
summary: string;
|
|
72
|
+
key_decisions?: string[];
|
|
73
|
+
constraints_observed?: string[];
|
|
74
|
+
constraints_violated?: string[];
|
|
75
|
+
assumptions?: string[];
|
|
76
|
+
risks?: string[];
|
|
77
|
+
files_touched?: string[];
|
|
78
|
+
evidence_refs?: string[];
|
|
79
|
+
created_at?: string;
|
|
80
|
+
}
|
|
81
|
+
export declare function normalizeAgentWorkSummary(input: AgentWorkSummaryInput, maxSummaryWords?: number): AgentWorkSummary;
|
|
82
|
+
export declare const PhaseArchitectureSummarySchema: z.ZodObject<{
|
|
83
|
+
schema_version: z.ZodLiteral<"1.0.0">;
|
|
84
|
+
phase: z.ZodNumber;
|
|
85
|
+
summary: z.ZodDefault<z.ZodString>;
|
|
86
|
+
agents_seen: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
87
|
+
tasks_seen: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
88
|
+
key_decisions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
89
|
+
conflicts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
90
|
+
unresolved_risks: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
91
|
+
constraint_violations: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
92
|
+
evidence_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
93
|
+
created_at: z.ZodString;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
export type PhaseArchitectureSummary = z.infer<typeof PhaseArchitectureSummarySchema>;
|
|
96
|
+
export declare const SupervisorFindingSchema: z.ZodObject<{
|
|
97
|
+
severity: z.ZodEnum<{
|
|
98
|
+
low: "low";
|
|
99
|
+
medium: "medium";
|
|
100
|
+
high: "high";
|
|
101
|
+
critical: "critical";
|
|
102
|
+
}>;
|
|
103
|
+
category: z.ZodString;
|
|
104
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
105
|
+
tasks: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
106
|
+
evidence_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
107
|
+
description: z.ZodString;
|
|
108
|
+
recommendation: z.ZodDefault<z.ZodString>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
export type SupervisorFinding = z.infer<typeof SupervisorFindingSchema>;
|
|
111
|
+
export declare const KnowledgeRecommendationSchema: z.ZodObject<{
|
|
112
|
+
lesson: z.ZodString;
|
|
113
|
+
target_agents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
114
|
+
confidence: z.ZodDefault<z.ZodNumber>;
|
|
115
|
+
evidence_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export type KnowledgeRecommendation = z.infer<typeof KnowledgeRecommendationSchema>;
|
|
118
|
+
export declare const ArchitectureSupervisorReportSchema: z.ZodObject<{
|
|
119
|
+
schema_version: z.ZodLiteral<"1.0.0">;
|
|
120
|
+
phase: z.ZodNumber;
|
|
121
|
+
verdict: z.ZodEnum<{
|
|
122
|
+
APPROVE: "APPROVE";
|
|
123
|
+
REJECT: "REJECT";
|
|
124
|
+
CONCERNS: "CONCERNS";
|
|
125
|
+
}>;
|
|
126
|
+
findings: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
127
|
+
severity: z.ZodEnum<{
|
|
128
|
+
low: "low";
|
|
129
|
+
medium: "medium";
|
|
130
|
+
high: "high";
|
|
131
|
+
critical: "critical";
|
|
132
|
+
}>;
|
|
133
|
+
category: z.ZodString;
|
|
134
|
+
agents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
135
|
+
tasks: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
136
|
+
evidence_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
137
|
+
description: z.ZodString;
|
|
138
|
+
recommendation: z.ZodDefault<z.ZodString>;
|
|
139
|
+
}, z.core.$strip>>>;
|
|
140
|
+
knowledge_recommendations: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
141
|
+
lesson: z.ZodString;
|
|
142
|
+
target_agents: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
143
|
+
confidence: z.ZodDefault<z.ZodNumber>;
|
|
144
|
+
evidence_refs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
145
|
+
}, z.core.$strip>>>;
|
|
146
|
+
created_at: z.ZodString;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
export type ArchitectureSupervisorReport = z.infer<typeof ArchitectureSupervisorReportSchema>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistence for the architecture-summary tiers (issue #893).
|
|
3
|
+
*
|
|
4
|
+
* Storage strategy (verified against the evidence system):
|
|
5
|
+
* - Per-agent summaries are stored as `note` evidence entries via saveEvidence(), with
|
|
6
|
+
* the structured payload under `metadata` (EvidenceBundleSchema parses entries through
|
|
7
|
+
* a discriminated union and strips unknown top-level keys, so the payload MUST live in
|
|
8
|
+
* metadata).
|
|
9
|
+
* - Phase summaries and the supervisor report are written as raw sidecar bundles
|
|
10
|
+
* (temp-file + rename), mirroring submit-phase-council-verdicts.ts, so the gate can
|
|
11
|
+
* read top-level fields (verdict, phase_number, timestamp) without zod stripping them.
|
|
12
|
+
*/
|
|
13
|
+
import { type AgentWorkSummary, type ArchitectureSupervisorReport, type PhaseArchitectureSummary } from './schema';
|
|
14
|
+
export declare const AGENT_SUMMARY_METADATA_KIND = "agent_summary";
|
|
15
|
+
/**
|
|
16
|
+
* Persist a per-agent work summary as a `note` evidence entry. The structured payload
|
|
17
|
+
* lives entirely under metadata so it survives EvidenceBundleSchema validation.
|
|
18
|
+
* Keyed by the agent's task_id when present, else a synthetic phase-scoped bucket.
|
|
19
|
+
*/
|
|
20
|
+
export declare function writeAgentSummary(directory: string, summary: AgentWorkSummary): Promise<string>;
|
|
21
|
+
export interface ListAgentSummariesFilter {
|
|
22
|
+
phase?: number;
|
|
23
|
+
session?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Scan all evidence bundles and return the agent work summaries matching the filter.
|
|
27
|
+
* Malformed payloads are skipped (logged, never thrown) so aggregation stays fail-open.
|
|
28
|
+
*/
|
|
29
|
+
export declare function listAgentSummaries(directory: string, filter?: ListAgentSummariesFilter): Promise<AgentWorkSummary[]>;
|
|
30
|
+
export declare function writePhaseArchitectureSummary(directory: string, summary: PhaseArchitectureSummary): string;
|
|
31
|
+
export declare function readPhaseArchitectureSummary(directory: string, phase: number): PhaseArchitectureSummary | null;
|
|
32
|
+
/**
|
|
33
|
+
* Write the supervisor report as a raw sidecar bundle whose single entry carries
|
|
34
|
+
* top-level `verdict`, `phase_number`, and `timestamp` — exactly the shape the
|
|
35
|
+
* phase-complete gate reads via fs.readFileSync + JSON.parse (mirrors phase-council).
|
|
36
|
+
*/
|
|
37
|
+
export declare function writeSupervisorReport(directory: string, report: ArchitectureSupervisorReport): string;
|
|
38
|
+
/** A single raw supervisor entry as read back from the sidecar (untyped JSON). */
|
|
39
|
+
export interface RawSupervisorEntry {
|
|
40
|
+
type: string;
|
|
41
|
+
phase_number?: number;
|
|
42
|
+
timestamp?: string;
|
|
43
|
+
verdict?: string;
|
|
44
|
+
findings?: unknown[];
|
|
45
|
+
knowledge_recommendations?: unknown[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Read the supervisor report sidecar raw (no zod), returning the supervisor entry or
|
|
49
|
+
* null when the file is missing/malformed. This is the read path the gate uses.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readSupervisorReportRaw(directory: string, phase: number): RawSupervisorEntry | null;
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -50,9 +50,11 @@ export { skill_inspect } from './skill-inspect';
|
|
|
50
50
|
export { skill_list } from './skill-list';
|
|
51
51
|
export { spec_write } from './spec-write';
|
|
52
52
|
export { submit_phase_council_verdicts } from './submit-phase-council-verdicts';
|
|
53
|
+
export { summarize_work } from './summarize-work';
|
|
53
54
|
export { createSwarmCommandTool, swarm_command } from './swarm-command';
|
|
54
55
|
export { swarm_memory_propose } from './swarm-memory-propose';
|
|
55
56
|
export { swarm_memory_recall } from './swarm-memory-recall';
|
|
57
|
+
export { write_architecture_supervisor_evidence } from './write-architecture-supervisor-evidence';
|
|
56
58
|
import { suggestPatch } from './suggest-patch';
|
|
57
59
|
export { suggestPatch };
|
|
58
60
|
export type { SuggestPatchArgs } from './suggest-patch';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* summarize_work — agents call this at task completion to emit a short structured
|
|
3
|
+
* summary of what they did (issue #893). Stored as a `note` evidence entry; rolled up
|
|
4
|
+
* per-phase and reviewed by the architecture-supervisor critic. Advisory: never blocks.
|
|
5
|
+
*/
|
|
6
|
+
import type { tool } from '@opencode-ai/plugin';
|
|
7
|
+
export declare const summarize_work: ReturnType<typeof tool>;
|
|
@@ -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' | 'diff_summary' | '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' | 'check_gate_status' | 'completion_verify' | 'submit_council_verdicts' | 'submit_phase_council_verdicts' | 'declare_council_criteria' | 'sbom_generate' | 'checkpoint' | 'pkg_audit' | 'test_runner' | 'test_impact' | 'mutation_test' | 'generate_mutants' | 'detect_domains' | 'gitingest' | 'retrieve_summary' | 'extract_code_blocks' | 'phase_complete' | 'save_plan' | 'update_task_status' | 'lint_spec' | 'write_retro' | 'write_drift_evidence' | 'write_hallucination_evidence' | 'write_mutation_evidence' | 'declare_scope' | 'knowledge_query' | 'doc_scan' | 'doc_extract' | 'curator_analyze' | 'knowledge_add' | 'knowledge_recall' | 'knowledge_remove' | 'co_change_analyzer' | 'search' | 'batch_symbols' | 'suggest_patch' | 'req_coverage' | 'get_approved_plan' | 'repo_map' | 'get_qa_gate_profile' | 'set_qa_gates' | 'web_search' | 'convene_general_council' | 'write_final_council_evidence' | 'skill_generate' | 'skill_list' | 'skill_apply' | 'skill_inspect' | 'skill_improve' | 'spec_write' | 'knowledge_ack' | 'swarm_memory_recall' | 'swarm_memory_propose' | 'swarm_command' | 'lean_turbo_plan_lanes' | 'lean_turbo_acquire_locks' | 'lean_turbo_runner_status' | 'lean_turbo_review' | 'lean_turbo_run_phase' | 'lean_turbo_status';
|
|
6
|
+
export type ToolName = 'diff' | 'diff_summary' | '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' | 'check_gate_status' | 'completion_verify' | 'submit_council_verdicts' | 'submit_phase_council_verdicts' | 'declare_council_criteria' | 'sbom_generate' | 'checkpoint' | 'pkg_audit' | 'test_runner' | 'test_impact' | 'mutation_test' | 'generate_mutants' | 'detect_domains' | 'gitingest' | 'retrieve_summary' | 'extract_code_blocks' | 'phase_complete' | 'save_plan' | 'update_task_status' | 'lint_spec' | 'write_retro' | 'write_drift_evidence' | 'write_hallucination_evidence' | 'write_mutation_evidence' | 'declare_scope' | 'knowledge_query' | 'doc_scan' | 'doc_extract' | 'curator_analyze' | 'knowledge_add' | 'knowledge_recall' | 'knowledge_remove' | 'co_change_analyzer' | 'search' | 'batch_symbols' | 'suggest_patch' | 'req_coverage' | 'get_approved_plan' | 'repo_map' | 'get_qa_gate_profile' | 'set_qa_gates' | 'web_search' | 'convene_general_council' | 'write_final_council_evidence' | 'skill_generate' | 'skill_list' | 'skill_apply' | 'skill_inspect' | 'skill_improve' | 'spec_write' | 'knowledge_ack' | 'swarm_memory_recall' | 'swarm_memory_propose' | 'swarm_command' | 'summarize_work' | 'write_architecture_supervisor_evidence' | 'lean_turbo_plan_lanes' | 'lean_turbo_acquire_locks' | 'lean_turbo_runner_status' | 'lean_turbo_review' | 'lean_turbo_run_phase' | 'lean_turbo_status';
|
|
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 */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* write_architecture_supervisor_evidence — persists the architecture-supervisor critic's
|
|
3
|
+
* verdict for a phase (issue #893, Chunk C). The architect dispatches
|
|
4
|
+
* critic_architecture_supervisor, collects its structured JSON verdict, then calls this
|
|
5
|
+
* tool to write the raw sidecar that the phase-complete gate (Chunk D) reads.
|
|
6
|
+
*
|
|
7
|
+
* Mirrors write_drift_evidence / submit_phase_council_verdicts: the tool persists only —
|
|
8
|
+
* it does not contact the supervisor.
|
|
9
|
+
*/
|
|
10
|
+
import type { tool } from '@opencode-ai/plugin';
|
|
11
|
+
export declare const write_architecture_supervisor_evidence: ReturnType<typeof tool>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.42.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",
|