opencode-swarm 7.125.1 → 7.125.3

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 (48) hide show
  1. package/dist/cli/{config-doctor-g3m2q646.js → config-doctor-rm1m07gz.js} +2 -2
  2. package/dist/cli/{core-d38hc85b.js → core-v1kp7anb.js} +2 -2
  3. package/dist/cli/{curation-policy-vgbx8530.js → curation-policy-7pgdjt5w.js} +2 -2
  4. package/dist/cli/{curator-xk4g1nx2.js → curator-arwm18td.js} +16 -16
  5. package/dist/cli/{curator-drift-h9a2sjvf.js → curator-drift-24bdacdc.js} +2 -2
  6. package/dist/cli/{curator-llm-factory-7pvqy94w.js → curator-llm-factory-yq5vf298.js} +16 -16
  7. package/dist/cli/{evidence-summary-service-v4h2w487.js → evidence-summary-service-thx1c3me.js} +3 -3
  8. package/dist/cli/{guardrail-explain-wfk16bpr.js → guardrail-explain-mscq3veq.js} +17 -17
  9. package/dist/cli/{guardrail-log-5zz9xx6z.js → guardrail-log-6a2zxvtx.js} +3 -3
  10. package/dist/cli/{hive-promoter-njwc5rt0.js → hive-promoter-q79naynh.js} +16 -16
  11. package/dist/cli/{index-tn3shyqj.js → index-01n43w2p.js} +4 -4
  12. package/dist/cli/{index-8yvqkbw7.js → index-414r47r7.js} +6 -4
  13. package/dist/cli/{index-mwdcvh0e.js → index-45mvd5q7.js} +4 -4
  14. package/dist/cli/index-4rhhvd1a.js +62 -0
  15. package/dist/cli/{index-txragda9.js → index-4ycq2mrp.js} +1 -1
  16. package/dist/cli/{index-cz6fv84h.js → index-7p6jkkat.js} +18 -18
  17. package/dist/cli/{index-kws8zn6y.js → index-8tjbq2ej.js} +1 -1
  18. package/dist/cli/{index-s9mj4rb9.js → index-9ss2m4rs.js} +1 -1
  19. package/dist/cli/{index-3k8pg467.js → index-ambnwnmt.js} +15 -6
  20. package/dist/cli/{index-rpg8qqjs.js → index-emzes7sj.js} +3 -3
  21. package/dist/cli/{index-83rwq7pb.js → index-fm4zfxnr.js} +1 -1
  22. package/dist/cli/{index-v2rdhwx8.js → index-g4ef4v3m.js} +1 -1
  23. package/dist/cli/{index-fs02c7tz.js → index-kk1scggc.js} +1 -1
  24. package/dist/cli/{index-dsf1yv4s.js → index-m5e00g9s.js} +47 -43
  25. package/dist/cli/{index-z4sc6yxc.js → index-pk099nqv.js} +87 -6
  26. package/dist/cli/{index-kvrk3h8p.js → index-rp5msv7n.js} +1 -1
  27. package/dist/cli/{index-ghteqdy1.js → index-sa3dgpmc.js} +2 -2
  28. package/dist/cli/{index-93cq8t5b.js → index-vdfewvn5.js} +5 -5
  29. package/dist/cli/{index-mhhmecsw.js → index-x8entmky.js} +2 -2
  30. package/dist/cli/{index-pbjenws7.js → index-xezv6tdw.js} +1 -1
  31. package/dist/cli/index.js +16 -16
  32. package/dist/cli/{knowledge-escalator-jtyykzqc.js → knowledge-escalator-gr8qd7kz.js} +3 -3
  33. package/dist/cli/{knowledge-events-qhr97sy9.js → knowledge-events-q83g3f8z.js} +1 -1
  34. package/dist/cli/{knowledge-store-332x3pjv.js → knowledge-store-qq3w5yt8.js} +1 -1
  35. package/dist/cli/{knowledge-validator-3t8tgzsz.js → knowledge-validator-7jhq8yam.js} +4 -4
  36. package/dist/cli/{scan-cursor-q21c9k9q.js → scan-cursor-fa5sy36q.js} +2 -2
  37. package/dist/cli/{schema-y2d7j2jk.js → schema-bw68my66.js} +3 -1
  38. package/dist/cli/{skill-generator-3gkxx98d.js → skill-generator-ffc1agyw.js} +6 -6
  39. package/dist/config/loader.d.ts +14 -0
  40. package/dist/config/schema.d.ts +10 -0
  41. package/dist/hooks/knowledge-application-gate.d.ts +8 -2
  42. package/dist/hooks/knowledge-application.d.ts +2 -0
  43. package/dist/index.js +10 -10
  44. package/dist/services/config-doctor.d.ts +14 -2
  45. package/dist/services/warning-buffer.d.ts +24 -5
  46. package/dist/state.d.ts +33 -2
  47. package/package.json +1 -1
  48. package/dist/cli/index-gacm5s2n.js +0 -34
