opencode-swarm 7.107.2 → 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 (69) 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-drift-6ad8mxxb.js → curator-drift-ed7p5mfy.js} +2 -2
  8. package/dist/cli/{curator-llm-factory-r3m5e7n8.js → curator-llm-factory-abw56kg0.js} +18 -13
  9. package/dist/cli/{curator-6zvpn7fs.js → curator-rb05fjjk.js} +18 -13
  10. package/dist/cli/{dispatch-e4ejrsz8.js → dispatch-anmxxhen.js} +56 -13
  11. package/dist/cli/{evidence-summary-service-7nwhd8s4.js → evidence-summary-service-nwdfnbz1.js} +4 -4
  12. package/dist/cli/gate-evidence-ywys9vfs.js +1 -1
  13. package/dist/cli/guardrail-explain-dayy7zw4.js +37 -0
  14. package/dist/cli/{guardrail-log-fsc85hwa.js → guardrail-log-fjypsmek.js} +4 -3
  15. package/dist/cli/{hive-promoter-nwcsha2j.js → hive-promoter-34bdmw1w.js} +18 -13
  16. package/dist/cli/{index-r87xhtmx.js → index-19vxtwa6.js} +22 -17
  17. package/dist/cli/{index-t4hbye3v.js → index-4r5z8sgw.js} +4 -4
  18. package/dist/cli/{index-fxtrk7y8.js → index-4vsgp5a8.js} +2 -2
  19. package/dist/cli/{index-mpe0yk9s.js → index-57ymmh7h.js} +5 -3
  20. package/dist/cli/{index-357p0baj.js → index-91j1sqzm.js} +14 -2
  21. package/dist/cli/{index-f12bmedv.js → index-9b7a6agd.js} +91 -34
  22. package/dist/cli/index-bfwt3abw.js +14 -0
  23. package/dist/cli/{index-9wstcavp.js → index-bpgqbwmf.js} +115 -1019
  24. package/dist/cli/index-bq8kd9r9.js +199 -0
  25. package/dist/cli/index-dfdg4ws5.js +741 -0
  26. package/dist/cli/{index-jr54w7pb.js → index-f45hbd5x.js} +2 -2
  27. package/dist/cli/{index-168p3bfr.js → index-gyzxeza3.js} +910 -608
  28. package/dist/cli/index-kxm3bdjh.js +631 -0
  29. package/dist/cli/index-n1sptn1w.js +147 -0
  30. package/dist/cli/{index-2560cctg.js → index-pchpahdf.js} +11 -0
  31. package/dist/cli/{index-esg1554h.js → index-wvxhynxq.js} +1 -1
  32. package/dist/cli/{index-8w4d325g.js → index-xg18az81.js} +61 -22
  33. package/dist/cli/{index-f7nma02k.js → index-xmarctsf.js} +137 -175
  34. package/dist/cli/{index-w8dzxnx4.js → index-zej8cy0j.js} +1 -1
  35. package/dist/cli/index.js +18 -13
  36. package/dist/cli/knowledge-escalator-3sgwrgy9.js +32 -0
  37. package/dist/cli/knowledge-events-kfc6xmkw.js +62 -0
  38. package/dist/cli/{knowledge-store-tsa8ezka.js → knowledge-store-kyacem71.js} +3 -1
  39. package/dist/cli/knowledge-validator-ez3ws8ef.js +57 -0
  40. package/dist/cli/{pending-delegations-46xf2n2e.js → pending-delegations-vfnpm8zt.js} +4 -4
  41. package/dist/cli/{pr-subscriptions-3c34rnm1.js → pr-subscriptions-bpvazmsw.js} +3 -3
  42. package/dist/cli/{schema-vw2ffhe9.js → schema-x0ekqzvs.js} +2 -1
  43. package/dist/cli/{skill-generator-y6mmq8n5.js → skill-generator-x83re96d.js} +6 -2
  44. package/dist/commands/knowledge.d.ts +5 -1
  45. package/dist/commands/registry.d.ts +2 -2
  46. package/dist/config/evidence-schema.d.ts +9 -9
  47. package/dist/config/schema.d.ts +42 -12
  48. package/dist/hooks/guardrails/file-authority.d.ts +1 -1
  49. package/dist/hooks/knowledge-curator.d.ts +27 -0
  50. package/dist/hooks/knowledge-escalator.d.ts +16 -0
  51. package/dist/hooks/knowledge-events.d.ts +11 -0
  52. package/dist/hooks/knowledge-injector.d.ts +3 -0
  53. package/dist/hooks/knowledge-store.d.ts +16 -1
  54. package/dist/hooks/knowledge-types.d.ts +85 -0
  55. package/dist/hooks/knowledge-validator.d.ts +15 -0
  56. package/dist/hooks/semantic-diff-injection.d.ts +19 -0
  57. package/dist/hooks/skill-usage-log.d.ts +3 -0
  58. package/dist/index.js +354 -353
  59. package/dist/memory/consolidation.d.ts +1 -1
  60. package/dist/memory/schema.d.ts +4 -4
  61. package/dist/sast/rules/rust.d.ts +6 -0
  62. package/dist/services/directive-predicate-runner.d.ts +1 -1
  63. package/dist/tools/knowledge-archive.d.ts +6 -2
  64. package/dist/tools/knowledge-remove.d.ts +11 -0
  65. package/dist/tools/lint.d.ts +2 -2
  66. package/dist/tools/secretscan.d.ts +16 -0
  67. package/dist/tools/test-runner.d.ts +1 -1
  68. package/package.json +1 -1
  69. package/dist/cli/guardrail-explain-zajegz3a.js +0 -32
