opencode-swarm 7.121.2 → 7.121.4

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/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  getPluginLockFilePaths,
8
8
  package_default,
9
9
  resolveCommand
10
- } from "./index-y0qa3xf0.js";
10
+ } from "./index-q0fv0xec.js";
11
11
  import"./index-kyvg2cmp.js";
12
12
  import"./index-vqcgmy4y.js";
13
13
  import"./index-emkb0bbe.js";
@@ -3,4 +3,8 @@
3
3
  * Sanitizes the description, parses flags, and emits a DESIGN_DOCS mode signal
4
4
  * that routes the architect into the design-doc generation/sync workflow.
5
5
  */
6
+ import { loadPluginConfigWithMeta } from '../config';
7
+ export declare const _internals: {
8
+ loadPluginConfigWithMeta: typeof loadPluginConfigWithMeta;
9
+ };
6
10
  export declare function handleDesignDocsCommand(directory: string, args: string[]): Promise<string>;
@@ -1,22 +1,22 @@
1
1
  /**
2
2
  * Handle /swarm pr-feedback command.
3
3
  *
4
- * Triggers the architect to enter MODE: PR_FEEDBACK — the swarm workflow for
4
+ * Triggers the architect to enter MODE: PR_FEEDBACK the swarm workflow for
5
5
  * ingesting and closing KNOWN pull-request feedback (review comments, requested
6
6
  * changes, CI failures, merge conflicts, stale branches, pasted notes). This is
7
7
  * distinct from /swarm pr-review, which discovers NEW findings.
8
8
  *
9
9
  * Input contract (PR reference is optional):
10
- * /swarm pr-feedback 155 → feedback pass on PR 155
11
- * /swarm pr-feedback 155 also fix the lint errors → PR 155 + extra instructions
10
+ * /swarm pr-feedback 155 feedback pass on PR 155
11
+ * /swarm pr-feedback 155 also fix the lint errors PR 155 + extra instructions
12
12
  * /swarm pr-feedback 155 continue from .swarm/pr-review/<run_id>/feedback-handoff.md
13
13
  * -> PR 155 + handoff path instructions
14
- * /swarm pr-feedback owner/repo#155 → shorthand
14
+ * /swarm pr-feedback owner/repo#155 shorthand
15
15
  * /swarm pr-feedback https://github.com/.../pull/155
16
- * /swarm pr-feedback → bare signal; architect builds
16
+ * /swarm pr-feedback bare signal; architect builds
17
17
  * the ledger from current PR/branch
18
18
  * /swarm pr-feedback address the review notes about error handling
19
- * → no parseable PR ref ⇒ the whole
19
+ * no parseable PR ref the whole
20
20
  * input is forwarded as instructions
21
21
  *
22
22
  * PR-reference parsing and injection-hardening are shared with /swarm pr-review
@@ -7,7 +7,11 @@
7
7
  * normalized directory path.
8
8
  * - `qa-gate-profile`: service layer for per-plan QA gate profiles stored
9
9
  * in the project DB.
10
+ * - `sqlite-loader`: runtime-portable SQLite `Database` constructor resolver
11
+ * (native `bun:sqlite` under Bun, a `node:sqlite` adapter under Node — issue
12
+ * #1873). Used by `global-db`, `project-db`, and the memory SQLite provider.
10
13
  */
11
14
  export { closeGlobalDb, getGlobalDb, runGlobalMigrations, } from './global-db.js';
12
15
  export { closeAllProjectDbs, closeProjectDb, getProjectDb, projectDbExists, projectDbPath, runProjectMigrations, } from './project-db.js';
13
16
  export { computeProfileHash, DEFAULT_QA_GATES, getEffectiveGates, getOrCreateProfile, getProfile, lockProfile, type QaGateProfile, type QaGates, setGates, } from './qa-gate-profile.js';
