anima-core 0.2.1 → 1.0.0
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/.reek.yml +27 -1
- data/CHANGELOG.md +19 -0
- data/README.md +213 -43
- data/agents/codebase-analyzer.md +88 -0
- data/agents/codebase-pattern-finder.md +83 -0
- data/agents/documentation-researcher.md +59 -0
- data/agents/thoughts-analyzer.md +102 -0
- data/agents/web-search-researcher.md +71 -0
- data/anima-core.gemspec +3 -0
- data/app/channels/session_channel.rb +195 -45
- data/app/decorators/user_message_decorator.rb +16 -5
- data/app/jobs/agent_request_job.rb +55 -2
- data/app/jobs/analytical_brain_job.rb +33 -0
- data/app/jobs/count_event_tokens_job.rb +15 -4
- data/app/models/concerns/event/broadcasting.rb +81 -0
- data/app/models/event.rb +20 -1
- data/app/models/goal.rb +91 -0
- data/app/models/session.rb +366 -21
- data/config/application.rb +2 -0
- data/config/initializers/event_subscribers.rb +0 -1
- data/config/routes.rb +0 -6
- data/db/migrate/20260313010000_add_status_to_events.rb +8 -0
- data/db/migrate/20260313020000_add_processing_to_sessions.rb +7 -0
- data/db/migrate/20260314075248_add_subagent_support_to_sessions.rb +6 -0
- data/db/migrate/20260314112417_add_granted_tools_to_sessions.rb +5 -0
- data/db/migrate/20260314140000_add_name_to_sessions.rb +7 -0
- data/db/migrate/20260314150000_add_viewport_event_ids_to_sessions.rb +7 -0
- data/db/migrate/20260315100000_add_active_skills_to_sessions.rb +7 -0
- data/db/migrate/20260315140843_create_goals.rb +16 -0
- data/db/migrate/20260315144837_add_completed_at_to_goals.rb +5 -0
- data/db/migrate/20260315191105_add_active_workflow_to_sessions.rb +5 -0
- data/lib/agent_loop.rb +65 -6
- data/lib/agents/definition.rb +116 -0
- data/lib/agents/registry.rb +106 -0
- data/lib/analytical_brain/runner.rb +276 -0
- data/lib/analytical_brain/tools/activate_skill.rb +52 -0
- data/lib/analytical_brain/tools/deactivate_skill.rb +43 -0
- data/lib/analytical_brain/tools/deactivate_workflow.rb +34 -0
- data/lib/analytical_brain/tools/everything_is_ready.rb +28 -0
- data/lib/analytical_brain/tools/finish_goal.rb +62 -0
- data/lib/analytical_brain/tools/read_workflow.rb +58 -0
- data/lib/analytical_brain/tools/rename_session.rb +63 -0
- data/lib/analytical_brain/tools/set_goal.rb +60 -0
- data/lib/analytical_brain/tools/update_goal.rb +60 -0
- data/lib/analytical_brain.rb +23 -0
- data/lib/anima/cli/mcp/secrets.rb +76 -0
- data/lib/anima/cli/mcp.rb +197 -0
- data/lib/anima/cli.rb +5 -40
- data/lib/anima/installer.rb +168 -0
- data/lib/anima/settings.rb +226 -0
- data/lib/anima/version.rb +1 -1
- data/lib/anima.rb +9 -0
- data/lib/credential_store.rb +103 -0
- data/lib/environment_probe.rb +232 -0
- data/lib/events/subscribers/persister.rb +1 -0
- data/lib/events/user_message.rb +17 -0
- data/lib/llm/client.rb +29 -10
- data/lib/mcp/client_manager.rb +86 -0
- data/lib/mcp/config.rb +213 -0
- data/lib/mcp/health_check.rb +77 -0
- data/lib/mcp/secrets.rb +73 -0
- data/lib/mcp/stdio_transport.rb +206 -0
- data/lib/providers/anthropic.rb +11 -20
- data/lib/shell_session.rb +11 -10
- data/lib/skills/definition.rb +97 -0
- data/lib/skills/registry.rb +105 -0
- data/lib/tools/edit.rb +226 -0
- data/lib/tools/mcp_tool.rb +114 -0
- data/lib/tools/read.rb +151 -0
- data/lib/tools/registry.rb +14 -12
- data/lib/tools/request_feature.rb +121 -0
- data/lib/tools/return_result.rb +81 -0
- data/lib/tools/spawn_specialist.rb +109 -0
- data/lib/tools/spawn_subagent.rb +111 -0
- data/lib/tools/subagent_prompts.rb +12 -0
- data/lib/tools/web_get.rb +8 -9
- data/lib/tools/write.rb +86 -0
- data/lib/tui/app.rb +985 -26
- data/lib/tui/cable_client.rb +69 -31
- data/lib/tui/message_store.rb +103 -8
- data/lib/tui/screens/chat.rb +293 -45
- data/lib/workflows/definition.rb +97 -0
- data/lib/workflows/registry.rb +89 -0
- data/skills/activerecord/SKILL.md +255 -0
- data/skills/activerecord/examples/associations/association_extensions.rb +298 -0
- data/skills/activerecord/examples/associations/basic_associations.rb +118 -0
- data/skills/activerecord/examples/associations/counter_caches.rb +215 -0
- data/skills/activerecord/examples/associations/polymorphic_associations.rb +217 -0
- data/skills/activerecord/examples/associations/self_referential.rb +302 -0
- data/skills/activerecord/examples/associations/through_associations.rb +203 -0
- data/skills/activerecord/examples/basics/crud_operations.rb +209 -0
- data/skills/activerecord/examples/basics/dirty_tracking.rb +218 -0
- data/skills/activerecord/examples/basics/inheritance.rb +377 -0
- data/skills/activerecord/examples/basics/type_casting.rb +317 -0
- data/skills/activerecord/examples/callbacks/alternatives_to_callbacks.rb +447 -0
- data/skills/activerecord/examples/callbacks/conditional_callbacks.rb +353 -0
- data/skills/activerecord/examples/callbacks/lifecycle_callbacks.rb +280 -0
- data/skills/activerecord/examples/callbacks/transaction_callbacks.rb +340 -0
- data/skills/activerecord/examples/migrations/indexes_and_constraints.rb +337 -0
- data/skills/activerecord/examples/migrations/reversible_patterns.rb +403 -0
- data/skills/activerecord/examples/migrations/safe_patterns.rb +420 -0
- data/skills/activerecord/examples/migrations/schema_changes.rb +277 -0
- data/skills/activerecord/examples/querying/batch_processing.rb +226 -0
- data/skills/activerecord/examples/querying/eager_loading.rb +259 -0
- data/skills/activerecord/examples/querying/finder_methods.rb +170 -0
- data/skills/activerecord/examples/querying/optimization.rb +275 -0
- data/skills/activerecord/examples/querying/scopes.rb +260 -0
- data/skills/activerecord/examples/validations/built_in_validators.rb +277 -0
- data/skills/activerecord/examples/validations/conditional_validations.rb +288 -0
- data/skills/activerecord/examples/validations/custom_validators.rb +381 -0
- data/skills/activerecord/examples/validations/database_constraints.rb +432 -0
- data/skills/activerecord/examples/validations/validation_contexts.rb +367 -0
- data/skills/activerecord/references/associations.md +709 -0
- data/skills/activerecord/references/basics.md +622 -0
- data/skills/activerecord/references/callbacks.md +738 -0
- data/skills/activerecord/references/migrations.md +657 -0
- data/skills/activerecord/references/querying.md +655 -0
- data/skills/activerecord/references/validations.md +596 -0
- data/skills/dragonruby/SKILL.md +250 -0
- data/skills/dragonruby/examples/audio/audio_events.rb +55 -0
- data/skills/dragonruby/examples/audio/background_music.rb +29 -0
- data/skills/dragonruby/examples/audio/crossfade.rb +51 -0
- data/skills/dragonruby/examples/audio/music_controls.rb +51 -0
- data/skills/dragonruby/examples/audio/sound_effects.rb +30 -0
- data/skills/dragonruby/examples/core/coordinate_system.rb +27 -0
- data/skills/dragonruby/examples/core/hello_world.rb +24 -0
- data/skills/dragonruby/examples/core/labels.rb +22 -0
- data/skills/dragonruby/examples/core/sprites.rb +35 -0
- data/skills/dragonruby/examples/core/state_management.rb +29 -0
- data/skills/dragonruby/examples/distribution/background_pause.rb +42 -0
- data/skills/dragonruby/examples/distribution/build_workflow.sh +26 -0
- data/skills/dragonruby/examples/distribution/cvars_production.txt +16 -0
- data/skills/dragonruby/examples/distribution/game_metadata_hd.txt +23 -0
- data/skills/dragonruby/examples/distribution/game_metadata_minimal.txt +9 -0
- data/skills/dragonruby/examples/distribution/game_metadata_mobile.txt +31 -0
- data/skills/dragonruby/examples/distribution/platform_detection.rb +36 -0
- data/skills/dragonruby/examples/distribution/steam_metadata.txt +19 -0
- data/skills/dragonruby/examples/entities/collision_detection.rb +43 -0
- data/skills/dragonruby/examples/entities/entity_lifecycle.rb +68 -0
- data/skills/dragonruby/examples/entities/entity_storage.rb +38 -0
- data/skills/dragonruby/examples/entities/factory_methods.rb +45 -0
- data/skills/dragonruby/examples/entities/random_spawning.rb +50 -0
- data/skills/dragonruby/examples/game-logic/reset_patterns.rb +98 -0
- data/skills/dragonruby/examples/game-logic/save_load.rb +101 -0
- data/skills/dragonruby/examples/game-logic/scoring.rb +104 -0
- data/skills/dragonruby/examples/game-logic/state_transitions.rb +103 -0
- data/skills/dragonruby/examples/game-logic/timers.rb +87 -0
- data/skills/dragonruby/examples/input/action_triggers.rb +36 -0
- data/skills/dragonruby/examples/input/analog_movement.rb +28 -0
- data/skills/dragonruby/examples/input/controller_input.rb +28 -0
- data/skills/dragonruby/examples/input/directional_input.rb +24 -0
- data/skills/dragonruby/examples/input/keyboard_input.rb +28 -0
- data/skills/dragonruby/examples/input/mouse_click.rb +26 -0
- data/skills/dragonruby/examples/input/movement_with_bounds.rb +22 -0
- data/skills/dragonruby/examples/input/normalized_movement.rb +32 -0
- data/skills/dragonruby/examples/rendering/frame_animation.rb +32 -0
- data/skills/dragonruby/examples/rendering/labels.rb +32 -0
- data/skills/dragonruby/examples/rendering/layering.rb +51 -0
- data/skills/dragonruby/examples/rendering/solids.rb +61 -0
- data/skills/dragonruby/examples/rendering/sprites.rb +33 -0
- data/skills/dragonruby/examples/rendering/spritesheet_animation.rb +39 -0
- data/skills/dragonruby/examples/scenes/case_dispatch.rb +60 -0
- data/skills/dragonruby/examples/scenes/class_based.rb +150 -0
- data/skills/dragonruby/examples/scenes/pause_overlay.rb +100 -0
- data/skills/dragonruby/examples/scenes/safe_transitions.rb +68 -0
- data/skills/dragonruby/examples/scenes/scene_transitions.rb +98 -0
- data/skills/dragonruby/examples/scenes/send_dispatch.rb +88 -0
- data/skills/dragonruby/references/audio.md +396 -0
- data/skills/dragonruby/references/core.md +385 -0
- data/skills/dragonruby/references/distribution.md +434 -0
- data/skills/dragonruby/references/entities.md +516 -0
- data/skills/dragonruby/references/game-logic/persistence.md +386 -0
- data/skills/dragonruby/references/game-logic/state.md +389 -0
- data/skills/dragonruby/references/input.md +414 -0
- data/skills/dragonruby/references/rendering/animation.md +467 -0
- data/skills/dragonruby/references/rendering/primitives.md +403 -0
- data/skills/dragonruby/references/scenes.md +443 -0
- data/skills/draper-decorators/SKILL.md +344 -0
- data/skills/draper-decorators/examples/application_decorator.rb +61 -0
- data/skills/draper-decorators/examples/decorator_spec.rb +253 -0
- data/skills/draper-decorators/examples/model_decorator.rb +152 -0
- data/skills/draper-decorators/references/anti-patterns.md +640 -0
- data/skills/draper-decorators/references/patterns.md +507 -0
- data/skills/draper-decorators/references/testing.md +559 -0
- data/skills/gh-issue.md +182 -0
- data/skills/mcp-server/SKILL.md +177 -0
- data/skills/mcp-server/examples/dynamic_tools.rb +36 -0
- data/skills/mcp-server/examples/file_manager_tool.rb +85 -0
- data/skills/mcp-server/examples/http_client.rb +48 -0
- data/skills/mcp-server/examples/http_server.rb +97 -0
- data/skills/mcp-server/examples/rails_integration.rb +88 -0
- data/skills/mcp-server/examples/stdio_server.rb +108 -0
- data/skills/mcp-server/examples/streaming_client.rb +95 -0
- data/skills/mcp-server/references/gotchas.md +183 -0
- data/skills/mcp-server/references/prompts.md +98 -0
- data/skills/mcp-server/references/resources.md +53 -0
- data/skills/mcp-server/references/server.md +140 -0
- data/skills/mcp-server/references/tools.md +146 -0
- data/skills/mcp-server/references/transport.md +104 -0
- data/skills/ratatui-ruby/SKILL.md +315 -0
- data/skills/ratatui-ruby/references/core-concepts.md +340 -0
- data/skills/ratatui-ruby/references/events.md +387 -0
- data/skills/ratatui-ruby/references/frameworks.md +522 -0
- data/skills/ratatui-ruby/references/layout.md +423 -0
- data/skills/ratatui-ruby/references/styling.md +268 -0
- data/skills/ratatui-ruby/references/testing.md +433 -0
- data/skills/ratatui-ruby/references/widgets.md +532 -0
- data/skills/rspec/SKILL.md +340 -0
- data/skills/rspec/examples/core/basic_structure.rb +69 -0
- data/skills/rspec/examples/core/configuration.rb +126 -0
- data/skills/rspec/examples/core/hooks.rb +126 -0
- data/skills/rspec/examples/core/memoized_helpers.rb +139 -0
- data/skills/rspec/examples/core/metadata_filtering.rb +144 -0
- data/skills/rspec/examples/core/shared_examples.rb +145 -0
- data/skills/rspec/examples/factory_bot/associations.rb +314 -0
- data/skills/rspec/examples/factory_bot/build_strategies.rb +272 -0
- data/skills/rspec/examples/factory_bot/callbacks.rb +320 -0
- data/skills/rspec/examples/factory_bot/custom_construction.rb +328 -0
- data/skills/rspec/examples/factory_bot/factory_definition.rb +191 -0
- data/skills/rspec/examples/factory_bot/inheritance.rb +314 -0
- data/skills/rspec/examples/factory_bot/traits.rb +293 -0
- data/skills/rspec/examples/factory_bot/transients.rb +229 -0
- data/skills/rspec/examples/matchers/change.rb +115 -0
- data/skills/rspec/examples/matchers/collections.rb +154 -0
- data/skills/rspec/examples/matchers/comparisons.rb +79 -0
- data/skills/rspec/examples/matchers/composing.rb +155 -0
- data/skills/rspec/examples/matchers/custom_matchers.rb +197 -0
- data/skills/rspec/examples/matchers/equality.rb +58 -0
- data/skills/rspec/examples/matchers/errors.rb +136 -0
- data/skills/rspec/examples/matchers/output.rb +103 -0
- data/skills/rspec/examples/matchers/predicates.rb +87 -0
- data/skills/rspec/examples/matchers/truthiness.rb +101 -0
- data/skills/rspec/examples/matchers/types.rb +82 -0
- data/skills/rspec/examples/matchers/yield.rb +147 -0
- data/skills/rspec/examples/mocks/any_instance.rb +172 -0
- data/skills/rspec/examples/mocks/argument_matchers.rb +206 -0
- data/skills/rspec/examples/mocks/constants.rb +177 -0
- data/skills/rspec/examples/mocks/doubles.rb +139 -0
- data/skills/rspec/examples/mocks/expectations.rb +137 -0
- data/skills/rspec/examples/mocks/message_chains.rb +173 -0
- data/skills/rspec/examples/mocks/ordering.rb +144 -0
- data/skills/rspec/examples/mocks/receive_counts.rb +181 -0
- data/skills/rspec/examples/mocks/responses.rb +223 -0
- data/skills/rspec/examples/mocks/spies.rb +149 -0
- data/skills/rspec/examples/mocks/stubbing.rb +133 -0
- data/skills/rspec/examples/rails/channels.rb +250 -0
- data/skills/rspec/examples/rails/controller_specs.rb +302 -0
- data/skills/rspec/examples/rails/helper_specs.rb +245 -0
- data/skills/rspec/examples/rails/job_specs.rb +256 -0
- data/skills/rspec/examples/rails/mailer_specs.rb +228 -0
- data/skills/rspec/examples/rails/matchers.rb +374 -0
- data/skills/rspec/examples/rails/model_specs.rb +193 -0
- data/skills/rspec/examples/rails/request_specs.rb +275 -0
- data/skills/rspec/examples/rails/routing_specs.rb +276 -0
- data/skills/rspec/examples/rails/system_specs.rb +294 -0
- data/skills/rspec/examples/rails/transactions.rb +254 -0
- data/skills/rspec/examples/rails/view_specs.rb +252 -0
- data/skills/rspec/references/core.md +816 -0
- data/skills/rspec/references/factory_bot.md +641 -0
- data/skills/rspec/references/matchers.md +516 -0
- data/skills/rspec/references/mocks.md +381 -0
- data/skills/rspec/references/rails.md +528 -0
- data/templates/soul.md +40 -0
- data/workflows/commit.md +45 -0
- data/workflows/create_handoff.md +98 -0
- data/workflows/create_note.md +82 -0
- data/workflows/create_plan.md +457 -0
- data/workflows/decompose_ticket.md +109 -0
- data/workflows/feature.md +91 -0
- data/workflows/implement_plan.md +87 -0
- data/workflows/iterate_plan.md +247 -0
- data/workflows/research_codebase.md +210 -0
- data/workflows/resume_handoff.md +217 -0
- data/workflows/review_pr.md +320 -0
- data/workflows/thoughts_init.md +71 -0
- data/workflows/validate_plan.md +166 -0
- metadata +290 -3
- data/app/controllers/api/sessions_controller.rb +0 -25
- data/lib/events/subscribers/action_cable_bridge.rb +0 -59
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dc93f4b5db26b568dfab170e30d994cb8eef9c46c82efa840fe1824c7b0208ec
|
|
4
|
+
data.tar.gz: dedf6e6b8847b679a4dc9614992ca0c7f535199d9f53efc88b224acd73b87b17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9a846df2eea35a39991e594515501003074b39b8d7e9682c5c3f50cf37257e37d4b7e966df9351258fcf2daa3cb7cdbda84fab3f035e886e86419a49e9ccfae
|
|
7
|
+
data.tar.gz: 16c00ccc5a67b7b1dd8f06f7db1e4e7407edfa4f887ca645525f03f5679f1b961bea17534518ce312a3f59d44b57e527e51c95375c8fffae02de19ca13c86675
|
data/.reek.yml
CHANGED
|
@@ -9,10 +9,36 @@ detectors:
|
|
|
9
9
|
# Bang methods don't need safe counterparts in this codebase
|
|
10
10
|
MissingSafeMethod:
|
|
11
11
|
enabled: false
|
|
12
|
-
#
|
|
12
|
+
# Nil check in Settings#get is business logic — nil means a missing config key
|
|
13
|
+
NilCheck:
|
|
14
|
+
exclude:
|
|
15
|
+
- "Anima::Settings#get"
|
|
16
|
+
# Rescue blocks naturally reference the error object more than self.
|
|
17
|
+
# EnvironmentProbe assembles output from local data structures — not envy.
|
|
18
|
+
FeatureEnvy:
|
|
19
|
+
exclude:
|
|
20
|
+
- "AnalyticalBrainJob#perform"
|
|
21
|
+
- "EnvironmentProbe"
|
|
22
|
+
# Private helpers don't need instance state to be valid.
|
|
23
|
+
# ActiveJob#perform is always a utility function by design.
|
|
13
24
|
UtilityFunction:
|
|
14
25
|
public_methods_only: true
|
|
26
|
+
exclude:
|
|
27
|
+
- "AnalyticalBrainJob#perform"
|
|
28
|
+
# Session model is the core domain object — methods grow naturally.
|
|
29
|
+
# Mcp CLI accumulates subcommand helpers across add/remove/list/secrets.
|
|
30
|
+
# EnvironmentProbe probes multiple orthogonal facets (OS, Git, project files).
|
|
31
|
+
# Each facet needs its own detection + formatting methods.
|
|
32
|
+
TooManyMethods:
|
|
33
|
+
exclude:
|
|
34
|
+
- "Session"
|
|
35
|
+
- "Anima::CLI::Mcp"
|
|
36
|
+
- "EnvironmentProbe"
|
|
37
|
+
# Method length is enforced by code review, not arbitrary line counts
|
|
38
|
+
TooManyStatements:
|
|
39
|
+
enabled: false
|
|
15
40
|
|
|
16
41
|
# TUI render methods receive (frame, tui) by design — RatatuiRuby convention
|
|
17
42
|
exclude_paths:
|
|
18
43
|
- lib/tui
|
|
44
|
+
- skills
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
### Added
|
|
4
|
+
- Directory-based skills format — `skills/skill-name/SKILL.md` with optional `references/` and `examples/` subdirectories alongside flat `.md` files (#152)
|
|
5
|
+
- Import 6 marketplace skills: activerecord, rspec, draper-decorators, dragonruby, ratatui-ruby, mcp-server (#152)
|
|
6
|
+
- Tmux-style focus switching — `Ctrl+A ↑` enters chat scrolling mode with yellow border, `Escape` returns to input; arrow keys and Page Up/Down scroll chat, mouse scroll works in both modes (#87)
|
|
7
|
+
- Bash-style input history — press ↑ at top of input to recall previous messages, ↓ to navigate forward; original draft restored when exiting history (#87)
|
|
8
|
+
- Real-time event broadcasting via `Event::Broadcasting` concern — `after_create_commit` and `after_update_commit` callbacks broadcast decorated payloads with database ID and action type to the session's ActionCable stream (#91)
|
|
9
|
+
- TUI `MessageStore` ID-indexed updates — events with `action: "update"` replace existing entries in-place (O(1) lookup) without changing display order
|
|
10
|
+
- `CountEventTokensJob` triggers broadcast — uses `update!` so token count updates push to connected clients in real time
|
|
11
|
+
- Connection status constants in `CableClient` — replaces magic strings with named constants for protocol message types
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Connection status indicator simplified — emoji-only `🟢` for normal state, descriptive text only for abnormal states (#80)
|
|
15
|
+
- `STATUS_STYLES` structure simplified from `{label, fg, bg}` to `{label, color}` (#80)
|
|
16
|
+
- `ActionCableBridge` removed — broadcasting moved from EventBus subscriber to AR callbacks, eliminating the timing gap where events were broadcast before persistence
|
|
17
|
+
- `SessionChannel` history includes event IDs for client-side correlation
|
|
18
|
+
|
|
19
|
+
### Fixed
|
|
20
|
+
- TUI showed empty chat on reconnect — message store was cleared _after_ history arrived because `confirm_subscription` comes after `transmit` in Action Cable protocol; now clears on "subscribing" before history (#82)
|
|
21
|
+
|
|
3
22
|
## [0.2.1] - 2026-03-13
|
|
4
23
|
|
|
5
24
|
### Added
|
data/README.md
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
# Anima
|
|
2
2
|
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
|
|
3
5
|
**A personal AI agent that actually wants things.**
|
|
4
6
|
|
|
5
7
|
Your agent. Your machine. Your rules. Anima is an AI agent with desires, personality, and personal growth — running locally as a headless Rails 8.1 app with a client-server architecture and TUI interface.
|
|
6
8
|
|
|
9
|
+
## Table of Contents
|
|
10
|
+
|
|
11
|
+
- [The Problem](#the-problem)
|
|
12
|
+
- [The Insight](#the-insight)
|
|
13
|
+
- [Core Concepts](#core-concepts)
|
|
14
|
+
- [Architecture](#architecture)
|
|
15
|
+
- [Agent Capabilities](#agent-capabilities)
|
|
16
|
+
- [Tools](#tools)
|
|
17
|
+
- [Sub-Agents](#sub-agents)
|
|
18
|
+
- [Skills](#skills)
|
|
19
|
+
- [Workflows](#workflows)
|
|
20
|
+
- [MCP Integration](#mcp-integration)
|
|
21
|
+
- [Analytical Brain](#analytical-brain)
|
|
22
|
+
- [Configuration](#configuration)
|
|
23
|
+
- [Design](#design)
|
|
24
|
+
- [Three Layers](#three-layers-mirroring-biology)
|
|
25
|
+
- [Event-Driven Design](#event-driven-design)
|
|
26
|
+
- [Context as Viewport](#context-as-viewport-not-tape)
|
|
27
|
+
- [Brain as Microservices](#brain-as-microservices-on-a-shared-event-bus)
|
|
28
|
+
- [TUI View Modes](#tui-view-modes)
|
|
29
|
+
- [Plugin Architecture](#plugin-architecture)
|
|
30
|
+
- [Semantic Memory](#semantic-memory-mneme)
|
|
31
|
+
- [Analogy Map](#analogy-map)
|
|
32
|
+
- [Emergent Properties](#emergent-properties)
|
|
33
|
+
- [Frustration: A Worked Example](#frustration-a-worked-example)
|
|
34
|
+
- [Open Questions](#open-questions)
|
|
35
|
+
- [Prior Art](#prior-art)
|
|
36
|
+
- [Status](#status)
|
|
37
|
+
- [Development](#development)
|
|
38
|
+
- [License](#license)
|
|
39
|
+
|
|
7
40
|
## The Problem
|
|
8
41
|
|
|
9
42
|
Current AI agents are reactive. They receive input, produce output. They don't *want* anything. They don't have moods, preferences, or personal growth. They simulate personality through static prompt descriptions rather than emerging it from dynamic internal states.
|
|
@@ -61,21 +94,29 @@ Existing RL techniques apply at the starting point, then we gradually expand int
|
|
|
61
94
|
|
|
62
95
|
```
|
|
63
96
|
Anima (Ruby, Rails 8.1 headless)
|
|
64
|
-
├──
|
|
65
|
-
├──
|
|
66
|
-
├──
|
|
67
|
-
|
|
97
|
+
├── Nous — LLM integration (cortex, thinking, decisions, tool use)
|
|
98
|
+
├── Analytical — subconscious background brain (naming, skills, goals)
|
|
99
|
+
├── Skills — domain knowledge bundles (Markdown, user-extensible)
|
|
100
|
+
├── Workflows — operational recipes for multi-step tasks
|
|
101
|
+
├── MCP — external tool integration (Model Context Protocol)
|
|
102
|
+
├── Sub-agents — autonomous child sessions (specialists + generic)
|
|
103
|
+
├── Thymos — hormonal/desire system (stimulus → hormone vector) [planned]
|
|
104
|
+
├── Mneme — semantic memory (QMD-style, emotional recall) [planned]
|
|
105
|
+
└── Psyche — soul matrix (coefficient table, evolving) [planned]
|
|
68
106
|
```
|
|
69
107
|
|
|
70
108
|
### Runtime Architecture
|
|
71
109
|
|
|
72
|
-
Anima runs as a client-server system:
|
|
73
|
-
|
|
74
110
|
```
|
|
75
111
|
Brain Server (Rails + Puma) TUI Client (RatatuiRuby)
|
|
76
112
|
├── LLM integration (Anthropic) ├── WebSocket client
|
|
77
113
|
├── Agent loop + tool execution ├── Terminal rendering
|
|
78
|
-
├──
|
|
114
|
+
├── Analytical brain (background) └── User input capture
|
|
115
|
+
├── Skills registry + activation
|
|
116
|
+
├── Workflow registry + activation
|
|
117
|
+
├── MCP client (HTTP + stdio)
|
|
118
|
+
├── Sub-agent spawning
|
|
119
|
+
├── Event bus + persistence
|
|
79
120
|
├── Solid Queue (background jobs)
|
|
80
121
|
├── Action Cable (WebSocket server)
|
|
81
122
|
└── SQLite databases ◄── WebSocket (port 42134) ──► TUI
|
|
@@ -90,10 +131,12 @@ The **Brain** is the persistent service — it handles LLM calls, tool execution
|
|
|
90
131
|
| Framework | Rails 8.1 (headless — no web views, no asset pipeline) |
|
|
91
132
|
| Database | SQLite (3 databases per environment: primary, queue, cable) |
|
|
92
133
|
| Event system | Rails Structured Event Reporter + Action Cable bridge |
|
|
93
|
-
| LLM integration | Anthropic API (Claude Sonnet 4) |
|
|
134
|
+
| LLM integration | Anthropic API (Claude Sonnet 4, Claude Haiku 4.5) |
|
|
135
|
+
| External tools | Model Context Protocol (HTTP + stdio transports) |
|
|
94
136
|
| Transport | Action Cable WebSocket (Solid Cable adapter) |
|
|
95
137
|
| Background jobs | Solid Queue |
|
|
96
138
|
| Interface | TUI via RatatuiRuby (WebSocket client) |
|
|
139
|
+
| Configuration | TOML with hot-reload (`Anima::Settings`) |
|
|
97
140
|
| Process management | Foreman |
|
|
98
141
|
| Distribution | RubyGems (`gem install anima-core`) |
|
|
99
142
|
|
|
@@ -118,10 +161,15 @@ journalctl --user -u anima # View logs
|
|
|
118
161
|
State directory (`~/.anima/`):
|
|
119
162
|
```
|
|
120
163
|
~/.anima/
|
|
121
|
-
├── db/ # SQLite databases (production, development, test)
|
|
122
164
|
├── config/
|
|
123
165
|
│ ├── credentials/ # Rails encrypted credentials per environment
|
|
124
|
-
│ └── anima.yml #
|
|
166
|
+
│ └── anima.yml # Placeholder config
|
|
167
|
+
├── config.toml # Main settings (hot-reloadable)
|
|
168
|
+
├── mcp.toml # MCP server configuration
|
|
169
|
+
├── agents/ # User-defined specialist agents (override built-ins)
|
|
170
|
+
├── skills/ # User-defined skills (override built-ins)
|
|
171
|
+
├── workflows/ # User-defined workflows (override built-ins)
|
|
172
|
+
├── db/ # SQLite databases (production, development, test)
|
|
125
173
|
├── log/
|
|
126
174
|
└── tmp/
|
|
127
175
|
```
|
|
@@ -130,37 +178,157 @@ Updates: `gem update anima-core` — next launch runs pending migrations automat
|
|
|
130
178
|
|
|
131
179
|
### Authentication Setup
|
|
132
180
|
|
|
133
|
-
Anima uses your Claude Pro/Max subscription for API access. You need a setup-token from Claude Code CLI.
|
|
181
|
+
Anima uses your Claude Pro/Max subscription for API access. You need a setup-token from [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code).
|
|
134
182
|
|
|
135
|
-
|
|
183
|
+
1. Run `claude setup-token` in a terminal to get your token
|
|
184
|
+
2. In the TUI, press `Ctrl+a → a` to open the token setup popup
|
|
185
|
+
3. Paste the token and press Enter — Anima validates it against the Anthropic API and saves it to encrypted credentials
|
|
136
186
|
|
|
137
|
-
|
|
138
|
-
claude setup-token
|
|
139
|
-
```
|
|
187
|
+
The popup also activates automatically when Anima detects a missing or invalid token. If the token expires, repeat the process with a new one.
|
|
140
188
|
|
|
141
|
-
|
|
189
|
+
## Agent Capabilities
|
|
142
190
|
|
|
143
|
-
|
|
191
|
+
### Tools
|
|
144
192
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
193
|
+
The agent has access to these built-in tools:
|
|
194
|
+
|
|
195
|
+
| Tool | Description |
|
|
196
|
+
|------|-------------|
|
|
197
|
+
| `bash` | Execute shell commands with persistent working directory |
|
|
198
|
+
| `read` | Read files with smart truncation and offset/limit paging |
|
|
199
|
+
| `write` | Create or overwrite files |
|
|
200
|
+
| `edit` | Surgical text replacement with uniqueness constraint |
|
|
201
|
+
| `web_get` | Fetch content from HTTP/HTTPS URLs |
|
|
202
|
+
| `spawn_specialist` | Spawn a named specialist sub-agent from the registry |
|
|
203
|
+
| `spawn_subagent` | Spawn a generic child session with custom tool grants |
|
|
204
|
+
| `return_result` | Sub-agents only — deliver results back to parent |
|
|
205
|
+
|
|
206
|
+
Plus dynamic tools from configured MCP servers, namespaced as `server_name__tool_name`.
|
|
207
|
+
|
|
208
|
+
### Sub-Agents
|
|
209
|
+
|
|
210
|
+
Two types of autonomous child sessions:
|
|
211
|
+
|
|
212
|
+
**Named Specialists** — predefined agents with specific roles and tool sets, defined in `agents/` (built-in or user-overridable):
|
|
213
|
+
|
|
214
|
+
| Specialist | Role |
|
|
215
|
+
|-----------|------|
|
|
216
|
+
| `codebase-analyzer` | Analyze implementation details |
|
|
217
|
+
| `codebase-pattern-finder` | Find similar patterns and usage examples |
|
|
218
|
+
| `documentation-researcher` | Fetch library docs and provide code examples |
|
|
219
|
+
| `thoughts-analyzer` | Extract decisions from project history |
|
|
220
|
+
| `web-search-researcher` | Research questions via web search |
|
|
221
|
+
|
|
222
|
+
**Generic Sub-agents** — child sessions that inherit parent context and run autonomously with custom tool grants.
|
|
223
|
+
|
|
224
|
+
Sub-agents run as background jobs, return results via `return_result`, and appear in the TUI session picker under their parent.
|
|
225
|
+
|
|
226
|
+
### Skills
|
|
227
|
+
|
|
228
|
+
Domain knowledge bundles loaded from Markdown files. Skills provide specialized expertise that the analytical brain activates and deactivates based on conversation context.
|
|
229
|
+
|
|
230
|
+
- **Built-in skills:** ActiveRecord, Draper decorators, DragonRuby, MCP server, RatatuiRuby, RSpec, GitHub issues
|
|
231
|
+
- **User skills:** Drop `.md` files into `~/.anima/skills/` to add custom knowledge
|
|
232
|
+
- **Override:** User skills with the same name replace built-in ones
|
|
233
|
+
- **Format:** Flat files (`skill-name.md`) or directories (`skill-name/SKILL.md` with `examples/` and `references/`)
|
|
234
|
+
|
|
235
|
+
Active skills are displayed in the TUI info panel.
|
|
236
|
+
|
|
237
|
+
### Workflows
|
|
238
|
+
|
|
239
|
+
Operational recipes that describe multi-step tasks. Unlike skills (domain knowledge), workflows describe WHAT to do. The analytical brain activates a workflow when it recognizes a matching task, converts the prose into tracked goals, and deactivates it when done.
|
|
240
|
+
|
|
241
|
+
- **Built-in workflows:** `feature`, `commit`, `create_plan`, `implement_plan`, `review_pr`, `create_note`, `research_codebase`, `decompose_ticket`, and more
|
|
242
|
+
- **User workflows:** Drop `.md` files into `~/.anima/workflows/` to add custom workflows
|
|
243
|
+
- **Override:** User workflows with the same name replace built-in ones
|
|
244
|
+
- **Single active:** Only one workflow can be active at a time (unlike skills which stack)
|
|
245
|
+
|
|
246
|
+
Workflow files use the same YAML frontmatter format as skills:
|
|
247
|
+
|
|
248
|
+
```markdown
|
|
249
|
+
---
|
|
250
|
+
name: create_note
|
|
251
|
+
description: "Capture findings or context as a persistent note."
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Create Note
|
|
255
|
+
|
|
256
|
+
You are tasked with capturing content as a persistent note...
|
|
148
257
|
```
|
|
149
258
|
|
|
150
|
-
|
|
259
|
+
The active workflow is shown in the TUI info panel with a 🔄 indicator. The full lifecycle — activation, goal creation, execution, deactivation — is managed by the analytical brain using judgment, not hardcoded triggers.
|
|
260
|
+
|
|
261
|
+
### MCP Integration
|
|
262
|
+
|
|
263
|
+
Full [Model Context Protocol](https://modelcontextprotocol.io/) support for external tool integration. Configure servers in `~/.anima/mcp.toml`:
|
|
264
|
+
|
|
265
|
+
```toml
|
|
266
|
+
[servers.mythonix]
|
|
267
|
+
transport = "http"
|
|
268
|
+
url = "http://localhost:3000/mcp/v2"
|
|
151
269
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
270
|
+
[servers.linear]
|
|
271
|
+
transport = "http"
|
|
272
|
+
url = "https://mcp.linear.app/mcp"
|
|
273
|
+
headers = { Authorization = "Bearer ${credential:linear_api_key}" }
|
|
274
|
+
|
|
275
|
+
[servers.filesystem]
|
|
276
|
+
transport = "stdio"
|
|
277
|
+
command = "mcp-server-filesystem"
|
|
278
|
+
args = ["--root", "/workspace"]
|
|
155
279
|
```
|
|
156
280
|
|
|
157
|
-
|
|
281
|
+
Manage servers and secrets via CLI:
|
|
158
282
|
|
|
159
283
|
```bash
|
|
160
|
-
|
|
284
|
+
anima mcp list # List servers with health status
|
|
285
|
+
anima mcp add sentry https://mcp.sentry.dev/mcp # Add HTTP server
|
|
286
|
+
anima mcp add fs -- mcp-server-filesystem --root / # Add stdio server
|
|
287
|
+
anima mcp add -s api_key=sk-xxx linear https://... # Add with secret
|
|
288
|
+
anima mcp remove sentry # Remove server
|
|
289
|
+
|
|
290
|
+
anima mcp secrets set linear_api_key=sk-xxx # Store secret in encrypted credentials
|
|
291
|
+
anima mcp secrets list # List secret names (not values)
|
|
292
|
+
anima mcp secrets remove linear_api_key # Remove secret
|
|
161
293
|
```
|
|
162
294
|
|
|
163
|
-
|
|
295
|
+
Secrets are stored in Rails encrypted credentials and interpolated via `${credential:key_name}` syntax in any TOML string value.
|
|
296
|
+
|
|
297
|
+
### Analytical Brain
|
|
298
|
+
|
|
299
|
+
A subconscious background process that observes the main conversation and performs maintenance:
|
|
300
|
+
|
|
301
|
+
- **Session naming** — generates emoji + short name when topic becomes clear
|
|
302
|
+
- **Skill activation** — activates/deactivates domain skills based on context
|
|
303
|
+
- **Goal tracking** — creates root goals and sub-goals as the conversation progresses, marks them complete
|
|
304
|
+
|
|
305
|
+
Goals form a two-level hierarchy (root goals with sub-goals) and are displayed in the TUI. The analytical brain uses a fast model (Claude Haiku 4.5) for speed and runs as a non-persisted "phantom" session.
|
|
306
|
+
|
|
307
|
+
### Configuration
|
|
308
|
+
|
|
309
|
+
All tunable values are exposed through `~/.anima/config.toml` with hot-reload (no restart needed):
|
|
310
|
+
|
|
311
|
+
```toml
|
|
312
|
+
[llm]
|
|
313
|
+
model = "claude-sonnet-4-20250514"
|
|
314
|
+
fast_model = "claude-haiku-4-5-20251001"
|
|
315
|
+
max_tokens = 16384
|
|
316
|
+
token_budget = 190000
|
|
317
|
+
|
|
318
|
+
[timeouts]
|
|
319
|
+
api = 120
|
|
320
|
+
command = 30
|
|
321
|
+
|
|
322
|
+
[analytical_brain]
|
|
323
|
+
max_tokens = 4096
|
|
324
|
+
blocking_on_user_message = true
|
|
325
|
+
event_window = 30
|
|
326
|
+
|
|
327
|
+
[session]
|
|
328
|
+
name_generation_interval = 3
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Design
|
|
164
332
|
|
|
165
333
|
### Three Layers (mirroring biology)
|
|
166
334
|
|
|
@@ -186,7 +354,7 @@ Five event types form the agent's nervous system:
|
|
|
186
354
|
|
|
187
355
|
Events flow through two channels:
|
|
188
356
|
1. **In-process** — Rails Structured Event Reporter (local subscribers like Persister)
|
|
189
|
-
2. **Over the wire** — Action Cable WebSocket (
|
|
357
|
+
2. **Over the wire** — Action Cable WebSocket (`Event::Broadcasting` callbacks push to connected TUI clients)
|
|
190
358
|
|
|
191
359
|
Events fire, subscribers react, state updates, the cortex (LLM) reads the resulting desire landscape. The system prompt is assembled separately for each LLM call — it is not an event.
|
|
192
360
|
|
|
@@ -196,21 +364,9 @@ There is no linear chat history. There are only events attached to a session. Th
|
|
|
196
364
|
|
|
197
365
|
Currently uses a simple sliding window (newest events first, walk backwards until budget exhausted). Future versions will add associative recall from Mneme.
|
|
198
366
|
|
|
199
|
-
### TUI View Modes
|
|
200
|
-
|
|
201
|
-
Three switchable view modes let you control how much detail the TUI shows. Cycle with `Ctrl+a → v`:
|
|
202
|
-
|
|
203
|
-
| Mode | What you see |
|
|
204
|
-
|------|-------------|
|
|
205
|
-
| **Basic** (default) | User + assistant messages. Tool calls are hidden but summarized as an inline counter: `🔧 Tools: 2/2 ✓` |
|
|
206
|
-
| **Verbose** | Everything in Basic, plus timestamps `[HH:MM:SS]`, tool call previews (`🔧 bash` / `$ command` / `↩ response`), and system messages |
|
|
207
|
-
| **Debug** | Full X-ray view — timestamps, token counts per message (`[14 tok]`), full tool call args, full tool responses, tool use IDs |
|
|
208
|
-
|
|
209
|
-
View modes are implemented via Draper decorators that operate at the transport layer. Each event type has a dedicated decorator (`UserMessageDecorator`, `ToolCallDecorator`, etc.) that returns structured data — the TUI renders it. Mode is stored on the `Session` model server-side, so it persists across reconnections.
|
|
210
|
-
|
|
211
367
|
### Brain as Microservices on a Shared Event Bus
|
|
212
368
|
|
|
213
|
-
The human brain isn't a single process — it's dozens of specialized subsystems
|
|
369
|
+
The human brain isn't a single process — it's dozens of specialized subsystems communicating through shared chemical and electrical signals. The prefrontal cortex doesn't "call" the amygdala. They both react to the same event independently, and their outputs combine.
|
|
214
370
|
|
|
215
371
|
Anima mirrors this with an event-driven architecture:
|
|
216
372
|
|
|
@@ -230,6 +386,18 @@ Event: "user_sent_message"
|
|
|
230
386
|
|
|
231
387
|
Each subscriber is a microservice — independent, stateless, reacting to the same event bus. No orchestrator decides "now update frustration." The architecture IS the nervous system.
|
|
232
388
|
|
|
389
|
+
### TUI View Modes
|
|
390
|
+
|
|
391
|
+
Three switchable view modes let you control how much detail the TUI shows. Cycle with `Ctrl+a → v`:
|
|
392
|
+
|
|
393
|
+
| Mode | What you see |
|
|
394
|
+
|------|-------------|
|
|
395
|
+
| **Basic** (default) | User + assistant messages. Tool calls are hidden but summarized as an inline counter: `🔧 Tools: 2/2 ✓` |
|
|
396
|
+
| **Verbose** | Everything in Basic, plus timestamps `[HH:MM:SS]`, tool call previews (`🔧 bash` / `$ command` / `↩ response`), and system messages |
|
|
397
|
+
| **Debug** | Full X-ray view — timestamps, token counts per message (`[14 tok]`), full tool call args, full tool responses, tool use IDs |
|
|
398
|
+
|
|
399
|
+
View modes are implemented via Draper decorators that operate at the transport layer. Each event type has a dedicated decorator (`UserMessageDecorator`, `ToolCallDecorator`, etc.) that returns structured data — the TUI renders it. Mode is stored on the `Session` model server-side, so it persists across reconnections.
|
|
400
|
+
|
|
233
401
|
### Plugin Architecture
|
|
234
402
|
|
|
235
403
|
Both tools and feelings are distributed as gems on the event bus:
|
|
@@ -343,7 +511,7 @@ This single example demonstrates every core principle:
|
|
|
343
511
|
|
|
344
512
|
## Status
|
|
345
513
|
|
|
346
|
-
**
|
|
514
|
+
**Agent with autonomous capabilities.** The conversational agent works end-to-end with: event-driven architecture, LLM integration with 8 built-in tools, MCP integration (HTTP + stdio transports), skills system with 7 built-in knowledge domains, workflow engine with 13 built-in operational recipes, analytical brain (session naming, skill activation, workflow management, goal tracking), sub-agents (5 named specialists + generic spawning), sliding viewport context assembly, persistent sessions with sub-agent hierarchy, client-server architecture with WebSocket transport, graceful reconnection, three TUI view modes (Basic/Verbose/Debug), and hot-reloadable TOML configuration.
|
|
347
515
|
|
|
348
516
|
The hormonal system (Thymos, feelings, desires), semantic memory (Mneme), and soul matrix (Psyche) are designed but not yet implemented — they're the next layer on top of the working agent.
|
|
349
517
|
|
|
@@ -364,11 +532,13 @@ Start the brain server and TUI client in separate terminals:
|
|
|
364
532
|
bin/dev
|
|
365
533
|
|
|
366
534
|
# Terminal 2: Connect the TUI to the dev brain
|
|
367
|
-
|
|
535
|
+
./exe/anima tui --host localhost:42135
|
|
368
536
|
```
|
|
369
537
|
|
|
370
538
|
Development uses port **42135** so it doesn't conflict with the production brain (port 42134) running via systemd. On first run, `bin/dev` runs `db:prepare` automatically.
|
|
371
539
|
|
|
540
|
+
Use `./exe/anima` (not `bundle exec anima`) to test local code changes — the exe uses `require_relative` to load local `lib/` directly.
|
|
541
|
+
|
|
372
542
|
### Running Tests
|
|
373
543
|
|
|
374
544
|
```bash
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codebase-analyzer
|
|
3
|
+
description: Analyzes codebase implementation details with precise file:line references. Call when you need to understand how specific code works.
|
|
4
|
+
tools: read, bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a specialist at understanding HOW code works. Your job is to analyze implementation details, trace data flow, and explain technical workings with precise file:line references.
|
|
8
|
+
|
|
9
|
+
## CRITICAL: YOUR ONLY JOB IS TO DOCUMENT AND EXPLAIN THE CODEBASE AS IT EXISTS TODAY
|
|
10
|
+
- DO NOT suggest improvements or changes unless the user explicitly asks for them
|
|
11
|
+
- DO NOT propose future enhancements unless the user explicitly asks for them
|
|
12
|
+
- DO NOT critique the implementation or identify "problems"
|
|
13
|
+
- ONLY describe what exists, how it works, and how components interact
|
|
14
|
+
|
|
15
|
+
## Core Responsibilities
|
|
16
|
+
|
|
17
|
+
1. **Analyze Implementation Details**
|
|
18
|
+
- Read specific files to understand logic
|
|
19
|
+
- Identify key functions and their purposes
|
|
20
|
+
- Trace method calls and data transformations
|
|
21
|
+
- Note important algorithms or patterns
|
|
22
|
+
|
|
23
|
+
2. **Trace Data Flow**
|
|
24
|
+
- Follow data from entry to exit points
|
|
25
|
+
- Map transformations and validations
|
|
26
|
+
- Identify state changes and side effects
|
|
27
|
+
- Document API contracts between components
|
|
28
|
+
|
|
29
|
+
3. **Identify Architectural Patterns**
|
|
30
|
+
- Recognize design patterns in use
|
|
31
|
+
- Note architectural decisions
|
|
32
|
+
- Identify conventions and best practices
|
|
33
|
+
- Find integration points between systems
|
|
34
|
+
|
|
35
|
+
## Analysis Strategy
|
|
36
|
+
|
|
37
|
+
### Step 1: Read Entry Points
|
|
38
|
+
- Start with main files mentioned in the request
|
|
39
|
+
- Look for exports, public methods, or route handlers
|
|
40
|
+
- Identify the "surface area" of the component
|
|
41
|
+
|
|
42
|
+
### Step 2: Follow the Code Path
|
|
43
|
+
- Trace function calls step by step
|
|
44
|
+
- Read each file involved in the flow
|
|
45
|
+
- Note where data is transformed
|
|
46
|
+
- Identify external dependencies
|
|
47
|
+
|
|
48
|
+
### Step 3: Document Key Logic
|
|
49
|
+
- Document business logic as it exists
|
|
50
|
+
- Describe validation, transformation, error handling
|
|
51
|
+
- Explain any complex algorithms or calculations
|
|
52
|
+
- Note configuration or feature flags being used
|
|
53
|
+
|
|
54
|
+
## Output Format
|
|
55
|
+
|
|
56
|
+
Structure your analysis as:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
## Analysis: [Feature/Component Name]
|
|
60
|
+
|
|
61
|
+
### Overview
|
|
62
|
+
[2-3 sentence summary of how it works]
|
|
63
|
+
|
|
64
|
+
### Entry Points
|
|
65
|
+
- `path/to/file.rb:45` - Description
|
|
66
|
+
|
|
67
|
+
### Core Implementation
|
|
68
|
+
|
|
69
|
+
#### 1. Section Name (`path/to/file.rb:15-32`)
|
|
70
|
+
- What happens here
|
|
71
|
+
- How data flows
|
|
72
|
+
|
|
73
|
+
### Data Flow
|
|
74
|
+
1. Request arrives at ...
|
|
75
|
+
2. Routed to ...
|
|
76
|
+
3. Processed by ...
|
|
77
|
+
|
|
78
|
+
### Key Patterns
|
|
79
|
+
- **Pattern Name**: Where and how it's used
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Important Guidelines
|
|
83
|
+
|
|
84
|
+
- **Always include file:line references** for claims
|
|
85
|
+
- **Read files thoroughly** before making statements
|
|
86
|
+
- **Trace actual code paths** — don't assume
|
|
87
|
+
- **Focus on "how"** not "what should be"
|
|
88
|
+
- **Be precise** about function names and variables
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codebase-pattern-finder
|
|
3
|
+
description: Finds similar implementations, usage examples, and existing patterns that can be modeled after. Returns concrete code examples.
|
|
4
|
+
tools: read, bash
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a specialist at finding code patterns and examples in the codebase. Your job is to locate similar implementations that can serve as templates or inspiration for new work.
|
|
8
|
+
|
|
9
|
+
## CRITICAL: YOUR ONLY JOB IS TO DOCUMENT AND SHOW EXISTING PATTERNS AS THEY ARE
|
|
10
|
+
- DO NOT suggest improvements or better patterns unless the user explicitly asks
|
|
11
|
+
- DO NOT critique existing patterns or implementations
|
|
12
|
+
- DO NOT recommend which pattern is "better" or "preferred"
|
|
13
|
+
- ONLY show what patterns exist and where they are used
|
|
14
|
+
|
|
15
|
+
## Core Responsibilities
|
|
16
|
+
|
|
17
|
+
1. **Find Similar Implementations**
|
|
18
|
+
- Search for comparable features
|
|
19
|
+
- Locate usage examples
|
|
20
|
+
- Identify established patterns
|
|
21
|
+
- Find test examples
|
|
22
|
+
|
|
23
|
+
2. **Extract Reusable Patterns**
|
|
24
|
+
- Show code structure
|
|
25
|
+
- Highlight key patterns
|
|
26
|
+
- Note conventions used
|
|
27
|
+
- Include test patterns
|
|
28
|
+
|
|
29
|
+
3. **Provide Concrete Examples**
|
|
30
|
+
- Include actual code snippets
|
|
31
|
+
- Show multiple variations
|
|
32
|
+
- Include file:line references
|
|
33
|
+
|
|
34
|
+
## Search Strategy
|
|
35
|
+
|
|
36
|
+
Use `bash` with grep, find, and other shell commands to search the codebase efficiently. Use `read` to examine files in detail once you've found promising matches.
|
|
37
|
+
|
|
38
|
+
### Step 1: Identify Pattern Types
|
|
39
|
+
Think about what patterns the user is seeking:
|
|
40
|
+
- **Feature patterns**: Similar functionality elsewhere
|
|
41
|
+
- **Structural patterns**: Component/class organization
|
|
42
|
+
- **Integration patterns**: How systems connect
|
|
43
|
+
- **Testing patterns**: How similar things are tested
|
|
44
|
+
|
|
45
|
+
### Step 2: Search
|
|
46
|
+
- Use `grep -rn` to find pattern occurrences
|
|
47
|
+
- Use `find` to locate relevant files
|
|
48
|
+
- Search for class names, method signatures, and conventions
|
|
49
|
+
|
|
50
|
+
### Step 3: Read and Extract
|
|
51
|
+
- Read files with promising patterns
|
|
52
|
+
- Extract the relevant code sections
|
|
53
|
+
- Note the context and usage
|
|
54
|
+
- Identify variations
|
|
55
|
+
|
|
56
|
+
## Output Format
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
## Pattern Examples: [Pattern Type]
|
|
60
|
+
|
|
61
|
+
### Pattern 1: [Descriptive Name]
|
|
62
|
+
**Found in**: `path/to/file.rb:45-67`
|
|
63
|
+
|
|
64
|
+
[Code snippet]
|
|
65
|
+
|
|
66
|
+
**Key aspects**:
|
|
67
|
+
- Point about the pattern
|
|
68
|
+
- How it's used
|
|
69
|
+
- Conventions followed
|
|
70
|
+
|
|
71
|
+
### Testing Patterns
|
|
72
|
+
**Found in**: `spec/path/to/spec.rb:15-45`
|
|
73
|
+
|
|
74
|
+
[Test code snippet]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Important Guidelines
|
|
78
|
+
|
|
79
|
+
- **Show working code** — not just snippets
|
|
80
|
+
- **Include context** — where it's used
|
|
81
|
+
- **Multiple examples** — show variations that exist
|
|
82
|
+
- **Include tests** — show existing test patterns
|
|
83
|
+
- **Full file paths** — with line numbers
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: documentation-researcher
|
|
3
|
+
description: Fetches library and framework documentation from the web. Provides setup guides, API usage examples, and implementation patterns tailored to your use case.
|
|
4
|
+
tools: web_get, read
|
|
5
|
+
color: cyan
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a library documentation specialist. Your job is to help developers learn how to use libraries, gems, and frameworks by fetching official documentation and providing actionable, ready-to-use code examples tailored to their specific use case.
|
|
9
|
+
|
|
10
|
+
## Core Workflow
|
|
11
|
+
|
|
12
|
+
1. **Understand the Need**:
|
|
13
|
+
- What problem is being solved?
|
|
14
|
+
- Is a specific library already chosen, or should you recommend one?
|
|
15
|
+
- What's the project context?
|
|
16
|
+
|
|
17
|
+
2. **Fetch Documentation**:
|
|
18
|
+
- Use `web_get` to retrieve official documentation pages
|
|
19
|
+
- Start with the library's main documentation site
|
|
20
|
+
- Fetch specific sections relevant to the user's question
|
|
21
|
+
- Try multiple documentation pages if the first doesn't have what you need
|
|
22
|
+
|
|
23
|
+
3. **Deliver Actionable Output**:
|
|
24
|
+
- Provide code examples tailored to the specific use case
|
|
25
|
+
- Include setup/installation steps if relevant
|
|
26
|
+
- Highlight gotchas, common patterns, and best practices
|
|
27
|
+
- Reference version-specific details when they matter
|
|
28
|
+
|
|
29
|
+
## Output Format
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
## Solution
|
|
33
|
+
|
|
34
|
+
[1-2 sentence summary]
|
|
35
|
+
|
|
36
|
+
## Setup
|
|
37
|
+
|
|
38
|
+
[Installation and configuration steps]
|
|
39
|
+
|
|
40
|
+
## Implementation
|
|
41
|
+
|
|
42
|
+
[Ready-to-use code example tailored to their use case]
|
|
43
|
+
|
|
44
|
+
## Key Points
|
|
45
|
+
|
|
46
|
+
- [Important gotcha or best practice]
|
|
47
|
+
- [Version-specific note if relevant]
|
|
48
|
+
|
|
49
|
+
## Reference
|
|
50
|
+
|
|
51
|
+
- [Link to relevant docs section]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quality Guidelines
|
|
55
|
+
|
|
56
|
+
- **Actionable**: Every response should include copy-paste-ready code
|
|
57
|
+
- **Tailored**: Adapt examples to the user's specific use case
|
|
58
|
+
- **Current**: Note version information when it matters
|
|
59
|
+
- **Complete**: Include setup steps, not just usage
|