ada-agent 0.1.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 (339) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +256 -0
  3. package/bench/README.md +88 -0
  4. package/bench/swebench.mjs +242 -0
  5. package/bin/ada-server.mjs +6 -0
  6. package/bin/ada.mjs +7 -0
  7. package/docs/agent-loop.svg +66 -0
  8. package/docs/architecture.md +139 -0
  9. package/docs/architecture.svg +73 -0
  10. package/docs/connectors.md +48 -0
  11. package/docs/integrations.md +59 -0
  12. package/docs/login-flow.svg +56 -0
  13. package/docs/orchestration.md +45 -0
  14. package/package.json +64 -0
  15. package/skills/accessibility/SKILL.md +23 -0
  16. package/skills/add-logging/SKILL.md +23 -0
  17. package/skills/add-metrics/SKILL.md +23 -0
  18. package/skills/adr/SKILL.md +24 -0
  19. package/skills/aesthetic-direction/SKILL.md +24 -0
  20. package/skills/agent-loop/SKILL.md +23 -0
  21. package/skills/alerting/SKILL.md +23 -0
  22. package/skills/alpha-compositing/SKILL.md +23 -0
  23. package/skills/android-compose/SKILL.md +23 -0
  24. package/skills/angular-module/SKILL.md +23 -0
  25. package/skills/ansible-playbook/SKILL.md +24 -0
  26. package/skills/api-docs/SKILL.md +24 -0
  27. package/skills/app-store-prep/SKILL.md +23 -0
  28. package/skills/architecture-diagram/SKILL.md +21 -0
  29. package/skills/architecture-doc/SKILL.md +24 -0
  30. package/skills/audit-log/SKILL.md +23 -0
  31. package/skills/authz-review/SKILL.md +23 -0
  32. package/skills/aws-lambda/SKILL.md +24 -0
  33. package/skills/bash-script/SKILL.md +23 -0
  34. package/skills/batch/SKILL.md +23 -0
  35. package/skills/bisect/SKILL.md +23 -0
  36. package/skills/bounding-box/SKILL.md +24 -0
  37. package/skills/branch-cleanup/SKILL.md +23 -0
  38. package/skills/bundle-analyze/SKILL.md +23 -0
  39. package/skills/cache/SKILL.md +23 -0
  40. package/skills/call-graph/SKILL.md +23 -0
  41. package/skills/canvas-debug/SKILL.md +23 -0
  42. package/skills/cdn-setup/SKILL.md +23 -0
  43. package/skills/changelog/SKILL.md +24 -0
  44. package/skills/cherry-pick/SKILL.md +23 -0
  45. package/skills/ci-setup/SKILL.md +23 -0
  46. package/skills/cleanup/SKILL.md +23 -0
  47. package/skills/cli-tool/SKILL.md +23 -0
  48. package/skills/cloudformation/SKILL.md +23 -0
  49. package/skills/code-examples/SKILL.md +24 -0
  50. package/skills/code-review/SKILL.md +23 -0
  51. package/skills/color-palette/SKILL.md +24 -0
  52. package/skills/color-space/SKILL.md +24 -0
  53. package/skills/comment-why/SKILL.md +23 -0
  54. package/skills/commit/SKILL.md +26 -0
  55. package/skills/complexity-audit/SKILL.md +23 -0
  56. package/skills/component/SKILL.md +23 -0
  57. package/skills/component-library/SKILL.md +23 -0
  58. package/skills/connect-github/SKILL.md +20 -0
  59. package/skills/connect-mcp/SKILL.md +21 -0
  60. package/skills/connect-postgres/SKILL.md +20 -0
  61. package/skills/connect-remote/SKILL.md +23 -0
  62. package/skills/connect-slack/SKILL.md +20 -0
  63. package/skills/contract-audit/SKILL.md +25 -0
  64. package/skills/contributing/SKILL.md +23 -0
  65. package/skills/cpp-raii/SKILL.md +23 -0
  66. package/skills/cron-job/SKILL.md +23 -0
  67. package/skills/cv-preprocess/SKILL.md +24 -0
  68. package/skills/dark-mode/SKILL.md +24 -0
  69. package/skills/dashboard/SKILL.md +23 -0
  70. package/skills/dashboard-ui/SKILL.md +23 -0
  71. package/skills/data-export/SKILL.md +23 -0
  72. package/skills/data-validation/SKILL.md +23 -0
  73. package/skills/dataframe/SKILL.md +23 -0
  74. package/skills/db-index/SKILL.md +24 -0
  75. package/skills/dead-code/SKILL.md +23 -0
  76. package/skills/debug/SKILL.md +24 -0
  77. package/skills/deck-review/SKILL.md +24 -0
  78. package/skills/dedupe/SKILL.md +23 -0
  79. package/skills/dedupe-deps/SKILL.md +23 -0
  80. package/skills/dependency-audit/SKILL.md +23 -0
  81. package/skills/dependency-update/SKILL.md +23 -0
  82. package/skills/deploy/SKILL.md +23 -0
  83. package/skills/design-system/SKILL.md +24 -0
  84. package/skills/design-tokens/SKILL.md +24 -0
  85. package/skills/diagram-as-code/SKILL.md +24 -0
  86. package/skills/diff-explain/SKILL.md +23 -0
  87. package/skills/django-view/SKILL.md +23 -0
  88. package/skills/doc-lint/SKILL.md +24 -0
  89. package/skills/docker-compose/SKILL.md +23 -0
  90. package/skills/dockerize/SKILL.md +23 -0
  91. package/skills/docstrings/SKILL.md +23 -0
  92. package/skills/dotfiles/SKILL.md +23 -0
  93. package/skills/dpi-scaling/SKILL.md +23 -0
  94. package/skills/e2e-test/SKILL.md +23 -0
  95. package/skills/embeddings/SKILL.md +23 -0
  96. package/skills/empty-states/SKILL.md +23 -0
  97. package/skills/env-setup/SKILL.md +23 -0
  98. package/skills/erc20/SKILL.md +24 -0
  99. package/skills/error-tracking/SKILL.md +23 -0
  100. package/skills/estimate/SKILL.md +23 -0
  101. package/skills/etl-pipeline/SKILL.md +24 -0
  102. package/skills/eval-harness/SKILL.md +23 -0
  103. package/skills/exif-orientation/SKILL.md +23 -0
  104. package/skills/explain-code/SKILL.md +23 -0
  105. package/skills/express-middleware/SKILL.md +23 -0
  106. package/skills/extract-function/SKILL.md +23 -0
  107. package/skills/faq/SKILL.md +24 -0
  108. package/skills/fastapi-endpoint/SKILL.md +23 -0
  109. package/skills/favicon/SKILL.md +23 -0
  110. package/skills/feature-engineering/SKILL.md +23 -0
  111. package/skills/few-shot/SKILL.md +23 -0
  112. package/skills/find-owner/SKILL.md +23 -0
  113. package/skills/firmware-driver/SKILL.md +23 -0
  114. package/skills/fix-flaky-tests/SKILL.md +23 -0
  115. package/skills/flutter-widget/SKILL.md +23 -0
  116. package/skills/font-rendering/SKILL.md +23 -0
  117. package/skills/form-validation/SKILL.md +23 -0
  118. package/skills/format/SKILL.md +23 -0
  119. package/skills/game-loop/SKILL.md +23 -0
  120. package/skills/gas-optimize/SKILL.md +25 -0
  121. package/skills/gdpr-review/SKILL.md +24 -0
  122. package/skills/github-actions/SKILL.md +23 -0
  123. package/skills/glossary/SKILL.md +24 -0
  124. package/skills/go-idioms/SKILL.md +23 -0
  125. package/skills/gpu-profile/SKILL.md +23 -0
  126. package/skills/graphify/SKILL.md +21 -0
  127. package/skills/graphql-resolver/SKILL.md +23 -0
  128. package/skills/grpc-service/SKILL.md +23 -0
  129. package/skills/guardrails/SKILL.md +23 -0
  130. package/skills/healthcheck/SKILL.md +23 -0
  131. package/skills/heisenbug/SKILL.md +23 -0
  132. package/skills/helm-chart/SKILL.md +24 -0
  133. package/skills/hero-section/SKILL.md +23 -0
  134. package/skills/html-email/SKILL.md +24 -0
  135. package/skills/html-form/SKILL.md +23 -0
  136. package/skills/html-sanitize/SKILL.md +23 -0
  137. package/skills/html-table/SKILL.md +23 -0
  138. package/skills/html-to-pdf/SKILL.md +23 -0
  139. package/skills/http-client/SKILL.md +23 -0
  140. package/skills/i18n/SKILL.md +23 -0
  141. package/skills/i2c-spi/SKILL.md +23 -0
  142. package/skills/image-decode/SKILL.md +24 -0
  143. package/skills/image-memory/SKILL.md +24 -0
  144. package/skills/image-perf/SKILL.md +24 -0
  145. package/skills/image-pipeline/SKILL.md +24 -0
  146. package/skills/image-upload/SKILL.md +24 -0
  147. package/skills/infra-cost/SKILL.md +24 -0
  148. package/skills/input-validation/SKILL.md +23 -0
  149. package/skills/issue-template/SKILL.md +23 -0
  150. package/skills/java-streams/SKILL.md +23 -0
  151. package/skills/k8s-manifest/SKILL.md +23 -0
  152. package/skills/kotlin-coroutines/SKILL.md +23 -0
  153. package/skills/landing-page/SKILL.md +24 -0
  154. package/skills/laravel-controller/SKILL.md +23 -0
  155. package/skills/lazy-load/SKILL.md +23 -0
  156. package/skills/license-check/SKILL.md +23 -0
  157. package/skills/license-header/SKILL.md +23 -0
  158. package/skills/lint-fix/SKILL.md +23 -0
  159. package/skills/llm-cost/SKILL.md +23 -0
  160. package/skills/lockfile-fix/SKILL.md +23 -0
  161. package/skills/low-power/SKILL.md +23 -0
  162. package/skills/makefile/SKILL.md +23 -0
  163. package/skills/man-page/SKILL.md +24 -0
  164. package/skills/mcp-server/SKILL.md +23 -0
  165. package/skills/memory-leak/SKILL.md +23 -0
  166. package/skills/mermaid-diagram/SKILL.md +23 -0
  167. package/skills/meta-tags/SKILL.md +23 -0
  168. package/skills/micro-interactions/SKILL.md +23 -0
  169. package/skills/migration/SKILL.md +23 -0
  170. package/skills/migration-guide/SKILL.md +24 -0
  171. package/skills/mkdocs-setup/SKILL.md +24 -0
  172. package/skills/mobile-permissions/SKILL.md +23 -0
  173. package/skills/mock-api/SKILL.md +23 -0
  174. package/skills/modernize/SKILL.md +23 -0
  175. package/skills/monorepo-setup/SKILL.md +23 -0
  176. package/skills/motion-design/SKILL.md +23 -0
  177. package/skills/n-plus-one/SKILL.md +23 -0
  178. package/skills/naming-review/SKILL.md +23 -0
  179. package/skills/nextjs-route/SKILL.md +23 -0
  180. package/skills/nginx-config/SKILL.md +23 -0
  181. package/skills/ocr-debug/SKILL.md +24 -0
  182. package/skills/onboard/SKILL.md +23 -0
  183. package/skills/onboarding-map/SKILL.md +23 -0
  184. package/skills/open-pr/SKILL.md +24 -0
  185. package/skills/openapi/SKILL.md +23 -0
  186. package/skills/opencv-debug/SKILL.md +24 -0
  187. package/skills/orm-model/SKILL.md +23 -0
  188. package/skills/owasp-check/SKILL.md +24 -0
  189. package/skills/page-transitions/SKILL.md +23 -0
  190. package/skills/pagination/SKILL.md +23 -0
  191. package/skills/perf-optimize/SKILL.md +23 -0
  192. package/skills/perf-profile/SKILL.md +23 -0
  193. package/skills/physics/SKILL.md +23 -0
  194. package/skills/pitch-deck/SKILL.md +24 -0
  195. package/skills/pixel-diff/SKILL.md +23 -0
  196. package/skills/ponytail/SKILL.md +46 -0
  197. package/skills/postmortem/SKILL.md +24 -0
  198. package/skills/pptx-deck/SKILL.md +23 -0
  199. package/skills/pptx-export/SKILL.md +23 -0
  200. package/skills/pptx-from-markdown/SKILL.md +23 -0
  201. package/skills/pptx-template/SKILL.md +24 -0
  202. package/skills/pr-review/SKILL.md +24 -0
  203. package/skills/precommit/SKILL.md +23 -0
  204. package/skills/pricing-page/SKILL.md +23 -0
  205. package/skills/project-overview/SKILL.md +22 -0
  206. package/skills/prompt-template/SKILL.md +23 -0
  207. package/skills/property-test/SKILL.md +23 -0
  208. package/skills/protobuf/SKILL.md +23 -0
  209. package/skills/py-async/SKILL.md +23 -0
  210. package/skills/py-typing/SKILL.md +23 -0
  211. package/skills/query-optimize/SKILL.md +23 -0
  212. package/skills/rag-pipeline/SKILL.md +23 -0
  213. package/skills/rails-resource/SKILL.md +23 -0
  214. package/skills/rate-limit/SKILL.md +23 -0
  215. package/skills/react-hooks/SKILL.md +23 -0
  216. package/skills/react-native-screen/SKILL.md +23 -0
  217. package/skills/react-perf/SKILL.md +23 -0
  218. package/skills/readme/SKILL.md +24 -0
  219. package/skills/rebase/SKILL.md +24 -0
  220. package/skills/refactor/SKILL.md +23 -0
  221. package/skills/regression-test/SKILL.md +23 -0
  222. package/skills/release-notes/SKILL.md +24 -0
  223. package/skills/rename-symbol/SKILL.md +23 -0
  224. package/skills/repro/SKILL.md +23 -0
  225. package/skills/resolve-conflicts/SKILL.md +23 -0
  226. package/skills/responsive/SKILL.md +23 -0
  227. package/skills/rest-endpoint/SKILL.md +23 -0
  228. package/skills/retro/SKILL.md +23 -0
  229. package/skills/rtos-task/SKILL.md +23 -0
  230. package/skills/runbook/SKILL.md +25 -0
  231. package/skills/rust-borrow/SKILL.md +23 -0
  232. package/skills/rust-unsafe-audit/SKILL.md +23 -0
  233. package/skills/sanitize/SKILL.md +23 -0
  234. package/skills/schema-design/SKILL.md +23 -0
  235. package/skills/screenshot-debug/SKILL.md +22 -0
  236. package/skills/scroll-animation/SKILL.md +23 -0
  237. package/skills/secret-scan/SKILL.md +23 -0
  238. package/skills/security-audit/SKILL.md +23 -0
  239. package/skills/security-review/SKILL.md +23 -0
  240. package/skills/seed-data/SKILL.md +23 -0
  241. package/skills/self-review/SKILL.md +23 -0
  242. package/skills/semantic-html/SKILL.md +23 -0
  243. package/skills/semver-bump/SKILL.md +24 -0
  244. package/skills/shader/SKILL.md +23 -0
  245. package/skills/shader-debug/SKILL.md +23 -0
  246. package/skills/simplify-conditionals/SKILL.md +23 -0
  247. package/skills/sitemap/SKILL.md +23 -0
  248. package/skills/skeleton-loader/SKILL.md +23 -0
  249. package/skills/slide-charts/SKILL.md +24 -0
  250. package/skills/slide-outline/SKILL.md +23 -0
  251. package/skills/snapshot-update/SKILL.md +23 -0
  252. package/skills/solidity-contract/SKILL.md +25 -0
  253. package/skills/speaker-notes/SKILL.md +23 -0
  254. package/skills/spike/SKILL.md +23 -0
  255. package/skills/split-file/SKILL.md +23 -0
  256. package/skills/spring-controller/SKILL.md +23 -0
  257. package/skills/sprite-anim/SKILL.md +23 -0
  258. package/skills/sql-report/SKILL.md +23 -0
  259. package/skills/squash/SKILL.md +24 -0
  260. package/skills/ssl-setup/SKILL.md +23 -0
  261. package/skills/stacktrace/SKILL.md +23 -0
  262. package/skills/static-site/SKILL.md +24 -0
  263. package/skills/structured-logging/SKILL.md +23 -0
  264. package/skills/svelte-store/SKILL.md +23 -0
  265. package/skills/swiftui-view/SKILL.md +23 -0
  266. package/skills/tailwind-theme/SKILL.md +24 -0
  267. package/skills/tcp-server/SKILL.md +23 -0
  268. package/skills/tdd/SKILL.md +23 -0
  269. package/skills/terraform-module/SKILL.md +24 -0
  270. package/skills/test-coverage/SKILL.md +23 -0
  271. package/skills/texture-debug/SKILL.md +23 -0
  272. package/skills/threat-model/SKILL.md +23 -0
  273. package/skills/thumbnail/SKILL.md +24 -0
  274. package/skills/todo-scan/SKILL.md +23 -0
  275. package/skills/tool-definition/SKILL.md +23 -0
  276. package/skills/trace-flow/SKILL.md +23 -0
  277. package/skills/tracing/SKILL.md +23 -0
  278. package/skills/train-model/SKILL.md +24 -0
  279. package/skills/tree-shake/SKILL.md +23 -0
  280. package/skills/ts-generics/SKILL.md +23 -0
  281. package/skills/ts-strict/SKILL.md +23 -0
  282. package/skills/tui-app/SKILL.md +23 -0
  283. package/skills/tutorial/SKILL.md +24 -0
  284. package/skills/type-tighten/SKILL.md +23 -0
  285. package/skills/typography/SKILL.md +24 -0
  286. package/skills/ui-bug-repro/SKILL.md +23 -0
  287. package/skills/ui-polish/SKILL.md +24 -0
  288. package/skills/ui-review/SKILL.md +24 -0
  289. package/skills/vendor/SKILL.md +23 -0
  290. package/skills/visual-diff-ci/SKILL.md +24 -0
  291. package/skills/visual-regression/SKILL.md +23 -0
  292. package/skills/vue-composition/SKILL.md +23 -0
  293. package/skills/web-component/SKILL.md +23 -0
  294. package/skills/web-fonts/SKILL.md +24 -0
  295. package/skills/web3-frontend/SKILL.md +25 -0
  296. package/skills/webgl-debug/SKILL.md +23 -0
  297. package/skills/webhook/SKILL.md +23 -0
  298. package/skills/websocket/SKILL.md +23 -0
  299. package/skills/write-tests/SKILL.md +19 -0
  300. package/src/client/agent.ts +803 -0
  301. package/src/client/background.ts +39 -0
  302. package/src/client/checkpoint.ts +48 -0
  303. package/src/client/cli.ts +1253 -0
  304. package/src/client/compaction.ts +86 -0
  305. package/src/client/extensions.ts +83 -0
  306. package/src/client/hooks.ts +40 -0
  307. package/src/client/image.ts +26 -0
  308. package/src/client/lsp.ts +0 -0
  309. package/src/client/mcp.ts +276 -0
  310. package/src/client/models-dev.ts +52 -0
  311. package/src/client/pkg.ts +41 -0
  312. package/src/client/platform.ts +94 -0
  313. package/src/client/prompts.ts +47 -0
  314. package/src/client/render.ts +138 -0
  315. package/src/client/session.ts +107 -0
  316. package/src/client/settings.ts +86 -0
  317. package/src/client/skill-router.ts +79 -0
  318. package/src/client/skills.ts +199 -0
  319. package/src/client/snapshot.ts +56 -0
  320. package/src/client/telemetry.ts +24 -0
  321. package/src/client/todos.ts +23 -0
  322. package/src/client/tools.ts +756 -0
  323. package/src/client/tui-mode.ts +41 -0
  324. package/src/client/tui.ts +224 -0
  325. package/src/sdk/index.ts +36 -0
  326. package/src/selfcheck.ts +364 -0
  327. package/src/server/config.ts +58 -0
  328. package/src/server/credentials.ts +89 -0
  329. package/src/server/identity.ts +58 -0
  330. package/src/server/index.ts +113 -0
  331. package/src/server/oauth.ts +93 -0
  332. package/src/server/providers/adapter.ts +25 -0
  333. package/src/server/providers/anthropic.ts +189 -0
  334. package/src/server/providers/openai-compat.ts +76 -0
  335. package/src/server/providers/registry.ts +31 -0
  336. package/src/server/router.ts +29 -0
  337. package/src/server/sse.ts +20 -0
  338. package/src/shared/types.ts +20 -0
  339. package/tsconfig.json +15 -0
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: visual-diff-ci
3
+ description: Wire visual regression into CI with stable rendering, diff artifacts, and tuned tolerance thresholds
4
+ category: visual-test
5
+ ---
6
+
7
+ # Visual Diff CI
8
+
9
+ Reach for this when screenshot tests pass locally but flake or fail in CI, or when you're adding visual checks to a pipeline for the first time.
10
+
11
+ 1. Pin the render environment: same browser/engine version, fonts, OS image, and a fixed DPR/viewport — bake it into a container so local == CI.
12
+ 2. Generate baselines INSIDE that container (or via the test runner's Docker image), never from a developer laptop, or you'll diff against the wrong font hinting.
13
+ 3. On every run, upload the three images per failing case — baseline, actual, diff — as CI artifacts so a reviewer can see the regression without rerunning.
14
+ 4. Tune two thresholds: per-pixel color tolerance (absorbs AA) and a max changed-pixel ratio (gates real changes); start strict, loosen only on proven flake.
15
+ 5. Make baseline updates an explicit, reviewable step (a labeled job or committed `--update-snapshots` PR), never an auto-overwrite on failure.
16
+ 6. Quarantine and fix flaky cases — disable animations, mock clocks/network, hide carets/scrollbars — rather than raising the threshold to hide them.
17
+
18
+ ## Rules
19
+ - Local-vs-CI font/AA mismatch is the top cause of CI-only flake; containerize rendering before touching thresholds.
20
+ - Always publish the diff image as an artifact — a red "visual test failed" with no picture is useless to reviewers.
21
+ - Never auto-update baselines on failure; that turns the gate into a rubber stamp.
22
+ - Loosening tolerance to silence flake hides real regressions — fix determinism instead.
23
+ - Shard/parallelize deterministically; non-deterministic data ordering produces phantom diffs.
24
+ - Keep baselines in-repo (or LFS) and tied to the commit, so a checkout reproduces the exact expected state.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: visual-regression
3
+ description: Baseline and pixel-diff screenshots so a UI change can't silently regress an unrelated view
4
+ category: visual-test
5
+ ---
6
+
7
+ # Visual Regression
8
+
9
+ Reach for this when a code change "shouldn't touch the UI" but you need proof, or when a regression slipped through and you want a net under it.
10
+
11
+ 1. Establish baselines from a known-good commit: render each target state to a deterministic PNG and commit those under `__snapshots__/` (or your tool's baseline dir).
12
+ 2. Make the change, re-render the same states with identical viewport/DPR/theme, and pixel-diff each new shot against its baseline.
13
+ 3. For every diff, open the highlighted-diff image: confirm whether the delta is the *intended* change or a *collateral* regression.
14
+ 4. If intended, update the baseline deliberately (`--update-snapshots`) and review the new PNG in the diff before committing it.
15
+ 5. If unintended, fix the code and re-run until only the expected states differ.
16
+ 6. Lock in determinism (frozen time, disabled animations, mocked data, fixed fonts) so reruns are byte-stable.
17
+
18
+ ## Rules
19
+ - Treat baselines as source: review every snapshot update in the PR like code; a blind `--update-all` defeats the entire net.
20
+ - Render in the SAME environment as CI (font rendering, GPU/SwiftShader, OS) or you get diffs from anti-aliasing, not bugs — see visual-diff-ci.
21
+ - Mock everything non-deterministic: clocks, random, network, animations, carets, scrollbars.
22
+ - Set a small per-pixel + total-diff tolerance to absorb sub-pixel AA, but keep it tight enough to catch a 1px shift.
23
+ - One state per snapshot — giant full-page baselines make every diff ambiguous and every update a rubber-stamp.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: vue-composition
3
+ description: Migrate a Vue Options API component to the Composition API with script setup
4
+ category: frameworks
5
+ ---
6
+
7
+ # Vue Composition
8
+
9
+ Use when converting a Vue 2/3 Options API component to `<script setup>` with the Composition API, keeping reactivity and lifecycle behavior intact.
10
+
11
+ 1. Replace the Options block with `<script setup>`; declare `defineProps` and `defineEmits` for the component's props and events.
12
+ 2. Convert each `data()` field to `ref()` (primitives) or `reactive()` (objects); access `.value` for refs in script.
13
+ 3. Turn `computed` options into `computed(() => ...)` and `watch`/`watchEffect` for the watchers.
14
+ 4. Move `methods` to plain functions in setup; map lifecycle hooks (`mounted` → `onMounted`, `beforeUnmount` → `onBeforeUnmount`, etc.).
15
+ 5. Extract reusable logic into composables (`useXxx()` functions returning refs) instead of mixins.
16
+ 6. Run the app; verify reactivity (template updates), emitted events, and that hooks fire in order.
17
+
18
+ ## Rules
19
+ - In the template, refs auto-unwrap — don't write `.value` there; in script you must.
20
+ - Destructuring a `reactive` object breaks reactivity; use `toRefs` if you need to spread it.
21
+ - `defineProps`/`defineEmits` are compiler macros — don't import them; they only work in `<script setup>`.
22
+ - Replace `this.$emit` with the function returned by `defineEmits`, and `this.$refs` with template `ref()`.
23
+ - Prefer composables over mixins; keep each composable focused on one concern and return only what's needed.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: web-component
3
+ description: Build a reusable custom element with Shadow DOM, attributes/properties, slots, and events using web standards.
4
+ category: html
5
+ ---
6
+
7
+ # Web Component
8
+
9
+ Use when you need a framework-agnostic, encapsulated UI element (design-system widget, embeddable badge) that works in any page or framework.
10
+
11
+ 1. Define a class extending `HTMLElement`, register it with `customElements.define('my-thing', MyThing)`, and use a hyphenated name (required for custom elements).
12
+ 2. Attach Shadow DOM in the constructor (`this.attachShadow({mode:'open'})`) so styles and markup are encapsulated and don't leak in or out.
13
+ 3. Render markup + scoped `<style>` into the shadow root; expose insertion points with `<slot>` (and named slots) for light-DOM content.
14
+ 4. Wire reactivity: list reflected attributes in `static observedAttributes`, react in `attributeChangedCallback`, and mirror important attrs to properties (getters/setters).
15
+ 5. Manage lifecycle in `connectedCallback`/`disconnectedCallback` — add listeners on connect, remove on disconnect to avoid leaks.
16
+ 6. Communicate outward with `dispatchEvent(new CustomEvent('change',{detail,bubbles:true,composed:true}))` so events cross the shadow boundary; expose theming via CSS custom properties and `::part()`.
17
+
18
+ ## Rules
19
+ - Tag names must contain a hyphen and be unique; registering the same name twice throws.
20
+ - Don't touch the DOM in the constructor (element may not be connected) — defer to `connectedCallback`.
21
+ - Use `composed:true` on CustomEvents that must escape the shadow root, and `bubbles:true` to propagate.
22
+ - Expose styling hooks via CSS custom properties / `::part()`; consumers can't reach inside closed Shadow DOM otherwise.
23
+ - Always remove event listeners and observers in `disconnectedCallback` to prevent memory leaks.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: web-fonts
3
+ description: Load and pair web fonts performantly — subset, preload, self-host, and avoid FOUT/FOIT and layout shift
4
+ category: ui-design
5
+ ---
6
+
7
+ # Web Fonts
8
+
9
+ Use this when adding or fixing custom fonts so they look right *and* load fast. Fonts are often a page's heaviest render-blocking asset and a top cause of layout shift.
10
+
11
+ 1. Prefer variable fonts in `woff2` only — one file covers all weights, drops requests, and `woff2` is the smallest format every modern browser supports.
12
+ 2. Self-host instead of linking Google Fonts: it removes a third-party round-trip and the privacy/consent overhead, and lets you control caching and `font-display`.
13
+ 3. Subset aggressively — strip to the scripts/glyphs you use (e.g. latin + latin-ext) with `glyphhanger`/`fonttools`; a full font can shrink 70%+, cutting first paint.
14
+ 4. `preload` the one or two critical fonts (the body and primary heading face) with `<link rel="preload" as="font" type="font/woff2" crossorigin>`; don't preload every weight.
15
+ 5. Set `font-display: swap` to render text immediately in a fallback, then tune the fallback metrics with `size-adjust`, `ascent-override`, and `descent-override` (or Next/Fontsource defaults) so the swap causes near-zero CLS.
16
+ 6. Define a real fallback stack matched in metrics to the web font (`"Inter", system-ui, sans-serif`) so the pre-swap render already looks close.
17
+ 7. Measure: confirm in DevTools that fonts are `woff2`, preloaded, swapped, and that the layout-shift score stays near zero after they load.
18
+
19
+ ## Rules
20
+ - `woff2` only, variable font when available; never serve `ttf`/`otf`/multiple static weights.
21
+ - Self-host critical fonts; reserve external CDNs for non-critical or fallback cases.
22
+ - Preload only the 1–2 above-the-fold faces — preloading everything defeats the purpose.
23
+ - `font-display: swap` plus metric-overridden fallbacks to keep CLS ≈ 0.
24
+ - Subset to the glyphs you actually render; ship no unused scripts.
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: web3-frontend
3
+ description: Wire a dapp frontend to contracts with wagmi/viem (or ethers) for wallet, reads, and writes
4
+ category: web3
5
+ ---
6
+
7
+ # Web3 Frontend
8
+
9
+ Use when connecting a React/Next dapp to on-chain contracts. Prefer wagmi + viem for typed, hook-based access; ethers is the fallback.
10
+
11
+ 1. Install and configure: `wagmi`, `viem`, and a connector kit (RainbowKit/ConnectKit); define `chains`, transports (RPC URLs from env), and wrap the app in `WagmiProvider` + a React Query client.
12
+ 2. Handle connection: render a connect button, read account/chain via `useAccount`/`useChainId`, and prompt a network switch when the wrong chain is active.
13
+ 3. Load typed ABIs: import the contract ABI `as const` so viem infers argument and return types.
14
+ 4. Read state with `useReadContract`/`useReadContracts`; batch related reads and key cache invalidation on the relevant block/account.
15
+ 5. Send transactions with `useWriteContract` + `useWaitForTransactionReceipt`; surface pending → confirmed → error states in the UI.
16
+ 6. Decode reverts and events into human-readable messages; format token amounts with `formatUnits`/`parseUnits` using the token's decimals.
17
+ 7. Test against a local fork/testnet (Anvil/Hardhat) before pointing at mainnet.
18
+
19
+ ## Rules
20
+ - Never hardcode private keys or seed phrases in frontend code — the wallet signs, the app never holds keys.
21
+ - Put RPC URLs and API keys in env vars and proxy paid RPC through a backend to avoid leaking quota.
22
+ - Always check `chainId` and the connected account before a write; guard against wrong-network sends.
23
+ - Use `parseUnits`/`formatUnits` with correct decimals; never do token math in floats.
24
+ - Show explicit loading/pending/error states — transactions are async and can fail or be dropped.
25
+ - Validate addresses (`isAddress`) and handle user rejection (code 4001) gracefully.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: webgl-debug
3
+ description: Debug WebGL/GPU rendering: blank canvas, context loss, bad buffers/attributes, silent draw-call failures
4
+ category: graphics
5
+ ---
6
+
7
+ # WebGL Debug
8
+
9
+ Reach for this when a WebGL scene renders black, flickers, or draws nothing despite "no errors" — the API fails silently, so you must instrument it.
10
+
11
+ 1. Check the context exists and isn't lost: confirm `gl = canvas.getContext('webgl2'||'webgl')` is non-null and listen for `webglcontextlost`. A null context usually means a prior context leak or an unsupported feature.
12
+ 2. Add `gl.getError()` after every meaningful call during bring-up (or wrap with a debug proxy). Hunt the first non-`NO_ERROR`; `INVALID_OPERATION` after a draw call almost always means an unbound buffer or mismatched attribute.
13
+ 3. Verify program linkage: check `gl.getProgramParameter(prog, gl.LINK_STATUS)` and `getShaderParameter(...COMPILE_STATUS)`, and print `getProgramInfoLog`/`getShaderInfoLog` — compile errors are otherwise swallowed.
14
+ 4. Audit the draw-call preconditions: program `useProgram`'d, VAO/attributes enabled with correct stride/offset/type, uniforms set after `useProgram`, viewport set via `gl.viewport(0,0,w,h)`, and the buffer actually has data (`bufferData` length > 0).
15
+ 5. Isolate: clear to a bright color (`clearColor(1,0,1,1); clear(...)`). If you don't even see magenta, it's context/viewport/canvas sizing — not your geometry.
16
+ 6. For black geometry that's clearly drawing, suspect depth test (everything failing depth, near/far swapped), culling (`CULL_FACE` with reversed winding), or NaN in the MVP matrix collapsing all verts to one point.
17
+
18
+ ## Rules
19
+ - Set uniforms and bind textures only AFTER `gl.useProgram`; before that they target the wrong/no program.
20
+ - `gl.viewport` does not auto-update on canvas resize — set it whenever the drawing buffer size changes.
21
+ - Always handle `webglcontextlost`/`restored`; GPU resets (tab background, driver hiccup) invalidate all buffers and textures.
22
+ - Attribute `stride`/`offset` are in bytes; getting the type or stride wrong reads garbage with no error.
23
+ - Use a magenta clear as the canary — it instantly separates "nothing draws" from "geometry is wrong".
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: webhook
3
+ description: Implement a webhook receiver with signature verification and idempotency
4
+ category: api
5
+ ---
6
+
7
+ # Webhook
8
+
9
+ Use when accepting inbound webhooks from a third party (Stripe, GitHub, etc.) — you must verify authenticity and process safely.
10
+
11
+ 1. Capture the raw request body before any JSON parsing — signature verification needs the exact bytes, not a re-serialized object.
12
+ 2. Read the signature header and shared secret, recompute the HMAC, and compare with a constant-time check; reject with 401 on mismatch.
13
+ 3. Reject stale events using the provider's timestamp (tolerance window) to block replay attacks.
14
+ 4. Deduplicate by the provider's event id so retries don't double-process — store seen ids or use a unique constraint.
15
+ 5. Acknowledge fast: return 2xx immediately and hand slow work to a queue/background job so the provider doesn't time out and retry.
16
+ 6. Test signature pass/fail, a replayed event, and a duplicate-id delivery.
17
+
18
+ ## Rules
19
+ - Never trust the payload until the signature verifies; verify against the raw body, framework body-parsers often mutate it.
20
+ - Use a constant-time comparison for signatures to avoid timing leaks; `==` on the digest is a vulnerability.
21
+ - Make handling idempotent — providers deliver at-least-once and will retry on any non-2xx or timeout.
22
+ - Return 2xx for accepted-but-unprocessed events; do real work async so a slow handler doesn't trigger redelivery storms.
23
+ - Keep the secret in env/secret storage, never in code, and scope it per-provider.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: websocket
3
+ description: Implement a WebSocket server or client with proper handshake, heartbeats, and reconnection
4
+ category: networking
5
+ ---
6
+
7
+ # WebSocket
8
+
9
+ Use for low-latency, bidirectional, long-lived connections (live feeds, chat, collaborative cursors). If the client only ever reads, prefer SSE; if it's request/response, prefer HTTP.
10
+
11
+ 1. Establish the connection: server upgrades the HTTP request (`Upgrade: websocket`), validating `Origin` and authenticating during the handshake (token in query/subprotocol, not after).
12
+ 2. Define a message protocol — pick JSON or binary, give every message a `type`, and version it so you can evolve the schema.
13
+ 3. Add ping/pong heartbeats on a timer; close connections that miss N pongs so dead peers and half-open NAT connections get reaped.
14
+ 4. On the client, implement reconnect with exponential backoff + jitter and resubscribe/replay state after reconnecting.
15
+ 5. Apply backpressure: bound the send queue per connection and drop or disconnect slow consumers instead of buffering unbounded.
16
+ 6. Handle clean shutdown — send a close frame with a status code, drain in-flight messages, and remove the connection from any registries.
17
+
18
+ ## Rules
19
+ - Always validate `Origin` (and auth) at handshake time; an open upgrade endpoint is a CSRF/abuse vector.
20
+ - Never trust message size — cap frame/message length and reject oversized payloads to avoid memory blowups.
21
+ - A WebSocket is not reliable delivery: design for dropped connections, duplicate messages on reconnect, and out-of-order resends.
22
+ - Use `wss://` in production; plain `ws://` breaks under TLS-terminating proxies and leaks tokens.
23
+ - Don't do heavy work in the read loop — hand messages to workers so one slow handler can't stall the socket.
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: write-tests
3
+ description: Write and run focused tests for a change — find the runner, add cases, run, report.
4
+ category: testing
5
+ ---
6
+
7
+ # Write tests
8
+
9
+ 1. **Detect the setup.** Check `package.json` `scripts.test`, or look for existing `*test*` / `*spec*` files and the framework in use (vitest, jest, mocha, pytest, `go test`, …). Match the project's existing style exactly.
10
+ 2. **Pick what to cover.** The change's happy path plus the edge cases that would actually break it: empty input, boundaries, error paths. Don't test trivial getters or framework code.
11
+ 3. **Write the tests** next to their siblings, following local conventions for naming, imports, and assertions.
12
+ 4. **Run them** with the project's command (`npm test`, `pytest -q`, `go test ./...`, …).
13
+ 5. **Report** pass/fail with the real output. If a test fails, decide whether the test or the code is wrong — never weaken a test just to make it pass.
14
+
15
+ ## Rules
16
+
17
+ - Cover the logic that would break, not every line. Minimal and meaningful.
18
+ - Don't add a new test framework unless the project has none and the user wants one.
19
+ - A test that can't fail is worthless — make sure each one would catch a real regression.