opencode-swarm 7.166.0 → 7.166.2

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 (107) hide show
  1. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  2. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  3. package/dist/background/candidate-contract.d.ts +14 -0
  4. package/dist/background/pr-subscriptions.d.ts +33 -1
  5. package/dist/background/workspace-snapshot.d.ts +41 -0
  6. package/dist/cli/{coder-settlement-ydg2jfrk.js → coder-settlement-pv86n7n4.js} +14 -14
  7. package/dist/cli/{config-doctor-drqx6tzc.js → config-doctor-fy1aytwt.js} +5 -5
  8. package/dist/cli/{core-x6sftfwt.js → core-1d9vqbt4.js} +4 -4
  9. package/dist/cli/{curation-policy-jtzwz6bc.js → curation-policy-gnpgc3z7.js} +7 -5
  10. package/dist/cli/{curator-kg2h8jjf.js → curator-a4rbehfr.js} +40 -40
  11. package/dist/cli/{curator-drift-2vwtkegg.js → curator-drift-efmgp1v2.js} +6 -6
  12. package/dist/cli/curator-llm-factory-cwg62ynw.js +70 -0
  13. package/dist/cli/{dispatch-c7xjt7js.js → dispatch-tmb929w8.js} +3 -3
  14. package/dist/cli/{evidence-summary-service-ry5ebnmq.js → evidence-summary-service-dvp1kbm4.js} +18 -18
  15. package/dist/cli/{gate-evidence-qgeceqy8.js → gate-evidence-qf27gdfx.js} +10 -9
  16. package/dist/cli/guardrail-explain-zskpzgsr.js +71 -0
  17. package/dist/cli/guardrail-log-qhw3knjt.js +23 -0
  18. package/dist/cli/{guardrail-reset-4nmy7xas.js → guardrail-reset-84ydxdg3.js} +40 -40
  19. package/dist/cli/hive-promoter-y2daybf6.js +85 -0
  20. package/dist/cli/{index-mg43w8p2.js → index-0a0jsbhg.js} +16 -7
  21. package/dist/cli/{index-a0d4fp6r.js → index-0tc0pcmh.js} +1 -1
  22. package/dist/cli/{index-a7rw4g4s.js → index-14z9en94.js} +3 -3
  23. package/dist/cli/{index-gy0nyfbw.js → index-19hjpqsy.js} +61 -16
  24. package/dist/cli/{index-fywshabz.js → index-22sannyk.js} +7 -7
  25. package/dist/cli/{index-p04pa9c9.js → index-2n1v8ft1.js} +2 -2
  26. package/dist/cli/{index-jc9cxh90.js → index-3nww2vnx.js} +11 -11
  27. package/dist/cli/{index-9hy5q7gp.js → index-3wtfrjcx.js} +4 -4
  28. package/dist/cli/{index-anxs69ad.js → index-4kwxpnf8.js} +13 -6
  29. package/dist/cli/{index-8m12y79g.js → index-7mxrqy4r.js} +7 -7
  30. package/dist/cli/{index-jx9f4ke1.js → index-7pp8fz4j.js} +1 -1
  31. package/dist/cli/{index-a5w71m8f.js → index-8nv3bc9h.js} +4 -4
  32. package/dist/cli/{index-30f4fe30.js → index-9ccxcjdm.js} +4 -4
  33. package/dist/cli/{index-hwj25q9r.js → index-bks56jbg.js} +70 -53
  34. package/dist/cli/{index-8hqkrd2j.js → index-bysyj3z4.js} +1 -1
  35. package/dist/cli/{index-8n62bphd.js → index-c0eyq4rp.js} +4 -4
  36. package/dist/cli/{index-c20gf089.js → index-c23w8t46.js} +1 -1
  37. package/dist/cli/{index-8d90gzaz.js → index-d5qf7hvh.js} +3 -3
  38. package/dist/cli/{index-nb924ar6.js → index-e0bjbadr.js} +2 -2
  39. package/dist/cli/{index-z6xqpmqg.js → index-ee6ydtfe.js} +1 -1
  40. package/dist/cli/{index-axf65x87.js → index-fkk7x6sy.js} +5 -5
  41. package/dist/cli/{index-17yszqs5.js → index-ft1tnx0e.js} +1 -1
  42. package/dist/cli/{index-an89qzd9.js → index-gy55mc55.js} +749 -755
  43. package/dist/cli/{index-2dvk153d.js → index-hbjax6hy.js} +17 -17
  44. package/dist/cli/{index-2v17wb75.js → index-hgphhnrp.js} +2 -2
  45. package/dist/cli/{index-hvk3zs62.js → index-j81kpway.js} +1 -1
  46. package/dist/cli/{index-hrkamw9q.js → index-jgtje76m.js} +7 -7
  47. package/dist/cli/{index-czr3jcg6.js → index-jr6tppv9.js} +47 -13
  48. package/dist/cli/{index-apxaa755.js → index-kd68b6mg.js} +3 -3
  49. package/dist/cli/{index-289epdpc.js → index-nrdj94za.js} +42 -42
  50. package/dist/cli/{index-79sr3fd1.js → index-nthqfxzz.js} +2 -2
  51. package/dist/cli/{index-6chhqq2n.js → index-p0r5fn7y.js} +94 -3
  52. package/dist/cli/{index-2rm5x9ps.js → index-qmp4gxac.js} +2 -2
  53. package/dist/cli/{index-rkn17q5e.js → index-st47knj6.js} +5 -5
  54. package/dist/cli/{index-edm41q4j.js → index-sxe3t040.js} +2 -2
  55. package/dist/cli/{index-52jfm5s0.js → index-sxsyd7kf.js} +9 -9
  56. package/dist/cli/{index-359djbj1.js → index-ty0wg9yp.js} +5 -5
  57. package/dist/cli/{index-qkq56zyr.js → index-wz258yje.js} +69 -18
  58. package/dist/cli/{index-bw7r2b2m.js → index-x4azb6qj.js} +2 -2
  59. package/dist/cli/{index-8bdk7124.js → index-x8cvbkjs.js} +2 -2
  60. package/dist/cli/{index-aftapk6j.js → index-y3dtdn2f.js} +3 -3
  61. package/dist/cli/{index-4mpdy32j.js → index-ytsts0zj.js} +1 -1
  62. package/dist/cli/{index-ejf6w8vw.js → index-z1kmkh72.js} +2 -2
  63. package/dist/cli/index-zpsr8rpc.js +68 -0
  64. package/dist/cli/index.js +40 -40
  65. package/dist/cli/{knowledge-escalator-xdzmr31d.js → knowledge-escalator-aq7gzhpd.js} +15 -15
  66. package/dist/cli/{knowledge-events-1t1t0bv7.js → knowledge-events-9z5sskyv.js} +13 -13
  67. package/dist/cli/{knowledge-link-1zykfk1p.js → knowledge-link-ps2v4s18.js} +6 -4
  68. package/dist/cli/{knowledge-store-m2snb0xg.js → knowledge-store-1hzt2a0t.js} +7 -5
  69. package/dist/cli/{knowledge-validator-tf7yq2pd.js → knowledge-validator-xe1fza7c.js} +9 -7
  70. package/dist/cli/{model-preflight-3s1c0zpc.js → model-preflight-b3b5pgsc.js} +2 -2
  71. package/dist/cli/{pending-delegations-jr8hwxrz.js → pending-delegations-0nfjg7vp.js} +13 -13
  72. package/dist/cli/{pr-subscriptions-ca1xmf9r.js → pr-subscriptions-8974hwa0.js} +19 -13
  73. package/dist/cli/{pr-workflow-gate-fb1dj0zx.js → pr-workflow-gate-xgak5wvz.js} +40 -40
  74. package/dist/cli/{runner-j3acybhs.js → runner-7zqbp81n.js} +8 -5
  75. package/dist/cli/{scan-cursor-3gdvy0ym.js → scan-cursor-hc4v0c90.js} +8 -6
  76. package/dist/cli/{schema-mzb1354k.js → schema-w1hsvw1h.js} +3 -3
  77. package/dist/cli/{scope-persistence-c4n21b5n.js → scope-persistence-k17003v4.js} +17 -16
  78. package/dist/cli/{skill-generator-dvpvwt8k.js → skill-generator-tbxgpc9x.js} +17 -17
  79. package/dist/cli/{snapshot-coordination-init-g7v63zcm.js → snapshot-coordination-init-vaf34wf0.js} +40 -40
  80. package/dist/cli/{telemetry-9h1z2w9d.js → telemetry-8qn4eag5.js} +5 -1
  81. package/dist/cli/{workspace-snapshot-6z9rk7xw.js → workspace-snapshot-y85jy6gs.js} +11 -1
  82. package/dist/cli/{worktree-collision-ownership-k15qrpy9.js → worktree-collision-ownership-r3jdke7h.js} +14 -14
  83. package/dist/cli/{worktree-isolation-y7ec1pm5.js → worktree-isolation-sa1tbqff.js} +40 -40
  84. package/dist/evidence/phase-participation.d.ts +1 -1
  85. package/dist/git/pr.d.ts +4 -2
  86. package/dist/git/safe-ref.d.ts +51 -0
  87. package/dist/hooks/guardrails/execution-stall.d.ts +10 -5
  88. package/dist/hooks/hive-promoter.d.ts +28 -5
  89. package/dist/hooks/repo-graph-builder.d.ts +14 -0
  90. package/dist/hooks/system-enhancer.d.ts +21 -0
  91. package/dist/index.js +250 -248
  92. package/dist/observability/catalog.d.ts +1 -1
  93. package/dist/session/snapshot-writer.d.ts +42 -0
  94. package/dist/telemetry.d.ts +31 -1
  95. package/dist/tools/co-change-analyzer.d.ts +7 -0
  96. package/dist/tools/gh-evidence.d.ts +15 -8
  97. package/dist/tools/pkg-audit.d.ts +23 -0
  98. package/dist/utils/atomic-write.d.ts +32 -0
  99. package/dist/utils/gh-executable.d.ts +106 -0
  100. package/dist/utils/merge.d.ts +26 -0
  101. package/dist/utils/swarm-artifact-cache.d.ts +6 -0
  102. package/package.json +1 -1
  103. package/dist/cli/curator-llm-factory-7znajprp.js +0 -70
  104. package/dist/cli/guardrail-explain-jdv4n2j3.js +0 -71
  105. package/dist/cli/guardrail-log-s7c3rpde.js +0 -23
  106. package/dist/cli/hive-promoter-w5tsgttc.js +0 -85
  107. package/dist/cli/index-zjygnfay.js +0 -33
