opencode-swarm 7.107.3 → 7.107.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.
Files changed (61) hide show
  1. package/.opencode/skills/consult/SKILL.md +10 -0
  2. package/.opencode/skills/council/SKILL.md +10 -0
  3. package/.opencode/skills/engineering-conventions/SKILL.md +20 -0
  4. package/README.md +2 -2
  5. package/dist/agents/agent-output-schema.d.ts +1 -1
  6. package/dist/cli/{config-doctor-cntnpyvj.js → config-doctor-kdq3vae4.js} +3 -2
  7. package/dist/cli/{curator-llm-factory-x9tk7e6m.js → curator-llm-factory-abw56kg0.js} +16 -11
  8. package/dist/cli/{curator-1nr4qszq.js → curator-rb05fjjk.js} +16 -11
  9. package/dist/cli/{dispatch-e4ejrsz8.js → dispatch-anmxxhen.js} +56 -13
  10. package/dist/cli/{evidence-summary-service-9r28ds8t.js → evidence-summary-service-nwdfnbz1.js} +2 -2
  11. package/dist/cli/gate-evidence-ywys9vfs.js +1 -1
  12. package/dist/cli/{guardrail-explain-etdrhd4d.js → guardrail-explain-dayy7zw4.js} +17 -12
  13. package/dist/cli/{guardrail-log-2rns4g6d.js → guardrail-log-fjypsmek.js} +4 -3
  14. package/dist/cli/{hive-promoter-j4e6rfa6.js → hive-promoter-34bdmw1w.js} +16 -11
  15. package/dist/cli/{index-502f6np6.js → index-19vxtwa6.js} +21 -16
  16. package/dist/cli/{index-tgtmbf3r.js → index-4vsgp5a8.js} +1 -1
  17. package/dist/cli/index-bfwt3abw.js +14 -0
  18. package/dist/cli/{index-9wstcavp.js → index-bpgqbwmf.js} +115 -1019
  19. package/dist/cli/index-bq8kd9r9.js +199 -0
  20. package/dist/cli/index-dfdg4ws5.js +741 -0
  21. package/dist/cli/{index-w15984gg.js → index-f45hbd5x.js} +2 -2
  22. package/dist/cli/{index-cyzzdbvw.js → index-gyzxeza3.js} +354 -116
  23. package/dist/cli/index-kxm3bdjh.js +631 -0
  24. package/dist/cli/index-n1sptn1w.js +147 -0
  25. package/dist/cli/{index-2560cctg.js → index-pchpahdf.js} +11 -0
  26. package/dist/cli/{index-esg1554h.js → index-wvxhynxq.js} +1 -1
  27. package/dist/cli/{index-8w4d325g.js → index-xg18az81.js} +61 -22
  28. package/dist/cli/{index-f7nma02k.js → index-xmarctsf.js} +137 -175
  29. package/dist/cli/{index-m1xjr58n.js → index-zej8cy0j.js} +1 -1
  30. package/dist/cli/index.js +17 -12
  31. package/dist/cli/knowledge-escalator-3sgwrgy9.js +32 -0
  32. package/dist/cli/knowledge-events-kfc6xmkw.js +62 -0
  33. package/dist/cli/{knowledge-store-tsa8ezka.js → knowledge-store-kyacem71.js} +3 -1
  34. package/dist/cli/knowledge-validator-ez3ws8ef.js +57 -0
  35. package/dist/cli/{pr-subscriptions-0dpn4epk.js → pr-subscriptions-bpvazmsw.js} +2 -2
  36. package/dist/cli/{schema-vw2ffhe9.js → schema-x0ekqzvs.js} +2 -1
  37. package/dist/cli/{skill-generator-y6mmq8n5.js → skill-generator-x83re96d.js} +6 -2
  38. package/dist/commands/knowledge.d.ts +5 -1
  39. package/dist/commands/registry.d.ts +2 -2
  40. package/dist/config/evidence-schema.d.ts +9 -9
  41. package/dist/config/schema.d.ts +42 -12
  42. package/dist/hooks/knowledge-curator.d.ts +27 -0
  43. package/dist/hooks/knowledge-escalator.d.ts +16 -0
  44. package/dist/hooks/knowledge-events.d.ts +11 -0
  45. package/dist/hooks/knowledge-reader.d.ts +0 -17
  46. package/dist/hooks/knowledge-store.d.ts +16 -1
  47. package/dist/hooks/knowledge-types.d.ts +85 -0
  48. package/dist/hooks/knowledge-validator.d.ts +15 -0
  49. package/dist/hooks/skill-usage-log.d.ts +3 -0
  50. package/dist/index.js +307 -305
  51. package/dist/memory/consolidation.d.ts +1 -1
  52. package/dist/memory/schema.d.ts +4 -4
  53. package/dist/sast/rules/rust.d.ts +6 -0
  54. package/dist/tools/knowledge-archive.d.ts +6 -2
  55. package/dist/tools/lint.d.ts +2 -2
  56. package/dist/tools/secretscan.d.ts +16 -0
  57. package/dist/tools/test-runner.d.ts +1 -1
  58. package/package.json +1 -1
  59. package/dist/cli/{index-hkpw4wwa.js → index-4r5z8sgw.js} +3 -3
  60. package/dist/cli/{index-kzfkggjx.js → index-9b7a6agd.js} +3 -3
  61. package/dist/cli/{pending-delegations-ws51m1e1.js → pending-delegations-vfnpm8zt.js} +3 -3
