opencode-swarm 7.123.0 → 7.125.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 (111) hide show
  1. package/.opencode/skills/critic-gate/SKILL.md +8 -0
  2. package/.opencode/skills/swarm/SKILL.md +12 -8
  3. package/.opencode/skills/swarm-pr-feedback/SKILL.md +252 -62
  4. package/.opencode/skills/swarm-pr-review/SKILL.md +242 -76
  5. package/README.md +6 -1
  6. package/dist/background/lane-output-store.d.ts +10 -0
  7. package/dist/background/pending-delegations.d.ts +3 -0
  8. package/dist/background/workspace-snapshot.d.ts +59 -0
  9. package/dist/cli/{config-doctor-3ksh1534.js → config-doctor-be9sxqx8.js} +6 -6
  10. package/dist/cli/{core-cwgb7ev8.js → core-d38hc85b.js} +4 -4
  11. package/dist/cli/{curation-policy-4j4qce5a.js → curation-policy-52kt6d7t.js} +2 -2
  12. package/dist/cli/{curator-drift-6b2fjsgr.js → curator-drift-h9a2sjvf.js} +7 -7
  13. package/dist/cli/{curator-tkyn9bzz.js → curator-hbst8nbc.js} +32 -30
  14. package/dist/cli/curator-llm-factory-frde1955.js +54 -0
  15. package/dist/cli/{dispatch-07jgc3hn.js → dispatch-f4hj1cj7.js} +3 -3
  16. package/dist/cli/{evidence-summary-service-96ndczbk.js → evidence-summary-service-9hq7n9k9.js} +12 -12
  17. package/dist/cli/{gate-evidence-xqks3kk2.js → gate-evidence-cy2te3x8.js} +2 -2
  18. package/dist/cli/guardrail-explain-112kqmbc.js +55 -0
  19. package/dist/cli/guardrail-log-c8zcab91.js +16 -0
  20. package/dist/cli/hive-promoter-448xs2tp.js +69 -0
  21. package/dist/cli/{index-hns7xjm7.js → index-09vd53pz.js} +4 -2
  22. package/dist/cli/{pending-delegations-68cbaqv2.js → index-0cz1ws47.js} +9 -21
  23. package/dist/cli/{index-det5jwfk.js → index-0y6tmm9v.js} +5 -1
  24. package/dist/cli/index-134d35c1.js +116 -0
  25. package/dist/cli/{index-m1abzg93.js → index-1kz6da87.js} +4 -2
  26. package/dist/cli/{index-22e127jw.js → index-23zsx7dm.js} +5 -3
  27. package/dist/cli/{index-kzj3fp7c.js → index-2445sx3d.js} +1 -1
  28. package/dist/cli/{index-ctpgsj84.js → index-2tn5h2zp.js} +1 -1
  29. package/dist/cli/{index-6xnxz6z0.js → index-3x761jqv.js} +4 -2
  30. package/dist/cli/{index-7cspygmb.js → index-4rzzzjtg.js} +11 -8
  31. package/dist/cli/{index-cqsak7bf.js → index-67hqr2zv.js} +1 -1
  32. package/dist/cli/{index-nprawcc0.js → index-6n2jpz7x.js} +1 -1
  33. package/dist/cli/{index-19zn67q6.js → index-6vfvc36k.js} +5 -1
  34. package/dist/cli/{index-6sgqnvpw.js → index-7j3sm7h8.js} +2 -2
  35. package/dist/cli/{index-2j25br0p.js → index-958hf0yr.js} +9 -9
  36. package/dist/cli/{index-j9kxwshw.js → index-99ed0h32.js} +8 -6
  37. package/dist/cli/{index-7g91saha.js → index-9hbwa5x1.js} +40 -32
  38. package/dist/cli/{index-jyrhy4ww.js → index-amspa811.js} +3179 -1557
  39. package/dist/cli/index-bk5tah7q.js +19 -0
  40. package/dist/cli/{index-293f68mj.js → index-bpmtbmy9.js} +4680 -4342
  41. package/dist/cli/{index-m0bmh3w0.js → index-dx2c2wjt.js} +2 -2
  42. package/dist/cli/{index-ye3fndsw.js → index-gacm5s2n.js} +9 -5
  43. package/dist/cli/{index-d6h5hq91.js → index-gnvg72y1.js} +2 -2
  44. package/dist/cli/{index-17eybc3z.js → index-jh6s75f6.js} +1 -1
  45. package/dist/cli/{index-vcgfqd8f.js → index-k5jrywpr.js} +4 -2
  46. package/dist/cli/{index-3rr0ese8.js → index-kt0awv1n.js} +41 -9
  47. package/dist/cli/index-mg54y5gc.js +564 -0
  48. package/dist/cli/{index-dywekeen.js → index-n6chz2g8.js} +1 -1
  49. package/dist/cli/{index-gnp9x6se.js → index-n832052r.js} +4 -2
  50. package/dist/cli/{index-816rkp4y.js → index-s9mj4rb9.js} +5 -3
  51. package/dist/cli/{index-gw3m5fw0.js → index-v2rdhwx8.js} +5 -3
  52. package/dist/cli/{index-q00e4s1s.js → index-vtwqjr4z.js} +11 -7
  53. package/dist/cli/index-xattnmyb.js +2502 -0
  54. package/dist/cli/{index-n2712byd.js → index-yt1v62pv.js} +8 -5
  55. package/dist/cli/{index-5e4e2hvv.js → index-z6xqpmqg.js} +4 -0
  56. package/dist/cli/{index-p0arc26j.js → index-zjygnfay.js} +7 -2
  57. package/dist/cli/index.js +35 -31
  58. package/dist/cli/{knowledge-escalator-dyxsm78k.js → knowledge-escalator-htafbhxg.js} +4 -4
  59. package/dist/cli/{knowledge-events-36q6nvae.js → knowledge-events-havw8c4t.js} +1 -1
  60. package/dist/cli/{knowledge-store-e07b4s54.js → knowledge-store-hqngpt2v.js} +2 -2
  61. package/dist/cli/{knowledge-validator-sfyf7wn2.js → knowledge-validator-g7mpnazh.js} +5 -5
  62. package/dist/cli/pending-delegations-7j8xqg5f.js +34 -0
  63. package/dist/cli/{pr-subscriptions-x653151h.js → pr-subscriptions-bxpqde8w.js} +5 -5
  64. package/dist/cli/{scan-cursor-hm0aqqae.js → scan-cursor-sx7cvh8v.js} +3 -3
  65. package/dist/cli/{schema-13bnng2n.js → schema-2418eqy3.js} +7 -4
  66. package/dist/cli/{scope-persistence-d9erwnvb.js → scope-persistence-habn4q8a.js} +4 -4
  67. package/dist/cli/{skill-generator-63r20a9k.js → skill-generator-zggy797r.js} +7 -7
  68. package/dist/cli/sqlite-loader-r1kgt2pq.js +12 -0
  69. package/dist/cli/workspace-snapshot-c9pxxt9a.js +48 -0
  70. package/dist/commands/memory-link.d.ts +28 -0
  71. package/dist/commands/registry.d.ts +26 -1
  72. package/dist/config/schema.d.ts +6 -0
  73. package/dist/hooks/pr-workflow-gate.d.ts +211 -0
  74. package/dist/hooks/pr-workflow-response-gate.d.ts +23 -0
  75. package/dist/hooks/pr-workflow-session-resolver.d.ts +14 -0
  76. package/dist/index.js +496 -451
  77. package/dist/knowledge/family-migration-shared.d.ts +24 -0
  78. package/dist/knowledge/family-migration.d.ts +5 -0
  79. package/dist/memory/config.d.ts +11 -0
  80. package/dist/memory/consolidation-log.d.ts +8 -2
  81. package/dist/memory/finalize-reward-sweep.d.ts +2 -1
  82. package/dist/memory/gateway.d.ts +13 -0
  83. package/dist/memory/index.d.ts +4 -2
  84. package/dist/memory/local-jsonl-provider.d.ts +25 -1
  85. package/dist/memory/memory-family-manifest.d.ts +52 -0
  86. package/dist/memory/memory-family-migration.d.ts +94 -0
  87. package/dist/memory/memory-link.d.ts +103 -0
  88. package/dist/memory/provider-pool.d.ts +35 -0
  89. package/dist/memory/redaction.d.ts +31 -0
  90. package/dist/memory/schema.d.ts +21 -0
  91. package/dist/memory/sqlite-provider.d.ts +58 -1
  92. package/dist/memory/storage-root.d.ts +93 -0
  93. package/dist/memory/types.d.ts +20 -1
  94. package/dist/services/knowledge-diagnostics.d.ts +25 -0
  95. package/dist/services/status-service.d.ts +16 -0
  96. package/dist/tools/complete-pr-workflow.d.ts +5 -0
  97. package/dist/tools/dispatch-lanes.d.ts +44 -0
  98. package/dist/tools/index.d.ts +2 -0
  99. package/dist/tools/manifest.d.ts +2 -0
  100. package/dist/tools/run-pr-feedback-stage-a.d.ts +69 -0
  101. package/dist/tools/tool-metadata.d.ts +8 -0
  102. package/dist/tools/write-pr-review-trigger-eval.d.ts +56 -46
  103. package/package.json +1 -1
  104. package/dist/cli/curator-llm-factory-mfvd4sqx.js +0 -52
  105. package/dist/cli/guardrail-explain-4vytbchb.js +0 -53
  106. package/dist/cli/guardrail-log-z291m4gw.js +0 -16
  107. package/dist/cli/hive-promoter-y5wsztkc.js +0 -67
  108. package/dist/cli/index-4rhcth7a.js +0 -14
  109. package/dist/cli/index-dqh3zhhc.js +0 -133
  110. package/dist/cli/index-wr8qgpz5.js +0 -2463
  111. package/dist/cli/workspace-snapshot-eyf6gd0d.js +0 -22
