opencode-swarm 7.130.2 → 7.131.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/cli/{config-doctor-489wej17.js → config-doctor-rjvb0hhn.js} +2 -2
- package/dist/cli/{curation-policy-aaz0hap6.js → curation-policy-f5bybzmh.js} +2 -2
- package/dist/cli/{curator-s2ynewsr.js → curator-kjzqa5m7.js} +13 -13
- package/dist/cli/{curator-llm-factory-mxjcctn8.js → curator-llm-factory-ezq4fakt.js} +13 -13
- package/dist/cli/{evidence-summary-service-hf7qq777.js → evidence-summary-service-jfagmvrh.js} +1 -1
- package/dist/cli/{guardrail-explain-s85kv81r.js → guardrail-explain-n93qh8k6.js} +14 -14
- package/dist/cli/{guardrail-log-2cejc33f.js → guardrail-log-h4tmcjwx.js} +3 -3
- package/dist/cli/{hive-promoter-qdgxajht.js → hive-promoter-mammxe5p.js} +13 -13
- package/dist/cli/{index-jvyn76xe.js → index-01nyrk95.js} +3 -3
- package/dist/cli/{index-kzvwb2se.js → index-03zyn94g.js} +110 -85
- package/dist/cli/{index-xa29259t.js → index-1atz85c8.js} +1 -1
- package/dist/cli/{index-6fqj8fcp.js → index-6vg0qczz.js} +2 -2
- package/dist/cli/{index-zft4hp35.js → index-cnwh164k.js} +1 -1
- package/dist/cli/{index-hjar4crm.js → index-cq22pnd2.js} +1 -1
- package/dist/cli/{index-etdgtk3m.js → index-d2tgc580.js} +2688 -1240
- package/dist/cli/{index-jxha73tm.js → index-fepakwhp.js} +1 -1
- package/dist/cli/{index-5xxgeksy.js → index-hynbzh7s.js} +46 -2
- package/dist/cli/{index-p6qgjkbt.js → index-kbfhyxtv.js} +9 -1
- package/dist/cli/{index-3rnkyb60.js → index-m6zfm7cm.js} +5 -5
- package/dist/cli/{index-s8h2cedv.js → index-pft1qxqh.js} +1 -1
- package/dist/cli/{index-ts9wh1ba.js → index-q68sprcy.js} +60 -8
- package/dist/cli/{index-agte9w1e.js → index-szkswbqf.js} +2 -2
- package/dist/cli/{index-nr5pr54q.js → index-tw33v84d.js} +1 -1
- package/dist/cli/{index-jvwkxz8q.js → index-xhd797bz.js} +15 -15
- package/dist/cli/{index-wy3q73j2.js → index-xv2ydncg.js} +18 -14
- package/dist/cli/index.js +13 -13
- package/dist/cli/{knowledge-escalator-1ypz0266.js → knowledge-escalator-cf1kkmfe.js} +3 -3
- package/dist/cli/{knowledge-events-yvcczmja.js → knowledge-events-p8t5ev44.js} +1 -1
- package/dist/cli/{knowledge-store-h8bp9eje.js → knowledge-store-vpdmcwem.js} +3 -1
- package/dist/cli/{knowledge-validator-sz9v1fdq.js → knowledge-validator-w1t0sw5f.js} +4 -4
- package/dist/cli/{scan-cursor-k9zyt374.js → scan-cursor-z4c51902.js} +2 -2
- package/dist/cli/{schema-fkpn2r1s.js → schema-yqzzfavj.js} +5 -1
- package/dist/cli/{skill-generator-a6a9jxfd.js → skill-generator-aaabj00n.js} +5 -5
- package/dist/commands/consolidate.d.ts +14 -0
- package/dist/commands/curate.d.ts +2 -0
- package/dist/commands/promote.d.ts +25 -0
- package/dist/commands/registry.d.ts +2 -2
- package/dist/config/schema.d.ts +101 -0
- package/dist/consensus/contracts.d.ts +479 -0
- package/dist/consensus/corpus.d.ts +261 -0
- package/dist/consensus/miner.d.ts +200 -0
- package/dist/consensus/public-api.d.ts +42 -0
- package/dist/consensus/store.d.ts +119 -0
- package/dist/evidence/immutable-store.d.ts +86 -0
- package/dist/evidence/manager.d.ts +31 -1
- package/dist/hooks/actionability-predicate.d.ts +36 -0
- package/dist/hooks/curator.d.ts +3 -0
- package/dist/hooks/hive-policy.d.ts +11 -0
- package/dist/hooks/hive-promoter.d.ts +27 -1
- package/dist/hooks/knowledge-dedup-sweep.d.ts +145 -0
- package/dist/hooks/knowledge-injector.d.ts +4 -0
- package/dist/hooks/knowledge-store.d.ts +26 -0
- package/dist/hooks/knowledge-types.d.ts +6 -0
- package/dist/hooks/knowledge-validator.d.ts +10 -14
- package/dist/hooks/micro-reflector.d.ts +106 -2
- package/dist/hooks/realtime-learning-nudge.d.ts +19 -0
- package/dist/index.js +426 -418
- package/dist/knowledge/entry-merge.d.ts +112 -0
- package/dist/knowledge/family-migration.d.ts +6 -2
- package/dist/learning/admission.d.ts +154 -0
- package/dist/learning/candidate-queue.d.ts +178 -0
- package/dist/learning/fingerprint.d.ts +56 -0
- package/dist/learning/prm-pattern-support.d.ts +124 -0
- package/dist/learning/provenance.d.ts +86 -0
- package/dist/prm/index.d.ts +46 -1
- package/dist/services/recommendation-ledger.d.ts +266 -0
- package/dist/services/skill-improver.d.ts +4 -0
- package/dist/services/status-service.d.ts +13 -0
- package/dist/services/trajectory-cluster.d.ts +65 -2
- package/dist/tools/consensus-mine.d.ts +172 -0
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/knowledge-add.d.ts +34 -0
- package/dist/tools/manifest.d.ts +1 -0
- package/dist/tools/tool-metadata.d.ts +4 -0
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `consensus_mine` — run the consensus miner and persist its report.
|
|
3
|
+
*
|
|
4
|
+
* The tool is a thin, fully-wired shell around `src/consensus/`: it resolves the
|
|
5
|
+
* effective consensus config, assembles a `ConsensusMineRequest` from the
|
|
6
|
+
* caller's overrides, optionally supplies an LLM dispatcher, delegates to
|
|
7
|
+
* `mineAndStoreConsensusV1`, applies report retention, and renders a bounded
|
|
8
|
+
* summary.
|
|
9
|
+
*
|
|
10
|
+
* It is NOT write-minimal, and the description the model reads says so. The
|
|
11
|
+
* complete list of effects, none of which touches a project file:
|
|
12
|
+
*
|
|
13
|
+
* 1. **Its own report** under `.swarm/evolution/consensus/<reportId>.json`.
|
|
14
|
+
* 2. **Deletions of its own prior reports.** `pruneConsensusReports` runs
|
|
15
|
+
* unconditionally after every mine and `consensus.report_retention` defaults
|
|
16
|
+
* to 50, so the steady state of a long-lived project is that each run
|
|
17
|
+
* `unlink`s the oldest report. Only `report_retention: 0` disables it.
|
|
18
|
+
* 3. **The shared dedup ledger** (issue #1821 AC21). It gains one entry per
|
|
19
|
+
* emitted proposal EXCEPT where it already carries that recommendation's
|
|
20
|
+
* cross key — those are counted as `duplicate_recommendation_count` instead.
|
|
21
|
+
* The append is a whole-file rewrite with FIFO eviction at
|
|
22
|
+
* `MAX_RECOMMENDATION_LEDGER_ENTRIES`, and eviction is by position, not by
|
|
23
|
+
* producer: a miner append can evict the CURATOR's or the IMPROVER's oldest
|
|
24
|
+
* entries. The ledger normally lives at
|
|
25
|
+
* `.swarm/learning/recommendation-ledger.jsonl`, but its root is
|
|
26
|
+
* `resolveKnowledgeStoreDir`, so under a knowledge-link pointer it lands in
|
|
27
|
+
* the shared cohort root rather than this project's `.swarm/`.
|
|
28
|
+
* 4. **Lock sentinels.** The report goes through `withEvidenceLock`, whose
|
|
29
|
+
* sentinel is an empty `<sha256>.lock` file under this project's
|
|
30
|
+
* `.swarm/locks/`; `proper-lockfile` removes its own lock directory but
|
|
31
|
+
* NOTHING removes that sentinel, so each distinct report id leaves one behind
|
|
32
|
+
* permanently. The ledger goes through `transactFile`, which locks the
|
|
33
|
+
* ledger's own containing directory and therefore produces
|
|
34
|
+
* `<resolveKnowledgeStoreDir(directory)>/learning.lock` — outside this
|
|
35
|
+
* project's `.swarm/` entirely whenever a knowledge link is active.
|
|
36
|
+
* 5. **A pending memory proposal per emitted proposal**, but only when
|
|
37
|
+
* `memory.enabled` is `true` (it defaults to `false`,
|
|
38
|
+
* `src/config/schema.ts`). This is issue #1821 AC22 — "use existing
|
|
39
|
+
* proposal/MemoryRecord paths, not another inbox" — so the mirror goes
|
|
40
|
+
* through the same `MemoryGateway.propose` path `swarm_memory_propose` uses,
|
|
41
|
+
* which creates a *pending proposal* requiring curator review and never a
|
|
42
|
+
* durable memory record.
|
|
43
|
+
* 6. **Up to `MAX_LLM_SUMMARIES` (20) `session.create` + `session.prompt`
|
|
44
|
+
* calls** whenever `consensus.llm_summarization_enabled` (default `true`)
|
|
45
|
+
* finds a wired OpenCode client.
|
|
46
|
+
*
|
|
47
|
+
* Effects 2-6 were absent from the tool description for four review rounds
|
|
48
|
+
* while it claimed "its only writes are its own immutable report and one entry
|
|
49
|
+
* in the shared recommendation dedup ledger". That string is read by a model as
|
|
50
|
+
* fact and was the premise of the Full-Auto auto-allow in
|
|
51
|
+
* `src/full-auto/policy.ts`; both now state the list above.
|
|
52
|
+
*
|
|
53
|
+
* What the tool does NOT do is mutate any of the evidence it reads. That is a
|
|
54
|
+
* chosen property, not a free one:
|
|
55
|
+
* `loadEvidence` upgrades a legacy flat retrospective in place by default, so
|
|
56
|
+
* `src/consensus/corpus.ts` binds it with `{ migrate: false }`. Without that, a
|
|
57
|
+
* mining run would rewrite evidence bundles — and remap their legacy
|
|
58
|
+
* `task_complexity` values — while advertising itself as read-only.
|
|
59
|
+
*
|
|
60
|
+
* It activates no skill, writes no knowledge entry, admits no durable memory
|
|
61
|
+
* record, and touches no project file — which is why it is classified as a
|
|
62
|
+
* **pathless write-like** tool in `src/full-auto/policy.ts` alongside
|
|
63
|
+
* `write_retro` and `knowledge_add`, and why it is absent from
|
|
64
|
+
* `WRITE_TOOL_NAMES` (`src/config/constants.ts`), whose members are the tools
|
|
65
|
+
* that write PROJECT FILE CONTENTS and are therefore subject to the scope guard.
|
|
66
|
+
* The knowledge-link redirection in effects 3 and 5 does not change that
|
|
67
|
+
* classification: `knowledge_add` and `knowledge_remove` are in the same
|
|
68
|
+
* auto-allow set and have the same redirection, and it comes from operator
|
|
69
|
+
* configuration rather than from anything the caller passed.
|
|
70
|
+
*
|
|
71
|
+
* `ctx.directory` is injected by `createSwarmTool`; there is no `process.cwd()`
|
|
72
|
+
* anywhere in this file (AGENTS.md invariant 4).
|
|
73
|
+
*/
|
|
74
|
+
import type { MemoryConfig } from '../config/schema';
|
|
75
|
+
import type { ConsensusAttributeV1, ConsensusReportV1 } from '../consensus/contracts';
|
|
76
|
+
import { createMemoryGateway } from '../memory';
|
|
77
|
+
import { type RecommendationCandidate } from '../services/recommendation-ledger';
|
|
78
|
+
import { createSwarmTool } from './create-tool';
|
|
79
|
+
/**
|
|
80
|
+
* Reconcile the summary counters with what the inline echo actually shows.
|
|
81
|
+
*
|
|
82
|
+
* These are two different orderings and they do not line up. Restatements are
|
|
83
|
+
* spent on the top `MAX_LLM_SUMMARIES` attributes by CONFIDENCE
|
|
84
|
+
* (`src/consensus/miner.ts`), while the echo below is the first
|
|
85
|
+
* `MAX_INLINE_ATTRIBUTES` in canonical SIGNAL order. With confidence inverted
|
|
86
|
+
* relative to signal order, a report can print `summarized_count: 20` while zero
|
|
87
|
+
* `llm_summary` values are visible — which is exactly what "the count always
|
|
88
|
+
* agrees with the values echoed alongside it" used to claim was impossible.
|
|
89
|
+
* `hidden` is what makes the discrepancy legible instead of mysterious.
|
|
90
|
+
*/
|
|
91
|
+
declare function countSummaries(attributes: readonly ConsensusAttributeV1[], inlineLimit: number): {
|
|
92
|
+
total: number;
|
|
93
|
+
hidden: number;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Describe the miner's emissions to the cross-producer dedup ledger
|
|
97
|
+
* (issue #1821 AC21).
|
|
98
|
+
*
|
|
99
|
+
* The statement is the proposal's `intent` — the sentence the miner actually
|
|
100
|
+
* emits — not the internal attribute statement its own `lrec_` fingerprint is
|
|
101
|
+
* built from: only the intent survives onto the persisted report, and it is the
|
|
102
|
+
* text a human reads as "the recommendation". `scopeKeys` stays empty for the
|
|
103
|
+
* same reason the curator's new-knowledge recommendations carry none: content
|
|
104
|
+
* alone is the identity of a freshly-minted lesson, and that is exactly where
|
|
105
|
+
* another producer can legitimately be proposing the same thing.
|
|
106
|
+
*/
|
|
107
|
+
declare function buildMinerRecommendationCandidates(report: Pick<ConsensusReportV1, 'proposals' | 'generatedAt'>, sessionId?: string): RecommendationCandidate[];
|
|
108
|
+
/**
|
|
109
|
+
* What the AC22 memory mirror actually did, reported rather than assumed.
|
|
110
|
+
*
|
|
111
|
+
* `attempted` is 0 whenever `enabled` is false, so a reader can tell "memory is
|
|
112
|
+
* off" from "memory is on and nothing was proposed". `failed` and `error` exist
|
|
113
|
+
* because the mirror is deliberately fail-open — the report is already durably
|
|
114
|
+
* written by the time it runs, and losing the whole mine to a memory-store
|
|
115
|
+
* problem would be worse than losing the mirror — but a fail-open path that
|
|
116
|
+
* reports nothing is exactly the defect `recommendation_ledger.degraded` was
|
|
117
|
+
* added to close.
|
|
118
|
+
*/
|
|
119
|
+
type MemoryMirrorResult = {
|
|
120
|
+
enabled: boolean;
|
|
121
|
+
attempted: number;
|
|
122
|
+
proposed: number;
|
|
123
|
+
rejected: number;
|
|
124
|
+
failed: number;
|
|
125
|
+
error?: string;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Issue #1821 AC22: mirror each emitted proposal into the EXISTING memory
|
|
129
|
+
* proposal path rather than leaving the consensus report as a write-only inbox.
|
|
130
|
+
*
|
|
131
|
+
* `MemoryGateway.propose` is the same entry point `swarm_memory_propose` uses
|
|
132
|
+
* (`src/tools/swarm-memory-propose.ts`), including its `dispose()` in a
|
|
133
|
+
* `finally`. It creates a PENDING proposal — curator review is still required,
|
|
134
|
+
* nothing durable is admitted — which is why the tool's proposals-only guarantee
|
|
135
|
+
* survives the mirror.
|
|
136
|
+
*
|
|
137
|
+
* Fail-open by design and per-proposal: one rejected or throwing proposal must
|
|
138
|
+
* not discard the ones that succeeded, and none of it can unwrite the report.
|
|
139
|
+
* Every outcome is counted and returned, so the tool's response says what
|
|
140
|
+
* happened instead of implying success.
|
|
141
|
+
*/
|
|
142
|
+
declare function mirrorProposalsToMemory(options: {
|
|
143
|
+
directory: string;
|
|
144
|
+
memoryConfig: MemoryConfig | undefined;
|
|
145
|
+
report: Pick<ConsensusReportV1, 'proposals' | 'reportId'>;
|
|
146
|
+
sessionId?: string;
|
|
147
|
+
}): Promise<MemoryMirrorResult>;
|
|
148
|
+
/**
|
|
149
|
+
* DI seam (AGENTS.md invariant 7). Lets a test drive the AC22 mirror's
|
|
150
|
+
* failure and rejection branches without a real provider and without
|
|
151
|
+
* `mock.module`. Restore each entry in `afterEach`.
|
|
152
|
+
*/
|
|
153
|
+
export declare const _internals: {
|
|
154
|
+
createMemoryGateway: typeof createMemoryGateway;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Pure-function seam for tests (writing-tests SKILL.md, Tier 0). Exported so a
|
|
158
|
+
* cross-producer dedup test can build the miner's ledger candidates through the
|
|
159
|
+
* same code the tool runs instead of restating the mapping, and so the
|
|
160
|
+
* summary-counter reconciliation can be asserted at the ordering that produces
|
|
161
|
+
* it — 20 summarized attributes with none visible — rather than only at the
|
|
162
|
+
* degenerate all-zero case a dispatcher-less run reaches.
|
|
163
|
+
*/
|
|
164
|
+
export declare const _test_exports: {
|
|
165
|
+
buildMinerRecommendationCandidates: typeof buildMinerRecommendationCandidates;
|
|
166
|
+
countSummaries: typeof countSummaries;
|
|
167
|
+
mirrorProposalsToMemory: typeof mirrorProposalsToMemory;
|
|
168
|
+
MAX_INLINE_ATTRIBUTES: number;
|
|
169
|
+
MIRRORED_PROPOSAL_KIND: "todo";
|
|
170
|
+
};
|
|
171
|
+
export declare const consensus_mine: ReturnType<typeof createSwarmTool>;
|
|
172
|
+
export {};
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { checkpoint } from './checkpoint';
|
|
|
10
10
|
export { co_change_analyzer } from './co-change-analyzer';
|
|
11
11
|
export { completion_verify } from './completion-verify';
|
|
12
12
|
export { complexity_hotspots } from './complexity-hotspots';
|
|
13
|
+
export { consensus_mine } from './consensus-mine';
|
|
13
14
|
export { context_status } from './context-status';
|
|
14
15
|
export { submit_council_verdicts } from './convene-council';
|
|
15
16
|
export { convene_general_council } from './convene-general-council';
|
|
@@ -1,2 +1,36 @@
|
|
|
1
1
|
import { createSwarmTool } from './create-tool.js';
|
|
2
|
+
/**
|
|
3
|
+
* Merge caller-supplied tags with the tags inferred from the lesson.
|
|
4
|
+
*
|
|
5
|
+
* Caller tags come FIRST so that when the combined list exceeds the cap,
|
|
6
|
+
* truncation drops inferred tags before it drops user intent. `dedupeCapped`
|
|
7
|
+
* is case-insensitive (first casing wins), so an inferred tag the caller
|
|
8
|
+
* already supplied collapses into the caller's casing instead of duplicating.
|
|
9
|
+
*
|
|
10
|
+
* Hoisted to module scope and exposed via `_test_exports` so this call site is
|
|
11
|
+
* observable on its own: the store write boundary normalizes the same fields,
|
|
12
|
+
* which would otherwise mask a regression here (issue #1821 Lane 0b).
|
|
13
|
+
*/
|
|
14
|
+
declare function mergeLessonTags(tagsInput: unknown, lesson: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Normalize one optional v3 actionability array from untrusted tool input.
|
|
17
|
+
*
|
|
18
|
+
* The `undefined` return is load-bearing: `validateActionableFields` and
|
|
19
|
+
* `validateActionability` distinguish an ABSENT field from an empty one, and
|
|
20
|
+
* JSON.stringify drops an `undefined` value so the persisted record keeps that
|
|
21
|
+
* distinction. Only the inner filter+cap is `dedupeCapped` (#1821 Lane 0b).
|
|
22
|
+
*/
|
|
23
|
+
declare function strArray(v: unknown): string[] | undefined;
|
|
2
24
|
export declare const knowledge_add: ReturnType<typeof createSwarmTool>;
|
|
25
|
+
/**
|
|
26
|
+
* Tier-0 test seam (issue #1821 Lane 0b). These are pure functions with no I/O.
|
|
27
|
+
* They are exported so the call-site normalization can be asserted directly:
|
|
28
|
+
* the store write boundary normalizes the same fields with the same semantics,
|
|
29
|
+
* so an assertion made against a PERSISTED entry cannot distinguish "call site
|
|
30
|
+
* fixed" from "call site reverted".
|
|
31
|
+
*/
|
|
32
|
+
export declare const _test_exports: {
|
|
33
|
+
mergeLessonTags: typeof mergeLessonTags;
|
|
34
|
+
strArray: typeof strArray;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
package/dist/tools/manifest.d.ts
CHANGED
|
@@ -79,6 +79,7 @@ export declare const TOOL_MANIFEST: {
|
|
|
79
79
|
doc_scan: () => ToolDefinition;
|
|
80
80
|
doc_extract: () => ToolDefinition;
|
|
81
81
|
curator_analyze: () => ToolDefinition;
|
|
82
|
+
consensus_mine: () => ToolDefinition;
|
|
82
83
|
knowledge_add: () => ToolDefinition;
|
|
83
84
|
knowledge_recall: () => ToolDefinition;
|
|
84
85
|
knowledge_remove: () => ToolDefinition;
|
|
@@ -320,6 +320,10 @@ export declare const TOOL_METADATA: {
|
|
|
320
320
|
description: string;
|
|
321
321
|
agents: "architect"[];
|
|
322
322
|
};
|
|
323
|
+
consensus_mine: {
|
|
324
|
+
description: string;
|
|
325
|
+
agents: ("architect" | "curator_phase" | "curator_postmortem")[];
|
|
326
|
+
};
|
|
323
327
|
knowledge_add: {
|
|
324
328
|
description: string;
|
|
325
329
|
agents: ("coder" | "architect")[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-swarm",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.131.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",
|