@@ -38,6 +38,14 @@ export interface ConfigFix {
38
38
  description: string;
39
39
  /** Risk level - only 'low' is auto-fixable */
40
40
  risk: 'low' | 'medium' | 'high';
41
+ /**
42
+ * When true, the fix loses user-authored data (e.g. trimming an over-length
43
+ * array). Lossy fixes are applied ONLY when the caller explicitly opts in via
44
+ * `applySafeAutoFixes(..., { applyLossy: true })` — the interactive
45
+ * `/swarm config doctor --fix` command does; the passive startup autofix path
46
+ * never does. This keeps a lossy repair from being applied silently (#1886).
47
+ */
48
+ lossy?: boolean;
41
49
  }
42
50
  /** Result of running the config doctor */
43
51
  export interface ConfigDoctorResult {
@@ -98,7 +106,9 @@ export declare function runConfigDoctor(config: PluginConfig, directory: string)
98
106
  * Apply safe auto-fixes to config
99
107
  * Only applies low-risk, non-destructive fixes
100
108
  */
101
- export declare function applySafeAutoFixes(directory: string, result: ConfigDoctorResult): {
109
+ export declare function applySafeAutoFixes(directory: string, result: ConfigDoctorResult, options?: {
110
+ applyLossy?: boolean;
111
+ }): {
102
112
  appliedFixes: ConfigFix[];
103
113
  updatedConfigPath: string | null;
104
114
  };
@@ -131,7 +141,9 @@ export declare function shouldRunOnStartup(automationConfig: {
131
141
  /**
132
142
  * Full config doctor run with backup and fix application
133
143
  */
134
- export declare function runConfigDoctorWithFixes(directory: string, config: PluginConfig, autoFix?: boolean): Promise<{
144
+ export declare function runConfigDoctorWithFixes(directory: string, config: PluginConfig, autoFix?: boolean, options?: {
145
+ applyLossy?: boolean;
146
+ }): Promise<{
135
147
  result: ConfigDoctorResult;
136
148
  backupPath: string | null;
137
149
  appliedFixes: ConfigFix[];
@@ -1,14 +1,33 @@
1
+ /**
2
+ * Buffer a warning for `/swarm diagnose`. This is the single write boundary
3
+ * for `deferredWarnings` — `advisoryWarn` funnels through it, and roughly a
4
+ * dozen call sites across `src/index.ts` and `src/agents/index.ts` call it
5
+ * directly with hand-composed messages. Several of those interpolate
6
+ * repo-controlled config content (agent names from `agents: z.record(...)`,
7
+ * the `auto_select_architect` string, …) that flows straight from an
8
+ * auto-loaded, attacker-editable `.opencode/opencode-swarm.json`.
9
+ *
10
+ * Sanitizing HERE — not in `advisoryWarn` — is what actually closes the class:
11
+ * every path into the buffer passes through this one function, so a future
12
+ * direct caller can't reintroduce the terminal-control-character /
13
+ * markdown-bullet-breaking class this guards against (security review,
14
+ * issue #1886 follow-up; an earlier revision of this fix sanitized only
15
+ * inside `advisoryWarn` and missed every direct caller).
16
+ */
1
17
  export declare function addDeferredWarning(warning: string): void;
2
18
  /**
3
19
  * Operational advisory: a non-fatal, operator-actionable condition reached on
4
20
  * a path that can run while the host TUI owns the terminal (plugin init,
5
- * /swarm command handlers, tool execution, chat/tool hooks). Routes the message
6
- * to BOTH delivery channels:
21
+ * /swarm command handlers, tool execution, chat/tool hooks). Routes to BOTH
22
+ * delivery channels:
7
23
  *
8
24
  * 1. `addDeferredWarning` — buffers it for `/swarm diagnose`, so the operator
9
- * can discover the condition without it polluting the live display.
10
- * 2. `log` the debug-gated logger, so it also shows under
11
- * `OPENCODE_SWARM_DEBUG=1` for live debugging.
25
+ * can discover the condition without it polluting the live display. The
26
+ * optional `data` is folded into the buffered entry (rendered compact +
27
+ * single-line) so actionable detail is visible in `/swarm diagnose`, not
28
+ * only under debug (issue #1886: config-validation detail was silently lost).
29
+ * 2. `log` — the debug-gated logger, so the message AND the structured `data`
30
+ * also show under `OPENCODE_SWARM_DEBUG=1` for live debugging.
12
31
  *
13
32
  * This NEVER writes raw stderr/stdout. It is the safe replacement for the raw
14
33
  * `console.warn` calls that corrupt the bubbletea TUI (issue #1249 class, and
package/dist/state.d.ts CHANGED
@@ -375,11 +375,24 @@ export declare const swarmState: {
375
375
  phase?: string;
376
376
  generatedAt: number;
377
377
  }>;
378
- /** v2: dedup set for ack records. Key = `${sessionId}|${id}|${result}|${dayKey}`.
378
+ /** v2: dedup set for ack records. Key = `${sessionId}|${id}|${result}`.
379
379
  * Prevents the chat.messages.transform path AND a knowledge_ack tool call
380
- * from double-counting the same ack within a session-day. FIFO-capped —
380
+ * from double-counting the same ack within a session. FIFO-capped —
381
381
  * see addKnowledgeAckDedup. */
382
382
  knowledgeAckDedup: Set<string>;
383
+ /** v2: per-session denial counter for the knowledge-application enforcement
384
+ * gate's deadlock escape hatch (`knowledgeApplicationGateBefore`). Keyed by
385
+ * sessionID; each entry also records the `directiveKey` (a sorted, joined
386
+ * fingerprint of the critical-directive-id set the count was accumulated
387
+ * against) so a session that has its critical directives swapped out from
388
+ * under it — an ordinary occurrence on phase/task transitions via
389
+ * `setCriticalShownIds` — does not carry a stale denial count into an
390
+ * unrelated new directive's budget. FIFO-capped — see
391
+ * incrementGateDenialCount/clearGateDenialCount. */
392
+ gateDenialCounts: Map<string, {
393
+ count: number;
394
+ directiveKey: string;
395
+ }>;
383
396
  /**
384
397
  * All generated agent names registered with OpenCode at plugin init.
385
398
  * Used by Full-Auto v2 delegation guard to apply strict registry-aware
@@ -731,6 +744,7 @@ export declare function getSessionEnvironment(sessionId: string): EnvironmentPro
731
744
  export declare function ensureSessionEnvironment(sessionId: string): EnvironmentProfile;
732
745
  export declare const MAX_TRACKED_CRITICAL_SHOWN = 500;
733
746
  export declare const MAX_TRACKED_KNOWLEDGE_ACKS = 5000;
747
+ export declare const MAX_TRACKED_GATE_DENIALS = 500;
734
748
  /** Set the critical shown ids for a session, FIFO-evicting the oldest entry
735
749
  * if the cap is exceeded. Re-setting an existing key keeps insertion order
736
750
  * fresh for that key (delete-then-set). */
@@ -744,6 +758,23 @@ export declare function setCriticalShownIds(sessionID: string, value: {
744
758
  * not bypass the FIFO-cap pathway with a direct `.delete()`. Returns
745
759
  * whether an entry was removed. */
746
760
  export declare function clearCriticalShownIds(sessionID: string): boolean;
761
+ /** Build the directive-identity fingerprint used to key the gate denial
762
+ * counter — a sorted, joined snapshot of a critical-directive-id set. Two
763
+ * calls with the same id set (regardless of order) produce the same key,
764
+ * so re-injecting the identical directive on a later turn does not reset
765
+ * the counter, but swapping to a genuinely different directive set does. */
766
+ export declare function buildGateDenialDirectiveKey(ids: string[]): string;
767
+ /** Increment (or start) the per-session gate denial counter for the given
768
+ * directive identity, FIFO-evicting the oldest session entry if the cap is
769
+ * exceeded. When the stored entry's `directiveKey` does not match
770
+ * `directiveKey`, the counter restarts at 1 instead of continuing to
771
+ * accumulate — this is what prevents a stale denial count from an earlier,
772
+ * unrelated critical directive from carrying into a fresh one's
773
+ * `max_gate_denials` budget. Returns the resulting count. */
774
+ export declare function incrementGateDenialCount(sessionID: string, directiveKey: string): number;
775
+ /** Clear the gate denial counter for a session. Centralised so call sites do
776
+ * not bypass the FIFO-cap pathway with a direct `.delete()`. */
777
+ export declare function clearGateDenialCount(sessionID: string): void;
747
778
  /** Add a knowledge ack dedup key, FIFO-evicting the oldest if the cap is
748
779
  * exceeded. Sets preserve insertion order in JS. */
749
780
  export declare function addKnowledgeAckDedup(key: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.125.1",
3
+ "version": "7.125.3",
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",
@@ -1,34 +0,0 @@
1
- // @bun
2
- import {
3
- init_logger,
4
- log
5
- } from "./index-zgwm4ryv.js";
6
- import {
7
- __esm
8
- } from "./index-a76rekgs.js";
9
-
10
- // src/services/warning-buffer.ts
11
- function addDeferredWarning(warning) {
12
- if (deferredWarnings.length < MAX_DEFERRED_WARNINGS - 1) {
13
- deferredWarnings.push(warning);
14
- return;
15
- }
16
- if (!deferredWarningsTruncated) {
17
- deferredWarnings.push(`[opencode-swarm] ${MAX_DEFERRED_WARNINGS - 1} deferred warnings buffered; additional advisories were dropped (cap reached). Run with OPENCODE_SWARM_DEBUG=1 to see all advisories in the debug log.`);
18
- deferredWarningsTruncated = true;
19
- }
20
- }
21
- function advisoryWarn(message, data) {
22
- addDeferredWarning(message);
23
- log(message, data);
24
- }
25
- function getDeferredWarnings() {
26
- return [...deferredWarnings];
27
- }
28
- var deferredWarnings, MAX_DEFERRED_WARNINGS = 50, deferredWarningsTruncated = false;
29
- var init_warning_buffer = __esm(() => {
30
- init_logger();
31
- deferredWarnings = [];
32
- });
33
-
34
- export { advisoryWarn, getDeferredWarnings, init_warning_buffer };