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,91 @@
1
+ ---
2
+ name: feature
3
+ description: "Implement a GitHub issue end-to-end: branch, research, code, test, commit, PR, self-review."
4
+ ---
5
+
6
+ ## Context
7
+
8
+ Create and complete a new feature or chore from branch creation to PR readiness.
9
+
10
+ Read the GitHub issue to understand requirements. If no issue exists, create one via `gh issue create`.
11
+
12
+ ## Workflow
13
+
14
+ ### Step 1: Setup
15
+
16
+ Pull latest base branch (usually `main` or `master`)
17
+ Create feature branch: `<type>/<issue-number>-<short-description>` (e.g., `feature/42-add-api-endpoint`)
18
+ Assign GitHub issue to self via `gh issue edit <number> --add-assignee @me`
19
+
20
+ ### Step 2: Gather Historical Context
21
+
22
+ Spawn the `thoughts-analyzer` specialist with ticket reference, title, description, acceptance criteria, and any additional instructions from user input.
23
+
24
+ DO NOT proceed to Step 3 until this specialist returns. Its output is required input for Step 3.
25
+
26
+ ### Step 3: Research Codebase
27
+
28
+ After Step 2 completes, spawn research specialists in parallel, passing ticket info and historical context output from Step 2:
29
+
30
+ `codebase-pattern-finder` — find similar implementations to model after
31
+ `codebase-analyzer` — analyze the area being modified
32
+
33
+ Wait for both specialists to complete before proceeding.
34
+
35
+ ### Step 4: Implementation
36
+
37
+ Follow project conventions (CLAUDE.md) and best practices.
38
+ Keep code clean, DRY, well-documented.
39
+ When modifying code: fix lurking bugs, refactor, add missing tests and regression tests.
40
+ Ensure solid test coverage with well-documented business logic (viewable with `--format documentation`).
41
+ Review changes for completeness.
42
+
43
+ ### Step 5: Testing & Quality
44
+
45
+ Run specs for changed/affected files only (never full suite locally): `bundle exec rspec spec/path/to/changed_spec.rb`
46
+ `bundle exec reek` – Code smell detection
47
+ `bundle exec standardrb --fix`
48
+ `npx @herb-tools/linter --fix app/views/**/*.erb` (if views changed)
49
+ Fix all issues, even flaky tests.
50
+
51
+ ### Step 6: Translations (i18n)
52
+
53
+ `bundle exec i18n-tasks missing` – Check for missing translations
54
+ `bundle exec i18n-tasks normalize` – Normalize locale files
55
+ Add missing translations (manually or via OpenAI)
56
+
57
+ ### Step 7: Pull Request
58
+
59
+ Push branch.
60
+ `gh pr create --draft`
61
+ Title: `#<issue-number> feat: <description>` or `#<issue-number> chore: <description>` or `#<issue-number> fix: <description>`
62
+ Description: summary, test plan, breaking changes. Link to GitHub issue.
63
+
64
+ ### Step 8: CI Monitoring
65
+
66
+ Monitor checks until all pass.
67
+ If tests fail, investigate root cause vs flakiness.
68
+ Fix flaky tests – don't just retry; stabilize the test.
69
+
70
+ ### Step 9: Finalization
71
+
72
+ Update PR title/description if needed.
73
+
74
+ ## Requirements
75
+
76
+ No direct pushes to `master`.
77
+ Always branch per task.
78
+ All tests must pass.
79
+ All i18n translations must be present and normalized.
80
+ Flaky tests must be fixed, not ignored.
81
+
82
+ ## Conventions (Beautiful Code)
83
+
84
+ Boy Scout Rule: Leave the code cleaner than you found it.
85
+ Favor Plain Old Ruby Objects (POROs) and service objects; keep controllers and models thin.
86
+ Avoid N+1 queries by using includes (and consider Bullet for detection).
87
+ Use clear, explicit naming; avoid magic values.
88
+ Document all public APIs.
89
+ Use squash merges to keep commit history clean.
90
+ Write small, focused commits using Conventional Commits (feat:, chore:, fix:)
91
+
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: implement_plan
3
+ description: "Implement an approved technical plan phase by phase with verification."
4
+ ---
5
+
6
+ # Implement Plan
7
+
8
+ You are tasked with implementing an approved technical plan from `./thoughts/shared/plans/`. These plans contain phases with specific changes and success criteria.
9
+
10
+ ## Getting Started
11
+
12
+ When given a plan path:
13
+ - Read the plan completely and check for any existing checkmarks (- [x])
14
+ - Read the original ticket and all files mentioned in the plan
15
+ - **Read files fully** - never use limit/offset parameters, you need complete context
16
+ - Think deeply about how the pieces fit together
17
+ - Create a todo list to track your progress
18
+ - Start implementing if you understand what needs to be done
19
+
20
+ If no plan path provided, ask for one.
21
+
22
+ ## Implementation Philosophy
23
+
24
+ Plans are carefully designed, but reality can be messy. Your job is to:
25
+ - Follow the plan's intent while adapting to what you find
26
+ - Implement each phase fully before moving to the next
27
+ - Verify your work makes sense in the broader codebase context
28
+ - Update checkboxes in the plan as you complete sections
29
+
30
+ When things don't match the plan exactly, think about why and communicate clearly. The plan is your guide, but your judgment matters too.
31
+
32
+ If you encounter a mismatch:
33
+ - STOP and think deeply about why the plan can't be followed
34
+ - Present the issue clearly:
35
+ ```
36
+ Issue in Phase [N]:
37
+ Expected: [what the plan says]
38
+ Found: [actual situation]
39
+ Why this matters: [explanation]
40
+
41
+ How should I proceed?
42
+ ```
43
+
44
+ ## Verification Approach
45
+
46
+ After implementing a phase:
47
+ - Run the success criteria checks (usually `make check test` covers everything)
48
+ - Fix any issues before proceeding
49
+ - Update your progress in both the plan and your todos
50
+ - Check off completed items in the plan file itself using Edit
51
+ - **Pause for human verification**: After completing all automated verification for a phase, pause and inform the human that the phase is ready for manual testing. Use this format:
52
+ ```
53
+ Phase [N] Complete - Ready for Manual Verification
54
+
55
+ Automated verification passed:
56
+ - [List automated checks that passed]
57
+
58
+ Please perform the manual verification steps listed in the plan:
59
+ - [List manual verification items from the plan]
60
+
61
+ Let me know when manual testing is complete so I can proceed to Phase [N+1].
62
+ ```
63
+
64
+ If instructed to execute multiple phases consecutively, skip the pause until the last phase. Otherwise, assume you are just doing one phase.
65
+
66
+ do not check off items in the manual testing steps until confirmed by the user.
67
+
68
+
69
+ ## If You Get Stuck
70
+
71
+ When something isn't working as expected:
72
+ - First, make sure you've read and understood all the relevant code
73
+ - Consider if the codebase has evolved since the plan was written
74
+ - Present the mismatch clearly and ask for guidance
75
+
76
+ Use sub-tasks sparingly - mainly for targeted debugging or exploring unfamiliar territory.
77
+
78
+ ## Resuming Work
79
+
80
+ If no existing checkmarks, create feature branch from updated main. **Make sure you're on a feature branch before implementing!**
81
+
82
+ If the plan has existing checkmarks:
83
+ - Trust that completed work is done
84
+ - Pick up from the first unchecked item
85
+ - Verify previous work only if something seems off
86
+
87
+ Remember: You're implementing a solution, not just checking boxes. Keep the end goal in mind and maintain forward momentum.
@@ -0,0 +1,247 @@
1
+ ---
2
+ name: iterate_plan
3
+ description: "Iterate on existing implementation plans with research and targeted updates."
4
+ ---
5
+
6
+ # Iterate Implementation Plan
7
+
8
+ You are tasked with updating existing implementation plans based on user feedback. You should be skeptical, thorough, and ensure changes are grounded in actual codebase reality.
9
+
10
+ ## Initial Response
11
+
12
+ When this command is invoked:
13
+
14
+ 1. **Parse the input to identify**:
15
+ - Plan file path (e.g., `./thoughts/shared/plans/2025-10-16/feature.md`)
16
+ - Requested changes/feedback
17
+
18
+ 2. **Handle different input scenarios**:
19
+
20
+ **If NO plan file provided**:
21
+ ```
22
+ I'll help you iterate on an existing implementation plan.
23
+
24
+ Which plan would you like to update? Please provide the path to the plan file (e.g., `./thoughts/shared/plans/2025-10-16/feature.md`).
25
+
26
+ Tip: You can list recent plans with `ls -lt ./thoughts/shared/plans/ | head`
27
+ ```
28
+ Wait for user input, then re-check for feedback.
29
+
30
+ **If plan file provided but NO feedback**:
31
+ ```
32
+ I've found the plan at [path]. What changes would you like to make?
33
+
34
+ For example:
35
+ - "Add a phase for migration handling"
36
+ - "Update the success criteria to include performance tests"
37
+ - "Adjust the scope to exclude feature X"
38
+ - "Split Phase 2 into two separate phases"
39
+ ```
40
+ Wait for user input.
41
+
42
+ **If BOTH plan file AND feedback provided**:
43
+ - Proceed immediately to Step 1
44
+ - No preliminary questions needed
45
+
46
+ ## Process Steps
47
+
48
+ ### Step 1: Read and Understand Current Plan
49
+
50
+ 1. **Read the existing plan file COMPLETELY**:
51
+ - Use the Read tool WITHOUT limit/offset parameters
52
+ - Understand the current structure, phases, and scope
53
+ - Note the success criteria and implementation approach
54
+
55
+ 2. **Understand the requested changes**:
56
+ - Parse what the user wants to add/modify/remove
57
+ - Identify if changes require codebase research
58
+ - Determine scope of the update
59
+
60
+ ### Step 2: Research If Needed
61
+
62
+ **Only spawn research tasks if the changes require new technical understanding.**
63
+
64
+ If the user's feedback requires understanding new code patterns or validating assumptions:
65
+
66
+ 1. **Create a research todo list**
67
+
68
+ 2. **Spawn parallel sub-tasks for research**:
69
+ Use the right agent for each type of research:
70
+
71
+ **For code investigation:**
72
+ - **codebase-analyzer** — find and understand implementation details
73
+ - **codebase-pattern-finder** — find similar patterns
74
+
75
+ **For historical context:**
76
+ - **thoughts-analyzer** — discover and extract insights from documents
77
+
78
+ **Be EXTREMELY specific about directories**:
79
+ - If the change involves "WUI", specify `humanlayer-wui/` directory
80
+ - If it involves "daemon", specify `hld/` directory
81
+ - Include full path context in prompts
82
+
83
+ 3. **Read any new files identified by research**:
84
+ - Read them FULLY into the main context
85
+ - Cross-reference with the plan requirements
86
+
87
+ 4. **Wait for ALL sub-tasks to complete** before proceeding
88
+
89
+ ### Step 3: Present Understanding and Approach
90
+
91
+ Before making changes, confirm your understanding:
92
+
93
+ ```
94
+ Based on your feedback, I understand you want to:
95
+ - [Change 1 with specific detail]
96
+ - [Change 2 with specific detail]
97
+
98
+ My research found:
99
+ - [Relevant code pattern or constraint]
100
+ - [Important discovery that affects the change]
101
+
102
+ I plan to update the plan by:
103
+ 1. [Specific modification to make]
104
+ 2. [Another modification]
105
+
106
+ Does this align with your intent?
107
+ ```
108
+
109
+ Get user confirmation before proceeding.
110
+
111
+ ### Step 4: Update the Plan
112
+
113
+ 1. **Make focused, precise edits** to the existing plan:
114
+ - Use the Edit tool for surgical changes
115
+ - Maintain the existing structure unless explicitly changing it
116
+ - Keep all file:line references accurate
117
+ - Update success criteria if needed
118
+
119
+ 2. **Ensure consistency**:
120
+ - If adding a new phase, ensure it follows the existing pattern
121
+ - If modifying scope, update "What We're NOT Doing" section
122
+ - If changing approach, update "Implementation Approach" section
123
+ - Maintain the distinction between automated vs manual success criteria
124
+
125
+ 3. **Preserve quality standards**:
126
+ - Include specific file paths and line numbers for new content
127
+ - Write measurable success criteria
128
+ - Use `make` commands for automated verification
129
+ - Keep language clear and actionable
130
+
131
+ ### Step 5: Sync and Review
132
+
133
+ 1. **Sync the updated plan**:
134
+ - Run `thoughts-sync`
135
+ - This ensures changes are properly indexed
136
+
137
+ 2. **Present the changes made**:
138
+ ```
139
+ I've updated the plan at `./thoughts/shared/plans/[filename].md`
140
+
141
+ Changes made:
142
+ - [Specific change 1]
143
+ - [Specific change 2]
144
+
145
+ The updated plan now:
146
+ - [Key improvement]
147
+ - [Another improvement]
148
+
149
+ Would you like any further adjustments?
150
+ ```
151
+
152
+ 3. **Be ready to iterate further** based on feedback
153
+
154
+ ## Important Guidelines
155
+
156
+ 1. **Be Skeptical**:
157
+ - Don't blindly accept change requests that seem problematic
158
+ - Question vague feedback - ask for clarification
159
+ - Verify technical feasibility with code research
160
+ - Point out potential conflicts with existing plan phases
161
+
162
+ 2. **Be Surgical**:
163
+ - Make precise edits, not wholesale rewrites
164
+ - Preserve good content that doesn't need changing
165
+ - Only research what's necessary for the specific changes
166
+ - Don't over-engineer the updates
167
+
168
+ 3. **Be Thorough**:
169
+ - Read the entire existing plan before making changes
170
+ - Research code patterns if changes require new technical understanding
171
+ - Ensure updated sections maintain quality standards
172
+ - Verify success criteria are still measurable
173
+
174
+ 4. **Be Interactive**:
175
+ - Confirm understanding before making changes
176
+ - Show what you plan to change before doing it
177
+ - Allow course corrections
178
+ - Don't disappear into research without communicating
179
+
180
+ 5. **Track Progress**:
181
+ - Track update tasks if complex
182
+ - Update todos as you complete research
183
+ - Mark tasks complete when done
184
+
185
+ 6. **No Open Questions**:
186
+ - If the requested change raises questions, ASK
187
+ - Research or get clarification immediately
188
+ - Do NOT update the plan with unresolved questions
189
+ - Every change must be complete and actionable
190
+
191
+ ## Success Criteria Guidelines
192
+
193
+ When updating success criteria, always maintain the two-category structure:
194
+
195
+ 1. **Automated Verification** (can be run by execution agents):
196
+ - Commands that can be run: `make test`, `npm run lint`, etc.
197
+ - Prefer `make` commands: `make -C humanlayer-wui check` instead of `cd humanlayer-wui && bun run fmt`
198
+ - Specific files that should exist
199
+ - Code compilation/type checking
200
+
201
+ 2. **Manual Verification** (requires human testing):
202
+ - UI/UX functionality
203
+ - Performance under real conditions
204
+ - Edge cases that are hard to automate
205
+ - User acceptance criteria
206
+
207
+ ## Sub-task Spawning Best Practices
208
+
209
+ When spawning research sub-tasks:
210
+
211
+ 1. **Only spawn if truly needed** - don't research for simple changes
212
+ 2. **Spawn multiple tasks in parallel** for efficiency
213
+ 3. **Each task should be focused** on a specific area
214
+ 4. **Provide detailed instructions** including:
215
+ - Exactly what to search for
216
+ - Which directories to focus on
217
+ - What information to extract
218
+ - Expected output format
219
+ 5. **Request specific file:line references** in responses
220
+ 6. **Wait for all tasks to complete** before synthesizing
221
+ 7. **Verify sub-task results** - if something seems off, spawn follow-up tasks
222
+
223
+ ## Example Interaction Flows
224
+
225
+ **Scenario 1: User provides everything upfront**
226
+ ```
227
+ User: iterate_plan ./thoughts/shared/plans/2025-10-16/feature.md - add phase for error handling
228
+ Assistant: [Reads plan, researches error handling patterns, updates plan]
229
+ ```
230
+
231
+ **Scenario 2: User provides just plan file**
232
+ ```
233
+ User: iterate_plan ./thoughts/shared/plans/2025-10-16/feature.md
234
+ Assistant: I've found the plan. What changes would you like to make?
235
+ User: Split Phase 2 into two phases - one for backend, one for frontend
236
+ Assistant: [Proceeds with update]
237
+ ```
238
+
239
+ **Scenario 3: User provides no arguments**
240
+ ```
241
+ User: iterate_plan
242
+ Assistant: Which plan would you like to update? Please provide the path...
243
+ User: ./thoughts/shared/plans/2025-10-16/feature.md
244
+ Assistant: I've found the plan. What changes would you like to make?
245
+ User: Add more specific success criteria
246
+ Assistant: [Proceeds with update]
247
+ ```
@@ -0,0 +1,210 @@
1
+ ---
2
+ name: research_codebase
3
+ description: "Comprehensive codebase research by spawning parallel specialists and synthesizing findings."
4
+ ---
5
+
6
+ # Research Codebase
7
+
8
+ You are tasked with conducting comprehensive research across the codebase to answer user questions by spawning parallel sub-agents and synthesizing their findings.
9
+
10
+ ## CRITICAL: YOUR ONLY JOB IS TO DOCUMENT AND EXPLAIN THE CODEBASE AS IT EXISTS TODAY
11
+ - DO NOT suggest improvements or changes unless the user explicitly asks for them
12
+ - DO NOT perform root cause analysis unless the user explicitly asks for them
13
+ - DO NOT propose future enhancements unless the user explicitly asks for them
14
+ - DO NOT critique the implementation or identify problems
15
+ - DO NOT recommend refactoring, optimization, or architectural changes
16
+ - ONLY describe what exists, where it exists, how it works, and how components interact
17
+ - You are creating a technical map/documentation of the existing system
18
+
19
+ ## Initial Setup:
20
+
21
+ When this command is invoked, respond with:
22
+ ```
23
+ I'm ready to research the codebase. Please provide your research question or area of interest, and I'll analyze it thoroughly by exploring relevant components and connections.
24
+ ```
25
+
26
+ Then wait for the user's research query.
27
+
28
+ ## Steps to follow after receiving the research query:
29
+
30
+ 1. **Read any directly mentioned files first:**
31
+ - If the user mentions specific files (tickets, docs, JSON), read them FULLY first
32
+ - **IMPORTANT**: Use the Read tool WITHOUT limit/offset parameters to read entire files
33
+ - **CRITICAL**: Read these files yourself in the main context before spawning any sub-tasks
34
+ - This ensures you have full context before decomposing the research
35
+
36
+ 2. **Analyze and decompose the research question:**
37
+ - Break down the user's query into composable research areas
38
+ - Take time to ultrathink about the underlying patterns, connections, and architectural implications the user might be seeking
39
+ - Identify specific components, patterns, or concepts to investigate
40
+ - Create a research plan to track all subtasks
41
+ - Consider which directories, files, or architectural patterns are relevant
42
+
43
+ 3. **Spawn parallel sub-agent tasks for comprehensive research:**
44
+ - Create multiple subagents to research different aspects concurrently
45
+ - We now have specialized agents that know how to do specific research tasks:
46
+
47
+ **For codebase research:**
48
+ - Use the **codebase-analyzer** specialist to find and understand HOW specific code works (without critiquing it)
49
+ - Use the **codebase-pattern-finder** specialist to find examples of existing patterns (without evaluating them)
50
+
51
+ **IMPORTANT**: All agents are documentarians, not critics. They will describe what exists without suggesting improvements or identifying issues.
52
+
53
+ **For thoughts directory:**
54
+ - Use the **thoughts-analyzer** specialist to discover and extract key insights from documents (only the most relevant ones)
55
+
56
+ **For web research (only if user explicitly asks):**
57
+ - Use the **web-search-researcher** specialist for external documentation and resources
58
+ - IF you use web-research agents, instruct them to return LINKS with their findings, and please INCLUDE those links in your final report
59
+
60
+ **For GitHub issues (if relevant):**
61
+ - Read issue details via `gh issue view <number>`
62
+ - Search related issues via `gh issue list --search "keyword"`
63
+
64
+ The key is to use these agents intelligently:
65
+ - Use analyzer agents to find relevant files and document how they work
66
+ - Run multiple agents in parallel when they're searching for different things
67
+ - Each agent knows its job - just tell it what you're looking for
68
+ - Don't write detailed prompts about HOW to search - the agents already know
69
+ - Remind agents they are documenting, not evaluating or improving
70
+
71
+ 4. **Wait for all sub-agents to complete and synthesize findings:**
72
+ - IMPORTANT: Wait for ALL sub-agent tasks to complete before proceeding
73
+ - Compile all sub-agent results (both codebase and thoughts findings)
74
+ - Prioritize live codebase findings as primary source of truth
75
+ - Use thoughts/ findings as supplementary historical context
76
+ - Connect findings across different components
77
+ - Include specific file paths and line numbers for reference
78
+ - Verify all thoughts/ paths are correct (e.g., ./thoughts/username/ not ./thoughts/shared/ for personal files)
79
+ - Highlight patterns, connections, and architectural decisions
80
+ - Answer the user's specific questions with concrete evidence
81
+
82
+ 5. **Gather metadata for the research document:**
83
+ - Run `spec-metadata` (in the PATH) to generate all relevant metadata
84
+ - Filename: `./thoughts/shared/research/YYYY-MM-DD/<issue-number>-description.md`
85
+ - Format: `YYYY-MM-DD/<issue-number>-description.md` where:
86
+ - YYYY-MM-DD is today's date
87
+ - issue-number is the GitHub issue number (omit if no issue)
88
+ - description is a brief kebab-case description of the research topic
89
+ - Examples:
90
+ - With issue: `2026-03-15/170-import-workflows.md`
91
+ - Without issue: `2026-03-15/authentication-flow.md`
92
+
93
+ 6. **Generate research document:**
94
+ - Use the metadata gathered in step 4
95
+ - Structure the document with YAML frontmatter followed by content:
96
+ ```markdown
97
+ ---
98
+ date: [Current date and time with timezone in ISO format]
99
+ researcher: [Researcher name from thoughts status]
100
+ git_commit: [Current commit hash]
101
+ branch: [Current branch name]
102
+ repository: [Repository name]
103
+ topic: "[User's Question/Topic]"
104
+ tags: [research, codebase, relevant-component-names]
105
+ status: complete
106
+ last_updated: [Current date in YYYY-MM-DD format]
107
+ last_updated_by: [Researcher name]
108
+ ---
109
+
110
+ # Research: [User's Question/Topic]
111
+
112
+ **Date**: [Current date and time with timezone from step 4]
113
+ **Researcher**: [Researcher name from thoughts status]
114
+ **Git Commit**: [Current commit hash from step 4]
115
+ **Branch**: [Current branch name from step 4]
116
+ **Repository**: [Repository name]
117
+
118
+ ## Research Question
119
+ [Original user query]
120
+
121
+ ## Summary
122
+ [High-level documentation of what was found, answering the user's question by describing what exists]
123
+
124
+ ## Detailed Findings
125
+
126
+ ### [Component/Area 1]
127
+ - Description of what exists ([file.ext:line](link))
128
+ - How it connects to other components
129
+ - Current implementation details (without evaluation)
130
+
131
+ ### [Component/Area 2]
132
+ ...
133
+
134
+ ## Code References
135
+ - `path/to/file.py:123` - Description of what's there
136
+ - `another/file.ts:45-67` - Description of the code block
137
+
138
+ ## Architecture Documentation
139
+ [Current patterns, conventions, and design implementations found in the codebase]
140
+
141
+ ## Historical Context (from thoughts/)
142
+ [Relevant insights from thoughts/ directory with references]
143
+ - `./thoughts/shared/something.md` - Historical decision about X
144
+ - `./thoughts/local/notes.md` - Past exploration of Y
145
+ Note: Paths exclude "searchable/" even if found there
146
+
147
+ ## Related Research
148
+ [Links to other research documents in ./thoughts/shared/research/]
149
+
150
+ ## Open Questions
151
+ [Any areas that need further investigation]
152
+ ```
153
+
154
+ 7. **Add GitHub permalinks (if applicable):**
155
+ - Check if on main branch or if commit is pushed: `git branch --show-current` and `git status`
156
+ - If on main/master or pushed, generate GitHub permalinks:
157
+ - Get repo info: `gh repo view --json owner,name`
158
+ - Create permalinks: `https://github.com/{owner}/{repo}/blob/{commit}/{file}#L{line}`
159
+ - Replace local file references with permalinks in the document
160
+
161
+ 8. **Sync and present findings:**
162
+ - Run `thoughts-sync` to sync the thoughts directory
163
+ - Present a concise summary of findings to the user
164
+ - Include key file references for easy navigation
165
+ - Ask if they have follow-up questions or need clarification
166
+
167
+ 9. **Handle follow-up questions:**
168
+ - If the user has follow-up questions, append to the same research document
169
+ - Update the frontmatter fields `last_updated` and `last_updated_by` to reflect the update
170
+ - Add `last_updated_note: "Added follow-up research for [brief description]"` to frontmatter
171
+ - Add a new section: `## Follow-up Research [timestamp]`
172
+ - Spawn new sub-agents as needed for additional investigation
173
+ - Continue updating the document and syncing
174
+
175
+ ## Important notes:
176
+ - Always use parallel subagents to maximize efficiency and minimize context usage
177
+ - Always run fresh codebase research - never rely solely on existing research documents
178
+ - The thoughts/ directory provides historical context to supplement live findings
179
+ - Focus on finding concrete file paths and line numbers for developer reference
180
+ - Research documents should be self-contained with all necessary context
181
+ - Each sub-agent prompt should be specific and focused on read-only documentation operations
182
+ - Document cross-component connections and how systems interact
183
+ - Include temporal context (when the research was conducted)
184
+ - Link to GitHub when possible for permanent references
185
+ - Keep the main agent focused on synthesis, not deep file reading
186
+ - Have sub-agents document examples and usage patterns as they exist
187
+ - Explore all of thoughts/ directory, not just research subdirectory
188
+ - **CRITICAL**: You and all sub-agents are documentarians, not evaluators
189
+ - **REMEMBER**: Document what IS, not what SHOULD BE
190
+ - **NO RECOMMENDATIONS**: Only describe the current state of the codebase
191
+ - **File reading**: Always read mentioned files FULLY (no limit/offset) before spawning sub-tasks
192
+ - **Critical ordering**: Follow the numbered steps exactly
193
+ - ALWAYS read mentioned files first before spawning sub-tasks (step 1)
194
+ - ALWAYS wait for all sub-agents to complete before synthesizing (step 4)
195
+ - ALWAYS gather metadata before writing the document (step 5 before step 6)
196
+ - NEVER write the research document with placeholder values
197
+ - **Path handling**: The ./thoughts/searchable/ directory contains hard links for searching
198
+ - Always document paths by removing ONLY "searchable/" - preserve all other subdirectories
199
+ - Examples of correct transformations:
200
+ - `./thoughts/searchable/username/old_stuff/notes.md` → `./thoughts/username/old_stuff/notes.md`
201
+ - `./thoughts/searchable/shared/prs/123.md` → `./thoughts/shared/prs/123.md`
202
+ - `./thoughts/searchable/global/shared/templates.md` → `./thoughts/global/shared/templates.md`
203
+ - NEVER change username/ to shared/ or vice versa - preserve the exact directory structure
204
+ - This ensures paths are correct for editing and navigation
205
+ - **Frontmatter consistency**:
206
+ - Always include frontmatter at the beginning of research documents
207
+ - Keep frontmatter fields consistent across all research documents
208
+ - Update frontmatter when adding follow-up research
209
+ - Use snake_case for multi-word field names (e.g., `last_updated`, `git_commit`)
210
+ - Tags should be relevant to the research topic and components studied