opencode-swarm 7.132.2 → 7.133.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 (97) hide show
  1. package/README.md +4 -1
  2. package/dist/agents/agent-output-schema.d.ts +74 -0
  3. package/dist/agents/critic.d.ts +2 -1
  4. package/dist/agents/reviewer.d.ts +1 -1
  5. package/dist/background/completion-observer.d.ts +2 -0
  6. package/dist/background/pending-delegations.d.ts +39 -1
  7. package/dist/background/stage-b-gates.d.ts +2 -0
  8. package/dist/cli/{config-doctor-bp5spb79.js → config-doctor-8nbdwnn6.js} +2 -2
  9. package/dist/cli/{core-wg3re04e.js → core-egwpry19.js} +2 -2
  10. package/dist/cli/{curation-policy-7zp2m9gv.js → curation-policy-gae3xm5d.js} +2 -2
  11. package/dist/cli/{curator-h067mrcc.js → curator-e88bm4mg.js} +17 -18
  12. package/dist/cli/{curator-llm-factory-605d08hf.js → curator-llm-factory-1a7esr69.js} +17 -18
  13. package/dist/cli/{evidence-summary-service-jfagmvrh.js → evidence-summary-service-nhsmsap8.js} +3 -3
  14. package/dist/cli/{guardrail-explain-s7vzm6z7.js → guardrail-explain-zgja2b9m.js} +18 -19
  15. package/dist/cli/{guardrail-log-aa112fxv.js → guardrail-log-fjgyx76r.js} +3 -3
  16. package/dist/cli/{hive-promoter-nv0m5rzk.js → hive-promoter-2b04e0wh.js} +17 -18
  17. package/dist/cli/{index-9cf1yr67.js → index-0vd91yb8.js} +3 -3
  18. package/dist/cli/{index-w9cb5zwh.js → index-17zjp67y.js} +1 -1
  19. package/dist/cli/{index-djwemsjn.js → index-66zght9d.js} +1 -1
  20. package/dist/cli/{index-6ccynjv3.js → index-7ftthvqt.js} +2 -2
  21. package/dist/cli/{index-jgfcp9bh.js → index-bz08438z.js} +1 -1
  22. package/dist/cli/{index-mwkwyej1.js → index-cpest8sa.js} +5 -5
  23. package/dist/cli/{index-y5qp59rc.js → index-hfpw5m0e.js} +9 -3
  24. package/dist/cli/{index-3s9rfnqq.js → index-j5pnah1w.js} +4 -4
  25. package/dist/cli/{index-jj4earrh.js → index-kc1m6vpr.js} +2 -2
  26. package/dist/cli/{index-8d3m0ge3.js → index-mhcge2ry.js} +34 -23
  27. package/dist/cli/{index-yvv1wt2h.js → index-mmvaf4t6.js} +1 -1
  28. package/dist/cli/{index-f6480ee6.js → index-mwqfyjja.js} +37751 -33949
  29. package/dist/cli/{index-fgcmxjp7.js → index-sp7tm8t7.js} +1 -1
  30. package/dist/cli/{index-k4tmx21m.js → index-sw82jvf2.js} +2 -2
  31. package/dist/cli/{index-630badhp.js → index-tj2mkfb3.js} +149 -6
  32. package/dist/cli/{index-rt5jgktq.js → index-wz36r0fk.js} +1 -1
  33. package/dist/cli/{index-bvp2v7k1.js → index-wzb4dv5s.js} +263 -16
  34. package/dist/cli/index.js +21 -20
  35. package/dist/cli/{knowledge-escalator-j0nceas7.js → knowledge-escalator-hzkw1ban.js} +3 -3
  36. package/dist/cli/{knowledge-events-gpqc62jr.js → knowledge-events-pbycdhqd.js} +1 -1
  37. package/dist/cli/{knowledge-store-ggxr3ww5.js → knowledge-store-45jawb2p.js} +1 -1
  38. package/dist/cli/{knowledge-validator-007smap6.js → knowledge-validator-ge576f8n.js} +4 -4
  39. package/dist/cli/pending-delegations-kxy8mdqg.js +75 -0
  40. package/dist/cli/{scan-cursor-wz4bff7a.js → scan-cursor-kvw872be.js} +2 -2
  41. package/dist/cli/{schema-023gwne7.js → schema-a2zm2m3r.js} +6 -2
  42. package/dist/cli/{scope-persistence-dm5bab50.js → scope-persistence-5qypzxxm.js} +1 -1
  43. package/dist/cli/{skill-generator-rtsg1m7x.js → skill-generator-ch79hvxh.js} +5 -5
  44. package/dist/commands/command-dispatch.d.ts +7 -0
  45. package/dist/commands/index.d.ts +7 -0
  46. package/dist/commands/registry.d.ts +16 -0
  47. package/dist/commands/review.d.ts +21 -0
  48. package/dist/config/agent-names.d.ts +3 -3
  49. package/dist/config/evidence-schema.d.ts +47 -47
  50. package/dist/config/index.d.ts +2 -2
  51. package/dist/config/schema.d.ts +58 -6
  52. package/dist/consensus/contracts.d.ts +3 -3
  53. package/dist/evaluation/contracts.d.ts +1 -1
  54. package/dist/evaluation/ephemeral-agent-dispatcher.d.ts +64 -0
  55. package/dist/evaluation/model-dispatcher.d.ts +11 -5
  56. package/dist/evaluation/public-api.d.ts +1 -1
  57. package/dist/hooks/auto-review.d.ts +30 -65
  58. package/dist/hooks/delegation-gate.d.ts +1 -1
  59. package/dist/hooks/guardrails/tool-before.d.ts +8 -0
  60. package/dist/hooks/review-receipt-collector.d.ts +53 -10
  61. package/dist/hooks/review-receipt-scope.d.ts +74 -0
  62. package/dist/hooks/review-receipt.d.ts +104 -10
  63. package/dist/hooks/reviewer-scope-file-fingerprint.d.ts +21 -0
  64. package/dist/hooks/reviewer-scope-lifecycle.d.ts +19 -0
  65. package/dist/hooks/task-result-classifier.d.ts +6 -0
  66. package/dist/index.d.ts +2 -0
  67. package/dist/index.js +660 -607
  68. package/dist/memory/schema.d.ts +5 -5
  69. package/dist/review/contracts.d.ts +29 -0
  70. package/dist/review/diff-source.d.ts +134 -0
  71. package/dist/review/engine.d.ts +60 -0
  72. package/dist/review/evidence.d.ts +88 -0
  73. package/dist/review/finding-validator.d.ts +77 -0
  74. package/dist/review/phase-runner.d.ts +37 -0
  75. package/dist/review/runtime.d.ts +32 -0
  76. package/dist/scope/scope-binding.d.ts +9 -0
  77. package/dist/services/config-doctor.d.ts +12 -0
  78. package/dist/state.d.ts +179 -0
  79. package/dist/tools/dispatch-lanes.d.ts +2 -0
  80. package/dist/tools/lean-turbo-review.d.ts +4 -1
  81. package/dist/tools/lean-turbo-run-phase.d.ts +3 -1
  82. package/dist/tools/phase-complete/gates/final-review-gate.d.ts +18 -0
  83. package/dist/tools/phase-complete/gates/index.d.ts +1 -0
  84. package/dist/tools/phase-complete/gates/types.d.ts +10 -0
  85. package/dist/tools/phase-complete.d.ts +13 -1
  86. package/dist/tools/plugin-registration.d.ts +3 -1
  87. package/dist/tools/swarm-command.d.ts +4 -1
  88. package/dist/tools/tool-metadata.d.ts +22 -22
  89. package/dist/turbo/lean/integration.d.ts +18 -2
  90. package/dist/turbo/lean/reviewer.d.ts +19 -3
  91. package/dist/turbo/lean/runner.d.ts +1 -1
  92. package/package.json +1 -1
  93. package/dist/cli/index-y2pfmd0z.js +0 -259
  94. package/dist/cli/pending-delegations-37t4xecr.js +0 -34
  95. package/dist/cli/{curator-drift-y1wm4atk.js → curator-drift-ea0p8nh1.js} +2 -2
  96. package/dist/cli/{index-4ff0x4cg.js → index-74tptrss.js} +0 -0
  97. package/dist/cli/{index-03zyn94g.js → index-r260ybay.js} +4 -4
