opencode-swarm 7.137.4 → 7.138.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.
Files changed (41) hide show
  1. package/dist/background/pending-delegations.d.ts +23 -3
  2. package/dist/cli/{config-doctor-5qymy0bp.js → config-doctor-mb81xytp.js} +2 -2
  3. package/dist/cli/{curation-policy-788qbgwk.js → curation-policy-qx23sc8b.js} +2 -2
  4. package/dist/cli/{curator-0zebvv5q.js → curator-b9ascpbh.js} +13 -13
  5. package/dist/cli/{curator-llm-factory-6w7hpfb0.js → curator-llm-factory-r47q1hbd.js} +13 -13
  6. package/dist/cli/{guardrail-explain-k1a7mwq9.js → guardrail-explain-ph1n3ryc.js} +14 -14
  7. package/dist/cli/{guardrail-log-wqsg11xd.js → guardrail-log-ghgqaw3w.js} +3 -3
  8. package/dist/cli/{hive-promoter-kxcm4n0n.js → hive-promoter-7x2zzhb7.js} +13 -13
  9. package/dist/cli/{index-c2v79596.js → index-0s4gr6qh.js} +53 -6
  10. package/dist/cli/{index-mrwr3kac.js → index-2vzgvscz.js} +2 -2
  11. package/dist/cli/{index-2qr7twf5.js → index-4xs9e82s.js} +3 -3
  12. package/dist/cli/{index-pzkn7d2k.js → index-6nenabrm.js} +1 -1
  13. package/dist/cli/{index-01dpavd4.js → index-7kgfvt3h.js} +1 -1
  14. package/dist/cli/{index-b2khb7xx.js → index-7wzyf4dr.js} +4 -4
  15. package/dist/cli/{index-p9shqpbc.js → index-9zf5gfca.js} +1 -1
  16. package/dist/cli/{index-rdg1tkz4.js → index-ag7ppc40.js} +15 -15
  17. package/dist/cli/{index-csneb2ph.js → index-bf0j2wd2.js} +2 -2
  18. package/dist/cli/{index-q9eqty52.js → index-ca6qmxd8.js} +1 -1
  19. package/dist/cli/{index-bma4nwts.js → index-cdx3aqj5.js} +1 -1
  20. package/dist/cli/{index-b9pgq0fk.js → index-hmapndcz.js} +5 -5
  21. package/dist/cli/{index-h353c1xz.js → index-npgjk6vc.js} +1 -1
  22. package/dist/cli/{index-nnf41ca1.js → index-sp7s1vk3.js} +1424 -1055
  23. package/dist/cli/{index-eq564d4t.js → index-whf5ecbw.js} +1 -1
  24. package/dist/cli/{index-m09k3dpz.js → index-xz0zjrdr.js} +1 -1
  25. package/dist/cli/{index-fetnv58w.js → index-z55s5719.js} +2 -2
  26. package/dist/cli/index.js +13 -13
  27. package/dist/cli/{knowledge-escalator-dna6s7qy.js → knowledge-escalator-pqskjp6y.js} +3 -3
  28. package/dist/cli/{knowledge-events-shy8wgb3.js → knowledge-events-ahpxnqjd.js} +1 -1
  29. package/dist/cli/{knowledge-store-j7xtx4dd.js → knowledge-store-27aynbeg.js} +1 -1
  30. package/dist/cli/{knowledge-validator-zfweje73.js → knowledge-validator-4saz53kh.js} +4 -4
  31. package/dist/cli/{pending-delegations-gee019ec.js → pending-delegations-ztb67amh.js} +3 -1
  32. package/dist/cli/{scan-cursor-fessrenj.js → scan-cursor-ngykkd7f.js} +2 -2
  33. package/dist/cli/{schema-36b6sv6b.js → schema-p82ntfy9.js} +1 -1
  34. package/dist/cli/{skill-generator-0ghcwxeb.js → skill-generator-r19a1zje.js} +5 -5
  35. package/dist/cli/{worktree-collision-ownership-y1c7yx14.js → worktree-collision-ownership-rc6pe17g.js} +1 -1
  36. package/dist/commands/close.d.ts +22 -0
  37. package/dist/hooks/delegation-gate.d.ts +1 -1
  38. package/dist/index.js +294 -285
  39. package/dist/services/session-reflection.d.ts +171 -0
  40. package/dist/tools/dispatch-lanes.d.ts +4 -0
  41. package/package.json +1 -1
@@ -14,7 +14,9 @@
14
14
  * When no LLM client is available, phase 2 falls back to a deterministic
15
15
  * summary so finalize never blocks on missing infrastructure.
16
16
  */
