@bonesofspring/ai-rules 0.2.2 → 0.2.4

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 (295) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +27 -4
  3. package/bin/cli.js +285 -72
  4. package/package.json +3 -2
  5. package/presets/claude/ios-swift/CLAUDE.md +28 -20
  6. package/presets/claude/ios-swift/MCP.md +14 -0
  7. package/presets/claude/ios-swift/README.md +18 -15
  8. package/presets/claude/ios-swift/agents/README.md +55 -0
  9. package/presets/claude/ios-swift/agents/accessibility-reviewer.md +67 -0
  10. package/presets/claude/ios-swift/agents/api-contract-reviewer.md +72 -0
  11. package/presets/claude/ios-swift/agents/build-verifier.md +64 -0
  12. package/presets/claude/ios-swift/agents/ci-investigator.md +73 -0
  13. package/presets/claude/ios-swift/agents/code-reviewer.md +75 -0
  14. package/presets/claude/ios-swift/agents/debugger.md +72 -0
  15. package/presets/claude/ios-swift/agents/feature-developer.md +35 -0
  16. package/presets/claude/ios-swift/agents/migration-specialist.md +73 -0
  17. package/presets/claude/ios-swift/agents/performance-auditor.md +72 -0
  18. package/presets/claude/ios-swift/agents/qa-tester.md +65 -0
  19. package/presets/claude/ios-swift/agents/security-reviewer.md +69 -0
  20. package/presets/claude/ios-swift/agents/solution-architect.md +17 -0
  21. package/presets/claude/ios-swift/agents/task-analyst.md +25 -0
  22. package/presets/claude/ios-swift/agents/task-router.md +62 -0
  23. package/presets/claude/ios-swift/agents/tech-writer.md +63 -0
  24. package/presets/claude/ios-swift/agents/unit-test-generator.md +54 -0
  25. package/presets/claude/ios-swift/agents/unit-test-healer.md +53 -0
  26. package/presets/claude/ios-swift/agents/unit-test-planner.md +64 -0
  27. package/presets/claude/ios-swift/agents/xcuitest-test-generator.md +47 -0
  28. package/presets/claude/ios-swift/agents/xcuitest-test-healer.md +47 -0
  29. package/presets/claude/ios-swift/agents/xcuitest-test-planner.md +67 -0
  30. package/presets/claude/ios-swift/commands/README.md +12 -2
  31. package/presets/claude/ios-swift/commands/feature-continue.md +51 -0
  32. package/presets/claude/ios-swift/commands/feature-start.md +30 -0
  33. package/presets/claude/ios-swift/commands/task-continue.md +49 -0
  34. package/presets/claude/ios-swift/commands/task.md +50 -0
  35. package/presets/claude/ios-swift/commands/technical-retro.md +58 -0
  36. package/presets/claude/ios-swift/hooks/README.md +10 -0
  37. package/presets/claude/ios-swift/hooks/chain-team-phases.sh +382 -0
  38. package/presets/claude/ios-swift/hooks/guard-shell-command.sh +79 -0
  39. package/presets/claude/ios-swift/mcp.json +12 -0
  40. package/presets/claude/ios-swift/rules/README.md +25 -14
  41. package/presets/claude/ios-swift/rules/api-and-data/README.md +2 -1
  42. package/presets/claude/ios-swift/rules/api-and-data/networking.md +2 -2
  43. package/presets/claude/ios-swift/rules/api-and-data/persistence.md +30 -0
  44. package/presets/claude/ios-swift/rules/architecture/README.md +3 -1
  45. package/presets/claude/ios-swift/rules/architecture/feature-delivery.md +10 -2
  46. package/presets/claude/ios-swift/rules/architecture/module-public-api.md +25 -0
  47. package/presets/claude/ios-swift/rules/architecture/reference-features.md +50 -0
  48. package/presets/claude/ios-swift/rules/stack/ios-app-core.md +2 -1
  49. package/presets/claude/ios-swift/rules/testing/ui.md +2 -0
  50. package/presets/claude/ios-swift/rules/tooling-and-review/README.md +6 -1
  51. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-intake.md +18 -0
  52. package/presets/claude/ios-swift/rules/tooling-and-review/agent-team-orchestrator.md +47 -0
  53. package/presets/claude/ios-swift/rules/tooling-and-review/code-review.md +5 -0
  54. package/presets/claude/ios-swift/rules/tooling-and-review/post-change-build.md +5 -0
  55. package/presets/claude/ios-swift/rules/tooling-and-review/security-ios.md +36 -0
  56. package/presets/claude/ios-swift/rules/tooling-and-review/technical-retro.md +14 -0
  57. package/presets/claude/ios-swift/rules/tooling-and-review/xcode-tooling.md +24 -0
  58. package/presets/claude/ios-swift/rules/ui-and-accessibility/README.md +2 -1
  59. package/presets/claude/ios-swift/rules/ui-and-accessibility/navigation.md +28 -0
  60. package/presets/claude/ios-swift/skills/README.md +13 -0
  61. package/presets/claude/ios-swift/skills/ci-investigation/SKILL.md +39 -0
  62. package/presets/claude/ios-swift/skills/code-review/SKILL.md +27 -0
  63. package/presets/claude/ios-swift/skills/debug-investigation/SKILL.md +30 -0
  64. package/presets/claude/ios-swift/skills/feature-delivery/SKILL.md +27 -0
  65. package/presets/claude/ios-swift/skills/technical-retro/SKILL.md +10 -0
  66. package/presets/claude/ios-swift/skills/unit-testing/SKILL.md +32 -0
  67. package/presets/claude/ios-swift/skills/xcuitest-e2e/SKILL.md +33 -0
  68. package/presets/claude/ios-swift/team/README.md +27 -0
  69. package/presets/claude/ios-swift/team/fixtures/bugfix-standard.json +33 -0
  70. package/presets/claude/ios-swift/team/fixtures/feature-full.json +48 -0
  71. package/presets/claude/ios-swift/team/fixtures/feature-light.json +36 -0
  72. package/presets/claude/next/CLAUDE.md +29 -5
  73. package/presets/claude/next/MCP.md +16 -0
  74. package/presets/claude/next/README.md +12 -0
  75. package/presets/claude/next/agents/README.md +155 -1
  76. package/presets/claude/next/agents/accessibility-reviewer.md +65 -0
  77. package/presets/claude/next/agents/api-contract-reviewer.md +69 -0
  78. package/presets/claude/next/agents/build-verifier.md +64 -0
  79. package/presets/claude/next/agents/ci-investigator.md +62 -0
  80. package/presets/claude/next/agents/code-reviewer.md +63 -0
  81. package/presets/claude/next/agents/debugger.md +63 -0
  82. package/presets/claude/next/agents/feature-developer.md +27 -0
  83. package/presets/claude/next/agents/migration-specialist.md +69 -0
  84. package/presets/claude/next/agents/performance-auditor.md +68 -0
  85. package/presets/claude/next/agents/qa-tester.md +56 -0
  86. package/presets/claude/next/agents/security-reviewer.md +64 -0
  87. package/presets/claude/next/agents/solution-architect.md +70 -0
  88. package/presets/claude/next/agents/task-analyst.md +111 -0
  89. package/presets/claude/next/agents/task-router.md +94 -0
  90. package/presets/claude/next/agents/tech-writer.md +61 -0
  91. package/presets/claude/next/agents/unit-test-generator.md +37 -0
  92. package/presets/claude/next/agents/unit-test-healer.md +38 -0
  93. package/presets/claude/next/agents/unit-test-planner.md +62 -0
  94. package/presets/claude/next/commands/README.md +10 -2
  95. package/presets/claude/next/commands/feature-continue.md +51 -0
  96. package/presets/claude/next/commands/feature-start.md +30 -0
  97. package/presets/claude/next/commands/task-continue.md +49 -0
  98. package/presets/claude/next/commands/task.md +50 -0
  99. package/presets/claude/next/commands/technical-retro.md +58 -0
  100. package/presets/claude/next/hooks/README.md +5 -2
  101. package/presets/claude/next/hooks/chain-team-phases.sh +380 -0
  102. package/presets/claude/next/hooks/guard-shell-command.sh +77 -0
  103. package/presets/claude/next/mcp.json +20 -0
  104. package/presets/claude/next/rules/README.md +42 -11
  105. package/presets/claude/next/rules/api-and-data/README.md +7 -1
  106. package/presets/claude/next/rules/api-and-data/api-services.md +57 -0
  107. package/presets/claude/next/rules/api-and-data/http-client.md +40 -0
  108. package/presets/claude/next/rules/api-and-data/store-rtk.md +65 -0
  109. package/presets/claude/next/rules/architecture/README.md +11 -2
  110. package/presets/claude/next/rules/architecture/architecture-boundaries-ui.md +15 -0
  111. package/presets/claude/next/rules/architecture/architecture-boundaries.md +75 -0
  112. package/presets/claude/next/rules/architecture/feature-delivery-workflow.md +79 -0
  113. package/presets/claude/next/rules/architecture/layer-barrel-exports.md +58 -0
  114. package/presets/claude/next/rules/architecture/public-imports.md +46 -0
  115. package/presets/claude/next/rules/architecture/reference-features.md +37 -0
  116. package/presets/claude/next/rules/stack/README.md +10 -1
  117. package/presets/claude/next/rules/stack/arrow-functions.md +45 -0
  118. package/presets/claude/next/rules/stack/navigation-router-ui.md +15 -0
  119. package/presets/claude/next/rules/stack/navigation-router.md +64 -0
  120. package/presets/claude/next/rules/stack/next-app-core.md +33 -0
  121. package/presets/claude/next/rules/stack/next-app-router.md +36 -0
  122. package/presets/claude/next/rules/stack/no-type-assertion.md +59 -0
  123. package/presets/claude/next/rules/stack/types-jsdoc.md +37 -0
  124. package/presets/claude/next/rules/testing/README.md +9 -1
  125. package/presets/claude/next/rules/testing/playwright-agents.md +74 -0
  126. package/presets/claude/next/rules/testing/tests-e2e-structure.md +52 -0
  127. package/presets/claude/next/rules/testing/tests-unit.md +66 -0
  128. package/presets/claude/next/rules/tooling-and-review/README.md +12 -1
  129. package/presets/claude/next/rules/tooling-and-review/agent-team-intake.md +15 -0
  130. package/presets/claude/next/rules/tooling-and-review/agent-team-orchestrator.md +145 -0
  131. package/presets/claude/next/rules/tooling-and-review/code-quality.md +42 -0
  132. package/presets/claude/next/rules/tooling-and-review/code-review-mr.md +30 -0
  133. package/presets/claude/next/rules/tooling-and-review/package-manager.md +11 -0
  134. package/presets/claude/next/rules/tooling-and-review/post-change-lint.md +44 -0
  135. package/presets/claude/next/rules/ui-and-accessibility/README.md +10 -1
  136. package/presets/claude/next/rules/ui-and-accessibility/css-property-order.md +14 -0
  137. package/presets/claude/next/rules/ui-and-accessibility/no-props-spread.md +57 -0
  138. package/presets/claude/next/rules/ui-and-accessibility/react-a11y-coding.md +37 -0
  139. package/presets/claude/next/rules/ui-and-accessibility/react-ui.md +91 -0
  140. package/presets/claude/next/skills/README.md +11 -1
  141. package/presets/claude/next/skills/ci-investigation/SKILL.md +36 -0
  142. package/presets/claude/next/skills/code-review/SKILL.md +26 -0
  143. package/presets/claude/next/skills/debug-investigation/SKILL.md +28 -0
  144. package/presets/claude/next/skills/feature-delivery/SKILL.md +15 -0
  145. package/presets/claude/next/skills/playwright-e2e/SKILL.md +31 -0
  146. package/presets/claude/next/skills/technical-retro/SKILL.md +40 -0
  147. package/presets/claude/next/skills/unit-testing/SKILL.md +32 -0
  148. package/presets/claude/next/team/README.md +105 -0
  149. package/presets/claude/next/team/fixtures/bugfix-standard.json +15 -0
  150. package/presets/claude/next/team/fixtures/feature-full.json +16 -0
  151. package/presets/claude/next/team/fixtures/feature-light.json +17 -0
  152. package/presets/claude/next/team/tasks/.gitkeep +1 -0
  153. package/presets/cursor/ios-swift/AGENTS.md +47 -0
  154. package/presets/cursor/ios-swift/BUGBOT.md +15 -0
  155. package/presets/cursor/ios-swift/MCP.md +16 -0
  156. package/presets/cursor/ios-swift/README.md +27 -7
  157. package/presets/cursor/ios-swift/agents/README.md +55 -0
  158. package/presets/cursor/ios-swift/agents/accessibility-reviewer.md +67 -0
  159. package/presets/cursor/ios-swift/agents/api-contract-reviewer.md +72 -0
  160. package/presets/cursor/ios-swift/agents/build-verifier.md +64 -0
  161. package/presets/cursor/ios-swift/agents/ci-investigator.md +73 -0
  162. package/presets/cursor/ios-swift/agents/code-reviewer.md +75 -0
  163. package/presets/cursor/ios-swift/agents/debugger.md +72 -0
  164. package/presets/cursor/ios-swift/agents/feature-developer.md +35 -0
  165. package/presets/cursor/ios-swift/agents/migration-specialist.md +73 -0
  166. package/presets/cursor/ios-swift/agents/performance-auditor.md +72 -0
  167. package/presets/cursor/ios-swift/agents/qa-tester.md +65 -0
  168. package/presets/cursor/ios-swift/agents/security-reviewer.md +69 -0
  169. package/presets/cursor/ios-swift/agents/solution-architect.md +17 -0
  170. package/presets/cursor/ios-swift/agents/task-analyst.md +25 -0
  171. package/presets/cursor/ios-swift/agents/task-router.md +62 -0
  172. package/presets/cursor/ios-swift/agents/tech-writer.md +63 -0
  173. package/presets/cursor/ios-swift/agents/unit-test-generator.md +54 -0
  174. package/presets/cursor/ios-swift/agents/unit-test-healer.md +53 -0
  175. package/presets/cursor/ios-swift/agents/unit-test-planner.md +64 -0
  176. package/presets/cursor/ios-swift/agents/xcuitest-test-generator.md +47 -0
  177. package/presets/cursor/ios-swift/agents/xcuitest-test-healer.md +47 -0
  178. package/presets/cursor/ios-swift/agents/xcuitest-test-planner.md +67 -0
  179. package/presets/cursor/ios-swift/commands/README.md +49 -1
  180. package/presets/cursor/ios-swift/commands/feature-continue.md +19 -0
  181. package/presets/cursor/ios-swift/commands/feature-start.md +33 -0
  182. package/presets/cursor/ios-swift/commands/task-continue.md +49 -0
  183. package/presets/cursor/ios-swift/commands/task.md +50 -0
  184. package/presets/cursor/ios-swift/commands/technical-retro.md +81 -0
  185. package/presets/cursor/ios-swift/hooks/README.md +8 -0
  186. package/presets/cursor/ios-swift/hooks/chain-team-phases.sh +382 -0
  187. package/presets/cursor/ios-swift/hooks/guard-shell-command.sh +79 -0
  188. package/presets/cursor/ios-swift/hooks.json +17 -0
  189. package/presets/cursor/ios-swift/mcp.json +11 -0
  190. package/presets/cursor/ios-swift/rules/README.md +45 -13
  191. package/presets/cursor/ios-swift/rules/agent-team-intake.mdc +16 -0
  192. package/presets/cursor/ios-swift/rules/agent-team-orchestrator.mdc +85 -0
  193. package/presets/cursor/ios-swift/rules/code-review-mr.mdc +1 -0
  194. package/presets/cursor/ios-swift/rules/feature-delivery-workflow.mdc +1 -1
  195. package/presets/cursor/ios-swift/rules/ios-app-core.mdc +2 -1
  196. package/presets/cursor/ios-swift/rules/module-public-api.mdc +26 -0
  197. package/presets/cursor/ios-swift/rules/navigation-coordinators.mdc +29 -0
  198. package/presets/cursor/ios-swift/rules/networking-services.mdc +2 -2
  199. package/presets/cursor/ios-swift/rules/persistence-data.mdc +31 -0
  200. package/presets/cursor/ios-swift/rules/reference-features.mdc +53 -0
  201. package/presets/cursor/ios-swift/rules/security-ios.mdc +35 -0
  202. package/presets/cursor/ios-swift/rules/technical-retro.mdc +12 -0
  203. package/presets/cursor/ios-swift/rules/tests-ui.mdc +1 -0
  204. package/presets/cursor/ios-swift/rules/xcode-tooling.mdc +20 -0
  205. package/presets/cursor/ios-swift/skills/README.md +13 -0
  206. package/presets/cursor/ios-swift/skills/ci-investigation/SKILL.md +39 -0
  207. package/presets/cursor/ios-swift/skills/code-review/SKILL.md +27 -0
  208. package/presets/cursor/ios-swift/skills/debug-investigation/SKILL.md +30 -0
  209. package/presets/cursor/ios-swift/skills/feature-delivery/SKILL.md +27 -0
  210. package/presets/cursor/ios-swift/skills/technical-retro/SKILL.md +10 -0
  211. package/presets/cursor/ios-swift/skills/unit-testing/SKILL.md +32 -0
  212. package/presets/cursor/ios-swift/skills/xcuitest-e2e/SKILL.md +33 -0
  213. package/presets/cursor/ios-swift/team/README.md +31 -0
  214. package/presets/cursor/ios-swift/team/fixtures/bugfix-standard.json +33 -0
  215. package/presets/cursor/ios-swift/team/fixtures/feature-full.json +48 -0
  216. package/presets/cursor/ios-swift/team/fixtures/feature-light.json +36 -0
  217. package/presets/cursor/next/AGENTS.md +36 -0
  218. package/presets/cursor/next/BUGBOT.md +14 -0
  219. package/presets/cursor/next/MCP.md +16 -0
  220. package/presets/cursor/next/agents/README.md +165 -0
  221. package/presets/cursor/next/agents/accessibility-reviewer.md +67 -0
  222. package/presets/cursor/next/agents/api-contract-reviewer.md +71 -0
  223. package/presets/cursor/next/agents/build-verifier.md +66 -0
  224. package/presets/cursor/next/agents/ci-investigator.md +64 -0
  225. package/presets/cursor/next/agents/code-reviewer.md +64 -0
  226. package/presets/cursor/next/agents/debugger.md +64 -0
  227. package/presets/cursor/next/agents/feature-developer.md +28 -0
  228. package/presets/cursor/next/agents/migration-specialist.md +71 -0
  229. package/presets/cursor/next/agents/performance-auditor.md +70 -0
  230. package/presets/cursor/next/agents/playwright-test-generator.md +27 -0
  231. package/presets/cursor/next/agents/playwright-test-healer.md +27 -0
  232. package/presets/cursor/next/agents/playwright-test-planner.md +28 -0
  233. package/presets/cursor/next/agents/qa-tester.md +58 -0
  234. package/presets/cursor/next/agents/security-reviewer.md +66 -0
  235. package/presets/cursor/next/agents/solution-architect.md +71 -0
  236. package/presets/cursor/next/agents/task-analyst.md +112 -0
  237. package/presets/cursor/next/agents/task-router.md +95 -0
  238. package/presets/cursor/next/agents/tech-writer.md +62 -0
  239. package/presets/cursor/next/agents/unit-test-generator.md +39 -0
  240. package/presets/cursor/next/agents/unit-test-healer.md +40 -0
  241. package/presets/cursor/next/agents/unit-test-planner.md +64 -0
  242. package/presets/cursor/next/commands/README.md +49 -1
  243. package/presets/cursor/next/commands/feature-continue.md +19 -0
  244. package/presets/cursor/next/commands/feature-start.md +33 -0
  245. package/presets/cursor/next/commands/task-continue.md +49 -0
  246. package/presets/cursor/next/commands/task.md +50 -0
  247. package/presets/cursor/next/commands/technical-retro.md +81 -0
  248. package/presets/cursor/next/hooks/README.md +8 -0
  249. package/presets/cursor/next/hooks/chain-team-phases.sh +380 -0
  250. package/presets/cursor/next/hooks/guard-shell-command.sh +77 -0
  251. package/presets/cursor/next/hooks.json +17 -0
  252. package/presets/cursor/next/mcp.json +19 -0
  253. package/presets/cursor/next/rules/README.md +67 -0
  254. package/presets/cursor/next/rules/agent-team-intake.mdc +14 -0
  255. package/presets/cursor/next/rules/agent-team-orchestrator.mdc +147 -0
  256. package/presets/cursor/next/rules/api-services.mdc +12 -10
  257. package/presets/cursor/next/rules/architecture-boundaries-ui.mdc +15 -0
  258. package/presets/cursor/next/rules/architecture-boundaries.mdc +31 -12
  259. package/presets/cursor/next/rules/arrow-functions.mdc +46 -0
  260. package/presets/cursor/next/rules/code-quality-and-refactoring.mdc +5 -4
  261. package/presets/cursor/next/rules/code-review-mr.mdc +21 -40
  262. package/presets/cursor/next/rules/css-property-order-stylelint.mdc +16 -0
  263. package/presets/cursor/next/rules/feature-delivery-workflow.mdc +76 -0
  264. package/presets/cursor/next/rules/http-client.mdc +42 -0
  265. package/presets/cursor/next/rules/layer-barrel-exports.mdc +59 -0
  266. package/presets/cursor/next/rules/navigation-router-stack.mdc +62 -0
  267. package/presets/cursor/next/rules/navigation-router-ui.mdc +16 -0
  268. package/presets/cursor/next/rules/next-app-core.mdc +18 -61
  269. package/presets/cursor/next/rules/next-app-router.mdc +36 -0
  270. package/presets/cursor/next/rules/no-props-spread.mdc +27 -4
  271. package/presets/cursor/next/rules/no-type-assertion-as-import-export.mdc +60 -0
  272. package/presets/cursor/next/rules/package-manager.mdc +16 -0
  273. package/presets/cursor/next/rules/playwright-agents.mdc +2 -1
  274. package/presets/cursor/next/rules/post-change-lint.mdc +40 -0
  275. package/presets/cursor/next/rules/public-imports.mdc +48 -0
  276. package/presets/cursor/next/rules/react-a11y-coding.mdc +37 -0
  277. package/presets/cursor/next/rules/react-ui.mdc +33 -3
  278. package/presets/cursor/next/rules/reference-features.mdc +39 -0
  279. package/presets/cursor/next/rules/store-rtk.mdc +13 -6
  280. package/presets/cursor/next/rules/technical-retro.mdc +12 -0
  281. package/presets/cursor/next/rules/tests-unit.mdc +30 -10
  282. package/presets/cursor/next/rules/types-jsdoc.mdc +42 -0
  283. package/presets/cursor/next/skills/README.md +15 -0
  284. package/presets/cursor/next/skills/ci-investigation/SKILL.md +36 -0
  285. package/presets/cursor/next/skills/code-review/SKILL.md +26 -0
  286. package/presets/cursor/next/skills/debug-investigation/SKILL.md +28 -0
  287. package/presets/cursor/next/skills/feature-delivery/SKILL.md +15 -0
  288. package/presets/cursor/next/skills/playwright-e2e/SKILL.md +31 -0
  289. package/presets/cursor/next/skills/technical-retro/SKILL.md +40 -0
  290. package/presets/cursor/next/skills/unit-testing/SKILL.md +32 -0
  291. package/presets/cursor/next/team/README.md +109 -0
  292. package/presets/cursor/next/team/fixtures/bugfix-standard.json +15 -0
  293. package/presets/cursor/next/team/fixtures/feature-full.json +16 -0
  294. package/presets/cursor/next/team/fixtures/feature-light.json +17 -0
  295. package/presets/cursor/next/team/tasks/.gitkeep +0 -0
