opencode-swarm 7.88.3 → 7.88.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 (39) hide show
  1. package/dist/agents/agent-output-schema.d.ts +1 -1
  2. package/dist/agents/curator-agent.d.ts +1 -1
  3. package/dist/agents/explorer.d.ts +1 -0
  4. package/dist/cli/{config-doctor-jzbgpbdh.js → config-doctor-g04wdz19.js} +2 -2
  5. package/dist/cli/{explorer-gz70sm9b.js → explorer-h2fnj343.js} +4 -2
  6. package/dist/cli/{guardrail-explain-eqypvw60.js → guardrail-explain-xe0wjnxz.js} +7 -7
  7. package/dist/cli/{guardrail-log-c7egm5km.js → guardrail-log-m3285thy.js} +3 -3
  8. package/dist/cli/{index-0asbrmdx.js → index-123s7kjc.js} +88 -2
  9. package/dist/cli/{index-0rt5aamg.js → index-5p1gvn98.js} +8 -8
  10. package/dist/cli/{index-g00qm2gf.js → index-6tnmt41c.js} +1 -1
  11. package/dist/cli/{index-yhsmmv2z.js → index-bm4f0nme.js} +25 -1
  12. package/dist/cli/{index-819xp49y.js → index-bywt2171.js} +1 -1
  13. package/dist/cli/{index-ds057q5k.js → index-d4hpgf63.js} +2 -2
  14. package/dist/cli/{index-vjsr9bqt.js → index-gg589mfw.js} +1 -1
  15. package/dist/cli/{index-g6f4tt38.js → index-hs2knbfq.js} +520 -375
  16. package/dist/cli/{index-32axfg6h.js → index-rh53rrpt.js} +82 -12
  17. package/dist/cli/index.js +6 -6
  18. package/dist/cli/{schema-vb6jkxgg.js → schema-t9th7frq.js} +1 -1
  19. package/dist/cli/{skill-generator-kz4q8e49.js → skill-generator-s0spm65v.js} +1 -1
  20. package/dist/commands/memory.d.ts +1 -0
  21. package/dist/commands/registry.d.ts +8 -0
  22. package/dist/config/agent-names.d.ts +2 -2
  23. package/dist/config/schema.d.ts +60 -0
  24. package/dist/hooks/curator-llm-factory.d.ts +1 -1
  25. package/dist/index.js +1971 -1077
  26. package/dist/memory/config.d.ts +35 -0
  27. package/dist/memory/consolidation-log.d.ts +29 -0
  28. package/dist/memory/consolidation.d.ts +124 -0
  29. package/dist/memory/decay.d.ts +24 -0
  30. package/dist/memory/gateway.d.ts +14 -2
  31. package/dist/memory/maintenance.d.ts +18 -0
  32. package/dist/memory/run-log.d.ts +8 -1
  33. package/dist/memory/schema.d.ts +3 -3
  34. package/dist/memory/scoring.d.ts +45 -0
  35. package/dist/memory/sentinel.d.ts +15 -0
  36. package/dist/services/memory-consolidation.d.ts +32 -0
  37. package/dist/services/skill-generator.d.ts +8 -1
  38. package/dist/state.d.ts +4 -2
  39. package/package.json +1 -1
@@ -1654,7 +1654,7 @@ async function generateSkills(req) {
1654
1654
  continue;
1655
1655
  }
1656
1656
  }
1657
- const content = renderSkillMarkdown(cluster, req.mode);
1657
+ let content = renderSkillMarkdown(cluster, req.mode);
1658
1658
  if (await isRejectedSkillContent(req.directory, cluster.slug, content)) {
1659
1659
  result.skipped.push({
1660
1660
  slug: cluster.slug,
@@ -1696,54 +1696,124 @@ async function generateSkills(req) {
1696
1696
  continue;
1697
1697
  }
1698
1698
  }
1699
- await atomicWrite2(targetPath, content);
1699
+ let missingSourceIds = [];
1700
1700
  if (req.mode === "active") {
1701
- await stampSourceEntries(req.directory, cluster.slug, cluster.entries.map((e) => e.id));
1701
+ const idsToStamp = req.sourceKnowledgeIds?.length ? req.sourceKnowledgeIds : cluster.entries.map((e) => e.id);
1702
+ const { missing } = await stampSourceEntries(req.directory, cluster.slug, idsToStamp);
1703
+ missingSourceIds = missing;
1704
+ if (missingSourceIds.length > 0) {
1705
+ content = injectMissingIdsIntoFrontmatter(content, missingSourceIds);
1706
+ }
1702
1707
  }
1708
+ await atomicWrite2(targetPath, content);
1703
1709
  result.written.push({
1704
1710
  slug: cluster.slug,
1705
1711
  path: targetPath,
1706
1712
  mode: req.mode,
1707
1713
  sourceKnowledgeIds: cluster.entries.map((e) => e.id),
1714
+ missingSourceKnowledgeIds: missingSourceIds,
1708
1715
  preserved,
1709
1716
  evaluation
1710
1717
  });
1711
1718
  }
1712
1719
  return result;
1713
1720
  }
