opencode-swarm-plugin 0.43.0 → 0.44.1

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 (208) hide show
  1. package/bin/cass.characterization.test.ts +422 -0
  2. package/bin/swarm.serve.test.ts +6 -4
  3. package/bin/swarm.test.ts +68 -0
  4. package/bin/swarm.ts +81 -8
  5. package/dist/compaction-prompt-scoring.js +139 -0
  6. package/dist/contributor-tools.d.ts +42 -0
  7. package/dist/contributor-tools.d.ts.map +1 -0
  8. package/dist/eval-capture.js +12811 -0
  9. package/dist/hive.d.ts.map +1 -1
  10. package/dist/index.d.ts +12 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +7728 -62590
  13. package/dist/plugin.js +23833 -78695
  14. package/dist/sessions/agent-discovery.d.ts +59 -0
  15. package/dist/sessions/agent-discovery.d.ts.map +1 -0
  16. package/dist/sessions/index.d.ts +10 -0
  17. package/dist/sessions/index.d.ts.map +1 -0
  18. package/dist/swarm-orchestrate.d.ts.map +1 -1
  19. package/dist/swarm-prompts.d.ts.map +1 -1
  20. package/dist/swarm-review.d.ts.map +1 -1
  21. package/package.json +17 -5
  22. package/.changeset/swarm-insights-data-layer.md +0 -63
  23. package/.hive/analysis/eval-failure-analysis-2025-12-25.md +0 -331
  24. package/.hive/analysis/session-data-quality-audit.md +0 -320
  25. package/.hive/eval-results.json +0 -483
  26. package/.hive/issues.jsonl +0 -138
  27. package/.hive/memories.jsonl +0 -729
  28. package/.opencode/eval-history.jsonl +0 -327
  29. package/.turbo/turbo-build.log +0 -9
  30. package/CHANGELOG.md +0 -2255
  31. package/SCORER-ANALYSIS.md +0 -598
  32. package/docs/analysis/subagent-coordination-patterns.md +0 -902
  33. package/docs/analysis-socratic-planner-pattern.md +0 -504
  34. package/docs/planning/ADR-001-monorepo-structure.md +0 -171
  35. package/docs/planning/ADR-002-package-extraction.md +0 -393
  36. package/docs/planning/ADR-003-performance-improvements.md +0 -451
  37. package/docs/planning/ADR-004-message-queue-features.md +0 -187
  38. package/docs/planning/ADR-005-devtools-observability.md +0 -202
  39. package/docs/planning/ADR-007-swarm-enhancements-worktree-review.md +0 -168
  40. package/docs/planning/ADR-008-worker-handoff-protocol.md +0 -293
  41. package/docs/planning/ADR-009-oh-my-opencode-patterns.md +0 -353
  42. package/docs/planning/ROADMAP.md +0 -368
  43. package/docs/semantic-memory-cli-syntax.md +0 -123
  44. package/docs/swarm-mail-architecture.md +0 -1147
  45. package/docs/testing/context-recovery-test.md +0 -470
  46. package/evals/ARCHITECTURE.md +0 -1189
  47. package/evals/README.md +0 -768
  48. package/evals/compaction-prompt.eval.ts +0 -149
  49. package/evals/compaction-resumption.eval.ts +0 -289
  50. package/evals/coordinator-behavior.eval.ts +0 -307
  51. package/evals/coordinator-session.eval.ts +0 -154
  52. package/evals/evalite.config.ts.bak +0 -15
  53. package/evals/example.eval.ts +0 -31
  54. package/evals/fixtures/compaction-cases.ts +0 -350
  55. package/evals/fixtures/compaction-prompt-cases.ts +0 -311
  56. package/evals/fixtures/coordinator-sessions.ts +0 -328
  57. package/evals/fixtures/decomposition-cases.ts +0 -105
  58. package/evals/lib/compaction-loader.test.ts +0 -248
  59. package/evals/lib/compaction-loader.ts +0 -320
  60. package/evals/lib/data-loader.evalite-test.ts +0 -289
  61. package/evals/lib/data-loader.test.ts +0 -345
  62. package/evals/lib/data-loader.ts +0 -281
  63. package/evals/lib/llm.ts +0 -115
  64. package/evals/scorers/compaction-prompt-scorers.ts +0 -145
  65. package/evals/scorers/compaction-scorers.ts +0 -305
  66. package/evals/scorers/coordinator-discipline.evalite-test.ts +0 -539
  67. package/evals/scorers/coordinator-discipline.ts +0 -325
  68. package/evals/scorers/index.test.ts +0 -146
  69. package/evals/scorers/index.ts +0 -328
  70. package/evals/scorers/outcome-scorers.evalite-test.ts +0 -27
  71. package/evals/scorers/outcome-scorers.ts +0 -349
  72. package/evals/swarm-decomposition.eval.ts +0 -121
  73. package/examples/commands/swarm.md +0 -745
  74. package/examples/plugin-wrapper-template.ts +0 -2426
  75. package/examples/skills/hive-workflow/SKILL.md +0 -212
  76. package/examples/skills/skill-creator/SKILL.md +0 -223
  77. package/examples/skills/swarm-coordination/SKILL.md +0 -292
  78. package/global-skills/cli-builder/SKILL.md +0 -344
  79. package/global-skills/cli-builder/references/advanced-patterns.md +0 -244
  80. package/global-skills/learning-systems/SKILL.md +0 -644
  81. package/global-skills/skill-creator/LICENSE.txt +0 -202
  82. package/global-skills/skill-creator/SKILL.md +0 -352
  83. package/global-skills/skill-creator/references/output-patterns.md +0 -82
  84. package/global-skills/skill-creator/references/workflows.md +0 -28
  85. package/global-skills/swarm-coordination/SKILL.md +0 -995
  86. package/global-skills/swarm-coordination/references/coordinator-patterns.md +0 -235
  87. package/global-skills/swarm-coordination/references/strategies.md +0 -138
  88. package/global-skills/system-design/SKILL.md +0 -213
  89. package/global-skills/testing-patterns/SKILL.md +0 -430
  90. package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +0 -586
  91. package/opencode-swarm-plugin-0.30.7.tgz +0 -0
  92. package/opencode-swarm-plugin-0.31.0.tgz +0 -0
  93. package/scripts/cleanup-test-memories.ts +0 -346
  94. package/scripts/init-skill.ts +0 -222
  95. package/scripts/migrate-unknown-sessions.ts +0 -349
  96. package/scripts/validate-skill.ts +0 -204
  97. package/src/agent-mail.ts +0 -1724
  98. package/src/anti-patterns.test.ts +0 -1167
  99. package/src/anti-patterns.ts +0 -448
  100. package/src/compaction-capture.integration.test.ts +0 -257
  101. package/src/compaction-hook.test.ts +0 -838
  102. package/src/compaction-hook.ts +0 -1204
  103. package/src/compaction-observability.integration.test.ts +0 -139
  104. package/src/compaction-observability.test.ts +0 -187
  105. package/src/compaction-observability.ts +0 -324
  106. package/src/compaction-prompt-scorers.test.ts +0 -475
  107. package/src/compaction-prompt-scoring.ts +0 -300
  108. package/src/dashboard.test.ts +0 -611
  109. package/src/dashboard.ts +0 -462
  110. package/src/error-enrichment.test.ts +0 -403
  111. package/src/error-enrichment.ts +0 -219
  112. package/src/eval-capture.test.ts +0 -1015
  113. package/src/eval-capture.ts +0 -929
  114. package/src/eval-gates.test.ts +0 -306
  115. package/src/eval-gates.ts +0 -218
  116. package/src/eval-history.test.ts +0 -508
  117. package/src/eval-history.ts +0 -214
  118. package/src/eval-learning.test.ts +0 -378
  119. package/src/eval-learning.ts +0 -360
  120. package/src/eval-runner.test.ts +0 -223
  121. package/src/eval-runner.ts +0 -402
  122. package/src/export-tools.test.ts +0 -476
  123. package/src/export-tools.ts +0 -257
  124. package/src/hive.integration.test.ts +0 -2241
  125. package/src/hive.ts +0 -1628
  126. package/src/index.ts +0 -935
  127. package/src/learning.integration.test.ts +0 -1815
  128. package/src/learning.ts +0 -1079
  129. package/src/logger.test.ts +0 -189
  130. package/src/logger.ts +0 -135
  131. package/src/mandate-promotion.test.ts +0 -473
  132. package/src/mandate-promotion.ts +0 -239
  133. package/src/mandate-storage.integration.test.ts +0 -601
  134. package/src/mandate-storage.test.ts +0 -578
  135. package/src/mandate-storage.ts +0 -794
  136. package/src/mandates.ts +0 -540
  137. package/src/memory-tools.test.ts +0 -195
  138. package/src/memory-tools.ts +0 -344
  139. package/src/memory.integration.test.ts +0 -334
  140. package/src/memory.test.ts +0 -158
  141. package/src/memory.ts +0 -527
  142. package/src/model-selection.test.ts +0 -188
  143. package/src/model-selection.ts +0 -68
  144. package/src/observability-tools.test.ts +0 -359
  145. package/src/observability-tools.ts +0 -871
  146. package/src/output-guardrails.test.ts +0 -438
  147. package/src/output-guardrails.ts +0 -381
  148. package/src/pattern-maturity.test.ts +0 -1160
  149. package/src/pattern-maturity.ts +0 -525
  150. package/src/planning-guardrails.test.ts +0 -491
  151. package/src/planning-guardrails.ts +0 -438
  152. package/src/plugin.ts +0 -23
  153. package/src/post-compaction-tracker.test.ts +0 -251
  154. package/src/post-compaction-tracker.ts +0 -237
  155. package/src/query-tools.test.ts +0 -636
  156. package/src/query-tools.ts +0 -324
  157. package/src/rate-limiter.integration.test.ts +0 -466
  158. package/src/rate-limiter.ts +0 -774
  159. package/src/replay-tools.test.ts +0 -496
  160. package/src/replay-tools.ts +0 -240
  161. package/src/repo-crawl.integration.test.ts +0 -441
  162. package/src/repo-crawl.ts +0 -610
  163. package/src/schemas/cell-events.test.ts +0 -347
  164. package/src/schemas/cell-events.ts +0 -807
  165. package/src/schemas/cell.ts +0 -257
  166. package/src/schemas/evaluation.ts +0 -166
  167. package/src/schemas/index.test.ts +0 -199
  168. package/src/schemas/index.ts +0 -286
  169. package/src/schemas/mandate.ts +0 -232
  170. package/src/schemas/swarm-context.ts +0 -115
  171. package/src/schemas/task.ts +0 -161
  172. package/src/schemas/worker-handoff.test.ts +0 -302
  173. package/src/schemas/worker-handoff.ts +0 -131
  174. package/src/skills.integration.test.ts +0 -1192
  175. package/src/skills.test.ts +0 -643
  176. package/src/skills.ts +0 -1549
  177. package/src/storage.integration.test.ts +0 -341
  178. package/src/storage.ts +0 -884
  179. package/src/structured.integration.test.ts +0 -817
  180. package/src/structured.test.ts +0 -1046
  181. package/src/structured.ts +0 -762
  182. package/src/swarm-decompose.test.ts +0 -188
  183. package/src/swarm-decompose.ts +0 -1302
  184. package/src/swarm-deferred.integration.test.ts +0 -157
  185. package/src/swarm-deferred.test.ts +0 -38
  186. package/src/swarm-insights.test.ts +0 -214
  187. package/src/swarm-insights.ts +0 -459
  188. package/src/swarm-mail.integration.test.ts +0 -970
  189. package/src/swarm-mail.ts +0 -739
  190. package/src/swarm-orchestrate.integration.test.ts +0 -282
  191. package/src/swarm-orchestrate.test.ts +0 -548
  192. package/src/swarm-orchestrate.ts +0 -3084
  193. package/src/swarm-prompts.test.ts +0 -1270
  194. package/src/swarm-prompts.ts +0 -2077
  195. package/src/swarm-research.integration.test.ts +0 -701
  196. package/src/swarm-research.test.ts +0 -698
  197. package/src/swarm-research.ts +0 -472
  198. package/src/swarm-review.integration.test.ts +0 -285
  199. package/src/swarm-review.test.ts +0 -879
  200. package/src/swarm-review.ts +0 -709
  201. package/src/swarm-strategies.ts +0 -407
  202. package/src/swarm-worktree.test.ts +0 -501
  203. package/src/swarm-worktree.ts +0 -575
  204. package/src/swarm.integration.test.ts +0 -2377
  205. package/src/swarm.ts +0 -38
  206. package/src/tool-adapter.integration.test.ts +0 -1221
  207. package/src/tool-availability.ts +0 -461
  208. package/tsconfig.json +0 -28