@@ -0,0 +1,380 @@
1
+ #!/usr/bin/env bash
2
+ # Chains agent team steps from pipeline.json after subagentStop.
3
+ # Falls back to legacy phase-based flow when pipeline.json is absent.
4
+
5
+ set -euo pipefail
6
+
7
+ input=$(cat)
8
+
9
+ INPUT="$input" node <<'NODE'
10
+ const fs = require('fs');
11
+ const path = require('path');
12
+
13
+ const TEAM_ROOT = path.join(process.cwd(), '.claude', 'team');
14
+
15
+ const inputRaw = process.env.INPUT || '';
16
+ let hookInput;
17
+ try {
18
+ hookInput = JSON.parse(inputRaw);
19
+ } catch {
20
+ process.stdout.write('{}');
21
+ process.exit(0);
22
+ }
23
+
24
+ if (hookInput.status !== 'completed') {
25
+ process.stdout.write('{}');
26
+ process.exit(0);
27
+ }
28
+
29
+ const activePath = path.join(TEAM_ROOT, 'active-task.json');
30
+
31
+ if (!fs.existsSync(activePath)) {
32
+ process.stdout.write('{}');
33
+ process.exit(0);
34
+ }
35
+
36
+ let active;
37
+ try {
38
+ active = JSON.parse(fs.readFileSync(activePath, 'utf8'));
39
+ } catch {
40
+ process.stdout.write('{}');
41
+ process.exit(0);
42
+ }
43
+
44
+ const slug = active.slug;
45
+ if (!slug) {
46
+ process.stdout.write('{}');
47
+ process.exit(0);
48
+ }
49
+
50
+ const taskDir = path.join(TEAM_ROOT, 'tasks', slug);
51
+ const statusPath = path.join(taskDir, 'status.json');
52
+ const pipelinePath = path.join(taskDir, 'pipeline.json');
53
+
54
+ if (!fs.existsSync(statusPath)) {
55
+ process.stdout.write('{}');
56
+ process.exit(0);
57
+ }
58
+
59
+ let status;
60
+ try {
61
+ status = JSON.parse(fs.readFileSync(statusPath, 'utf8'));
62
+ } catch {
63
+ process.stdout.write('{}');
64
+ process.exit(0);
65
+ }
66
+
67
+ const now = new Date().toISOString();
68
+
69
+ function writeStatus(next) {
70
+ status = { ...status, ...next, slug, updatedAt: now };
71
+ fs.writeFileSync(statusPath, JSON.stringify(status, null, 2) + '\n');
72
+ }
73
+
74
+ function out(message) {
75
+ process.stdout.write(JSON.stringify({ followup_message: message }));
76
+ }
77
+
78
+ function readArtifact(name) {
79
+ const p = path.join(taskDir, name);
80
+ if (!fs.existsSync(p)) return '';
81
+ try {
82
+ return fs.readFileSync(p, 'utf8');
83
+ } catch {
84
+ return '';
85
+ }
86
+ }
87
+
88
+ function getStepAgents(step) {
89
+ if (!step) return [];
90
+ return Array.isArray(step.agent) ? step.agent : [step.agent];
91
+ }
92
+
93
+ function skipIfMatches(skipIf, dir) {
94
+ if (!skipIf) return false;
95
+ if (skipIf === 'debugger.fixed') {
96
+ const text = readArtifact('debug-report.md');
97
+ return /fixApplied:\s*true/i.test(text) || /\*\*Fix applied:\*\*\s*true/i.test(text);
98
+ }
99
+ if (skipIf === 'ci-investigator.resolved') {
100
+ const text = readArtifact('ci-report.md');
101
+ return /fixApplied:\s*true/i.test(text) || /## Verdict\s*\nPASS/i.test(text);
102
+ }
103
+ return false;
104
+ }
105
+
106
+ function findNextExecutableStep(steps, startIdx, dir) {
107
+ for (let i = startIdx; i < steps.length; i++) {
108
+ if (!skipIfMatches(steps[i].skipIf, dir)) {
109
+ return { step: steps[i], index: i };
110
+ }
111
+ }
112
+ return null;
113
+ }
114
+
115
+ const AGENT_HANDOFF = {
116
+ 'task-analyst': (s) =>
117
+ `Invoke task-analyst for slug "${s}". Write brief.md and decomposition.md under .claude/team/tasks/${s}/. ` +
118
+ `Set status.json: phase executing, state awaiting_approval if human gate applies. Do not use legacy phase analysis.`,
119
+ debugger: (s) =>
120
+ `Invoke debugger subagent for slug "${s}". Investigate root cause; write debug-report.md with fixApplied: true/false. ` +
121
+ `Update status.json when done.`,
122
+ 'solution-architect': (s) =>
123
+ `Invoke solution-architect for slug "${s}". Read brief.md; write architecture.md. Update status.json when done.`,
124
+ 'migration-specialist': (s) =>
125
+ `Invoke migration-specialist for slug "${s}". Read brief.md; write migration-plan.md. Update status.json when done.`,
126
+ 'api-contract-reviewer': (s) =>
127
+ `Invoke api-contract-reviewer (readonly) for slug "${s}". Write api-contract-review.md. Update status.json when done.`,
128
+ 'ci-investigator': (s) =>
129
+ `Invoke ci-investigator for slug "${s}". Diagnose CI failure; write ci-report.md; apply minimal fix. ` +
130
+ `Use ci-investigation skill. Update status.json when done.`,
131
+ 'feature-developer': (s) =>
132
+ `Invoke feature-developer for slug "${s}". Read brief.md, decomposition.md, validation-report.md, review.md, architecture.md, migration-plan.md, api-contract-review.md, debug-report.md if present. ` +
133
+ `Follow architecture/feature-delivery-workflow.md and architecture/reference-features.md. Include unit tests for mappers/logic before handoff. Update status.json when done.`,
134
+ 'build-verifier': (s) =>
135
+ `Invoke build-verifier (readonly) for slug "${s}". Run lint:js, lint:css, type-check, and targeted unit tests from app/. ` +
136
+ `Write validation-report.md. Set state completed or validation_failed. Do not edit production code.`,
137
+ 'accessibility-reviewer': (s) =>
138
+ `Invoke accessibility-reviewer (readonly) for slug "${s}". Review UI diff; write a11y-review.md. Update status.json when done.`,
139
+ 'performance-auditor': (s) =>
140
+ `Invoke performance-auditor (readonly) for slug "${s}". Write perf-report.md. Update status.json when done.`,
141
+ 'code-reviewer': (s) =>
142
+ `Invoke code-reviewer subagent (readonly) for slug "${s}". Review git diff vs brief.md per tooling-and-review/code-review-mr.md. ` +
143
+ `Update status.json when done.`,
144
+ 'security-reviewer': (s) =>
145
+ `Invoke security-reviewer (readonly) for slug "${s}". Write security-review.md. Update status.json when done.`,
146
+ 'qa-tester': (s, scope) =>
147
+ `Invoke qa-tester for slug "${s}"${scope ? ` (scope: ${scope})` : ''}. ` +
148
+ `Add/update tests per brief. Follow testing/playwright-agents.md. Update status.json when done.`,
149
+ 'unit-test-planner': (s) =>
150
+ `Invoke unit-test-planner for slug "${s}". Write unit-test-plan.md. Use unit-testing skill. Update status.json when done.`,
151
+ 'unit-test-generator': (s) =>
152
+ `Invoke unit-test-generator for slug "${s}". Implement specs from unit-test-plan.md. Use unit-testing skill. Update status.json when done.`,
153
+ 'unit-test-healer': (s) =>
154
+ `Invoke unit-test-healer for slug "${s}". Fix failing unit tests. Use unit-testing and debug-investigation skills. Update status.json when done.`,
155
+ 'playwright-test-planner': (s) =>
156
+ `Invoke playwright-test-planner for slug "${s}". Create/update app/__tests__/e2e/**/*.cases.md. ` +
157
+ `Follow testing/playwright-agents.md and the playwright-e2e skill. Update status.json when done.`,
158
+ 'playwright-test-generator': (s) =>
159
+ `Invoke playwright-test-generator for slug "${s}". Generate/update *.spec.ts from matching *.cases.md. ` +
160
+ `Use playwright MCP when available. Follow testing/playwright-agents.md and the playwright-e2e skill. Update status.json when done.`,
161
+ 'playwright-test-healer': (s) =>
162
+ `Invoke playwright-test-healer for slug "${s}". Fix failing/flaky e2e while preserving cases.md assertions. ` +
163
+ `Use playwright MCP when available. Follow testing/playwright-agents.md and debug-investigation. Update status.json when done.`,
164
+ 'tech-writer': (s) =>
165
+ `Invoke tech-writer for slug "${s}". Write documentation.md from task artifacts. Update status.json when done.`,
166
+ };
167
+
168
+ const REVIEW_AGENTS = new Set([
169
+ 'code-reviewer',
170
+ 'accessibility-reviewer',
171
+ 'security-reviewer',
172
+ 'api-contract-reviewer',
173
+ ]);
174
+
175
+ function handoffForAgent(agent, scope) {
176
+ const fn = AGENT_HANDOFF[agent];
177
+ return fn ? fn(slug, scope) : `Invoke ${agent} subagent for slug "${slug}". Update status.json when done.`;
178
+ }
179
+
180
+ function handoffForParallelStep(step) {
181
+ const agents = getStepAgents(step);
182
+ return (
183
+ `Invoke IN PARALLEL (one message, multiple Task calls): ${agents.join(' AND ')} for slug "${slug}". ` +
184
+ `Each agent writes its artifact and appends itself to status.json parallelCompleted when done.`
185
+ );
186
+ }
187
+
188
+ function hasGateAfter(agent, humanGates) {
189
+ return Array.isArray(humanGates) && humanGates.includes(`after:${agent}`);
190
+ }
191
+
192
+ function hasGateAfterStep(step, humanGates) {
193
+ return getStepAgents(step).some((a) => hasGateAfter(a, humanGates));
194
+ }
195
+
196
+ function legacyFlow() {
197
+ if (status.phase === 'analysis') {
198
+ process.stdout.write('{}');
199
+ process.exit(0);
200
+ }
201
+ if (status.phase === 'development' && (status.state === 'completed' || status.state === 'in_progress')) {
202
+ writeStatus({ phase: 'executing', state: 'in_progress', currentAgent: 'build-verifier' });
203
+ out(handoffForAgent('build-verifier'));
204
+ process.exit(0);
205
+ }
206
+ if (status.currentAgent === 'build-verifier' && status.state === 'completed') {
207
+ writeStatus({ phase: 'executing', state: 'in_progress', currentAgent: 'code-reviewer' });
208
+ out(handoffForAgent('code-reviewer'));
209
+ process.exit(0);
210
+ }
211
+ if (status.phase === 'review' && status.state === 'completed') {
212
+ writeStatus({ phase: 'executing', state: 'in_progress', currentAgent: 'qa-tester' });
213
+ out(handoffForAgent('qa-tester'));
214
+ process.exit(0);
215
+ }
216
+ if (status.state === 'changes_requested' && REVIEW_AGENTS.has(status.currentAgent)) {
217
+ writeStatus({
218
+ currentAgent: 'feature-developer',
219
+ state: 'in_progress',
220
+ phase: 'executing',
221
+ retryAfterFix: status.currentAgent,
222
+ });
223
+ out(
224
+ handoffForAgent('feature-developer') +
225
+ ` After fixes, re-run ${status.currentAgent}.`,
226
+ );
227
+ process.exit(0);
228
+ }
229
+ if (status.state === 'validation_failed' && status.currentAgent === 'build-verifier') {
230
+ writeStatus({
231
+ currentAgent: 'feature-developer',
232
+ state: 'in_progress',
233
+ phase: 'executing',
234
+ retryAfterFix: 'build-verifier',
235
+ });
236
+ out(
237
+ handoffForAgent('feature-developer') +
238
+ ` Read validation-report.md. After fixes, re-run build-verifier.`,
239
+ );
240
+ process.exit(0);
241
+ }
242
+ if (status.state === 'completed' && status.retryAfterFix) {
243
+ const retry = status.retryAfterFix;
244
+ writeStatus({ currentAgent: retry, state: 'in_progress', retryAfterFix: null });
245
+ out(handoffForAgent(retry));
246
+ process.exit(0);
247
+ }
248
+ if (status.phase === 'testing' && status.state === 'completed') {
249
+ writeStatus({ phase: 'done', state: 'completed' });
250
+ out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
251
+ process.exit(0);
252
+ }
253
+ process.stdout.write('{}');
254
+ process.exit(0);
255
+ }
256
+
257
+ if (!fs.existsSync(pipelinePath)) {
258
+ legacyFlow();
259
+ }
260
+
261
+ let pipeline;
262
+ try {
263
+ pipeline = JSON.parse(fs.readFileSync(pipelinePath, 'utf8'));
264
+ } catch {
265
+ legacyFlow();
266
+ }
267
+
268
+ const steps = pipeline.steps || [];
269
+ if (steps.length === 0 || pipeline.autoChain === false) {
270
+ process.stdout.write('{}');
271
+ process.exit(0);
272
+ }
273
+
274
+ if (status.awaitingHumanGate || status.state === 'awaiting_approval') {
275
+ process.stdout.write('{}');
276
+ process.exit(0);
277
+ }
278
+
279
+ if (status.state === 'changes_requested' && REVIEW_AGENTS.has(status.currentAgent)) {
280
+ const reviewer = status.currentAgent;
281
+ writeStatus({
282
+ currentAgent: 'feature-developer',
283
+ state: 'in_progress',
284
+ phase: 'executing',
285
+ retryAfterFix: reviewer,
286
+ });
287
+ out(
288
+ handoffForAgent('feature-developer') +
289
+ ` After fixes, re-run ${reviewer}.`,
290
+ );
291
+ process.exit(0);
292
+ }
293
+
294
+ if (status.state === 'validation_failed' && status.currentAgent === 'build-verifier') {
295
+ writeStatus({
296
+ currentAgent: 'feature-developer',
297
+ state: 'in_progress',
298
+ phase: 'executing',
299
+ retryAfterFix: 'build-verifier',
300
+ });
301
+ out(
302
+ handoffForAgent('feature-developer') +
303
+ ` Read validation-report.md. After fixes, re-run build-verifier.`,
304
+ );
305
+ process.exit(0);
306
+ }
307
+
308
+ if (status.state === 'completed' && status.retryAfterFix) {
309
+ const retry = status.retryAfterFix;
310
+ writeStatus({ currentAgent: retry, state: 'in_progress', retryAfterFix: null });
311
+ out(handoffForAgent(retry));
312
+ process.exit(0);
313
+ }
314
+
315
+ const idx = typeof status.pipelineIndex === 'number' ? status.pipelineIndex : 0;
316
+ const currentStep = steps[idx];
317
+ if (!currentStep) {
318
+ writeStatus({ phase: 'done', state: 'completed', currentAgent: null });
319
+ out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
320
+ process.exit(0);
321
+ }
322
+
323
+ const completedAgent = status.currentAgent || getStepAgents(currentStep)[0];
324
+ const stepAgents = getStepAgents(currentStep);
325
+
326
+ if (currentStep.parallel && stepAgents.length > 1) {
327
+ const done = [...(status.parallelCompleted || [])];
328
+ if (completedAgent && !done.includes(completedAgent)) {
329
+ done.push(completedAgent);
330
+ }
331
+ writeStatus({ parallelCompleted: done });
332
+ const remaining = stepAgents.filter((a) => !done.includes(a));
333
+ if (remaining.length > 0) {
334
+ process.stdout.write('{}');
335
+ process.exit(0);
336
+ }
337
+ writeStatus({ parallelCompleted: [] });
338
+ }
339
+
340
+ if (hasGateAfterStep(currentStep, pipeline.humanGates)) {
341
+ writeStatus({
342
+ awaitingHumanGate: true,
343
+ state: 'awaiting_approval',
344
+ currentAgent: completedAgent,
345
+ });
346
+ process.stdout.write('{}');
347
+ process.exit(0);
348
+ }
349
+
350
+ const next = findNextExecutableStep(steps, idx + 1, taskDir);
351
+ if (!next) {
352
+ writeStatus({
353
+ pipelineIndex: steps.length,
354
+ phase: 'done',
355
+ state: 'completed',
356
+ currentAgent: null,
357
+ awaitingHumanGate: false,
358
+ });
359
+ out(`Pipeline complete for "${slug}". Run /technical-retro ${slug}.`);
360
+ process.exit(0);
361
+ }
362
+
363
+ const { step: nextStep, index: nextIdx } = next;
364
+ const nextAgents = getStepAgents(nextStep);
365
+
366
+ writeStatus({
367
+ pipelineIndex: nextIdx,
368
+ currentAgent: nextAgents[0],
369
+ phase: 'executing',
370
+ state: 'in_progress',
371
+ awaitingHumanGate: false,
372
+ parallelCompleted: [],
373
+ });
374
+
375
+ if (nextStep.parallel && nextAgents.length > 1) {
376
+ out(handoffForParallelStep(nextStep));
377
+ } else {
378
+ out(handoffForAgent(nextAgents[0], nextStep.scope));
379
+ }
380
+ NODE
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env bash
2
+ # Lightweight shell guard for Claude projects using this preset.
3
+
4
+ set -euo pipefail
5
+
6
+ input=$(cat)
7
+
8
+ INPUT="$input" node <<'NODE'
9
+ const fs = require('fs');
10
+
11
+ const raw = process.env.INPUT || '';
12
+ let event;
13
+ try {
14
+ event = JSON.parse(raw);
15
+ } catch {
16
+ process.stdout.write('{ "permission": "allow" }');
17
+ process.exit(0);
18
+ }
19
+
20
+ const command = String(event.command || event.input?.command || '');
21
+ if (!command.trim()) {
22
+ process.stdout.write('{ "permission": "allow" }');
23
+ process.exit(0);
24
+ }
25
+
26
+ function out(permission, userMessage, agentMessage) {
27
+ process.stdout.write(JSON.stringify({
28
+ permission,
29
+ user_message: userMessage,
30
+ agent_message: agentMessage || userMessage,
31
+ }));
32
+ }
33
+
34
+ const dangerousGit = /\bgit\s+(reset\s+--hard|clean\s+-[^\n]*f|push\s+--force|push\s+-f|checkout\s+--\s+)/;
35
+ if (dangerousGit.test(command)) {
36
+ out(
37
+ 'ask',
38
+ 'This command looks destructive for git state. Review it before continuing.',
39
+ 'A project hook flagged a destructive git command. Ask the user before running it.',
40
+ );
41
+ process.exit(0);
42
+ }
43
+
44
+ const managerByFile = [
45
+ ['yarn.lock', 'yarn'],
46
+ ['pnpm-lock.yaml', 'pnpm'],
47
+ ['package-lock.json', 'npm'],
48
+ ].find(([file]) => fs.existsSync(file));
49
+
50
+ let expected = managerByFile?.[1];
51
+ if (!expected && fs.existsSync('package.json')) {
52
+ try {
53
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
54
+ const pm = typeof pkg.packageManager === 'string' ? pkg.packageManager : '';
55
+ expected = pm.split('@')[0] || undefined;
56
+ } catch {
57
+ // Ignore invalid package.json in the hook; the agent can diagnose it later.
58
+ }
59
+ }
60
+
61
+ if (!expected) {
62
+ process.stdout.write('{ "permission": "allow" }');
63
+ process.exit(0);
64
+ }
65
+
66
+ const used = command.match(/(^|[;&|]\s*)(npm|yarn|pnpm)\s+/)?.[2];
67
+ if (used && used !== expected) {
68
+ out(
69
+ 'ask',
70
+ `This repository appears to use ${expected}, but the command uses ${used}. Confirm before continuing.`,
71
+ `Use ${expected} for package scripts and installs unless the user explicitly approves ${used}.`,
72
+ );
73
+ process.exit(0);
74
+ }
75
+
76
+ process.stdout.write('{ "permission": "allow" }');
77
+ NODE
@@ -0,0 +1,20 @@
1
+ {
2
+ "mcpServers": {
3
+ "context7": {
4
+ "command": "npx",
5
+ "args": ["-y", "@upstash/context7-mcp"]
6
+ },
7
+ "playwright-test": {
8
+ "command": "npx",
9
+ "args": ["-y", "@playwright/mcp@latest"]
10
+ },
11
+ "chrome-devtools": {
12
+ "command": "npx",
13
+ "args": ["-y", "chrome-devtools-mcp@latest"]
14
+ },
15
+ "figma": {
16
+ "type": "http",
17
+ "url": "https://mcp.figma.com/mcp"
18
+ }
19
+ }
20
+ }
@@ -1,16 +1,47 @@
1
1
  # `.claude/rules` (preset next)