1721
+ function injectMissingIdsIntoFrontmatter(content, missingIds) {
1722
+ if (missingIds.length === 0)
1723
+ return content;
1724
+ const stripped = content.charCodeAt(0) === 65279 ? content.slice(1) : content;
1725
+ const openFence = stripped.match(/^---[ \t]*\r?\n/);
1726
+ if (!openFence)
1727
+ return content;
1728
+ const fenceLen = openFence[0].length;
1729
+ const closeFence = stripped.slice(fenceLen).match(/\n---[ \t]*(\r?\n|$)/);
1730
+ if (!closeFence)
1731
+ return content;
1732
+ const closeStart = fenceLen + (closeFence.index ?? 0);
1733
+ const body = stripped.slice(fenceLen, closeStart).replace(/\r\n/g, `
1734
+ `);
1735
+ const sourceIdx = body.indexOf("source_knowledge_ids:");
1736
+ if (sourceIdx === -1)
1737
+ return content;
1738
+ const afterLabel = body.indexOf(`
1739
+ `, sourceIdx);
1740
+ const listStart = afterLabel === -1 ? body.length : afterLabel + 1;
1741
+ const lines = body.split(`
1742
+ `);
1743
+ let insertIdx = -1;
1744
+ for (let i = 0;i < lines.length; i++) {
1745
+ if (lines[i].length === 0)
1746
+ continue;
1747
+ const relativePos = body.indexOf(lines[i], listStart);
1748
+ if (relativePos >= 0 && relativePos < listStart + 2)
1749
+ continue;
1750
+ if (body.slice(listStart, body.indexOf(lines[i], listStart)).match(/^\s+-/)) {
1751
+ continue;
1752
+ }
1753
+ insertIdx = body.indexOf(lines[i], listStart);
1754
+ break;
1755
+ }
1756
+ if (insertIdx === -1)
1757
+ insertIdx = body.length;
1758
+ const missingBlock = [
1759
+ "missing_source_knowledge_ids:",
1760
+ ...missingIds.map((id) => ` - ${id}`),
1761
+ ""
1762
+ ].join(`
1763
+ `);
1764
+ const newBody = body.slice(0, insertIdx) + missingBlock + body.slice(insertIdx);
1765
+ const prefix = stripped.slice(0, fenceLen);
1766
+ const suffix = stripped.slice(closeStart);
1767
+ return prefix + newBody + suffix;
1768
+ }
1714
1769
  async function stampSourceEntries(directory, slug, ids) {
1715
1770
  if (!ids || ids.length === 0)
1716
- return;
1771
+ return { stamped: [], missing: [] };
1717
1772
  const swarmPath = resolveSwarmKnowledgePath(directory);
1718
1773
  const swarm = await readKnowledge(swarmPath);
1719
1774
  const idSet = new Set(ids);
1720
- let touched = false;
1775
+ const stamped = [];
1776
+ const missing = [];
1777
+ const found = new Set;
1721
1778
  const repoRel = activeRepoRelativePath(slug);
1722
1779
  for (const e of swarm) {
1723
1780
  if (!idSet.has(e.id))
1724
1781
  continue;
1782
+ found.add(e.id);
1725
1783
  e.generated_skill_slug = slug;
1726
1784
  e.generated_skill_path = repoRel;
1727
1785
  e.updated_at = new Date().toISOString();
1728
- touched = true;
1729
1786
  }
1730
- if (touched)
1787
+ if (found.size > 0)
1731
1788
  await rewriteKnowledge(swarmPath, swarm);
1789
+ stamped.push(...found);
1732
1790
  const hivePath = resolveHiveKnowledgePath();
1733
- if (!existsSync3(hivePath))
1734
- return;
1791
+ if (!existsSync3(hivePath)) {
1792
+ for (const id of ids) {
1793
+ if (!found.has(id))
1794
+ missing.push(id);
1795
+ }
1796
+ return { stamped, missing };
1797
+ }
1735
1798
  const hive = await readKnowledge(hivePath);
1736
- let touchedHive = false;
1799
+ const foundHive = new Set;
1737
1800
  for (const e of hive) {
1738
1801
  if (!idSet.has(e.id))
1739
1802
  continue;
1803
+ foundHive.add(e.id);
1740
1804
  e.generated_skill_slug = slug;
1741
1805
  e.generated_skill_path = repoRel;
1742
1806
  e.updated_at = new Date().toISOString();
1743
- touchedHive = true;
1744
1807
  }
1745
- if (touchedHive)
1808
+ if (foundHive.size > 0)
1746
1809
  await rewriteKnowledge(hivePath, hive);
1810
+ stamped.push(...foundHive);
1811
+ const allFound = new Set([...found, ...foundHive]);
1812
+ for (const id of ids) {
1813
+ if (!allFound.has(id))
1814
+ missing.push(id);
1815
+ }
1816
+ return { stamped, missing };
1747
1817
  }