@@ -18,6 +18,14 @@ export interface SQLiteJsonlImportResult {
18
18
  export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryProposalStore {
19
19
  readonly name = "sqlite";
20
20
  private readonly rootDirectory;
21
+ /**
22
+ * #1850: when set, the provider serves a cohort-shared store rather than
23
+ * the worktree-local `.swarm/memory`. Cohort roots live under the platform
24
+ * data dir (`<dataDir>/links/<linkId>/memory`) and bypass
25
+ * `validateSwarmPath` by construction (the resolver sanitizes the linkId).
26
+ * `null` for local-root providers (today's behavior, still validated).
27
+ */
28
+ private readonly cohortRoot;
21
29
  private readonly config;
22
30
  private initialized;
23
31
  private initPromise;
@@ -32,7 +40,24 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
32
40
  private lastAutomaticJsonlMigration;
33
41
  private recallCountSinceLastCompaction;
34
42
  private isCompacting;
35
- constructor(rootDirectory: string, config?: Partial<MemoryConfig>);
43
+ constructor(rootDirectory: string, config?: Partial<MemoryConfig>,
44
+ /**
45
+ * #1850: optional cohort root. When provided, the provider opens the DB
46
+ * at `<cohortRoot>/memory.db` and bypasses `validateSwarmPath` (the
47
+ * cohort root is resolver-constructed from a sanitized linkId, not a
48
+ * user-supplied path). When omitted, the provider uses the worktree
49
+ * `.swarm` path with full `validateSwarmPath` enforcement (today's
50
+ * behavior).
51
+ */
52
+ vettedCohortRoot?: string | null);
53
+ /**
54
+ * #1850 (critic GAP-5): explicit cohort-root path branch.
55
+ * - cohort root → `<cohortRoot>/memory.db` (NO validateSwarmPath — the
56
+ * cohort root is a platform-data-dir path constructed by the resolver
57
+ * from a sanitized linkId, never from user input).
58
+ * - local root → existing behavior: strip `.swarm/` prefix, pass through
59
+ * `validateSwarmPath` to enforce `.swarm` containment.
60
+ */
36
61
  private databasePath;
37
62
  initialize(): Promise<void>;
38
63
  private doInitialize;
@@ -57,6 +82,23 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
57
82
  }): Promise<MemoryProposal[]>;
