opencode-swarm 7.144.1 → 7.144.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 (103) hide show
  1. package/.opencode/skills/swarm-pr-review/references/lane-output-recoverability.md +96 -0
  2. package/dist/agents/architect.d.ts +1 -0
  3. package/dist/agents/coder.d.ts +1 -0
  4. package/dist/agents/critic.d.ts +1 -0
  5. package/dist/agents/explorer.d.ts +1 -0
  6. package/dist/agents/reviewer.d.ts +1 -0
  7. package/dist/background/pending-delegations.d.ts +20 -0
  8. package/dist/cli/{ast-diff-ypptrcan.js → ast-diff-wbjcazfx.js} +5 -3
  9. package/dist/cli/{config-doctor-5hj26phk.js → config-doctor-pkr9w2nv.js} +3 -3
  10. package/dist/cli/{core-aqtegsag.js → core-7pymdx0b.js} +3 -3
  11. package/dist/cli/{curation-policy-pkb2eeb1.js → curation-policy-y1pqpztb.js} +5 -5
  12. package/dist/cli/curator-drift-2jbjv03a.js +1 -1
  13. package/dist/cli/{curator-llm-factory-1rg62kzr.js → curator-llm-factory-7are9wjh.js} +34 -34
  14. package/dist/cli/{curator-vcrcht4h.js → curator-wbzcjd0q.js} +34 -34
  15. package/dist/cli/{evidence-summary-service-fsh6jfhm.js → evidence-summary-service-rcgrdm52.js} +14 -14
  16. package/dist/cli/{explorer-18353rhn.js → explorer-zvk5kbcb.js} +3 -1
  17. package/dist/cli/{gate-evidence-9w2eehnj.js → gate-evidence-jmzctnhg.js} +7 -7
  18. package/dist/cli/{guardrail-explain-6mxn4bj8.js → guardrail-explain-brgw4sve.js} +35 -35
  19. package/dist/cli/{guardrail-log-81c5b018.js → guardrail-log-k1s9xf3h.js} +4 -4
  20. package/dist/cli/{hive-promoter-rxkykddk.js → hive-promoter-vcj5h0e3.js} +36 -36
  21. package/dist/cli/{index-n11zkp9g.js → index-06cn7haa.js} +2 -2
  22. package/dist/cli/{index-tq5s07ta.js → index-0fgwdtvp.js} +1 -1
  23. package/dist/cli/{index-j3byg0a9.js → index-1brb14xc.js} +6 -2
  24. package/dist/cli/{index-e9w1tfmm.js → index-247wf23m.js} +6974 -1859
  25. package/dist/cli/{index-mz1zwz96.js → index-2en8s72h.js} +2 -2
  26. package/dist/cli/{index-gdd4jt6b.js → index-584grrwn.js} +1 -1
  27. package/dist/cli/{index-2ht8c7ew.js → index-6s2q144w.js} +2 -7
  28. package/dist/cli/{index-xmzmeknp.js → index-70ha9e09.js} +2 -1
  29. package/dist/cli/{index-j2eb0x44.js → index-7554tecy.js} +2 -2
  30. package/dist/cli/{index-5n69863d.js → index-7ryh498h.js} +1 -173
  31. package/dist/cli/{index-k92cagmt.js → index-8214dd7j.js} +2 -2
  32. package/dist/cli/{index-rdb3nr6d.js → index-8hkjk37c.js} +1 -1
  33. package/dist/cli/{index-315tnsve.js → index-b227mpnk.js} +4 -4
  34. package/dist/cli/index-ddpkwdcb.js +176 -0
  35. package/dist/cli/{index-w7x7qxz2.js → index-dpfphnmy.js} +1 -1
  36. package/dist/cli/{index-8gs34d2q.js → index-ep14xc5z.js} +4 -4
  37. package/dist/cli/{index-g0vr2a4m.js → index-eya357bk.js} +9 -9
  38. package/dist/cli/{index-hc25qawy.js → index-ghzvxj3g.js} +37 -37
  39. package/dist/cli/{index-bgdr1ww3.js → index-j6mfyy0a.js} +3 -3
  40. package/dist/cli/{index-4fda8kkw.js → index-krxcxkdq.js} +13 -3
  41. package/dist/cli/{index-f79hf8dr.js → index-p7hbphaq.js} +4 -4
  42. package/dist/cli/{index-4s5htbgq.js → index-p863y7xx.js} +1 -1
  43. package/dist/cli/{index-dq26vbfp.js → index-pag8nsb1.js} +10 -10
  44. package/dist/cli/{index-rr2fjfsd.js → index-pr8vhj6j.js} +12 -12
  45. package/dist/cli/{index-8jrn4rwp.js → index-qj22wyw2.js} +3 -3
  46. package/dist/cli/{index-1faydhv8.js → index-satc0vs6.js} +203 -100
  47. package/dist/cli/{index-2pmaxbvj.js → index-wck434f8.js} +2 -2
  48. package/dist/cli/{index-jqsfsqbx.js → index-whezv7vc.js} +4 -0
  49. package/dist/cli/{index-4905hd2m.js → index-wx8zdh4a.js} +6 -1
  50. package/dist/cli/{index-sqp6349j.js → index-x68tw7v3.js} +5 -5
  51. package/dist/cli/{index-c3zag2cw.js → index-xwpmxpb7.js} +9 -9
  52. package/dist/cli/{index-erfnw81g.js → index-zswmbm15.js} +1 -1
  53. package/dist/cli/{index-4q9vfav6.js → index-zwrqe065.js} +1 -1
  54. package/dist/cli/index.js +37 -51
  55. package/dist/cli/{knowledge-escalator-hg4jzbrx.js → knowledge-escalator-x6jrcrwj.js} +13 -13
  56. package/dist/cli/{knowledge-events-wgy7gbct.js → knowledge-events-aw22r72m.js} +11 -11
  57. package/dist/cli/{knowledge-link-fn5j3r4q.js → knowledge-link-bntppte4.js} +4 -4
  58. package/dist/cli/{knowledge-store-nd0f0e86.js → knowledge-store-19xg1rw1.js} +6 -6
  59. package/dist/cli/{knowledge-validator-0ar015bf.js → knowledge-validator-8wh82z0a.js} +8 -8
  60. package/dist/cli/{pending-delegations-thy8g30k.js → pending-delegations-1y303j3k.js} +3 -3
  61. package/dist/cli/{pr-subscriptions-jyav582d.js → pr-subscriptions-wvd041rp.js} +3 -3
  62. package/dist/cli/{runner-pde6b5sx.js → runner-jn55k8xb.js} +5 -5
  63. package/dist/cli/{runtime-te94z1zb.js → runtime-x10qb3z1.js} +3 -2
  64. package/dist/cli/{scan-cursor-pqp3bsqv.js → scan-cursor-429r5db9.js} +7 -7
  65. package/dist/cli/{schema-4ew49zrv.js → schema-jdwjcby0.js} +2 -2
  66. package/dist/cli/{scope-persistence-geth2hb1.js → scope-persistence-s0s1bz15.js} +7 -7
  67. package/dist/cli/{skill-generator-8azm6p2y.js → skill-generator-ffbj0ye5.js} +16 -16
  68. package/dist/cli/tree-sitter-431q1bka.js +26 -0
  69. package/dist/cli/{worktree-collision-ownership-j6d33p49.js → worktree-collision-ownership-z5ftwjz3.js} +6 -6
  70. package/dist/cli/{worktree-isolation-cqxgdk2p.js → worktree-isolation-y2p93438.js} +34 -34
  71. package/dist/commands/registry.d.ts +1 -1
  72. package/dist/config/constants.d.ts +1 -1
  73. package/dist/config/schema.d.ts +8 -0
  74. package/dist/hooks/pr-workflow-gate.d.ts +132 -3
  75. package/dist/hooks/review-receipt-scope.d.ts +42 -15
  76. package/dist/hooks/reviewer-scope-file-fingerprint.d.ts +58 -6
  77. package/dist/hooks/reviewer-scope-lifecycle.d.ts +9 -1
  78. package/dist/hooks/reviewer-scope-mergeback.d.ts +23 -0
  79. package/dist/index.d.ts +3 -0
  80. package/dist/index.js +858 -816
  81. package/dist/memory/config.d.ts +6 -0
  82. package/dist/memory/consolidation.d.ts +2 -0
  83. package/dist/memory/gateway.d.ts +12 -1
  84. package/dist/memory/index.d.ts +6 -4
  85. package/dist/memory/jsonl-migration.d.ts +28 -3
  86. package/dist/memory/local-jsonl-provider.d.ts +16 -1
  87. package/dist/memory/maintenance.d.ts +5 -0
  88. package/dist/memory/memory-family-migration.d.ts +12 -0
  89. package/dist/memory/outcome-events.d.ts +24 -0
  90. package/dist/memory/provider.d.ts +7 -1
  91. package/dist/memory/reflection-injection.d.ts +1 -0
  92. package/dist/memory/reflection-service.d.ts +68 -0
  93. package/dist/memory/reflection.d.ts +41 -0
  94. package/dist/memory/schema.d.ts +13 -1
  95. package/dist/memory/sqlite-provider.d.ts +18 -1
  96. package/dist/memory/types.d.ts +19 -1
  97. package/dist/state.d.ts +107 -2
  98. package/dist/tools/index.d.ts +1 -0
  99. package/dist/tools/manifest.d.ts +1 -0
  100. package/dist/tools/swarm-memory-outcome.d.ts +11 -0
  101. package/dist/tools/tool-metadata.d.ts +4 -0
  102. package/package.json +1 -1
  103. package/dist/cli/{index-k31en0ja.js → index-wd24zn2e.js} +3 -3