1748
1818
  function parseDraftFrontmatter(content) {
1749
1819
  const stripped = content.charCodeAt(0) === 65279 ? content.slice(1) : content;
package/dist/cli/index.js CHANGED
@@ -7,15 +7,15 @@ import {
7
7
  getPluginLockFilePaths,
8
8
  package_default,
9
9
  resolveCommand
10
- } from "./index-g6f4tt38.js";
11
- import"./index-g00qm2gf.js";
12
- import"./index-yhsmmv2z.js";
13
- import"./index-32axfg6h.js";
10
+ } from "./index-hs2knbfq.js";
11
+ import"./index-6tnmt41c.js";
12
+ import"./index-bm4f0nme.js";
13
+ import"./index-rh53rrpt.js";
14
14
  import"./index-e8pk68cc.js";
15
- import"./index-819xp49y.js";
15
+ import"./index-bywt2171.js";
16
16
  import {
17
17
  DEFAULT_AGENT_CONFIGS
18
- } from "./index-0asbrmdx.js";
18
+ } from "./index-123s7kjc.js";
19
19
  import"./index-8y7qetpg.js";
20
20
  import"./index-adz3nk9b.js";
21
21
  import"./index-v4fcn4tr.js";
@@ -81,7 +81,7 @@ import {
81
81
  resolveGeneratedAgentRole,
82
82
  resolveGuardrailsConfig,
83
83
  stripKnownSwarmPrefix
84
- } from "./index-0asbrmdx.js";
84
+ } from "./index-123s7kjc.js";
85
85
  import"./index-p0arc26j.js";
86
86
  import"./index-293f68mj.js";
87
87
  import"./index-a76rekgs.js";
@@ -22,7 +22,7 @@ import {
22
22
  retireSkill,
23
23
  sanitizeSlug,
24
24
  selectCandidateEntries
25
- } from "./index-32axfg6h.js";
25
+ } from "./index-rh53rrpt.js";
26
26
  import"./index-e8pk68cc.js";
27
27
  import"./index-fjwwrwr5.js";
28
28
  import"./index-jtqkh8jf.js";
@@ -1,4 +1,5 @@
1
1
  export declare function handleMemoryCommand(_directory: string, _args: string[]): Promise<string>;
2
+ export declare function handleMemoryConsolidationLogCommand(directory: string, args: string[]): Promise<string>;
2
3
  export declare function handleMemoryStatusCommand(directory: string, _args: string[]): Promise<string>;
3
4
  export declare function handleMemoryPendingCommand(directory: string, args: string[]): Promise<string>;
4
5
  export declare function handleMemoryRecallLogCommand(directory: string, args: string[]): Promise<string>;
@@ -816,6 +816,14 @@ export declare const COMMAND_REGISTRY: {
816
816
  readonly category: "utility";
817
817
  readonly toolPolicy: "human-only";
818
818
  };
