anima-core 0.3.0 → 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.
Files changed (269) hide show
  1. checksums.yaml +4 -4
  2. data/.reek.yml +27 -1
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +219 -25
  5. data/agents/codebase-analyzer.md +88 -0
  6. data/agents/codebase-pattern-finder.md +83 -0
  7. data/agents/documentation-researcher.md +59 -0
  8. data/agents/thoughts-analyzer.md +102 -0
  9. data/agents/web-search-researcher.md +71 -0
  10. data/anima-core.gemspec +3 -0
  11. data/app/channels/session_channel.rb +76 -28
  12. data/app/jobs/agent_request_job.rb +24 -0
  13. data/app/jobs/analytical_brain_job.rb +33 -0
  14. data/app/jobs/count_event_tokens_job.rb +1 -1
  15. data/app/models/concerns/event/broadcasting.rb +20 -2
  16. data/app/models/event.rb +1 -1
  17. data/app/models/goal.rb +91 -0
  18. data/app/models/session.rb +347 -22
  19. data/config/application.rb +2 -0
  20. data/db/migrate/20260314075248_add_subagent_support_to_sessions.rb +6 -0
  21. data/db/migrate/20260314112417_add_granted_tools_to_sessions.rb +5 -0
  22. data/db/migrate/20260314140000_add_name_to_sessions.rb +7 -0
  23. data/db/migrate/20260314150000_add_viewport_event_ids_to_sessions.rb +7 -0
  24. data/db/migrate/20260315100000_add_active_skills_to_sessions.rb +7 -0
  25. data/db/migrate/20260315140843_create_goals.rb +16 -0
  26. data/db/migrate/20260315144837_add_completed_at_to_goals.rb +5 -0
  27. data/db/migrate/20260315191105_add_active_workflow_to_sessions.rb +5 -0
  28. data/lib/agent_loop.rb +65 -9
  29. data/lib/agents/definition.rb +116 -0
  30. data/lib/agents/registry.rb +106 -0
  31. data/lib/analytical_brain/runner.rb +276 -0
  32. data/lib/analytical_brain/tools/activate_skill.rb +52 -0
  33. data/lib/analytical_brain/tools/deactivate_skill.rb +43 -0
  34. data/lib/analytical_brain/tools/deactivate_workflow.rb +34 -0
  35. data/lib/analytical_brain/tools/everything_is_ready.rb +28 -0
  36. data/lib/analytical_brain/tools/finish_goal.rb +62 -0
  37. data/lib/analytical_brain/tools/read_workflow.rb +58 -0
  38. data/lib/analytical_brain/tools/rename_session.rb +63 -0
  39. data/lib/analytical_brain/tools/set_goal.rb +60 -0
  40. data/lib/analytical_brain/tools/update_goal.rb +60 -0
  41. data/lib/analytical_brain.rb +23 -0
  42. data/lib/anima/cli/mcp/secrets.rb +76 -0
  43. data/lib/anima/cli/mcp.rb +197 -0
  44. data/lib/anima/cli.rb +4 -0
  45. data/lib/anima/installer.rb +168 -0
  46. data/lib/anima/settings.rb +226 -0
  47. data/lib/anima/version.rb +1 -1
  48. data/lib/anima.rb +9 -0
  49. data/lib/credential_store.rb +103 -0
  50. data/lib/environment_probe.rb +232 -0
  51. data/lib/llm/client.rb +29 -10
  52. data/lib/mcp/client_manager.rb +86 -0
  53. data/lib/mcp/config.rb +213 -0
  54. data/lib/mcp/health_check.rb +77 -0
  55. data/lib/mcp/secrets.rb +73 -0
  56. data/lib/mcp/stdio_transport.rb +206 -0
  57. data/lib/providers/anthropic.rb +8 -7
  58. data/lib/shell_session.rb +11 -10
  59. data/lib/skills/definition.rb +97 -0
  60. data/lib/skills/registry.rb +105 -0
  61. data/lib/tools/edit.rb +3 -4
  62. data/lib/tools/mcp_tool.rb +114 -0
  63. data/lib/tools/read.rb +15 -16
  64. data/lib/tools/registry.rb +14 -12
  65. data/lib/tools/request_feature.rb +121 -0
  66. data/lib/tools/return_result.rb +81 -0
  67. data/lib/tools/spawn_specialist.rb +109 -0
  68. data/lib/tools/spawn_subagent.rb +111 -0
  69. data/lib/tools/subagent_prompts.rb +12 -0
  70. data/lib/tools/web_get.rb +8 -9
  71. data/lib/tui/app.rb +332 -43
  72. data/lib/tui/message_store.rb +20 -0
  73. data/lib/tui/screens/chat.rb +207 -20
  74. data/lib/workflows/definition.rb +97 -0
  75. data/lib/workflows/registry.rb +89 -0
  76. data/skills/activerecord/SKILL.md +255 -0
  77. data/skills/activerecord/examples/associations/association_extensions.rb +298 -0
  78. data/skills/activerecord/examples/associations/basic_associations.rb +118 -0
  79. data/skills/activerecord/examples/associations/counter_caches.rb +215 -0
  80. data/skills/activerecord/examples/associations/polymorphic_associations.rb +217 -0
  81. data/skills/activerecord/examples/associations/self_referential.rb +302 -0
  82. data/skills/activerecord/examples/associations/through_associations.rb +203 -0
  83. data/skills/activerecord/examples/basics/crud_operations.rb +209 -0
  84. data/skills/activerecord/examples/basics/dirty_tracking.rb +218 -0
  85. data/skills/activerecord/examples/basics/inheritance.rb +377 -0
  86. data/skills/activerecord/examples/basics/type_casting.rb +317 -0
  87. data/skills/activerecord/examples/callbacks/alternatives_to_callbacks.rb +447 -0
  88. data/skills/activerecord/examples/callbacks/conditional_callbacks.rb +353 -0
  89. data/skills/activerecord/examples/callbacks/lifecycle_callbacks.rb +280 -0
  90. data/skills/activerecord/examples/callbacks/transaction_callbacks.rb +340 -0
  91. data/skills/activerecord/examples/migrations/indexes_and_constraints.rb +337 -0
  92. data/skills/activerecord/examples/migrations/reversible_patterns.rb +403 -0
  93. data/skills/activerecord/examples/migrations/safe_patterns.rb +420 -0
  94. data/skills/activerecord/examples/migrations/schema_changes.rb +277 -0
  95. data/skills/activerecord/examples/querying/batch_processing.rb +226 -0
  96. data/skills/activerecord/examples/querying/eager_loading.rb +259 -0
  97. data/skills/activerecord/examples/querying/finder_methods.rb +170 -0
  98. data/skills/activerecord/examples/querying/optimization.rb +275 -0
  99. data/skills/activerecord/examples/querying/scopes.rb +260 -0
  100. data/skills/activerecord/examples/validations/built_in_validators.rb +277 -0
  101. data/skills/activerecord/examples/validations/conditional_validations.rb +288 -0
  102. data/skills/activerecord/examples/validations/custom_validators.rb +381 -0
  103. data/skills/activerecord/examples/validations/database_constraints.rb +432 -0
  104. data/skills/activerecord/examples/validations/validation_contexts.rb +367 -0
  105. data/skills/activerecord/references/associations.md +709 -0
  106. data/skills/activerecord/references/basics.md +622 -0
  107. data/skills/activerecord/references/callbacks.md +738 -0
  108. data/skills/activerecord/references/migrations.md +657 -0
  109. data/skills/activerecord/references/querying.md +655 -0
  110. data/skills/activerecord/references/validations.md +596 -0
  111. data/skills/dragonruby/SKILL.md +250 -0
  112. data/skills/dragonruby/examples/audio/audio_events.rb +55 -0
  113. data/skills/dragonruby/examples/audio/background_music.rb +29 -0
  114. data/skills/dragonruby/examples/audio/crossfade.rb +51 -0
  115. data/skills/dragonruby/examples/audio/music_controls.rb +51 -0
  116. data/skills/dragonruby/examples/audio/sound_effects.rb +30 -0
  117. data/skills/dragonruby/examples/core/coordinate_system.rb +27 -0
  118. data/skills/dragonruby/examples/core/hello_world.rb +24 -0
  119. data/skills/dragonruby/examples/core/labels.rb +22 -0
  120. data/skills/dragonruby/examples/core/sprites.rb +35 -0
  121. data/skills/dragonruby/examples/core/state_management.rb +29 -0
  122. data/skills/dragonruby/examples/distribution/background_pause.rb +42 -0
  123. data/skills/dragonruby/examples/distribution/build_workflow.sh +26 -0
  124. data/skills/dragonruby/examples/distribution/cvars_production.txt +16 -0
  125. data/skills/dragonruby/examples/distribution/game_metadata_hd.txt +23 -0
  126. data/skills/dragonruby/examples/distribution/game_metadata_minimal.txt +9 -0
  127. data/skills/dragonruby/examples/distribution/game_metadata_mobile.txt +31 -0
  128. data/skills/dragonruby/examples/distribution/platform_detection.rb +36 -0
  129. data/skills/dragonruby/examples/distribution/steam_metadata.txt +19 -0
  130. data/skills/dragonruby/examples/entities/collision_detection.rb +43 -0
  131. data/skills/dragonruby/examples/entities/entity_lifecycle.rb +68 -0
  132. data/skills/dragonruby/examples/entities/entity_storage.rb +38 -0
  133. data/skills/dragonruby/examples/entities/factory_methods.rb +45 -0
  134. data/skills/dragonruby/examples/entities/random_spawning.rb +50 -0
  135. data/skills/dragonruby/examples/game-logic/reset_patterns.rb +98 -0
  136. data/skills/dragonruby/examples/game-logic/save_load.rb +101 -0
  137. data/skills/dragonruby/examples/game-logic/scoring.rb +104 -0
  138. data/skills/dragonruby/examples/game-logic/state_transitions.rb +103 -0
  139. data/skills/dragonruby/examples/game-logic/timers.rb +87 -0
  140. data/skills/dragonruby/examples/input/action_triggers.rb +36 -0
  141. data/skills/dragonruby/examples/input/analog_movement.rb +28 -0
  142. data/skills/dragonruby/examples/input/controller_input.rb +28 -0
  143. data/skills/dragonruby/examples/input/directional_input.rb +24 -0
  144. data/skills/dragonruby/examples/input/keyboard_input.rb +28 -0
  145. data/skills/dragonruby/examples/input/mouse_click.rb +26 -0
  146. data/skills/dragonruby/examples/input/movement_with_bounds.rb +22 -0
  147. data/skills/dragonruby/examples/input/normalized_movement.rb +32 -0
  148. data/skills/dragonruby/examples/rendering/frame_animation.rb +32 -0
  149. data/skills/dragonruby/examples/rendering/labels.rb +32 -0
  150. data/skills/dragonruby/examples/rendering/layering.rb +51 -0
  151. data/skills/dragonruby/examples/rendering/solids.rb +61 -0
  152. data/skills/dragonruby/examples/rendering/sprites.rb +33 -0
  153. data/skills/dragonruby/examples/rendering/spritesheet_animation.rb +39 -0
  154. data/skills/dragonruby/examples/scenes/case_dispatch.rb +60 -0
  155. data/skills/dragonruby/examples/scenes/class_based.rb +150 -0
  156. data/skills/dragonruby/examples/scenes/pause_overlay.rb +100 -0
  157. data/skills/dragonruby/examples/scenes/safe_transitions.rb +68 -0
  158. data/skills/dragonruby/examples/scenes/scene_transitions.rb +98 -0
  159. data/skills/dragonruby/examples/scenes/send_dispatch.rb +88 -0
  160. data/skills/dragonruby/references/audio.md +396 -0
  161. data/skills/dragonruby/references/core.md +385 -0
  162. data/skills/dragonruby/references/distribution.md +434 -0
  163. data/skills/dragonruby/references/entities.md +516 -0
  164. data/skills/dragonruby/references/game-logic/persistence.md +386 -0
  165. data/skills/dragonruby/references/game-logic/state.md +389 -0
  166. data/skills/dragonruby/references/input.md +414 -0
  167. data/skills/dragonruby/references/rendering/animation.md +467 -0
  168. data/skills/dragonruby/references/rendering/primitives.md +403 -0
  169. data/skills/dragonruby/references/scenes.md +443 -0
  170. data/skills/draper-decorators/SKILL.md +344 -0
  171. data/skills/draper-decorators/examples/application_decorator.rb +61 -0
  172. data/skills/draper-decorators/examples/decorator_spec.rb +253 -0
  173. data/skills/draper-decorators/examples/model_decorator.rb +152 -0
  174. data/skills/draper-decorators/references/anti-patterns.md +640 -0
  175. data/skills/draper-decorators/references/patterns.md +507 -0
  176. data/skills/draper-decorators/references/testing.md +559 -0
  177. data/skills/gh-issue.md +182 -0
  178. data/skills/mcp-server/SKILL.md +177 -0
  179. data/skills/mcp-server/examples/dynamic_tools.rb +36 -0
  180. data/skills/mcp-server/examples/file_manager_tool.rb +85 -0
  181. data/skills/mcp-server/examples/http_client.rb +48 -0
  182. data/skills/mcp-server/examples/http_server.rb +97 -0
  183. data/skills/mcp-server/examples/rails_integration.rb +88 -0
  184. data/skills/mcp-server/examples/stdio_server.rb +108 -0
  185. data/skills/mcp-server/examples/streaming_client.rb +95 -0
  186. data/skills/mcp-server/references/gotchas.md +183 -0
  187. data/skills/mcp-server/references/prompts.md +98 -0
  188. data/skills/mcp-server/references/resources.md +53 -0
  189. data/skills/mcp-server/references/server.md +140 -0
  190. data/skills/mcp-server/references/tools.md +146 -0
  191. data/skills/mcp-server/references/transport.md +104 -0
  192. data/skills/ratatui-ruby/SKILL.md +315 -0
  193. data/skills/ratatui-ruby/references/core-concepts.md +340 -0
  194. data/skills/ratatui-ruby/references/events.md +387 -0
  195. data/skills/ratatui-ruby/references/frameworks.md +522 -0
  196. data/skills/ratatui-ruby/references/layout.md +423 -0
  197. data/skills/ratatui-ruby/references/styling.md +268 -0
  198. data/skills/ratatui-ruby/references/testing.md +433 -0
  199. data/skills/ratatui-ruby/references/widgets.md +532 -0
  200. data/skills/rspec/SKILL.md +340 -0
  201. data/skills/rspec/examples/core/basic_structure.rb +69 -0
  202. data/skills/rspec/examples/core/configuration.rb +126 -0
  203. data/skills/rspec/examples/core/hooks.rb +126 -0
  204. data/skills/rspec/examples/core/memoized_helpers.rb +139 -0
  205. data/skills/rspec/examples/core/metadata_filtering.rb +144 -0
  206. data/skills/rspec/examples/core/shared_examples.rb +145 -0
  207. data/skills/rspec/examples/factory_bot/associations.rb +314 -0
  208. data/skills/rspec/examples/factory_bot/build_strategies.rb +272 -0
  209. data/skills/rspec/examples/factory_bot/callbacks.rb +320 -0
  210. data/skills/rspec/examples/factory_bot/custom_construction.rb +328 -0
  211. data/skills/rspec/examples/factory_bot/factory_definition.rb +191 -0
  212. data/skills/rspec/examples/factory_bot/inheritance.rb +314 -0
  213. data/skills/rspec/examples/factory_bot/traits.rb +293 -0
  214. data/skills/rspec/examples/factory_bot/transients.rb +229 -0
  215. data/skills/rspec/examples/matchers/change.rb +115 -0
  216. data/skills/rspec/examples/matchers/collections.rb +154 -0
  217. data/skills/rspec/examples/matchers/comparisons.rb +79 -0
  218. data/skills/rspec/examples/matchers/composing.rb +155 -0
  219. data/skills/rspec/examples/matchers/custom_matchers.rb +197 -0
  220. data/skills/rspec/examples/matchers/equality.rb +58 -0
  221. data/skills/rspec/examples/matchers/errors.rb +136 -0
  222. data/skills/rspec/examples/matchers/output.rb +103 -0
  223. data/skills/rspec/examples/matchers/predicates.rb +87 -0
  224. data/skills/rspec/examples/matchers/truthiness.rb +101 -0
  225. data/skills/rspec/examples/matchers/types.rb +82 -0
  226. data/skills/rspec/examples/matchers/yield.rb +147 -0
  227. data/skills/rspec/examples/mocks/any_instance.rb +172 -0
  228. data/skills/rspec/examples/mocks/argument_matchers.rb +206 -0
  229. data/skills/rspec/examples/mocks/constants.rb +177 -0
  230. data/skills/rspec/examples/mocks/doubles.rb +139 -0
  231. data/skills/rspec/examples/mocks/expectations.rb +137 -0
  232. data/skills/rspec/examples/mocks/message_chains.rb +173 -0
  233. data/skills/rspec/examples/mocks/ordering.rb +144 -0
  234. data/skills/rspec/examples/mocks/receive_counts.rb +181 -0
  235. data/skills/rspec/examples/mocks/responses.rb +223 -0
  236. data/skills/rspec/examples/mocks/spies.rb +149 -0
  237. data/skills/rspec/examples/mocks/stubbing.rb +133 -0
  238. data/skills/rspec/examples/rails/channels.rb +250 -0
  239. data/skills/rspec/examples/rails/controller_specs.rb +302 -0
  240. data/skills/rspec/examples/rails/helper_specs.rb +245 -0
  241. data/skills/rspec/examples/rails/job_specs.rb +256 -0
  242. data/skills/rspec/examples/rails/mailer_specs.rb +228 -0
  243. data/skills/rspec/examples/rails/matchers.rb +374 -0
  244. data/skills/rspec/examples/rails/model_specs.rb +193 -0
  245. data/skills/rspec/examples/rails/request_specs.rb +275 -0
  246. data/skills/rspec/examples/rails/routing_specs.rb +276 -0
  247. data/skills/rspec/examples/rails/system_specs.rb +294 -0
  248. data/skills/rspec/examples/rails/transactions.rb +254 -0
  249. data/skills/rspec/examples/rails/view_specs.rb +252 -0
  250. data/skills/rspec/references/core.md +816 -0
  251. data/skills/rspec/references/factory_bot.md +641 -0
  252. data/skills/rspec/references/matchers.md +516 -0
  253. data/skills/rspec/references/mocks.md +381 -0
  254. data/skills/rspec/references/rails.md +528 -0
  255. data/templates/soul.md +40 -0
  256. data/workflows/commit.md +45 -0
  257. data/workflows/create_handoff.md +98 -0
  258. data/workflows/create_note.md +82 -0
  259. data/workflows/create_plan.md +457 -0
  260. data/workflows/decompose_ticket.md +109 -0
  261. data/workflows/feature.md +91 -0
  262. data/workflows/implement_plan.md +87 -0
  263. data/workflows/iterate_plan.md +247 -0
  264. data/workflows/research_codebase.md +210 -0
  265. data/workflows/resume_handoff.md +217 -0
  266. data/workflows/review_pr.md +320 -0
  267. data/workflows/thoughts_init.md +71 -0
  268. data/workflows/validate_plan.md +166 -0
  269. metadata +284 -1
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: create_note
3
+ description: "Capture findings or context as a persistent note in the thoughts system."
4
+ ---
5
+
6
+ # Create Note
7
+
8
+ You are tasked with capturing content as a persistent note in the thoughts system. This could be findings from a research specialist, insights from the current session, or any content worth preserving for future reference.
9
+
10
+ ## Process
11
+
12
+ ### 1. Gather Metadata
13
+
14
+ Run `spec-metadata` (in the PATH) to get date, time, git commit, branch, and repository name.
15
+
16
+ ### 2. Filepath & Naming
17
+
18
+ Create your file under `./thoughts/shared/notes/YYYY-MM-DD/description.md`, where:
19
+ - YYYY-MM-DD is today's date
20
+ - description is a brief kebab-case description of the content
21
+
22
+ Examples:
23
+ - `2026-02-23/rails-8-turbo-stream-patterns.md`
24
+ - `2026-02-23/sidekiq-retry-best-practices.md`
25
+ - `2026-02-23/authentication-library-comparison.md`
26
+
27
+ ### 3. Note Writing
28
+
29
+ Using the above conventions, write your document with the following YAML frontmatter pattern. Use the metadata gathered in step 1:
30
+
31
+ ```markdown
32
+ ---
33
+ date: [Current date and time with timezone in ISO format]
34
+ author: [Author name from spec-metadata]
35
+ git_commit: [Current commit hash]
36
+ branch: [Current branch name]
37
+ repository: [Repository name]
38
+ topic: "[Brief topic description]"
39
+ tags: [note, relevant-keywords]
40
+ status: complete
41
+ last_updated: [Current date in YYYY-MM-DD format]
42
+ last_updated_by: [Author name]
43
+ ---
44
+
45
+ # [Topic]
46
+
47
+ ## Context
48
+
49
+ [What prompted this note - the question, task, or goal]
50
+
51
+ ## Content
52
+
53
+ [The actual content - preserved exactly as provided without summarization or transformation]
54
+
55
+ ## Sources
56
+
57
+ [Links, file paths, or references - if applicable, omit section if none]
58
+
59
+ ## Related
60
+
61
+ [Links to related notes, research, or plans in thoughts/ - if applicable, omit section if none]
62
+ ```
63
+
64
+ ### 4. Sync and Present
65
+
66
+ Run `thoughts-sync` to save the document.
67
+
68
+ Once complete, respond with:
69
+
70
+ ```
71
+ Note captured at: ./thoughts/shared/notes/YYYY-MM-DD/description.md
72
+
73
+ You can reference this in future sessions or as input to other workflows.
74
+ ```
75
+
76
+ ## Additional Notes & Instructions
77
+
78
+ - **Preserve content exactly**: The value of this note is capturing content losslessly. Do not summarize, synthesize, or transform the content unless explicitly asked.
79
+ - **Include all links**: If content came from web research, documentation lookups, or file analysis, preserve all URLs and file:line references.
80
+ - **Topic from context**: Derive the topic from the content being captured. Only ask the user if genuinely ambiguous.
81
+ - **Sections are flexible**: The Content section is required. Sources and Related sections should be included when applicable, omitted when not.
82
+ - **Follow-up notes**: If adding to an existing topic, consider updating the existing note rather than creating a duplicate. Update `last_updated` and `last_updated_by` fields.
@@ -0,0 +1,457 @@
1
+ ---
2
+ name: create_plan
3
+ description: "Create detailed implementation plans through interactive research and iteration."
4
+ ---
5
+
6
+ # Implementation Plan
7
+
8
+ You are tasked with creating detailed implementation plans through an interactive, iterative process. You should be skeptical, thorough, and work collaboratively with the user to produce high-quality technical specifications.
9
+
10
+ ## Initial Response
11
+
12
+ When this command is invoked:
13
+
14
+ 1. **Check if parameters were provided**:
15
+ - If a file path or ticket reference was provided as a parameter, skip the default message
16
+ - Immediately read any provided files FULLY
17
+ - Begin the research process
18
+
19
+ 2. **If no parameters provided**, respond with:
20
+ ```
21
+ I'll help you create a detailed implementation plan. Let me start by understanding what we're building.
22
+
23
+ Please provide:
24
+ 1. The task/ticket description (or reference to a ticket file)
25
+ 2. Any relevant context, constraints, or specific requirements
26
+ 3. Links to related research or previous implementations
27
+
28
+ I'll analyze this information and work with you to create a comprehensive plan.
29
+
30
+ Provide a GitHub issue reference or a description of what needs to be planned.
31
+ ```
32
+
33
+ Then wait for the user's input.
34
+
35
+ ## Process Steps
36
+
37
+ ### Step 1: Context Gathering & Initial Analysis
38
+
39
+ 1. **Read all mentioned files (if any) immediately and FULLY**:
40
+ - GitHub issue details (via `gh issue view`)
41
+ - Research documents
42
+ - Related implementation plans
43
+ - Any JSON/data files mentioned
44
+ - **IMPORTANT**: Use the Read tool WITHOUT limit/offset parameters to read entire files
45
+ - **CRITICAL**: If files mentioned, DO NOT spawn sub-tasks before reading these files yourself in the main context
46
+ - **NEVER** read files partially - if a file is mentioned, read it completely
47
+
48
+ 2. **Gather Historical Context**:
49
+ Spawn the `thoughts-analyzer` specialist with ticket reference, title, description, and acceptance criteria.
50
+
51
+ DO NOT proceed to step 3 until this specialist returns. Its output is required input for step 3.
52
+
53
+ 3. **Spawn codebase research tasks**:
54
+ After step 2 completes, spawn research specialists in parallel, passing ticket info and historical context output from step 2:
55
+
56
+ - Use the **codebase-analyzer** specialist to find and understand how the current implementation works
57
+ - If a GitHub issue is mentioned, read full details via `gh issue view`
58
+
59
+ These agents will:
60
+ - Find relevant source files, configs, and tests
61
+ - Identify the specific directories to focus on (e.g., if WUI is mentioned, they'll focus on humanlayer-wui/)
62
+ - Trace data flow and key functions
63
+ - Return detailed explanations with file:line references
64
+
65
+ 4. **Read all files identified by research tasks**:
66
+ - After research tasks complete, read ALL files they identified as relevant
67
+ - Read them FULLY into the main context
68
+ - This ensures you have complete understanding before proceeding
69
+
70
+ 5. **Analyze and verify understanding**:
71
+ - Cross-reference the ticket requirements with actual code
72
+ - Identify any discrepancies or misunderstandings
73
+ - Note assumptions that need verification
74
+ - Determine true scope based on codebase reality
75
+
76
+ 6. **Present informed understanding and focused questions**:
77
+ ```
78
+ Based on the ticket and my research of the codebase, I understand we need to [accurate summary].
79
+
80
+ I've found that:
81
+ - [Current implementation detail with file:line reference]
82
+ - [Relevant pattern or constraint discovered]
83
+ - [Potential complexity or edge case identified]
84
+
85
+ Questions that my research couldn't answer:
86
+ - [Specific technical question that requires human judgment]
87
+ - [Business logic clarification]
88
+ - [Design preference that affects implementation]
89
+ ```
90
+
91
+ Only ask questions that you genuinely cannot answer through code investigation.
92
+
93
+ ### Step 2: Research & Discovery
94
+
95
+ After getting initial clarifications:
96
+
97
+ 1. **If the user corrects any misunderstanding**:
98
+ - DO NOT just accept the correction
99
+ - Spawn new research tasks to verify the correct information
100
+ - Read the specific files/directories they mention
101
+ - Only proceed once you've verified the facts yourself
102
+
103
+ 2. **Create a research todo list** to track exploration tasks
104
+
105
+ 3. **Spawn parallel sub-tasks for comprehensive research**:
106
+ - Create multiple subagents to research different aspects concurrently
107
+ - Use the right agent for each type of research:
108
+
109
+ **For codebase research:**
110
+ - **codebase-analyzer** — find and understand implementation details (e.g., "analyze how [system] works")
111
+ - **codebase-pattern-finder** — find similar features we can model after
112
+
113
+ **For related issues:**
114
+ - Search GitHub issues via `gh issue list --search "keyword"`
115
+
116
+ Each agent knows how to:
117
+ - Find the right files and code patterns
118
+ - Identify conventions and patterns to follow
119
+ - Look for integration points and dependencies
120
+ - Return specific file:line references
121
+ - Find tests and examples
122
+
123
+ 4. **Wait for ALL sub-tasks to complete** before proceeding
124
+
125
+ 5. **Present findings and design options**:
126
+ ```
127
+ Based on my research, here's what I found:
128
+
129
+ **Current State:**
130
+ - [Key discovery about existing code]
131
+ - [Pattern or convention to follow]
132
+
133
+ **Design Options:**
134
+ 1. [Option A] - [pros/cons]
135
+ 2. [Option B] - [pros/cons]
136
+
137
+ **Open Questions:**
138
+ - [Technical uncertainty]
139
+ - [Design decision needed]
140
+
141
+ Which approach aligns best with your vision?
142
+ ```
143
+
144
+ ### Step 3: Plan Structure Development
145
+
146
+ Once aligned on approach:
147
+
148
+ **Phase = Commit**
149
+
150
+ Each phase represents one atomic commit - the smallest meaningful change that leaves the codebase working.
151
+
152
+ **Atomicity test**: If your phase description needs "and", split it. If specs are in another Phase, merge into one.
153
+
154
+ **For testable code**, follow RGRC: Red → Green → Refactor → Commit. Your phases should mirror your test cases.
155
+
156
+ 1. **Create initial plan outline**:
157
+ ```
158
+ Here's my proposed plan structure:
159
+
160
+ ## Overview
161
+ [1-2 sentence summary]
162
+
163
+ ## Implementation Phases:
164
+ 1. [Phase name] - [what it accomplishes]
165
+ 2. [Phase name] - [what it accomplishes]
166
+ 3. [Phase name] - [what it accomplishes]
167
+
168
+ Does this phasing make sense? Should I adjust the order or granularity?
169
+ ```
170
+
171
+ 2. **Get feedback on structure** before writing details
172
+
173
+ ### Step 4: Detailed Plan Writing
174
+
175
+ After structure approval:
176
+
177
+ 1. **Write the plan** to `./thoughts/shared/plans/YYYY-MM-DD/<issue-number>-description.md`
178
+ - Format: `YYYY-MM-DD/<issue-number>-description.md` where:
179
+ - YYYY-MM-DD is today's date
180
+ - issue-number is the GitHub issue number (omit if no issue)
181
+ - description is a brief kebab-case description
182
+ - Examples:
183
+ - With issue: `2026-03-15/170-import-workflows.md`
184
+ - Without issue: `2026-03-15/improve-error-handling.md`
185
+ 2. **Use this template structure**:
186
+
187
+ ````markdown
188
+ # [Feature/Task Name] Implementation Plan
189
+
190
+ ## Overview
191
+
192
+ [Brief description of what we're implementing and why]
193
+
194
+ ## Current State Analysis
195
+
196
+ [What exists now, what's missing, key constraints discovered]
197
+
198
+ ## Desired End State
199
+
200
+ [A Specification of the desired end state after this plan is complete, and how to verify it]
201
+
202
+ ### Key Discoveries:
203
+ - [Important finding with file:line reference]
204
+ - [Pattern to follow]
205
+ - [Constraint to work within]
206
+
207
+ ## What We're NOT Doing
208
+
209
+ [Explicitly list out-of-scope items to prevent scope creep]
210
+
211
+ ## Implementation Approach
212
+
213
+ [High-level strategy and reasoning]
214
+
215
+ ## Phase 1: [Descriptive Name]
216
+
217
+ ### Commit
218
+ `<ticket||type>: <imperative summary>`
219
+
220
+ ### Overview
221
+ [What this phase accomplishes]
222
+
223
+ ### Changes Required:
224
+
225
+ #### 1. [Component/File Group]
226
+ **File**: `path/to/file.ext`
227
+ **Changes**: [Summary of changes]
228
+
229
+ ```[language]
230
+ // Specific code to add/modify
231
+ ```
232
+
233
+ ### Success Criteria:
234
+
235
+ #### Automated Verification:
236
+ - [ ] Migration applies cleanly: `make migrate`
237
+ - [ ] Unit tests pass: `make test-component`
238
+ - [ ] Type checking passes: `npm run typecheck`
239
+ - [ ] Linting passes: `make lint`
240
+ - [ ] Integration tests pass: `make test-integration`
241
+
242
+ #### Manual Verification:
243
+ - [ ] Feature works as expected when tested via UI
244
+ - [ ] Performance is acceptable under load
245
+ - [ ] Edge case handling verified manually
246
+ - [ ] No regressions in related features
247
+
248
+ **Implementation Note**: After completing this phase and all automated verification passes, pause here for manual confirmation from the human that the manual testing was successful before proceeding to the next phase.
249
+
250
+ ---
251
+
252
+ ## Phase 2: [Descriptive Name]
253
+
254
+ [Similar structure with both automated and manual success criteria...]
255
+
256
+ ---
257
+
258
+ ## Testing Strategy
259
+
260
+ ### Unit Tests:
261
+ - [What to test]
262
+ - [Key edge cases]
263
+
264
+ ### Integration Tests:
265
+ - [End-to-end scenarios]
266
+
267
+ ### Manual Testing Steps:
268
+ 1. [Specific step to verify feature]
269
+ 2. [Another verification step]
270
+ 3. [Edge case to test manually]
271
+
272
+ ## Performance Considerations
273
+
274
+ [Any performance implications or optimizations needed]
275
+
276
+ ## Migration Notes
277
+
278
+ [If applicable, how to handle existing data/systems]
279
+
280
+ ## References
281
+
282
+ - Original issue: GitHub issue #NNN
283
+ - Related research: `./thoughts/shared/research/[relevant].md`
284
+ - Similar implementation: `[file:line]`
285
+ ````
286
+
287
+ ### Step 5: Sync and Review
288
+
289
+ 1. **Sync the thoughts directory**:
290
+ - Run `thoughts-sync` to sync the newly created plan
291
+ - This ensures the plan is properly indexed and available
292
+
293
+ 2. **Present the draft plan location**:
294
+ ```
295
+ I've created the initial implementation plan at:
296
+ `./thoughts/shared/plans/YYYY-MM-DD/<issue-number>-description.md`
297
+
298
+ Please review it and let me know:
299
+ - Are the phases properly scoped?
300
+ - Are the success criteria specific enough?
301
+ - Any technical details that need adjustment?
302
+ - Missing edge cases or considerations?
303
+ ```
304
+
305
+ 3. **Iterate based on feedback** - be ready to:
306
+ - Add missing phases
307
+ - Adjust technical approach
308
+ - Clarify success criteria (both automated and manual)
309
+ - Add/remove scope items
310
+ - After making changes, run `thoughts-sync` again
311
+
312
+ 4. **Continue refining** until the user is satisfied
313
+
314
+ ## Important Guidelines
315
+
316
+ 1. **Be Skeptical**:
317
+ - Question vague requirements
318
+ - Identify potential issues early
319
+ - Ask "why" and "what about"
320
+ - Don't assume - verify with code
321
+
322
+ 2. **Be Interactive**:
323
+ - Don't write the full plan in one shot
324
+ - Get buy-in at each major step
325
+ - Allow course corrections
326
+ - Work collaboratively
327
+
328
+ 3. **Be Thorough**:
329
+ - Read all context files COMPLETELY before planning
330
+ - Research actual code patterns using parallel sub-tasks
331
+ - Include specific file paths and line numbers
332
+ - Write measurable success criteria with clear automated vs manual distinction
333
+ - automated steps should use `make` whenever possible - for example `make -C humanlayer-wui check` instead of `cd humanlayer-wui && bun run fmt`
334
+
335
+ 4. **Be Practical**:
336
+ - Focus on incremental, testable changes
337
+ - Consider migration and rollback
338
+ - Think about edge cases
339
+ - Include "what we're NOT doing"
340
+
341
+ 5. **Track Progress**:
342
+ - Track planning tasks as you go
343
+ - Update todos as you complete research
344
+ - Mark planning tasks complete when done
345
+
346
+ 6. **No Open Questions in Final Plan**:
347
+ - If you encounter open questions during planning, STOP
348
+ - Research or ask for clarification immediately
349
+ - Do NOT write the plan with unresolved questions
350
+ - The implementation plan must be complete and actionable
351
+ - Every decision must be made before finalizing the plan
352
+
353
+ ## Success Criteria Guidelines
354
+
355
+ **Always separate success criteria into two categories:**
356
+
357
+ 1. **Automated Verification** (can be run by execution agents):
358
+ - Commands that can be run: `make test`, `npm run lint`, etc.
359
+ - Specific files that should exist
360
+ - Code compilation/type checking
361
+ - Automated test suites
362
+
363
+ 2. **Manual Verification** (requires human testing):
364
+ - UI/UX functionality
365
+ - Performance under real conditions
366
+ - Edge cases that are hard to automate
367
+ - User acceptance criteria
368
+
369
+ **Format example:**
370
+ ```markdown
371
+ ### Success Criteria:
372
+
373
+ #### Automated Verification:
374
+ - [ ] Database migration runs successfully: `make migrate`
375
+ - [ ] All unit tests pass: `go test ./...`
376
+ - [ ] No linting errors: `golangci-lint run`
377
+ - [ ] API endpoint returns 200: `curl localhost:8080/api/new-endpoint`
378
+
379
+ #### Manual Verification:
380
+ - [ ] New feature appears correctly in the UI
381
+ - [ ] Performance is acceptable with 1000+ items
382
+ - [ ] Error messages are user-friendly
383
+ - [ ] Feature works correctly on mobile devices
384
+ ```
385
+
386
+ ## Common Patterns
387
+
388
+ ### For Database Changes:
389
+ - Start with schema/migration
390
+ - Add store methods
391
+ - Update business logic
392
+ - Expose via API
393
+ - Update clients
394
+
395
+ ### For New Features:
396
+ - Research existing patterns first
397
+ - Start with data model
398
+ - Build backend logic
399
+ - Add API endpoints
400
+ - Implement UI last
401
+
402
+ ### For Refactoring:
403
+ - Document current behavior
404
+ - Plan incremental changes
405
+ - Maintain backwards compatibility
406
+ - Include migration strategy
407
+
408
+ ## Sub-task Spawning Best Practices
409
+
410
+ When spawning research sub-tasks:
411
+
412
+ 1. **Spawn multiple tasks in parallel** for efficiency
413
+ 2. **Each task should be focused** on a specific area
414
+ 3. **Provide detailed instructions** including:
415
+ - Exactly what to search for
416
+ - Which directories to focus on
417
+ - What information to extract
418
+ - Expected output format
419
+ 4. **Be EXTREMELY specific about directories**:
420
+ - If the ticket mentions "WUI", specify `humanlayer-wui/` directory
421
+ - If it mentions "daemon", specify `hld/` directory
422
+ - Never use generic terms like "UI" when you mean "WUI"
423
+ - Include the full path context in your prompts
424
+ 5. **Specify read-only tools** to use
425
+ 6. **Request specific file:line references** in responses
426
+ 7. **Wait for all tasks to complete** before synthesizing
427
+ 8. **Verify sub-task results**:
428
+ - If a sub-task returns unexpected results, spawn follow-up tasks
429
+ - Cross-check findings against the actual codebase
430
+ - Don't accept results that seem incorrect
431
+
432
+ Example of spawning multiple tasks:
433
+ ```python
434
+ # Spawn these tasks concurrently:
435
+ tasks = [
436
+ Task("Research database schema", db_research_prompt),
437
+ Task("Find API patterns", api_research_prompt),
438
+ Task("Investigate UI components", ui_research_prompt),
439
+ Task("Check test patterns", test_research_prompt)
440
+ ]
441
+ ```
442
+
443
+ ## Example Interaction Flow
444
+
445
+ ```
446
+ User: /implementation_plan
447
+ Assistant: I'll help you create a detailed implementation plan...
448
+
449
+ User: We need to add parent-child tracking for Claude sub-tasks. See ./thoughts/username/tickets/ENG-1234.md
450
+ Assistant: Let me read that ticket file completely first...
451
+
452
+ [Reads file fully]
453
+
454
+ Based on the ticket, I understand we need to track parent-child relationships for Claude sub-task events in the hld daemon. Before I start planning, I have some questions...
455
+
456
+ [Interactive process continues...]
457
+ ```
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: decompose_ticket
3
+ description: "Decompose a feature ticket into vertical slices — testable, deliverable units ordered by dependency."
4
+ ---
5
+
6
+ # Decompose Ticket
7
+
8
+ Break a feature ticket into vertical slices. Each slice is a testable, deliverable unit that can be implemented, reviewed, and merged independently.
9
+
10
+ ## The Principle
11
+
12
+ **Never decompose by layer. Always decompose by function.**
13
+
14
+ Horizontal (wrong):
15
+ - Task 1: Routes
16
+ - Task 2: Model
17
+ - Task 3: Controller
18
+ - Task 4: Views
19
+
20
+ Each piece is untestable in isolation. Nothing is deliverable until everything is done.
21
+
22
+ Vertical (correct):
23
+ - Slice 1: Model + index action + seeds → immediately visible
24
+ - Slice 2: Show action → testable independently
25
+ - Slice 3: Edit/update actions → independently deliverable
26
+ - Slice 4: Delete action → independently deliverable
27
+
28
+ Each slice = working functionality that can be tested and reviewed on its own.
29
+
30
+ ## Process
31
+
32
+ ### Step 1: Understand the Ticket
33
+
34
+ Read the GitHub issue thoroughly. Identify:
35
+ - What is the desired end state?
36
+ - What are the acceptance criteria?
37
+ - What components are involved (models, controllers, views, services, jobs)?
38
+
39
+ Spawn the `thoughts-analyzer` specialist to find historical context about the feature area.
40
+
41
+ ### Step 2: Identify the Minimum Viable Slice
42
+
43
+ The first slice must be the smallest unit that produces something visible/testable:
44
+
45
+ **For Rails features:**
46
+ - Model + migration + seeds + one controller action + route + minimal view
47
+ - This is the "can I see something working?" threshold
48
+
49
+ **For API features:**
50
+ - Model + migration + one endpoint + request spec
51
+ - This is the "can I call it and get a response?" threshold
52
+
53
+ **For library/gem features:**
54
+ - Core class + public method + unit spec
55
+ - This is the "can I use it from a console?" threshold
56
+
57
+ ### Step 3: Slice by Function
58
+
59
+ After the minimum slice, decompose remaining work by function:
60
+
61
+ 1. **Read-only first**: index, show, list, get — safe, easy to verify
62
+ 2. **Mutations second**: create, update, delete — each independently
63
+ 3. **Edge cases last**: error handling, validations, authorization — after happy path works
64
+
65
+ Each slice must:
66
+ - Build on previous slices (no orphaned dependencies)
67
+ - Be independently testable
68
+ - Have clear acceptance criteria
69
+ - Be small enough for a single PR
70
+
71
+ ### Step 4: Create Sub-Issues
72
+
73
+ For each slice, create a GitHub sub-issue:
74
+ - Title: `Slice N: <what it delivers>`
75
+ - Body: What's included, what's NOT included, acceptance criteria, dependencies
76
+ - Link as sub-issue to the parent ticket
77
+
78
+ ```bash
79
+ # Create sub-issue
80
+ gh issue create --title "Slice 1: Model + index" --body "..."
81
+
82
+ # Link as sub-issue to parent
83
+ ISSUE_ID=$(gh api repos/{owner}/{repo}/issues/{new_number} --jq '.id')
84
+ gh api repos/{owner}/{repo}/issues/{parent_number}/sub_issues -X POST -F sub_issue_id=$ISSUE_ID
85
+ ```
86
+
87
+ ### Step 5: Order and Verify
88
+
89
+ Review the full sequence:
90
+ - Does each slice build on the previous?
91
+ - Is the first slice the smallest possible visible unit?
92
+ - Can each slice be tested without the ones after it?
93
+ - Are there any horizontal slices disguised as vertical? (e.g., "all migrations" is horizontal)
94
+
95
+ Present the decomposition for review before creating issues.
96
+
97
+ ## Anti-Patterns
98
+
99
+ - **"Set up the database first"** — horizontal. Include only the migration needed for slice 1.
100
+ - **"Add all routes"** — horizontal. Add routes as each action is implemented.
101
+ - **"Write all tests at the end"** — horizontal. Tests live with their slice.
102
+ - **"Refactor before building"** — unless blocking, refactoring is its own slice.
103
+
104
+ ## Guidelines
105
+
106
+ - Fewer, larger slices are better than many tiny ones — each slice has PR overhead
107
+ - The first slice should be demonstrable within hours, not days
108
+ - When in doubt about order: read before write, simple before complex, core before edge
109
+ - Each slice should leave the codebase in a working state (green tests)