@@ -294,7 +294,15 @@ function renderRequirement(req, used, warnings, reserved) {
294
294
  function detectSpeckit(directory) {
295
295
  const root = path.resolve(directory);
296
296
  const markerPath = path.join(root, SPECKIT_MARKER);
297
- const markerPresent = fs.statSync(markerPath, { throwIfNoEntry: false })?.isDirectory() ?? false;
297
+ let markerPresent = false;
298
+ try {
299
+ markerPresent = fs.statSync(markerPath, { throwIfNoEntry: false })?.isDirectory() ?? false;
300
+ } catch (error) {
301
+ const code = error.code;
302
+ if (code !== "ENOENT" && code !== "ENOTDIR" && code !== "EACCES" && code !== "EPERM" && code !== "EUNKNOWN") {
303
+ throw error;
304
+ }
305
+ }
298
306
  if (!markerPresent) {
299
307
  return { markerPresent: false, features: [] };
300
308
  }
@@ -592,6 +600,9 @@ function buildOpenSpecProjectionSync(directory, options = {}) {
592
600
  };
593
601
  }
594
602
  function readEffectiveSpecSync(directory, opts) {
603
+ if (directory.includes("\x00")) {
604
+ return null;
605
+ }
595
606
  const root = path.resolve(directory);
596
607
  const swSpecPath = path.join(root, SWARM_SPEC_REL);
597
608
  try {
@@ -608,7 +619,8 @@ function readEffectiveSpecSync(directory, opts) {
608
619
  };
609
620
  }
610
621
  } catch (error) {
611
- if (error.code !== "ENOENT") {
622
+ const code = error.code;
623
+ if (code !== "ENOENT" && code !== "ENOTDIR" && code !== "EACCES" && code !== "EPERM" && code !== "EUNKNOWN") {
612
624
  throw error;
613
625
  }
614
626
  }
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  readEffectiveSpecSync
4
- } from "./index-357p0baj.js";
4
+ } from "./index-91j1sqzm.js";
5
5
  import {
6
6
  isValidTaskId,
7
7
  readTaskEvidence,
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  readSwarmFileAsync,
13
13
  validateSwarmPath
14
- } from "./index-mpe0yk9s.js";
14
+ } from "./index-57ymmh7h.js";
15
15
  import {
16
16
  readCachedParsedFile
17
17
  } from "./index-jtqkh8jf.js";
@@ -21,13 +21,13 @@ import {
21
21
  init_logger,
22
22
  warn
23
23
  } from "./index-zgwm4ryv.js";
24
- import {
25
- withEvidenceLock
26
- } from "./index-3naa2ajc.js";
27
24
  import {
28
25
  ZodError,
29
26
  exports_external
30
27
  } from "./index-293f68mj.js";