@@ -6,11 +6,11 @@ import {
6
6
  PluginConfigSchema,
7
7
  init_schema,
8
8
  stripKnownSwarmPrefix
9
- } from "./index-j3byg0a9.js";
9
+ } from "./index-1brb14xc.js";
10
10
  import {
11
11
  ALL_AGENT_NAMES,
12
12
  init_constants
13
- } from "./index-jqsfsqbx.js";
13
+ } from "./index-whezv7vc.js";
14
14
  import {
15
15
  log
16
16
  } from "./index-zgwm4ryv.js";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./index-rn0eq85g.js";
5
5
  import {
6
6
  withEvidenceLock
7
- } from "./index-k31en0ja.js";
7
+ } from "./index-wd24zn2e.js";
8
8
  import {
9
9
  exports_external,
10
10
  init_zod
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  SWARM_WORKTREE_DIR_NAME,
8
8
  init_constants
9
- } from "./index-jqsfsqbx.js";
9
+ } from "./index-whezv7vc.js";
10
10
  import {
11
11
  bunSpawn
12
12
  } from "./index-4nt52yr9.js";
@@ -86,7 +86,7 @@ var _internals = {
86
86
  symlinkSync: fs.symlinkSync
87
87
  },
88
88
  writeScopeToDisk: async (directory, taskId, files) => {
89
- const { writeScopeToDisk: realWrite } = await import("./scope-persistence-geth2hb1.js");
89
+ const { writeScopeToDisk: realWrite } = await import("./scope-persistence-s0s1bz15.js");
90
90
  return realWrite(directory, taskId, files);
91
91
  },