58
83
  applyCuratorDecision(decision: ResolvedCuratorMemoryDecision): Promise<AppliedMemoryChange>;
59
84
  close(): void;
85
+ /**
86
+ * #1850 (critic CONCERN-3): checkpoint the WAL into the main DB, then
87
+ * close the handle. Used by the memory family migration engine before it
88
+ * copies the DB file, so the copy reflects all committed writes and is not
89
+ * mid-checkpoint. After this call, the provider is closed and must be
90
+ * re-opened (the migration engine re-creates it via the pool).
91
+ *
92
+ * Returns the absolute paths to copy: `memory.db` plus any non-empty
93
+ * `-wal`/`-shm` sidecars (after a TRUNCATE checkpoint the WAL is typically
94
+ * empty; if it is not, copying it alongside the DB is still correct because
95
+ * SQLite recovers from WAL on next open).
96
+ */
97
+ checkpointCloseSnapshot(): {
98
+ dbPath: string;
99
+ walPath: string | null;
100
+ shmPath: string | null;
101
+ };
60
102
  /**
61
103
  * Re-embed all durable memory records with the current embedding provider
62
104
  * model, update the stored global model_version, and clear the embedding
@@ -94,6 +136,21 @@ export declare class SQLiteMemoryProvider implements MemoryProvider, MemoryPropo
94
136
  private loadMemories;
95
137
  private loadProposals;
96
138
  private writeMemory;
139
+ /**
140
+ * #1850: write a monotonic generation marker so siblings re-open their
141
+ * in-memory mirror. Fire-and-forget; failures are non-fatal (peers simply
142
+ * revalidate on the next pointer-stat change or TTL expiry).
143
+ */
144
+ private bumpCohortGeneration;
145
+ /**
146
+ * #1850 (reviewer important fix): read `memory-cohort-config.json` and fail
147
+ * closed if the stored provider/embedding/redaction fingerprint disagrees
148
+ * with this worktree's config (acceptance #10). Absent file = first link
149
+ * (permissive — the linker writes it immediately after migration). A
150
+ * malformed file is also permissive (fail-open never strands memory, but
151
+ * a mismatch is a hard error).
152
+ */
153
+ private assertCohortConfigFingerprint;
97
154
  private writeMemoryFts;
98
155
  private writeMemoryVec;
99
156
  private deleteMemoryFts;
