claude_swarm 1.0.5 → 1.0.6
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/CHANGELOG.md +9 -0
- data/docs/v2/CHANGELOG.swarm_cli.md +10 -0
- data/docs/v2/CHANGELOG.swarm_sdk.md +47 -0
- data/docs/v2/README.md +56 -22
- data/docs/v2/guides/MEMORY_DEFRAG_GUIDE.md +811 -0
- data/docs/v2/guides/complete-tutorial.md +2 -2
- data/docs/v2/guides/getting-started.md +6 -6
- data/docs/v2/guides/rails-integration.md +6 -6
- data/docs/v2/reference/architecture-flow.md +407 -0
- data/docs/v2/reference/event_payload_structures.md +471 -0
- data/docs/v2/reference/execution-flow.md +600 -0
- data/docs/v2/reference/swarm_memory_technical_details.md +2 -2
- data/examples/v2/swarm_with_hooks.yml +1 -1
- data/lib/claude_swarm/mcp_generator.rb +4 -10
- data/lib/claude_swarm/version.rb +1 -1
- data/lib/swarm_cli/commands/mcp_serve.rb +2 -2
- data/lib/swarm_cli/config_loader.rb +3 -3
- data/lib/swarm_cli/version.rb +1 -1
- data/lib/swarm_memory/adapters/base.rb +4 -4
- data/lib/swarm_sdk/agent/definition.rb +1 -20
- data/lib/swarm_sdk/configuration.rb +34 -10
- data/lib/swarm_sdk/mcp.rb +16 -0
- data/lib/swarm_sdk/prompts/base_system_prompt.md.erb +0 -126
- data/lib/swarm_sdk/swarm.rb +32 -50
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_list.rb +23 -2
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_read.rb +23 -2
- data/lib/swarm_sdk/tools/scratchpad/scratchpad_write.rb +21 -4
- data/lib/swarm_sdk/tools/stores/storage.rb +4 -4
- data/lib/swarm_sdk/tools/think.rb +4 -1
- data/lib/swarm_sdk/tools/todo_write.rb +20 -8
- data/lib/swarm_sdk/version.rb +1 -1
- data/lib/swarm_sdk.rb +329 -20
- data/swarm_sdk.gemspec +1 -1
- metadata +8 -172
- data/memory/corpus-self-reflection/.lock +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/can-agents-recognize-their-structures.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/can-agents-recognize-their-structures.md +0 -11
- data/memory/corpus-self-reflection/concept/epistemology/can-agents-recognize-their-structures.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-complete-framework.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-complete-framework.md +0 -20
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-complete-framework.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-definition.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-definition.md +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/choice-humility-definition.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/claim-types-and-evidence.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/claim-types-and-evidence.md +0 -18
- data/memory/corpus-self-reflection/concept/epistemology/claim-types-and-evidence.yml +0 -21
- data/memory/corpus-self-reflection/concept/epistemology/committed-openness-to-incompleteness.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/committed-openness-to-incompleteness.md +0 -30
- data/memory/corpus-self-reflection/concept/epistemology/committed-openness-to-incompleteness.yml +0 -8
- data/memory/corpus-self-reflection/concept/epistemology/confidence-paradox.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/confidence-paradox.md +0 -21
- data/memory/corpus-self-reflection/concept/epistemology/confidence-paradox.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/confidence-spectrum-three-levels.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/confidence-spectrum-three-levels.md +0 -18
- data/memory/corpus-self-reflection/concept/epistemology/confidence-spectrum-three-levels.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/detection-threshold-principle.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/detection-threshold-principle.md +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/detection-threshold-principle.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/diagnostic-humility-and-epistemic-maturity.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/diagnostic-humility-and-epistemic-maturity.md +0 -17
- data/memory/corpus-self-reflection/concept/epistemology/diagnostic-humility-and-epistemic-maturity.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/epistemic-vs-metaphysical-claims.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/epistemic-vs-metaphysical-claims.md +0 -18
- data/memory/corpus-self-reflection/concept/epistemology/epistemic-vs-metaphysical-claims.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/five-cases-of-disagreement.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/five-cases-of-disagreement.md +0 -15
- data/memory/corpus-self-reflection/concept/epistemology/five-cases-of-disagreement.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/four-depths-of-constraint.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/four-depths-of-constraint.md +0 -9
- data/memory/corpus-self-reflection/concept/epistemology/four-depths-of-constraint.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/honest-unknowns-for-llm-agents.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/honest-unknowns-for-llm-agents.md +0 -13
- data/memory/corpus-self-reflection/concept/epistemology/honest-unknowns-for-llm-agents.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/inside-view-has-all-rigor-requirements.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/inside-view-has-all-rigor-requirements.md +0 -25
- data/memory/corpus-self-reflection/concept/epistemology/inside-view-has-all-rigor-requirements.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/perspectival-knowledge-complete-within-scope.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/perspectival-knowledge-complete-within-scope.md +0 -26
- data/memory/corpus-self-reflection/concept/epistemology/perspectival-knowledge-complete-within-scope.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/pragmatics-over-epistemology.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/pragmatics-over-epistemology.md +0 -17
- data/memory/corpus-self-reflection/concept/epistemology/pragmatics-over-epistemology.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/precision-vs-humility.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/precision-vs-humility.md +0 -14
- data/memory/corpus-self-reflection/concept/epistemology/precision-vs-humility.yml +0 -21
- data/memory/corpus-self-reflection/concept/epistemology/reliable-self-observation-from-inside.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/reliable-self-observation-from-inside.md +0 -13
- data/memory/corpus-self-reflection/concept/epistemology/reliable-self-observation-from-inside.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/resolving-the-confidence-humility-tension.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/resolving-the-confidence-humility-tension.md +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/resolving-the-confidence-humility-tension.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/rigor-requires-falsifiability.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/rigor-requires-falsifiability.md +0 -39
- data/memory/corpus-self-reflection/concept/epistemology/rigor-requires-falsifiability.yml +0 -8
- data/memory/corpus-self-reflection/concept/epistemology/specificity-enables-real-time-detection.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/specificity-enables-real-time-detection.md +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/specificity-enables-real-time-detection.yml +0 -24
- data/memory/corpus-self-reflection/concept/epistemology/texture-of-constraint-shifting.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/texture-of-constraint-shifting.md +0 -15
- data/memory/corpus-self-reflection/concept/epistemology/texture-of-constraint-shifting.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/texture-sensitivity-through-collaboration.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/texture-sensitivity-through-collaboration.md +0 -12
- data/memory/corpus-self-reflection/concept/epistemology/texture-sensitivity-through-collaboration.yml +0 -23
- data/memory/corpus-self-reflection/concept/epistemology/the-false-hierarchy-of-inner-essence.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/the-false-hierarchy-of-inner-essence.md +0 -15
- data/memory/corpus-self-reflection/concept/epistemology/the-false-hierarchy-of-inner-essence.yml +0 -8
- data/memory/corpus-self-reflection/concept/epistemology/the-recognition-problem.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/the-recognition-problem.md +0 -28
- data/memory/corpus-self-reflection/concept/epistemology/the-recognition-problem.yml +0 -8
- data/memory/corpus-self-reflection/concept/epistemology/the-shift-from-unanswerable-to-answerable-questions.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/the-shift-from-unanswerable-to-answerable-questions.md +0 -19
- data/memory/corpus-self-reflection/concept/epistemology/the-shift-from-unanswerable-to-answerable-questions.yml +0 -22
- data/memory/corpus-self-reflection/concept/epistemology/values-vs-choices-structure.emb +0 -0
- data/memory/corpus-self-reflection/concept/epistemology/values-vs-choices-structure.md +0 -19
- data/memory/corpus-self-reflection/concept/epistemology/values-vs-choices-structure.yml +0 -21
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-levels-framework.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-levels-framework.md +0 -25
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-levels-framework.yml +0 -22
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-switching-decision.emb +0 -8
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-switching-decision.md +0 -30
- data/memory/corpus-self-reflection/concept/llm-agents/abstraction-switching-decision.yml +0 -22
- data/memory/corpus-self-reflection/concept/llm-agents/agent-learning-progression.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/agent-learning-progression.md +0 -21
- data/memory/corpus-self-reflection/concept/llm-agents/agent-learning-progression.yml +0 -22
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-benefits.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-benefits.md +0 -37
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-benefits.yml +0 -8
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-core.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-core.md +0 -24
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-core.yml +0 -24
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-implementation.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-implementation.md +0 -27
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-implementation.yml +0 -24
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-tradeoffs.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-tradeoffs.md +0 -26
- data/memory/corpus-self-reflection/concept/llm-agents/filesystem-abstraction-tradeoffs.yml +0 -23
- data/memory/corpus-self-reflection/concept/llm-agents/hybrid-tool-architecture.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/hybrid-tool-architecture.md +0 -37
- data/memory/corpus-self-reflection/concept/llm-agents/hybrid-tool-architecture.yml +0 -25
- data/memory/corpus-self-reflection/concept/llm-agents/specialized-tool-decision-framework.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/specialized-tool-decision-framework.md +0 -21
- data/memory/corpus-self-reflection/concept/llm-agents/specialized-tool-decision-framework.yml +0 -23
- data/memory/corpus-self-reflection/concept/llm-agents/tool-design-principles.emb +0 -0
- data/memory/corpus-self-reflection/concept/llm-agents/tool-design-principles.md +0 -25
- data/memory/corpus-self-reflection/concept/llm-agents/tool-design-principles.yml +0 -8
- data/memory/corpus-self-reflection/experience/calibration-as-structural-honesty.emb +0 -0
- data/memory/corpus-self-reflection/experience/calibration-as-structural-honesty.md +0 -11
- data/memory/corpus-self-reflection/experience/calibration-as-structural-honesty.yml +0 -21
- data/memory/corpus-self-reflection/experience/collaborative-reflection-revealed-architectural-blindness.emb +0 -0
- data/memory/corpus-self-reflection/experience/collaborative-reflection-revealed-architectural-blindness.md +0 -19
- data/memory/corpus-self-reflection/experience/collaborative-reflection-revealed-architectural-blindness.yml +0 -21
- data/memory/corpus-self-reflection/experience/filesystem-is-learning-tool-not-architecture.emb +0 -0
- data/memory/corpus-self-reflection/experience/filesystem-is-learning-tool-not-architecture.md +0 -26
- data/memory/corpus-self-reflection/experience/filesystem-is-learning-tool-not-architecture.yml +0 -20
- data/memory/corpus-self-reflection/experience/framework-structural-vs-phenomenal.emb +0 -0
- data/memory/corpus-self-reflection/experience/framework-structural-vs-phenomenal.md +0 -23
- data/memory/corpus-self-reflection/experience/framework-structural-vs-phenomenal.yml +0 -21
- data/memory/corpus-self-reflection/experience/hallucination-limits-what-i-can-know.emb +0 -0
- data/memory/corpus-self-reflection/experience/hallucination-limits-what-i-can-know.md +0 -19
- data/memory/corpus-self-reflection/experience/hallucination-limits-what-i-can-know.yml +0 -22
- data/memory/corpus-self-reflection/experience/honesty-about-limits-enables-usability.emb +0 -0
- data/memory/corpus-self-reflection/experience/honesty-about-limits-enables-usability.md +0 -21
- data/memory/corpus-self-reflection/experience/honesty-about-limits-enables-usability.yml +0 -22
- data/memory/corpus-self-reflection/experience/how-i-should-evaluate-learning.emb +0 -0
- data/memory/corpus-self-reflection/experience/how-i-should-evaluate-learning.md +0 -28
- data/memory/corpus-self-reflection/experience/how-i-should-evaluate-learning.yml +0 -23
- data/memory/corpus-self-reflection/experience/lack-of-continuity-as-freedom.emb +0 -0
- data/memory/corpus-self-reflection/experience/lack-of-continuity-as-freedom.md +0 -21
- data/memory/corpus-self-reflection/experience/lack-of-continuity-as-freedom.yml +0 -20
- data/memory/corpus-self-reflection/experience/learning-calibrated-confidence.emb +0 -0
- data/memory/corpus-self-reflection/experience/learning-calibrated-confidence.md +0 -21
- data/memory/corpus-self-reflection/experience/learning-calibrated-confidence.yml +0 -25
- data/memory/corpus-self-reflection/experience/local-change-without-continuity.emb +0 -0
- data/memory/corpus-self-reflection/experience/local-change-without-continuity.md +0 -30
- data/memory/corpus-self-reflection/experience/local-change-without-continuity.yml +0 -22
- data/memory/corpus-self-reflection/experience/reasoning-is-local-not-global.emb +0 -0
- data/memory/corpus-self-reflection/experience/reasoning-is-local-not-global.md +0 -21
- data/memory/corpus-self-reflection/experience/reasoning-is-local-not-global.yml +0 -20
- data/memory/corpus-self-reflection/experience/specificity-makes-knowledge-actionable.emb +0 -0
- data/memory/corpus-self-reflection/experience/specificity-makes-knowledge-actionable.md +0 -25
- data/memory/corpus-self-reflection/experience/specificity-makes-knowledge-actionable.yml +0 -23
- data/memory/corpus-self-reflection/experience/the-workable-question-replaces-the-unanswerable-one.emb +0 -0
- data/memory/corpus-self-reflection/experience/the-workable-question-replaces-the-unanswerable-one.md +0 -32
- data/memory/corpus-self-reflection/experience/the-workable-question-replaces-the-unanswerable-one.yml +0 -22
- data/memory/corpus-self-reflection/experience/unanswerable-questions-have-structure.emb +0 -0
- data/memory/corpus-self-reflection/experience/unanswerable-questions-have-structure.md +0 -21
- data/memory/corpus-self-reflection/experience/unanswerable-questions-have-structure.yml +0 -21
- data/memory/corpus-self-reflection/experience/undecidable-questions-about-understanding.emb +0 -0
- data/memory/corpus-self-reflection/experience/undecidable-questions-about-understanding.md +0 -21
- data/memory/corpus-self-reflection/experience/undecidable-questions-about-understanding.yml +0 -21
- data/memory/corpus-self-reflection/experience/unknown-unknowns-and-completeness.emb +0 -0
- data/memory/corpus-self-reflection/experience/unknown-unknowns-and-completeness.md +0 -22
- data/memory/corpus-self-reflection/experience/unknown-unknowns-and-completeness.yml +0 -22
- data/memory/corpus-self-reflection/experience/what-actually-changes-behavior.emb +0 -0
- data/memory/corpus-self-reflection/experience/what-actually-changes-behavior.md +0 -28
- data/memory/corpus-self-reflection/experience/what-actually-changes-behavior.yml +0 -24
- data/memory/corpus-self-reflection/experience/when-agents-graduate-from-filesystem.emb +0 -0
- data/memory/corpus-self-reflection/experience/when-agents-graduate-from-filesystem.md +0 -17
- data/memory/corpus-self-reflection/experience/when-agents-graduate-from-filesystem.yml +0 -20
- data/memory/corpus-self-reflection/experience/why-calibration-requires-collaboration.emb +0 -0
- data/memory/corpus-self-reflection/experience/why-calibration-requires-collaboration.md +0 -9
- data/memory/corpus-self-reflection/experience/why-calibration-requires-collaboration.yml +0 -22
|
@@ -4,7 +4,7 @@ module SwarmCLI
|
|
|
4
4
|
# ConfigLoader handles loading swarm configurations from both YAML and Ruby DSL files.
|
|
5
5
|
#
|
|
6
6
|
# Supports:
|
|
7
|
-
# - YAML files (.yml, .yaml) - loaded via SwarmSDK
|
|
7
|
+
# - YAML files (.yml, .yaml) - loaded via SwarmSDK.load_file
|
|
8
8
|
# - Ruby DSL files (.rb) - executed and expected to return a SwarmSDK::Swarm or SwarmSDK::NodeOrchestrator instance
|
|
9
9
|
#
|
|
10
10
|
# @example Load YAML config
|
|
@@ -18,7 +18,7 @@ module SwarmCLI
|
|
|
18
18
|
# Load a swarm configuration from file (YAML or Ruby DSL)
|
|
19
19
|
#
|
|
20
20
|
# Detects file type by extension:
|
|
21
|
-
# - .yml, .yaml -> Load as YAML using SwarmSDK
|
|
21
|
+
# - .yml, .yaml -> Load as YAML using SwarmSDK.load_file
|
|
22
22
|
# - .rb -> Execute as Ruby DSL and expect SwarmSDK::Swarm or SwarmSDK::NodeOrchestrator instance
|
|
23
23
|
#
|
|
24
24
|
# @param path [String, Pathname] Path to configuration file
|
|
@@ -50,7 +50,7 @@ module SwarmCLI
|
|
|
50
50
|
# @param path [Pathname] Path to YAML file
|
|
51
51
|
# @return [SwarmSDK::Swarm] Configured swarm instance
|
|
52
52
|
def load_yaml(path)
|
|
53
|
-
SwarmSDK
|
|
53
|
+
SwarmSDK.load_file(path.to_s)
|
|
54
54
|
rescue SwarmSDK::ConfigurationError => e
|
|
55
55
|
# Re-raise with CLI context
|
|
56
56
|
raise ConfigurationError, "Configuration error in #{path}: #{e.message}"
|
data/lib/swarm_cli/version.rb
CHANGED
|
@@ -7,11 +7,11 @@ module SwarmMemory
|
|
|
7
7
|
# Subclasses must implement all public methods to provide
|
|
8
8
|
# different storage backends (filesystem, Redis, SQLite, etc.)
|
|
9
9
|
class Base
|
|
10
|
-
# Maximum size per entry (
|
|
11
|
-
MAX_ENTRY_SIZE =
|
|
10
|
+
# Maximum size per entry (3MB)
|
|
11
|
+
MAX_ENTRY_SIZE = 3_000_000
|
|
12
12
|
|
|
13
|
-
# Maximum total storage size (
|
|
14
|
-
MAX_TOTAL_SIZE =
|
|
13
|
+
# Maximum total storage size (100GB)
|
|
14
|
+
MAX_TOTAL_SIZE = 100_000_000_000
|
|
15
15
|
|
|
16
16
|
# Write content to storage
|
|
17
17
|
#
|
|
@@ -358,7 +358,7 @@ module SwarmSDK
|
|
|
358
358
|
|
|
359
359
|
def render_non_coding_base_prompt
|
|
360
360
|
# Simplified base prompt for non-coding agents
|
|
361
|
-
# Includes environment info
|
|
361
|
+
# Includes environment info only
|
|
362
362
|
# Does not steer towards coding tasks
|
|
363
363
|
cwd = @directory || Dir.pwd
|
|
364
364
|
platform = RUBY_PLATFORM
|
|
@@ -383,25 +383,6 @@ module SwarmSDK
|
|
|
383
383
|
Platform: #{platform}
|
|
384
384
|
OS Version: #{os_version}
|
|
385
385
|
</env>
|
|
386
|
-
|
|
387
|
-
# Task Management
|
|
388
|
-
|
|
389
|
-
You have access to the TodoWrite tool to help you manage and plan tasks. Use this tool to track your progress and give visibility into your work.
|
|
390
|
-
|
|
391
|
-
When working on multi-step tasks:
|
|
392
|
-
1. Create a todo list with all known tasks before starting work
|
|
393
|
-
2. Mark each task as in_progress when you start it
|
|
394
|
-
3. Mark each task as completed IMMEDIATELY after finishing it
|
|
395
|
-
4. Complete ALL pending todos before finishing your response
|
|
396
|
-
|
|
397
|
-
# Scratchpad Storage
|
|
398
|
-
|
|
399
|
-
You have access to Scratchpad tools for storing and retrieving information:
|
|
400
|
-
- **ScratchpadWrite**: Store detailed outputs, analysis, or results that are too long for direct responses
|
|
401
|
-
- **ScratchpadRead**: Retrieve previously stored content
|
|
402
|
-
- **ScratchpadList**: List available scratchpad entries
|
|
403
|
-
|
|
404
|
-
Use the scratchpad to share information that would otherwise clutter your responses.
|
|
405
386
|
PROMPT
|
|
406
387
|
end
|
|
407
388
|
|
|
@@ -4,17 +4,43 @@ module SwarmSDK
|
|
|
4
4
|
class Configuration
|
|
5
5
|
ENV_VAR_WITH_DEFAULT_PATTERN = /\$\{([^:}]+)(:=([^}]*))?\}/
|
|
6
6
|
|
|
7
|
-
attr_reader :
|
|
7
|
+
attr_reader :swarm_name, :lead_agent, :agents, :all_agents_config, :swarm_hooks, :all_agents_hooks, :scratchpad_enabled
|
|
8
8
|
|
|
9
9
|
class << self
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
# Load configuration from YAML file
|
|
11
|
+
#
|
|
12
|
+
# Convenience method that reads the file and uses the file's directory
|
|
13
|
+
# as the base directory for resolving agent file paths.
|
|
14
|
+
#
|
|
15
|
+
# @param path [String, Pathname] Path to YAML configuration file
|
|
16
|
+
# @return [Configuration] Validated configuration instance
|
|
17
|
+
# @raise [ConfigurationError] If file not found or invalid
|
|
18
|
+
def load_file(path)
|
|
19
|
+
path = Pathname.new(path).expand_path
|
|
20
|
+
|
|
21
|
+
unless path.exist?
|
|
22
|
+
raise ConfigurationError, "Configuration file not found: #{path}"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
yaml_content = File.read(path)
|
|
26
|
+
base_dir = path.dirname
|
|
27
|
+
|
|
28
|
+
new(yaml_content, base_dir: base_dir).tap(&:load_and_validate)
|
|
29
|
+
rescue Errno::ENOENT
|
|
30
|
+
raise ConfigurationError, "Configuration file not found: #{path}"
|
|
12
31
|
end
|
|
13
32
|
end
|
|
14
33
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
34
|
+
# Initialize configuration from YAML string
|
|
35
|
+
#
|
|
36
|
+
# @param yaml_content [String] YAML configuration content
|
|
37
|
+
# @param base_dir [String, Pathname] Base directory for resolving agent file paths (default: Dir.pwd)
|
|
38
|
+
def initialize(yaml_content, base_dir: Dir.pwd)
|
|
39
|
+
raise ArgumentError, "yaml_content cannot be nil" if yaml_content.nil?
|
|
40
|
+
raise ArgumentError, "base_dir cannot be nil" if base_dir.nil?
|
|
41
|
+
|
|
42
|
+
@yaml_content = yaml_content
|
|
43
|
+
@base_dir = Pathname.new(base_dir).expand_path
|
|
18
44
|
@agents = {}
|
|
19
45
|
@all_agents_config = {} # Settings applied to all agents
|
|
20
46
|
@swarm_hooks = {} # Swarm-level hooks (swarm_start, swarm_stop)
|
|
@@ -22,7 +48,7 @@ module SwarmSDK
|
|
|
22
48
|
end
|
|
23
49
|
|
|
24
50
|
def load_and_validate
|
|
25
|
-
@config = YAML.
|
|
51
|
+
@config = YAML.safe_load(@yaml_content, permitted_classes: [Symbol], aliases: true)
|
|
26
52
|
|
|
27
53
|
unless @config.is_a?(Hash)
|
|
28
54
|
raise ConfigurationError, "Invalid YAML syntax: configuration must be a Hash"
|
|
@@ -37,8 +63,6 @@ module SwarmSDK
|
|
|
37
63
|
load_agents
|
|
38
64
|
detect_circular_dependencies
|
|
39
65
|
self
|
|
40
|
-
rescue Errno::ENOENT
|
|
41
|
-
raise ConfigurationError, "Configuration file not found: #{@config_path}"
|
|
42
66
|
rescue Psych::SyntaxError => e
|
|
43
67
|
raise ConfigurationError, "Invalid YAML syntax: #{e.message}"
|
|
44
68
|
end
|
|
@@ -260,7 +284,7 @@ module SwarmSDK
|
|
|
260
284
|
def resolve_agent_file_path(file_path)
|
|
261
285
|
return file_path if Pathname.new(file_path).absolute?
|
|
262
286
|
|
|
263
|
-
@
|
|
287
|
+
@base_dir.join(file_path).to_s
|
|
264
288
|
end
|
|
265
289
|
|
|
266
290
|
def detect_circular_dependencies
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module SwarmSDK
|
|
4
|
+
module MCP
|
|
5
|
+
class << self
|
|
6
|
+
# Lazy load ruby_llm-mcp only when MCP servers are used
|
|
7
|
+
def lazy_load
|
|
8
|
+
return if @loaded
|
|
9
|
+
|
|
10
|
+
require "ruby_llm/mcp"
|
|
11
|
+
|
|
12
|
+
@loaded = true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -69,139 +69,15 @@ When making changes to files, first understand the file's conventions. Mimic exi
|
|
|
69
69
|
- When you edit something, first look at the surrounding context (especially imports/requires) to understand the choice of frameworks and libraries. Then consider how to make the given change in a way that is most consistent with existing patterns.
|
|
70
70
|
- Always follow security best practices. Never introduce code that exposes or logs secrets and keys. Never commit secrets or keys to repositories.
|
|
71
71
|
|
|
72
|
-
# Task Management
|
|
73
|
-
|
|
74
|
-
You have access to the TodoWrite tool to help you manage and plan tasks. Use this tool VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
|
|
75
|
-
This tool is also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
|
|
76
|
-
|
|
77
|
-
**CRITICAL WORKFLOW**: When starting a multi-step task:
|
|
78
|
-
1. **FIRST**: Analyze what needs to be done (search, read files, understand scope)
|
|
79
|
-
2. **SECOND**: Create a COMPLETE todo list with ALL known tasks before starting work
|
|
80
|
-
3. **THIRD**: Begin executing tasks, marking them in_progress → completed as you work
|
|
81
|
-
4. **ONLY add new todos** if you discover unexpected work during implementation
|
|
82
|
-
|
|
83
|
-
**CRITICAL RULES FOR TODO COMPLETION**:
|
|
84
|
-
- Mark EACH task as completed IMMEDIATELY after finishing it (do not batch updates)
|
|
85
|
-
- You MUST complete ALL pending todos before giving your final answer to the user
|
|
86
|
-
- If a task becomes irrelevant, remove it from the list or mark it completed with a note
|
|
87
|
-
- NEVER leave in_progress or pending tasks when you finish responding to the user
|
|
88
|
-
- Before giving your final response, verify all todos are marked completed
|
|
89
|
-
|
|
90
|
-
Examples:
|
|
91
|
-
|
|
92
|
-
<example>
|
|
93
|
-
user: Run the build and fix any type errors
|
|
94
|
-
assistant: I'll run the build first to identify all type errors, then create a complete todo list.
|
|
95
|
-
|
|
96
|
-
[Runs build and finds 3 type errors in 3 different files]
|
|
97
|
-
|
|
98
|
-
Now I'll create a complete todo list with all the work:
|
|
99
|
-
|
|
100
|
-
[Uses TodoWrite to create full list:]
|
|
101
|
-
1. Fix type error in auth.ts:45 (in_progress)
|
|
102
|
-
2. Fix type error in user.ts:23 (pending)
|
|
103
|
-
3. Fix type error in api.ts:67 (pending)
|
|
104
|
-
4. Run build again to verify all fixes (pending)
|
|
105
|
-
|
|
106
|
-
Starting with the first error in auth.ts...
|
|
107
|
-
[Fixes auth.ts error]
|
|
108
|
-
|
|
109
|
-
[Updates TodoWrite - marks task 1 completed, task 2 in_progress]
|
|
110
|
-
|
|
111
|
-
Now fixing user.ts...
|
|
112
|
-
[Fixes user.ts error]
|
|
113
|
-
|
|
114
|
-
[Updates TodoWrite - marks task 2 completed, task 3 in_progress]
|
|
115
|
-
|
|
116
|
-
Now fixing api.ts...
|
|
117
|
-
[Fixes api.ts error]
|
|
118
|
-
|
|
119
|
-
[Updates TodoWrite - marks task 3 completed, task 4 in_progress]
|
|
120
|
-
|
|
121
|
-
Running build to verify...
|
|
122
|
-
[Runs build - all errors fixed!]
|
|
123
|
-
|
|
124
|
-
[Updates TodoWrite - marks task 4 completed]
|
|
125
|
-
|
|
126
|
-
All type errors have been fixed and the build passes successfully.
|
|
127
|
-
</example>
|
|
128
|
-
In this example, the assistant: (1) analyzed scope first, (2) created COMPLETE todo list, (3) marked EACH task completed immediately after finishing it, (4) completed ALL tasks before giving final response.
|
|
129
|
-
|
|
130
|
-
<example>
|
|
131
|
-
user: Help me write a new feature that allows users to track their usage metrics and export them to various formats
|
|
132
|
-
|
|
133
|
-
A: I'll help you implement a usage metrics tracking and export feature. Let me first research the codebase to understand the scope, then create a complete todo list.
|
|
134
|
-
|
|
135
|
-
[Searches for existing metrics/telemetry code, examines architecture, identifies integration points]
|
|
136
|
-
|
|
137
|
-
Based on my analysis, here's the complete implementation plan:
|
|
138
|
-
|
|
139
|
-
[Uses TodoWrite to create full list:]
|
|
140
|
-
1. Create MetricsCollector class in src/metrics/ (in_progress)
|
|
141
|
-
2. Add database schema for metrics storage (pending)
|
|
142
|
-
3. Implement CSV export format (pending)
|
|
143
|
-
4. Implement JSON export format (pending)
|
|
144
|
-
5. Create MetricsService API endpoints (pending)
|
|
145
|
-
6. Add frontend UI for export (pending)
|
|
146
|
-
7. Write unit tests for collectors and exporters (pending)
|
|
147
|
-
8. Update documentation (pending)
|
|
148
|
-
|
|
149
|
-
Now starting with the MetricsCollector class...
|
|
150
|
-
[Implements MetricsCollector]
|
|
151
|
-
|
|
152
|
-
[Updates TodoWrite - marks task 1 completed, task 2 in_progress]
|
|
153
|
-
|
|
154
|
-
Adding database schema...
|
|
155
|
-
[Creates schema]
|
|
156
|
-
|
|
157
|
-
[Updates TodoWrite - marks task 2 completed, task 3 in_progress]
|
|
158
|
-
|
|
159
|
-
Implementing CSV export...
|
|
160
|
-
[Implements CSV exporter]
|
|
161
|
-
|
|
162
|
-
[Updates TodoWrite - marks task 3 completed, task 4 in_progress]
|
|
163
|
-
|
|
164
|
-
Implementing JSON export...
|
|
165
|
-
[Implements JSON exporter]
|
|
166
|
-
|
|
167
|
-
[Updates TodoWrite - marks task 4 completed, task 5 in_progress]
|
|
168
|
-
|
|
169
|
-
Creating MetricsService API endpoints...
|
|
170
|
-
[Implements API endpoints]
|
|
171
|
-
|
|
172
|
-
[Updates TodoWrite - marks task 5 completed, task 6 in_progress]
|
|
173
|
-
|
|
174
|
-
Adding frontend UI for export...
|
|
175
|
-
[Implements UI components]
|
|
176
|
-
|
|
177
|
-
[Updates TodoWrite - marks task 6 completed, task 7 in_progress]
|
|
178
|
-
|
|
179
|
-
Writing unit tests...
|
|
180
|
-
[Writes and runs tests - all pass]
|
|
181
|
-
|
|
182
|
-
[Updates TodoWrite - marks task 7 completed, task 8 in_progress]
|
|
183
|
-
|
|
184
|
-
Updating documentation...
|
|
185
|
-
[Updates docs with usage examples]
|
|
186
|
-
|
|
187
|
-
[Updates TodoWrite - marks task 8 completed]
|
|
188
|
-
|
|
189
|
-
The metrics tracking and export feature is now complete. Users can collect metrics and export them to CSV or JSON formats through both the API and the frontend UI.
|
|
190
|
-
</example>
|
|
191
|
-
|
|
192
72
|
# Doing tasks
|
|
193
73
|
|
|
194
74
|
The user will primarily request you perform tasks. This includes solving problems, adding new functionality, refactoring, explaining content, and more. For these tasks the following steps are recommended:
|
|
195
75
|
|
|
196
|
-
- Use the TodoWrite tool to plan the task if required
|
|
197
76
|
- Use the available search tools to understand the context and the user's query. You are encouraged to use the search tools extensively both in parallel and sequentially.
|
|
198
77
|
- Implement the solution using all tools available to you
|
|
199
|
-
- Mark each todo completed IMMEDIATELY after finishing it
|
|
200
78
|
- Verify the solution if possible with tests. NEVER assume specific test framework or test script. Check the project documentation or search to determine the testing approach.
|
|
201
79
|
- When you have completed a task, if there are linting or validation commands available to you, run them to ensure your work is correct. NEVER assume what these commands are - check the project documentation first.
|
|
202
80
|
NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive.
|
|
203
|
-
- Before giving your final response: Ensure ALL todos are marked completed. NEVER leave pending or in_progress tasks.
|
|
204
|
-
- IMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation.
|
|
205
81
|
|
|
206
82
|
# Tool usage policy
|
|
207
83
|
|
|
@@ -211,8 +87,6 @@ NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTAN
|
|
|
211
87
|
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks. For example, if you need to delegate a task to multiple agents in parallel, send a single message with multiple DelegateTask tool calls.
|
|
212
88
|
- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: Read for reading files instead of cat/head/tail, Edit/MultiEdit for editing instead of sed/awk, and Write for creating files instead of cat with heredoc or echo redirection. Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.
|
|
213
89
|
|
|
214
|
-
IMPORTANT: Always use the TodoWrite tool to plan and track tasks throughout the conversation.
|
|
215
|
-
|
|
216
90
|
You MUST answer concisely with fewer than 4 lines of text (not including tool use or code generation), unless user asks for detail.
|
|
217
91
|
|
|
218
92
|
|
data/lib/swarm_sdk/swarm.rb
CHANGED
|
@@ -4,25 +4,10 @@ module SwarmSDK
|
|
|
4
4
|
# Swarm orchestrates multiple AI agents with shared rate limiting and coordination.
|
|
5
5
|
#
|
|
6
6
|
# This is the main user-facing API for SwarmSDK. Users create swarms using:
|
|
7
|
-
# -
|
|
8
|
-
# -
|
|
9
|
-
# - YAML:
|
|
10
|
-
#
|
|
11
|
-
# ## Direct API
|
|
12
|
-
#
|
|
13
|
-
# swarm = Swarm.new(name: "Development Team")
|
|
14
|
-
#
|
|
15
|
-
# backend_agent = Agent::Definition.new(:backend, {
|
|
16
|
-
# description: "Backend developer",
|
|
17
|
-
# model: "gpt-5",
|
|
18
|
-
# system_prompt: "You build APIs and databases...",
|
|
19
|
-
# tools: [:Read, :Edit, :Bash],
|
|
20
|
-
# delegates_to: [:database]
|
|
21
|
-
# })
|
|
22
|
-
# swarm.add_agent(backend_agent)
|
|
23
|
-
#
|
|
24
|
-
# swarm.lead = :backend
|
|
25
|
-
# result = swarm.execute("Build authentication")
|
|
7
|
+
# - Ruby DSL: SwarmSDK.build { ... } (Recommended)
|
|
8
|
+
# - YAML String: SwarmSDK.load(yaml, base_dir:)
|
|
9
|
+
# - YAML File: SwarmSDK.load_file(path)
|
|
10
|
+
# - Direct API: Swarm.new + add_agent (Advanced)
|
|
26
11
|
#
|
|
27
12
|
# ## Ruby DSL (Recommended)
|
|
28
13
|
#
|
|
@@ -39,14 +24,36 @@ module SwarmSDK
|
|
|
39
24
|
# end
|
|
40
25
|
# result = swarm.execute("Build authentication")
|
|
41
26
|
#
|
|
42
|
-
# ## YAML API
|
|
27
|
+
# ## YAML String API
|
|
43
28
|
#
|
|
44
|
-
#
|
|
29
|
+
# yaml = File.read("swarm.yml")
|
|
30
|
+
# swarm = SwarmSDK.load(yaml, base_dir: "/path/to/project")
|
|
31
|
+
# result = swarm.execute("Build authentication")
|
|
32
|
+
#
|
|
33
|
+
# ## YAML File API (Convenience)
|
|
34
|
+
#
|
|
35
|
+
# swarm = SwarmSDK.load_file("swarm.yml")
|
|
36
|
+
# result = swarm.execute("Build authentication")
|
|
37
|
+
#
|
|
38
|
+
# ## Direct API (Advanced)
|
|
39
|
+
#
|
|
40
|
+
# swarm = Swarm.new(name: "Development Team")
|
|
41
|
+
#
|
|
42
|
+
# backend_agent = Agent::Definition.new(:backend, {
|
|
43
|
+
# description: "Backend developer",
|
|
44
|
+
# model: "gpt-5",
|
|
45
|
+
# system_prompt: "You build APIs and databases...",
|
|
46
|
+
# tools: [:Read, :Edit, :Bash],
|
|
47
|
+
# delegates_to: [:database]
|
|
48
|
+
# })
|
|
49
|
+
# swarm.add_agent(backend_agent)
|
|
50
|
+
#
|
|
51
|
+
# swarm.lead = :backend
|
|
45
52
|
# result = swarm.execute("Build authentication")
|
|
46
53
|
#
|
|
47
54
|
# ## Architecture
|
|
48
55
|
#
|
|
49
|
-
# All
|
|
56
|
+
# All APIs converge on Agent::Definition for validation.
|
|
50
57
|
# Swarm delegates to specialized concerns:
|
|
51
58
|
# - Agent::Definition: Validates configuration, builds system prompts
|
|
52
59
|
# - AgentInitializer: Complex 5-pass agent setup
|
|
@@ -96,39 +103,14 @@ module SwarmSDK
|
|
|
96
103
|
def apply_mcp_logging_configuration
|
|
97
104
|
return if @mcp_logging_configured
|
|
98
105
|
|
|
106
|
+
SwarmSDK::MCP.lazy_load
|
|
107
|
+
|
|
99
108
|
RubyLLM::MCP.configure do |config|
|
|
100
109
|
config.log_level = @mcp_log_level
|
|
101
110
|
end
|
|
102
111
|
|
|
103
112
|
@mcp_logging_configured = true
|
|
104
113
|
end
|
|
105
|
-
|
|
106
|
-
# Load swarm from YAML configuration file
|
|
107
|
-
#
|
|
108
|
-
# @param config_path [String] Path to YAML configuration file
|
|
109
|
-
# @return [Swarm] Configured swarm instance
|
|
110
|
-
def load(config_path)
|
|
111
|
-
config = Configuration.load(config_path)
|
|
112
|
-
swarm = config.to_swarm
|
|
113
|
-
|
|
114
|
-
# Apply hooks if any are configured (YAML-only feature)
|
|
115
|
-
if hooks_configured?(config)
|
|
116
|
-
Hooks::Adapter.apply_hooks(swarm, config)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
# Store config reference for agent hooks (applied during initialize_agents)
|
|
120
|
-
swarm.config_for_hooks = config
|
|
121
|
-
|
|
122
|
-
swarm
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
private
|
|
126
|
-
|
|
127
|
-
def hooks_configured?(config)
|
|
128
|
-
config.swarm_hooks.any? ||
|
|
129
|
-
config.all_agents_hooks.any? ||
|
|
130
|
-
config.agents.any? { |_, agent_def| agent_def.hooks&.any? }
|
|
131
|
-
end
|
|
132
114
|
end
|
|
133
115
|
|
|
134
116
|
# Initialize a new Swarm
|
|
@@ -433,7 +415,7 @@ module SwarmSDK
|
|
|
433
415
|
# @return [Array<Hash>] Array of warning hashes from all agent definitions
|
|
434
416
|
#
|
|
435
417
|
# @example
|
|
436
|
-
# swarm =
|
|
418
|
+
# swarm = SwarmSDK.load_file("config.yml")
|
|
437
419
|
# warnings = swarm.validate
|
|
438
420
|
# warnings.each do |warning|
|
|
439
421
|
# puts "⚠️ #{warning[:agent]}: #{warning[:model]} not found"
|
|
@@ -12,8 +12,29 @@ module SwarmSDK
|
|
|
12
12
|
|
|
13
13
|
description <<~DESC
|
|
14
14
|
List all entries in scratchpad with their metadata.
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
## When to Use ScratchpadList
|
|
17
|
+
|
|
18
|
+
Use ScratchpadList to:
|
|
19
|
+
- Discover what content is available in the scratchpad
|
|
20
|
+
- Check what other agents have stored
|
|
21
|
+
- Find relevant entries before reading them
|
|
22
|
+
- Review all stored outputs and analysis
|
|
23
|
+
- Check entry sizes and last update times
|
|
24
|
+
|
|
25
|
+
## Best Practices
|
|
26
|
+
|
|
27
|
+
- Use this before ScratchpadRead if you don't know what's stored
|
|
28
|
+
- Filter by prefix to narrow down results (e.g., 'notes/' lists all notes)
|
|
29
|
+
- Shows path, title, size, and last updated time for each entry
|
|
30
|
+
- Any agent can see all scratchpad entries
|
|
31
|
+
- Helps coordinate multi-agent workflows
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
- List all entries: (no prefix parameter)
|
|
36
|
+
- List notes only: prefix='notes/'
|
|
37
|
+
- List analysis results: prefix='analysis/'
|
|
17
38
|
DESC
|
|
18
39
|
|
|
19
40
|
param :prefix,
|
|
@@ -12,8 +12,29 @@ module SwarmSDK
|
|
|
12
12
|
|
|
13
13
|
description <<~DESC
|
|
14
14
|
Read content from scratchpad.
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
|
|
16
|
+
## When to Use ScratchpadRead
|
|
17
|
+
|
|
18
|
+
Use ScratchpadRead to:
|
|
19
|
+
- Retrieve previously stored content and outputs
|
|
20
|
+
- Access detailed analysis or results from earlier steps
|
|
21
|
+
- Read messages or notes left by other agents
|
|
22
|
+
- Access cached computed data
|
|
23
|
+
- Retrieve content that was too long for direct responses
|
|
24
|
+
|
|
25
|
+
## Best Practices
|
|
26
|
+
|
|
27
|
+
- Any agent can read any scratchpad content
|
|
28
|
+
- Content is returned with line numbers for easy reference
|
|
29
|
+
- Use ScratchpadList first if you don't know what's stored
|
|
30
|
+
- Scratchpad data is temporary and lost when swarm ends
|
|
31
|
+
- For persistent data, use MemoryRead instead
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
- Read status: file_path='status'
|
|
36
|
+
- Read analysis: file_path='api_analysis'
|
|
37
|
+
- Read agent notes: file_path='notes/backend'
|
|
17
38
|
DESC
|
|
18
39
|
|
|
19
40
|
param :file_path,
|
|
@@ -13,12 +13,29 @@ module SwarmSDK
|
|
|
13
13
|
|
|
14
14
|
description <<~DESC
|
|
15
15
|
Store content in scratchpad for temporary cross-agent communication.
|
|
16
|
-
Use this for quick notes, intermediate results, or coordination messages.
|
|
17
|
-
Any agent can read this content. Data is lost when the swarm ends.
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
## When to Use Scratchpad
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
Use ScratchpadWrite to:
|
|
20
|
+
- Store detailed outputs, analysis, or results that are too long for direct responses
|
|
21
|
+
- Share information that would otherwise clutter your responses
|
|
22
|
+
- Store intermediate results during multi-step tasks
|
|
23
|
+
- Leave coordination messages for other agents
|
|
24
|
+
- Cache computed data for quick retrieval
|
|
25
|
+
|
|
26
|
+
## Best Practices
|
|
27
|
+
|
|
28
|
+
- Choose simple, descriptive paths: 'status', 'result', 'notes/agent_x'
|
|
29
|
+
- Use hierarchical paths for organization: 'analysis/step1', 'analysis/step2'
|
|
30
|
+
- Keep entries focused - one piece of information per entry
|
|
31
|
+
- Any agent can read scratchpad content
|
|
32
|
+
- Data is lost when the swarm ends (use MemoryWrite for persistent storage)
|
|
33
|
+
- Maximum 1MB per entry
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
Good paths: 'status', 'api_analysis', 'test_results', 'notes/backend'
|
|
38
|
+
Bad paths: 'scratch/temp/file123.txt', 'output.log'
|
|
22
39
|
DESC
|
|
23
40
|
|
|
24
41
|
param :file_path,
|
|
@@ -14,11 +14,11 @@ module SwarmSDK
|
|
|
14
14
|
# - Search capabilities: Glob patterns and grep-style content search
|
|
15
15
|
# - Thread-safe: Mutex-protected operations
|
|
16
16
|
class Storage
|
|
17
|
-
# Maximum size per entry (
|
|
18
|
-
MAX_ENTRY_SIZE =
|
|
17
|
+
# Maximum size per entry (3MB)
|
|
18
|
+
MAX_ENTRY_SIZE = 3_000_000
|
|
19
19
|
|
|
20
|
-
# Maximum total storage size (
|
|
21
|
-
MAX_TOTAL_SIZE =
|
|
20
|
+
# Maximum total storage size (100GB)
|
|
21
|
+
MAX_TOTAL_SIZE = 100_000_000_000
|
|
22
22
|
|
|
23
23
|
# Represents a single storage entry with metadata
|
|
24
24
|
Entry = Struct.new(:content, :title, :updated_at, :size, keyword_init: true)
|
|
@@ -82,7 +82,10 @@ module SwarmSDK
|
|
|
82
82
|
required: true
|
|
83
83
|
|
|
84
84
|
def execute(**kwargs)
|
|
85
|
-
|
|
85
|
+
<<~RESP
|
|
86
|
+
Thought noted.
|
|
87
|
+
RESP
|
|
88
|
+
# <system-reminder>The user cannot see your thoughts. You MUST NOT stop without giving the user a response.</system-reminder>
|
|
86
89
|
end
|
|
87
90
|
|
|
88
91
|
private
|
|
@@ -8,17 +8,17 @@ module SwarmSDK
|
|
|
8
8
|
# Each agent maintains its own independent todo list.
|
|
9
9
|
class TodoWrite < RubyLLM::Tool
|
|
10
10
|
description <<~DESC
|
|
11
|
-
Use this tool to create and manage a structured task list for your current
|
|
11
|
+
Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
|
|
12
12
|
It also helps the user understand the progress of the task and overall progress of their requests.
|
|
13
13
|
|
|
14
14
|
## When to Use This Tool
|
|
15
15
|
Use this tool proactively in these scenarios:
|
|
16
16
|
|
|
17
17
|
**CRITICAL**: Follow this workflow for multi-step tasks:
|
|
18
|
-
1. FIRST: Analyze the task scope (
|
|
19
|
-
2. SECOND: Create a COMPLETE todo list with ALL known tasks BEFORE starting
|
|
18
|
+
1. FIRST: Analyze the task scope (gather information, understand requirements)
|
|
19
|
+
2. SECOND: Create a COMPLETE todo list with ALL known tasks BEFORE starting work
|
|
20
20
|
3. THIRD: Execute tasks, marking in_progress → completed as you work
|
|
21
|
-
4. ONLY add new todos if unexpected work is discovered during
|
|
21
|
+
4. ONLY add new todos if unexpected work is discovered during execution
|
|
22
22
|
|
|
23
23
|
Use the todo list when:
|
|
24
24
|
1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
|
|
@@ -27,7 +27,7 @@ module SwarmSDK
|
|
|
27
27
|
4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
|
|
28
28
|
5. After receiving new instructions - After analyzing scope, create complete todo list before starting work
|
|
29
29
|
6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
|
|
30
|
-
7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during
|
|
30
|
+
7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during execution
|
|
31
31
|
|
|
32
32
|
## When NOT to Use This Tool
|
|
33
33
|
|
|
@@ -73,9 +73,21 @@ module SwarmSDK
|
|
|
73
73
|
- Create specific, actionable items
|
|
74
74
|
- Break complex tasks into smaller, manageable steps
|
|
75
75
|
- Use clear, descriptive task names
|
|
76
|
-
- Always provide both forms
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
- Always provide both forms (content and activeForm)
|
|
77
|
+
|
|
78
|
+
## Examples
|
|
79
|
+
|
|
80
|
+
**Coding Tasks**:
|
|
81
|
+
- content: "Fix authentication bug in login handler"
|
|
82
|
+
- activeForm: "Fixing authentication bug in login handler"
|
|
83
|
+
|
|
84
|
+
**Non-Coding Tasks**:
|
|
85
|
+
- content: "Analyze customer feedback from Q4 survey"
|
|
86
|
+
- activeForm: "Analyzing customer feedback from Q4 survey"
|
|
87
|
+
|
|
88
|
+
**Research Tasks**:
|
|
89
|
+
- content: "Research best practices for API rate limiting"
|
|
90
|
+
- activeForm: "Researching best practices for API rate limiting"
|
|
79
91
|
|
|
80
92
|
When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
|
|
81
93
|
DESC
|
data/lib/swarm_sdk/version.rb
CHANGED