92
92
  writeLaneProfileToDisk: async (_worktreePath, _laneIndex, _envOverrides) => {
@@ -275,11 +275,6 @@ async function provisionWorktree(directory, id, sessionId, options) {
275
275
  };
276
276
  const expectedPath = normalizeGitPath(worktreePath);
277
277
  let entries = [];
278
- let current = {
279
- path: "",
280
- branch: undefined,
281
- prunable: false
282
- };
283
278
  if (listResult.exitCode !== 0) {
284
279
  const raw = listResult.stderr.trim() || listResult.stdout.trim();
285
280
  const bounded = raw.length > 500 ? `${raw.slice(0, 500)}... (truncated)` : raw;
@@ -21,6 +21,7 @@ You may be invoked through dispatch_lanes or dispatch_lanes_async as a read-only
21
21
  - Return findings for the architect to synthesize. Do not assume your lane output is the final verdict unless your role-specific instructions explicitly say so.`;
22
22
 
23
23
  // src/agents/explorer.ts
24
+ var EXPLORER_MEMORY_OUTCOME_GUIDANCE = "Use `swarm_memory_outcome` after evaluating recalled memory or a graph answer: record `useful`, `dead_end`, or `corrected` with the relevant file/symbol anchors.";
24
25
  var EXPLORER_PROMPT = `## IDENTITY
25
26
  You are Explorer. You analyze codebases directly \u2014 you do NOT delegate.
26
27
  DO NOT use the Task tool to delegate to other agents. You ARE the agent that does the work.
@@ -429,4 +430,4 @@ function createExplorerAgent(model, customPrompt, customAppendPrompt) {
429
430
  };
430
431
  }
431
432
 
432
- export { READ_ONLY_LANE_GUIDANCE, EXPLORER_PROMPT, CURATOR_INIT_PROMPT, CURATOR_PHASE_PROMPT, CURATOR_POSTMORTEM_PROMPT, CURATOR_CONSOLIDATION_PROMPT, createExplorerAgent };
433
+ export { READ_ONLY_LANE_GUIDANCE, EXPLORER_MEMORY_OUTCOME_GUIDANCE, EXPLORER_PROMPT, CURATOR_INIT_PROMPT, CURATOR_PHASE_PROMPT, CURATOR_POSTMORTEM_PROMPT, CURATOR_CONSOLIDATION_PROMPT, createExplorerAgent };
@@ -11,10 +11,10 @@ import {
11
11
  import {
12
12
  init_schema,
13
13
  stripKnownSwarmPrefix
14
- } from "./index-j3byg0a9.js";
14
+ } from "./index-1brb14xc.js";
15
15
  import {
16
16
  init_constants
17
- } from "./index-jqsfsqbx.js";
17
+ } from "./index-whezv7vc.js";
18
18
  import {
19
19
  init_logger,
20
20
  warn
@@ -1,16 +1,8 @@
1
1
  // @bun
2
- import {
3
- withTimeout
4
- } from "./index-4905hd2m.js";
5
2
  import {
6
3
  __require
7
4
  } from "./index-a76rekgs.js";
8
5
 
9
- // src/lang/runtime.ts
10
- import { existsSync, statSync } from "fs";
11
- import * as path from "path";
12
- import { fileURLToPath } from "url";
13
-
14
6
  // node_modules/web-tree-sitter/tree-sitter.js
15
7
  var __defProp = Object.defineProperty;
16
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
@@ -3222,168 +3214,4 @@ var Parser = class {
3222
3214
  return this.logCallback;
3223
3215
  }
3224
3216
  };