@@ -0,0 +1,93 @@
1
+ /**
2
+ * #1850 Linked Knowledge 5/5: vetted memory storage-root capability.
3
+ *
4
+ * Problem: when cohort memory sharing is opted in, the memory provider must
5
+ * open a database at a cohort-scoped root (under the platform data dir), not
6
+ * the worktree's `.swarm/memory`. But accepting an arbitrary external path
7
+ * would violate `validateSwarmPath` and `.swarm` containment (AGENTS.md
8
+ * invariant #4, issue #1850 acceptance #3).
9
+ *
10
+ * Resolution: a narrow discriminated union `VettedMemoryRoot` that can only
11
+ * represent one of two validated shapes:
12
+ * - `{kind:'local'}` — the worktree's `.swarm/memory` root (today's path,
13
+ * still gated by `validateSwarmPath` in the provider constructors).
14
+ * - `{kind:'cohort'}` — a cohort root derived from the #1846 cohort
15
+ * identity via the sanitized linkId. Constructed only by
16
+ * `resolveVettedMemoryRoot` from the memory-link pointer; there is no
17
+ * public `openMemoryAt(arbitraryPath)` entry.
18
+ *
19
+ * Cohort roots live under `<dataDir>/links/<linkId>/memory/` — the SAME shared
20
+ * store directory used by knowledge linking, namespaced under `memory/`. The
21
+ * `validateSwarmPath` invariant is preserved by construction: cohort roots are
22
+ * never passed through it (they are platform-data-dir paths, not `.swarm`
23
+ * paths), and local roots continue to flow through the existing validation.
24
+ *
25
+ * This module is sync-only and side-effect-free (a pointer read) so it is safe
26
+ * to call from the lazy gateway constructor on the plugin hot path.
27
+ */
28
+ import type { MemoryConfig } from './config.js';
29
+ import { type MemoryLinkPointer } from './memory-link.js';
30
+ /**
31
+ * The vetted root. `directory` is always the worktree's project root (so
32
+ * providers can still derive auxiliary per-worktree paths when needed); `root`
33
+ * is the resolved storage root (worktree `.swarm` for local, cohort dir for
34
+ * cohort).
35
+ */
36
+ export type VettedMemoryRoot = {
37
+ kind: 'local';
38
+ /** Resolved worktree `.swarm` directory (parent of `storageDir`). */
39
+ root: string;
40
+ /** Original worktree project root (ctx.directory). */
41
+ directory: string;
42
+ } | {
43
+ kind: 'cohort';
44
+ /** Cohort memory root: `<dataDir>/links/<linkId>/memory`. */
45
+ cohortRoot: string;
46
+ /** Canonical cohort id from #1846 (shared by all sibling worktrees). */
47
+ cohortId: string;
48
+ /** Monotonic link generation (bumped on link/unlink; aids revalidation). */
49
+ generation: number;
50
+ /** Sanitized linkId (the cohort directory segment). */
51
+ linkId: string;
52
+ /** Original worktree project root (ctx.directory). */
53
+ directory: string;
54
+ };
55
+ /**
56
+ * Resolve the vetted memory root for a worktree. Sync, side-effect-free.
57
+ *
58
+ * Decision tree:
59
+ * 1. If `config.link?.enabled !== true` → local (today's behavior).
60
+ * 2. Read the memory-link pointer. If absent or malformed → local.
61
+ * 3. If the pointer resolves to a cohort store → cohort root under
62
+ * `<resolveMemoryStoreDir(directory)>/memory`. `resolveMemoryStoreDir`
63
+ * already canonicalizes via `path.resolve` and revalidates the pointer
64
+ * stat on cache hits (mirrors `resolveKnowledgeStoreDir` in
65
+ * `src/hooks/knowledge-link.ts:396`).
66
+ *
67
+ * The cohort memory root is `<resolveMemoryStoreDir(directory)>/memory` — a
68
+ * `memory/` subdirectory of the shared link dir, sibling to the knowledge
69
+ * family files. This keeps knowledge and memory in the same cohort container
70
+ * without colliding filenames.
71
+ */
72
+ export declare function resolveVettedMemoryRoot(directory: string, config: Pick<MemoryConfig, 'link'> | Partial<Pick<MemoryConfig, 'link'>>): VettedMemoryRoot;
73
+ /**
74
+ * Backward-compat shim: wraps a raw directory into a local vetted root. Emits
75
+ * a debug log so incomplete wiring (a caller that should have resolved a vetted
76
+ * root itself) is visible during development (critic CONCERN-5).
77
+ */
78
+ export declare function wrapLocalRoot(directory: string): VettedMemoryRoot;
79
+ /** Type guard for the cohort branch. */
80
+ export declare function isCohortRoot(root: VettedMemoryRoot): root is Extract<VettedMemoryRoot, {
81
+ kind: 'cohort';
82
+ }>;
83
+ /** Type guard for the local branch. */
84
+ export declare function isLocalRoot(root: VettedMemoryRoot): root is Extract<VettedMemoryRoot, {
85
+ kind: 'local';
86
+ }>;
87
+ /** Return the resolved storage path for a given root (no validation). */
88
+ export declare function rootStoragePath(root: VettedMemoryRoot): string;
89
+ export declare const _internals: {
90
+ resolveVettedMemoryRoot: typeof resolveVettedMemoryRoot;
91
+ wrapLocalRoot: typeof wrapLocalRoot;
92
+ };
93
+ export type { MemoryLinkPointer };
@@ -1,4 +1,4 @@
1
- export type MemoryScopeType = 'global_user' | 'workspace' | 'project' | 'repository' | 'run' | 'agent';
1
+ export type MemoryScopeType = 'global_user' | 'workspace' | 'project' | 'repository' | 'run' | 'agent' | 'cohort';
2
2
  export interface MemoryScopeRef {
3
3
  type: MemoryScopeType;
4
4
  userId?: string;
@@ -8,6 +8,10 @@ export interface MemoryScopeRef {
8
8
  repoRoot?: string;
9
9
  runId?: string;
10
10
  agentId?: string;
11
+ /** Canonical cohort id from `resolveCohortId` (#1850). Set when
12
+ * `type === 'cohort'`. Required for cohort-scoped records so the scope key
13
+ * and recall filters distinguish different cohorts. */
14
+ cohortId?: string;
11
15
  }
12
16
  export type MemoryKind = 'user_preference' | 'project_fact' | 'architecture_decision' | 'repo_convention' | 'api_finding' | 'code_pattern' | 'test_pattern' | 'failure_pattern' | 'security_note' | 'evidence' | 'todo' | 'scratch';
13
17
  export interface MemorySource {
@@ -35,6 +39,21 @@ export interface MemoryRecord {
35
39
  supersededBy?: string;
36
40
  contentHash: string;
37
41
  metadata: Record<string, unknown>;
42
+ /** Canonical cohort id the record belongs to. Matches `scope.cohortId`
43
+ * when `scope.type === 'cohort'`. */
44
+ cohortId?: string;
45
+ /** Session id of the producer (when policy permits retention). */
46
+ producerSessionId?: string;
47
+ /** Agent role of the producer. */
48
+ producerAgentRole?: string;
49
+ /** Redaction policy version at write time (from REDACTION_POLICY_VERSION). */
50
+ redactionPolicyVersion?: number;
51
+ /** Memory schema version at write time. */
52
+ schemaVersion?: number;
53
+ /** Provider name at write time (`'sqlite'` | `'local-jsonl'`). */
54
+ providerVersion?: string;
55
+ /** Source git revision of the producer, when available. */
56
+ sourceRevision?: string;
38
57
  }
39
58
  export interface MemoryProposal {
40
59
  id: string;
@@ -132,6 +132,31 @@ export interface KnowledgeDebugMeta {
132
132
  */
133
133
  pending_proposals: number;
134
134
  };
135
+ /**
136
+ * #1850: memory cohort link health. Distinct from the knowledge `cohort`
137
+ * block so diagnostics can report knowledge-link and memory-link
138
+ * independently. Carries provider/config fingerprint agreement so an
139
+ * operator can detect cohort divergence. No record text is emitted here
140
+ * (diagnostics-no-leakage discipline, acceptance #13).
141
+ */
142
+ memory: {
143
+ linked: boolean;
144
+ pointer_version: 1 | 2 | null;
145
+ link_id: string | null;
146
+ cohort_id: string | null;
147
+ identity_source: 'remote' | 'git-common-dir' | 'path' | null;
148
+ degraded: boolean;
149
+ shared_root: string | null;
150
+ generation: number | null;
151
+ /** Provider name from config ('sqlite' | 'local-jsonl'). */
152
+ provider: string | null;
153
+ /**
154
+ * #1850 (KC-002): config fingerprint agreement — true when this
155
+ * worktree's config matches the cohort's stored fingerprint, false on
156
+ * mismatch, null when not checked (unlinked or file absent).
157
+ */
158
+ config_fingerprint_match: boolean | null;
159
+ };
135
160
  }
136
161
  /**
137
162
  * Compute the debug-metadata block for the knowledge system. Best-effort: never
@@ -91,6 +91,22 @@ export interface StatusData {
91
91
  sharedRoot?: string;
92
92
  generation?: number;
93
93
  };
94
+ /**
95
+ * #1850: memory cohort link status. Distinct from `cohort` (knowledge link)
96
+ * so status can distinguish knowledge-linked from memory-linked (acceptance
97
+ * #2). Carries provider/config/privacy health fields.
98
+ */
99
+ memoryCohort?: {
100
+ linked: boolean;
101
+ linkId?: string;
102
+ cohortId?: string;
103
+ identitySource?: 'remote' | 'git-common-dir' | 'path';
104
+ degraded?: boolean;
105
+ sharedRoot?: string;
106
+ generation?: number;
107
+ provider?: string;
108
+ configFingerprintMatch?: boolean;
109
+ };
94
110
  }
95
111
  /**
96
112
  * Get status data from the swarm directory.
@@ -0,0 +1,5 @@
1
+ import { createSwarmTool } from './create-tool.js';
2
+ export declare function executeCompletePrWorkflow(args: unknown, directory: string, context?: {
3
+ sessionID?: string;
4
+ }): Promise<string>;
5
+ export declare const complete_pr_workflow: ReturnType<typeof createSwarmTool>;
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { resolveExactMergeBase, resolvePrWorkflowRevisionDigest } from '../background/workspace-snapshot.js';
2
3
  import { createParallelDispatcher } from '../parallel/dispatcher/parallel-dispatcher.js';
3
4
  import { createSwarmTool } from './create-tool.js';
4
5
  export declare const MAX_PROMPT_CHARS = 80000;
@@ -6,12 +7,18 @@ declare const LaneSchema: z.ZodObject<{
6
7
  id: z.ZodString;
7
8
  agent: z.ZodString;
8
9
  prompt: z.ZodString;
10
+ workflow_lane: z.ZodOptional<z.ZodString>;
11
+ feedback_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
12
+ review_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
9
13
  }, z.core.$strip>;
10
14
  declare const DispatchLanesArgsSchema: z.ZodObject<{
11
15
  lanes: z.ZodArray<z.ZodObject<{
12
16
  id: z.ZodString;
13
17
  agent: z.ZodString;
14
18
  prompt: z.ZodString;
19
+ workflow_lane: z.ZodOptional<z.ZodString>;
20
+ feedback_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
+ review_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
15
22
  }, z.core.$strip>>;
16
23
  common_prompt: z.ZodOptional<z.ZodString>;
17
24
  max_concurrent: z.ZodOptional<z.ZodNumber>;
@@ -22,6 +29,9 @@ declare const DispatchLanesAsyncArgsSchema: z.ZodObject<{
22
29
  id: z.ZodString;
23
30
  agent: z.ZodString;
24
31
  prompt: z.ZodString;
32
+ workflow_lane: z.ZodOptional<z.ZodString>;
33
+ feedback_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
+ review_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
35
  }, z.core.$strip>>;
26
36
  common_prompt: z.ZodOptional<z.ZodString>;
27
37
  max_concurrent: z.ZodOptional<z.ZodNumber>;
@@ -30,7 +40,15 @@ declare const DispatchLanesAsyncArgsSchema: z.ZodObject<{
30
40
  batch_id: z.ZodOptional<z.ZodString>;
31
41
  mode: z.ZodOptional<z.ZodString>;
32
42
  pr_head_sha: z.ZodOptional<z.ZodString>;
43
+ base_sha: z.ZodOptional<z.ZodString>;
44
+ base_ref: z.ZodOptional<z.ZodString>;
33
45
  scope: z.ZodOptional<z.ZodString>;
46
+ trigger_evaluation: z.ZodOptional<z.ZodArray<z.ZodObject<{
47
+ trigger_id: z.ZodString;
48
+ result: z.ZodLiteral<"MATCHED">;
49
+ evidence: z.ZodString;
50
+ }, z.core.$strict>>>;
51
+ feedback_inventory: z.ZodOptional<z.ZodArray<z.ZodString>>;
34
52
  }, z.core.$strip>;
35
53
  declare const CollectLaneResultsArgsSchema: z.ZodObject<{
36
54
  batch_id: z.ZodString;
@@ -213,12 +231,16 @@ export declare const _internals: {
213
231
  getSessionOps: () => SessionOps | null;
214
232
  getGeneratedAgentNames: () => readonly string[];
215
233
  createParallelDispatcher: typeof createParallelDispatcher;
234
+ resolvePrWorkflowRevisionDigest: typeof resolvePrWorkflowRevisionDigest;
235
+ resolveExactMergeBase: typeof resolveExactMergeBase;
216
236
  now: () => number;
217
237
  sleep: (ms: number) => Promise<void>;
218
238
  };
219
239
  export declare const _test_exports: {
220
240
  applyCommonPrompt: typeof applyCommonPrompt;
221
241
  applyExplorerFormatSuffix: typeof applyExplorerFormatSuffix;
242
+ applyPrWorkflowPromptContract: typeof applyPrWorkflowPromptContract;
243
+ buildReadOnlyTools: typeof buildReadOnlyTools;
222
244
  buildLaneSessionCreateArgs: typeof buildLaneSessionCreateArgs;
223
245
  extractAssistantTranscript: typeof extractAssistantTranscript;
224
246
  formatError: typeof formatError;
@@ -229,6 +251,9 @@ export declare const _test_exports: {
229
251
  id: z.ZodString;
230
252
  agent: z.ZodString;
231
253
  prompt: z.ZodString;
254
+ workflow_lane: z.ZodOptional<z.ZodString>;
255
+ feedback_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
256
+ review_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
232
257
  }, z.core.$strip>>;
233
258
  common_prompt: z.ZodOptional<z.ZodString>;
234
259
  max_concurrent: z.ZodOptional<z.ZodNumber>;
@@ -239,6 +264,9 @@ export declare const _test_exports: {
239
264
  id: z.ZodString;
240
265
  agent: z.ZodString;
241
266
  prompt: z.ZodString;
267
+ workflow_lane: z.ZodOptional<z.ZodString>;
268
+ feedback_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
269
+ review_item_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
242
270
  }, z.core.$strip>>;
243
271
  common_prompt: z.ZodOptional<z.ZodString>;
244
272
  max_concurrent: z.ZodOptional<z.ZodNumber>;
@@ -247,7 +275,15 @@ export declare const _test_exports: {
247
275
  batch_id: z.ZodOptional<z.ZodString>;
248
276
  mode: z.ZodOptional<z.ZodString>;
249
277
  pr_head_sha: z.ZodOptional<z.ZodString>;
278
+ base_sha: z.ZodOptional<z.ZodString>;
279
+ base_ref: z.ZodOptional<z.ZodString>;
250
280
  scope: z.ZodOptional<z.ZodString>;
281
+ trigger_evaluation: z.ZodOptional<z.ZodArray<z.ZodObject<{
282
+ trigger_id: z.ZodString;
283
+ result: z.ZodLiteral<"MATCHED">;
284
+ evidence: z.ZodString;
285
+ }, z.core.$strict>>>;
286
+ feedback_inventory: z.ZodOptional<z.ZodArray<z.ZodString>>;
251
287
  }, z.core.$strip>;
252
288
  DEFAULT_TIMEOUT_MS: number;
253
289
  DEFAULT_ASYNC_LAUNCH_TIMEOUT_MS: number;
@@ -280,6 +316,7 @@ declare function extractAssistantTranscript(messages: Array<{
280
316
  transcriptIncomplete: boolean;
281
317
  };
282
318
  declare function nextCollectPollInterval(currentMs: number): number;
319
+ declare function buildReadOnlyTools(): ReadOnlyToolPermissions;
283
320
  type ApplyCommonPromptResult = {
284
321
  ok: true;
285
322
  lanes: DispatchLaneSpec[];
@@ -299,6 +336,13 @@ type ApplyCommonPromptResult = {
299
336
  */
300
337
  declare function applyCommonPrompt(lanes: DispatchLaneSpec[], commonPrompt: string | undefined): ApplyCommonPromptResult;
301
338
  declare function applyExplorerFormatSuffix(lanes: DispatchLaneSpec[]): DispatchLaneSpec[];
339
+ declare function applyPrWorkflowPromptContract(lanes: DispatchLaneSpec[], options: {
340
+ mode?: string;
341
+ prHeadSha?: string;
342
+ revisionDigest?: string;
343
+ scope?: string;
344
+ callerFocus?: string;
345
+ }): ApplyCommonPromptResult;
302
346
  declare function formatError(error: unknown): string;
303
347
  declare function buildLaneSessionCreateArgs(directory: string, lane: DispatchLaneSpec, context: Pick<DispatchLanesExecutionContext, 'sessionID'>): {
304
348
  body: {
@@ -86,6 +86,7 @@ export type { ClassifiedFailure, FailureClassification, FailureCluster, } from '
86
86
  export { classifyAndCluster, classifyFailure, clusterFailures, } from '../test-impact/failure-classifier.js';
87
87
  export type { FlakyTestEntry } from '../test-impact/flaky-detector.js';
88
88
  export { computeFlakyScore, detectFlakyTests, isTestQuarantined, } from '../test-impact/flaky-detector.js';
89
+ export { complete_pr_workflow, executeCompletePrWorkflow, } from './complete-pr-workflow';
89
90
  export { epic_plan_waves } from './epic-plan-waves';
90
91
  export { epic_record_divergence } from './epic-record-divergence';
91
92
  export { epic_decide_phase } from './epic-run-phase';
@@ -98,6 +99,7 @@ export { lean_turbo_runner_status } from './lean-turbo-runner-status';
98
99
  export { lean_turbo_status } from './lean-turbo-status';
99
100
  export { lint_spec } from './lint-spec';
100
101
  export { mutation_test } from './mutation-test';
102
+ export { executeRunPrFeedbackStageA, run_pr_feedback_stage_a, } from './run-pr-feedback-stage-a';
101
103
  export { symbols } from './symbols';
102
104
  export { type SyntaxCheckFileResult, type SyntaxCheckInput, type SyntaxCheckResult, syntax_check, syntaxCheck, } from './syntax-check';
103
105
  export { test_impact } from './test-impact';
@@ -42,6 +42,8 @@ export declare const TOOL_MANIFEST: {
42
42
  evidence_check: () => ToolDefinition;
43
43
  check_gate_status: () => ToolDefinition;
44
44
  completion_verify: () => ToolDefinition;
45
+ complete_pr_workflow: () => ToolDefinition;
46
+ run_pr_feedback_stage_a: () => ToolDefinition;
45
47
  submit_council_verdicts: () => ToolDefinition;
46
48
  submit_phase_council_verdicts: () => ToolDefinition;
47
49
  declare_council_criteria: () => ToolDefinition;
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ import { readGitTextAtRevision, resolveCurrentGitHead, resolveExactMergeBase, resolveGitControlStateDigest, resolvePrWorkflowRevisionDigest } from '../background/workspace-snapshot.js';
3
+ import { runExternalTool } from '../utils/external-tool-runner.js';
4
+ import { createSwarmTool } from './create-tool.js';
5
+ declare const STAGE_A_CATEGORIES: readonly ["build", "typecheck", "lint", "diff-check", "reproduction"];
6
+ type StageACategory = (typeof STAGE_A_CATEGORIES)[number];
7
+ declare const OPTIONAL_STAGE_A_CATEGORIES: readonly ["build", "typecheck", "lint"];
8
+ type OptionalStageACategory = (typeof OPTIONAL_STAGE_A_CATEGORIES)[number];
9
+ interface StageAObligation {
10
+ id: string;
11
+ category: OptionalStageACategory;
12
+ workingDirectory: string;
13
+ source: string;
14
+ validatorContract?: {
15
+ path: string;
16
+ id: string;
17
+ };
18
+ }
19
+ interface ContractBaseProvenance {
20
+ baseRef: string;
21
+ baseSha: string;
22
+ }
23
+ declare const StageACheckSchema: z.ZodObject<{
24
+ category: z.ZodEnum<{
25
+ lint: "lint";
26
+ build: "build";
27
+ typecheck: "typecheck";
28
+ "diff-check": "diff-check";
29
+ reproduction: "reproduction";
30
+ }>;
31
+ command: z.ZodArray<z.ZodString>;
32
+ targets: z.ZodOptional<z.ZodArray<z.ZodString>>;
33
+ feedback_targets: z.ZodOptional<z.ZodArray<z.ZodObject<{
34
+ feedback_item_id: z.ZodString;
35
+ target: z.ZodString;
36
+ expected_behavior: z.ZodString;
37
+ }, z.core.$strict>>>;
38
+ working_directory: z.ZodOptional<z.ZodString>;
39
+ obligation_id: z.ZodOptional<z.ZodString>;
40
+ validator_contract: z.ZodOptional<z.ZodObject<{
41
+ path: z.ZodString;
42
+ id: z.ZodString;
43
+ }, z.core.$strict>>;
44
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
45
+ }, z.core.$strict>;
46
+ declare function isPlausibleStageACommand(category: StageACategory, command: readonly string[]): boolean;
47
+ type StageACheckInput = z.infer<typeof StageACheckSchema>;
48
+ declare function commandMatchesObligationSource(directory: string, obligation: StageAObligation, check: StageACheckInput, contractValidated: boolean): boolean;
49
+ /** Discover concrete workspace/category/source obligations from bounded local signals. */
50
+ declare function discoverApplicableStageAObligations(directory: string, contractBase?: ContractBaseProvenance): StageAObligation[];
51
+ declare function discoverApplicableStageACategories(directory: string, contractBase?: ContractBaseProvenance): OptionalStageACategory[];
52
+ /** Execute every mandatory repository-generic Stage A category and persist receipts. */
53
+ export declare function executeRunPrFeedbackStageA(args: unknown, directory: string, context?: {
54
+ sessionID?: string;
55
+ }): Promise<string>;
56
+ export declare const _internals: {
57
+ runExternalTool: typeof runExternalTool;
58
+ readGitTextAtRevision: typeof readGitTextAtRevision;
59
+ resolveExactMergeBase: typeof resolveExactMergeBase;
60
+ resolveCurrentGitHead: typeof resolveCurrentGitHead;
61
+ resolveGitControlStateDigest: typeof resolveGitControlStateDigest;
62
+ resolvePrWorkflowRevisionDigest: typeof resolvePrWorkflowRevisionDigest;
63
+ isPlausibleStageACommand: typeof isPlausibleStageACommand;
64
+ discoverApplicableStageACategories: typeof discoverApplicableStageACategories;
65
+ discoverApplicableStageAObligations: typeof discoverApplicableStageAObligations;
66
+ commandMatchesObligationSource: typeof commandMatchesObligationSource;
67
+ };
68
+ export declare const run_pr_feedback_stage_a: ReturnType<typeof createSwarmTool>;
69
+ export {};
@@ -99,6 +99,14 @@ export declare const TOOL_METADATA: {
99
99
  description: string;
100
100
  agents: ("critic_oversight" | "architect")[];
101
101
  };
102
+ complete_pr_workflow: {
103
+ description: string;
104
+ agents: "architect"[];
105
+ };
106
+ run_pr_feedback_stage_a: {
107
+ description: string;
108
+ agents: "architect"[];
109
+ };
102
110
  submit_council_verdicts: {
103
111
  description: string;
104
112
  agents: never[];
@@ -1,67 +1,75 @@
1
1
  import { z } from 'zod';
2
+ import { resolveExactMergeBase, resolvePrWorkflowRevisionDigest } from '../background/workspace-snapshot.js';
2
3
  import { createSwarmTool } from './create-tool';
4
+ export declare const _internals: {
5
+ resolvePrWorkflowRevisionDigest: typeof resolvePrWorkflowRevisionDigest;
6
+ resolveMergeBase: typeof resolveExactMergeBase;
7
+ };
3
8
  /** Canonical trigger IDs and display values shared with the PR-review protocol. */
4
9
  export declare const PR_REVIEW_TRIGGER_DEFINITIONS: readonly [{
5
- readonly id: "architect-prompts";
6
- readonly trigger_row: "agents, prompts, templates, prompt interpolation, role text";
7
- readonly micro_lane: "Architect prompt integrity";
10
+ readonly id: "auth-identity-secrets";
11
+ readonly scope: "universal";
12
+ readonly trigger_row: "authentication, authorization, identity, sessions, permissions, secrets, cryptography";
13
+ readonly micro_lane: "Identity and secret boundaries";
8
14
  }, {
9
- readonly id: "council-orchestration";
10
- readonly trigger_row: "council, verdict, quorum, veto, synthesis";
11
- readonly micro_lane: "Council orchestration";
15
+ readonly id: "untrusted-input-boundaries";
16
+ readonly scope: "universal";
17
+ readonly trigger_row: "parsing, serialization, queries, templates/rendering, file or network input/output";
18
+ readonly micro_lane: "Untrusted input and sink analysis";
12
19
  }, {
13
- readonly id: "guardrail-bypass";
14
- readonly trigger_row: "guardrail, gate, delegation, rate limit, approval checks";
15
- readonly micro_lane: "Guardrail bypass paths";
20
+ readonly id: "subprocess-platform";
21
+ readonly scope: "universal";
22
+ readonly trigger_row: "subprocesses, shell commands, filesystem operations, OS/runtime-specific code";
23
+ readonly micro_lane: "Subprocess and platform safety";
16
24
  }, {
17
- readonly id: "evidence-schema";
18
- readonly trigger_row: "schema, evidence, JSONL, migrations, serializers";
19
- readonly micro_lane: "Evidence schema drift";
25
+ readonly id: "concurrency-state";
26
+ readonly scope: "universal";
27
+ readonly trigger_row: "queues, caches, retries, transactions, locks, state machines, async coordination";
28
+ readonly micro_lane: "Concurrency and state transitions";
20
29
  }, {
21
- readonly id: "knowledge-contract";
22
- readonly trigger_row: "knowledge, curator, hive, quarantine, memory";
23
- readonly micro_lane: "Knowledge base contract";
30
+ readonly id: "dependencies-build-release";
31
+ readonly scope: "universal";
32
+ readonly trigger_row: "dependency manifests, lockfiles, installers, build scripts, CI, packaging, deployment";
33
+ readonly micro_lane: "Dependency and delivery integrity";
24
34
  }, {
25
- readonly id: "phase-transitions";
26
- readonly trigger_row: "phase, state, plan, .swarm/state, completion markers";
27
- readonly micro_lane: "Phase transition validation";
35
+ readonly id: "api-schema-migrations";
36
+ readonly scope: "universal";
37
+ readonly trigger_row: "public API, wire/schema/config/storage formats, migrations, feature flags";
38
+ readonly micro_lane: "Compatibility and migration safety";
28
39
  }, {
29
- readonly id: "model-role-mapping";
30
- readonly trigger_row: "model, role, prefix, tool, agent config";
31
- readonly micro_lane: "Model-to-role mapping";
32
- }, {
33
- readonly id: "config-ratchet";
34
- readonly trigger_row: "config, defaults, ratchet, locks, policy flags";
35
- readonly micro_lane: "Config ratchet semantics";
36
- }, {
37
- readonly id: "url-fetch";
38
- readonly trigger_row: "url, fetch, http, GitHub PR/issue parsing, package fetch";
39
- readonly micro_lane: "URL sanitization and external fetch";
40
+ readonly id: "test-infrastructure";
41
+ readonly scope: "universal";
42
+ readonly trigger_row: "tests, mocks, fixtures, harnesses, coverage, CI matrices";
43
+ readonly micro_lane: "Test validity and isolation";
40
44
  }, {
41
- readonly id: "git-safety";
42
- readonly trigger_row: "git, branch, checkout, reset, worktree, .git";
43
- readonly micro_lane: "Git safety";
45
+ readonly id: "ui-accessibility-i18n";
46
+ readonly scope: "universal";
47
+ readonly trigger_row: "user interfaces, interaction flows, rendering, accessibility, localization";
48
+ readonly micro_lane: "UI and human-interface quality";
44
49
  }, {
45
- readonly id: "shell-write";
46
- readonly trigger_row: "shell, exec, command parser, file writes, delete/move/copy";
47
- readonly micro_lane: "Shell/write authority and path containment";
50
+ readonly id: "privacy-observability";
51
+ readonly scope: "universal";
52
+ readonly trigger_row: "telemetry, logs, analytics, traces, retention, diagnostics";
53
+ readonly micro_lane: "Privacy and observability safety";
48
54
  }, {
49
- readonly id: "test-infrastructure";
50
- readonly trigger_row: "test, bun, mocks, fixtures, CI matrix";
51
- readonly micro_lane: "Test infrastructure";
55
+ readonly id: "generated-provenance";
56
+ readonly scope: "universal";
57
+ readonly trigger_row: "generated, vendored, binary, model-produced, codegen or checked-in build artifacts";
58
+ readonly micro_lane: "Generated artifact provenance";
52
59
  }, {
53
- readonly id: "metrics-privacy";
54
- readonly trigger_row: "metrics, telemetry, logs, serialized traces";
55
- readonly micro_lane: "Metrics and evidence privacy";
60
+ readonly id: "unclassified-risk";
61
+ readonly scope: "universal";
62
+ readonly trigger_row: "any changed artifact or behavior not confidently classified by the rows above";
63
+ readonly micro_lane: "Unclassified high-risk fallback";
56
64
  }];
57
65
  declare const WritePrReviewTriggerEvalArgsSchema: z.ZodObject<{
58
66
  run_id: z.ZodString;
67
+ pr_head_sha: z.ZodString;
68
+ base_sha: z.ZodOptional<z.ZodString>;
69
+ base_ref: z.ZodOptional<z.ZodString>;
59
70
  rows: z.ZodArray<z.ZodObject<{
60
71
  trigger_id: z.ZodString;
61
- result: z.ZodEnum<{
62
- MATCHED: "MATCHED";
63
- "NO-MATCH": "NO-MATCH";
64
- }>;
72
+ result: z.ZodLiteral<"MATCHED">;
65
73
  evidence: z.ZodString;
66
74
  source_batch_id: z.ZodOptional<z.ZodString>;
67
75
  source_lane_id: z.ZodOptional<z.ZodString>;
@@ -69,6 +77,8 @@ declare const WritePrReviewTriggerEvalArgsSchema: z.ZodObject<{
69
77
  }, z.core.$strict>;
70
78
  export type WritePrReviewTriggerEvalArgs = z.infer<typeof WritePrReviewTriggerEvalArgsSchema>;
71
79
  /** Validate and atomically persist the complete PR-review trigger evaluation. */
72
- export declare function executeWritePrReviewTriggerEval(args: unknown, directory: string): Promise<string>;
80
+ export declare function executeWritePrReviewTriggerEval(args: unknown, directory: string, context?: {
81
+ sessionID?: string;
82
+ }): Promise<string>;
73
83
  export declare const write_pr_review_trigger_eval: ReturnType<typeof createSwarmTool>;
74
84
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.123.0",
3
+ "version": "7.125.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",