819
+ readonly 'memory consolidation-log': {
820
+ readonly handler: (ctx: CommandContext) => Promise<string>;
821
+ readonly description: "Summarize recent memory consolidation passes and metrics";
822
+ readonly subcommandOf: "memory";
823
+ readonly args: "--limit <n>";
824
+ readonly category: "diagnostics";
825
+ readonly toolPolicy: "agent";
826
+ };
819
827
  readonly 'memory-status': {
820
828
  readonly handler: (ctx: CommandContext) => Promise<string>;
821
829
  readonly description: "Show Swarm memory provider, JSONL, and migration status";
@@ -12,8 +12,8 @@
12
12
  export declare const QA_AGENTS: readonly ["reviewer", "critic", "critic_oversight"];
13
13
  export declare const PIPELINE_AGENTS: readonly ["explorer", "coder", "test_engineer"];
14
14
  export declare const ORCHESTRATOR_NAME: "architect";
15
- export declare const ALL_SUBAGENT_NAMES: readonly ["sme", "researcher", "docs", "docs_design", "designer", "critic_sounding_board", "critic_drift_verifier", "critic_hallucination_verifier", "critic_architecture_supervisor", "curator_init", "curator_phase", "curator_postmortem", "council_generalist", "council_skeptic", "council_domain_expert", "skill_improver", "spec_writer", "reviewer", "critic", "critic_oversight", "explorer", "coder", "test_engineer"];
16
- export declare const ALL_AGENT_NAMES: readonly ["architect", "sme", "researcher", "docs", "docs_design", "designer", "critic_sounding_board", "critic_drift_verifier", "critic_hallucination_verifier", "critic_architecture_supervisor", "curator_init", "curator_phase", "curator_postmortem", "council_generalist", "council_skeptic", "council_domain_expert", "skill_improver", "spec_writer", "reviewer", "critic", "critic_oversight", "explorer", "coder", "test_engineer"];
15
+ export declare const ALL_SUBAGENT_NAMES: readonly ["sme", "researcher", "docs", "docs_design", "designer", "critic_sounding_board", "critic_drift_verifier", "critic_hallucination_verifier", "critic_architecture_supervisor", "curator_init", "curator_phase", "curator_postmortem", "curator_consolidation", "council_generalist", "council_skeptic", "council_domain_expert", "skill_improver", "spec_writer", "reviewer", "critic", "critic_oversight", "explorer", "coder", "test_engineer"];
16
+ export declare const ALL_AGENT_NAMES: readonly ["architect", "sme", "researcher", "docs", "docs_design", "designer", "critic_sounding_board", "critic_drift_verifier", "critic_hallucination_verifier", "critic_architecture_supervisor", "curator_init", "curator_phase", "curator_postmortem", "curator_consolidation", "council_generalist", "council_skeptic", "council_domain_expert", "skill_improver", "spec_writer", "reviewer", "critic", "critic_oversight", "explorer", "coder", "test_engineer"];
17
17
  export type QAAgentName = (typeof QA_AGENTS)[number];
18
18
  export type PipelineAgentName = (typeof PIPELINE_AGENTS)[number];
19
19
  export type AgentName = (typeof ALL_AGENT_NAMES)[number];
@@ -632,6 +632,36 @@ export declare const MemoryConfigSchema: z.ZodObject<{
632
632
  maintenance: z.ZodDefault<z.ZodObject<{
633
633
  lowUtilityMaxConfidence: z.ZodDefault<z.ZodNumber>;
634
634
  lowUtilityMinAgeDays: z.ZodDefault<z.ZodNumber>;
635
+ importance: z.ZodDefault<z.ZodObject<{
636
+ wRecency: z.ZodDefault<z.ZodNumber>;
637
+ wFrequency: z.ZodDefault<z.ZodNumber>;
638
+ wFreshness: z.ZodDefault<z.ZodNumber>;
639
+ wConfidence: z.ZodDefault<z.ZodNumber>;
640
+ lambda: z.ZodDefault<z.ZodNumber>;
641
+ mu: z.ZodDefault<z.ZodNumber>;
642
+ n: z.ZodDefault<z.ZodNumber>;
643
+ threshold: z.ZodDefault<z.ZodNumber>;
644
+ }, z.core.$strip>>;
645
+ }, z.core.$strip>>;
646
+ consolidation: z.ZodDefault<z.ZodObject<{
647
+ enabled: z.ZodDefault<z.ZodBoolean>;
648
+ maxClustersPerPass: z.ZodDefault<z.ZodNumber>;
649
+ jaccardThreshold: z.ZodDefault<z.ZodNumber>;
650
+ autoApplyMinConfidence: z.ZodDefault<z.ZodNumber>;
651
+ decayHalfLifeDays: z.ZodDefault<z.ZodObject<{
652
+ user_preference: z.ZodDefault<z.ZodNumber>;
653
+ project_fact: z.ZodDefault<z.ZodNumber>;
654
+ architecture_decision: z.ZodDefault<z.ZodNumber>;
655
+ repo_convention: z.ZodDefault<z.ZodNumber>;
656
+ api_finding: z.ZodDefault<z.ZodNumber>;
657
+ code_pattern: z.ZodDefault<z.ZodNumber>;
658
+ test_pattern: z.ZodDefault<z.ZodNumber>;
659
+ failure_pattern: z.ZodDefault<z.ZodNumber>;
660
+ security_note: z.ZodDefault<z.ZodNumber>;
661
+ evidence: z.ZodDefault<z.ZodNumber>;
662
+ todo: z.ZodDefault<z.ZodNumber>;
663
+ scratch: z.ZodDefault<z.ZodNumber>;
664
+ }, z.core.$strip>>;
635
665
  }, z.core.$strip>>;
636
666
  hardDelete: z.ZodDefault<z.ZodBoolean>;
637
667
  }, z.core.$strip>;
@@ -1747,6 +1777,36 @@ export declare const PluginConfigSchema: z.ZodObject<{
1747
1777
  maintenance: z.ZodDefault<z.ZodObject<{
1748
1778
  lowUtilityMaxConfidence: z.ZodDefault<z.ZodNumber>;
1749
1779
  lowUtilityMinAgeDays: z.ZodDefault<z.ZodNumber>;
1780
+ importance: z.ZodDefault<z.ZodObject<{
1781
+ wRecency: z.ZodDefault<z.ZodNumber>;
1782
+ wFrequency: z.ZodDefault<z.ZodNumber>;
1783
+ wFreshness: z.ZodDefault<z.ZodNumber>;
1784
+ wConfidence: z.ZodDefault<z.ZodNumber>;
1785
+ lambda: z.ZodDefault<z.ZodNumber>;
1786
+ mu: z.ZodDefault<z.ZodNumber>;
1787
+ n: z.ZodDefault<z.ZodNumber>;
1788
+ threshold: z.ZodDefault<z.ZodNumber>;
1789
+ }, z.core.$strip>>;
1790
+ }, z.core.$strip>>;
1791
+ consolidation: z.ZodDefault<z.ZodObject<{
1792
+ enabled: z.ZodDefault<z.ZodBoolean>;
1793
+ maxClustersPerPass: z.ZodDefault<z.ZodNumber>;
1794
+ jaccardThreshold: z.ZodDefault<z.ZodNumber>;
1795
+ autoApplyMinConfidence: z.ZodDefault<z.ZodNumber>;
1796
+ decayHalfLifeDays: z.ZodDefault<z.ZodObject<{
1797
+ user_preference: z.ZodDefault<z.ZodNumber>;
1798
+ project_fact: z.ZodDefault<z.ZodNumber>;
1799
+ architecture_decision: z.ZodDefault<z.ZodNumber>;
1800
+ repo_convention: z.ZodDefault<z.ZodNumber>;
1801
+ api_finding: z.ZodDefault<z.ZodNumber>;
1802
+ code_pattern: z.ZodDefault<z.ZodNumber>;
1803
+ test_pattern: z.ZodDefault<z.ZodNumber>;
1804
+ failure_pattern: z.ZodDefault<z.ZodNumber>;
1805
+ security_note: z.ZodDefault<z.ZodNumber>;
1806
+ evidence: z.ZodDefault<z.ZodNumber>;
1807
+ todo: z.ZodDefault<z.ZodNumber>;
1808
+ scratch: z.ZodDefault<z.ZodNumber>;
1809
+ }, z.core.$strip>>;
1750
1810
  }, z.core.$strip>>;
1751
1811
  hardDelete: z.ZodDefault<z.ZodBoolean>;
1752
1812
  }, z.core.$strip>>;
@@ -18,4 +18,4 @@ import type { CuratorLLMDelegate } from './curator.js';
18
18
  *
19
19
  * Returns undefined if swarmState.opencodeClient is not set (e.g. in unit tests).
20
20
  */
21
- export declare function createCuratorLLMDelegate(directory: string, mode?: 'init' | 'phase' | 'postmortem', sessionId?: string): CuratorLLMDelegate | undefined;
21
+ export declare function createCuratorLLMDelegate(directory: string, mode?: 'init' | 'phase' | 'postmortem' | 'consolidation', sessionId?: string): CuratorLLMDelegate | undefined;