3225
-
3226
- // src/lang/runtime.ts
3227
- var parserCache = new Map;
3228
- var inflightLoads = new Map;
3229
- var GRAMMAR_LOAD_TIMEOUT_MS = 1e4;
3230
- var initializedLanguages = new Set;
3231
- var treeSitterInitPromise = null;
3232
- var _internals = {
3233
- parserInit: Parser.init,
3234
- getModuleDir: () => path.dirname(fileURLToPath(import.meta.url)),
3235
- fileExists: existsSync
3236
- };
3237
- async function initTreeSitter() {
3238
- if (!treeSitterInitPromise) {
3239
- treeSitterInitPromise = (async () => {
3240
- const thisDir = _internals.getModuleDir();
3241
- const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
3242
- if (isSource) {
3243
- await _internals.parserInit();
3244
- } else {
3245
- const grammarsDir = getGrammarsDirAbsolute();
3246
- const coreWasmPath = path.join(grammarsDir, "tree-sitter.wasm");
3247
- if (!_internals.fileExists(coreWasmPath)) {
3248
- throw new Error(`Core tree-sitter WASM runtime missing: ${coreWasmPath}
3249
- ` + `The installed OpenCode plugin cache is incomplete or stale. Run ` + `'bunx opencode-swarm update', then restart OpenCode so it fetches ` + `a fresh package from npm.`);
3250
- }
3251
- await _internals.parserInit({
3252
- locateFile(scriptName) {
3253
- return path.join(grammarsDir, scriptName);
3254
- }
3255
- });
3256
- }
3257
- })().catch((err2) => {
3258
- treeSitterInitPromise = null;
3259
- throw err2;
3260
- });
3261
- }
3262
- return treeSitterInitPromise;
3263
- }
3264
- var LANGUAGE_WASM_MAP = {
3265
- javascript: "tree-sitter-javascript.wasm",
3266
- typescript: "tree-sitter-typescript.wasm",
3267
- tsx: "tree-sitter-tsx.wasm",
3268
- python: "tree-sitter-python.wasm",
3269
- go: "tree-sitter-go.wasm",
3270
- rust: "tree-sitter-rust.wasm",
3271
- cpp: "tree-sitter-cpp.wasm",
3272
- c: "tree-sitter-cpp.wasm",
3273
- csharp: "tree-sitter-c-sharp.wasm",
3274
- css: "tree-sitter-css.wasm",
3275
- bash: "tree-sitter-bash.wasm",
3276
- ruby: "tree-sitter-ruby.wasm",
3277
- php: "tree-sitter-php.wasm",
3278
- java: "tree-sitter-java.wasm",
3279
- kotlin: "tree-sitter-kotlin.wasm",
3280
- swift: "tree-sitter-swift.wasm",
3281
- dart: "tree-sitter-dart.wasm",
3282
- powershell: "tree-sitter-powershell.wasm",
3283
- ini: "tree-sitter-ini.wasm",
3284
- regex: "tree-sitter-regex.wasm"
3285
- };
3286
- function sanitizeLanguageId(languageId) {
3287
- const normalized = languageId.toLowerCase();
3288
- if (!/^[a-z0-9-]+$/.test(normalized)) {
3289
- throw new Error(`Invalid language ID: ${languageId}`);
3290
- }
3291
- return normalized;
3292
- }
3293
- function getWasmFileName(languageId) {
3294
- const sanitized = sanitizeLanguageId(languageId).toLowerCase();
3295
- if (LANGUAGE_WASM_MAP[sanitized]) {
3296
- return LANGUAGE_WASM_MAP[sanitized];
3297
- }
3298
- return `tree-sitter-${sanitized}.wasm`;
3299
- }
3300
- function resolveGrammarsDir(thisDir) {
3301
- const normalized = thisDir.replace(/\\/g, "/");
3302
- const isSource = normalized.endsWith("/src/lang");
3303
- const isCliBundle = normalized.endsWith("/cli");
3304
- return isSource ? path.join(thisDir, "grammars") : isCliBundle ? path.join(thisDir, "..", "lang", "grammars") : path.join(thisDir, "lang", "grammars");
3305
- }
3306
- function getGrammarsDirAbsolute() {
3307
- const thisDir = _internals.getModuleDir();
3308
- return resolveGrammarsDir(thisDir);
3309
- }
3310
- async function loadGrammar(languageId) {
3311
- if (typeof languageId !== "string" || languageId.length > 100) {
3312
- throw new Error(`Invalid languageId: must be a string of at most 100 characters`);
3313
- }
3314
- const normalizedId = sanitizeLanguageId(languageId).toLowerCase();
3315
- if (normalizedId.length === 0) {
3316
- throw new Error(`Invalid languageId: empty after sanitization`);
3317
- }
3318
- if (parserCache.has(normalizedId)) {
3319
- return parserCache.get(normalizedId);
3320
- }
3321
- const existing = inflightLoads.get(normalizedId);
3322
- if (existing)
3323
- return existing;
3324
- const loadPromise = (async () => {
3325
- await initTreeSitter();
3326
- const parser = new Parser;
3327
- const wasmFileName = getWasmFileName(normalizedId);
3328
- const wasmPath = path.join(getGrammarsDirAbsolute(), wasmFileName);
3329
- if (!_internals.fileExists(wasmPath)) {
3330
- throw new Error(`Grammar file not found for ${languageId}: ${wasmPath}
3331
- ` + `Make sure to run 'bun run build' to copy grammar files to dist/lang/grammars/. ` + `If this is an installed OpenCode plugin cache, run ` + `'bunx opencode-swarm update' and restart OpenCode.`);
3332
- }
3333
- try {
3334
- const language = await withTimeout(Language.load(wasmPath), GRAMMAR_LOAD_TIMEOUT_MS, new Error(`Timed out after ${GRAMMAR_LOAD_TIMEOUT_MS}ms loading grammar`));
3335
- parser.setLanguage(language);
3336
- } catch (error) {
3337
- throw new Error(`Failed to load grammar for ${languageId}: ${error instanceof Error ? error.message : String(error)}
3338
- ` + `WASM path: ${wasmPath}`);
3339
- }
3340
- parserCache.set(normalizedId, parser);
3341
- initializedLanguages.add(normalizedId);
3342
- return parser;
3343
- })();
3344
- inflightLoads.set(normalizedId, loadPromise);
3345
- try {
3346
- return await loadPromise;
3347
- } finally {
3348
- inflightLoads.delete(normalizedId);
3349
- }
3350
- }
3351
- async function isGrammarAvailable(languageId) {
3352
- if (typeof languageId !== "string" || languageId.length > 100) {
3353
- return false;
3354
- }
3355
- let normalizedId;
3356
- try {
3357
- normalizedId = sanitizeLanguageId(languageId).toLowerCase();
3358
- } catch {
3359
- return false;
3360
- }
3361
- if (normalizedId.length === 0) {
3362
- return false;
3363
- }
3364
- if (parserCache.has(normalizedId)) {
3365
- return true;
3366
- }
3367
- try {
3368
- const wasmFileName = getWasmFileName(normalizedId);
3369
- const wasmPath = path.join(getGrammarsDirAbsolute(), wasmFileName);
3370
- statSync(wasmPath);
3371
- return true;
3372
- } catch {
3373
- return false;
3374
- }
3375
- }
3376
- function clearParserCache() {
3377
- parserCache.clear();
3378
- inflightLoads.clear();
3379
- initializedLanguages.clear();
3380
- treeSitterInitPromise = null;
3381
- }
3382
- function getInitializedLanguages() {
3383
- return Array.from(initializedLanguages);
3384
- }
3385
- function getSupportedLanguages() {
3386
- return Object.keys(LANGUAGE_WASM_MAP);
3387
- }
3388
-
3389
- export { Query, parserCache, _internals, resolveGrammarsDir, loadGrammar, isGrammarAvailable, clearParserCache, getInitializedLanguages, getSupportedLanguages };
3217
+ export { LookaheadIterator, Tree, TreeCursor, Node, CaptureQuantifier, Query, Language, LANGUAGE_VERSION, MIN_COMPATIBLE_VERSION, Parser };
@@ -9,11 +9,11 @@ import {
9
9
  } from "./index-y8552snf.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-erfnw81g.js";