17
+ export { loadDatabaseCtor } from './sqlite-loader.js';
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Runtime-portable SQLite driver loader for opencode-swarm.
3
+ *
4
+ * Why this exists (issue #1873): the published plugin bundle (`dist/index.js`) is
5
+ * built `--target node` and OpenCode Desktop loads it inside a **Node.js** Electron
6
+ * `utilityProcess` sidecar. The previous DB layer resolved the driver with a lazy
7
+ * `createRequire(import.meta.url)('bun:sqlite')` and **no fallback**. `bun:sqlite` is
8
+ * a Bun-only built-in, so under Node every SQLite-backed tool threw
9
+ * `Error: Cannot find module 'bun:sqlite'` (`swarm_memory_recall`, the QA-gate tools,
10
+ * `get_approved_plan`, …).
11
+ *
12
+ * The lazy require kept `bun:sqlite` out of the bundle's top-level ESM imports (which
13
+ * is what invariant #2 / issue #675 requires — a static `import … from 'bun:…'` breaks
14
+ * Node's ESM resolver with `ERR_UNSUPPORTED_ESM_URL_SCHEME`), but it still assumed a
15
+ * Bun runtime at call time.
16
+ *
17
+ * This module is the single, sanctioned place that resolves a `bun:sqlite`-shaped
18
+ * `Database` constructor:
19
+ * 1. Under Bun: return the native `bun:sqlite` `Database` (behaviour unchanged).
20
+ * 2. Under Node: wrap `node:sqlite`'s `DatabaseSync` (flag-free in Node 22.13+; added
21
+ * behind `--experimental-sqlite` in 22.5; shipped by Electron 42+) in a small
22
+ * adapter that presents the exact `Database` subset the
23
+ * codebase uses — `run(sql, params?)`, `query(sql).{get,all,iterate}`,
24
+ * `transaction(fn)`, `inTransaction`, `loadExtension(path)`, `close()`. A bare
25
+ * constructor swap is NOT enough: `DatabaseSync` has none of
26
+ * `run/query/transaction/inTransaction`.
27
+ * 3. If neither driver is available: throw one clear, combined diagnostic.
28
+ *
29
+ * Portability contract (invariant #2): all three former call sites
30
+ * (`project-db.ts`, `global-db.ts`, `memory/sqlite-provider.ts`) now import
31
+ * `loadDatabaseCtor` from here. No new lazy `require('bun:…')` may be added elsewhere —
32
+ * `tests/unit/build/bundle-portability.test.ts` enforces this statically, and
33
+ * `scripts/repro-1873.mjs` exercises the real Node driver end-to-end in CI.
34
+ */
35
+ import type { Database } from 'bun:sqlite';
36
+ interface NodeStatementSync {
37
+ get(...params: unknown[]): unknown;
38
+ all(...params: unknown[]): unknown[];
39
+ iterate(...params: unknown[]): IterableIterator<unknown>;
40
+ run(...params: unknown[]): {
41
+ changes: number | bigint;
42
+ lastInsertRowid: number | bigint;
43
+ };
44
+ }
45
+ interface NodeDatabaseSync {
46
+ exec(sql: string): void;
47
+ prepare(sql: string): NodeStatementSync;
48
+ readonly isTransaction: boolean;
49
+ enableLoadExtension(enable: boolean): void;
50
+ loadExtension(path: string): void;
51
+ close(): void;
52
+ }
53
+ type NodeDatabaseSyncCtor = new (filename: string, options?: {
54
+ allowExtension?: boolean;
55
+ }) => NodeDatabaseSync;
56
+ /**
57
+ * Build a `bun:sqlite`-`Database`-compatible constructor backed by `node:sqlite`'s
58
+ * `DatabaseSync`. Exported for direct unit testing under Bun (which lacks
59
+ * `node:sqlite`) via an injected fake `DatabaseSync`.
60
+ */
61
+ export declare function createNodeDatabaseCtor(DatabaseSyncCtor: NodeDatabaseSyncCtor): typeof Database;
62
+ /**
63
+ * Internal seam for tests: `requireModule` is dependency-injected so a Bun test can
64
+ * force the Node fallback path with a fake `node:sqlite`, and `reset()` clears the
65
+ * module-level cache between cases. Not part of the public API.
66
+ */
67
+ export declare const _internals: {
68
+ requireModule(id: string): unknown;
69
+ reset(): void;
70
+ };
71
+ /**
72
+ * Resolve a `bun:sqlite`-`Database`-compatible constructor for the current runtime.
73
+ * Cached after first resolution.
74
+ *
75
+ * Order: native `bun:sqlite` (Bun) → `node:sqlite` adapter (Node) → clear error.
76
+ */
77
+ export declare function loadDatabaseCtor(): typeof Database;
78
+ export {};
@@ -55,7 +55,7 @@ export interface EnrichmentQuotaOptions {
55
55
  * One retry on schema failure (with a RETRY message naming the missing
56
56
  * fields). Quota-gated per call via the dedicated knowledge-enrichment quota.
57
57
  * Returns null when
58
- * enrichment is unavailable (quota exhausted) or fails twice — the caller
58
+ * enrichment is unavailable (quota exhausted) or fails twice the caller
59
59
  * quarantines the entry. Never throws.
60
60
  */
61
61
  export declare function enrichLessonToV3(params: {
@@ -106,15 +106,15 @@ export declare function runAutoPromotion(directory: string, config: KnowledgeCon
106
106
  /**
107
107
  * G7 (#1716): Auto-demote swarm entries that have sustained a net-negative
108
108
  * outcome signal over consecutive phase EVALUATIONS (i.e. consecutive
109
- * `runAutoDemotion` invocations with distinct phase numbers — a skipped phase
110
- * in between still counts, matching the issue's "≥3 consecutive" intent as
109
+ * `runAutoDemotion` invocations with distinct phase numbers a skipped phase
110
+ * in between still counts, matching the issue's "3 consecutive" intent as
111
111
  * implemented against evaluation cadence, not wall-clock phase contiguity).
112
112
  *
113
113
  * Companion to {@link runAutoPromotion}. For each `promoted` entry:
114
114
  * 1. Dedupe by phase: if `entry.last_demotion_phase === phaseNumber`, this
115
115
  * entry has already been processed for this phase (handles the case where
116
116
  * `curateAndStoreSwarm` is invoked multiple times in the same logical
117
- * phase — e.g. phase-complete + close). Skip the counter update.
117
+ * phase e.g. phase-complete + close). Skip the counter update.
118
118
  * 2. Otherwise compute the outcome signal. If at/below
119
119
  * `config.promoted_demotion_signal_threshold`, increment
120
120
  * `recent_negative_phase_count`; else reset it to 0.