opencode-swarm-plugin 0.30.0 → 0.30.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 (40) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/CHANGELOG.md +93 -0
  3. package/README.md +3 -6
  4. package/bin/swarm.ts +151 -22
  5. package/dist/hive.d.ts.map +1 -1
  6. package/dist/index.d.ts +94 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +18826 -3467
  9. package/dist/memory-tools.d.ts +209 -0
  10. package/dist/memory-tools.d.ts.map +1 -0
  11. package/dist/memory.d.ts +124 -0
  12. package/dist/memory.d.ts.map +1 -0
  13. package/dist/plugin.js +18766 -3418
  14. package/dist/schemas/index.d.ts +7 -0
  15. package/dist/schemas/index.d.ts.map +1 -1
  16. package/dist/schemas/worker-handoff.d.ts +78 -0
  17. package/dist/schemas/worker-handoff.d.ts.map +1 -0
  18. package/dist/swarm-orchestrate.d.ts +50 -0
  19. package/dist/swarm-orchestrate.d.ts.map +1 -1
  20. package/dist/swarm-prompts.d.ts +1 -1
  21. package/dist/swarm-prompts.d.ts.map +1 -1
  22. package/dist/swarm-review.d.ts +4 -0
  23. package/dist/swarm-review.d.ts.map +1 -1
  24. package/docs/planning/ADR-008-worker-handoff-protocol.md +293 -0
  25. package/package.json +4 -2
  26. package/src/hive.integration.test.ts +114 -0
  27. package/src/hive.ts +33 -22
  28. package/src/index.ts +38 -3
  29. package/src/memory-tools.test.ts +111 -0
  30. package/src/memory-tools.ts +273 -0
  31. package/src/memory.integration.test.ts +266 -0
  32. package/src/memory.test.ts +334 -0
  33. package/src/memory.ts +441 -0
  34. package/src/schemas/index.ts +18 -0
  35. package/src/schemas/worker-handoff.test.ts +271 -0
  36. package/src/schemas/worker-handoff.ts +131 -0
  37. package/src/swarm-orchestrate.ts +262 -24
  38. package/src/swarm-prompts.ts +48 -5
  39. package/src/swarm-review.ts +7 -0
  40. package/src/swarm.integration.test.ts +386 -9