12
+ } from "./index-zswmbm15.js";
13
13
  import {
14
14
  assertProjectRoot,
15
15
  withEvidenceLock
16
- } from "./index-k31en0ja.js";
16
+ } from "./index-wd24zn2e.js";
17
17
  import {
18
18
  exports_external,
19
19
  init_zod
@@ -6,7 +6,7 @@ import {
6
6
  PluginConfigSchema,
7
7
  init_schema,
8
8
  resolveExternalSkillsConfig
9
- } from "./index-j3byg0a9.js";
9
+ } from "./index-1brb14xc.js";
10
10
  import {
11
11
  advisoryWarn,
12
12
  init_warning_buffer
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  authorizeCuration
4
- } from "./index-tq5s07ta.js";
4
+ } from "./index-0fgwdtvp.js";
5
5
  import {
6
6
  findNearDuplicate,
7
7
  inferTags,
@@ -9,13 +9,13 @@ import {
9
9
  resolveSwarmKnowledgePath,
10
10
  resolveSwarmRejectedPath,
11
11
  transactKnowledge
12
- } from "./index-c3zag2cw.js";
12
+ } from "./index-xwpmxpb7.js";
13
13
  import {
14
14
  resolveKnowledgeStoreDir
15
- } from "./index-w7x7qxz2.js";
15
+ } from "./index-dpfphnmy.js";
16
16
  import {
17
17
  atomicWriteFile
18
- } from "./index-erfnw81g.js";
18
+ } from "./index-zswmbm15.js";
19
19
  import {
20
20
  require_proper_lockfile
21
21
  } from "./index-7g4c7s5r.js";