28
+ import {
29
+ withEvidenceLock
30
+ } from "./index-3naa2ajc.js";
31
31
  import {
32
32
  bunHash,
33
33
  bunWrite
@@ -1740,6 +1740,49 @@ var CAS_BACKOFF_START_MS = 5;
1740
1740
  var CAS_BACKOFF_CAP_MS = 250;
1741
1741
  var CAS_BACKOFF_JITTER = 0.25;
1742
1742
  var CAS_MAX_RETRIES = 3;
1743
+ function derivePhaseStatusesInPlace(plan) {
1744
+ for (const phase of plan.phases) {
1745
+ const tasks = phase.tasks;
1746
+ if (tasks.length > 0 && tasks.every((t) => t.status === "completed")) {
1747
+ phase.status = "complete";
1748
+ } else if (tasks.some((t) => t.status === "in_progress")) {
1749
+ phase.status = "in_progress";
1750
+ } else if (tasks.some((t) => t.status === "blocked")) {
1751
+ phase.status = "blocked";
1752
+ } else {
1753
+ phase.status = "pending";
1754
+ }
1755
+ }
1756
+ }
1757
+ function overlayLedgerStatuses(validated, replayed, ledgerStatusTaskIds) {
1758
+ const projected = structuredClone(validated);
1759
+ const statusByTaskId = new Map;
1760
+ for (const phase of replayed.phases) {
1761
+ for (const task of phase.tasks) {
1762
+ if (ledgerStatusTaskIds.has(task.id)) {
1763
+ statusByTaskId.set(task.id, task.status);
1764
+ }
1765
+ }
1766
+ }
1767
+ for (const phase of projected.phases) {
1768
+ for (const task of phase.tasks) {
1769
+ const replayedStatus = statusByTaskId.get(task.id);
1770
+ if (replayedStatus)
1771
+ task.status = replayedStatus;
1772
+ }
1773
+ }
1774
+ derivePhaseStatusesInPlace(projected);
1775
+ return projected;
1776
+ }
1777
+ function collectLedgerStatusTaskIds(events) {
1778
+ const statusTaskIds = new Set;
1779
+ for (const event of events) {
1780
+ if (event.event_type === "task_status_changed" && typeof event.task_id === "string") {
1781
+ statusTaskIds.add(event.task_id);
1782
+ }
1783
+ }
1784
+ return statusTaskIds;
1785
+ }
1743
1786
  async function retryCasWithBackoff(directory, eventInput, options) {
1744
1787
  const maxRetries = options.maxRetries ?? CAS_MAX_RETRIES;
1745
1788
  let currentExpected = options.expectedHash;
@@ -2182,18 +2225,7 @@ async function savePlan(directory, plan, options) {
2182
2225
  }
2183
2226
  } catch {}
2184
2227
  }
2185
- for (const phase of validated.phases) {
2186
- const tasks = phase.tasks;
2187
- if (tasks.length > 0 && tasks.every((t) => t.status === "completed")) {
2188
- phase.status = "complete";
2189
- } else if (tasks.some((t) => t.status === "in_progress")) {
2190
- phase.status = "in_progress";
2191
- } else if (tasks.some((t) => t.status === "blocked")) {
2192
- phase.status = "blocked";
2193
- } else {
2194
- phase.status = "pending";
2195
- }
2196
- }
2228
+ derivePhaseStatusesInPlace(validated);
2197
2229
  const currentPlan = await _internals4.loadPlanJsonOnly(directory);
2198
2230
  const planId = derivePlanId(validated);
2199
2231
  const planHashForInit = computePlanHash(validated);
@@ -2399,7 +2431,16 @@ async function savePlan(directory, plan, options) {
2399
2431
  throw error2;
2400
2432
  }
2401
2433
  }
2402
- const projectedPlan = await replayFromLedger(directory) ?? validated;
2434
+ const ledgerStatusTaskIds = collectLedgerStatusTaskIds(await readLedgerEvents(directory));
2435
+ const replayedBeforeProjection = await replayFromLedger(directory);
2436
+ const projectionCandidate = replayedBeforeProjection ? overlayLedgerStatuses(validated, replayedBeforeProjection, ledgerStatusTaskIds) : validated;
2437
+ if (replayedBeforeProjection && computePlanHash(replayedBeforeProjection) !== computePlanHash(projectionCandidate)) {
2438
+ await takeSnapshotEvent(directory, projectionCandidate, {
2439
+ planHashAfter: computePlanHash(projectionCandidate),
2440
+ source: "savePlan_structural_projection"
2441
+ });
2442
+ }
2443
+ const projectedPlan = await replayFromLedger(directory) ?? projectionCandidate;
2403
2444
  const SNAPSHOT_INTERVAL = 50;