@@ -0,0 +1,147 @@
1
+ // @bun
2
+ import {
3
+ atomicWriteFile
4
+ } from "./index-9b7qp18e.js";
5
+
6
+ // src/hooks/knowledge-link.ts
7
+ import { existsSync, mkdirSync, readFileSync, rmSync } from "fs";
8
+ import * as os from "os";
9
+ import * as path from "path";
10
+ var LINK_POINTER_FILENAME = "link.json";
11
+ var MAX_LINK_ID_LENGTH = 64;
12
+ var WINDOWS_RESERVED_NAMES = new Set([
13
+ "con",
14
+ "prn",
15
+ "aux",
16
+ "nul",
17
+ "com0",
18
+ "com1",
19
+ "com2",
20
+ "com3",
21
+ "com4",
22
+ "com5",
23
+ "com6",
24
+ "com7",
25
+ "com8",
26
+ "com9",
27
+ "lpt0",
28
+ "lpt1",
29
+ "lpt2",
30
+ "lpt3",
31
+ "lpt4",
32
+ "lpt5",
33
+ "lpt6",
34
+ "lpt7",
35
+ "lpt8",
36
+ "lpt9"
37
+ ]);
38
+ var CACHE_TTL_MS = 2000;
39
+ var MAX_CACHE_ENTRIES = 500;
40
+ function resolveDataDir() {
41
+ const platform = process.platform;
42
+ const home = process.env.HOME || os.homedir();
43
+ if (platform === "win32") {
44
+ return path.join(process.env.LOCALAPPDATA || path.join(home, "AppData", "Local"), "opencode-swarm", "Data");
45
+ } else if (platform === "darwin") {
46
+ return path.join(home, "Library", "Application Support", "opencode-swarm");
47
+ }
48
+ return path.join(process.env.XDG_DATA_HOME || path.join(home, ".local", "share"), "opencode-swarm");
49
+ }
50
+ function resolveLinkBaseDir() {
51
+ return path.join(resolveDataDir(), "links");
52
+ }
53
+ function resolveLinkDir(linkId) {
54
+ return path.join(resolveLinkBaseDir(), linkId);
55
+ }
56
+ function sanitizeLinkId(name) {
57
+ if (typeof name !== "string")
58
+ return null;
59
+ const cleaned = name.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^[-.]+|[-.]+$/g, "").slice(0, MAX_LINK_ID_LENGTH).replace(/[-.]+$/g, "");
60
+ if (cleaned.length === 0)
61
+ return null;
62
+ const base = cleaned.split(".")[0];
63
+ if (WINDOWS_RESERVED_NAMES.has(base))
64
+ return null;
65
+ return cleaned;
66
+ }
67
+ function resolveLinkPointerPath(directory) {
68
+ return path.join(directory, ".swarm", LINK_POINTER_FILENAME);
69
+ }
70
+ function readLinkPointer(directory) {
71
+ const pointerPath = resolveLinkPointerPath(directory);
72
+ if (!existsSync(pointerPath))
73
+ return null;
74
+ try {
75
+ const raw = JSON.parse(readFileSync(pointerPath, "utf-8"));
76
+ if (!raw || typeof raw !== "object")
77
+ return null;
78
+ const obj = raw;
79
+ const linkId = obj.linkId;
80
+ if (typeof linkId !== "string" || linkId.length === 0)
81
+ return null;
82
+ const safeId = sanitizeLinkId(linkId);
83
+ if (!safeId)
84
+ return null;
85
+ return {
86
+ version: 1,
87
+ linkId: safeId,
88
+ name: typeof obj.name === "string" ? obj.name : undefined,
89
+ createdAt: typeof obj.createdAt === "string" ? obj.createdAt : new Date(0).toISOString(),
90
+ source: obj.source === "auto" ? "auto" : "manual"
91
+ };
92
+ } catch {
93
+ return null;
94
+ }
95
+ }
96
+ async function writeLinkPointer(directory, pointer) {
97
+ const swarmDir = path.join(directory, ".swarm");
98
+ mkdirSync(swarmDir, { recursive: true });
99
+ const pointerPath = resolveLinkPointerPath(directory);
100
+ await atomicWriteFile(pointerPath, JSON.stringify(pointer, null, 2));
101
+ invalidateKnowledgeStoreDirCache(directory);
102
+ }
103
+ async function removeLinkPointer(directory) {
104
+ const pointerPath = resolveLinkPointerPath(directory);
105
+ try {
106
+ rmSync(pointerPath, { force: true });
107
+ } finally {
108
+ invalidateKnowledgeStoreDirCache(directory);
109
+ }
110
+ }
111
+ var _resolutionCache = new Map;
112
+ function resolveKnowledgeStoreDir(directory) {
113
+ const localSwarm = path.join(directory, ".swarm");
114
+ const now = Date.now();
115
+ const cached = _resolutionCache.get(directory);
116
+ if (cached && now < cached.expires) {
117
+ return cached.linkDir ?? localSwarm;
118
+ }
119
+ let linkDir = null;
120
+ try {
121
+ const pointer = readLinkPointer(directory);
122
+ if (pointer) {
123
+ linkDir = path.resolve(resolveLinkDir(pointer.linkId));
124
+ }
125
+ } catch {
126
+ linkDir = null;
127
+ }
128
+ if (!_resolutionCache.has(directory) && _resolutionCache.size >= MAX_CACHE_ENTRIES) {
129
+ const oldest = _resolutionCache.keys().next().value;
130
+ if (oldest !== undefined)
131
+ _resolutionCache.delete(oldest);
132
+ }
133
+ _resolutionCache.set(directory, { linkDir, expires: now + CACHE_TTL_MS });
134
+ return linkDir ?? localSwarm;
135
+ }
136
+ function invalidateKnowledgeStoreDirCache(directory) {
137
+ if (directory === undefined) {
138
+ _resolutionCache.clear();
139
+ return;
140
+ }
141
+ _resolutionCache.delete(directory);
142
+ }
143
+ function isLinked(directory) {
144
+ return readLinkPointer(directory) !== null;
145
+ }
146
+
147
+ export { resolveLinkDir, sanitizeLinkId, readLinkPointer, writeLinkPointer, removeLinkPointer, resolveKnowledgeStoreDir, isLinked };
@@ -1,4 +1,7 @@
1
1
  // @bun