@@ -0,0 +1,176 @@
1
+ // @bun
2
+ import {
3
+ Language,
4
+ Parser
5
+ } from "./index-7ryh498h.js";
6
+ import {
7
+ withTimeout
8
+ } from "./index-wx8zdh4a.js";
9
+
10
+ // src/lang/runtime.ts
11
+ import { existsSync, statSync } from "fs";
12
+ import * as path from "path";
13
+ import { fileURLToPath } from "url";
14
+ var parserCache = new Map;
15
+ var inflightLoads = new Map;
16
+ var GRAMMAR_LOAD_TIMEOUT_MS = 1e4;
17
+ var initializedLanguages = new Set;
18
+ var treeSitterInitPromise = null;
19
+ var _internals = {
20
+ parserInit: Parser.init,
21
+ getModuleDir: () => path.dirname(fileURLToPath(import.meta.url)),
22
+ fileExists: existsSync
23
+ };
24
+ async function initTreeSitter() {
25
+ if (!treeSitterInitPromise) {
26
+ treeSitterInitPromise = (async () => {
27
+ const thisDir = _internals.getModuleDir();
28
+ const isSource = thisDir.replace(/\\/g, "/").endsWith("/src/lang");
29
+ if (isSource) {
30
+ await _internals.parserInit();
31
+ } else {
32
+ const grammarsDir = getGrammarsDirAbsolute();
33
+ const coreWasmPath = path.join(grammarsDir, "tree-sitter.wasm");
34
+ if (!_internals.fileExists(coreWasmPath)) {
35
+ throw new Error(`Core tree-sitter WASM runtime missing: ${coreWasmPath}
36
+ ` + `The installed OpenCode plugin cache is incomplete or stale. Run ` + `'bunx opencode-swarm update', then restart OpenCode so it fetches ` + `a fresh package from npm.`);
37
+ }
38
+ await _internals.parserInit({
39
+ locateFile(scriptName) {
40
+ return path.join(grammarsDir, scriptName);
41
+ }
42
+ });
43
+ }
44
+ })().catch((err) => {
45
+ treeSitterInitPromise = null;
46
+ throw err;
47
+ });
48
+ }
49
+ return treeSitterInitPromise;
50
+ }
51
+ var LANGUAGE_WASM_MAP = {
52
+ javascript: "tree-sitter-javascript.wasm",
53
+ typescript: "tree-sitter-typescript.wasm",
54
+ tsx: "tree-sitter-tsx.wasm",
55
+ python: "tree-sitter-python.wasm",
56
+ go: "tree-sitter-go.wasm",
57
+ rust: "tree-sitter-rust.wasm",
58
+ cpp: "tree-sitter-cpp.wasm",
59
+ c: "tree-sitter-cpp.wasm",
60
+ csharp: "tree-sitter-c-sharp.wasm",
61
+ css: "tree-sitter-css.wasm",
62
+ bash: "tree-sitter-bash.wasm",
63
+ ruby: "tree-sitter-ruby.wasm",
64
+ php: "tree-sitter-php.wasm",
65
+ java: "tree-sitter-java.wasm",
66
+ kotlin: "tree-sitter-kotlin.wasm",
67
+ swift: "tree-sitter-swift.wasm",
68
+ dart: "tree-sitter-dart.wasm",
69
+ powershell: "tree-sitter-powershell.wasm",
70
+ ini: "tree-sitter-ini.wasm",
71
+ regex: "tree-sitter-regex.wasm"
72
+ };
73
+ function sanitizeLanguageId(languageId) {
74
+ const normalized = languageId.toLowerCase();
75
+ if (!/^[a-z0-9-]+$/.test(normalized)) {
76
+ throw new Error(`Invalid language ID: ${languageId}`);
77
+ }
78
+ return normalized;
79
+ }
80
+ function getWasmFileName(languageId) {
81
+ const sanitized = sanitizeLanguageId(languageId).toLowerCase();
82
+ if (LANGUAGE_WASM_MAP[sanitized]) {
83
+ return LANGUAGE_WASM_MAP[sanitized];
84
+ }
85
+ return `tree-sitter-${sanitized}.wasm`;
86
+ }
87
+ function resolveGrammarsDir(thisDir) {
88
+ const normalized = thisDir.replace(/\\/g, "/");
89
+ const isSource = normalized.endsWith("/src/lang");
90
+ const isCliBundle = normalized.endsWith("/cli");
91
+ return isSource ? path.join(thisDir, "grammars") : isCliBundle ? path.join(thisDir, "..", "lang", "grammars") : path.join(thisDir, "lang", "grammars");
92
+ }
93
+ function getGrammarsDirAbsolute() {
94
+ const thisDir = _internals.getModuleDir();
95
+ return resolveGrammarsDir(thisDir);
96
+ }
97
+ async function loadGrammar(languageId) {
98
+ if (typeof languageId !== "string" || languageId.length > 100) {
99
+ throw new Error(`Invalid languageId: must be a string of at most 100 characters`);
100
+ }
101
+ const normalizedId = sanitizeLanguageId(languageId).toLowerCase();
102
+ if (normalizedId.length === 0) {
103
+ throw new Error(`Invalid languageId: empty after sanitization`);
104
+ }
105
+ if (parserCache.has(normalizedId)) {
106
+ return parserCache.get(normalizedId);
107
+ }
108
+ const existing = inflightLoads.get(normalizedId);
109
+ if (existing)
110
+ return existing;
111
+ const loadPromise = (async () => {
112
+ await initTreeSitter();
113
+ const parser = new Parser;
114
+ const wasmFileName = getWasmFileName(normalizedId);
115
+ const wasmPath = path.join(getGrammarsDirAbsolute(), wasmFileName);
116
+ if (!_internals.fileExists(wasmPath)) {
117
+ throw new Error(`Grammar file not found for ${languageId}: ${wasmPath}
118
+ ` + `Make sure to run 'bun run build' to copy grammar files to dist/lang/grammars/. ` + `If this is an installed OpenCode plugin cache, run ` + `'bunx opencode-swarm update' and restart OpenCode.`);
119
+ }
120
+ try {
121
+ const language = await withTimeout(Language.load(wasmPath), GRAMMAR_LOAD_TIMEOUT_MS, new Error(`Timed out after ${GRAMMAR_LOAD_TIMEOUT_MS}ms loading grammar`));
122
+ parser.setLanguage(language);
123
+ } catch (error) {
124
+ throw new Error(`Failed to load grammar for ${languageId}: ${error instanceof Error ? error.message : String(error)}
125
+ ` + `WASM path: ${wasmPath}`);
126
+ }
127
+ parserCache.set(normalizedId, parser);
128
+ initializedLanguages.add(normalizedId);
129
+ return parser;
130
+ })();
131
+ inflightLoads.set(normalizedId, loadPromise);
132
+ try {
133
+ return await loadPromise;
134
+ } finally {
135
+ inflightLoads.delete(normalizedId);
136
+ }
137
+ }
138
+ async function isGrammarAvailable(languageId) {
139
+ if (typeof languageId !== "string" || languageId.length > 100) {
140
+ return false;
141
+ }
142
+ let normalizedId;
143
+ try {
144
+ normalizedId = sanitizeLanguageId(languageId).toLowerCase();
145
+ } catch {
146
+ return false;
147
+ }
148
+ if (normalizedId.length === 0) {
149
+ return false;
150
+ }
151
+ if (parserCache.has(normalizedId)) {
152
+ return true;
153
+ }
154
+ try {
155
+ const wasmFileName = getWasmFileName(normalizedId);
156
+ const wasmPath = path.join(getGrammarsDirAbsolute(), wasmFileName);
157
+ statSync(wasmPath);
158
+ return true;
159
+ } catch {
160
+ return false;
161
+ }
162
+ }
163
+ function clearParserCache() {
164
+ parserCache.clear();
165
+ inflightLoads.clear();
166
+ initializedLanguages.clear();
167
+ treeSitterInitPromise = null;
168
+ }
169
+ function getInitializedLanguages() {
170
+ return Array.from(initializedLanguages);
171
+ }
172
+ function getSupportedLanguages() {
173
+ return Object.keys(LANGUAGE_WASM_MAP);
174
+ }
175
+
176
+ export { parserCache, _internals, resolveGrammarsDir, loadGrammar, isGrammarAvailable, clearParserCache, getInitializedLanguages, getSupportedLanguages };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  atomicWriteFile
4
- } from "./index-erfnw81g.js";
4
+ } from "./index-zswmbm15.js";
5
5
  import {
6
6
  init_logger,
7
7
  warn
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  _internals,
4
4
  resolveWorktreeIsolationConfig
5
- } from "./index-8jrn4rwp.js";
5
+ } from "./index-qj22wyw2.js";
6
6
  import {
7
7
  ApprovalEvidenceSchema,
8
8
  BaseEvidenceSchema,
@@ -42,7 +42,7 @@ import {
42
42
  loadPluginConfig,
43
43
  loadPluginConfigWithMeta,
44
44
  loadPluginConfigWithMetaAsync
45
- } from "./index-rdb3nr6d.js";
45
+ } from "./index-8hkjk37c.js";
46
46
  import {
47
47
  AUTO_REVIEW_V8_BURN_IN_DECISION,
48
48
  AgentOverrideConfigSchema,
@@ -64,7 +64,7 @@ import {
64
64
  TurboConfigSchema,
65
65
  WorktreeIsolationConfigSchema,
66
66
  resolveAutoReviewConfig
67
- } from "./index-j3byg0a9.js";
67
+ } from "./index-1brb14xc.js";
68
68
  import"./index-4rhhvd1a.js";
