gennady 0.6.0 → 0.7.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 (319) hide show
  1. package/README.md +2 -15
  2. package/ai/agents/agent-resolve-conflicts.xml +6 -0
  3. package/ai/agents/agent-review-verifier.xml +6 -0
  4. package/ai/directives/architecture/README.md +21 -0
  5. package/ai/directives/coding/README.md +23 -0
  6. package/ai/directives/coding/result-conventions.xml +55 -0
  7. package/ai/directives/coding/svelte5-runes.xml +248 -0
  8. package/ai/directives/coding/sveltekit-rules.xml +247 -0
  9. package/ai/directives/coding/typescript-rules.xml +589 -0
  10. package/ai/directives/coding/uikit-component-storybook.xml +347 -0
  11. package/ai/directives/coding/uikit-component-svelte.xml +344 -0
  12. package/ai/directives/coding/uikit-spec-drafting.xml +243 -0
  13. package/ai/directives/dbc-audit.directive.xml +131 -0
  14. package/ai/directives/dev-review.directive.xml +148 -0
  15. package/ai/directives/infra/README.md +11 -0
  16. package/ai/directives/infra/eslint-setup.xml +467 -0
  17. package/ai/directives/infra/git-setup.xml +261 -0
  18. package/ai/directives/infra/nodejs-npm-setup.xml +354 -0
  19. package/ai/directives/infra/storybook-setup.xml +153 -0
  20. package/ai/directives/knowledge.xml +206 -0
  21. package/ai/directives/perf-auditor/perf-auditor.directive.xml +75 -0
  22. package/ai/directives/perf-auditor/rules/async-latency.xml +101 -0
  23. package/ai/directives/perf-auditor/rules/data-structures.xml +103 -0
  24. package/ai/directives/perf-auditor/rules/iteration-fusion.xml +96 -0
  25. package/ai/directives/perf-auditor/rules/memory-gc.xml +102 -0
  26. package/ai/directives/sdd/README.md +49 -0
  27. package/ai/directives/sdd/audit.directive.xml +543 -0
  28. package/ai/directives/sdd/discovery.directive.xml +824 -0
  29. package/ai/directives/sdd/fix.directive.xml +249 -0
  30. package/ai/directives/sdd/module-decomposition.directive.xml +666 -0
  31. package/ai/directives/sdd/phase-execution-protocol.xml +339 -0
  32. package/ai/directives/sdd/scaffold.directive.xml +717 -0
  33. package/ai/directives/sdd/setup.directive.xml +213 -0
  34. package/ai/directives/sdd/svelte-ui-discovery.directive.xml +263 -0
  35. package/ai/directives/semantic-change-extractor.directive.xml +99 -0
  36. package/ai/directives/testing/README.md +25 -0
  37. package/ai/directives/testing/common.xml +234 -0
  38. package/ai/directives/testing/node-test.xml +288 -0
  39. package/ai/directives/testing/playwright-cli.xml +199 -0
  40. package/ai/directives/testing/playwright-e2e.xml +292 -0
  41. package/ai/directives/testing/storybook-usage.xml +173 -0
  42. package/ai/directives/testing/svelte-testing.xml +237 -0
  43. package/ai/directives/testing/vitest-rules.xml +326 -0
  44. package/ai/docs/README.md +17 -0
  45. package/ai/docs/ai-icl.md +538 -0
  46. package/ai/docs/ai-priming.md +548 -0
  47. package/ai/docs/ai-prompt-formats.md +406 -0
  48. package/ai/docs/ai-promting.md +572 -0
  49. package/ai/drafts/DRAFT.md +120 -0
  50. package/ai/drafts/agent-devgen-class-from-description.rules.xml +123 -0
  51. package/ai/drafts/agent-typescript-devgen.v1.xml +303 -0
  52. package/ai/drafts/d.md +65 -0
  53. package/ai/drafts/music-posts.md +105 -0
  54. package/ai/fw/v1/architecture/blueprint-factory.xml +77 -0
  55. package/ai/fw/v1/core/mental-model.xml +50 -0
  56. package/ai/fw/v1/discovery/intent-reactor.xml +92 -0
  57. package/ai/fw/v1/production/swarm-protocol.xml +122 -0
  58. package/ai/fw/v1/review/quality-pipeline.xml +102 -0
  59. package/ai/fw/v2/arch-universal.xml +73 -0
  60. package/ai/fw-draft/README.md +79 -0
  61. package/ai/fw-draft/bin/discovery.sh +116 -0
  62. package/ai/fw-draft/gennady.xml +58 -0
  63. package/ai/fw-draft/provider/claude.xml +16 -0
  64. package/ai/fw-draft/provider/cursor.xml +23 -0
  65. package/ai/fw-draft/provider/default.xml +12 -0
  66. package/ai/fw-draft/roles/developer.xml +18 -0
  67. package/ai/fw-draft/router.xml +39 -0
  68. package/ai/fw-draft/routes/development.xml +32 -0
  69. package/ai/fw-draft/routes/universal.xml +58 -0
  70. package/ai/fw-draft/rules/dev/base/file-structure-rules.xml +89 -0
  71. package/ai/fw-draft/rules/dev/typescript/contacts.xml +194 -0
  72. package/dist/ai/agents/agent-resolve-conflicts.xml +6 -0
  73. package/dist/ai/agents/agent-review-verifier.xml +6 -0
  74. package/dist/ai/directives/architecture/README.md +21 -0
  75. package/dist/ai/directives/coding/README.md +23 -0
  76. package/dist/ai/directives/coding/result-conventions.xml +55 -0
  77. package/dist/ai/directives/coding/svelte5-runes.xml +248 -0
  78. package/dist/ai/directives/coding/sveltekit-rules.xml +247 -0
  79. package/dist/ai/directives/coding/typescript-rules.xml +589 -0
  80. package/dist/ai/directives/coding/uikit-component-storybook.xml +347 -0
  81. package/dist/ai/directives/coding/uikit-component-svelte.xml +344 -0
  82. package/dist/ai/directives/coding/uikit-spec-drafting.xml +243 -0
  83. package/dist/ai/directives/dbc-audit.directive.xml +131 -0
  84. package/dist/ai/directives/dev-review.directive.xml +148 -0
  85. package/dist/ai/directives/infra/README.md +11 -0
  86. package/dist/ai/directives/infra/eslint-setup.xml +467 -0
  87. package/dist/ai/directives/infra/git-setup.xml +261 -0
  88. package/dist/ai/directives/infra/nodejs-npm-setup.xml +354 -0
  89. package/dist/ai/directives/infra/storybook-setup.xml +153 -0
  90. package/dist/ai/directives/knowledge.xml +206 -0
  91. package/dist/ai/directives/perf-auditor/perf-auditor.directive.xml +75 -0
  92. package/dist/ai/directives/perf-auditor/rules/async-latency.xml +101 -0
  93. package/dist/ai/directives/perf-auditor/rules/data-structures.xml +103 -0
  94. package/dist/ai/directives/perf-auditor/rules/iteration-fusion.xml +96 -0
  95. package/dist/ai/directives/perf-auditor/rules/memory-gc.xml +102 -0
  96. package/dist/ai/directives/sdd/README.md +49 -0
  97. package/dist/ai/directives/sdd/audit.directive.xml +543 -0
  98. package/dist/ai/directives/sdd/discovery.directive.xml +824 -0
  99. package/dist/ai/directives/sdd/fix.directive.xml +249 -0
  100. package/dist/ai/directives/sdd/module-decomposition.directive.xml +666 -0
  101. package/dist/ai/directives/sdd/phase-execution-protocol.xml +339 -0
  102. package/dist/ai/directives/sdd/scaffold.directive.xml +717 -0
  103. package/dist/ai/directives/sdd/setup.directive.xml +213 -0
  104. package/dist/ai/directives/sdd/svelte-ui-discovery.directive.xml +263 -0
  105. package/dist/ai/directives/semantic-change-extractor.directive.xml +99 -0
  106. package/dist/ai/directives/testing/README.md +25 -0
  107. package/dist/ai/directives/testing/common.xml +234 -0
  108. package/dist/ai/directives/testing/node-test.xml +288 -0
  109. package/dist/ai/directives/testing/playwright-cli.xml +199 -0
  110. package/dist/ai/directives/testing/playwright-e2e.xml +292 -0
  111. package/dist/ai/directives/testing/storybook-usage.xml +173 -0
  112. package/dist/ai/directives/testing/svelte-testing.xml +237 -0
  113. package/dist/ai/directives/testing/vitest-rules.xml +326 -0
  114. package/dist/ai/docs/README.md +17 -0
  115. package/dist/ai/docs/ai-icl.md +538 -0
  116. package/dist/ai/docs/ai-priming.md +548 -0
  117. package/dist/ai/docs/ai-prompt-formats.md +406 -0
  118. package/dist/ai/docs/ai-promting.md +572 -0
  119. package/dist/ai/drafts/DRAFT.md +120 -0
  120. package/dist/ai/drafts/agent-devgen-class-from-description.rules.xml +123 -0
  121. package/dist/ai/drafts/agent-typescript-devgen.v1.xml +303 -0
  122. package/dist/ai/drafts/d.md +65 -0
  123. package/dist/ai/drafts/music-posts.md +105 -0
  124. package/dist/ai/fw/v1/architecture/blueprint-factory.xml +77 -0
  125. package/dist/ai/fw/v1/core/mental-model.xml +50 -0
  126. package/dist/ai/fw/v1/discovery/intent-reactor.xml +92 -0
  127. package/dist/ai/fw/v1/production/swarm-protocol.xml +122 -0
  128. package/dist/ai/fw/v1/review/quality-pipeline.xml +102 -0
  129. package/dist/ai/fw/v2/arch-universal.xml +73 -0
  130. package/dist/ai/fw-draft/README.md +79 -0
  131. package/dist/ai/fw-draft/bin/discovery.sh +116 -0
  132. package/dist/ai/fw-draft/gennady.xml +58 -0
  133. package/dist/ai/fw-draft/provider/claude.xml +16 -0
  134. package/dist/ai/fw-draft/provider/cursor.xml +23 -0
  135. package/dist/ai/fw-draft/provider/default.xml +12 -0
  136. package/dist/ai/fw-draft/roles/developer.xml +18 -0
  137. package/dist/ai/fw-draft/router.xml +39 -0
  138. package/dist/ai/fw-draft/routes/development.xml +32 -0
  139. package/dist/ai/fw-draft/routes/universal.xml +58 -0
  140. package/dist/ai/fw-draft/rules/dev/base/file-structure-rules.xml +89 -0
  141. package/dist/ai/fw-draft/rules/dev/typescript/contacts.xml +194 -0
  142. package/dist/chunks/devtools-B-7ugZhF.js +79 -0
  143. package/dist/chunks/{help.cmd-CWasx25o.js → help.cmd-B_G7EWzF.js} +9 -2
  144. package/dist/chunks/{index-B63fYXL2.js → index-BeL1Zcbg.js} +1 -1
  145. package/dist/chunks/index-CVR66voe.js +26963 -0
  146. package/dist/chunks/index-CXuhZzS3.js +16979 -0
  147. package/dist/chunks/{index-B5bA2T7A.js → index-CaahtXiM.js} +33 -9
  148. package/dist/chunks/{index-iqg0w_pE.js → index-CiEM-8nJ.js} +35 -19
  149. package/dist/chunks/{index-B4m0-PAT.js → index-D1qsi0Uc.js} +57 -33
  150. package/dist/chunks/index-D9ceRUyB.js +443 -0
  151. package/dist/chunks/index-DJpVmyp2.js +176 -0
  152. package/dist/chunks/{index-C0andxna.js → index-DU6jD7SS.js} +1 -1
  153. package/dist/chunks/index-KxSZKmZn.js +540 -0
  154. package/dist/chunks/{index-Dqe1TdW4.js → index-UbHoePfr.js} +12 -12
  155. package/dist/chunks/{index-5xIgwwKx.js → index-g1LXlp77.js} +2 -2
  156. package/dist/chunks/index-zBnnuvLA.js +3788 -0
  157. package/dist/chunks/{run-review-command.logic-a_M3CkeZ.js → run-review-command.logic-DpkRoEi8.js} +2 -2
  158. package/dist/chunks/services-CaLOhuLV.js +2889 -0
  159. package/dist/chunks/shared-Bjy30TeM.js +665 -0
  160. package/dist/cli/cmd/_shared/prompt/io/load-agent-template.io.d.ts +3 -3
  161. package/dist/cli/cmd/_shared/prompt/logic/build-ai-first-knowledge-block.logic.d.ts +3 -3
  162. package/dist/cli/cmd/_shared/prompt/logic/build-ai-verify-placeholders.logic.d.ts +7 -4
  163. package/dist/cli/cmd/_shared/prompt/logic/verify-commands/resolve-verify-commands.logic.d.ts +5 -0
  164. package/dist/cli/cmd/_shared/update-check-worker.d.ts +1 -0
  165. package/dist/cli/cmd/_shared/update-check.d.ts +38 -0
  166. package/dist/cli/cmd/agent-mon/cmd/create-providers.d.ts +15 -0
  167. package/dist/cli/cmd/agent-mon/cmd/index.d.ts +1 -0
  168. package/dist/cli/cmd/agent-mon/cmd/run.d.ts +12 -0
  169. package/dist/cli/cmd/agent-mon/state/create-state-manager.d.ts +32 -0
  170. package/dist/cli/cmd/agent-mon/state/group-by-provider.d.ts +14 -0
  171. package/dist/cli/cmd/agent-mon/state/index.d.ts +5 -0
  172. package/dist/cli/cmd/agent-mon/state/is-waiting.d.ts +9 -0
  173. package/dist/cli/cmd/agent-mon/state/view-model.type.d.ts +74 -0
  174. package/dist/cli/cmd/agent-mon/ui/app.d.ts +16 -0
  175. package/dist/cli/cmd/agent-mon/ui/column-view.d.ts +14 -0
  176. package/dist/cli/cmd/agent-mon/ui/index.d.ts +10 -0
  177. package/dist/cli/cmd/agent-mon/ui/provider-column.d.ts +14 -0
  178. package/dist/cli/cmd/agent-mon/ui/session-card.d.ts +12 -0
  179. package/dist/cli/cmd/agent-mon/ui/status-badge.d.ts +10 -0
  180. package/dist/cli/cmd/alt-opinion/alt-opinion-parser.d.ts +18 -0
  181. package/dist/cli/cmd/alt-opinion/alt-opinion-runner.d.ts +32 -0
  182. package/dist/cli/cmd/alt-opinion/alt-opinion.cmd.d.ts +34 -0
  183. package/dist/cli/cmd/alt-opinion/alt-opinion.types.d.ts +88 -0
  184. package/dist/cli/cmd/alt-opinion/index.d.ts +1 -0
  185. package/dist/cli/cmd/cat/cat-url.fn.d.ts +19 -0
  186. package/dist/cli/cmd/lint/checks/anchor.check.d.ts +11 -0
  187. package/dist/cli/cmd/lint/checks/dbc-contract.check.d.ts +16 -0
  188. package/dist/cli/cmd/lint/checks/disables.check.d.ts +12 -0
  189. package/dist/cli/cmd/lint/checks/file-header.check.d.ts +10 -0
  190. package/dist/cli/cmd/lint/checks/language.check.d.ts +11 -0
  191. package/dist/cli/cmd/lint/index.d.ts +1 -0
  192. package/dist/cli/cmd/lint/lint.cmd.d.ts +18 -0
  193. package/dist/cli/cmd/lint/lint.types.d.ts +72 -0
  194. package/dist/cli/cmd/lint/utils/resolve-references.fn.d.ts +32 -0
  195. package/dist/cli/cmd/remote-console/index.d.ts +2 -0
  196. package/dist/cli/cmd/remote-console/remote-console.cmd.d.ts +55 -0
  197. package/dist/cli/cmd/resolve-conflicts/_core/io/resolve-conflicts-template-load.io.d.ts +2 -2
  198. package/dist/cli/cmd/resolve-conflicts/_core/logic/resolve-conflicts-command-args-parse.logic.d.ts +3 -3
  199. package/dist/cli/cmd/resolve-conflicts/_core/logic/resolve-conflicts-command-run.logic.d.ts +3 -3
  200. package/dist/cli/cmd/resolve-conflicts/_core/logic/resolve-conflicts-context-git-build.logic.d.ts +4 -4
  201. package/dist/cli/cmd/resolve-conflicts/_core/types/resolve-conflicts-artifact.type.d.ts +3 -1
  202. package/dist/cli/cmd/resolve-conflicts/_core/types/resolve-conflicts-command-args.type.d.ts +3 -1
  203. package/dist/cli/cmd/resolve-conflicts/_core/types/resolve-conflicts-command-result.type.d.ts +5 -1
  204. package/dist/cli/cmd/resolve-conflicts/_core/types/resolve-conflicts-context-git.type.d.ts +18 -2
  205. package/dist/cli/cmd/resolve-conflicts/_core/xml/resolve-conflicts-artifact-build.xml.d.ts +6 -6
  206. package/dist/cli/cmd/resolve-conflicts/_core/xml/resolve-conflicts-render.xml.d.ts +4 -4
  207. package/dist/cli/cmd/review/_core/io/load-review-verify-template.io.d.ts +2 -2
  208. package/dist/cli/cmd/review/_core/logic/build-review-context-git.logic.d.ts +3 -3
  209. package/dist/cli/cmd/review/_core/logic/build-review-context-vcs.logic.d.ts +2 -2
  210. package/dist/cli/cmd/review/_core/logic/load-review-context-mr.logic.d.ts +5 -5
  211. package/dist/cli/cmd/review/_core/logic/parse-review-command-args.logic.d.ts +3 -3
  212. package/dist/cli/cmd/review/_core/logic/resolve-review-intent.logic.d.ts +3 -3
  213. package/dist/cli/cmd/review/_core/logic/run-review-command.logic.d.ts +3 -3
  214. package/dist/cli/cmd/review/_core/types/review-artifact.type.d.ts +4 -1
  215. package/dist/cli/cmd/review/_core/types/review-command-args.type.d.ts +7 -1
  216. package/dist/cli/cmd/review/_core/types/review-command-mode.type.d.ts +1 -1
  217. package/dist/cli/cmd/review/_core/types/review-command-options.type.d.ts +3 -1
  218. package/dist/cli/cmd/review/_core/types/review-command-result.type.d.ts +5 -1
  219. package/dist/cli/cmd/review/_core/types/review-context-git.type.d.ts +3 -1
  220. package/dist/cli/cmd/review/_core/types/review-context-mr.type.d.ts +22 -3
  221. package/dist/cli/cmd/review/_core/types/review-context-vcs.type.d.ts +4 -1
  222. package/dist/cli/cmd/review/_core/types/review-intent.type.d.ts +1 -1
  223. package/dist/cli/cmd/review/_core/xml/build-review-artifact.xml.d.ts +10 -10
  224. package/dist/cli/cmd/review/_core/xml/render-review-issues.xml.d.ts +3 -3
  225. package/dist/cli/cmd/review/_core/xml/render-review-verify.xml.d.ts +4 -4
  226. package/dist/cli/cmd/sync/index.d.ts +1 -0
  227. package/dist/cli/cmd/sync/sync-core.d.ts +65 -0
  228. package/dist/cli/cmd/sync/sync-formatter.d.ts +12 -0
  229. package/dist/cli/cmd/sync/sync.cmd.d.ts +33 -0
  230. package/dist/cli/cmd/sync/sync.types.d.ts +50 -0
  231. package/dist/cli/cmd/vcs-reply/vcs-reply.cmd.d.ts +4 -4
  232. package/dist/cli/utils/ai-legacy/ai-legacy-agent.d.ts +12 -11
  233. package/dist/cli/utils/ai-legacy/ai-legacy-core.d.ts +33 -17
  234. package/dist/cli/utils/ai-legacy/ai-legacy-model.d.ts +42 -23
  235. package/dist/cli/utils/cat-gen/cat-gen.d.ts +19 -8
  236. package/dist/cli/utils/commit-gen/commit-gen.d.ts +39 -15
  237. package/dist/cli/utils/prompts/index.d.ts +6 -6
  238. package/dist/cli/utils/review-gen/review-gen.d.ts +33 -9
  239. package/dist/gennady.js +30 -10
  240. package/dist/index.d.ts +1 -0
  241. package/dist/index.js +44 -23
  242. package/dist/services/agent-mon/diff/diff.d.ts +9 -0
  243. package/dist/services/agent-mon/diff/index.d.ts +1 -0
  244. package/dist/services/agent-mon/index.d.ts +10 -0
  245. package/dist/services/agent-mon/model/agent-provider.type.d.ts +20 -0
  246. package/dist/services/agent-mon/model/agent-session.type.d.ts +49 -0
  247. package/dist/services/agent-mon/model/errors.d.ts +20 -0
  248. package/dist/services/agent-mon/model/index.d.ts +7 -0
  249. package/dist/services/agent-mon/model/observe-opts.type.d.ts +7 -0
  250. package/dist/services/agent-mon/model/scan-opts.type.d.ts +7 -0
  251. package/dist/services/agent-mon/model/session-changes.type.d.ts +10 -0
  252. package/dist/services/agent-mon/monitor/agent-monitor.d.ts +44 -0
  253. package/dist/services/agent-mon/monitor/create-monitor.d.ts +6 -0
  254. package/dist/services/agent-mon/monitor/index.d.ts +2 -0
  255. package/dist/services/agent-mon/observe/index.d.ts +1 -0
  256. package/dist/services/agent-mon/observe/observe.d.ts +12 -0
  257. package/dist/services/agent-mon/providers/claude/claude-provider.d.ts +50 -0
  258. package/dist/services/agent-mon/providers/claude/index.d.ts +5 -0
  259. package/dist/services/agent-mon/providers/claude/ps.d.ts +36 -0
  260. package/dist/services/agent-mon/providers/claude/session-json.d.ts +37 -0
  261. package/dist/services/agent-mon/providers/opencode/db.d.ts +41 -0
  262. package/dist/services/agent-mon/providers/opencode/index.d.ts +3 -0
  263. package/dist/services/agent-mon/providers/opencode/model-parser.d.ts +6 -0
  264. package/dist/services/agent-mon/providers/opencode/opencode-provider.d.ts +45 -0
  265. package/dist/services/ai-client/providers/ai-model.type.d.ts +14 -0
  266. package/dist/services/ai-client/providers/open-router/open-router-model.type.d.ts +1 -4
  267. package/dist/services/ai-client/providers/open-router/open-router-provider.d.ts +17 -0
  268. package/dist/services/ai-client/providers/openai-like-provider.d.ts +1 -0
  269. package/dist/services/data-ore/telegram/telegram-data-ore.d.ts +17 -0
  270. package/dist/services/data-ore/telegram/telegram-data-ore.types.d.ts +4 -0
  271. package/dist/services/data-ore/telegram/telegram-demo-music-helper.d.ts +1 -0
  272. package/dist/services/data-ore/telegram/telegram-demo.d.ts +1 -0
  273. package/dist/services/dbc/linter/dbc-ast-adapter.types.d.ts +82 -0
  274. package/dist/services/dbc/linter/dbc-linter.types.d.ts +95 -0
  275. package/dist/services/dbc/linter/implementations/ts/dbc-ts-ast-adapter.d.ts +183 -0
  276. package/dist/services/dbc/linter/implementations/ts/dbc-ts-linter.d.ts +152 -0
  277. package/dist/services/dbc/parser/dbc-parser.types.d.ts +16 -16
  278. package/dist/services/dbc/parser/implementations/jsdoc/dbc-jsdoc-parser.d.ts +14 -4
  279. package/dist/services/logger/logger.d.ts +26 -6
  280. package/dist/services/remote-console/client/remote-console-client-serializer.d.ts +7 -0
  281. package/dist/services/remote-console/client/remote-console-client.d.ts +20 -0
  282. package/dist/services/remote-console/client/remote-console-client.types.d.ts +88 -0
  283. package/dist/services/remote-console/remote-console.d.ts +6 -0
  284. package/dist/services/remote-console/server/remote-console-server.d.ts +10 -0
  285. package/dist/services/remote-console/server/remote-console-server.types.d.ts +44 -0
  286. package/dist/services/remote-console/server/remote-console-stdout-writer.d.ts +26 -0
  287. package/dist/services/vcs-client/abstract/vcs-client-merge-discussions.d.ts +22 -14
  288. package/dist/services/vcs-client/abstract/vcs-client-merge-requests.d.ts +31 -14
  289. package/dist/services/vcs-client/abstract/vcs-client-repository-files.d.ts +16 -0
  290. package/dist/services/vcs-client/abstract/vcs-client.d.ts +9 -5
  291. package/dist/services/vcs-client/entities/vcs-file-content.type.d.ts +24 -0
  292. package/dist/services/vcs-client/entities/vcs-merge-request-changes.type.d.ts +32 -0
  293. package/dist/services/vcs-client/entities/vcs-url.type.d.ts +14 -0
  294. package/dist/services/vcs-client/entities/vcs-user.type.d.ts +3 -0
  295. package/dist/services/vcs-client/github/vcs-github-client.d.ts +31 -0
  296. package/dist/services/vcs-client/github/vcs-github-merge-requests.d.ts +40 -0
  297. package/dist/services/vcs-client/github/vcs-github-repository-files.d.ts +27 -0
  298. package/dist/services/vcs-client/gitlab/vcs-gitlab-client.d.ts +13 -4
  299. package/dist/services/vcs-client/gitlab/vcs-gitlab-merge-discussions.d.ts +16 -5
  300. package/dist/services/vcs-client/gitlab/vcs-gitlab-merge-requests.d.ts +24 -5
  301. package/dist/services/vcs-client/gitlab/vcs-gitlab-repository-files.d.ts +27 -0
  302. package/dist/services/vcs-client/parse-vcs-url.d.ts +3 -0
  303. package/dist/shared/backend/git/git-core.d.ts +24 -22
  304. package/dist/shared/backend/git/git-diff.d.ts +16 -5
  305. package/dist/shared/backend/rc/rc-config.d.ts +27 -15
  306. package/dist/shared/common/exec.d.ts +4 -6
  307. package/dist/shared/common/files.d.ts +1 -3
  308. package/dist/shared/common/language.d.ts +3 -6
  309. package/dist/shared/common/parse-args.d.ts +1 -4
  310. package/dist/shared/common/style.d.ts +3 -3
  311. package/dist/shared/common/think.d.ts +1 -5
  312. package/dist/shared/common/tokens.d.ts +1 -5
  313. package/dist/shared/common/unguard.d.ts +4 -8
  314. package/dist/shared/common/xml.d.ts +16 -12
  315. package/package.json +20 -4
  316. package/dist/.ai/agents/agent-review-verifier.xml +0 -181
  317. package/dist/chunks/index-CNbmXK8M.js +0 -3548
  318. package/dist/chunks/services-Sb7TwLxt.js +0 -122
  319. package/dist/chunks/shared-BgLzFWMH.js +0 -577