@@ -0,0 +1,209 @@
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
+ import { createMemoryAdapter, type MemoryAdapter, type StoreArgs, type FindArgs, type IdArgs, type ListArgs, type StoreResult, type FindResult, type StatsResult, type HealthResult, type OperationResult } from "./memory";
16
+ export type { MemoryAdapter, StoreArgs, FindArgs, IdArgs, ListArgs, StoreResult, FindResult, StatsResult, HealthResult, OperationResult, };
17
+ /**
18
+ * Reset adapter cache (for testing)
19
+ */
20
+ export declare function resetMemoryCache(): void;
21
+ export { createMemoryAdapter };
22
+ /**
23
+ * Store a memory with semantic embedding
24
+ */
25
+ export declare const semantic_memory_store: {
26
+ description: string;
27
+ args: {
28
+ information: import("zod").ZodString;
29
+ collection: import("zod").ZodOptional<import("zod").ZodString>;
30
+ tags: import("zod").ZodOptional<import("zod").ZodString>;
31
+ metadata: import("zod").ZodOptional<import("zod").ZodString>;
32
+ };
33
+ execute(args: {
34
+ information: string;
35
+ collection?: string | undefined;
36
+ tags?: string | undefined;
37
+ metadata?: string | undefined;
38
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
39
+ };
40
+ /**
41
+ * Find memories by semantic similarity or full-text search
42
+ */
43
+ export declare const semantic_memory_find: {
44
+ description: string;
45
+ args: {
46
+ query: import("zod").ZodString;
47
+ limit: import("zod").ZodOptional<import("zod").ZodNumber>;
48
+ collection: import("zod").ZodOptional<import("zod").ZodString>;
49
+ expand: import("zod").ZodOptional<import("zod").ZodBoolean>;
50
+ fts: import("zod").ZodOptional<import("zod").ZodBoolean>;
51
+ };
52
+ execute(args: {
53
+ query: string;
54
+ limit?: number | undefined;
55
+ collection?: string | undefined;
56
+ expand?: boolean | undefined;
57
+ fts?: boolean | undefined;
58
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
59
+ };
60
+ /**
61
+ * Get a single memory by ID
62
+ */
63
+ export declare const semantic_memory_get: {
64
+ description: string;
65
+ args: {
66
+ id: import("zod").ZodString;
67
+ };
68
+ execute(args: {
69
+ id: string;
70
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
71
+ };
72
+ /**
73
+ * Remove a memory
74
+ */
75
+ export declare const semantic_memory_remove: {
76
+ description: string;
77
+ args: {
78
+ id: import("zod").ZodString;
79
+ };
80
+ execute(args: {
81
+ id: string;
82
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
83
+ };
84
+ /**
85
+ * Validate a memory (reset decay timer)
86
+ */
87
+ export declare const semantic_memory_validate: {
88
+ description: string;
89
+ args: {
90
+ id: import("zod").ZodString;
91
+ };
92
+ execute(args: {
93
+ id: string;
94
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
95
+ };
96
+ /**
97
+ * List memories
98
+ */
99
+ export declare const semantic_memory_list: {
100
+ description: string;
101
+ args: {
102
+ collection: import("zod").ZodOptional<import("zod").ZodString>;
103
+ };
104
+ execute(args: {
105
+ collection?: string | undefined;
106
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
107
+ };
108
+ /**
109
+ * Get memory statistics
110
+ */
111
+ export declare const semantic_memory_stats: {
112
+ description: string;
113
+ args: {};
114
+ execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
115
+ };
116
+ /**
117
+ * Check Ollama health
118
+ */
119
+ export declare const semantic_memory_check: {
120
+ description: string;
121
+ args: {};
122
+ execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
123
+ };
124
+ /**
125
+ * All semantic memory tools
126
+ *
127
+ * Register these in the plugin with spread operator: { ...memoryTools }
128
+ */
129
+ export declare const memoryTools: {
130
+ readonly "semantic-memory_store": {
131
+ description: string;
132
+ args: {
133
+ information: import("zod").ZodString;
134
+ collection: import("zod").ZodOptional<import("zod").ZodString>;
135
+ tags: import("zod").ZodOptional<import("zod").ZodString>;
136
+ metadata: import("zod").ZodOptional<import("zod").ZodString>;
137
+ };
138
+ execute(args: {
139
+ information: string;
140
+ collection?: string | undefined;
141
+ tags?: string | undefined;
142
+ metadata?: string | undefined;
143
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
144
+ };
145
+ readonly "semantic-memory_find": {
146
+ description: string;
147
+ args: {
148
+ query: import("zod").ZodString;
149
+ limit: import("zod").ZodOptional<import("zod").ZodNumber>;
150
+ collection: import("zod").ZodOptional<import("zod").ZodString>;
151
+ expand: import("zod").ZodOptional<import("zod").ZodBoolean>;
152
+ fts: import("zod").ZodOptional<import("zod").ZodBoolean>;
153
+ };
154
+ execute(args: {
155
+ query: string;
156
+ limit?: number | undefined;
157
+ collection?: string | undefined;
158
+ expand?: boolean | undefined;
159
+ fts?: boolean | undefined;
160
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
161
+ };
162
+ readonly "semantic-memory_get": {
163
+ description: string;
164
+ args: {
165
+ id: import("zod").ZodString;
166
+ };
167
+ execute(args: {
168
+ id: string;
169
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
170
+ };
171
+ readonly "semantic-memory_remove": {
172
+ description: string;
173
+ args: {
174
+ id: import("zod").ZodString;
175
+ };
176
+ execute(args: {
177
+ id: string;
178
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
179
+ };
180
+ readonly "semantic-memory_validate": {
181
+ description: string;
182
+ args: {
183
+ id: import("zod").ZodString;
184
+ };
185
+ execute(args: {
186
+ id: string;
187
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
188
+ };
189
+ readonly "semantic-memory_list": {
190
+ description: string;
191
+ args: {
192
+ collection: import("zod").ZodOptional<import("zod").ZodString>;
193
+ };
194
+ execute(args: {
195
+ collection?: string | undefined;
196
+ }, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
197
+ };
198
+ readonly "semantic-memory_stats": {
199
+ description: string;
200
+ args: {};
201
+ execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
202
+ };
203
+ readonly "semantic-memory_check": {
204
+ description: string;
205
+ args: {};
206
+ execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
207
+ };
208
+ };
209
+ //# sourceMappingURL=memory-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-tools.d.ts","sourceRoot":"","sources":["../src/memory-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EACN,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,MAAM,UAAU,CAAC;AAGlB,YAAY,EACX,aAAa,EACb,SAAS,EACT,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,eAAe,GACf,CAAC;AA2CF;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC;AAGD,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAM/B;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;CAyBhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;CA2B/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;CAU9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;CAUjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;CAWnC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;CAa/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;CAQhC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;CAShC,CAAC;AAMH;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CASd,CAAC"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Memory Module - Semantic Memory Adapter
3
+ *
4
+ * Provides a high-level adapter around swarm-mail's MemoryStore + Ollama.
5
+ * Used by semantic-memory_* tools in the plugin.
6
+ *
7
+ * ## Design
8
+ * - Wraps MemoryStore (vector storage) + Ollama (embeddings)
9
+ * - Handles ID generation, metadata parsing, error handling
10
+ * - Tool-friendly API (string inputs/outputs, no Effect-TS in signatures)
11
+ *
12
+ * ## Usage
13
+ * ```typescript
14
+ * const adapter = await createMemoryAdapter(swarmMail.db);
15
+ *
16
+ * // Store memory
17
+ * const { id } = await adapter.store({
18
+ * information: "OAuth tokens need 5min buffer",
19
+ * tags: "auth,tokens",
20
+ * });
21
+ *
22
+ * // Search memories
23
+ * const results = await adapter.find({
24
+ * query: "token refresh",
25
+ * limit: 5,
26
+ * });
27
+ * ```
28
+ */
29
+ import { type DatabaseAdapter, type Memory } from "swarm-mail";
30
+ /**
31
+ * Reset migration check flag (for testing)
32
+ * @internal
33
+ */
34
+ export declare function resetMigrationCheck(): void;
35
+ /** Arguments for store operation */
36
+ export interface StoreArgs {
37
+ readonly information: string;
38
+ readonly collection?: string;
39
+ readonly tags?: string;
40
+ readonly metadata?: string;
41
+ }
42
+ /** Arguments for find operation */
43
+ export interface FindArgs {
44
+ readonly query: string;
45
+ readonly limit?: number;
46
+ readonly collection?: string;
47
+ readonly expand?: boolean;
48
+ readonly fts?: boolean;
49
+ }
50
+ /** Arguments for get/remove/validate operations */
51
+ export interface IdArgs {
52
+ readonly id: string;
53
+ }
54
+ /** Arguments for list operation */
55
+ export interface ListArgs {
56
+ readonly collection?: string;
57
+ }
58
+ /** Result from store operation */
59
+ export interface StoreResult {
60
+ readonly id: string;
61
+ readonly message: string;
62
+ }
63
+ /** Result from find operation */
64
+ export interface FindResult {
65
+ readonly results: Array<{
66
+ readonly id: string;
67
+ readonly content: string;
68
+ readonly score: number;
69
+ readonly collection: string;
70
+ readonly metadata: Record<string, unknown>;
71
+ readonly createdAt: string;
72
+ }>;
73
+ readonly count: number;
74
+ }
75
+ /** Result from stats operation */
76
+ export interface StatsResult {
77
+ readonly memories: number;
78
+ readonly embeddings: number;
79
+ }
80
+ /** Result from health check */
81
+ export interface HealthResult {
82
+ readonly ollama: boolean;
83
+ readonly message?: string;
84
+ }
85
+ /** Result from validate/remove operations */
86
+ export interface OperationResult {
87
+ readonly success: boolean;
88
+ readonly message?: string;
89
+ }
90
+ /**
91
+ * Memory Adapter Interface
92
+ *
93
+ * High-level API for semantic memory operations.
94
+ */
95
+ export interface MemoryAdapter {
96
+ readonly store: (args: StoreArgs) => Promise<StoreResult>;
97
+ readonly find: (args: FindArgs) => Promise<FindResult>;
98
+ readonly get: (args: IdArgs) => Promise<Memory | null>;
99
+ readonly remove: (args: IdArgs) => Promise<OperationResult>;
100
+ readonly validate: (args: IdArgs) => Promise<OperationResult>;
101
+ readonly list: (args: ListArgs) => Promise<Memory[]>;
102
+ readonly stats: () => Promise<StatsResult>;
103
+ readonly checkHealth: () => Promise<HealthResult>;
104
+ }
105
+ /**
106
+ * Create Memory Adapter
107
+ *
108
+ * @param db - DatabaseAdapter (from SwarmMail)
109
+ * @returns Memory adapter with high-level operations
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * import { getSwarmMail } from 'swarm-mail';
114
+ * import { createMemoryAdapter } from './memory';
115
+ *
116
+ * const swarmMail = await getSwarmMail('/path/to/project');
117
+ * const adapter = await createMemoryAdapter(swarmMail.db);
118
+ *
119
+ * await adapter.store({ information: "Learning X" });
120
+ * const results = await adapter.find({ query: "X" });
121
+ * ```
122
+ */
123
+ export declare function createMemoryAdapter(db: DatabaseAdapter): Promise<MemoryAdapter>;
124
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EACN,KAAK,eAAe,EAKpB,KAAK,MAAM,EAIX,MAAM,YAAY,CAAC;AAYpB;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAMD,oCAAoC;AACpC,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,mDAAmD;AACnD,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACpB;AAED,mCAAmC;AACnC,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,kCAAkC;AAClC,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CA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