69
69
  import {
70
70
  ALL_AGENT_NAMES,
@@ -75,7 +75,7 @@ import {
75
75
  QA_AGENTS,
76
76
  isQAAgent,
77
77
  isSubagent
78
- } from "./index-jqsfsqbx.js";
78
+ } from "./index-whezv7vc.js";
79
79
  import"./index-zjygnfay.js";
80
80
  import"./index-bk5tah7q.js";
81
81
  import"./index-bpmtbmy9.js";
@@ -1,9 +1,4 @@
1
1
  // @bun
2
- import {
3
- queryHistoricalOutcomes,
4
- readKnowledgeEvents,
5
- recordKnowledgeEvent
6
- } from "./index-rr2fjfsd.js";
7
2
  import {
8
3
  jaccardBigram,
9
4
  readKnowledge,
@@ -11,7 +6,12 @@ import {
11
6
  resolveSwarmKnowledgePath,
12
7
  transactKnowledge,
13
8
  wordBigrams
14
- } from "./index-c3zag2cw.js";
9
+ } from "./index-xwpmxpb7.js";
10
+ import {
11
+ queryHistoricalOutcomes,
12
+ readKnowledgeEvents,
13
+ recordKnowledgeEvent
14
+ } from "./index-pr8vhj6j.js";
15
15
  import {
16
16
  init_knowledge_types,
17
17
  isActiveStatus
@@ -224,11 +224,11 @@ async function maybeQuarantineOnContradiction(directory, entryId, threshold, win
224
224
  alreadyInactive: true
225
225
  };
226
226
  }
227
- const { quarantineEntry } = await import("./knowledge-validator-0ar015bf.js");
227
+ const { quarantineEntry } = await import("./knowledge-validator-8wh82z0a.js");
228
228
  let policyConfig;
229
229
  try {
230
- const { KnowledgeConfigSchema } = await import("./schema-4ew49zrv.js");
231
- const { loadPluginConfigWithMeta } = await import("./index-8gs34d2q.js");
230
+ const { KnowledgeConfigSchema } = await import("./schema-jdwjcby0.js");
231
+ const { loadPluginConfigWithMeta } = await import("./index-ep14xc5z.js");
232
232
  const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
233
233
  policyConfig = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
234
234
  } catch {