2
2
 
3
- В Claude Code все `.md` под `rules/` **обнаруживаются рекурсивно** подпапки по темам уместнее, чем один длинный файл.
3
+ В Claude Code все `.md` под `rules/` **обнаруживаются рекурсивно**. Правила без YAML frontmatter загружаются **в начале сессии**; с `paths:` — **только при работе** с matching-файлами.
4
4
 
5
- Соответствие темам из пресета Cursor (для переноса смысла из `.mdc`):
5
+ ## Loading strategy
6
6
 
7
- | Папка | О чём |
8
- |-------|--------|
9
- | `stack/` | Next.js, React, TypeScript |
10
- | `architecture/` | границы слоёв, модули |
11
- | `api-and-data/` | сервисы, API, данные |
12
- | `testing/` | unit, e2e, Playwright |
13
- | `ui-and-accessibility/` | UI, a11y, без spread props там, где это правило команды |
14
- | `tooling-and-review/` | качество кода, ревью MR |
7
+ - **Session start (no `paths:`):** ровно **3** — `next-app-core`, `package-manager`, `code-quality`
8
+ - **On-demand (`paths:` or via commands):** `post-change-lint` (**обязателен после правок кода**), `agent-team-intake`, `agent-team-orchestrator`, `code-review-mr`, architecture, imports, UI, tests, feature-delivery-workflow, reference-features, next-app-router, react-a11y-coding
9
+ - **Skills:** long workflows (`feature-delivery`, `code-review`, …)
15
10
 