@@ -22,13 +22,21 @@
22
22
  * but MUST NOT blindly trust them — staleness check is mandatory.
23
23
  *
24
24
  * Scope-description heterogeneity: receipts in one index may be fingerprinted
25
- * over different canonical contents (e.g. 'reviewer-task-prompt' hashes the
26
- * delegation prompt; 'auto-review-*-diff' hashes the reviewed diff). A prompt
27
- * fingerprint does NOT change when the worktree changes, so consumers MUST
28
- * filter by `scope_fingerprint.scope_description` (or compare like-for-like
29
- * content) before treating an approved receipt as fresh via isScopeStale().
25
+ * over different canonical contents (e.g. `reviewer-task-files-v1` hashes the
26
+ * guardrails-observed file scope plus HEAD and current content; auto-review
27
+ * receipts hash a canonical diff). Consumers MUST filter by
28
+ * `scope_fingerprint.scope_description` and compare like-for-like content
29
+ * before treating an approved receipt as fresh via isScopeStale().
30
30
  */
31
+ import * as fs from 'node:fs';
32
+ import type { FindingValidation, ReviewFinding } from '../agents/agent-output-schema.js';
31
33
  export type ReceiptVerdict = 'rejected' | 'approved';
34
+ export type ReviewFindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
35
+ /** Raised when reviewed bytes stop matching immediately before a durable commit. */
36
+ export declare class ReviewScopeStaleError extends Error {
37
+ readonly code = "REVIEW_SCOPE_STALE";
38
+ constructor(message: string);
39
+ }
32
40
  /** Identity of the reviewer/curator that produced the receipt. */