17
+ import { readKnowledge, readRejectedLessons } from '../hooks/knowledge-store';
17
18
  import { type SkillImproverLLMDelegate } from '../hooks/skill-improver-llm-factory';
19
+ import { readSkillUsageEntriesTail } from '../hooks/skill-usage-log';
18
20
  import type { ToolAggregate } from '../state';
19
21
  export interface ToolProblem {
20
22
  tool: string;
@@ -33,6 +35,68 @@ export interface GateFailureSummary {
33
35
  taskId: string;
34
36
  count: number;
35
37
  }
38
+ /**
39
+ * Knowledge-delta surface for the reflection report (issue #2077).
40
+ *
41
+ * `admitted` / `reinforcedRealtime` / `rejectedCurator` are recovered
42
+ * READ-ONLY from durable markers stamped by the realtime admission path
43
+ * (`src/learning/admission.ts`) and the curator rejected-lessons file —
44
+ * the in-memory `DrainSummary` is discarded at `src/index.ts` (issue
45
+ * #1821), but the outcomes it summarized persist on the entries
46
+ * themselves, so the counts are reconstructable here without any new
47
+ * writes. Realtime *rejections* (screened-out candidates that never
48
+ * reached the store) remain unobservable and are flagged in the report.
49
+ */
50
+ export interface KnowledgeDelta {
51
+ /** Entries created this session (count, from countSessionKnowledgeEntries). */
52
+ sessionKnowledgeCreated: number;
53
+ /** FR-015 dedup: retro lessons dropped as already-known. */
54
+ dedupDropped: number;
55
+ /** False when the dedup read failed (fail-open) — distinguishes "0 deduped" from "dedup did not run". */
56
+ dedupAvailable: boolean;
57
+ /** Retro lessons that survived dedup and were curated. */
58
+ retroLessonTotal: number;
59
+ /** Close-time curation counts (finalize retro-lesson batch). */
60
+ curation?: {
61
+ stored: number;
62
+ reinforced: number;
63
+ skipped: number;
64
+ rejected: number;
65
+ quarantined: number;
66
+ };
67
+ /** Entries admitted this session (created_at >= sessionStart AND carry an `insight:` provenance marker). */
68
+ admitted?: number;
69
+ /** Pre-existing entries reinforced this session (some confirmed_by[].confirmed_at >= sessionStart). */
70
+ reinforcedRealtime?: number;
71
+ /** Curator-path rejections this session (rejected_at >= sessionStart, from .swarm/knowledge-rejected.jsonl). */
72
+ rejectedCurator?: number;
73
+ }
74
+ export interface SkillViolationSignal {
75
+ skillPath: string;
76
+ violations: number;
77
+ total: number;
78
+ /** Always true — the 64 KB tail may truncate the denominator. */
79
+ tailBounded: boolean;
80
+ /** 'session' when filtered by sessionID; 'all_sessions' when no sessionID was available. */
81
+ scope: 'session' | 'all_sessions';
82
+ }
83
+ export interface ContradictionCandidate {
84
+ newLesson: string;
85
+ newEntryId: string;
86
+ conflictsWithId: string;
87
+ conflictsWithLesson: string;
88
+ similarity: number;
89
+ }
90
+ export type ReflectionActionKind = 'supersede' | 'file_issue' | 'draft_skill';
91
+ export interface ReflectionActionProposal {
92
+ kind: ReflectionActionKind;
93
+ /** Short human-readable label for the menu line. */
94
+ label: string;
95
+ /** Longer body (issue body, lesson text, etc.). */
96
+ detail: string;
97
+ /** Existing tool/command to route to, e.g. '/swarm curate'. */
98
+ routing: string;
99
+ }
36
100
  export interface SessionReflectionData {
37
101
  timestamp: string;
38
102
  totalToolCalls: number;
@@ -42,11 +106,22 @@ export interface SessionReflectionData {
42
106
  gateFailures: GateFailureSummary[];
43
107
  lessonsFromRetros: string[];
44
108
  errorTaxonomy: Record<string, number>;
109
+ knowledgeDelta?: KnowledgeDelta;
110
+ skillViolations: SkillViolationSignal[];
111
+ contradictionCandidates: ContradictionCandidate[];
45
112
  }
46
113
  export interface SessionReflectionResult {
47
114
  data: SessionReflectionData;
48
115
  architectReport: string;
116
+ /**
117
+ * Always-rendered signals block (issue #2077). Surfaced UNCONDITIONALLY
118
+ * by close.ts (not gated by the narrative-report `hasSignals` check) so
119
+ * the "0 captured; N deduped" / NOOP line appears even in a clean
120
+ * session. Present on BOTH the llm and deterministic paths.
121
+ */
122
+ signalsReport: string;
49
123
  source: 'llm' | 'deterministic';
124
+ actionProposals: ReflectionActionProposal[];
50
125
  }
51
126
  declare function gatherToolProblems(toolAggregates: Map<string, ToolAggregate>): {
52
127
  problems: ToolProblem[];
@@ -63,7 +138,83 @@ declare function gatherRetroLessonsAndTaxonomy(directory: string): Promise<{
63
138
  taxonomy: Record<string, number>;
64
139
  }>;
65
140
  declare function gatherGateFailures(directory: string): Promise<GateFailureSummary[]>;
141
+ /**
142
+ * Top skills by violation this session (issue #2077).
143
+ *
144
+ * Reads the bounded tail of `.swarm/skill-usage.jsonl`, groups by
145
+ * `skillPath`, and counts entries where the normalized compliance
146
+ * verdict is `'violated'`. Returns `[]` when `sessionId` is undefined:
147
+ * without a session filter the tail is cumulative cross-session data
148
+ * and MUST NOT be labeled "this session" (issue #2077 critic item 8).
149
+ * `tailBounded` is always true — the 64 KB tail may truncate the
150
+ * denominator.
151
+ */
152
+ export declare function gatherSkillViolations(directory: string, sessionId?: string): SkillViolationSignal[];
153
+ /**
154
+ * Contradiction candidates among session-created knowledge (issue #2077).
155
+ *
156
+ * IMPORTANT (issue #2077 critic item 3): the realtime admission and
157
+ * curator write paths dedup at `dedup_threshold` (default 0.6) BEFORE an
158
+ * entry becomes active, so two active entries with Jaccard similarity
159
+ * ≥ that threshold cannot coexist. A detector run at the dedup threshold
160
+ * would therefore return `[]` in every real session. Instead this looks
161
+ * in a sub-threshold band `[CONTRADICTION_LOWER, dedupThreshold)` AND
162
+ * requires negation-polarity divergence — the only shape that can occur
163
+ * in production. Uses the exported `wordBigrams`/`jaccardBigram`
164
+ * primitives directly so the score is available (the
165
+ * `findActiveSwarmNearDuplicate` helper returns only the entry, with no
166
+ * score and no self-exclusion). Detect-only: never writes, never
167
+ * auto-supersedes. Supersession is operationally deletion
168
+ * (`superseded_by IS NULL` read filter) and is surfaced only as a menu
169
+ * item the user opts into.
170
+ */
171
+ export declare function gatherContradictionCandidates(directory: string, sessionStart?: string, dedupThreshold?: number): Promise<ContradictionCandidate[]>;
172
+ /**
173
+ * Realtime admission counts recovered READ-ONLY from durable markers
174
+ * (issue #2077 critic item 4). The in-memory `DrainSummary` is
175
+ * discarded at `src/index.ts`, but the outcomes persist:
176
+ * - admitted: entries created this session with an `insight:` provenance marker
177
+ * (stamped by `admitCandidate` via `unionSourceKnowledgeIds`).
178
+ * - reinforced: pre-existing entries with a `confirmed_by` record
179
+ * stamped this session (the realtime reinforce path).
180
+ * - rejected: curator-path rejections this session, from
181
+ * `.swarm/knowledge-rejected.jsonl`.
182
+ * Returns `undefined` when `sessionStart` is undefined (counts are
183
+ * session-scoped). Realtime *rejections* (screened-out candidates that
184
+ * never reached the store) are NOT recoverable and are flagged in the
185
+ * report as tracked by #1821.
186
+ */
187
+ export declare function gatherRealtimeAdmissionCounts(directory: string, sessionStart?: string): Promise<{
188
+ admitted: number;
189
+ reinforced: number;
190
+ rejected: number;
191
+ } | undefined>;
66
192
  declare function buildReflectionDataSummary(data: SessionReflectionData): string;
193
+ /**
194
+ * Always-rendered signals block (issue #2077). Rendered UNCONDITIONALLY
195
+ * by close.ts (not gated by the narrative-report `hasSignals` check) so
196
+ * the "0 captured; N deduped" / NOOP line appears even in a clean
197
+ * session. Surfaces all six signal classes: knowledge delta, skill
198
+ * violations, contradiction candidates, negatives, drafted issues.
199
+ */
200
+ export declare function buildSignalsBlock(data: SessionReflectionData): string;
201
+ /**
202
+ * Assemble a numbered action menu from reflection proposals (issue #2077
203
+ * Phase B). Advisory only — application happens in a later user turn via
204
+ * the named existing tools. Under full-auto the "reply with numbers"
205
+ * prompt is suppressed (reported-only) so the run is not blocked waiting
206
+ * on human input. Returns '' when there are no proposals.
207
+ */
208
+ export declare function buildActionMenu(proposals: ReflectionActionProposal[], fullAuto: boolean): string;
209
+ /**
210
+ * Build action proposals from gathered signals (issue #2077 Phase B).
211
+ * The `capture` kind is intentionally absent (issue #2077 critic item 7):
212
+ * aggregate curation counts cannot derive per-lesson outcomes, and
213
+ * re-proposing quarantined lessons would fail the actionability gate
214
+ * identically when applied. A menu item guaranteed to be rejected is
215
+ * worse than no menu item.
216
+ */
217
+ export declare function buildActionProposals(data: SessionReflectionData): ReflectionActionProposal[];
67
218
  declare function buildDeterministicReport(data: SessionReflectionData): string;
68
219
  export interface SessionReflectionInput {
69
220
  directory: string;
@@ -72,6 +223,17 @@ export interface SessionReflectionInput {
72
223
  sessionId?: string;
73
224
  signal?: AbortSignal;
74
225
  delegate?: SkillImproverLLMDelegate;
226
+ /** Issue #2077: knowledge-delta surface (close-time curation counts + dedup state). */
227
+ knowledgeDelta?: KnowledgeDelta;
228
+ /** Issue #2077: session start (ISO), used to scope session-created entries. */
229
+ sessionStart?: string;
230
+ /**
231
+ * Issue #2077: configured dedup threshold (upper bound of the contradiction
232
+ * band). Read from `config.dedup_threshold` so a user-tuned threshold (e.g.
233
+ * 0.8) does not cause advisory false negatives for pairs in [0.6, 0.8) that
234
+ * can coexist in the active store. Defaults to 0.6 (the schema default).
235
+ */
236
+ dedupThreshold?: number;
75
237
  }
76
238
  export declare function runSessionReflection(input: SessionReflectionInput): Promise<SessionReflectionResult>;
77
239
  export declare function writeSessionReflection(directory: string, result: SessionReflectionResult): Promise<string>;
@@ -82,5 +244,14 @@ export declare const _internals: {
82
244
  gatherGateFailures: typeof gatherGateFailures;
83
245
  buildReflectionDataSummary: typeof buildReflectionDataSummary;
84
246
  buildDeterministicReport: typeof buildDeterministicReport;
247
+ gatherSkillViolations: typeof gatherSkillViolations;
248
+ gatherContradictionCandidates: typeof gatherContradictionCandidates;
249
+ gatherRealtimeAdmissionCounts: typeof gatherRealtimeAdmissionCounts;
250
+ buildSignalsBlock: typeof buildSignalsBlock;
251
+ buildActionMenu: typeof buildActionMenu;
252
+ buildActionProposals: typeof buildActionProposals;
253
+ readSkillUsageEntriesTail: typeof readSkillUsageEntriesTail;
254
+ readKnowledge: typeof readKnowledge;
255
+ readRejectedLessons: typeof readRejectedLessons;
85
256
  };
86
257
  export {};
@@ -104,6 +104,8 @@ export interface DispatchLaneResult {
104
104
  session_id?: string;
105
105
  slot_id?: string;
106
106
  run_id?: string;
107
+ /** One-based session.create attempt that produced this result. */
108
+ generation?: number;
107
109
  started_at: string;
108
110
  completed_at: string;
109
111
  output?: string;
@@ -291,6 +293,7 @@ export declare const _test_exports: {
291
293
  formatError: typeof formatError;
292
294
  nextCollectPollInterval: typeof nextCollectPollInterval;
293
295
  promptHash: typeof promptHash;
296
+ isRetryableSessionCreateFailure: typeof isRetryableSessionCreateFailure;
294
297
  DispatchLanesArgsSchema: z.ZodObject<{
295
298
  lanes: z.ZodArray<z.ZodObject<{
296
299
  id: z.ZodString;
@@ -384,6 +387,7 @@ interface DispatchLanesExecutionContext {
384
387
  export declare function executeDispatchLanes(args: unknown, directory: string, context?: DispatchLanesExecutionContext): Promise<DispatchLanesResult>;
385
388
  export declare function executeDispatchLanesAsync(args: unknown, directory: string, context?: DispatchLanesExecutionContext): Promise<DispatchLanesAsyncResult>;
386
389
  export declare function executeCollectLaneResults(args: unknown, directory: string, context?: Pick<DispatchLanesExecutionContext, 'sessionID'>): Promise<CollectLaneResultsResult>;
390
+ declare function isRetryableSessionCreateFailure(error: unknown): boolean;
387
391
  declare function extractAssistantTranscript(messages: Array<{
388
392
  info?: {
389
393
  role?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.137.4",
3
+ "version": "7.138.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",