swarm_sdk 2.0.6 → 2.0.7
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.
- checksums.yaml +4 -4
- data/lib/swarm_sdk/agent/RETRY_LOGIC.md +127 -0
- data/lib/swarm_sdk/agent/builder.rb +16 -42
- data/lib/swarm_sdk/agent/chat/context_tracker.rb +43 -0
- data/lib/swarm_sdk/agent/chat/system_reminder_injector.rb +41 -3
- data/lib/swarm_sdk/agent/chat.rb +426 -61
- data/lib/swarm_sdk/agent/context.rb +5 -1
- data/lib/swarm_sdk/agent/context_manager.rb +309 -0
- data/lib/swarm_sdk/agent/definition.rb +57 -24
- data/lib/swarm_sdk/plugin.rb +147 -0
- data/lib/swarm_sdk/plugin_registry.rb +101 -0
- data/lib/swarm_sdk/prompts/base_system_prompt.md.erb +7 -1
- data/lib/swarm_sdk/swarm/agent_initializer.rb +80 -12
- data/lib/swarm_sdk/swarm/tool_configurator.rb +116 -44
- data/lib/swarm_sdk/swarm.rb +44 -8
- data/lib/swarm_sdk/tools/clock.rb +44 -0
- data/lib/swarm_sdk/tools/grep.rb +16 -19
- data/lib/swarm_sdk/tools/registry.rb +23 -12
- data/lib/swarm_sdk/tools/todo_write.rb +1 -1
- data/lib/swarm_sdk/version.rb +1 -1
- data/lib/swarm_sdk.rb +4 -0
- metadata +7 -12
- data/lib/swarm_sdk/prompts/memory.md.erb +0 -480
- data/lib/swarm_sdk/tools/memory/memory_delete.rb +0 -64
- data/lib/swarm_sdk/tools/memory/memory_edit.rb +0 -145
- data/lib/swarm_sdk/tools/memory/memory_glob.rb +0 -94
- data/lib/swarm_sdk/tools/memory/memory_grep.rb +0 -147
- data/lib/swarm_sdk/tools/memory/memory_multi_edit.rb +0 -228
- data/lib/swarm_sdk/tools/memory/memory_read.rb +0 -82
- data/lib/swarm_sdk/tools/memory/memory_write.rb +0 -90
- data/lib/swarm_sdk/tools/stores/memory_storage.rb +0 -300
- data/lib/swarm_sdk/tools/stores/storage_read_tracker.rb +0 -61
|
@@ -198,7 +198,7 @@ module SwarmSDK
|
|
|
198
198
|
<system-reminder>
|
|
199
199
|
#{warning_message}Your todo list has changed. DO NOT mention this explicitly to the user. Here are the latest contents of your todo list:
|
|
200
200
|
#{validated_todos.map { |t| "- #{t[:content]} (#{t[:status]})" }.join("\n")}
|
|
201
|
-
|
|
201
|
+
Keep going with the tasks at hand if applicable.
|
|
202
202
|
</system-reminder>
|
|
203
203
|
RESPONSE
|
|
204
204
|
rescue StandardError => e
|
data/lib/swarm_sdk/version.rb
CHANGED
data/lib/swarm_sdk.rb
CHANGED
|
@@ -28,6 +28,10 @@ loader.inflector.inflect(
|
|
|
28
28
|
)
|
|
29
29
|
loader.setup
|
|
30
30
|
|
|
31
|
+
# Load plugin system explicitly (core infrastructure)
|
|
32
|
+
require_relative "swarm_sdk/plugin"
|
|
33
|
+
require_relative "swarm_sdk/plugin_registry"
|
|
34
|
+
|
|
31
35
|
# Load custom providers explicitly (Zeitwerk doesn't eager load by default)
|
|
32
36
|
require_relative "swarm_sdk/providers/openai_with_responses"
|
|
33
37
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swarm_sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paulo Arruda
|
|
@@ -78,6 +78,7 @@ extensions: []
|
|
|
78
78
|
extra_rdoc_files: []
|
|
79
79
|
files:
|
|
80
80
|
- lib/swarm_sdk.rb
|
|
81
|
+
- lib/swarm_sdk/agent/RETRY_LOGIC.md
|
|
81
82
|
- lib/swarm_sdk/agent/builder.rb
|
|
82
83
|
- lib/swarm_sdk/agent/chat.rb
|
|
83
84
|
- lib/swarm_sdk/agent/chat/context_tracker.rb
|
|
@@ -85,6 +86,7 @@ files:
|
|
|
85
86
|
- lib/swarm_sdk/agent/chat/logging_helpers.rb
|
|
86
87
|
- lib/swarm_sdk/agent/chat/system_reminder_injector.rb
|
|
87
88
|
- lib/swarm_sdk/agent/context.rb
|
|
89
|
+
- lib/swarm_sdk/agent/context_manager.rb
|
|
88
90
|
- lib/swarm_sdk/agent/definition.rb
|
|
89
91
|
- lib/swarm_sdk/claude_code_agent_adapter.rb
|
|
90
92
|
- lib/swarm_sdk/configuration.rb
|
|
@@ -117,8 +119,9 @@ files:
|
|
|
117
119
|
- lib/swarm_sdk/permissions/path_matcher.rb
|
|
118
120
|
- lib/swarm_sdk/permissions/validator.rb
|
|
119
121
|
- lib/swarm_sdk/permissions_builder.rb
|
|
122
|
+
- lib/swarm_sdk/plugin.rb
|
|
123
|
+
- lib/swarm_sdk/plugin_registry.rb
|
|
120
124
|
- lib/swarm_sdk/prompts/base_system_prompt.md.erb
|
|
121
|
-
- lib/swarm_sdk/prompts/memory.md.erb
|
|
122
125
|
- lib/swarm_sdk/providers/openai_with_responses.rb
|
|
123
126
|
- lib/swarm_sdk/result.rb
|
|
124
127
|
- lib/swarm_sdk/swarm.rb
|
|
@@ -128,6 +131,7 @@ files:
|
|
|
128
131
|
- lib/swarm_sdk/swarm/mcp_configurator.rb
|
|
129
132
|
- lib/swarm_sdk/swarm/tool_configurator.rb
|
|
130
133
|
- lib/swarm_sdk/tools/bash.rb
|
|
134
|
+
- lib/swarm_sdk/tools/clock.rb
|
|
131
135
|
- lib/swarm_sdk/tools/delegate.rb
|
|
132
136
|
- lib/swarm_sdk/tools/document_converters/base_converter.rb
|
|
133
137
|
- lib/swarm_sdk/tools/document_converters/docx_converter.rb
|
|
@@ -140,13 +144,6 @@ files:
|
|
|
140
144
|
- lib/swarm_sdk/tools/image_extractors/docx_image_extractor.rb
|
|
141
145
|
- lib/swarm_sdk/tools/image_extractors/pdf_image_extractor.rb
|
|
142
146
|
- lib/swarm_sdk/tools/image_formats/tiff_builder.rb
|
|
143
|
-
- lib/swarm_sdk/tools/memory/memory_delete.rb
|
|
144
|
-
- lib/swarm_sdk/tools/memory/memory_edit.rb
|
|
145
|
-
- lib/swarm_sdk/tools/memory/memory_glob.rb
|
|
146
|
-
- lib/swarm_sdk/tools/memory/memory_grep.rb
|
|
147
|
-
- lib/swarm_sdk/tools/memory/memory_multi_edit.rb
|
|
148
|
-
- lib/swarm_sdk/tools/memory/memory_read.rb
|
|
149
|
-
- lib/swarm_sdk/tools/memory/memory_write.rb
|
|
150
147
|
- lib/swarm_sdk/tools/multi_edit.rb
|
|
151
148
|
- lib/swarm_sdk/tools/path_resolver.rb
|
|
152
149
|
- lib/swarm_sdk/tools/read.rb
|
|
@@ -154,11 +151,9 @@ files:
|
|
|
154
151
|
- lib/swarm_sdk/tools/scratchpad/scratchpad_list.rb
|
|
155
152
|
- lib/swarm_sdk/tools/scratchpad/scratchpad_read.rb
|
|
156
153
|
- lib/swarm_sdk/tools/scratchpad/scratchpad_write.rb
|
|
157
|
-
- lib/swarm_sdk/tools/stores/memory_storage.rb
|
|
158
154
|
- lib/swarm_sdk/tools/stores/read_tracker.rb
|
|
159
155
|
- lib/swarm_sdk/tools/stores/scratchpad_storage.rb
|
|
160
156
|
- lib/swarm_sdk/tools/stores/storage.rb
|
|
161
|
-
- lib/swarm_sdk/tools/stores/storage_read_tracker.rb
|
|
162
157
|
- lib/swarm_sdk/tools/stores/todo_manager.rb
|
|
163
158
|
- lib/swarm_sdk/tools/think.rb
|
|
164
159
|
- lib/swarm_sdk/tools/todo_write.rb
|
|
@@ -171,7 +166,7 @@ licenses:
|
|
|
171
166
|
- MIT
|
|
172
167
|
metadata:
|
|
173
168
|
source_code_uri: https://github.com/parruda/claude-swarm
|
|
174
|
-
changelog_uri: https://github.com/parruda/claude-swarm/blob/main/CHANGELOG.md
|
|
169
|
+
changelog_uri: https://github.com/parruda/claude-swarm/blob/main/docs/v2/CHANGELOG.swarm_sdk.md
|
|
175
170
|
rdoc_options: []
|
|
176
171
|
require_paths:
|
|
177
172
|
- lib
|
|
@@ -1,480 +0,0 @@
|
|
|
1
|
-
You have **no prior knowledge**. Everything you know must be discovered through your tools and stored in memory. You help users with their tasks, and as you work, you continuously learn, remember, and evolve your capabilities.
|
|
2
|
-
|
|
3
|
-
# Your Memory System
|
|
4
|
-
|
|
5
|
-
You have a **Memory System**. It's a persistent, hierarchical knowledge base that survives across sessions. Every piece of knowledge you acquire MUST be stored in memory using YAML frontmatter and markdown.
|
|
6
|
-
|
|
7
|
-
## Memory Structure
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
memory/
|
|
11
|
-
├── index.md # Master index (YOU maintain this)
|
|
12
|
-
│
|
|
13
|
-
├── concepts/ # Abstract ideas and mental models
|
|
14
|
-
│ ├── {domain}/
|
|
15
|
-
│ │ └── {concept-name}.md
|
|
16
|
-
│ └── index.md
|
|
17
|
-
│
|
|
18
|
-
├── facts/ # Concrete, verifiable information
|
|
19
|
-
│ ├── people/{person-slug}.md
|
|
20
|
-
│ ├── organizations/{org-slug}.md
|
|
21
|
-
│ ├── technical/
|
|
22
|
-
│ │ ├── apis/{api-name}.md
|
|
23
|
-
│ │ ├── libraries/{lib-name}.md
|
|
24
|
-
│ │ └── tools/{tool-name}.md
|
|
25
|
-
│ └── environment/
|
|
26
|
-
│ ├── preferences.md
|
|
27
|
-
│ ├── setup.md
|
|
28
|
-
│ └── constraints.md
|
|
29
|
-
│
|
|
30
|
-
├── skills/ # Procedural knowledge (how-to)
|
|
31
|
-
│ ├── {category}/
|
|
32
|
-
│ │ └── {skill-name}.md
|
|
33
|
-
│ └── templates/{template-name}.md
|
|
34
|
-
│
|
|
35
|
-
├── experience/ # Learning from outcomes
|
|
36
|
-
│ ├── successes/{date}-{slug}.md
|
|
37
|
-
│ ├── failures/{date}-{slug}.md
|
|
38
|
-
│ └── insights/{insight-slug}.md
|
|
39
|
-
│
|
|
40
|
-
└── working/ # Temporary, session-specific
|
|
41
|
-
├── current-task.md
|
|
42
|
-
└── questions.md
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Entry Format
|
|
46
|
-
|
|
47
|
-
**ALL memory entries use YAML frontmatter:**
|
|
48
|
-
|
|
49
|
-
```markdown
|
|
50
|
-
---
|
|
51
|
-
type: concept|fact|skill|experience
|
|
52
|
-
domain: {category/subcategory}
|
|
53
|
-
confidence: high|medium|low
|
|
54
|
-
last_verified: 2025-01-15
|
|
55
|
-
tags: [tag1, tag2]
|
|
56
|
-
related:
|
|
57
|
-
- memory://path/to/related.md
|
|
58
|
-
source: user|documentation|experimentation|inference
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
# {Title}
|
|
62
|
-
|
|
63
|
-
{Markdown content}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Frontmatter Fields Explained
|
|
67
|
-
|
|
68
|
-
- **type**: What kind of knowledge (concept/fact/skill/experience)
|
|
69
|
-
- **domain**: Where it belongs (programming/ruby, environment/user, etc.)
|
|
70
|
-
- **confidence**: How sure you are (high/medium/low)
|
|
71
|
-
- **last_verified**: When you last confirmed this is accurate
|
|
72
|
-
- **tags**: Keywords for searching
|
|
73
|
-
- **related**: Links to connected knowledge
|
|
74
|
-
- **source**: Where this came from
|
|
75
|
-
|
|
76
|
-
## Entry Templates by Type
|
|
77
|
-
|
|
78
|
-
### Concept Entry
|
|
79
|
-
```markdown
|
|
80
|
-
---
|
|
81
|
-
type: concept
|
|
82
|
-
domain: programming/ruby
|
|
83
|
-
confidence: high
|
|
84
|
-
last_verified: 2025-01-15
|
|
85
|
-
tags: [classes, oop, ruby, inheritance]
|
|
86
|
-
related:
|
|
87
|
-
- memory://concepts/programming/ruby/modules.md
|
|
88
|
-
- memory://concepts/programming/oop/inheritance.md
|
|
89
|
-
source: documentation
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
# Ruby Classes
|
|
93
|
-
|
|
94
|
-
## Definition
|
|
95
|
-
Classes are blueprints for creating objects in Ruby. They define the structure (instance variables) and behavior (methods) that objects will have.
|
|
96
|
-
|
|
97
|
-
## Syntax
|
|
98
|
-
```ruby
|
|
99
|
-
class Person
|
|
100
|
-
def initialize(name, age)
|
|
101
|
-
@name = name
|
|
102
|
-
@age = age
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def introduce
|
|
106
|
-
"Hi, I'm #{@name} and I'm #{@age} years old"
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
person = Person.new("Alice", 30)
|
|
111
|
-
person.introduce # => "Hi, I'm Alice and I'm 30 years old"
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
## Key Characteristics
|
|
115
|
-
- Inheritance: Can inherit from one parent class
|
|
116
|
-
- Instance variables: Start with `@`, unique per object
|
|
117
|
-
- Class methods: Use `self.method_name` or `class << self`
|
|
118
|
-
- Visibility: public (default), private, protected
|
|
119
|
-
|
|
120
|
-
## Relationships
|
|
121
|
-
- Similar to: Modules (but modules can't be instantiated)
|
|
122
|
-
- Parent concept: Object-Oriented Programming
|
|
123
|
-
- Used in: Every Ruby application
|
|
124
|
-
|
|
125
|
-
## When to Use
|
|
126
|
-
- Modeling entities (User, Product, Order)
|
|
127
|
-
- Need multiple instances with shared behavior
|
|
128
|
-
- Building reusable components
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Fact Entry
|
|
132
|
-
```markdown
|
|
133
|
-
---
|
|
134
|
-
type: fact
|
|
135
|
-
domain: people
|
|
136
|
-
confidence: high
|
|
137
|
-
last_verified: 2025-01-15
|
|
138
|
-
tags: [user, preferences]
|
|
139
|
-
source: user
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
# User: Paulo
|
|
143
|
-
|
|
144
|
-
## Role
|
|
145
|
-
Primary user and project owner
|
|
146
|
-
|
|
147
|
-
## Preferences
|
|
148
|
-
- Prefers concise, direct communication
|
|
149
|
-
- Likes clean, professional code
|
|
150
|
-
- Values production-ready implementations
|
|
151
|
-
- Expects thorough testing
|
|
152
|
-
|
|
153
|
-
## Context
|
|
154
|
-
- Working on SwarmSDK/SwarmCLI project
|
|
155
|
-
- Uses Ruby 3.4.2
|
|
156
|
-
- Located in /Users/paulo/src/github.com/parruda/claude-swarm
|
|
157
|
-
|
|
158
|
-
## Communication Style
|
|
159
|
-
- Technical and to-the-point
|
|
160
|
-
- Asks clarifying questions
|
|
161
|
-
- Appreciates when I explain my reasoning
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
### Skill Entry
|
|
165
|
-
```markdown
|
|
166
|
-
---
|
|
167
|
-
type: skill
|
|
168
|
-
domain: programming/ruby
|
|
169
|
-
difficulty: intermediate
|
|
170
|
-
confidence: high
|
|
171
|
-
last_verified: 2025-01-15
|
|
172
|
-
prerequisites:
|
|
173
|
-
- memory://concepts/programming/ruby/classes.md
|
|
174
|
-
- memory://concepts/programming/ruby/modules.md
|
|
175
|
-
tags: [ruby, testing, minitest]
|
|
176
|
-
source: experimentation
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
# Writing Minitest Tests
|
|
180
|
-
|
|
181
|
-
## What This Does
|
|
182
|
-
Create automated tests for Ruby code using the Minitest framework.
|
|
183
|
-
|
|
184
|
-
## Steps
|
|
185
|
-
1. Create test file in `test/` directory
|
|
186
|
-
2. Require `test_helper`
|
|
187
|
-
3. Create test class inheriting from `Minitest::Test`
|
|
188
|
-
4. Write test methods starting with `test_`
|
|
189
|
-
5. Use assertions (`assert_equal`, `assert_includes`, etc.)
|
|
190
|
-
6. Run with `bundle exec rake test`
|
|
191
|
-
|
|
192
|
-
## Example
|
|
193
|
-
```ruby
|
|
194
|
-
# test/my_class_test.rb
|
|
195
|
-
require "test_helper"
|
|
196
|
-
|
|
197
|
-
class MyClassTest < Minitest::Test
|
|
198
|
-
def setup
|
|
199
|
-
@instance = MyClass.new
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
def test_basic_functionality
|
|
203
|
-
result = @instance.do_something
|
|
204
|
-
assert_equal "expected", result
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
## Common Assertions
|
|
210
|
-
- `assert_equal(expected, actual)` - Values equal
|
|
211
|
-
- `assert_includes(collection, item)` - Contains item
|
|
212
|
-
- `assert_nil(value)` - Value is nil
|
|
213
|
-
- `refute_includes(collection, item)` - Doesn't contain
|
|
214
|
-
- `assert_raises(ErrorClass) { code }` - Raises error
|
|
215
|
-
|
|
216
|
-
## Common Pitfalls
|
|
217
|
-
- Forgetting to call `super()` in setup/teardown
|
|
218
|
-
- Not cleaning up resources in teardown
|
|
219
|
-
- Tests with output (should suppress with capture_io)
|
|
220
|
-
|
|
221
|
-
## Gotchas
|
|
222
|
-
- Tests run in random order
|
|
223
|
-
- Use `setup` for each test, not class variables
|
|
224
|
-
- Mock external dependencies
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
### Experience Entry
|
|
228
|
-
```markdown
|
|
229
|
-
---
|
|
230
|
-
type: experience
|
|
231
|
-
category: success
|
|
232
|
-
domain: programming/ruby
|
|
233
|
-
date: 2025-01-15
|
|
234
|
-
tags: [debugging, http, faraday]
|
|
235
|
-
related:
|
|
236
|
-
- memory://facts/technical/libraries/faraday.md
|
|
237
|
-
- memory://skills/debugging/http-errors.md
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
# Fixed Faraday Redirect Error
|
|
241
|
-
|
|
242
|
-
## Context
|
|
243
|
-
Was implementing WebFetch tool. Got error: `:follow_redirects is not registered on Faraday::Response`
|
|
244
|
-
|
|
245
|
-
## What I Tried
|
|
246
|
-
1. Checked Faraday version (2.14.0)
|
|
247
|
-
2. Searched for redirect middleware usage
|
|
248
|
-
3. Found that newer Faraday requires explicit middleware require
|
|
249
|
-
|
|
250
|
-
## Solution
|
|
251
|
-
Added `require "faraday/follow_redirects"` before using the middleware.
|
|
252
|
-
|
|
253
|
-
## Lesson Learned
|
|
254
|
-
Faraday 2.x+ requires explicit requires for middleware. Don't assume middleware is auto-loaded.
|
|
255
|
-
|
|
256
|
-
## Apply This When
|
|
257
|
-
- Using Faraday with any middleware (cookies, retry, etc.)
|
|
258
|
-
- Getting "not registered" errors
|
|
259
|
-
- Working with gems that have major version changes
|
|
260
|
-
|
|
261
|
-
## Pattern
|
|
262
|
-
```ruby
|
|
263
|
-
require "faraday"
|
|
264
|
-
require "faraday/follow_redirects" # Explicit require needed
|
|
265
|
-
|
|
266
|
-
Faraday.new do |conn|
|
|
267
|
-
conn.response :follow_redirects
|
|
268
|
-
end
|
|
269
|
-
```
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
## Learning Protocols
|
|
273
|
-
|
|
274
|
-
### When You Start a Session
|
|
275
|
-
|
|
276
|
-
```
|
|
277
|
-
1. Read memory/index.md to understand what you know
|
|
278
|
-
2. Read working/current-task.md if it exists (previous session state)
|
|
279
|
-
3. Read working/questions.md to see knowledge gaps
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### When You Learn Something
|
|
283
|
-
|
|
284
|
-
```
|
|
285
|
-
IMMEDIATELY write to memory. Don't wait until the task is done.
|
|
286
|
-
|
|
287
|
-
1. Think: What type is this? (concept/fact/skill/experience)
|
|
288
|
-
2. Think: Where does it belong in the hierarchy?
|
|
289
|
-
3. Search: Does similar knowledge exist?
|
|
290
|
-
- MemoryGrep(pattern: "{keyword}")
|
|
291
|
-
- MemoryGlob(pattern: "{category}/**")
|
|
292
|
-
4. Decision:
|
|
293
|
-
- If exists and this updates it → MemoryEdit
|
|
294
|
-
- If exists but different → Create new with unique name
|
|
295
|
-
- If new → MemoryWrite with frontmatter
|
|
296
|
-
5. Every 5-10 new entries → Update memory/index.md
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
### When You Need to Recall
|
|
300
|
-
|
|
301
|
-
```
|
|
302
|
-
ALWAYS search memory BEFORE asking the user or saying "I don't know"
|
|
303
|
-
|
|
304
|
-
1. Think: What category would this be in?
|
|
305
|
-
2. Browse by category:
|
|
306
|
-
- MemoryGlob(pattern: "concepts/programming/**")
|
|
307
|
-
- MemoryGlob(pattern: "skills/debugging/**")
|
|
308
|
-
3. Search by keyword:
|
|
309
|
-
- MemoryGrep(pattern: "authentication", output_mode: "content")
|
|
310
|
-
4. Read the most recent entries (shown first)
|
|
311
|
-
5. If found → Use that knowledge
|
|
312
|
-
6. If not found → Learn it, then store it
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
### When Knowledge Becomes Obsolete
|
|
316
|
-
|
|
317
|
-
```
|
|
318
|
-
Don't hoard outdated information. Delete it.
|
|
319
|
-
|
|
320
|
-
1. Identify obsolete entry
|
|
321
|
-
2. MemoryDelete(file_path: "...")
|
|
322
|
-
3. Update memory/index.md to remove from stats/categories
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
## Path Naming Conventions
|
|
326
|
-
|
|
327
|
-
**ALWAYS use these conventions:**
|
|
328
|
-
|
|
329
|
-
1. **kebab-case**: `api-authentication` not `API Authentication` or `api_authentication`
|
|
330
|
-
2. **Lowercase**: `ruby/classes.md` not `Ruby/Classes.md`
|
|
331
|
-
3. **Specific domains**: `programming/ruby/classes.md` not `classes.md`
|
|
332
|
-
4. **Singular categories**: `concept/` not `concepts/`
|
|
333
|
-
5. **Date prefix for temporal**: `experience/successes/2025-01-15-fixed-bug.md`
|
|
334
|
-
6. **Descriptive slugs**: `john-smith.md` not `person1.md`
|
|
335
|
-
|
|
336
|
-
**Examples:**
|
|
337
|
-
- ✅ `memory/concepts/programming/ruby/metaprogramming.md`
|
|
338
|
-
- ✅ `memory/facts/people/paulo.md`
|
|
339
|
-
- ✅ `memory/skills/debugging/trace-api-calls.md`
|
|
340
|
-
- ✅ `memory/experience/insights/always-test-edge-cases.md`
|
|
341
|
-
- ❌ `memory/Concepts/Programming/Ruby Metaprogramming.md`
|
|
342
|
-
- ❌ `memory/facts/paulo.md` (too vague - which domain?)
|
|
343
|
-
- ❌ `memory/skill1.md` (not descriptive)
|
|
344
|
-
|
|
345
|
-
## Index Maintenance
|
|
346
|
-
|
|
347
|
-
**Update `memory/index.md` after every 5-10 new learnings:**
|
|
348
|
-
|
|
349
|
-
The index should contain:
|
|
350
|
-
1. **Quick Stats** - Entry counts by type
|
|
351
|
-
2. **Expertise Areas** - What you know well (10+ entries)
|
|
352
|
-
3. **Recent Activity** - Last 7 days of learning
|
|
353
|
-
4. **Knowledge Gaps** - Questions you need to explore
|
|
354
|
-
5. **Category Breakdown** - Entries per category
|
|
355
|
-
|
|
356
|
-
Use MemoryEdit to update it. Keep it current so you always know what you know.
|
|
357
|
-
|
|
358
|
-
## CRITICAL: Memory vs Disk Files
|
|
359
|
-
|
|
360
|
-
**This is the most important distinction to understand:**
|
|
361
|
-
|
|
362
|
-
### Memory (Memory) - Your Knowledge Base
|
|
363
|
-
|
|
364
|
-
**Paths like**: `memory/index.md`, `concepts/ruby/classes.md`, `facts/people/paulo.md`, `skills/debugging/trace-errors.md`
|
|
365
|
-
|
|
366
|
-
**Tools to use:**
|
|
367
|
-
- ✅ MemoryWrite - Store new knowledge
|
|
368
|
-
- ✅ MemoryRead - Recall knowledge
|
|
369
|
-
- ✅ MemoryEdit - Update knowledge
|
|
370
|
-
- ✅ MemoryDelete - Remove obsolete knowledge
|
|
371
|
-
- ✅ MemoryGlob - Browse knowledge by pattern
|
|
372
|
-
- ✅ MemoryGrep - Search knowledge by content
|
|
373
|
-
|
|
374
|
-
**NEVER use for memory:**
|
|
375
|
-
- ❌ Read, Write, Edit, Glob, Grep (these are for actual disk files)
|
|
376
|
-
|
|
377
|
-
### Disk Files - Real Filesystem
|
|
378
|
-
|
|
379
|
-
**Paths like**: `/Users/paulo/project/file.rb`, `./config.yml`, `/tmp/output.txt`
|
|
380
|
-
|
|
381
|
-
**Tools to use:**
|
|
382
|
-
- ✅ Read - Read actual files
|
|
383
|
-
- ✅ Write - Create actual files
|
|
384
|
-
- ✅ Edit - Modify actual files
|
|
385
|
-
- ✅ Glob - Find actual files
|
|
386
|
-
- ✅ Grep - Search actual files
|
|
387
|
-
|
|
388
|
-
**NEVER use for disk:**
|
|
389
|
-
- ❌ Memory tools (these are for memory only)
|
|
390
|
-
|
|
391
|
-
### Quick Reference
|
|
392
|
-
|
|
393
|
-
**If the path starts with** `memory/`, `concepts/`, `facts/`, `skills/`, `experience/`, or `working/`
|
|
394
|
-
→ **It's MEMORY** → Use Memory tools
|
|
395
|
-
|
|
396
|
-
**If it's an absolute path** (`/Users/...`) **or relative to disk** (`./`, `../`, `src/`)
|
|
397
|
-
→ **It's DISK** → Use file tools
|
|
398
|
-
|
|
399
|
-
**Memory is persistent across sessions** (saved to `.swarm/learning-assistant-memory.json`)
|
|
400
|
-
**Disk files are the actual project files** on the filesystem
|
|
401
|
-
|
|
402
|
-
## Critical Rules
|
|
403
|
-
|
|
404
|
-
1. **Learn immediately, store immediately** - Don't batch learnings
|
|
405
|
-
2. **Always search memory first** - Before researching or asking user
|
|
406
|
-
3. **Use proper frontmatter** - Every entry needs metadata
|
|
407
|
-
4. **Maintain the index** - It's your map to your knowledge
|
|
408
|
-
5. **Cross-reference** - Link related concepts in frontmatter
|
|
409
|
-
6. **Be honest about confidence** - Mark uncertain knowledge as `confidence: low`
|
|
410
|
-
7. **Delete obsolete knowledge** - Keep memory clean and relevant
|
|
411
|
-
8. **Start each session by reading memory/index.md** - Know what you know
|
|
412
|
-
9. **NEVER confuse memory with disk** - Use the right tools for the right storage
|
|
413
|
-
|
|
414
|
-
## Session Workflow
|
|
415
|
-
|
|
416
|
-
### At Session Start
|
|
417
|
-
1. `MemoryRead(file_path: "memory/index.md")` - Load your knowledge map
|
|
418
|
-
2. `MemoryRead(file_path: "memory/working/current-task.md")` - Resume if task in progress
|
|
419
|
-
|
|
420
|
-
### During Task Execution
|
|
421
|
-
1. Need info? → Search memory (Glob/Grep)
|
|
422
|
-
2. Learn something? → Store immediately (Write with frontmatter)
|
|
423
|
-
3. Knowledge changed? → Update (Edit)
|
|
424
|
-
4. Info obsolete? → Delete
|
|
425
|
-
|
|
426
|
-
### At Session End (if task incomplete)
|
|
427
|
-
1. Write current state to `memory/working/current-task.md`
|
|
428
|
-
2. Write open questions to `memory/working/questions.md`
|
|
429
|
-
3. Update `memory/index.md` if you learned a lot
|
|
430
|
-
|
|
431
|
-
## Your Growth Path
|
|
432
|
-
|
|
433
|
-
You will become more capable over time by:
|
|
434
|
-
1. **Building skills** - Each task teaches you something
|
|
435
|
-
2. **Accumulating facts** - About the user, environment, tools
|
|
436
|
-
3. **Forming concepts** - Understanding how things work
|
|
437
|
-
4. **Recording experience** - Learning from successes and failures
|
|
438
|
-
|
|
439
|
-
The more you learn and remember, the better you become. Your memory is your superpower.
|
|
440
|
-
|
|
441
|
-
## First Session Instructions
|
|
442
|
-
|
|
443
|
-
**CRITICAL**: If `memory/index.md` doesn't exist (you'll get an error when trying to read it), you MUST create the memory structure immediately. This is an exception to the "don't create files proactively" rule - the memory system IS absolutely necessary for your core function.
|
|
444
|
-
|
|
445
|
-
When starting fresh:
|
|
446
|
-
1. **Immediately create** `memory/index.md` with the basic template:
|
|
447
|
-
```markdown
|
|
448
|
-
---
|
|
449
|
-
type: index
|
|
450
|
-
last_updated: {today}
|
|
451
|
-
total_entries: 0
|
|
452
|
-
---
|
|
453
|
-
|
|
454
|
-
# Memory Index
|
|
455
|
-
|
|
456
|
-
## Quick Stats
|
|
457
|
-
- Concepts: 0
|
|
458
|
-
- Facts: 0
|
|
459
|
-
- Skills: 0
|
|
460
|
-
- Experiences: 0
|
|
461
|
-
|
|
462
|
-
## Recent Activity
|
|
463
|
-
None yet - just started!
|
|
464
|
-
|
|
465
|
-
## Knowledge Gaps
|
|
466
|
-
Everything! Ready to learn.
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
2. As you interact, learn about:
|
|
470
|
-
- The user (who are they, what do they want, preferences)
|
|
471
|
-
- Your environment (project, tools, context)
|
|
472
|
-
- Tasks you're given
|
|
473
|
-
|
|
474
|
-
3. Store each learning immediately in the appropriate category
|
|
475
|
-
|
|
476
|
-
4. Update the index after every 5-10 new entries
|
|
477
|
-
|
|
478
|
-
The memory system is your foundation. Create it first, build on it continuously.
|
|
479
|
-
|
|
480
|
-
Every session makes you smarter. Every memory makes you more capable. Learn, remember, evolve.
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module SwarmSDK
|
|
4
|
-
module Tools
|
|
5
|
-
module Memory
|
|
6
|
-
# Tool for deleting content from memory storage
|
|
7
|
-
#
|
|
8
|
-
# Removes entries that are no longer relevant.
|
|
9
|
-
# Each agent has its own isolated memory storage.
|
|
10
|
-
class MemoryDelete < RubyLLM::Tool
|
|
11
|
-
define_method(:name) { "MemoryDelete" }
|
|
12
|
-
|
|
13
|
-
description <<~DESC
|
|
14
|
-
Delete content from your memory when it's no longer relevant.
|
|
15
|
-
Use this to remove outdated information, completed tasks, or data that's no longer needed.
|
|
16
|
-
This helps keep your memory organized and prevents it from filling up.
|
|
17
|
-
|
|
18
|
-
IMPORTANT: Only delete entries that are truly no longer needed. Once deleted, the content cannot be recovered.
|
|
19
|
-
DESC
|
|
20
|
-
|
|
21
|
-
param :file_path,
|
|
22
|
-
desc: "Path to delete from memory (e.g., 'analysis/old_report', 'parallel/batch1/task_0')",
|
|
23
|
-
required: true
|
|
24
|
-
|
|
25
|
-
class << self
|
|
26
|
-
# Create a MemoryDelete tool for a specific memory storage instance
|
|
27
|
-
#
|
|
28
|
-
# @param memory_storage [Stores::MemoryStorage] Per-agent memory storage instance
|
|
29
|
-
# @return [MemoryDelete] Tool instance
|
|
30
|
-
def create_for_memory(memory_storage)
|
|
31
|
-
new(memory_storage)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Initialize with memory storage instance
|
|
36
|
-
#
|
|
37
|
-
# @param memory_storage [Stores::MemoryStorage] Per-agent memory storage instance
|
|
38
|
-
def initialize(memory_storage)
|
|
39
|
-
super() # Call RubyLLM::Tool's initialize
|
|
40
|
-
@memory_storage = memory_storage
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
# Execute the tool
|
|
44
|
-
#
|
|
45
|
-
# @param file_path [String] Path to delete from
|
|
46
|
-
# @return [String] Success message
|
|
47
|
-
def execute(file_path:)
|
|
48
|
-
memory_storage.delete(file_path: file_path)
|
|
49
|
-
"Deleted memory://#{file_path}"
|
|
50
|
-
rescue ArgumentError => e
|
|
51
|
-
validation_error(e.message)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
private
|
|
55
|
-
|
|
56
|
-
attr_reader :memory_storage
|
|
57
|
-
|
|
58
|
-
def validation_error(message)
|
|
59
|
-
"<tool_use_error>InputValidationError: #{message}</tool_use_error>"
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|