2
+ import {
3
+ OUTCOME_BLOCK_THRESHOLD
4
+ } from "./index-bfwt3abw.js";
2
5
  import {
3
6
  exports_external
4
7
  } from "./index-293f68mj.js";
@@ -1509,6 +1512,14 @@ var KnowledgeConfigSchema = exports_external.object({
1509
1512
  default_max_phases: exports_external.number().int().positive().default(10),
1510
1513
  todo_max_phases: exports_external.number().int().positive().default(3),
1511
1514
  sweep_enabled: exports_external.boolean().default(true),
1515
+ confidence_floor_action: exports_external.enum(["none", "demote", "quarantine"]).default("demote"),
1516
+ confidence_floor_min_outcomes: exports_external.number().int().min(0).default(3),
1517
+ confidence_floor_signal_threshold: exports_external.number().min(-1).max(1).default(0),
1518
+ contradiction_threshold_action: exports_external.enum(["tag_only", "quarantine"]).default("quarantine"),
1519
+ contradiction_quarantine_threshold: exports_external.number().int().positive().default(3),
1520
+ contradiction_quarantine_window_days: exports_external.number().int().positive().default(30),
1521
+ promoted_demotion_min_negative_phases: exports_external.number().int().positive().default(3),
1522
+ promoted_demotion_signal_threshold: exports_external.number().min(-1).max(1).default(OUTCOME_BLOCK_THRESHOLD),
1512
1523
  realtime_learning_nudge: exports_external.object({
1513
1524
  enabled: exports_external.boolean().default(true),
1514
1525
  first_after_tool_calls: exports_external.number().int().min(1).max(1000).default(10),
@@ -3,7 +3,7 @@ import {
3
3
  ALL_AGENT_NAMES,
4
4
  PluginConfigSchema,
5
5
  stripKnownSwarmPrefix
6
- } from "./index-2560cctg.js";
6
+ } from "./index-pchpahdf.js";
7
7
  import {
8
8
  log
9
9
  } from "./index-zgwm4ryv.js";
@@ -487,7 +487,7 @@ LANGUAGE_REGISTRY.register({
487
487
  command: "govulncheck -json ./...",
488
488
  outputFormat: "json"
489
489
  },
490
- sast: { nativeRuleSet: null, semgrepSupport: "ga" },
490
+ sast: { nativeRuleSet: "go", semgrepSupport: "ga" },
491
491
  prompts: {
492
492
  coderConstraints: [
493
493
  "Always check and return errors; never discard error return values",
@@ -13559,9 +13559,9 @@ var ECOSYSTEMS = [
13559
13559
  buildFiles: ["package.json"],
13560
13560
  toolchainCommands: ["npm", "yarn", "pnpm"],
13561
13561
  commands: [
13562
- { command: "npm run build", priority: 1 },
13563
- { command: "npm run typecheck", priority: 2 },
13564
- { command: "npm run check", priority: 3 }
13562
+ { command: "npm run build", priority: 30 },
13563
+ { command: "npm run typecheck", priority: 20 },
13564
+ { command: "npm run check", priority: 10 }
13565
13565
  ],
13566
13566
  repoDefinedScripts: ["build", "typecheck", "check", "compile"]
13567
13567
  },
@@ -13570,30 +13570,30 @@ var ECOSYSTEMS = [
13570
13570
  buildFiles: ["Cargo.toml"],
13571
13571
  toolchainCommands: ["cargo"],
13572
13572
  commands: [
13573
- { command: "cargo build", priority: 1 },
13574
- { command: "cargo check", priority: 2 }
13573
+ { command: "cargo build", priority: 20 },
13574
+ { command: "cargo check", priority: 10 }
13575
13575
  ]
13576
13576
  },
13577
13577
  {
13578
13578
  ecosystem: "go",
13579
13579
  buildFiles: ["go.mod"],
13580
13580
  toolchainCommands: ["go"],
13581
- commands: [{ command: "go build ./...", priority: 1 }]
13581
+ commands: [{ command: "go build ./...", priority: 10 }]
13582
13582
  },
13583
13583
  {
13584
13584
  ecosystem: "python",
13585
13585
  buildFiles: ["pyproject.toml", "setup.py", "setup.cfg"],
13586
13586
  toolchainCommands: ["python", "python3", "py"],
13587
13587
  commands: [
13588
- { command: "python -m py_compile", priority: 1 },
13589
- { command: "python -m build", priority: 2 }
13588
+ { command: "python -m build", priority: 20 },
13589
+ { command: "python -m py_compile", priority: 10 }
13590
13590
  ]
13591
13591
  },
13592
13592
  {
13593
13593
  ecosystem: "java-maven",
13594
13594
  buildFiles: ["pom.xml"],
13595
13595
  toolchainCommands: ["mvn"],
13596
- commands: [{ command: "mvn compile", priority: 1 }]
13596
+ commands: [{ command: "mvn compile", priority: 10 }]
13597
13597
  },
13598
13598
  {
13599
13599
  ecosystem: "java-gradle",
@@ -13602,30 +13602,30 @@ var ECOSYSTEMS = [
13602
13602
  commands: [
13603
13603
  {
13604
13604
  command: process.platform === "win32" ? "gradlew.bat build" : "./gradlew build",
13605
- priority: 1
13605
+ priority: 20
13606
13606
  },
13607
- { command: "gradle build", priority: 2 }
13607
+ { command: "gradle build", priority: 10 }
13608
13608
  ]
13609
13609
  },
13610
13610
  {
13611
13611
  ecosystem: "dotnet",
13612
13612
  buildFiles: ["*.csproj", "*.fsproj", "*.vbproj"],
13613
13613
  toolchainCommands: ["dotnet"],
13614
- commands: [{ command: "dotnet build", priority: 1 }]
13614
+ commands: [{ command: "dotnet build", priority: 10 }]
13615
13615
  },
13616
13616
  {
13617
13617
  ecosystem: "swift",
13618
13618
  buildFiles: ["Package.swift"],
13619
13619
  toolchainCommands: ["swift"],
13620
- commands: [{ command: "swift build", priority: 1 }]
13620
+ commands: [{ command: "swift build", priority: 10 }]
13621
13621
  },
13622
13622
  {
13623
13623
  ecosystem: "dart",
13624
13624
  buildFiles: ["pubspec.yaml", "pubspec.lock"],
13625
13625
  toolchainCommands: ["dart", "flutter"],
13626
13626
  commands: [
13627
- { command: "dart analyze", priority: 1 },
13628
- { command: "dart compile", priority: 2 }
13627
+ { command: "dart compile", priority: 20 },
13628
+ { command: "dart analyze", priority: 10 }
13629
13629
  ]
13630
13630
  },
13631
13631
  {
@@ -13633,8 +13633,8 @@ var ECOSYSTEMS = [
13633
13633
  buildFiles: ["Makefile", "CMakeLists.txt"],
13634
13634
  toolchainCommands: ["make", "cmake"],
13635
13635
  commands: [
13636
- { command: "make", priority: 1 },
13637
- { command: "cmake -B build && cmake --build build", priority: 2 }
13636
+ { command: "make", priority: 20 },
13637
+ { command: "cmake -B build && cmake --build build", priority: 10 }
13638
13638
  ]
13639
13639
  },
13640
13640
  {
@@ -13644,7 +13644,7 @@ var ECOSYSTEMS = [
13644
13644
  commands: [
13645
13645
  {
13646
13646
  command: "composer install --no-interaction --prefer-dist",
13647
- priority: 1
13647
+ priority: 10
13648
13648
  }
13649
13649
  ]
13650
13650
  }
@@ -13727,7 +13727,7 @@ function getRepoDefinedScripts(workingDir, scripts) {
13727
13727
  if (pkg.scripts[scriptName]) {
13728
13728
  found.push({
13729
13729
  script: `npm run ${scriptName}`,
13730
- priority: 0
13730
+ priority: 100
13731
13731
  });
13732
13732
  }
13733
13733
  }
@@ -13793,7 +13793,7 @@ async function discoverBuildCommandsFromProfiles(workingDir) {
13793
13793
  warn(`[build-discovery] profile ${profile.id} not found in registry, skipping`);
13794
13794
  continue;
13795
13795
  }
13796
- const sortedCommands = [...fullProfile.build.commands].sort((a, b) => a.priority - b.priority);
13796
+ const sortedCommands = [...fullProfile.build.commands].sort((a, b) => b.priority - a.priority);
13797
13797
  let foundCommand = false;
13798
13798
  for (const cmd of sortedCommands) {
13799
13799
  if (cmd.detectFile) {
@@ -13884,7 +13884,7 @@ async function discoverBuildCommands(workingDir, options) {
13884
13884
  });
13885
13885
  }
13886
13886
  }
13887
- commands.sort((a, b) => a.priority - b.priority);
13887
+ commands.sort((a, b) => b.priority - a.priority);
13888
13888
  return { commands, skipped };
13889
13889
  }
13890
13890
  function clearToolchainCache() {
@@ -14104,6 +14104,24 @@ function defaultBuildTestCommand(profile, framework, files, dir = ".", opts = {}
14104
14104
  "-e",
14105
14105
  'Dir.glob("test/**/*_test.rb").sort.each { |f| require_relative f }'
14106
14106
  ];
14107
+ case "pest": {
14108
+ const args = [phpVendorBin("pest")];
14109
+ if (scope !== "all" && files.length > 0)
14110
+ args.push(...files);
14111
+ return args;
14112
+ }
14113
+ case "phpunit": {
14114
+ const args = [phpVendorBin("phpunit")];
14115
+ if (scope !== "all" && files.length > 0)
14116
+ args.push(...files);
14117
+ return args;
14118
+ }
14119
+ case "php-artisan": {
14120
+ const args = ["php", "artisan", "test"];
14121
+ if (scope !== "all" && files.length > 0)
14122
+ args.push(...files);
14123
+ return args;
14124
+ }
14107
14125
  default: {
14108
14126
  const fw = profile.test.frameworks.find((f) => f.name === framework);
14109
14127
  if (!fw)
@@ -14117,6 +14135,9 @@ function defaultBuildTestCommand(profile, framework, files, dir = ".", opts = {}
14117
14135
  }
14118
14136
  }
14119
14137
  }
14138
+ function phpVendorBin(name) {
14139
+ return path2.join("vendor", "bin", process.platform === "win32" ? `${name}.bat` : name);
14140
+ }
14120
14141
  function defaultParseTestOutput(framework, stdout, stderr, exitCode) {
14121
14142
  const output = stdout && stderr ? `${stdout}
14122
14143
  ${stderr}` : stdout || stderr || "";
@@ -14325,6 +14346,24 @@ ${stderr}` : stdout || stderr || "";
14325
14346
  }
14326
14347
  break;
14327
14348
  }
14349
+ case "pest":
14350
+ case "phpunit":
14351
+ case "php-artisan": {
14352
+ const phpunitMatch = output.match(/Tests:\s*(\d+),\s*Assertions:\s*\d+(?:,\s*Failures:\s*(\d+))?(?:,\s*Errors:\s*(\d+))?(?:,\s*Skipped:\s*(\d+))?/);
14353
+ const okMatch = output.match(/OK\s*\((\d+)\s+tests?/);
14354
+ if (phpunitMatch) {
14355
+ total = parseInt(phpunitMatch[1], 10);
14356
+ const failures = phpunitMatch[2] ? parseInt(phpunitMatch[2], 10) : 0;
14357
+ const errors3 = phpunitMatch[3] ? parseInt(phpunitMatch[3], 10) : 0;
14358
+ skipped = phpunitMatch[4] ? parseInt(phpunitMatch[4], 10) : 0;
14359
+ failed = failures + errors3;
14360
+ passed = total - failed - skipped;
14361
+ } else if (okMatch) {
14362
+ total = parseInt(okMatch[1], 10);
14363
+ passed = total;
14364
+ }
14365
+ break;
14366
+ }
14328
14367
  default:
14329
14368
  break;
14330
14369
  }