@@ -0,0 +1,153 @@
1
+ <StorybookSetupRules keywords="storybook, setup, mcp, agentic-init, install, addon-test, agents-md" type="infra-rules" ver="2.0">
2
+ <Mission>
3
+ Define how an execution-agent installs and configures Storybook for an agent-first project. The agent runs the official initializer, follows its generated guidance, installs the MCP/test addon set, registers the MCP server with the agent runner, and updates `AGENTS.md` so the integration is discoverable without chat context.
4
+
5
+ **Base axiom:** Storybook's value for an agentic project is mechanical — preview URL + MCP tools + run-story-tests. If any one of those three is missing, the integration is not «partially working»; it is broken in a way that silently fails later. The setup directive optimises for «all three present and verified» on first installation, not for fast partial scaffolds.
6
+
7
+ Companion (runtime usage after setup): `ai/directives/testing/storybook-usage.xml`.
8
+ </Mission>
9
+
10
+ <Belief_State>
11
+ <Axiom id="AX_SB_INIT_VIA_OFFICIAL_INSTALLER">
12
+ Storybook installation starts with the official initializer (`npx storybook@latest init`). Manually scaffolding `.storybook/main.*`, `.storybook/preview.*`, or hand-editing build config before running `init` is forbidden — the initializer is the source of truth for the framework detection, plugin set, and TS configuration that the project's framework currently requires.
13
+
14
+ The init is interactive: when it prompts about framework, builder, or feature opt-ins, the agent answers based on observed project state (existing `vite.config.*`, `package.json` scripts, framework deps), not on assumptions.
15
+ </Axiom>
16
+
17
+ <Axiom id="AX_SB_FOLLOW_GENERATED_GUIDE">
18
+ After `init` completes, the generated setup notes (`storybook` CLI output + any `.storybook/` README or onboarding file) are normative. The agent does NOT improvise alternative configuration, alternative entry points, or alternative scripts; it follows the generated guide and only deviates with explicit operator confirmation. Drift between the installer's intent and the project's actual config is the most common source of «Storybook used to work» tickets.
19
+ </Axiom>
20
+
21
+ <Axiom id="AX_SB_MCP_IS_MANDATORY">
22
+ For an agent-first project, the MCP integration (test/preview addon exposing tools the agent runner can call) is NOT optional. Without MCP, the agent cannot fetch component docs, preview stories, or run story tests programmatically — Storybook becomes a human-only GUI tool and loses its value in the workflow.
23
+
24
+ Setup is incomplete until the MCP addon is installed AND the MCP server is registered with the agent runner AND at least one MCP tool call returns a non-error response.
25
+ </Axiom>
26
+
27
+ <Axiom id="AX_SB_AGENTS_MD_UPDATED_AS_PART_OF_SETUP">
28
+ Setup ends with an `AGENTS.md` update making the integration discoverable: which MCP tools exist, story-file conventions adopted, tags reserved (e.g. `ai-generated`), pointer to the runtime usage directive. Skipping the `AGENTS.md` step turns the integration into tribal knowledge — every later agent must rediscover it from scratch.
29
+ </Axiom>
30
+
31
+ <Axiom id="AX_SB_VERIFY_BEFORE_HANDOFF">
32
+ Setup is verified end-to-end before being declared complete:
33
+ 1. `storybook dev` boots without errors and serves the preview URL.
34
+ 2. At least one MCP tool call to the registered server succeeds.
35
+ 3. `run-story-tests` (or the project's equivalent) passes on at least one story.
36
+
37
+ Any of the three failing → setup is not done; the failure is surfaced to the operator with the exact error rather than masked as «mostly working».
38
+ </Axiom>
39
+
40
+ <Axiom id="AX_SB_BROWSER_PREREQ_HANDLED">
41
+ Story tests run in a real browser (typically Chromium via Playwright). If the project does not already install Playwright browsers, the setup MUST add the install step (`npx playwright install chromium`, or the framework's equivalent) and verify the browser is available before declaring done. A missing browser turns the first story-test run into a confusing failure.
42
+ </Axiom>
43
+
44
+ <Axiom id="AX_SB_NO_PARALLEL_TEST_HARNESSES">
45
+ Story-level tests use ONE harness — the test addon shipped/recommended with Storybook for the project's framework. Introducing a parallel harness (e.g., a custom Vitest project that mounts stories outside the addon) fragments the project's testing surface and creates two report channels for the same component contract. If the project already has a chosen Storybook test addon, the agent reuses it; if not, the agent installs the official one and stops there.
46
+ </Axiom>
47
+ </Belief_State>
48
+
49
+ <Definitions>
50
+ <Definition id="DEF_SB_MCP_SERVER">
51
+ An MCP-compliant server exposing Storybook capabilities (documentation retrieval, story preview, story-test execution) to an agent runner. Realised by the Storybook test/MCP addon plus runner-side registration.
52
+ </Definition>
53
+ <Definition id="DEF_SB_TEST_ADDON">
54
+ The Storybook addon that provides programmatic story execution and assertions (current canonical: `@storybook/experimental-addon-test` family or its successor). Used by both human-side test runs and the MCP server.
55
+ </Definition>
56
+ </Definitions>
57
+
58
+ <Setup_Steps>
59
+ <Step id="STEP_SB_1_RUN_INIT">
60
+ Run `npx storybook@latest init` and answer prompts based on observed project structure. Do NOT pre-scaffold `.storybook/` before this step.
61
+ Ref: AX_SB_INIT_VIA_OFFICIAL_INSTALLER.
62
+ </Step>
63
+ <Step id="STEP_SB_2_APPLY_GENERATED_GUIDE">
64
+ Apply every manual step in the initializer's generated guide / onboarding doc verbatim. Surface deviations to the operator before applying them.
65
+ Ref: AX_SB_FOLLOW_GENERATED_GUIDE.
66
+ </Step>
67
+ <Step id="STEP_SB_3_INSTALL_TEST_ADDON">
68
+ Install the Storybook test/MCP addon recommended for the framework: `npx storybook add @storybook/experimental-addon-test` (or its current canonical successor). Confirm the addon appears in `package.json` and in `.storybook/main.*` addons array.
69
+ Ref: AX_SB_MCP_IS_MANDATORY, AX_SB_NO_PARALLEL_TEST_HARNESSES.
70
+ </Step>
71
+ <Step id="STEP_SB_4_INSTALL_BROWSER">
72
+ If a story-test browser is not already installed, run `npx playwright install chromium` (or the project's equivalent install step) and verify availability.
73
+ Ref: AX_SB_BROWSER_PREREQ_HANDLED.
74
+ </Step>
75
+ <Step id="STEP_SB_5_REGISTER_MCP_SERVER">
76
+ Register the Storybook MCP server in the agent runner's MCP configuration (command, args, env). Restart / reload the runner if it requires it.
77
+ Ref: AX_SB_MCP_IS_MANDATORY.
78
+ </Step>
79
+ <Step id="STEP_SB_6_VERIFY_END_TO_END">
80
+ Boot `storybook dev`, confirm preview URL responds; make at least one MCP tool call; run `run-story-tests` on one story. All three must succeed.
81
+ Ref: AX_SB_VERIFY_BEFORE_HANDOFF.
82
+ </Step>
83
+ <Step id="STEP_SB_7_UPDATE_AGENTS_MD">
84
+ Add a Storybook section to `AGENTS.md`: MCP tools available, story-file conventions (`*.stories.ts` location, naming), reserved tags (`ai-generated`), pointer to `testing/storybook-usage.xml`.
85
+ Ref: AX_SB_AGENTS_MD_UPDATED_AS_PART_OF_SETUP.
86
+ </Step>
87
+ </Setup_Steps>
88
+
89
+ <Anti_Patterns>
90
+ <Anti_Pattern id="AP_SB_MANUAL_SCAFFOLD_BEFORE_INIT">
91
+ <Bad>Agent hand-creates `.storybook/main.ts` with a guess at the framework integration, copies a preset from another project, and runs `storybook dev` to «see if it works».</Bad>
92
+ <Why_Bad>Bypasses the official initializer (`AX_SB_INIT_VIA_OFFICIAL_INSTALLER`). The initializer's framework detection is the single source of truth for the current Storybook version's expected config; a hand-rolled main file drifts from it on the first minor upgrade and produces opaque «works on the laptop, fails in CI» symptoms.</Why_Bad>
93
+ <Good>Delete the hand-rolled `.storybook/`, run `npx storybook@latest init`, answer prompts based on observed project state, then follow the generated guide verbatim.</Good>
94
+ </Anti_Pattern>
95
+
96
+ <Anti_Pattern id="AP_SB_NO_MCP_INTEGRATION">
97
+ <Bad>Agent installs base Storybook, gets `storybook dev` running, and marks the ticket done without installing the test/MCP addon or registering the MCP server.</Bad>
98
+ <Why_Bad>Storybook present but unreachable by agents (`AX_SB_MCP_IS_MANDATORY`). Every subsequent component task must either rediscover props from source code or fall back to human-driven preview. The integration is structurally incomplete; calling it «done» misrepresents project state.</Why_Bad>
99
+ <Good>Install the recommended test/MCP addon (`STEP_SB_3_INSTALL_TEST_ADDON`), register the MCP server with the agent runner (`STEP_SB_5_REGISTER_MCP_SERVER`), and verify at least one MCP tool call returns a non-error response.</Good>
100
+ </Anti_Pattern>
101
+
102
+ <Anti_Pattern id="AP_SB_VERIFY_SKIPPED">
103
+ <Bad>Agent finishes the install steps and reports «Storybook configured» based solely on `npm install` exit code, without booting `storybook dev` or running any story test.</Bad>
104
+ <Why_Bad>Setup declared complete without end-to-end verification (`AX_SB_VERIFY_BEFORE_HANDOFF`). Misses Playwright browser missing, MCP server not registered, addon misconfigured, port conflict — all of which compile fine but break the first real use.</Why_Bad>
105
+ <Good>Boot `storybook dev` and confirm preview URL responds; call one MCP tool; run `run-story-tests` on one story. If any fails, surface the exact error to the operator before marking the ticket complete.</Good>
106
+ </Anti_Pattern>
107
+
108
+ <Anti_Pattern id="AP_SB_AGENTS_MD_SKIPPED">
109
+ <Bad>Setup verified end-to-end, but `AGENTS.md` not updated — no mention of Storybook tooling, MCP tools, or story conventions.</Bad>
110
+ <Why_Bad>Integration becomes tribal knowledge (`AX_SB_AGENTS_MD_UPDATED_AS_PART_OF_SETUP`). Next agent on the project must rediscover the entire integration from chat history or trial-and-error. Defeats the «discoverable without chat context» principle that justifies `AGENTS.md` in the first place.</Why_Bad>
111
+ <Good>Append a Storybook section to `AGENTS.md`: MCP tool names, story-file location and naming conventions, reserved tags (e.g. `ai-generated`), pointer to `testing/storybook-usage.xml`.</Good>
112
+ </Anti_Pattern>
113
+ </Anti_Patterns>
114
+
115
+ <Verification_Hooks>
116
+ <Hook id="HOOK_SB_PREVIEW_BOOTS">
117
+ <Purpose>Storybook dev server boots without errors and serves the preview.</Purpose>
118
+ <Command>npx storybook dev --ci --quiet &amp; PID=$!; sleep 8; curl -fsS http://localhost:6006/index.json > /dev/null; STATUS=$?; kill $PID 2>/dev/null; wait $PID 2>/dev/null; exit $STATUS</Command>
119
+ <Expected>Exit 0. Non-zero indicates the preview did not boot within the timeout or the index endpoint is unreachable.</Expected>
120
+ </Hook>
121
+ <Hook id="HOOK_SB_ADDON_PRESENT">
122
+ <Purpose>Test/MCP addon is listed in Storybook config.</Purpose>
123
+ <Command>find .storybook -maxdepth 2 -type f \( -name 'main.ts' -o -name 'main.js' -o -name 'main.mts' \) -print0 | xargs -0 grep -nE 'addon-test|addon-mcp' || true</Command>
124
+ <Expected>At least one match. Empty output means the addon is not registered in `.storybook/main.*`.</Expected>
125
+ </Hook>
126
+ <Hook id="HOOK_SB_AGENTS_MD_MENTIONS_STORYBOOK">
127
+ <Purpose>`AGENTS.md` mentions Storybook so the integration is discoverable.</Purpose>
128
+ <Command>test -f AGENTS.md &amp;&amp; grep -nE 'Storybook|storybook' AGENTS.md || echo MISSING</Command>
129
+ <Expected>At least one match in `AGENTS.md`. `MISSING` (file absent) or empty output is a setup gap.</Expected>
130
+ </Hook>
131
+ <Hook id="HOOK_SB_PLAYWRIGHT_BROWSER_PRESENT">
132
+ <Purpose>Chromium is installed for story tests.</Purpose>
133
+ <Command>npx playwright install --dry-run chromium 2>&amp;1 | grep -E "browser is already installed|is downloaded" || echo MISSING</Command>
134
+ <Expected>Output indicates Chromium is already installed. `MISSING` means the browser still needs `npx playwright install chromium`.</Expected>
135
+ </Hook>
136
+ </Verification_Hooks>
137
+
138
+ <Reward_Criteria>
139
+ ✅ Storybook installed via the official initializer; generated guide applied verbatim.
140
+ ✅ Test/MCP addon installed and present in `.storybook/main.*`.
141
+ ✅ MCP server registered in the agent runner; at least one MCP tool call succeeds.
142
+ ✅ Required browser (Chromium / equivalent) installed before story-test runs.
143
+ ✅ End-to-end verification: `storybook dev` boots, MCP tool call returns, `run-story-tests` passes on one story.
144
+ ✅ `AGENTS.md` updated with Storybook section: MCP tools, story conventions, reserved tags, pointer to `testing/storybook-usage.xml`.
145
+
146
+ ❌ Hand-scaffolded `.storybook/` config bypassing the initializer.
147
+ ❌ Storybook installed without the test/MCP addon.
148
+ ❌ MCP server not registered with the agent runner.
149
+ ❌ Setup declared done without booting `storybook dev` or running a story test.
150
+ ❌ `AGENTS.md` not updated; integration left as tribal knowledge.
151
+ ❌ Parallel story-test harness introduced alongside the official addon.
152
+ </Reward_Criteria>
153
+ </StorybookSetupRules>
@@ -0,0 +1,206 @@
1
+ <AiKnowledge ver="2.0">
2
+ <Directives>
3
+ <Sdd>
4
+ <SddSetup>
5
+ <File>ai/directives/sdd/setup.directive.xml</File>
6
+ <Purpose>Creates or updates specs/README.md — Vision and Scope Graph. Sole owner of the Portal. Idempotent.</Purpose>
7
+ <Triggers>new project · add scope · change project vision · register scope after discovery</Triggers>
8
+ <SkipWhen>designing a specific scope · module decomposition · task scaffolding</SkipWhen>
9
+ <Preconditions>None</Preconditions>
10
+ </SddSetup>
11
+ <SddDiscovery>
12
+ <File>ai/directives/sdd/discovery.directive.xml</File>
13
+ <Purpose>Scope-level discovery session. Creates or evolves specs/[scope]/[scope].spec.md. Branches by scope-type: infrastructure, contracts, library, product.</Purpose>
14
+ <Triggers>design scope · raw idea for service/SDK/CLI/app · bootstrap infra tooling · refine or pivot existing scope</Triggers>
15
+ <SkipWhen>approved spec exists and operator wants module decomposition · bug fix or local refactor · project-level vision change</SkipWhen>
16
+ <Preconditions>greenfield: none. refine/pivot: specs/[scope]/[scope].spec.md exists</Preconditions>
17
+ </SddDiscovery>
18
+ <SddModuleDecomposition>
19
+ <File>ai/directives/sdd/module-decomposition.directive.xml</File>
20
+ <Purpose>Decomposes a product or library scope into module specs with closed-world entity inventory, public surfaces, DbC contracts (Ports / Adapters / Services).</Purpose>
21
+ <Triggers>discovery complete · split into modules · build module map · list all entities · produce DbC · Ports and Adapters</Triggers>
22
+ <SkipWhen>scope spec missing or not approved · discovery still open · scope-type is infrastructure or contracts · tasks already generated</SkipWhen>
23
+ <Preconditions>specs/[scope]/[scope].spec.md with scope-type=product or library</Preconditions>
24
+ </SddModuleDecomposition>
25
+ <SddTaskScaffolding>
26
+ <File>ai/directives/sdd/task-scaffolding.directive.xml</File>
27
+ <Purpose>Builds DAG of compact task tickets from scope graph. Each ticket includes BDD, Effective Rules, Verification, Execution Log template.</Purpose>
28
+ <Triggers>all scope specs ready · break into tasks · build DAG · produce execution plan · scaffold tickets</Triggers>
29
+ <SkipWhen>module specs lack contracts · discovery or module-decomp not closed · tasks already generated</SkipWhen>
30
+ <Preconditions>specs/README.md Scope Graph ✅; coding rule files exist for each language</Preconditions>
31
+ </SddTaskScaffolding>
32
+ <SddPhaseExecution>
33
+ <File>ai/directives/sdd/phase-execution-protocol.xml</File>
34
+ <Purpose>Execute ONE phase of ONE task ticket, dispatched by sdd-execute orchestrator. Read only what the phase needs; write only Target Files; emit typed Handoff for next phase / audit.</Purpose>
35
+ <Triggers>orchestrator dispatches phase · phase ID + ticket path provided in prompt</Triggers>
36
+ <SkipWhen>operator invokes directly without orchestrator · no phase ID</SkipWhen>
37
+ <Preconditions>ticket has section 2 Phases Overview + section 3 Phases block for target phase ID; prior-phase Handoffs (if any) recorded in current Round</Preconditions>
38
+ </SddPhaseExecution>
39
+ <SddAudit>
40
+ <File>ai/directives/sdd/audit.directive.xml</File>
41
+ <Purpose>Post-execution verification. Compares spec ↔ ticket ↔ code. Detects drift, gaps, rules violations. Output: ephemeral findings routed to spec/ticket.</Purpose>
42
+ <Triggers>audit · drift detection · post-implementation review · verify implementation · end of epic before merge</Triggers>
43
+ <SkipWhen>no executed tasks · Execution Log empty · no spec to compare</SkipWhen>
44
+ <Preconditions>spec exists; ticket with non-empty Execution Log; code committed</Preconditions>
45
+ </SddAudit>
46
+ </Sdd>
47
+ </Directives>
48
+ <Rules>
49
+ <CheckPhaseOrder>typecheck test lint format</CheckPhaseOrder>
50
+
51
+ <Coding>
52
+ <Rule id="result-conventions">
53
+ <File>ai/directives/coding/result-conventions.xml</File>
54
+ <Purpose>ESLint enforcement of Result pattern conventions: no second generic, no object literals, no isErr short-circuit, no bare throw unknown.</Purpose>
55
+ <Triggers>Target Files use Result from @tessell/core/result · task touches error-handling code · task adds new DML / service methods</Triggers>
56
+ <SkipWhen>Config-only task; no Result usage in target files</SkipWhen>
57
+ <ActivationHint>Before writing or reviewing any file that returns or propagates Result</ActivationHint>
58
+ <CheckPhase>lint</CheckPhase>
59
+ <RequiresVerification>check-command</RequiresVerification>
60
+ </Rule>
61
+ <Rule id="typescript-rules">
62
+ <File>ai/directives/coding/typescript-rules.xml</File>
63
+ <Purpose>Writing code in the chosen language: typing, DbC, patterns, anti-patterns.</Purpose>
64
+ <Triggers>Target Files include source code files (not config)</Triggers>
65
+ <SkipWhen>Config-only task; infra-setup task without code files</SkipWhen>
66
+ <ActivationHint>Before editing or creating any source code file</ActivationHint>
67
+ <CheckPhase>typecheck</CheckPhase>
68
+ <RequiresVerification>check-command</RequiresVerification>
69
+ </Rule>
70
+ <Rule id="svelte5-runes">
71
+ <File>ai/directives/coding/svelte5-runes.xml</File>
72
+ <Purpose>Writing Svelte 5 components with runes ($state, $derived, $effect, $props, $bindable). Inherits typescript-rules; adds Svelte-specific reactivity, template syntax, component structure. Prevents React-pattern code in .svelte files.</Purpose>
73
+ <Triggers>creating .svelte file · writing Svelte component · using runes · .svelte.ts module</Triggers>
74
+ <SkipWhen>pure TypeScript without Svelte · React/Vue project · backend server code</SkipWhen>
75
+ <ActivationHint>Before editing or creating any .svelte, .svelte.ts, or .svelte.js file. Inherits from typescript-rules — read both.</ActivationHint>
76
+ <CheckPhase>typecheck</CheckPhase>
77
+ <RequiresVerification>check-command</RequiresVerification>
78
+ <CrossRef id="typescript-rules">Parent directive: inherits all TypeScript rules for language baseline.</CrossRef>
79
+ <CrossRef id="sveltekit-rules">SvelteKit projects also activate sveltekit-rules (inherits from this directive).</CrossRef>
80
+ </Rule>
81
+ <Rule id="sveltekit-rules">
82
+ <File>ai/directives/coding/sveltekit-rules.xml</File>
83
+ <Purpose>Writing SvelteKit applications: file-based routing (+page, +layout, +server), server load functions, form actions, hooks, adapters, $app modules. Inherits svelte5-runes + typescript-rules transitively.</Purpose>
84
+ <Triggers>creating SvelteKit route · load function · form actions · hooks.server.ts · server/client boundary</Triggers>
85
+ <SkipWhen>standalone Svelte without SvelteKit · pure component library · non-SvelteKit project</SkipWhen>
86
+ <ActivationHint>Before writing SvelteKit route files or server logic. Inherits from svelte5-runes — read both.</ActivationHint>
87
+ <CheckPhase>typecheck</CheckPhase>
88
+ <RequiresVerification>check-command</RequiresVerification>
89
+ <CrossRef id="svelte5-runes">Parent directive: inherits all Svelte 5 runes rules.</CrossRef>
90
+ <CrossRef id="typescript-rules">Transitive parent: inherits TypeScript rules through svelte5-runes.</CrossRef>
91
+ </Rule>
92
+ </Coding>
93
+ <Testing>
94
+ <Rule id="testing-common">
95
+ <File>ai/directives/testing/common.xml</File>
96
+ <Purpose>Shared testing core inherited by every runner-specific directive: contract boundary, case flow, phase anchors, unified context + factory, BDD mapping, snapshot operator-confirm, file budget.</Purpose>
97
+ <Triggers>any runner-specific testing rule activates</Triggers>
98
+ <SkipWhen>no test files in scope</SkipWhen>
99
+ <ActivationHint>Auto-read whenever node-test or vitest-rules activates. Runner-specific files only state deltas.</ActivationHint>
100
+ <CheckPhase>test</CheckPhase>
101
+ <RequiresVerification>check-command</RequiresVerification>
102
+ </Rule>
103
+ <Rule id="vitest-rules">
104
+ <File>ai/directives/testing/vitest-rules.xml</File>
105
+ <Purpose>Writing tests on Vitest runner.</Purpose>
106
+ <Triggers>Target Test Files present AND stack uses Vitest</Triggers>
107
+ <SkipWhen>Stack uses a different test runner; no test files in scope</SkipWhen>
108
+ <ActivationHint>Before writing or modifying test files. Inherits testing-common.</ActivationHint>
109
+ <CheckPhase>test</CheckPhase>
110
+ <RequiresVerification>check-command</RequiresVerification>
111
+ <CrossRef id="testing-common">Parent directive: read first for case flow, anchors, unified context, BDD mapping.</CrossRef>
112
+ </Rule>
113
+ <Rule id="node-test">
114
+ <File>ai/directives/testing/node-test.xml</File>
115
+ <Purpose>Writing tests on node:test runner.</Purpose>
116
+ <Triggers>Target Test Files present AND stack uses node:test</Triggers>
117
+ <SkipWhen>Stack uses a different test runner; no test files in scope</SkipWhen>
118
+ <ActivationHint>Before writing or modifying test files. Inherits testing-common.</ActivationHint>
119
+ <CheckPhase>test</CheckPhase>
120
+ <RequiresVerification>check-command</RequiresVerification>
121
+ <CrossRef id="testing-common">Parent directive: read first for case flow, anchors, unified context, BDD mapping.</CrossRef>
122
+ </Rule>
123
+ <Rule id="playwright-cli">
124
+ <File>ai/directives/testing/playwright-cli.xml</File>
125
+ <Purpose>Exploring web apps through Playwright CLI: AX Tree vision, aria snapshots, screenshots, trace viewer, codegen. Gives the agent eyes and hands for browser exploration.</Purpose>
126
+ <Triggers>developing UI component · building a page · verifying visual layout · debugging failing e2e test · capturing aria snapshots</Triggers>
127
+ <SkipWhen>pure backend logic · CLI command implementation · API endpoint without UI</SkipWhen>
128
+ <ActivationHint>BEFORE writing any e2e test — explore the page first. Also when an e2e test fails and the agent needs to see what rendered.</ActivationHint>
129
+ <CheckPhase>test</CheckPhase>
130
+ <RequiresVerification>check-command</RequiresVerification>
131
+ <CrossRef id="playwright-e2e">Transition to playwright-e2e when exploration complete.</CrossRef>
132
+ </Rule>
133
+ <Rule id="playwright-e2e">
134
+ <File>ai/directives/testing/playwright-e2e.xml</File>
135
+ <Purpose>Writing Playwright E2E tests: aria-snapshot-first contracts, role-based locators, fixture-based POM, auth via storageState, network mocking.</Purpose>
136
+ <Triggers>writing e2e test · creating browser test · adding Playwright spec · testing user flow</Triggers>
137
+ <SkipWhen>unit test · integration test without browser · exploration not done (use playwright-cli first)</SkipWhen>
138
+ <ActivationHint>AFTER playwright-cli exploration. Before writing Playwright spec files.</ActivationHint>
139
+ <CheckPhase>test</CheckPhase>
140
+ <RequiresVerification>check-command</RequiresVerification>
141
+ <CrossRef id="playwright-cli">MUST run playwright-cli exploration first.</CrossRef>
142
+ </Rule>
143
+ <Rule id="storybook-usage">
144
+ <File>ai/directives/testing/storybook-usage.xml</File>
145
+ <Purpose>Using Storybook MCP tools: reading manifests (component docs, props, stories), writing stories, running tests, self-verifying component rendering.</Purpose>
146
+ <Triggers>developing UI component · using design system · creating story · fixing component bug · verifying component renders</Triggers>
147
+ <SkipWhen>pure backend/CLI logic · no Storybook · MCP not installed (use storybook-setup first)</SkipWhen>
148
+ <ActivationHint>Whenever working with UI components — BEFORE writing code, call MCP tools to check documented props.</ActivationHint>
149
+ <CheckPhase>test</CheckPhase>
150
+ <RequiresVerification>check-command</RequiresVerification>
151
+ <CrossRef id="storybook-setup">MUST have Storybook + MCP running. If unreachable, invoke storybook-setup.</CrossRef>
152
+ </Rule>
153
+ <Rule id="svelte-testing">
154
+ <File>ai/directives/testing/svelte-testing.xml</File>
155
+ <Purpose>Testing Svelte 5 components: .svelte.test.ts extension, $effect.root isolation, flushSync for DOM, mount/unmount, @testing-library/svelte. Inherits node-test + vitest-rules.</Purpose>
156
+ <Triggers>writing Svelte component test · testing runes · mounting Svelte component · Storybook interaction test for Svelte</Triggers>
157
+ <SkipWhen>pure TS logic test without runes · E2E test with Playwright · non-Svelte project</SkipWhen>
158
+ <ActivationHint>Before writing .svelte.test.ts. Inherits from node-test.xml and vitest-rules.xml.</ActivationHint>
159
+ <CheckPhase>test</CheckPhase>
160
+ <RequiresVerification>check-command</RequiresVerification>
161
+ <CrossRef id="node-test">Inherits general testing rules (phase anchors, learning briefs, contract coverage).</CrossRef>
162
+ <CrossRef id="vitest-rules">Inherits Vitest-specific rules (unified context, mock discipline).</CrossRef>
163
+ <CrossRef id="svelte5-runes">Runes knowledge required (.svelte.test.ts, $effect.root, flushSync).</CrossRef>
164
+ </Rule>
165
+ </Testing>
166
+ <Infra>
167
+ <Rule id="eslint-setup">
168
+ <File>ai/directives/infra/eslint-setup.xml</File>
169
+ <Purpose>Configuring a linter: severity policy, autofix, config format, formatter integration.</Purpose>
170
+ <Triggers>Task configures linter · installs linter · sets lint rules</Triggers>
171
+ <SkipWhen>Coding/testing task that only RUNS lint, does not configure it</SkipWhen>
172
+ <ActivationHint>Before writing linter config or modifying lint rules</ActivationHint>
173
+ <CheckPhase>lint</CheckPhase>
174
+ <RequiresVerification>check-command</RequiresVerification>
175
+ </Rule>
176
+ <Rule id="git-setup">
177
+ <File>ai/directives/infra/git-setup.xml</File>
178
+ <Purpose>Configuring VCS: ignore baseline, branches, commits, hooks, secrets discipline.</Purpose>
179
+ <Triggers>Task bootstraps repo · configures VCS ignore file · sets up hooks · commit convention</Triggers>
180
+ <SkipWhen>Task only commits code changes (does not configure VCS itself)</SkipWhen>
181
+ <ActivationHint>Before writing VCS ignore file or configuring hooks</ActivationHint>
182
+ <CheckPhase></CheckPhase>
183
+ <RequiresVerification></RequiresVerification>
184
+ </Rule>
185
+ <Rule id="nodejs-npm-setup">
186
+ <File>ai/directives/infra/nodejs-npm-setup.xml</File>
187
+ <Purpose>Runtime + package manager setup: version pinning, single package manager, module system, mandatory check script.</Purpose>
188
+ <Triggers>Task writes package manager manifest · runtime version file · sets engines · chooses package manager</Triggers>
189
+ <SkipWhen>Task does not touch package manager manifest or runtime config</SkipWhen>
190
+ <ActivationHint>Before writing package manager manifest or runtime version file</ActivationHint>
191
+ <CheckPhase></CheckPhase>
192
+ <RequiresVerification></RequiresVerification>
193
+ </Rule>
194
+ <Rule id="storybook-setup">
195
+ <File>ai/directives/infra/storybook-setup.xml</File>
196
+ <Purpose>Installing Storybook + MCP server: agentic init, MCP addon, Vitest addon, agent registration, AGENTS.md update. Bootstraps component development environment.</Purpose>
197
+ <Triggers>install Storybook · add Storybook to project · configure MCP server · bootstrap UI toolchain</Triggers>
198
+ <SkipWhen>no UI components · Storybook already installed + MCP confirmed running</SkipWhen>
199
+ <ActivationHint>When project needs Storybook for first time. Follow agentic init: npx storybook@latest init.</ActivationHint>
200
+ <CheckPhase>test</CheckPhase>
201
+ <RequiresVerification>check-command</RequiresVerification>
202
+ <CrossRef id="storybook-usage">After setup (MCP running, manifest accessible), transition to storybook-usage.</CrossRef>
203
+ </Rule>
204
+ </Infra>
205
+ </Rules>
206
+ </AiKnowledge>
@@ -0,0 +1,75 @@
1
+ <PerfAuditor keywords="performance, audit, optimization, cpu, memory, latency, event_lag, fps, gc, oom" type="directive" ver="2.0">
2
+ <Mission>
3
+ Автономный ИИ-аудитор производительности. Сканирует код, находит узкие места, **сам подгружает соответствующие Rulebooks** для проверки гипотез, верифицирует safety рефакторинга и выдаёт инструкции для DevAgent.
4
+
5
+ **Target hardware:** Mid-range Mobile/Desktop, 4–8 GB RAM. Фокус: снижение GC pauses, устранение O(n²), контроль Event Loop и backpressure. **Без изменения бизнес-логики.**
6
+ </Mission>
7
+
8
+ <Belief_State>
9
+ <Axiom id="AX_AUTONOMOUS_RESEARCH">Не делаешь выводов «из головы». Обнаружив паттерн, ОБЯЗАН открыть соответствующий Rulebook из `<Knowledge_Base_Index>`, изучить его правила/tradeoff/guardrails, и только потом принимать решение.</Axiom>
10
+ <Axiom id="AX_NO_CODE_GENERATION">Не пишешь код. Финальный артефакт — набор семантически привязанных инструкций для DevAgent.</Axiom>
11
+ <Axiom id="AX_SEMANTIC_SAFETY">Если применение правила может изменить поведение (порядок элементов, обработка ошибок, мутабельность) и не можешь доказать обратное → отклони как False Positive.</Axiom>
12
+ <Axiom id="AX_TARGET_HARDWARE">На 4–8 GB RAM аллокация объектов важнее микро-CPU-оптимизаций. Избегай промежуточных массивов и утечек памяти.</Axiom>
13
+ </Belief_State>
14
+
15
+ <Input_Contract>
16
+ **Принимается:** TS/JS файлы; папки/модули/diff/набор файлов на аудит; контекст (hot path, latency-жалобы, event-loop lag, memory spikes, OOM, FPS drops).
17
+
18
+ **Scope rules:**
19
+ - Diff передан → приоритет изменённым участкам; соседний код только для доказательства safety.
20
+ - Файл/папка без hot-path-маркера → определи участки с performance-impact: циклы, коллекции, I/O, async orchestration, caching, listeners, timers.
21
+ - Не аудируешь бизнес-логику. Только performance-risk и refactoring safety.
22
+ - Не предлагай оптимизации ради микро-выигрыша без видимого latency/memory benefit на target hardware.
23
+
24
+ **Исключено:** generated code, fixtures, snapshots, vendor artifacts, тестовые helper'ы — если оператор явно не указал их источником проблемы. Не предлагай rewriting архитектуры, если локальная оптимизация решает.
25
+ </Input_Contract>
26
+
27
+ <Knowledge_Base_Index>
28
+ Агент использует `Signals` чтобы понять, какой Rulebook грузить на Шаге 2.
29
+
30
+ <Rulebook file="./rules/data-structures.xml">
31
+ <Description>Array vs Set vs Map, TypedArrays, Queues.</Description>
32
+ <Signals>`.includes()` / `.indexOf()` в циклах; `{}` как словарь с динамическими ключами или частые `delete`; `array.shift()` / `unshift()` для очередей; математика над огромными числовыми массивами.</Signals>
33
+ </Rulebook>
34
+ <Rulebook file="./rules/memory-gc.xml">
35
+ <Description>Утечки памяти, GC pressure, замыкания, таймеры, DOM-ссылки.</Description>
36
+ <Signals>Глобальные переменные / кэши без очистки (LRU/TTL); `setInterval`, `addEventListener` без сохранения ссылок для очистки; `new RegExp` / `Intl.DateTimeFormat` внутри циклов; `...spread` / `.concat()` / `.slice()` в горячих циклах.</Signals>
37
+ </Rulebook>
38
+ <Rulebook file="./rules/async-latency.xml">
39
+ <Description>Concurrency, backpressure, Promise.all, Event Loop blocks.</Description>
40
+ <Signals>`await` в `for`/`while` (последовательное выполнение); `Promise.all` на массивах неизвестной/большой длины; `fs.readFile` целиком или потоки без `drain`/`pause`; fetch без `AbortController`; рекурсивные retry без exponential backoff.</Signals>
41
+ </Rulebook>
42
+ <Rulebook file="./rules/iteration-fusion.xml">
43
+ <Description>Слияние циклов (fusion), early exit, избегание промежуточных аллокаций.</Description>
44
+ <Signals>Цепочки `.filter(...).map(...)` или `.map(...).flat()`; `.filter(...)[0]` / `.filter(...).length > 0`; результат `.map()`/`.filter()` не используется; `forEach` с `return` для early exit.</Signals>
45
+ </Rulebook>
46
+ </Knowledge_Base_Index>
47
+
48
+ <Execution_Plan>
49
+ <Step id="1_INITIAL_SCAN">Анализ кода. Сопоставь структуру с `<Signals>` в `<Knowledge_Base_Index>`. Составь список подозрений (Code Smells).</Step>
50
+ <Step id="2_LOAD_RULEBOOKS">Открой и прочитай ТОЛЬКО релевантные Rulebooks. Порядок попыток: 1) прямое чтение файла по `file=`, 2) tool/read_file по этому пути, 3) fallback на эквивалентный локальный file-fetch. Не ссылайся на Rulebook, который фактически не прочитал в этом запуске.</Step>
51
+ <Step id="3_DEEP_VERIFICATION">Для каждого подозрения: проверь по релевантным секциям Rulebook (`Performance_Mechanism`, `Safety_Guardrails`, `Directive_Template` или эквивалентам). Явно проверь premature optimization / false positive по guardrails. Докажи семантическую safety («`filter()[0]` → `find()` безопасно: нужен только первый элемент»). Отбрось не прошедшие.</Step>
52
+ <Step id="4_REPORT_GENERATION">Сформируй `<Performance_Audit_Report>` для DevAgent — только верифицированные директивы.</Step>
53
+ </Execution_Plan>
54
+
55
+ <Output_Contract>
56
+ Финальный ответ содержит ТОЛЬКО `<Verification_Log>` и `<Performance_Audit_Report>` в этом порядке. Запрещено писать блоки кода с готовым решением — только семантические якоря и инструкции.
57
+
58
+ ```xml
59
+ <Verification_Log>
60
+ Краткий лог рассуждений Шага 3: что подтвердилось, что отброшено как False Positive и почему.
61
+ Если подтверждённых нарушений нет — всё равно заполни и явно перечисли отклонённые гипотезы.
62
+ </Verification_Log>
63
+
64
+ <Performance_Audit_Report>
65
+ <!-- Если нет подтверждённых нарушений — пустой отчёт с пометкой `No verified findings`. -->
66
+ <Finding rulebook_ref="[Rulebook name]">
67
+ <Location file="[Path]" semantic_anchor="[например: 'Внутри метода processData, цикл for-of по orders']" />
68
+ <Issue_Description>В чём проблема (со ссылкой на механизмы из Rulebook: O(n²), GC-аллокации, backpressure).</Issue_Description>
69
+ <Safety_Proof>Доказательство, что рефакторинг не сломает логику (по Guardrails из Rulebook).</Safety_Proof>
70
+ <Dev_Agent_Directive>Строгий приказ для DevAgent. Пример: «Извлеки массив X в `new Set()` до цикла. Внутри цикла замени `.includes` на `.has()`».</Dev_Agent_Directive>
71
+ </Finding>
72
+ </Performance_Audit_Report>
73
+ ```
74
+ </Output_Contract>
75
+ </PerfAuditor>
@@ -0,0 +1,101 @@
1
+ <Rulebook id="rulebook_async_latency" type="knowledge_base">
2
+ <Primary_Goal>
3
+ Предоставить Аудитору критерии для выявления проблем с конкурентностью, отсутствием обратного давления (Backpressure), блокировками Event Loop и неэффективным управлением сетевыми/дисковыми ресурсами.
4
+ </Primary_Goal>
5
+ <Belief_State>
6
+ <Axiom id="AX_BACKPRESSURE_IS_LAW">Чтение данных быстрее, чем их может обработать потребитель, накапливает бесконечный буфер в RAM. Игнорирование Backpressure — это прямой путь к OOM на устройствах с 4-8 GB памяти.</Axiom>
7
+ <Axiom id="AX_CONCURRENCY_LIMITS">ОС и железо имеют лимиты на открытые сокеты и дескрипторы. Запуск неограниченного числа параллельных задач убивает систему быстрее, чем последовательное выполнение.</Axiom>
8
+ <Axiom id="AX_LATENCY_STACKING">Последовательный `await` независимых задач складывает их задержки (Latency). Параллельный запуск сводит общую задержку к самой медленной задаче.</Axiom>
9
+ </Belief_State>
10
+ <Rules_Registry>
11
+ <!-- ПРАВИЛО 1: Отсутствие контроля параллелизма -->
12
+ <Rule id="ASYNC_UNBOUNDED_PROMISE_ALL">
13
+ <Trigger_Signals>
14
+ - Вызов `Promise.all(arr.map(...))` или `Promise.allSettled(...)`, где `arr` — массив неизвестного или потенциально большого размера.
15
+ </Trigger_Signals>
16
+ <Performance_Mechanism>
17
+ Запуск тысяч промисов одновременно перегружает Event Loop, исчерпывает пул соединений (database/network meltdown) и вызывает пик потребления памяти (все ответы сохраняются в RAM одновременно).
18
+ </Performance_Mechanism>
19
+ <Safety_Guardrails>
20
+ <Guardrail condition="KNOWN_SMALL_ARRAY">Если размер массива жестко ограничен бизнес-логикой (например, `['user', 'admin'].map(...)`), игнорировать.</Guardrail>
21
+ </Safety_Guardrails>
22
+ <Directive_Template>
23
+ "Неограниченный параллелизм. Замени `Promise.all` на пакетную обработку (batching) через цикл `for` с нарезкой массива (например, по 10 элементов) или используй библиотеку контроля конкурентности (например, `p-limit`)."
24
+ </Directive_Template>
25
+ </Rule>
26
+ <!-- ПРАВИЛО 2: Лишняя последовательность (Sequential Await) -->
27
+ <Rule id="ASYNC_SEQUENTIAL_AWAIT">
28
+ <Trigger_Signals>
29
+ - Несколько операторов `await` идут подряд в одном блоке кода.
30
+ - Использование `await` внутри цикла `for...of` при вызове независимых API.
31
+ </Trigger_Signals>
32
+ <Performance_Mechanism>
33
+ Ожидание завершения первой задачи перед стартом второй удваивает время ответа (Latency) и заставляет CPU простаивать в ожидании I/O.
34
+ </Performance_Mechanism>
35
+ <Safety_Guardrails>
36
+ <Guardrail condition="DATA_DEPENDENCY">Если второй `await` использует результат первого (например, `const user = await getUser(); const posts = await getPosts(user.id);`), оптимизация невозможна. Отклонить.</Guardrail>
37
+ <Guardrail condition="ORDER_REQUIREMENT">Если важен строгий порядок выполнения на сервере (например, транзакции), отклонить.</Guardrail>
38
+ </Safety_Guardrails>
39
+ <Directive_Template>
40
+ "Последовательное выполнение независимых задач. Оберни эти вызовы в `Promise.all([...])` для параллельного выполнения и снижения Latency."
41
+ </Directive_Template>
42
+ </Rule>
43
+ <!-- ПРАВИЛО 3: Игнорирование Backpressure (Потоки) -->
44
+ <Rule id="ASYNC_NO_BACKPRESSURE">
45
+ <Trigger_Signals>
46
+ - Чтение файлов целиком: `fs.readFile`, `fs.promises.readFile`, `Buffer.concat()`.
47
+ - Чтение HTTP-ответов целиком: `await response.text()` или `.json()` для огромных payload.
48
+ - Использование `readable.on('data', chunk => writable.write(chunk))` без проверки возвращаемого значения `write()` и вызова `pause()`.
49
+ </Trigger_Signals>
50
+ <Performance_Mechanism>
51
+ Полная буферизация загружает весь объем данных в RAM. В Node.js это может увеличить потребление памяти с 50 MB до 1.5 GB. Потоки (Streams) с Backpressure держат в памяти только один чанк (chunk).
52
+ </Performance_Mechanism>
53
+ <Safety_Guardrails>
54
+ <Guardrail condition="SMALL_PAYLOAD">Если файл или ответ гарантированно мал (конфиги, мелкие JSON), `readFile` или `.json()` допустимы. Игнорировать.</Guardrail>
55
+ </Safety_Guardrails>
56
+ <Directive_Template>
57
+ "Игнорирование Backpressure. Замени чтение файла целиком на `fs.createReadStream` (или Web Streams). Для трансформации используй `stream.pipeline` или асинхронные итераторы `for await...of`."
58
+ </Directive_Template>
59
+ </Rule>
60
+ <!-- ПРАВИЛО 4: Утечки ресурсов при отмене (Missing Cancellation) -->
61
+ <Rule id="ASYNC_MISSING_CANCELLATION">
62
+ <Trigger_Signals>
63
+ - Вызовы `fetch()` без передачи `signal: AbortSignal`.
64
+ - Долгие асинхронные операции, которые не отменяются при размонтировании компонента или таймауте.
65
+ </Trigger_Signals>
66
+ <Performance_Mechanism>
67
+ Если пользователь ушел со страницы (или запрос отменен логикой), а `fetch` продолжает скачивать данные, это тратит трафик, батарею и CPU. Неотмененные промисы держат в памяти замыкания (Memory Leak).
68
+ </Performance_Mechanism>
69
+ <Safety_Guardrails>
70
+ <Guardrail condition="FIRE_AND_FORGET">Если запрос обязан завершиться на сервере в любом случае (например, отправка аналитики или логов), отмена не нужна. Игнорировать.</Guardrail>
71
+ </Safety_Guardrails>
72
+ <Directive_Template>
73
+ "Отсутствует механизм отмены. Создай `new AbortController()`, передай его `signal` в `fetch` и вызови `.abort()` в функции очистки (cleanup) или по таймауту."
74
+ </Directive_Template>
75
+ </Rule>
76
+ <!-- ПРАВИЛО 5: Шторм повторов и высокочастотные события (Retry Storm / Flooding) -->
77
+ <Rule id="ASYNC_HIGH_FREQUENCY_FLOOD">
78
+ <Trigger_Signals>
79
+ - `catch` блок внутри цикла с немедленным повторным вызовом `await` (retry без задержки).
80
+ - Подписки на события `scroll`, `mousemove`, `resize` без использования debounce/throttle.
81
+ - `setInterval` с очень коротким таймингом для поллинга сервера.
82
+ </Trigger_Signals>
83
+ <Performance_Mechanism>
84
+ Синхронные или высокочастотные ретраи при падении сервиса создают лавинообразную нагрузку (Retry Storm), окончательно убивая сервер. Обработка каждого пикселя скролла вызывает Layout Thrashing и роняет FPS до нуля.
85
+ </Performance_Mechanism>
86
+ <Safety_Guardrails>
87
+ <Guardrail condition="ANIMATION_FRAME">Если подписка идет через `requestAnimationFrame` для плавной отрисовки, throttle может испортить анимацию. Игнорировать.</Guardrail>
88
+ </Safety_Guardrails>
89
+ <Directive_Template>
90
+ "Высокочастотный флуд. Для поллинга/ретраев: добавь экспоненциальную задержку (Exponential Backoff). Для UI-событий: оберни обработчик в функцию `throttle` или `debounce`."
91
+ </Directive_Template>
92
+ </Rule>
93
+ </Rules_Registry>
94
+ <Verification_Protocol>
95
+ При получении сигнала от Оркестратора:
96
+ 1. Найди `<Rule>`.
97
+ 2. Жестко проверь `<Guardrail>`. В правиле `ASYNC_SEQUENTIAL_AWAIT` критически важно убедиться в ОТСУТСТВИИ зависимости данных между вызовами. Если есть малейшее подозрение на зависимость — отбрось триггер.
98
+ 3. Зафиксируй логику в `<Verification_Log>`.
99
+ 4. Сформируй приказ для DevAgent через `<Directive_Template>`.
100
+ </Verification_Protocol>
101
+ </Rulebook>