2404
2445
  const latestSeq = await getLatestLedgerSeq(directory);
2405
2446
  if (latestSeq > 0 && latestSeq % SNAPSHOT_INTERVAL === 0) {
@@ -2881,6 +2922,7 @@ import {
2881
2922
  statSync as statSync2
2882
2923
  } from "fs";
2883
2924
  import * as fs5 from "fs/promises";
2925
+ import * as os from "os";
2884
2926
  import * as path6 from "path";
2885
2927
 
2886
2928
  // src/config/evidence-schema.ts
@@ -3199,6 +3241,30 @@ var PROJECT_INDICATORS = [
3199
3241
  "build.gradle",
3200
3242
  "CMakeLists.txt"
3201
3243
  ];
3244
+ function isWeakConfigContainerRoot(directory) {
3245
+ try {
3246
+ const resolved = realpathSync(directory);
3247
+ return resolved === realpathSync(os.tmpdir()) || resolved === realpathSync(os.homedir());
3248
+ } catch {
3249
+ const resolved = path6.resolve(directory);
3250
+ return resolved === path6.resolve(os.tmpdir()) || resolved === path6.resolve(os.homedir());
3251
+ }
3252
+ }
3253
+ function hasAccessibleProjectIndicator(directory, options = {}) {
3254
+ const allowConfigOnly = options.allowConfigOnly ?? true;
3255
+ for (const indicator of PROJECT_INDICATORS) {
3256
+ if (!allowConfigOnly && indicator === ".opencode") {
3257
+ continue;
3258
+ }
3259
+ try {
3260
+ const indicatorStat = statSync2(path6.join(directory, indicator));
3261
+ if (indicatorStat.isFile() || indicatorStat.isDirectory()) {
3262
+ return true;
3263
+ }
3264
+ } catch {}
3265
+ }
3266
+ return false;
3267
+ }
3202
3268
  function validateProjectRoot(directory) {
3203
3269
  let resolved;
3204
3270
  try {
@@ -3216,25 +3282,16 @@ function validateProjectRoot(directory) {
3216
3282
  const parent = path6.dirname(current);
3217
3283
  if (parent === current)
3218
3284
  break;
3285
+ if (path6.dirname(parent) === parent) {
3286
+ current = parent;
3287
+ continue;
3288
+ }
3219
3289
  const parentSwarm = path6.join(parent, ".swarm");
3220
3290
  try {
3221
3291
  if (statSync2(parentSwarm).isDirectory()) {
3222
- let hasProjectIndicator = false;
3223
- for (const indicator of PROJECT_INDICATORS) {
3224
- try {
3225
- const indicatorStat = statSync2(path6.join(parent, indicator));
3226
- if (indicatorStat.isFile() || indicatorStat.isDirectory()) {
3227
- hasProjectIndicator = true;
3228
- break;
3229
- }
3230
- } catch (error2) {
3231
- if (error2 instanceof Error && "code" in error2 && error2.code === "ENOENT") {} else {
3232
- hasProjectIndicator = true;
3233
- break;
3234
- }
3235
- }
3236
- }
3237
- if (hasProjectIndicator) {
3292
+ if (hasAccessibleProjectIndicator(parent, {
3293
+ allowConfigOnly: !isWeakConfigContainerRoot(parent)
3294
+ })) {
3238
3295
  warn(`[evidence] Rejecting write to subdirectory "${resolved}" \u2014 parent "${parent}" already contains .swarm/`);
3239
3296
  throw new Error(`Cannot write evidence in "${resolved}" \u2014 parent directory "${parent}" already contains a .swarm/ folder. Evidence must be written to the project root.`);
3240
3297
  }
@@ -0,0 +1,14 @@
1
+ // @bun
2
+ // src/hooks/knowledge-types.ts
3
+ var KNOWLEDGE_SCHEMA_VERSION = 2;
4
+ var INACTIVE_STATUSES = new Set([
5
+ "archived",
6
+ "quarantined",
7
+ "quarantined_unactionable"
8
+ ]);
9
+ var OUTCOME_BLOCK_THRESHOLD = -0.3;
10
+ function isActiveStatus(status) {
11
+ return !INACTIVE_STATUSES.has(status ?? "");
12
+ }
13
+
14
+ export { KNOWLEDGE_SCHEMA_VERSION, OUTCOME_BLOCK_THRESHOLD, isActiveStatus };