@@ -1,195 +0,0 @@
1
- /**
2
- * Memory Tools Integration Tests
3
- *
4
- * Tests for semantic-memory_* tool registration and execution.
5
- */
6
-
7
- import { describe, test, expect, beforeAll, afterAll } from "bun:test";
8
- import { memoryTools, resetMemoryCache } from "./memory-tools";
9
- import { closeAllSwarmMail } from "swarm-mail";
10
-
11
- describe("memory tools integration", () => {
12
- afterAll(async () => {
13
- resetMemoryCache();
14
- await closeAllSwarmMail();
15
- });
16
-
17
- test("all tools are registered with correct names", () => {
18
- const toolNames = Object.keys(memoryTools);
19
- expect(toolNames).toContain("semantic-memory_store");
20
- expect(toolNames).toContain("semantic-memory_find");
21
- expect(toolNames).toContain("semantic-memory_get");
22
- expect(toolNames).toContain("semantic-memory_remove");
23
- expect(toolNames).toContain("semantic-memory_validate");
24
- expect(toolNames).toContain("semantic-memory_list");
25
- expect(toolNames).toContain("semantic-memory_stats");
26
- expect(toolNames).toContain("semantic-memory_check");
27
- expect(toolNames).toContain("semantic-memory_upsert");
28
- });
29
-
30
- test("tools have execute functions", () => {
31
- for (const [name, tool] of Object.entries(memoryTools)) {
32
- expect(typeof tool.execute).toBe("function");
33
- }
34
- });
35
-
36
- describe("semantic-memory_store", () => {
37
- test("executes and returns JSON", async () => {
38
- const tool = memoryTools["semantic-memory_store"];
39
- const result = await tool.execute(
40
- {
41
- information: "Test memory for tools integration",
42
- tags: "test",
43
- },
44
- { sessionID: "test-session" } as any,
45
- );
46
-
47
- expect(typeof result).toBe("string");
48
- const parsed = JSON.parse(result);
49
- expect(parsed.id).toBeDefined();
50
- expect(parsed.id).toMatch(/^mem_/);
51
- expect(parsed.message).toContain("Stored memory");
52
- });
53
- });
54
-
55
- describe("semantic-memory_find", () => {
56
- test("executes and returns JSON array", async () => {
57
- // Store a memory first
58
- const storeTool = memoryTools["semantic-memory_store"];
59
- await storeTool.execute(
60
- {
61
- information: "Findable test memory with unique keyword xyztest123",
62
- },
63
- { sessionID: "test-session" } as any,
64
- );
65
-
66
- // Search for it
67
- const findTool = memoryTools["semantic-memory_find"];
68
- const result = await findTool.execute(
69
- {
70
- query: "xyztest123",
71
- limit: 5,
72
- },
73
- { sessionID: "test-session" } as any,
74
- );
75
-
76
- expect(typeof result).toBe("string");
77
- const parsed = JSON.parse(result);
78
- expect(parsed.results).toBeDefined();
79
- expect(Array.isArray(parsed.results)).toBe(true);
80
- expect(parsed.count).toBeGreaterThanOrEqual(0);
81
- });
82
- });
83
-
84
- describe("semantic-memory_stats", () => {
85
- test("returns memory and embedding counts", async () => {
86
- const tool = memoryTools["semantic-memory_stats"];
87
- const result = await tool.execute(
88
- {},
89
- { sessionID: "test-session" } as any,
90
- );
91
-
92
- expect(typeof result).toBe("string");
93
- const parsed = JSON.parse(result);
94
- expect(typeof parsed.memories).toBe("number");
95
- expect(typeof parsed.embeddings).toBe("number");
96
- });
97
- });
98
-
99
- describe("semantic-memory_check", () => {
100
- test("checks Ollama health", async () => {
101
- const tool = memoryTools["semantic-memory_check"];
102
- const result = await tool.execute(
103
- {},
104
- { sessionID: "test-session" } as any,
105
- );
106
-
107
- expect(typeof result).toBe("string");
108
- const parsed = JSON.parse(result);
109
- expect(typeof parsed.ollama).toBe("boolean");
110
- });
111
- });
112
-
113
- describe("semantic-memory_upsert", () => {
114
- test("returns valid ADD operation result", async () => {
115
- const tool = memoryTools["semantic-memory_upsert"];
116
- const result = await tool.execute(
117
- {
118
- information: "Test memory for plugin tool",
119
- tags: "test,plugin",
120
- },
121
- { sessionID: "test-session" } as any,
122
- );
123
-
124
- const parsed = JSON.parse(result);
125
-
126
- expect(parsed.operation).toBe("ADD");
127
- expect(parsed.reason).toBeDefined();
128
- expect(parsed.memoryId).toBeDefined();
129
- expect(parsed.memoryId).toMatch(/^mem_/);
130
- });
131
-
132
- test("includes autoTags when enabled", async () => {
133
- const tool = memoryTools["semantic-memory_upsert"];
134
- const result = await tool.execute(
135
- {
136
- information: "TypeScript is a typed superset of JavaScript",
137
- autoTag: true,
138
- },
139
- { sessionID: "test-session" } as any,
140
- );
141
-
142
- const parsed = JSON.parse(result);
143
-
144
- expect(parsed.autoTags).toBeDefined();
145
- expect(parsed.autoTags.tags).toBeInstanceOf(Array);
146
- expect(parsed.autoTags.keywords).toBeInstanceOf(Array);
147
- expect(parsed.autoTags.category).toBe("general");
148
- });
149
-
150
- test("includes linksCreated when autoLink enabled", async () => {
151
- const tool = memoryTools["semantic-memory_upsert"];
152
- const result = await tool.execute(
153
- {
154
- information: "React hooks enable functional components to use state",
155
- autoLink: true,
156
- },
157
- { sessionID: "test-session" } as any,
158
- );
159
-
160
- const parsed = JSON.parse(result);
161
-
162
- expect(parsed.linksCreated).toBeDefined();
163
- expect(typeof parsed.linksCreated).toBe("number");
164
- });
165
-
166
- test("includes entitiesExtracted when extractEntities enabled", async () => {
167
- const tool = memoryTools["semantic-memory_upsert"];
168
- const result = await tool.execute(
169
- {
170
- information: "Next.js 15 was released by Vercel in October 2024",
171
- extractEntities: true,
172
- },
173
- { sessionID: "test-session" } as any,
174
- );
175
-
176
- const parsed = JSON.parse(result);
177
-
178
- expect(parsed.entitiesExtracted).toBeDefined();
179
- expect(typeof parsed.entitiesExtracted).toBe("number");
180
- });
181
-
182
- test("throws error when information is missing", async () => {
183
- const tool = memoryTools["semantic-memory_upsert"];
184
-
185
- await expect(async () => {
186
- await tool.execute(
187
- {
188
- tags: "test",
189
- } as any,
190
- { sessionID: "test-session" } as any,
191
- );
192
- }).toThrow("information is required");
193
- });
194
- });
195
- });
@@ -1,344 +0,0 @@
1
- /**
2
- * Semantic Memory Plugin Tools - Embedded implementation
3
- *
4
- * Provides semantic memory operations using swarm-mail's MemoryStore + Ollama.
5
- * Replaces external MCP-based semantic-memory calls with embedded storage.
6
- *
7
- * Key features:
8
- * - Vector similarity search with Ollama embeddings
9
- * - Full-text search fallback
10
- * - Memory decay tracking (TODO: implement in MemoryStore)
11
- * - Collection-based organization
12
- *
13
- * Tool signatures maintained for backward compatibility with existing prompts.
14
- */
15
-
16
- import { tool } from "@opencode-ai/plugin";
17
- import { getSwarmMailLibSQL } from "swarm-mail";
18
- import {
19
- createMemoryAdapter,
20
- type MemoryAdapter,
21
- type StoreArgs,
22
- type FindArgs,
23
- type IdArgs,
24
- type ListArgs,
25
- type StoreResult,
26
- type FindResult,
27
- type StatsResult,
28
- type HealthResult,
29
- type OperationResult,
30
- type UpsertArgs,
31
- type UpsertResult,
32
- type AutoTags,
33
- } from "./memory";
34
-
35
- // Re-export types for external use
36
- export type {
37
- MemoryAdapter,
38
- StoreArgs,
39
- FindArgs,
40
- IdArgs,
41
- ListArgs,
42
- StoreResult,
43
- FindResult,
44
- StatsResult,
45
- HealthResult,
46
- OperationResult,
47
- UpsertArgs,
48
- UpsertResult,
49
- AutoTags,
50
- } from "./memory";
51
-
52
- // ============================================================================
53
- // Types
54
- // ============================================================================
55
-
56
- /** Tool execution context from OpenCode plugin */
57
- interface ToolContext {
58
- sessionID: string;
59
- }
60
-
61
- // ============================================================================
62
- // Memory Adapter Cache
63
- // ============================================================================
64
-
65
- let cachedAdapter: MemoryAdapter | null = null;
66
- let cachedProjectPath: string | null = null;
67
-
68
- /**
69
- * Get or create memory adapter for the current project
70
- *
71
- * @param projectPath - Project path (uses CWD if not provided)
72
- * @returns Memory adapter instance
73
- */
74
- export async function getMemoryAdapter(
75
- projectPath?: string,
76
- ): Promise<MemoryAdapter> {
77
- const path = projectPath || process.cwd();
78
-
79
- // Return cached adapter if same project
80
- if (cachedAdapter && cachedProjectPath === path) {
81
- return cachedAdapter;
82
- }
83
-
84
- // Create new adapter
85
- const swarmMail = await getSwarmMailLibSQL(path);
86
- const dbAdapter = await swarmMail.getDatabase();
87
-
88
- // createMemoryAdapter now accepts DatabaseAdapter directly and converts internally
89
- cachedAdapter = await createMemoryAdapter(dbAdapter);
90
- cachedProjectPath = path;
91
-
92
- return cachedAdapter;
93
- }
94
-
95
- /**
96
- * Reset adapter cache (for testing)
97
- */
98
- export function resetMemoryCache(): void {
99
- cachedAdapter = null;
100
- cachedProjectPath = null;
101
- }
102
-
103
- // Re-export createMemoryAdapter for external use
104
- export { createMemoryAdapter };
105
-
106
- // ============================================================================
107
- // Plugin Tools
108
- // ============================================================================
109
-
110
- /**
111
- * Store a memory with semantic embedding
112
- */
113
- export const semantic_memory_store = tool({
114
- description:
115
- "Store a memory with semantic embedding. Memories are searchable by semantic similarity and can be organized into collections. Confidence affects decay rate: high confidence (1.0) = 135 day half-life, low confidence (0.0) = 45 day half-life. Supports auto-tagging, auto-linking, and entity extraction via LLM.",
116
- args: {
117
- information: tool.schema
118
- .string()
119
- .describe("The information to store (required)"),
120
- collection: tool.schema
121
- .string()
122
- .optional()
123
- .describe("Collection name (defaults to 'default')"),
124
- tags: tool.schema
125
- .string()
126
- .optional()
127
- .describe("Comma-separated tags (e.g., 'auth,tokens,oauth')"),
128
- metadata: tool.schema
129
- .string()
130
- .optional()
131
- .describe("JSON string with additional metadata"),
132
- confidence: tool.schema
133
- .number()
134
- .optional()
135
- .describe("Confidence level (0.0-1.0) affecting decay rate. Higher = slower decay. Default 0.7"),
136
- autoTag: tool.schema
137
- .boolean()
138
- .optional()
139
- .describe("Auto-generate tags using LLM. Default false"),
140
- autoLink: tool.schema
141
- .boolean()
142
- .optional()
143
- .describe("Auto-link to related memories. Default false"),
144
- extractEntities: tool.schema
145
- .boolean()
146
- .optional()
147
- .describe("Extract entities (people, places, technologies). Default false"),
148
- },
149
- async execute(args, ctx: ToolContext) {
150
- const adapter = await getMemoryAdapter();
151
- const result = await adapter.store(args);
152
- return JSON.stringify(result, null, 2);
153
- },
154
- });
155
-
156
- /**
157
- * Find memories by semantic similarity or full-text search
158
- */
159
- export const semantic_memory_find = tool({
160
- description:
161
- "Search memories by semantic similarity (vector search) or full-text search. Returns results ranked by relevance score.",
162
- args: {
163
- query: tool.schema.string().describe("Search query (required)"),
164
- limit: tool.schema
165
- .number()
166
- .optional()
167
- .describe("Maximum number of results (default: 10)"),
168
- collection: tool.schema
169
- .string()
170
- .optional()
171
- .describe("Filter by collection name"),
172
- expand: tool.schema
173
- .boolean()
174
- .optional()
175
- .describe("Return full content instead of truncated preview (default: false)"),
176
- fts: tool.schema
177
- .boolean()
178
- .optional()
179
- .describe("Use full-text search instead of vector search (default: false)"),
180
- },
181
- async execute(args, ctx: ToolContext) {
182
- const adapter = await getMemoryAdapter();
183
- const result = await adapter.find(args);
184
- return JSON.stringify(result, null, 2);
185
- },
186
- });
187
-
188
- /**
189
- * Get a single memory by ID
190
- */
191
- export const semantic_memory_get = tool({
192
- description: "Retrieve a specific memory by its ID.",
193
- args: {
194
- id: tool.schema.string().describe("Memory ID (required)"),
195
- },
196
- async execute(args, ctx: ToolContext) {
197
- const adapter = await getMemoryAdapter();
198
- const memory = await adapter.get(args);
199
- return memory ? JSON.stringify(memory, null, 2) : "Memory not found";
200
- },
201
- });
202
-
203
- /**
204
- * Remove a memory
205
- */
206
- export const semantic_memory_remove = tool({
207
- description: "Delete a memory by ID. Use this to remove outdated or incorrect memories.",
208
- args: {
209
- id: tool.schema.string().describe("Memory ID (required)"),
210
- },
211
- async execute(args, ctx: ToolContext) {
212
- const adapter = await getMemoryAdapter();
213
- const result = await adapter.remove(args);
214
- return JSON.stringify(result, null, 2);
215
- },
216
- });
217
-
218
- /**
219
- * Validate a memory (reset decay timer)
220
- */
221
- export const semantic_memory_validate = tool({
222
- description:
223
- "Validate that a memory is still accurate and reset its decay timer. Use when you confirm a memory is correct.",
224
- args: {
225
- id: tool.schema.string().describe("Memory ID (required)"),
226
- },
227
- async execute(args, ctx: ToolContext) {
228
- const adapter = await getMemoryAdapter();
229
- const result = await adapter.validate(args);
230
- return JSON.stringify(result, null, 2);
231
- },
232
- });
233
-
234
- /**
235
- * List memories
236
- */
237
- export const semantic_memory_list = tool({
238
- description: "List all stored memories, optionally filtered by collection.",
239
- args: {
240
- collection: tool.schema
241
- .string()
242
- .optional()
243
- .describe("Filter by collection name"),
244
- },
245
- async execute(args, ctx: ToolContext) {
246
- const adapter = await getMemoryAdapter();
247
- const memories = await adapter.list(args);
248
- return JSON.stringify(memories, null, 2);
249
- },
250
- });
251
-
252
- /**
253
- * Get memory statistics
254
- */
255
- export const semantic_memory_stats = tool({
256
- description: "Get statistics about stored memories and embeddings.",
257
- args: {},
258
- async execute(args, ctx: ToolContext) {
259
- const adapter = await getMemoryAdapter();
260
- const stats = await adapter.stats();
261
- return JSON.stringify(stats, null, 2);
262
- },
263
- });
264
-
265
- /**
266
- * Check Ollama health
267
- */
268
- export const semantic_memory_check = tool({
269
- description:
270
- "Check if Ollama is running and available for embedding generation.",
271
- args: {},
272
- async execute(args, ctx: ToolContext) {
273
- const adapter = await getMemoryAdapter();
274
- const health = await adapter.checkHealth();
275
- return JSON.stringify(health, null, 2);
276
- },
277
- });
278
-
279
- /**
280
- * Smart upsert - ADD, UPDATE, DELETE, or NOOP based on existing memories
281
- */
282
- export const semantic_memory_upsert = tool({
283
- description:
284
- "Smart memory storage that decides whether to ADD, UPDATE, DELETE, or skip (NOOP) based on existing memories. Uses LLM to detect duplicates, refinements, and contradictions. Auto-generates tags, links, and entities when enabled.",
285
- args: {
286
- information: tool.schema
287
- .string()
288
- .describe("The information to store (required)"),
289
- collection: tool.schema
290
- .string()
291
- .optional()
292
- .describe("Collection name (defaults to 'default')"),
293
- tags: tool.schema
294
- .string()
295
- .optional()
296
- .describe("Comma-separated tags (e.g., 'auth,tokens,oauth')"),
297
- metadata: tool.schema
298
- .string()
299
- .optional()
300
- .describe("JSON string with additional metadata"),
301
- confidence: tool.schema
302
- .number()
303
- .optional()
304
- .describe("Confidence level (0.0-1.0) affecting decay rate. Higher = slower decay. Default 0.7"),
305
- autoTag: tool.schema
306
- .boolean()
307
- .optional()
308
- .describe("Auto-generate tags using LLM. Default true"),
309
- autoLink: tool.schema
310
- .boolean()
311
- .optional()
312
- .describe("Auto-link to related memories. Default true"),
313
- extractEntities: tool.schema
314
- .boolean()
315
- .optional()
316
- .describe("Extract entities (people, places, technologies). Default false"),
317
- },
318
- async execute(args, ctx: ToolContext) {
319
- const adapter = await getMemoryAdapter();
320
- const result = await adapter.upsert(args);
321
- return JSON.stringify(result, null, 2);
322
- },
323
- });
324
-
325
- // ============================================================================
326
- // Tool Registry
327
- // ============================================================================
328
-
329
- /**
330
- * All semantic memory tools
331
- *
332
- * Register these in the plugin with spread operator: { ...memoryTools }
333
- */
334
- export const memoryTools = {
335
- "semantic-memory_store": semantic_memory_store,
336
- "semantic-memory_find": semantic_memory_find,
337
- "semantic-memory_get": semantic_memory_get,
338
- "semantic-memory_remove": semantic_memory_remove,
339
- "semantic-memory_validate": semantic_memory_validate,
340
- "semantic-memory_list": semantic_memory_list,
341
- "semantic-memory_stats": semantic_memory_stats,
342
- "semantic-memory_check": semantic_memory_check,
343
- "semantic-memory_upsert": semantic_memory_upsert,
344
- } as const;