@@ -2,7 +2,7 @@
2
2
  * The event catalog (issue #2029).
3
3
  *
4
4
  * Exactly 61 entries, matching the `TelemetryEvent` union at
5
- * `src/telemetry.ts:16-172`. Thirty-eight predate the #2029 contract; the 39th is
5
+ * `src/telemetry.ts:20-172`. Thirty-eight predate the #2029 contract; the 39th is
6
6
  * `agent_conflict_detected` (previously emitted through a force-cast past the
7
7
  * type system), the 40th is `close_archive_result` (issue #2030 — the
8
8
  * structured close/archive result event), the 41st is the bounded diagnostic
@@ -104,6 +104,48 @@ export interface SerializedAgentSession {
104
104
  /** Provider id paired with lastObservedModel (#1896). Omitted when undefined. */
105
105
  lastObservedProviderID?: string;
106
106
  }
107
+ /**
108
+ * Compile-time snapshot-field parity map (issue #2472 W6 / AC-7; frozen check C7).
109
+ *
110
+ * WHY THIS MAP EXISTS — the serializer reads FROM `AgentSessionState` and
111
+ * writes TO `SerializedAgentSession`, so the drift-prone direction is a field
112
+ * that exists on the live state but silently never reaches the snapshot:
113
+ * nothing fails, the field is just lost on every restart. The
114
+ * `Record<Exclude<keyof AgentSessionState, keyof SerializedAgentSession>, string>`
115
+ * key type makes that direction exhaustive at compile time — EVERY state field
116
+ * that is not a serialized field MUST appear here with a one-line rationale,
117
+ * and a key that is NOT such a field is an excess-property type error. Adding
118
+ * a field to either interface without reconciling this map fails
119
+ * `bun run typecheck` (CI gate).
120
+ *
121
+ * The serialized-only direction (a `SerializedAgentSession` field with no
122
+ * `AgentSessionState` counterpart) is guarded separately by the
123
+ * `_serializedFieldsExistOnState` assertion below. The asymmetry is
124
+ * deliberate: the serializer can only *drop* state fields, while the reader
125
+ * could otherwise *invent* fields the live state does not have.
126
+ *
127
+ * This is NOT the same list as `TRANSIENT_SESSION_FIELDS` in
128
+ * `src/session/snapshot-reader.ts` (fields RESET on rehydration — a subset of
129
+ * the *serialized* fields). This map lists fields that are NEVER serialized.
130
+ * Most are genuinely process-local; `workspaceDirectory` is deliberately
131
+ * unserializable for trust reasons (see its TRUST BOUNDARY comment in
132
+ * `src/state.ts`), which is exactly why it must carry an entry here rather
133
+ * than fall out of the type silently.
134
+ *
135
+ * The runtime mirror of this guard lives at
136
+ * `tests/unit/session/snapshot-field-parity-guard.test.ts` (what frozen
137
+ * check C7 runs).
138
+ */
139
+ export declare const SESSION_TRANSIENT_FIELDS: Readonly<Record<Exclude<keyof AgentSessionState, keyof SerializedAgentSession>, string>>;
140
+ /**
141
+ * Reverse-direction parity guard: every `SerializedAgentSession` field must
142
+ * exist on `AgentSessionState`. The const assignment is what makes tsc
143
+ * actually enforce the conditional type — when a serialized field has no
144
+ * state counterpart, the type degrades to the error tuple below and assigning
145
+ * `true` fails `bun run typecheck` with that message.
146
+ */
147
+ export type SerializedFieldsAllExistOnState = Exclude<keyof SerializedAgentSession, keyof AgentSessionState> extends never ? true : ['SerializedAgentSession field missing from AgentSessionState'];
148
+ export declare const _serializedFieldsExistOnState: SerializedFieldsAllExistOnState;
107
149
  /**
108
150
  * Minimal interface for serialized InvocationWindow
109
151
  */
@@ -66,7 +66,37 @@ export declare function resetTelemetryForTesting(): void;
66
66
  /**
67
67
  * Initialize telemetry with the project directory.
68
68
  * Creates `.swarm/` if it doesn't exist and opens `telemetry.jsonl` for appending.
69
- * Idempotent — calling multiple times has no effect after the first successful call.
69
+ * Idempotent — calling multiple times with the SAME directory has no effect
70
+ * after the first successful call.
71
+ *
72
+ * Re-home (issue #2472 W9): when called with a projectDirectory DIFFERENT
73
+ * from the latched `_projectDirectory` while a stream exists (a second
74
+ * server() instance initializing in this process for another project root),
75
+ * telemetry re-initializes for the new directory exactly as a fresh init
76
+ * does — the previous behavior latched the first directory forever, so the
77
+ * second project's `.swarm/telemetry.jsonl` was never created. A disabled
78
+ * telemetry state stays disabled.
79
+ *
80
+ * No-drop ordering + fail-open ownership retention (PR #2588, review finding
81
+ * 6 / PRR-019): the NEW stream is created and published FIRST, and only then
82
+ * is the old stream flushed/closed best-effort. The previous
83
+ * close-then-create order nulled `_writeStream` before the replacement
84
+ * existed, so any emit racing the re-home was dropped by the
85
+ * `_writeStream === null` guard, and a new-stream creation FAILURE took the
86
+ * whole process's telemetry down (`_disabled = true`) after the old stream
87
+ * was already gone. On creation failure the OLD stream is now retained
88
+ * (logged non-fatally, no re-home) — events keep flowing to the previous
89
+ * directory until a later successful init.
90
+ *
91
+ * OWNERSHIP CONTRACT (last-init-wins): the newest successful initTelemetry
92
+ * call owns THE single live stream for the whole process. In a
93
+ * multi-project process, a project initialized earlier SHARES the latest
94
+ * stream until it re-initializes; per-event project routing is out of scope
95
+ * — the issue #2472 obligation is directory-CHANGE detection, not per-event
96
+ * fan-out. Same-directory detection uses canonical project-root identity
97
+ * (`sameProjectRoot`), so Windows case differences and symlink/junction
98
+ * spellings of one root do not churn the stream.
99
+ *
70
100
  * @param projectDirectory - Absolute path to the project root
71
101
  */
72
102
  export declare function initTelemetry(projectDirectory: string): void;
@@ -1,5 +1,10 @@
1
+ import * as child_process from 'node:child_process';
1
2
  import type { tool } from '@opencode-ai/plugin';
2
3
  import type { SwarmKnowledgeEntry } from '../hooks/knowledge-types.js';
4
+ /** Lazy-bind so mock.module can intercept at call time (#330); all internal
5
+ * calls route through _internals.getExecFileAsync so tests can replace the
6
+ * seam directly (PRR-020). */
7
+ declare function getExecFileAsync(): typeof child_process.execFile.__promisify__;
3
8
  export interface CoChangeEntry {
4
9
  fileA: string;
5
10
  fileB: string;
@@ -55,4 +60,6 @@ export declare const _internals: {
55
60
  detectDarkMatter: typeof detectDarkMatter;
56
61
  darkMatterToKnowledgeEntries: typeof darkMatterToKnowledgeEntries;
57
62
  formatDarkMatterOutput: typeof formatDarkMatterOutput;
63
+ getExecFileAsync: typeof getExecFileAsync;
58
64
  };
65
+ export {};
@@ -1,18 +1,24 @@
1
1
  import type { ToolDefinition } from '@opencode-ai/plugin/tool';
2
2
  import { resolveExecutableFromPath, runExternalTool } from '../utils/external-tool-runner';
3
+ import { resolveGhExecutable } from '../utils/gh-executable';
3
4
  interface GhBinaryCandidateOptions {
4
- env?: Pick<NodeJS.ProcessEnv, 'ProgramFiles' | 'ProgramFiles(x86)' | 'LOCALAPPDATA'>;
5
+ env?: NodeJS.ProcessEnv;
5
6
  platform?: NodeJS.Platform;
6
7
  }
7
8
  export declare function resolveGhBinaryCandidates(options?: GhBinaryCandidateOptions): string[];
8
9
  /**
9
- * Resolve the `gh` binary to invoke. Exported (issue #2236 hardening, lane
10
- * C1b) so other call sites that need a `gh` executable — e.g. `src/git/pr.ts`,
11
- * `src/commands/pr-monitor-status.ts` — reuse this resolver instead of
12
- * spawning a bare `'gh'` literal or inventing a second gh resolver. Returns
13
- * `null` when no candidate is found; callers should fall back to the bare
14
- * `'gh'` literal (mirrors `resolveGitExecutable()`'s "never regress a working
15
- * host" fallback in `src/utils/git-executable.ts`).
10
+ * Resolve the `gh` binary for the gh_evidence tool. Exported (issue #2236
11
+ * hardening, lane C1b) so other call sites that need a `gh` executable — e.g.
12
+ * `src/git/pr.ts`, `src/commands/pr-monitor-status.ts` — reuse this resolver
13
+ * instead of spawning a bare `'gh'` literal or inventing a second gh resolver.
14
+ *
15
+ * Issue #2476 AC1: delegates to the hardened twin of the git resolver
16
+ * (`src/utils/gh-executable.ts`) — absolute-candidate-first ordering,
17
+ * absoluteness requirement, `gh --version` probe, bounded budget, caching.
18
+ * Returns `null` when nothing validated (the resolver's bare-`'gh'` terminal
19
+ * fallback maps here to null so the tool renders its gh-not-found guidance
20
+ * exactly as a scan-miss did before); callers that spawn directly should use
21
+ * `resolveGhExecutable()` instead, which never returns null.
16
22
  */
17
23
  export declare function resolveGhBinary(): string | null;
18
24
  /**
@@ -26,6 +32,7 @@ export declare const gh_evidence: ToolDefinition;
26
32
  export declare const _internals: {
27
33
  resolveGhBinaryCandidates: typeof resolveGhBinaryCandidates;
28
34
  resolveExecutableFromPath: typeof resolveExecutableFromPath;
35
+ resolveGhExecutable: typeof resolveGhExecutable;
29
36
  resolveGhBinary: typeof resolveGhBinary;
30
37
  runExternalTool: typeof runExternalTool;
31
38
  };
@@ -9,7 +9,30 @@ import { bunSpawn } from '../utils/bun-compat';
9
9
  * functions gate strictly on a non-zero exit and were dispositioned
10
10
  * SAFE-EXIT-CHECK by that sweep.
11
11
  */
12
+ /**
13
+ * Resolve the spawn command prefix for a package-audit binary (issue #2476
14
+ * AC5). On POSIX (or when resolution fails) the bare name is returned -- the
15
+ * historical behavior, which works there. On win32 the absolute candidate is
16
+ * resolved via resolveExecutableFromPath (.exe/.cmd/.bat variants); a
17
+ * `.cmd`/`.bat` hit cannot be spawned directly by Node (EINVAL since the
18
+ * CVE-2024-27980 hardening), so it is routed through cmd.exe as
19
+ * `/d /s /c call "<resolved>"` -- everything after `/c` is cmd's own command
20
+ * line, the repo-documented windowsVerbatimArguments pattern. Empirically
21
+ * verified on Windows (node & Bun): a bare quoted tail `"<path>"` is mangled
22
+ * by cmd's /s quote-stripping (the last quote in the line is removed), while
23
+ * the `call` prefix keeps the quoted path intact for paths containing spaces
24
+ * such as C:\Program Files. Callers append their fixed literal arguments
25
+ * (`audit --json`) as separate argv elements; verbatim joining keeps them
26
+ * outside the quoted path. The only interpolated value is the resolved
27
+ * ABSOLUTE path, rejected when it contains any cmd metacharacter
28
+ * (`" & | < > ^ ! %`) so the verbatim command line degrades to the bare-name
29
+ * fallback rather than through any cmd re-interpretation; the remaining
30
+ * tokens are fixed literals.
31
+ */
32
+ declare function resolveAuditCommandDefault(name: 'npm' | 'cargo'): string[];
12
33
  export declare const _internals: {
13
34
  bunSpawn: typeof bunSpawn;
35
+ resolveAuditCommand: typeof resolveAuditCommandDefault;
14
36
  };
15
37
  export declare const pkg_audit: ReturnType<typeof tool>;
38
+ export {};
@@ -128,6 +128,38 @@ export declare function assertWellFormedTargetPath(targetPath: string): void;
128
128
  export declare function assertSwarmContainedTarget(targetPath: string): SwarmContainment;
129
129
  /** Hard bound on a single atomic write (bounded-write requirement). */
130
130
  export declare const MAX_ATOMIC_WRITE_BYTES: number;
131
+ /**
132
+ * Default window within which an ENOENT read of a target this process wrote
133
+ * (or is writing) is treated as plausibly mid-rename rather than never-existed
134
+ * — see `wasRecentlyWrittenByThisProcess` and the three-way ENOENT policy in
135
+ * `readSwarmFileAsync` (src/hooks/utils.ts).
136
+ */
137
+ export declare const RECENT_WRITE_WINDOW_MS = 500;
138
+ /**
139
+ * Remove the recent-write marker for `targetPath` (PRR-008). Called from the
140
+ * canonical writer's failure path: a write that throws before its rename
141
+ * completes must not leave a stale INTENT stamp behind, or a subsequent ENOENT
142
+ * read of the target would be misclassified as a rename race and retried
143
+ * against a file this process is no longer producing. Successful writes are
144
+ * unaffected — they reach the WRITE COMPLETION refresh, which re-stamps the
145
+ * marker for the post-rename visibility window. Returns true when a stamp was
146
+ * present and removed.
147
+ */
148
+ export declare function clearRecentWriteActivity(targetPath: string): boolean;
149
+ /**
150
+ * Whether this process recorded a write INTENT or write COMPLETION for
151
+ * `targetPath` within the last `withinMs` milliseconds (default
152
+ * {@link RECENT_WRITE_WINDOW_MS}).
153
+ *
154
+ * Consumers: the ENOENT retry ladders (`readSwarmFileAsync`,
155
+ * `readFileOrEmpty` in src/services/context-budget-service.ts) use this as
156
+ * the "evidenced rename-race" arm — an ENOENT on a file THIS process just
157
+ * wrote (or is mid-write on: intent is recorded before the temp file write
158
+ * begins) retries, while an ENOENT with no evidence the file ever existed
159
+ * returns immediately (issue #2472 PERF-1: 4×10ms of sleeps per missing-file
160
+ * read, ~1.9s/turn on plan-less projects).
161
+ */
162
+ export declare function wasRecentlyWrittenByThisProcess(targetPath: string, withinMs?: number): boolean;
131
163
  export interface AtomicWriteOptions {
132
164
  /** Skip the pre-rename fsync (tests / truly ephemeral data). */
133
165
  readonly skipFsync?: boolean;
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Single source of truth for "what absolute path do we invoke for gh" — the
3
+ * gh twin of `resolveGitExecutable()` in `src/utils/git-executable.ts`
4
+ * (issue #2476 AC1 / source issue #2262).
5
+ *
6
+ * The pre-fix resolver (`resolveGhBinaryCandidates` in
7
+ * `src/tools/gh-evidence.ts` + `resolveExecutableFromPath`) put the bare
8
+ * name FIRST, so a full PATH scan for `gh` beat every ProgramFiles absolute
9
+ * candidate; accepted any stat-able regular file (a 20-byte text file named
10
+ * gh.exe passed); and had no `gh --version` behavioral probe, no budget, and
11
+ * no cache. That matters MORE than the git case: `gh` runs with the user's
12
+ * GitHub token, so a hijack is credential theft in addition to code
13
+ * execution.
14
+ *
15
+ * Contract (mirrors git-executable.ts; deviations called out inline):
16
+ *
17
+ * 1. explicit override — the `OPENCODE_SWARM_GH_BINARY` env var ONLY.
18
+ * There is deliberately NO config-file `gh.binary` key: the config path
19
+ * is the attack surface `enforceGitBinaryProvenance` exists to strip
20
+ * for git, and gh never had one. Env-only keeps every override
21
+ * user-controlled by construction.
22
+ * 2. platform absolute candidates (win32 ProgramFiles/LOCALAPPDATA — the
23
+ * set `resolveGhBinaryCandidates` already knew — plus darwin/linux
24
+ * install locations, which the old resolver lacked entirely);
25
+ * 3. ALL PATH matches for `gh` (win32: `.exe`/`.cmd`/`.bat` variants);
26
+ * 4. bare `'gh'` LAST, unprobed, so a host that works via plain PATH
27
+ * lookup never regresses.
28
+ *
29
+ * Each non-bare candidate must be ABSOLUTE and is validated once with
30
+ * `gh --version` (bounded, explicit cwd) whose output must match
31
+ * GH_VERSION_PATTERN — exit 0 alone does not accept a candidate. NOT AN
32
+ * ANTI-TAMPERING CONTROL (a hostile program can print `gh version 2.x`); it
33
+ * stops ACCIDENTS — a non-gh that merely exits 0, a broken shim. The
34
+ * trust-boundary control is that no repository-controlled value can name a
35
+ * candidate at all (env-only override).
36
+ *
37
+ * Bounded probing (AGENTS.md invariant 1): per-probe timeout 250 ms, total
38
+ * first-resolution budget 1000 ms. gh resolution is LAZY (tool/ghExec call
39
+ * paths, never plugin init), so the sync API below is sufficient — there is
40
+ * no init-path need for an async variant.
41
+ *
42
+ * NEVER throws: both non-accepting outcomes (budget exhausted, every
43
+ * candidate rejected) return the bare `'gh'` fallback, memoized with a 60 s
44
+ * TTL so a host that installs gh mid-session recovers (same rationale as
45
+ * git-executable.ts — a slash-less spawn does not resolve against the PATH
46
+ * this module enumerates, so "gh is missing" is not a state this resolver
47
+ * may report).
48
+ */
49
+ import { spawnSync } from 'node:child_process';
50
+ /** Env var escape hatch — a blocked user can set this without editing files. */
51
+ export declare const GH_BINARY_ENV_VAR = "OPENCODE_SWARM_GH_BINARY";
52
+ /**
53
+ * `gh --version` prints `gh version 2.74.0 (2025-...)` — a fixed format
54
+ * string in gh's own root command. Same accident-not-attacker contract as
55
+ * `GIT_VERSION_PATTERN` (see git-executable.ts); anchored to the first line.
56
+ */
57
+ export declare const GH_VERSION_PATTERN: RegExp;
58
+ export type GhResolutionCandidateSource = 'override' | 'platform' | 'path';
59
+ export interface GhResolutionAttempt {
60
+ source: GhResolutionCandidateSource;
61
+ candidate: string;
62
+ accepted: boolean;
63
+ /** Rejection reason; absent when `accepted` is true. */
64
+ reason?: string;
65
+ }
66
+ export interface GhResolutionDescription {
67
+ resolved: boolean;
68
+ resolvedPath?: string;
69
+ attempts: GhResolutionAttempt[];
70
+ overrideValue?: string;
71
+ }
72
+ /**
73
+ * Windows install locations, kept in one place so the legacy
74
+ * `resolveGhBinaryCandidates` export in gh-evidence.ts can share the set.
75
+ * Paths are built with native separators via path.join by the caller.
76
+ */
77
+ export declare function windowsGhAbsoluteCandidates(env: NodeJS.ProcessEnv): string[];
78
+ /**
79
+ * Resolve the gh executable to invoke. Lazy, memoized, bounded by
80
+ * TOTAL_BUDGET_MS, never throws. Returns a validated absolute path or the
81
+ * bare `'gh'` fallback.
82
+ */
83
+ export declare function resolveGhExecutable(): string;
84
+ /** Exported for tests; clears the memoized cache (and bumps the generation). */
85
+ export declare function resetGhExecutableCache(): void;
86
+ /**
87
+ * TEST-ONLY seam — NOT a production API, do not call from `src/`. Pre-seeds
88
+ * the resolver cache with an explicit "success" entry so
89
+ * `resolveGhExecutable()` returns `value` with zero probe spawns. Distinct
90
+ * from gh-evidence.ts's `__seedGhBinaryForTests` (which pins only that
91
+ * wrapper's legacy layer): neither bypasses the other.
92
+ */
93
+ export declare function __seedGhExecutableForTests(value: string): void;
94
+ /** Diagnostic surface: candidates tried in the most recent probe cycle. */
95
+ export declare function describeGhResolution(): GhResolutionDescription;
96
+ /**
97
+ * DI seam for testability (repo convention — see git-executable.ts).
98
+ * `platform`/`env` let tests drive every platform branch regardless of the
99
+ * host OS; `now` makes the TTL and budget deterministically testable.
100
+ */
101
+ export declare const _internals: {
102
+ spawnSync: typeof spawnSync;
103
+ platform: () => NodeJS.Platform;
104
+ env: () => NodeJS.ProcessEnv;
105
+ now: () => number;
106
+ };
@@ -1,5 +1,31 @@
1
1
  export declare const MAX_MERGE_DEPTH = 10;
2
+ /**
3
+ * Keys that must never be merged, at any depth (issue #2476 AC2 / source
4
+ * issue #2264). `JSON.parse` creates `__proto__` as an OWN ENUMERABLE data
5
+ * property (CreateDataProperty, not [[Set]]), so `Object.keys(override)`
6
+ * yields it and the plain assignment below would invoke the
7
+ * `Object.prototype.__proto__` setter and reparent the merged object.
8
+ * `constructor`/`prototype` are the sibling prototype-pollution carriers.
9
+ * Only the OVERRIDE side is checked: that is the untrusted side at every
10
+ * production call site (repo-supplied project config over user config at
11
+ * `src/config/loader.ts`; user scoring config over defaults at
12
+ * `src/config/constants.ts`) — `base` is either caller-built defaults or an
13
+ * already-vetted earlier merge.
14
+ */
15
+ export declare const DANGEROUS_MERGE_KEYS: ReadonlySet<string>;
16
+ /** Typed, fail-closed rejection of a dangerous merge key (issue #2476 AC2). */
17
+ export declare class DangerousMergeKeyError extends Error {
18
+ readonly key: string;
19
+ readonly path: string;
20
+ constructor(key: string, path: string);
21
+ }
2
22
  /**
3
23
  * Deep merge two objects, with override values taking precedence.
24
+ *
25
+ * Throws `DangerousMergeKeyError` when the override object carries
26
+ * `__proto__`, `constructor`, or `prototype` at ANY depth (issue #2476 AC2).
27
+ * The config loader catches this at the repo-supplied project-config merge
28
+ * and continues with user-level config only; other callers get the typed
29
+ * throw as fail-closed semantics.
4
30
  */
5
31
  export declare function deepMerge<T extends Record<string, unknown>>(base?: T, override?: T): T | undefined;
@@ -15,6 +15,12 @@ export interface SwarmArtifactCacheStats {
15
15
  textEntryCount: number;
16
16
  parsedEntryCount: number;
17
17
  }
18
+ /**
19
+ * Whether a previous successful stat/read inside this module observed
20
+ * `filePath` to exist (resolved the same way the cache keys are). Cheap Set
21
+ * lookup — safe on hot paths.
22
+ */
23
+ export declare function wasObservedToExist(filePath: string): boolean;
18
24
  /**
19
25
  * Dependency-injection seam for testing. Tests can temporarily replace these
20
26
  * to force a specific (e.g. colliding) stat stamp without relying on
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-swarm",
3
- "version": "7.166.0",
3
+ "version": "7.166.2",
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,70 +0,0 @@
1
- // @bun
2
- import {
3
- createCuratorLLMDelegate
4
- } from "./index-an89qzd9.js";
5
- import"./index-8d90gzaz.js";
6
- import"./index-hvk3zs62.js";
7
- import"./index-9hy5q7gp.js";
8
- import"./index-p04pa9c9.js";
9
- import"./index-qkq56zyr.js";
10
- import"./index-17yszqs5.js";
11
- import"./index-txdagbh7.js";
12
- import"./index-cw912re7.js";
13
- import"./index-hrkamw9q.js";
14
- import"./index-359djbj1.js";
15
- import"./index-bw7r2b2m.js";
16
- import"./index-70ha9e09.js";
17
- import"./index-8hqkrd2j.js";
18
- import"./index-9ss2m4rs.js";
19
- import"./index-czr3jcg6.js";
20
- import"./index-zsrtt42s.js";
21
- import"./index-2dvk153d.js";
22
- import"./index-6chhqq2n.js";
23
- import"./index-8bdk7124.js";
24
- import"./index-b43rt5ph.js";
25
- import"./index-q7sjgr1y.js";
26
- import"./index-8n62bphd.js";
27
- import"./index-2rm5x9ps.js";
28
- import"./index-52jfm5s0.js";
29
- import"./index-jc9cxh90.js";
30
- import"./index-anxs69ad.js";
31
- import"./index-z6xqpmqg.js";
32
- import"./index-p612v1mv.js";
33
- import"./index-a5w71m8f.js";
34
- import"./index-c20gf089.js";
35
- import"./index-rtry5xyf.js";
36
- import"./index-apxaa755.js";
37
- import"./index-3qf1vxtb.js";
38
- import"./index-n832052r.js";
39
- import"./index-8m12y79g.js";
40
- import"./index-30f4fe30.js";
41
- import"./index-2v17wb75.js";
42
- import"./index-79sr3fd1.js";
43
- import"./index-jx9f4ke1.js";
44
- import"./index-aftapk6j.js";
45
- import"./index-ry16d01s.js";
46
- import"./index-n4fzmqz8.js";
47
- import"./index-axf65x87.js";
48
- import"./index-fywshabz.js";
49
- import"./index-ae75rja9.js";
50
- import"./index-a7rw4g4s.js";
51
- import"./index-7qefgq4j.js";
52
- import"./index-edm41q4j.js";
53
- import"./index-gy0nyfbw.js";
54
- import"./index-hwj25q9r.js";
55
- import"./index-7g4c7s5r.js";
56
- import"./index-mg43w8p2.js";
57
- import"./index-9e6fdz2h.js";
58
- import"./index-4rhhvd1a.js";
59
- import"./index-nb924ar6.js";
60
- import"./index-a0d4fp6r.js";
61
- import"./index-zjygnfay.js";
62
- import"./index-bk5tah7q.js";
63
- import"./index-bpmtbmy9.js";
64
- import"./index-q1r1cfww.js";
65
- import"./index-yzjaj53h.js";
66
- import"./index-zgwm4ryv.js";
67
- import"./index-a76rekgs.js";
68
- export {
69
- createCuratorLLMDelegate
70
- };
@@ -1,71 +0,0 @@
1
- // @bun
2
- import {
3
- handleGuardrailExplain
4
- } from "./index-ejf6w8vw.js";
5
- import"./index-an89qzd9.js";
6
- import"./index-8d90gzaz.js";
7
- import"./index-hvk3zs62.js";
8
- import"./index-9hy5q7gp.js";
9
- import"./index-p04pa9c9.js";
10
- import"./index-qkq56zyr.js";
11
- import"./index-17yszqs5.js";
12
- import"./index-txdagbh7.js";
13
- import"./index-cw912re7.js";
14
- import"./index-hrkamw9q.js";
15
- import"./index-359djbj1.js";
16
- import"./index-bw7r2b2m.js";
17
- import"./index-70ha9e09.js";
18
- import"./index-8hqkrd2j.js";
19
- import"./index-9ss2m4rs.js";
20
- import"./index-czr3jcg6.js";
21
- import"./index-zsrtt42s.js";
22
- import"./index-2dvk153d.js";
23
- import"./index-6chhqq2n.js";
24
- import"./index-8bdk7124.js";
25
- import"./index-b43rt5ph.js";
26
- import"./index-q7sjgr1y.js";
27
- import"./index-8n62bphd.js";
28
- import"./index-2rm5x9ps.js";
29
- import"./index-52jfm5s0.js";
30
- import"./index-jc9cxh90.js";
31
- import"./index-anxs69ad.js";
32
- import"./index-z6xqpmqg.js";
33
- import"./index-p612v1mv.js";
34
- import"./index-a5w71m8f.js";
35
- import"./index-c20gf089.js";
36
- import"./index-rtry5xyf.js";
37
- import"./index-apxaa755.js";
38
- import"./index-3qf1vxtb.js";
39
- import"./index-n832052r.js";
40
- import"./index-8m12y79g.js";
41
- import"./index-30f4fe30.js";
42
- import"./index-2v17wb75.js";
43
- import"./index-79sr3fd1.js";
44
- import"./index-jx9f4ke1.js";
45
- import"./index-aftapk6j.js";
46
- import"./index-ry16d01s.js";
47
- import"./index-n4fzmqz8.js";
48
- import"./index-axf65x87.js";
49
- import"./index-fywshabz.js";
50
- import"./index-ae75rja9.js";
51
- import"./index-a7rw4g4s.js";
52
- import"./index-7qefgq4j.js";
53
- import"./index-edm41q4j.js";
54
- import"./index-gy0nyfbw.js";
55
- import"./index-hwj25q9r.js";
56
- import"./index-7g4c7s5r.js";
57
- import"./index-mg43w8p2.js";
58
- import"./index-9e6fdz2h.js";
59
- import"./index-4rhhvd1a.js";
60
- import"./index-nb924ar6.js";
61
- import"./index-a0d4fp6r.js";
62
- import"./index-zjygnfay.js";
63
- import"./index-bk5tah7q.js";
64
- import"./index-bpmtbmy9.js";
65
- import"./index-q1r1cfww.js";
66
- import"./index-yzjaj53h.js";
67
- import"./index-zgwm4ryv.js";
68
- import"./index-a76rekgs.js";
69
- export {
70
- handleGuardrailExplain
71
- };
@@ -1,23 +0,0 @@
1
- // @bun
2
- import {
3
- handleGuardrailLog
4
- } from "./index-4mpdy32j.js";
5
- import"./index-9hy5q7gp.js";
6
- import"./index-z6xqpmqg.js";
7
- import"./index-p612v1mv.js";
8
- import"./index-2v17wb75.js";
9
- import"./index-axf65x87.js";
10
- import"./index-7qefgq4j.js";
11
- import"./index-gy0nyfbw.js";
12
- import"./index-hwj25q9r.js";
13
- import"./index-nb924ar6.js";
14
- import"./index-a0d4fp6r.js";
15
- import"./index-zjygnfay.js";
16
- import"./index-bk5tah7q.js";
17
- import"./index-bpmtbmy9.js";
18
- import"./index-yzjaj53h.js";
19
- import"./index-zgwm4ryv.js";
20
- import"./index-a76rekgs.js";
21
- export {
22
- handleGuardrailLog
23
- };
@@ -1,85 +0,0 @@
1
- // @bun
2
- import {
3
- _internals2 as _internals,
4
- checkHivePromotions,
5
- countDistinctProjects,
6
- createHivePromoterHook,
7
- isHiveEligible,
8
- promoteFromSwarm,
9
- promoteToHive
10
- } from "./index-an89qzd9.js";
11
- import"./index-8d90gzaz.js";
12
- import"./index-hvk3zs62.js";
13
- import"./index-9hy5q7gp.js";
14
- import"./index-p04pa9c9.js";
15
- import"./index-qkq56zyr.js";
16
- import"./index-17yszqs5.js";
17
- import"./index-txdagbh7.js";
18
- import"./index-cw912re7.js";
19
- import"./index-hrkamw9q.js";
20
- import"./index-359djbj1.js";
21
- import"./index-bw7r2b2m.js";
22
- import"./index-70ha9e09.js";
23
- import"./index-8hqkrd2j.js";
24
- import"./index-9ss2m4rs.js";
25
- import"./index-czr3jcg6.js";
26
- import"./index-zsrtt42s.js";
27
- import"./index-2dvk153d.js";
28
- import"./index-6chhqq2n.js";
29
- import"./index-8bdk7124.js";
30
- import"./index-b43rt5ph.js";
31
- import"./index-q7sjgr1y.js";
32
- import"./index-8n62bphd.js";
33
- import"./index-2rm5x9ps.js";
34
- import"./index-52jfm5s0.js";
35
- import"./index-jc9cxh90.js";
36
- import"./index-anxs69ad.js";
37
- import"./index-z6xqpmqg.js";
38
- import"./index-p612v1mv.js";
39
- import"./index-a5w71m8f.js";
40
- import"./index-c20gf089.js";
41
- import"./index-rtry5xyf.js";
42
- import"./index-apxaa755.js";
43
- import"./index-3qf1vxtb.js";
44
- import"./index-n832052r.js";
45
- import"./index-8m12y79g.js";
46
- import"./index-30f4fe30.js";
47
- import"./index-2v17wb75.js";
48
- import"./index-79sr3fd1.js";
49
- import"./index-jx9f4ke1.js";
50
- import"./index-aftapk6j.js";
51
- import"./index-ry16d01s.js";
52
- import"./index-n4fzmqz8.js";
53
- import"./index-axf65x87.js";
54
- import {
55
- resolveHiveKnowledgePath
56
- } from "./index-fywshabz.js";
57
- import"./index-ae75rja9.js";
58
- import"./index-a7rw4g4s.js";
59
- import"./index-7qefgq4j.js";
60
- import"./index-edm41q4j.js";
61
- import"./index-gy0nyfbw.js";
62
- import"./index-hwj25q9r.js";
63
- import"./index-7g4c7s5r.js";
64
- import"./index-mg43w8p2.js";
65
- import"./index-9e6fdz2h.js";
66
- import"./index-4rhhvd1a.js";
67
- import"./index-nb924ar6.js";
68
- import"./index-a0d4fp6r.js";
69
- import"./index-zjygnfay.js";
70
- import"./index-bk5tah7q.js";
71
- import"./index-bpmtbmy9.js";
72
- import"./index-q1r1cfww.js";
73
- import"./index-yzjaj53h.js";
74
- import"./index-zgwm4ryv.js";
75
- import"./index-a76rekgs.js";
76
- export {
77
- resolveHiveKnowledgePath,
78
- promoteToHive,
79
- promoteFromSwarm,
80
- isHiveEligible,
81
- createHivePromoterHook,
82
- countDistinctProjects,
83
- checkHivePromotions,
84
- _internals
85
- };