33
41
  export interface ReviewerIdentity {
34
42
  /** Agent name (e.g. 'reviewer', 'critic', 'curator') */
@@ -45,7 +53,12 @@ export interface ScopeFingerprint {
45
53
  /** Length of the original content in characters */
46
54
  content_length: number;
47
55
  }
48
- /** A blocking finding recorded in a rejected review. */
56
+ /**
57
+ * A finding recorded in a rejected review.
58
+ *
59
+ * The `blocking_findings` JSON field name is retained for schema-v1
60
+ * compatibility, but `effective_severity` is authoritative when present.
61
+ */
49
62
  export interface BlockingFinding {
50
63
  /** File path (relative) or identifier */
51
64
  location: string;
@@ -53,8 +66,23 @@ export interface BlockingFinding {
53
66
  summary: string;
54
67
  /** Line number if applicable */
55
68
  line?: number;
56
- /** Severity: 'critical' | 'high' | 'medium' */
57
- severity: 'critical' | 'high' | 'medium';
69
+ /** Reviewer-reported severity. */
70
+ severity: ReviewFindingSeverity;
71
+ /** Structured-finding fields are additive so legacy v1 receipts remain readable. */
72
+ finding_id?: string;
73
+ title?: string;
74
+ body?: string;
75
+ confidence?: number;
76
+ file?: string;
77
+ line_start?: number;
78
+ line_end?: number;
79
+ /** Severity after confidence, anchoring, and validation policy is applied. */
80
+ effective_severity?: ReviewFindingSeverity;
81
+ validator_disposition?: FindingValidation['disposition'];
82
+ validator_confidence?: number;
83
+ validator_evidence?: string;
84
+ anchor_status?: 'anchored' | 'unanchored' | 'truncated' | 'rejected';
85
+ anchor_reason?: string;
58
86
  }
59
87
  /**
60
88
  * Rejected review receipt.
@@ -71,7 +99,10 @@ export interface RejectedReviewReceipt {
71
99
  reviewed_at: string;
72
100
  /** Fingerprint of the reviewed scope */
73
101
  scope_fingerprint: ScopeFingerprint;
74
- /** Blocking findings that caused rejection */
102
+ /**
103
+ * Rejected findings retained under the schema-v1 field name.
104
+ * Consumers must use effective severity when deciding which can block.
105
+ */
75
106
  blocking_findings: BlockingFinding[];
76
107
  /** Exact evidence references (file paths, line numbers, etc.) */
77
108
  evidence_references: string[];
@@ -79,6 +110,11 @@ export interface RejectedReviewReceipt {
79
110
  pass_conditions: string[];
80
111
  /** Optional free-text summary */
81
112
  summary?: string;
113
+ /** Original machine-readable reviewer payload, when one was available. */
114
+ structured_findings?: ReviewFinding[];
115
+ review_overall_confidence?: number;
116
+ /** Independent validator output, when validation was requested. */
117
+ finding_validations?: FindingValidation[];
82
118
  }
83
119
  /**
84
120
  * Approved review receipt.
@@ -101,6 +137,11 @@ export interface ApprovedReviewReceipt {
101
137
  validated_claims: string[];
102
138
  /** Residual risk or caveats */
103
139
  caveats?: string[];
140
+ /** Original machine-readable reviewer payload, when one was available. */
141
+ structured_findings?: ReviewFinding[];
142
+ review_overall_confidence?: number;
143
+ /** Independent validator output, when validation was requested. */
144
+ finding_validations?: FindingValidation[];
104
145
  }
105
146
  export type ReviewReceipt = RejectedReviewReceipt | ApprovedReviewReceipt;
106
147
  /** Index entry for fast lookup without reading every receipt file. */
@@ -121,6 +162,20 @@ export interface ReceiptIndex {
121
162
  export declare function resolveReceiptsDir(directory: string): string;
122
163
  /** Returns the index file path. */
123
164
  export declare function resolveReceiptIndexPath(directory: string): string;
165
+ export declare const _internals: {
166
+ openSync: typeof fs.openSync;
167
+ lstatBigIntSync: (path: fs.PathLike) => fs.BigIntStats;
168
+ fstatBigIntSync: (fd: number) => fs.BigIntStats;
169
+ };
170
+ /**
171
+ * Read a direct review-receipt file without following redirected ancestors.
172
+ *
173
+ * The directory identities are captured before opening, then revalidated
174
+ * around a descriptor-owned read. Comparing the opened descriptor with the
175
+ * pathname snapshots prevents a project/.swarm/review-receipts swap from
176
+ * redirecting the read outside the project between validation and open.
177
+ */
178
+ export declare function readReviewReceiptText(directory: string, receiptPath: string, maxBytes?: number): string | null;
124
179
  /**
125
180
  * Compute a SHA-256 scope fingerprint for a given content string.
126
181
  * The hash is deterministic: same content → same hash.
@@ -135,12 +190,45 @@ export declare function computeScopeFingerprint(content: string, scopeDescriptio
135
190
  * is treated as stale (conservative: assume the scope has changed).
136
191
  */
137
192
  export declare function isScopeStale(receipt: ReviewReceipt, currentContent: string | undefined): boolean;
193
+ export interface PersistReviewReceiptOptions {
194
+ /**
195
+ * Rebuild and verify the immutable reviewed scope immediately before each
196
+ * synchronous atomic rename. A false result aborts without publishing stale
197
+ * receipt/index state.
198
+ */
199
+ verifyCurrent?: () => Promise<boolean>;
200
+ }
201
+ export interface UpdateReviewReceiptValidationsOptions {
202
+ /** Refuse to update a receipt that no longer has the expected immutable identity. */
203
+ expectedIdentity?: {
204
+ id: string;
205
+ scopeHash: string;
206
+ scopeDescription: string;
207
+ };
208
+ /**
209
+ * Rebuild and verify the exact reviewer generation and scope immediately before
210
+ * the synchronous atomic rename. A false result discards the temporary update.
211
+ */
212
+ verifyCurrent?: () => Promise<boolean>;
213
+ }
138
214
  /**
139
215
  * Persist a review receipt (rejected or approved) to disk.
140
216
  * Creates .swarm/review-receipts/<date>-<id>.json and updates the index.
141
217
  * Returns the absolute path of the written receipt file.
142
218
  */
143
- export declare function persistReviewReceipt(directory: string, receipt: ReviewReceipt): Promise<string>;
219
+ export declare function persistReviewReceipt(directory: string, receipt: ReviewReceipt, options?: PersistReviewReceiptOptions): Promise<string>;
220
+ /**
221
+ * Remove a just-persisted receipt after a later persistence step fails.
222
+ *
223
+ * The index entry is committed first so a crash can leave at most an unindexed
224
+ * orphan file, never a dangling index entry that points at missing evidence.
225
+ */
226
+ export declare function removeReviewReceipt(directory: string, receiptPath: string, receiptId: string): Promise<void>;
227
+ /**
228
+ * Atomically attach independent finding-validation results to an existing
229
+ * receipt. The receipt identity and index entry remain unchanged.
230
+ */
231
+ export declare function updateReviewReceiptValidations(receiptPath: string, validations: FindingValidation[], options?: UpdateReviewReceiptValidationsOptions): Promise<void>;
144
232
  /**
145
233
  * Read a single receipt by ID. Returns null if not found or unreadable.
146
234
  */
@@ -168,6 +256,9 @@ export declare function buildRejectedReceipt(opts: {
168
256
  evidenceReferences: string[];
169
257
  passConditions: string[];
170
258
  summary?: string;
259
+ structuredFindings?: ReviewFinding[];
260
+ reviewOverallConfidence?: number;
261
+ findingValidations?: FindingValidation[];
171
262
  }): RejectedReviewReceipt;
172
263
  /**
173
264
  * Build an ApprovedReviewReceipt.
@@ -181,6 +272,9 @@ export declare function buildApprovedReceipt(opts: {
181
272
  checkedAspects: string[];
182
273
  validatedClaims: string[];
183
274
  caveats?: string[];
275
+ structuredFindings?: ReviewFinding[];
276
+ reviewOverallConfidence?: number;
277
+ findingValidations?: FindingValidation[];
184
278
  }): ApprovedReviewReceipt;
185
279
  /**
186
280
  * Build a structured context summary of prior receipts for critic drift
@@ -0,0 +1,21 @@
1
+ import * as fs from 'node:fs';
2
+ export declare const MAX_REVIEWER_SCOPE_FINGERPRINT_BYTES = 1048576;
3
+ export declare const MAX_REVIEWER_SCOPE_FINGERPRINT_AGGREGATE_BYTES = 4194304;
4
+ export type ReviewerScopeFileFingerprint = {
5
+ file: string;
6
+ kind: 'file';
7
+ size: number;
8
+ hash: string;
9
+ } | {
10
+ file: string;
11
+ kind: 'deleted';
12
+ };
13
+ export declare const _internals: {
14
+ readFileSync: typeof fs.readFileSync;
15
+ };
16
+ /**
17
+ * Capture the exact post-write file state with a bounded read. Oversized,
18
+ * non-regular, path-racing, and unreadable targets fail closed to null.
19
+ */
20
+ export declare function captureReviewerScopeFileFingerprint(directory: string, file: string, maxBytes?: number): ReviewerScopeFileFingerprint | null;
21
+ export declare function reviewerScopeFileFingerprintsEqual(left: ReviewerScopeFileFingerprint, right: ReviewerScopeFileFingerprint): boolean;
@@ -0,0 +1,19 @@
1
+ export type ReviewerScopeLifecycleTransition = 'coder_started' | 'coder_ready' | 'reviewer_claimed';
2
+ /** Run only after the complete blocking before-chain approved this Task call. */
3
+ export declare function beginApprovedReviewerScopeLifecycle(input: {
4
+ directory: string;
5
+ tool: unknown;
6
+ args: unknown;
7
+ parentSessionID: string;
8
+ callID: string;
9
+ maxBytes?: number;
10
+ }): Promise<ReviewerScopeLifecycleTransition | null>;
11
+ /** Mark a synchronous coder terminal; background running placeholders are inert. */
12
+ export declare function completeReviewerScopeLifecycle(input: {
13
+ directory: string;
14
+ tool: unknown;
15
+ args: unknown;
16
+ output: unknown;
17
+ parentSessionID: string;
18
+ callID: string;
19
+ }): Promise<ReviewerScopeLifecycleTransition | null>;
@@ -0,0 +1,6 @@
1
+ export type TaskResultClassification = 'running' | 'success' | 'non_success';
2
+ /**
3
+ * Shared Task-result classifier for every Stage-B lifecycle consumer.
4
+ * Explicit state/status and error fields win. Unknown shapes fail closed.
5
+ */
6
+ export declare function classifyTaskResult(output: unknown): TaskResultClassification;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Plugin } from '@opencode-ai/plugin';
2
2
  import { loadPluginConfigWithMetaAsync } from './config';
3
+ import { resolveAutoReviewConfig } from './config/schema';
3
4
  import { createRepoGraphBuilderHook } from './hooks';
4
5
  import { loadSnapshot } from './session/snapshot-reader.js';
5
6
  import { ensureSwarmGitExcluded } from './utils/gitignore-warning';
@@ -24,6 +25,7 @@ export declare function overrideIndexInternalsForTest(overrides: {
24
25
  loadPluginConfigWithMetaAsync?: typeof loadPluginConfigWithMetaAsync;
25
26
  loadSnapshot?: typeof loadSnapshot;
26
27
  ensureSwarmGitExcluded?: typeof ensureSwarmGitExcluded;
28
+ resolveAutoReviewConfig?: typeof resolveAutoReviewConfig;
27
29
  }): () => void;
28
30
  export declare function schedulePostResolutionTasksForTest(tasks: readonly PostResolutionTask[]): void;
29
31
  /**