16
- Добавляйте сюда `.md` файлы с осмысленными именами (`testing.md`, `api-design.md`, …).
11
+ ### UI edit bundle (consolidated paths)
12
+
13
+ При правке `app/src/ui/**/*.tsx` подгружается **уменьшенный** набор:
14
+
15
+ | Rule | Назначение |
16
+ |------|------------|
17
+ | `ui-and-accessibility/react-ui.md` | Структура, стили, пропсы |
18
+ | `architecture/architecture-boundaries-ui.md` | Slim границы UI-слоя |
19
+ | `ui-and-accessibility/react-a11y-coding.md` | A11y |
20
+ | `stack/navigation-router-ui.md` | Краткий ориентир навигации |
21
+
22
+ **Не грузятся на типичный UI edit:** `architecture/architecture-boundaries.md` (api/store/types/lib), `architecture/layer-barrel-exports.md` (только `index.ts`), `stack/navigation-router.md` (только `app/src/app/**`). Стили колокации — в `react-ui.md` (не отдельный stub).
23
+
24
+ ## С чего начать
25
+
26
+ - **`commands/task.md`** — router → `pipeline.json` → agents
27
+ - **`architecture/reference-features.md`** — заполнить TBD после init
28
+ - **`architecture/feature-delivery-workflow.md`** — порядок слоёв
29
+
30
+ ## Каталог (новые и ключевые)
31
+
32
+ | Файл | Назначение |
33
+ |------|------------|
34
+ | `architecture/reference-features.md` | Эталонные пути UI/store/API |
35
+ | `stack/next-app-router.md` | App Router, RSC |
36
+ | `ui-and-accessibility/react-a11y-coding.md` | A11y при кодинге UI |
37
+ | `architecture/feature-delivery-workflow.md` | Сквозной чеклист (paths) |
38
+ | `architecture/architecture-boundaries-ui.md` | Slim границы UI при правках компонентов |
39
+ | `architecture/architecture-boundaries.md` | Полная карта UI / store / API |
40
+ | `stack/navigation-router-ui.md` | Навигация в UI-компонентах (slim) |
41
+ | `stack/navigation-router.md` | Полный аудит стека навигации |
42
+ | `tooling-and-review/agent-team-orchestrator.md` | Pipeline, build-verifier, parallel |
43
+ | `agents/build-verifier.md` | Validation gate agent |
44
+
45
+ Полный список — см. подпапки `architecture/`, `stack/`, `api-and-data/`, `ui-and-accessibility/`, `testing/`, `tooling-and-review/`.
46
+
47
+ **Коллизии:** импорт типов и API — **`architecture/public-imports.md`**.
@@ -1,3 +1,9 @@
1
1
  # API and data
2
2
 
3
- Конвенции сервисов, API-слоя и работы с данными.
3
+ HTTP-транспорт, сервисы, Redux store.
4
+
5
+ | Файл | Содержание | `paths:` |
6
+ |------|------------|----------|
7
+ | `http-client.md` | Единый HTTP-клиент, ошибки, связь со store | `app/src/lib/clients/**`, `app/src/api/clients/**` |
8
+ | `api-services.md` | Сервисы, мапперы, DTO → домен | `app/src/api/services/**` |
9
+ | `store-rtk.md` | Redux Toolkit, thunk'и, типизация | `app/src/store/**` |
@@ -0,0 +1,57 @@
1
+ ---
2
+ paths:
3
+ - app/src/api/services/**/*.ts
4
+ ---
5
+
6
+ # Роль API слоя
7
+
8
+ - Инкапсулировать всё, что связано с:
9
+ - HTTP‑запросами через **экземпляры прикладных API‑клиентов** в `app/src/api/clients/**`, собранные на **общей реализации** из `app/src/lib/clients/**` (как в существующем коде); подробности — **`api-and-data/http-client.md`**; положение слоя в схеме **порты и адаптеры** — `architecture/architecture-boundaries.md`;
10
+ - URL/путями,
11
+ - заголовками и кодами ответов,
12
+ - DTO backend.
13
+ - Предоставлять UI и store **стабильный доменный интерфейс**:
14
+ - функции, работающие с доменными типами из `@/types` (`architecture/public-imports.md`).
15
+ - мапперы между DTO и доменными типами.
16
+
17
+ # Структура модулей
18
+
19
+ - Для каждой доменной области (например, заказы, биллинг, настройки аккаунта):
20
+ - отдельный каталог в `app/src/api/services/<ИмяСервиса или фичи>/**` по конвенции репозитория.
21
+ - Внутри модуля:
22
+ - файлы с вызовами API (`index.ts` или `*.service.ts`);
23
+ - файлы мапперов (`*responseMappers.ts`);
24
+ - специфичные типы запросов/ответов (если не вынесены в `app/src/types/**` с экспортом через barrel `@/types`).
25
+ - при необходимости — локальные `index.ts` / barrel внутри модуля для структуры **внутри** `app/src/api/**`; **снаружи** этого слоя UI, store и остальной код импортируют только из корневого barrel `app/src/api/index.ts` (`import … from '@/api'`, **`architecture/public-imports.md`**).
26
+
27
+ # Мапперы и типы
28
+
29
+ - Для каждого запроса/эндпоинта:
30
+ - описывать **response‑тип (DTO)**, точно соответствующий контракту backend;
31
+ - определять **целевой доменный тип** в `app/src/types/**`, с которым будет работать приложение (включая вычисляемые/агрегированные поля).
32
+ - Мапперы (например, `*responseMappers.ts`):
33
+ - чистые функции, без сайд‑эффектов;
34
+ - выполняют все необходимые вычисления и преобразования данных (булевы флаги, склейка строк, агрегаты и т.п.) при переводе из DTO в доменные модели;
35
+ - при необходимости обеспечивают обратное преобразование (доменные модели → транспортные типы).
36
+ - UI и store работают только с доменными типами (из `@/types` или экспортируемыми из public API слоя API), а не с «сырыми» DTO.
37
+ - **Не вызывать `fetch` напрямую** в теле API‑методов: только через клиент; исключения — узкие модули (например JSON‑RPC), если так уже устроено в репозитории.
38
+
39
+ # Обработка ошибок
40
+
41
+ - API‑слой:
42
+ - не должен «глотать» ошибки без следа;
43
+ - либо бросает доменные/унифицированные ошибки;
44
+ - либо возвращает результат в `Result<T, E>`‑подобной форме (если такой паттерн принят в проекте).
45
+ - Интеграция с APM/трассировкой (если есть в проекте):
46
+ - централизованно (HTTP‑клиент, обёртки), а не в каждом методе сервиса.
47
+
48
+ # Требование к агенту
49
+
50
+ При добавлении/изменении API‑метода:
51
+
52
+ - Следовать существующим сервисам и мапперам как эталону.
53
+ - Пройти чеклист barrel-экспортов (**`architecture/layer-barrel-exports.md`**): локальный `index.ts` → фасад слоя → корневой barrel.
54
+ - Не смешивать слой API и UI/store:
55
+ - компоненты не должны зависеть от DTO;
56
+ - store не должен сам собирать URL/коды эндпоинтов и не обходить сервисы; **транспортный тип ответа** и **контракт ошибки** из `@/types` (как у прикладного клиента) допустимы во thunk при разборе `catch`/payload, если так выстроен сервис (см. `api-and-data/store-rtk.md`, `api-and-data/http-client.md`).
57
+ - При использовании API‑сервисов в UI, store и утилитах **вне** `app/src/api/**` импортировать **только** из `@/api` (корневой barrel), см. **`architecture/public-imports.md`**; внутри слоя API — по относительным путям или `@/api/services/**` / `@/api/clients/**`, не дублируя публичный контракт мимо корневого barrel для внешних потребителей.
@@ -0,0 +1,40 @@
1
+ ---
2
+ paths:
3
+ - app/src/lib/clients/**/*.ts
4
+ - app/src/api/clients/**/*.ts
5
+ ---
6
+
7
+ # HTTP-транспорт
8
+
9
+ **Имена** фабрик, классов ошибок, типов ответа и конфига — **как в текущем коде репозитория** и в barrel `app/src/types/index.ts`. Ниже — **архитектурные правила**, а не спецификация переименований.
10
+
11
+ ## Роль слоя
12
+
13
+ - Обычные REST‑вызовы к backend идут через **одну реализацию** в `app/src/lib/clients/**` (модуль общего клиента) и **преднастроенные экземпляры** в `app/src/api/clients/**`, по тому же паттерну, что уже принят в проекте.
14
+ - Место транспорта в общей картине **порты и адаптеры** — в `architecture/architecture-boundaries.md` (раздел **«Порты и адаптеры»**).
15
+ - **Не** вызывать `fetch` напрямую из `app/src/api/services/**`, store и UI (см. `architecture/architecture-boundaries.md`, `api-and-data/api-services.md`); из store/UI — только вызовы через сервисы из `@/api` (`architecture/public-imports.md`).
16
+ - **Исключения** (узкие протоколы, отдельный транспорт) — только там, где в репозитории уже есть образец; повторять его, не плодить произвольные обходы общего клиента.
17
+
18
+ ## Типы
19
+
20
+ - Всё, что относится к **контракту запроса/ответа/ошибки** приложения и реэкспортируется для HTTP‑слоя, импортировать **только** из barrel `@/types`, без deep‑импортов из внутренних файлов `app/src/types/**` (см. `architecture/public-imports.md`).
21
+ - Не поднимать в новом коде **типы и зависимости от внешнего HTTP‑клиента**, от которого проект ушёл; ориентир — **`package.json`** и существующие вызовы.
22
+
23
+ ## Контракт ошибок
24
+
25
+ - Ошибки сети и HTTP должны приходить в **едином виде**, который задаёт общий клиент (обычно класс/обёртка с полем вроде `response` для тела и статуса).
26
+ - В **`catch`** ориентироваться на **фактическую форму** ошибки в этом репозитории (как в соседних слайсах/сервисах): доступ к телу ошибки, статусу, диагностическому коду — **по полям текущей реализации**, без выдумывания второго формата.
27
+
28
+ ## Поведение, которое остаётся в клиенте
29
+
30
+ - Общие заголовки, `credentials`, загрузка файлов (**FormData** / снятие лишних заголовков), бинарные ответы (**blob** и аналоги), единообразный разбор JSON и прочих тел.
31
+ - Перехват **401 / refresh**, обработка **404** и т.п. — **централизованно**, если так уже сделано в клиенте; не дублировать ту же логику в каждом сервисе.
32
+
33
+ ## Связь со store
34
+
35
+ - Thunk может возвращать **тип обёртки успешного ответа**, если сервис так устроен; в **state** по возможности класть **доменные** типы после маппинга. Подробнее — `api-and-data/store-rtk.md`.
36
+
37
+ ## Требование к агенту
38
+
39
+ - Меняя реализацию общего клиента — **обновить или добавить behavior‑тесты** рядом с модулем клиента (`testing/tests-unit.md`).
40
+ - Не вводить **второй полноценный HTTP‑стек** без явной задачи и согласования с архитектурой репозитория.