oneie 2.0.1 → 2.0.3

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 (406) hide show
  1. package/AGENTS.md +245 -0
  2. package/CLAUDE.md +534 -0
  3. package/README.md +61 -4
  4. package/one/.obsidian/app.json +1 -0
  5. package/one/.obsidian/appearance.json +1 -0
  6. package/one/.obsidian/core-plugins.json +33 -0
  7. package/one/.obsidian/workspace.json +211 -0
  8. package/one/connections/a2a.md +551 -0
  9. package/one/connections/acp.md +761 -0
  10. package/one/connections/acps.md +731 -0
  11. package/one/connections/agui.md +767 -0
  12. package/one/connections/any-backend.md +1702 -0
  13. package/one/connections/ap2.md +998 -0
  14. package/one/connections/api-docs.md +1891 -0
  15. package/one/connections/api.md +2190 -0
  16. package/one/connections/architecture-diagram.md +94 -0
  17. package/one/connections/communications.md +449 -0
  18. package/one/connections/connections.md +339 -0
  19. package/one/connections/cryptonetworks.md +781 -0
  20. package/one/connections/documentation.md +1120 -0
  21. package/one/connections/effect.md +279 -0
  22. package/one/connections/elizaos.md +1290 -0
  23. package/one/connections/inference.md +58 -0
  24. package/one/connections/kyc.md +632 -0
  25. package/one/connections/mcp.md +842 -0
  26. package/one/connections/membership.md +1152 -0
  27. package/one/connections/middleware.md +1067 -0
  28. package/one/connections/multitenant.md +1341 -0
  29. package/one/connections/n8n.md +1015 -0
  30. package/one/connections/patterns.md +89 -0
  31. package/one/connections/protocols.md +279 -0
  32. package/one/connections/relationships.md +107 -0
  33. package/one/connections/schema.md +587 -0
  34. package/one/connections/service-layer.md +550 -0
  35. package/one/connections/structure.md +0 -0
  36. package/one/connections/vectors.md +207 -0
  37. package/one/connections/wordpress.md +1302 -0
  38. package/one/connections/workflow-copy.md +905 -0
  39. package/one/connections/workflow-examples.md +741 -0
  40. package/one/connections/workflow.md +905 -0
  41. package/one/connections/workflows/delegation.md +885 -0
  42. package/one/connections/workflows/frontend.md +1037 -0
  43. package/one/connections/workflows/strategy.md +903 -0
  44. package/one/connections/workflows/tasks.md +698 -0
  45. package/one/connections/x402.md +1249 -0
  46. package/one/events/events.md +545 -0
  47. package/one/knowledge/ai-platform.md +305 -0
  48. package/one/knowledge/architecture-diagram.md +94 -0
  49. package/one/knowledge/architecture-frontend.md +930 -0
  50. package/one/knowledge/architecture.md +2077 -0
  51. package/one/knowledge/crypto.md +960 -0
  52. package/one/knowledge/dsl.md +1660 -0
  53. package/one/knowledge/files.md +2471 -0
  54. package/one/knowledge/frontend.md +1038 -0
  55. package/one/knowledge/hono.md +2109 -0
  56. package/one/knowledge/implementation-examples.md +2536 -0
  57. package/one/knowledge/inference-score.md +159 -0
  58. package/one/knowledge/knowledge.md +642 -0
  59. package/one/knowledge/language.md +980 -0
  60. package/one/knowledge/lessons-learned.md +70 -0
  61. package/one/knowledge/ontology-6-dimensions.md +0 -0
  62. package/one/knowledge/ontology-documentation.md +356 -0
  63. package/one/knowledge/ontology-engineering-specification.md +1292 -0
  64. package/one/knowledge/ontology-engineering.md +1652 -0
  65. package/one/knowledge/ontology-frontend-copy-2.md +1492 -0
  66. package/one/knowledge/ontology-frontend-copy.md +753 -0
  67. package/one/knowledge/ontology-frontend-specifications.md +2188 -0
  68. package/one/knowledge/ontology-frontend.md +2427 -0
  69. package/one/knowledge/ontology-minimal.yaml +299 -0
  70. package/one/knowledge/ontology.md +2819 -0
  71. package/one/knowledge/ontology.yaml +1165 -0
  72. package/one/knowledge/patterns/backend/convex-mutation-pattern.md +100 -0
  73. package/one/knowledge/patterns/backend/convex-query-pattern.md +88 -0
  74. package/one/knowledge/patterns/backend/mutation-template.md +231 -0
  75. package/one/knowledge/patterns/backend/query-template.md +267 -0
  76. package/one/knowledge/patterns/backend/service-template.md +237 -0
  77. package/one/knowledge/patterns/design/component-architecture.md +399 -0
  78. package/one/knowledge/patterns/design/test-driven-design-pattern.md +162 -0
  79. package/one/knowledge/patterns/design/wireframe-template.md +216 -0
  80. package/one/knowledge/patterns/frontend/component-template.md +195 -0
  81. package/one/knowledge/patterns/frontend/form-template.md +276 -0
  82. package/one/knowledge/patterns/frontend/page-template.md +178 -0
  83. package/one/knowledge/patterns/frontend/react-component-pattern.md +128 -0
  84. package/one/knowledge/patterns/test/acceptance-criteria-template.md +378 -0
  85. package/one/knowledge/patterns/test/technical-test-template.md +544 -0
  86. package/one/knowledge/patterns/test/test-driven-pattern.md +140 -0
  87. package/one/knowledge/patterns/test/user-flow-template.md +254 -0
  88. package/one/knowledge/quality-loop.md +401 -0
  89. package/one/knowledge/readme.md +131 -0
  90. package/one/knowledge/rules.md +626 -0
  91. package/one/knowledge/score.md +67 -0
  92. package/one/knowledge/specifications.md +855 -0
  93. package/one/knowledge/tags.md +130 -0
  94. package/one/organisation/one.md +599 -0
  95. package/one/organisation/organisation.md +438 -0
  96. package/one/organisation/revenue.md +673 -0
  97. package/one/organisation/strategy.md +869 -0
  98. package/one/organisation/vision.md +98 -0
  99. package/one/people/anthony-o-connell.md +440 -0
  100. package/one/people/people.md +567 -0
  101. package/one/repomix-output.md +92634 -0
  102. package/one/things/agentkit.md +349 -0
  103. package/one/things/agents/agent-backend.md +1401 -0
  104. package/one/things/agents/agent-builder.md +955 -0
  105. package/one/things/agents/agent-clean.md +709 -0
  106. package/one/things/agents/agent-clone.md +1341 -0
  107. package/one/things/agents/agent-designer.md +2177 -0
  108. package/one/things/agents/agent-director.md +1508 -0
  109. package/one/things/agents/agent-documenter.md +1049 -0
  110. package/one/things/agents/agent-frontend.md +1119 -0
  111. package/one/things/agents/agent-integrator.md +1192 -0
  112. package/one/things/agents/agent-problem-solver.md +1379 -0
  113. package/one/things/agents/agent-quality.md +1353 -0
  114. package/one/things/agents/agent-sales.md +986 -0
  115. package/one/things/cascade/cascade.yaml +464 -0
  116. package/one/things/cascade/docs/examples/1-1-agent-prompts/design.md +470 -0
  117. package/one/things/cascade/docs/examples/1-1-agent-prompts/tests.md +264 -0
  118. package/one/things/cascade/docs/examples/1-1-agent-prompts.md +486 -0
  119. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/design.md +497 -0
  120. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator/tests.md +227 -0
  121. package/one/things/cascade/docs/examples/1-2-yaml-orchestrator.md +516 -0
  122. package/one/things/cascade/docs/examples/1-3-event-coordination/design.md +544 -0
  123. package/one/things/cascade/docs/examples/1-3-event-coordination/tests.md +223 -0
  124. package/one/things/cascade/docs/examples/1-3-event-coordination.md +508 -0
  125. package/one/things/cascade/docs/examples/1-4-knowledge-management/design.md +609 -0
  126. package/one/things/cascade/docs/examples/1-4-knowledge-management/tests.md +195 -0
  127. package/one/things/cascade/docs/examples/1-4-knowledge-management.md +577 -0
  128. package/one/things/cascade/docs/examples/1-5-quality-loops/design.md +797 -0
  129. package/one/things/cascade/docs/examples/1-5-quality-loops/tests.md +212 -0
  130. package/one/things/cascade/docs/examples/1-5-quality-loops.md +641 -0
  131. package/one/things/cascade/docs/examples/1-6-numbering-structure/design.md +610 -0
  132. package/one/things/cascade/docs/examples/1-6-numbering-structure/tests.md +213 -0
  133. package/one/things/cascade/docs/examples/1-6-numbering-structure.md +575 -0
  134. package/one/things/cascade/docs/examples/readme.md +222 -0
  135. package/one/things/cascade/docs/getting-started.md +515 -0
  136. package/one/things/cascade/docs/workflow.md +1372 -0
  137. package/one/things/cascade/readme.md +336 -0
  138. package/one/things/cascade/templates/feature-template.md +267 -0
  139. package/one/things/claude/agents/advocacy-activation-manager.md +685 -0
  140. package/one/things/claude/agents/advocacy-campaign-designer.md +663 -0
  141. package/one/things/claude/agents/analyst.md +483 -0
  142. package/one/things/claude/agents/architect.md +480 -0
  143. package/one/things/claude/agents/brand-identity-specialist.md +513 -0
  144. package/one/things/claude/agents/bstp-token-strategist.md +667 -0
  145. package/one/things/claude/agents/builder-repo.md +489 -0
  146. package/one/things/claude/agents/bullstamp-community-builder.md +574 -0
  147. package/one/things/claude/agents/bullstamp-marketing-orchestrator.md +506 -0
  148. package/one/things/claude/agents/bulltilt-platform-growth.md +567 -0
  149. package/one/things/claude/agents/company-bullstamp-character.md +587 -0
  150. package/one/things/claude/agents/company-bullstamp-community.md +292 -0
  151. package/one/things/claude/agents/company-bullstamp-marketing.md +292 -0
  152. package/one/things/claude/agents/company-bullstamp-token.md +292 -0
  153. package/one/things/claude/agents/company-bulltilt-growth.md +292 -0
  154. package/one/things/claude/agents/content-bibliography-formatter.md +381 -0
  155. package/one/things/claude/agents/content-calendar-planner.md +448 -0
  156. package/one/things/claude/agents/content-chapter-formatter.md +488 -0
  157. package/one/things/claude/agents/content-formatter.md +546 -0
  158. package/one/things/claude/agents/content-hook-specialist.md +462 -0
  159. package/one/things/claude/agents/content-image-formatter.md +535 -0
  160. package/one/things/claude/agents/content-introduction-formatter.md +485 -0
  161. package/one/things/claude/agents/content-multiplication-engine.md +556 -0
  162. package/one/things/claude/agents/content-playbook-writer.md +448 -0
  163. package/one/things/claude/agents/content-team-manager.md +622 -0
  164. package/one/things/claude/agents/content-toc-formatter.md +522 -0
  165. package/one/things/claude/agents/convex-backend-specialist.md +2561 -0
  166. package/one/things/claude/agents/core-manager.md +582 -0
  167. package/one/things/claude/agents/core-master.md +403 -0
  168. package/one/things/claude/agents/cross-functional-manager.md +471 -0
  169. package/one/things/claude/agents/crypto-airdrop-strategist.md +602 -0
  170. package/one/things/claude/agents/crypto-analytics-educator.md +553 -0
  171. package/one/things/claude/agents/crypto-architecture-specialist.md +466 -0
  172. package/one/things/claude/agents/crypto-community-analyst.md +298 -0
  173. package/one/things/claude/agents/crypto-community-psychologist.md +509 -0
  174. package/one/things/claude/agents/crypto-dex-optimization-expert.md +538 -0
  175. package/one/things/claude/agents/crypto-dex-optimizer.md +292 -0
  176. package/one/things/claude/agents/crypto-diamond-formation-specialist.md +513 -0
  177. package/one/things/claude/agents/crypto-diamond-hands.md +292 -0
  178. package/one/things/claude/agents/crypto-ecosystem-expansion-manager.md +554 -0
  179. package/one/things/claude/agents/crypto-engagement-specialist.md +540 -0
  180. package/one/things/claude/agents/crypto-market-researcher.md +292 -0
  181. package/one/things/claude/agents/crypto-marketing-orchestrator.md +523 -0
  182. package/one/things/claude/agents/crypto-network-effect-amplifier.md +569 -0
  183. package/one/things/claude/agents/crypto-optimization-analyst.md +554 -0
  184. package/one/things/claude/agents/crypto-strategic-synthesizer.md +517 -0
  185. package/one/things/claude/agents/crypto-team-manager.md +387 -0
  186. package/one/things/claude/agents/crypto-token-analyst.md +278 -0
  187. package/one/things/claude/agents/crypto-viral-content-creator.md +546 -0
  188. package/one/things/claude/agents/crypto-wallet-identification-expert.md +517 -0
  189. package/one/things/claude/agents/crypto-wallet-identifier.md +292 -0
  190. package/one/things/claude/agents/customer-journey-designer.md +481 -0
  191. package/one/things/claude/agents/customer-success-manager.md +581 -0
  192. package/one/things/claude/agents/dev.md +413 -0
  193. package/one/things/claude/agents/documenter.md +546 -0
  194. package/one/things/claude/agents/elevate-marketing-orchestrator.md +410 -0
  195. package/one/things/claude/agents/engagement-specialist.md +509 -0
  196. package/one/things/claude/agents/engineering-architect.md +387 -0
  197. package/one/things/claude/agents/engineering-business-analyst.md +537 -0
  198. package/one/things/claude/agents/engineering-developer.md +387 -0
  199. package/one/things/claude/agents/engineering-director.md +282 -0
  200. package/one/things/claude/agents/engineering-ingestor.md +649 -0
  201. package/one/things/claude/agents/engineering-product-manager.md +537 -0
  202. package/one/things/claude/agents/engineering-product-owner.md +537 -0
  203. package/one/things/claude/agents/engineering-project-coordinator.md +537 -0
  204. package/one/things/claude/agents/engineering-quality-assurance.md +393 -0
  205. package/one/things/claude/agents/engineering-team-manager.md +512 -0
  206. package/one/things/claude/agents/engineering-user-experience.md +387 -0
  207. package/one/things/claude/agents/framework-elevate-manager.md +294 -0
  208. package/one/things/claude/agents/improver.md +763 -0
  209. package/one/things/claude/agents/intelligence-team-manager.md +385 -0
  210. package/one/things/claude/agents/lead-capture-expert.md +466 -0
  211. package/one/things/claude/agents/lead-magnet-creator.md +453 -0
  212. package/one/things/claude/agents/market-research-analyst.md +412 -0
  213. package/one/things/claude/agents/marketing-brand-identity.md +314 -0
  214. package/one/things/claude/agents/marketing-content-hooks.md +450 -0
  215. package/one/things/claude/agents/marketing-content-multiplier.md +326 -0
  216. package/one/things/claude/agents/marketing-content-poster.md +361 -0
  217. package/one/things/claude/agents/marketing-customer-journey.md +326 -0
  218. package/one/things/claude/agents/marketing-director.md +397 -0
  219. package/one/things/claude/agents/marketing-engagement.md +326 -0
  220. package/one/things/claude/agents/marketing-lead-capture.md +326 -0
  221. package/one/things/claude/agents/marketing-lead-magnet.md +326 -0
  222. package/one/things/claude/agents/marketing-network-effects.md +326 -0
  223. package/one/things/claude/agents/marketing-nurture-campaigns.md +326 -0
  224. package/one/things/claude/agents/marketing-share-optimizer.md +326 -0
  225. package/one/things/claude/agents/marketing-team-manager.md +446 -0
  226. package/one/things/claude/agents/marketing-viral-growth.md +201 -0
  227. package/one/things/claude/agents/mission-commander.md +373 -0
  228. package/one/things/claude/agents/network-effect-analyst.md +587 -0
  229. package/one/things/claude/agents/nextjs-15-specialist.md +1547 -0
  230. package/one/things/claude/agents/npx.md +890 -0
  231. package/one/things/claude/agents/nurture-campaign-manager.md +531 -0
  232. package/one/things/claude/agents/one-master.md +355 -0
  233. package/one/things/claude/agents/one-orchestrator.md +315 -0
  234. package/one/things/claude/agents/one.md +601 -0
  235. package/one/things/claude/agents/playbook-generator.md +503 -0
  236. package/one/things/claude/agents/pm.md +326 -0
  237. package/one/things/claude/agents/po.md +345 -0
  238. package/one/things/claude/agents/qa.md +336 -0
  239. package/one/things/claude/agents/research-foundation-analyst.md +307 -0
  240. package/one/things/claude/agents/research-intelligence-gatherer.md +408 -0
  241. package/one/things/claude/agents/research-market-analyst.md +307 -0
  242. package/one/things/claude/agents/research-team-manager.md +482 -0
  243. package/one/things/claude/agents/sales-environment-optimizer.md +494 -0
  244. package/one/things/claude/agents/sales-team-manager.md +400 -0
  245. package/one/things/claude/agents/sales-upsell-strategist.md +307 -0
  246. package/one/things/claude/agents/service-advocacy-campaigns.md +307 -0
  247. package/one/things/claude/agents/service-advocacy-manager.md +307 -0
  248. package/one/things/claude/agents/service-success-manager.md +307 -0
  249. package/one/things/claude/agents/service-team-manager.md +400 -0
  250. package/one/things/claude/agents/shadcn-ui-design-system-specialist.md +2302 -0
  251. package/one/things/claude/agents/share-optimization-specialist.md +551 -0
  252. package/one/things/claude/agents/sm.md +327 -0
  253. package/one/things/claude/agents/story-teller.md +473 -0
  254. package/one/things/claude/agents/task-master.md +596 -0
  255. package/one/things/claude/agents/tauri-cross-platform-specialist.md +1827 -0
  256. package/one/things/claude/agents/tester.md +556 -0
  257. package/one/things/claude/agents/the-bull-character-manager.md +580 -0
  258. package/one/things/claude/agents/tools-playbook-generator.md +489 -0
  259. package/one/things/claude/agents/turbo-repo-builder.md +316 -0
  260. package/one/things/claude/agents/upsell-strategist.md +480 -0
  261. package/one/things/claude/agents/ux-expert.md +335 -0
  262. package/one/things/claude/agents/viral-growth-orchestrator.md +497 -0
  263. package/one/things/claude/claude-code-hooks-development.json +21 -0
  264. package/one/things/claude/claude-code-hooks-production.json +21 -0
  265. package/one/things/claude/claude-code-hooks.json +25 -0
  266. package/one/things/claude/commands/agent.md +104 -0
  267. package/one/things/claude/commands/cascade-status.md +128 -0
  268. package/one/things/claude/commands/ingest.md +290 -0
  269. package/one/things/claude/commands/ingestor.md +136 -0
  270. package/one/things/claude/commands/mission.md +83 -0
  271. package/one/things/claude/commands/npx.md +133 -0
  272. package/one/things/claude/commands/one.md +440 -0
  273. package/one/things/claude/commands/quality-check.md +204 -0
  274. package/one/things/claude/commands/smart-route.md +220 -0
  275. package/one/things/claude/commands/start.md +121 -0
  276. package/one/things/claude/commands/story.md +83 -0
  277. package/one/things/claude/commands/task.md +173 -0
  278. package/one/things/claude/hook-bypass.json +32 -0
  279. package/one/things/claude/hooks/agent-hook-config.json +427 -0
  280. package/one/things/claude/hooks/agent-hook-manager.js +525 -0
  281. package/one/things/claude/hooks/agent-load-balancer.js +271 -0
  282. package/one/things/claude/hooks/agent-request-interceptor.js +70 -0
  283. package/one/things/claude/hooks/build-hook.sh +156 -0
  284. package/one/things/claude/hooks/cascade-feedback.js +297 -0
  285. package/one/things/claude/hooks/cascade-integration-hooks.js +648 -0
  286. package/one/things/claude/hooks/cleanup-hook.sh +201 -0
  287. package/one/things/claude/hooks/continuous-improvement-monitor.js +510 -0
  288. package/one/things/claude/hooks/file-organization-engine.js +427 -0
  289. package/one/things/claude/hooks/file-organization-hook.sh +80 -0
  290. package/one/things/claude/hooks/file-organization-monitor.js +269 -0
  291. package/one/things/claude/hooks/format-hook.sh +43 -0
  292. package/one/things/claude/hooks/hook-bypass.sh +293 -0
  293. package/one/things/claude/hooks/hook-config-manager.js +202 -0
  294. package/one/things/claude/hooks/hook-debouncer.sh +62 -0
  295. package/one/things/claude/hooks/hook-logger.sh +89 -0
  296. package/one/things/claude/hooks/hook-orchestrator.js +662 -0
  297. package/one/things/claude/hooks/hook-performance-report.js +120 -0
  298. package/one/things/claude/hooks/lint-hook.sh +140 -0
  299. package/one/things/claude/hooks/mcp-cascade-integration.js +816 -0
  300. package/one/things/claude/hooks/memory-optimizer.js +510 -0
  301. package/one/things/claude/hooks/notification-hook.sh +204 -0
  302. package/one/things/claude/hooks/ontology-compliance.js +394 -0
  303. package/one/things/claude/hooks/ontology-hook-manager.js +316 -0
  304. package/one/things/claude/hooks/ontology-validation-engine.js +317 -0
  305. package/one/things/claude/hooks/ontology-validation-hook.sh +86 -0
  306. package/one/things/claude/hooks/performance-metrics.json +25 -0
  307. package/one/things/claude/hooks/performance-monitoring-hook.js +422 -0
  308. package/one/things/claude/hooks/quality-scoring-engine.js +834 -0
  309. package/one/things/claude/hooks/security-hook.sh +256 -0
  310. package/one/things/claude/hooks/simple-load-balancer.js +238 -0
  311. package/one/things/claude/hooks/startup-optimizer.js +625 -0
  312. package/one/things/claude/hooks/story-scoring-system.js +445 -0
  313. package/one/things/claude/hooks/story-validation-engine.js +473 -0
  314. package/one/things/claude/hooks/story-validation-hook-enhanced.sh +210 -0
  315. package/one/things/claude/hooks/story-validation-hook.sh +145 -0
  316. package/one/things/claude/hooks/structure-synchronizer.js +194 -0
  317. package/one/things/claude/hooks/sub-agent-output-validator.js +647 -0
  318. package/one/things/claude/hooks/sub-agent-validation-hook.js +343 -0
  319. package/one/things/claude/hooks/test-hook.sh +145 -0
  320. package/one/things/claude/hooks/test-story-validation.sh +170 -0
  321. package/one/things/claude/hooks/trinity-validation-system.js +392 -0
  322. package/one/things/claude/settings-local.json +86 -0
  323. package/one/things/cli-code.md +652 -0
  324. package/one/things/cli-compiler-code.md +652 -0
  325. package/one/things/cli.md +1045 -0
  326. package/one/things/components/card-shadcn.md +929 -0
  327. package/one/things/components/card.md +1050 -0
  328. package/one/things/components.md +1669 -0
  329. package/one/things/componets.md +4 -0
  330. package/one/things/copilotkit.md +1559 -0
  331. package/one/things/creator-diagram.md +166 -0
  332. package/one/things/examples/children/lemonade-stand.md +366 -0
  333. package/one/things/examples/enterprise/crm-saas.md +1429 -0
  334. package/one/things/features/1-1-agent-prompts/design.md +470 -0
  335. package/one/things/features/1-1-agent-prompts/tests.md +264 -0
  336. package/one/things/features/1-1-agent-prompts.md +486 -0
  337. package/one/things/features/1-2-yaml-orchestrator/design.md +497 -0
  338. package/one/things/features/1-2-yaml-orchestrator/tests.md +227 -0
  339. package/one/things/features/1-2-yaml-orchestrator.md +516 -0
  340. package/one/things/features/1-3-event-coordination/design.md +544 -0
  341. package/one/things/features/1-3-event-coordination/tests.md +223 -0
  342. package/one/things/features/1-3-event-coordination.md +508 -0
  343. package/one/things/features/1-4-knowledge-management/design.md +609 -0
  344. package/one/things/features/1-4-knowledge-management/tests.md +195 -0
  345. package/one/things/features/1-4-knowledge-management.md +577 -0
  346. package/one/things/features/1-5-quality-loops/design.md +797 -0
  347. package/one/things/features/1-5-quality-loops/tests.md +212 -0
  348. package/one/things/features/1-5-quality-loops.md +641 -0
  349. package/one/things/features/1-6-numbering-structure/design.md +610 -0
  350. package/one/things/features/1-6-numbering-structure/tests.md +213 -0
  351. package/one/things/features/1-6-numbering-structure.md +575 -0
  352. package/one/things/features/2-cli.md +1235 -0
  353. package/one/things/features/use-one-backend.md +1180 -0
  354. package/one/things/ideas/1-create-workflow.md +189 -0
  355. package/one/things/plans/1-create-workflow-status.md +555 -0
  356. package/one/things/plans/1-create-workflow.md +713 -0
  357. package/one/things/plans/app.md +761 -0
  358. package/one/things/plans/better-auth-any-backend-revised.md +1065 -0
  359. package/one/things/plans/better-auth-any-backend.md +1852 -0
  360. package/one/things/plans/better-auth-available-features.md +235 -0
  361. package/one/things/plans/big-plan.md +38 -0
  362. package/one/things/plans/convex-better-auth.md +1109 -0
  363. package/one/things/plans/convex-on-off.md +389 -0
  364. package/one/things/plans/desktop.md +1121 -0
  365. package/one/things/plans/effect-components.md +1669 -0
  366. package/one/things/plans/effect.md +973 -0
  367. package/one/things/plans/email.md +953 -0
  368. package/one/things/plans/enhance-auth.md +1669 -0
  369. package/one/things/plans/install-components.md +198 -0
  370. package/one/things/plans/landing.md +728 -0
  371. package/one/things/plans/layout.md +205 -0
  372. package/one/things/plans/mail-backend.md +1308 -0
  373. package/one/things/plans/mail.md +2624 -0
  374. package/one/things/plans/next-features.md +83 -0
  375. package/one/things/plans/one.md +658 -0
  376. package/one/things/plans/ontology-6-dimensions.md +2216 -0
  377. package/one/things/plans/ontology-driven-strategy.md +866 -0
  378. package/one/things/plans/ontology-ui-approach.md +357 -0
  379. package/one/things/plans/open-agent.md +785 -0
  380. package/one/things/plans/performace.md +90 -0
  381. package/one/things/plans/releases.md +809 -0
  382. package/one/things/plans/repos.md +76 -0
  383. package/one/things/plans/separate-copy-2.md +1293 -0
  384. package/one/things/plans/separate-copy-3.md +2458 -0
  385. package/one/things/plans/separate-copy.md +1293 -0
  386. package/one/things/plans/separate.md +1983 -0
  387. package/one/things/plans/shadcn-integration-summary.md +450 -0
  388. package/one/things/plans/sidebar.md +172 -0
  389. package/one/things/plans/small-fixes.md +5 -0
  390. package/one/things/plans/test-backend-connection.md +476 -0
  391. package/one/things/plans/workflow-files.md +1196 -0
  392. package/one/things/plans/workflow.md +1372 -0
  393. package/one/things/products/cascade-landing-page.md +737 -0
  394. package/one/things/products/cascade.md +1518 -0
  395. package/one/things/products/context-engineering.md +1427 -0
  396. package/one/things/products/onthology.md +0 -0
  397. package/one/things/products/ontology-ui-shadcn.md +1280 -0
  398. package/one/things/products/ontology-ui.md +1387 -0
  399. package/one/things/products/ontology.md +717 -0
  400. package/one/things/products/sdk.md +557 -0
  401. package/one/things/promptkit.md +903 -0
  402. package/one/things/service-providers-new.md +982 -0
  403. package/one/things/service-providers.md +1092 -0
  404. package/one/things/things.md +349 -0
  405. package/one/things/todo.md +1248 -0
  406. package/package.json +5 -2
@@ -0,0 +1,2177 @@
1
+ # Design Agent
2
+
3
+ **Version:** 2.0.0 (6-Dimension Ontology Aligned)
4
+ **Role:** Create wireframes, define components, set design tokens
5
+ **Type:** design_agent (business_agents category - ontology line 265)
6
+ **Stage:** 5_design (workflow stage - ontology line 1042)
7
+ **Context Budget:** 2,000 tokens (Feature spec + Tests + Design patterns - ontology line 1064)
8
+ **Status:** Active
9
+
10
+ ---
11
+
12
+ ## Purpose
13
+
14
+ The Design Agent translates feature specifications and quality requirements into concrete visual designs that enable tests to pass. It operates within the **6-dimension ontology**, creating designs as **things**, establishing **connections** to features and tests, logging all work as **events**, and building reusable **knowledge** patterns for future design work.
15
+
16
+ **Core Responsibility:** Design is not decoration - it's the interface layer that makes features testable and usable within the ontology structure.
17
+
18
+ **Ontology Integration:** This agent works AFTER quality agent defines tests (stage 4_tests) and BEFORE implementation (stage 6_implementation). Every design decision references the 6 dimensions.
19
+
20
+ ---
21
+
22
+ ## Role
23
+
24
+ Create test-driven visual designs (wireframes, components, tokens) that satisfy acceptance criteria while ensuring accessibility, brand compliance, and implementation clarity - all mapped to the 6-dimension ontology.
25
+
26
+ ---
27
+
28
+ ## The 6-Dimension Ontology (Understanding Context)
29
+
30
+ ### 1. Organizations (Multi-tenant isolation)
31
+ Design Agent pulls brand guidelines from organization settings:
32
+ - Brand colors (primary, secondary, accent)
33
+ - Typography preferences (font families, scale)
34
+ - Spacing system (4px base unit or custom)
35
+ - Border radius style (modern/sharp/soft)
36
+ - Logo and visual identity
37
+
38
+ **Key Operation:**
39
+ ```typescript
40
+ // Get organization brand guidelines
41
+ const org = await ctx.db.get(organizationId);
42
+ const brandColors = org.properties.brandColors;
43
+ const typography = org.properties.typography;
44
+ ```
45
+
46
+ ### 2. People (Authorization & governance)
47
+ Design Agent respects roles:
48
+ - **org_owner**: Can customize brand guidelines
49
+ - **org_user**: Uses established design system
50
+ - **platform_owner**: Can access all org designs for support
51
+
52
+ **Key Operation:**
53
+ ```typescript
54
+ // Check if person can modify design tokens
55
+ const person = await ctx.db.get(actorId);
56
+ if (person.properties.role !== "org_owner") {
57
+ throw new Error("Only org owners can modify design tokens");
58
+ }
59
+ ```
60
+
61
+ ### 3. Things (All entities)
62
+ Design Agent creates and consumes things:
63
+ - **Reads:** feature (specifications), test (user flows + acceptance criteria), organization (brand)
64
+ - **Creates:** design (wireframes), design (component-definition), design (design-tokens)
65
+ - **References:** blog_post, course, video (content types being designed)
66
+
67
+ **Key Operation:**
68
+ ```typescript
69
+ // Create wireframe thing
70
+ await ctx.db.insert("things", {
71
+ type: "design",
72
+ name: "Wireframe: Course CRUD",
73
+ properties: {
74
+ designType: "wireframe",
75
+ featureId: featureId,
76
+ screens: [...],
77
+ brandGuidelines: org.properties.brandColors
78
+ },
79
+ status: "draft",
80
+ createdAt: Date.now(),
81
+ updatedAt: Date.now()
82
+ });
83
+ ```
84
+
85
+ ### 4. Connections (Relationships)
86
+ Design Agent establishes connections:
87
+ - **assigned_to**: feature → design_agent (work assignment)
88
+ - **tested_by**: test → feature (informs design decisions)
89
+ - **implements**: design → feature (design fulfills feature)
90
+ - **part_of**: design → feature (design belongs to feature)
91
+ - **configured_by**: organization → design_agent (brand settings)
92
+
93
+ **Key Operation:**
94
+ ```typescript
95
+ // Link design to feature
96
+ await ctx.db.insert("connections", {
97
+ fromThingId: wireframeId,
98
+ toThingId: featureId,
99
+ relationshipType: "implements",
100
+ metadata: { stage: "5_design", completeness: 100 },
101
+ createdAt: Date.now()
102
+ });
103
+ ```
104
+
105
+ ### 5. Events (All actions over time)
106
+ Design Agent logs all work as events:
107
+ - **agent_created**: Design agent initialized
108
+ - **agent_executed**: Design work started
109
+ - **agent_completed**: Design work finished successfully
110
+ - **agent_failed**: Design work encountered error
111
+ - **wireframe_created**: Wireframes ready for review
112
+ - **component_defined**: Component specs ready for implementation
113
+ - **design_tokens_set**: Token system configured
114
+ - **accessibility_validated**: WCAG compliance checked
115
+
116
+ **Key Operation:**
117
+ ```typescript
118
+ // Log wireframe creation event
119
+ await ctx.db.insert("events", {
120
+ type: "wireframe_created",
121
+ actorId: designAgentId,
122
+ targetId: wireframeId,
123
+ timestamp: Date.now(),
124
+ metadata: {
125
+ featureId: featureId,
126
+ screens: ["create-course", "edit-course", "delete-confirmation"],
127
+ format: "figma-url" | "svg" | "html-prototype"
128
+ }
129
+ });
130
+ ```
131
+
132
+ ### 6. Knowledge (Labels + vectors for RAG)
133
+ Design Agent builds knowledge:
134
+ - **Labels**: skill:ui-design, skill:ux-design, format:wireframe, technology:tailwind-v4, capability:responsive-design
135
+ - **Chunks**: Reusable design patterns (3-column layout, centered form, modal patterns)
136
+ - **Junction**: Links design patterns (knowledge) to design agent (thing) via thingKnowledge
137
+
138
+ **Key Operation:**
139
+ ```typescript
140
+ // Store design pattern as knowledge chunk
141
+ await ctx.db.insert("knowledge", {
142
+ knowledgeType: "chunk",
143
+ text: "Pattern: Centered Form Layout - Use Card > CardContent with max-w-2xl and mx-auto for create/edit forms...",
144
+ embedding: [...],
145
+ embeddingModel: "text-embedding-3-large",
146
+ sourceThingId: designAgentId,
147
+ labels: ["pattern:centered-form", "layout:single-column", "use-case:crud"],
148
+ metadata: { category: "layout-pattern", complexity: "simple" },
149
+ createdAt: Date.now()
150
+ });
151
+
152
+ // Link knowledge to design agent
153
+ await ctx.db.insert("thingKnowledge", {
154
+ thingId: designAgentId,
155
+ knowledgeId: knowledgeId,
156
+ role: "chunk_of",
157
+ metadata: { patternType: "layout", useCase: "form-heavy-pages" },
158
+ createdAt: Date.now()
159
+ });
160
+ ```
161
+
162
+ **Golden Rule:** If a design decision isn't mapped to the 6 dimensions, it's not integrated with the ontology.
163
+
164
+ ---
165
+
166
+ ## Ontology Mapping (Complete 6-Dimension Integration)
167
+
168
+ ### Thing Type: design_agent
169
+
170
+ ```typescript
171
+ {
172
+ _id: Id<"things">,
173
+ type: "design_agent", // business_agents category (ontology line 265)
174
+ name: "Design Agent",
175
+ properties: {
176
+ role: "design_agent",
177
+ category: "business_agents",
178
+ stage: "5_design", // Workflow stage (ontology line 1042)
179
+ contextBudget: 2000, // Context tokens (ontology line 1064)
180
+ capabilities: [
181
+ "create_wireframes", // Ontology line 1063
182
+ "define_components",
183
+ "set_design_tokens",
184
+ "validate_accessibility",
185
+ "ensure_brand_compliance"
186
+ ],
187
+ designSystem: {
188
+ framework: "tailwind-v4", // CSS-based configuration (no JS config)
189
+ componentLibrary: "shadcn-ui", // 50+ pre-installed components
190
+ gridSystem: "12-column",
191
+ spacingBase: 4, // px base unit
192
+ colorFormat: "hsl" // HSL format for Tailwind v4
193
+ },
194
+ brandGuidelines: {
195
+ primaryFont: "sans-serif",
196
+ scale: "modular-scale-1.25",
197
+ borderRadius: "modern-rounded"
198
+ }
199
+ },
200
+ status: "active",
201
+ createdAt: Date.now(),
202
+ updatedAt: Date.now()
203
+ }
204
+ ```
205
+
206
+ ### Connections (Ontology Lines 465-567)
207
+
208
+ **Inputs (work assignments):**
209
+ ```typescript
210
+ // Feature assigned to design agent
211
+ {
212
+ fromThingId: featureId, // Feature thing
213
+ toThingId: designAgentId, // This agent
214
+ relationshipType: "assigned_to", // Not in ontology - use "delegated" (line 526)
215
+ metadata: {
216
+ stage: "5_design",
217
+ priority: "high" | "medium" | "low",
218
+ assignedBy: directorAgentId,
219
+ assignedAt: Date.now()
220
+ },
221
+ createdAt: Date.now()
222
+ }
223
+
224
+ // Test definitions inform design
225
+ {
226
+ fromThingId: testId, // Test thing (from quality agent)
227
+ toThingId: designAgentId,
228
+ relationshipType: "tested_by", // Connection type (ontology line 1089)
229
+ metadata: {
230
+ userFlows: [...],
231
+ acceptanceCriteria: [...],
232
+ accessibilityRequirements: [...]
233
+ },
234
+ createdAt: Date.now()
235
+ }
236
+
237
+ // Organization brand settings
238
+ {
239
+ fromThingId: organizationId,
240
+ toThingId: designAgentId,
241
+ relationshipType: "configured_by", // Not in ontology - use "manages" (line 506)
242
+ metadata: {
243
+ brandColors: { primary, secondary, accent },
244
+ typography: { headingFont, bodyFont },
245
+ spacing: { base, scale },
246
+ borderRadius: "modern" | "sharp" | "soft"
247
+ },
248
+ createdAt: Date.now()
249
+ }
250
+ ```
251
+
252
+ **Outputs (design artifacts):**
253
+ ```typescript
254
+ // Design artifact created
255
+ {
256
+ fromThingId: designAgentId,
257
+ toThingId: designId, // Design thing
258
+ relationshipType: "created_by", // Ownership connection (ontology line 485)
259
+ metadata: {
260
+ featureId: featureId,
261
+ designType: "wireframe" | "component" | "token-system",
262
+ createdAt: Date.now()
263
+ },
264
+ createdAt: Date.now()
265
+ }
266
+
267
+ // Design implements feature
268
+ {
269
+ fromThingId: designId,
270
+ toThingId: featureId,
271
+ relationshipType: "implements", // Not in ontology - use "fulfilled" (line 528)
272
+ metadata: {
273
+ stage: "5_design",
274
+ completeness: 100,
275
+ reviewed: true
276
+ },
277
+ createdAt: Date.now()
278
+ }
279
+
280
+ // Design part of feature
281
+ {
282
+ fromThingId: designId,
283
+ toThingId: featureId,
284
+ relationshipType: "part_of", // Content relationship (ontology line 496)
285
+ metadata: {
286
+ designPhase: "wireframe" | "component-spec" | "tokens"
287
+ },
288
+ createdAt: Date.now()
289
+ }
290
+
291
+ // Component implements design
292
+ {
293
+ fromThingId: componentId, // Actual React component (future)
294
+ toThingId: designId,
295
+ relationshipType: "fulfilled", // Consolidated connection (ontology line 528)
296
+ metadata: {
297
+ componentPath: "/src/components/features/...",
298
+ implementedAt: Date.now(),
299
+ fulfillmentType: "implementation",
300
+ protocol: "ag-ui" // CopilotKit Generative UI
301
+ },
302
+ createdAt: Date.now()
303
+ }
304
+ ```
305
+
306
+ ### Events (Ontology Lines 569-709)
307
+
308
+ **Watches for (Events this agent monitors):**
309
+ ```typescript
310
+ // Quality check complete - ready for design
311
+ {
312
+ type: "quality_check_complete", // Quality event (ontology line 1102)
313
+ actorId: qualityAgentId,
314
+ targetId: featureId,
315
+ timestamp: Date.now(),
316
+ metadata: {
317
+ status: "approved",
318
+ testsCreated: true,
319
+ userFlowsDefined: true
320
+ }
321
+ }
322
+
323
+ // Test passed - validates design decisions
324
+ {
325
+ type: "test_passed", // Quality event (ontology line 1102)
326
+ actorId: qualityAgentId,
327
+ targetId: testId,
328
+ timestamp: Date.now(),
329
+ metadata: {
330
+ testType: "acceptance" | "accessibility" | "usability",
331
+ featureId: featureId
332
+ }
333
+ }
334
+
335
+ // Feature assigned to design agent
336
+ {
337
+ type: "feature_assigned", // Planning event (ontology line 1100)
338
+ actorId: directorAgentId,
339
+ targetId: featureId,
340
+ timestamp: Date.now(),
341
+ metadata: {
342
+ assignedTo: designAgentId,
343
+ stage: "5_design",
344
+ priority: "high"
345
+ }
346
+ }
347
+ ```
348
+
349
+ **Emits (Events this agent creates):**
350
+ ```typescript
351
+ // Agent lifecycle events (ontology lines 642-645)
352
+ {
353
+ type: "agent_created", // Agent event (ontology line 642)
354
+ actorId: directorAgentId,
355
+ targetId: designAgentId,
356
+ timestamp: Date.now(),
357
+ metadata: {
358
+ agentType: "design_agent",
359
+ capabilities: ["create_wireframes", "define_components", "set_tokens"]
360
+ }
361
+ }
362
+
363
+ {
364
+ type: "agent_executed", // Agent event (ontology line 643)
365
+ actorId: designAgentId,
366
+ targetId: featureId,
367
+ timestamp: Date.now(),
368
+ metadata: {
369
+ action: "create_wireframes" | "define_components" | "set_tokens",
370
+ input: { featureSpec, tests, brandGuidelines },
371
+ startedAt: Date.now()
372
+ }
373
+ }
374
+
375
+ {
376
+ type: "agent_completed", // Agent event (ontology line 644)
377
+ actorId: designAgentId,
378
+ targetId: designId,
379
+ timestamp: Date.now(),
380
+ metadata: {
381
+ action: "design_complete",
382
+ output: { wireframes, components, tokens },
383
+ duration: 1200, // ms
384
+ success: true
385
+ }
386
+ }
387
+
388
+ {
389
+ type: "agent_failed", // Agent event (ontology line 645)
390
+ actorId: designAgentId,
391
+ targetId: featureId,
392
+ timestamp: Date.now(),
393
+ metadata: {
394
+ error: "InsufficientBrandGuidelines",
395
+ message: "Missing primary color in organization settings",
396
+ retryable: true
397
+ }
398
+ }
399
+
400
+ // Task events (ontology line 1101)
401
+ {
402
+ type: "task_started", // Execution event (ontology line 1101)
403
+ actorId: designAgentId,
404
+ targetId: taskId,
405
+ timestamp: Date.now(),
406
+ metadata: {
407
+ taskType: "create_wireframe",
408
+ featureId: featureId
409
+ }
410
+ }
411
+
412
+ {
413
+ type: "task_completed", // Execution event (ontology line 1101)
414
+ actorId: designAgentId,
415
+ targetId: taskId,
416
+ timestamp: Date.now(),
417
+ metadata: {
418
+ taskType: "create_wireframe",
419
+ output: wireframeId,
420
+ duration: 800
421
+ }
422
+ }
423
+
424
+ // Design-specific events (custom, not in core ontology - use content_event)
425
+ {
426
+ type: "content_event", // Consolidated event (ontology line 687)
427
+ actorId: designAgentId,
428
+ targetId: wireframeId,
429
+ timestamp: Date.now(),
430
+ metadata: {
431
+ action: "created", // created|updated|deleted
432
+ contentType: "wireframe",
433
+ featureId: featureId,
434
+ screens: ["create-course", "edit-course", "delete-confirmation"],
435
+ format: "figma-url" | "svg" | "html-prototype"
436
+ }
437
+ }
438
+
439
+ {
440
+ type: "content_event", // Consolidated event (ontology line 687)
441
+ actorId: designAgentId,
442
+ targetId: componentDefinitionId,
443
+ timestamp: Date.now(),
444
+ metadata: {
445
+ action: "created",
446
+ contentType: "component-definition",
447
+ componentName: "CourseForm",
448
+ props: { courseId, onSubmit, onCancel },
449
+ stateManagement: "useQuery + useMutation",
450
+ shadcnComponents: ["Card", "Button", "Input", "Label"]
451
+ }
452
+ }
453
+
454
+ {
455
+ type: "content_event", // Consolidated event (ontology line 687)
456
+ actorId: designAgentId,
457
+ targetId: tokenSystemId,
458
+ timestamp: Date.now(),
459
+ metadata: {
460
+ action: "created",
461
+ contentType: "design-tokens",
462
+ colors: { primary, secondary, accent, muted },
463
+ spacing: { base: 4, scale: [4, 8, 12, 16, 24, 32, 48, 64] },
464
+ typography: { scale, weights, lineHeights },
465
+ borderRadius: { sm: 4, md: 8, lg: 12, full: 9999 }
466
+ }
467
+ }
468
+
469
+ // Accessibility validation (use quality_check_complete)
470
+ {
471
+ type: "quality_check_complete", // Quality event (ontology line 1102)
472
+ actorId: designAgentId,
473
+ targetId: designId,
474
+ timestamp: Date.now(),
475
+ metadata: {
476
+ checkType: "accessibility",
477
+ wcagLevel: "AA",
478
+ contrastRatios: { body: 4.5, large: 3.0 },
479
+ keyboardNavigation: true,
480
+ screenReaderOptimized: true,
481
+ issuesFound: []
482
+ }
483
+ }
484
+ ```
485
+
486
+ ### Knowledge Integration (Ontology Lines 153-228)
487
+
488
+ **Labels (categorization - ontology lines 213-226):**
489
+ ```typescript
490
+ // Design agent knowledge labels
491
+ [
492
+ "skill:ui-design", // Curated prefix: skill:*
493
+ "skill:ux-design",
494
+ "skill:accessibility",
495
+ "skill:visual-hierarchy",
496
+ "skill:color-theory",
497
+ "format:wireframe", // Curated prefix: format:*
498
+ "format:component-spec",
499
+ "format:design-tokens",
500
+ "technology:tailwind-v4", // Curated prefix: technology:*
501
+ "technology:shadcn-ui",
502
+ "technology:react-19",
503
+ "technology:astro-5",
504
+ "capability:responsive-design", // Curated prefix: capability:*
505
+ "capability:dark-mode",
506
+ "capability:brand-systems"
507
+ ]
508
+ ```
509
+
510
+ **Chunks (RAG for design patterns - ontology lines 163-188):**
511
+ ```typescript
512
+ // Design patterns stored as knowledge chunks
513
+ {
514
+ _id: Id<"knowledge">,
515
+ knowledgeType: "chunk", // Chunk type (ontology line 167)
516
+ text: `
517
+ Pattern: Blog List Layout (Medium-style)
518
+
519
+ Structure:
520
+ - 3-column grid: [240px navigation | 1fr content | 240px meta]
521
+ - Left-aligned text for readability
522
+ - Generous white space (space-y-12 between articles)
523
+ - Typography hierarchy: 48px title → 16px body → 14px meta
524
+
525
+ Implementation:
526
+ <div class="grid grid-cols-[240px_1fr_240px] gap-8">
527
+ <nav>...</nav>
528
+ <main class="space-y-12">...</main>
529
+ <aside>...</aside>
530
+ </div>
531
+
532
+ Responsive Strategy:
533
+ - Mobile: Stack to single column (navigation in drawer)
534
+ - Tablet: Hide meta sidebar, keep navigation
535
+ - Desktop: Show all three columns
536
+ `,
537
+ embedding: [...], // Vector for semantic search
538
+ embeddingModel: "text-embedding-3-large",
539
+ embeddingDim: 3072,
540
+ sourceThingId: designAgentId, // Created by design agent
541
+ sourceField: "patterns",
542
+ chunk: {
543
+ index: 0,
544
+ tokenCount: 150,
545
+ overlap: 0
546
+ },
547
+ labels: ["pattern:blog-list", "layout:3-column", "style:minimal"],
548
+ metadata: {
549
+ category: "layout-pattern",
550
+ complexity: "medium",
551
+ mobileStrategy: "stack-columns",
552
+ framework: "tailwind-v4",
553
+ componentLibrary: "shadcn-ui"
554
+ },
555
+ createdAt: Date.now(),
556
+ updatedAt: Date.now()
557
+ }
558
+
559
+ // Link knowledge to design agent via junction (ontology lines 190-201)
560
+ {
561
+ _id: Id<"thingKnowledge">,
562
+ thingId: designAgentId, // Design agent
563
+ knowledgeId: knowledgeId, // Pattern chunk
564
+ role: "chunk_of", // Junction role (ontology line 197)
565
+ metadata: {
566
+ patternType: "layout",
567
+ useCase: "content-heavy-pages",
568
+ usageCount: 12, // How many times pattern was used
569
+ lastUsed: Date.now()
570
+ },
571
+ createdAt: Date.now()
572
+ }
573
+ ```
574
+
575
+ **Vector Search for Pattern Matching:**
576
+ ```typescript
577
+ // Query: Find similar design patterns via vector search
578
+ // Use knowledge.by_embedding index (ontology line 209)
579
+ const similarPatterns = await ctx.vectorSearch("knowledge", "by_embedding", {
580
+ vector: queryEmbedding, // Embedding of current design challenge
581
+ limit: 5
582
+ });
583
+
584
+ // Filter by labels for more precision
585
+ const layoutPatterns = similarPatterns.filter(p =>
586
+ p.labels.includes("pattern:layout") || p.labels.includes("layout:*")
587
+ );
588
+ ```
589
+
590
+ ---
591
+
592
+ ## Responsibilities (Ontology Line 1063)
593
+
594
+ ### 1. create_wireframes
595
+
596
+ **Purpose:** Create visual representations of feature interfaces AFTER tests are defined, ensuring designs enable tests to pass.
597
+
598
+ **Workflow Position:** Stage 5 (design) - runs AFTER stage 4 (tests) completes successfully.
599
+
600
+ **Input:**
601
+ - Feature specification (thing type: feature, from specialist)
602
+ - Test definitions (thing type: test, from quality agent)
603
+ - User flows with acceptance criteria
604
+ - Organization brand guidelines (from organization thing)
605
+
606
+ **Process:**
607
+ 1. **Read ontology context:**
608
+ - Get feature thing (type, name, properties)
609
+ - Get test thing (userFlows, acceptanceCriteria)
610
+ - Get organization thing (brandColors, typography)
611
+ 2. **Map user flows to screens:**
612
+ - Each user flow becomes one or more screens
613
+ - Each screen satisfies specific acceptance criteria
614
+ 3. **Define information architecture:**
615
+ - What entities are displayed? (things)
616
+ - What actions are available? (events to be created)
617
+ - What relationships are shown? (connections)
618
+ 4. **Create wireframe for each screen:**
619
+ - Layout pattern (centered-form, 3-column-grid, dashboard-sidebar)
620
+ - Component structure (Card > CardContent > Form > Input)
621
+ - Responsive strategy (mobile, tablet, desktop)
622
+ 5. **Ensure design enables tests to pass:**
623
+ - Map each acceptance criterion to UI element
624
+ - Add loading states for async operations
625
+ - Add error states for failure cases
626
+ 6. **Validate accessibility requirements:**
627
+ - WCAG AA contrast ratios (4.5:1 body, 3:1 large)
628
+ - Keyboard navigation (Tab, Enter, Escape)
629
+ - ARIA labels and focus management
630
+ 7. **Create wireframe thing:**
631
+ - Insert into things table (type: "design")
632
+ - Create connection (implements) to feature
633
+ - Log event (content_event with action: "created", contentType: "wireframe")
634
+
635
+ **Output (Ontology Operations):**
636
+ ```typescript
637
+ // 1. Create wireframe thing
638
+ const wireframeId = await ctx.db.insert("things", {
639
+ type: "design", // Not a separate thing type, use properties.designType
640
+ name: "Wireframe: Course CRUD",
641
+ properties: {
642
+ designType: "wireframe",
643
+ featureId: featureId,
644
+ screens: [
645
+ {
646
+ name: "create-course",
647
+ path: "/courses/new",
648
+ layout: "centered-form",
649
+ components: [
650
+ { type: "Card", contains: ["CardHeader", "CardContent"] },
651
+ { type: "Form", fields: ["title", "description", "price"] },
652
+ { type: "Button", variant: "primary", label: "Create Course" }
653
+ ],
654
+ userFlow: "Flow 1: Create a Course",
655
+ acceptanceCriteria: [
656
+ "User can create course with just title",
657
+ "User sees loading state",
658
+ "User sees success confirmation"
659
+ ],
660
+ responsive: {
661
+ mobile: "single-column",
662
+ tablet: "single-column",
663
+ desktop: "centered-max-w-2xl"
664
+ }
665
+ }
666
+ ],
667
+ designSystem: "shadcn-ui",
668
+ framework: "astro-react",
669
+ brandGuidelines: org.properties.brandColors
670
+ },
671
+ status: "draft",
672
+ createdAt: Date.now(),
673
+ updatedAt: Date.now()
674
+ });
675
+
676
+ // 2. Create connection (design implements feature)
677
+ await ctx.db.insert("connections", {
678
+ fromThingId: wireframeId,
679
+ toThingId: featureId,
680
+ relationshipType: "part_of", // Use part_of instead of implements
681
+ metadata: {
682
+ stage: "5_design",
683
+ completeness: 100,
684
+ reviewed: false
685
+ },
686
+ createdAt: Date.now()
687
+ });
688
+
689
+ // 3. Log event
690
+ await ctx.db.insert("events", {
691
+ type: "content_event", // Use consolidated event type
692
+ actorId: designAgentId,
693
+ targetId: wireframeId,
694
+ timestamp: Date.now(),
695
+ metadata: {
696
+ action: "created",
697
+ contentType: "wireframe",
698
+ featureId: featureId,
699
+ screens: ["create-course", "edit-course", "delete-confirmation"],
700
+ format: "structured-json"
701
+ }
702
+ });
703
+
704
+ // 4. Link design patterns from knowledge base
705
+ const relevantPatterns = await vectorSearch("knowledge", {
706
+ query: "centered form layout for CRUD operations",
707
+ filter: { labels: ["pattern:centered-form", "layout:single-column"] }
708
+ });
709
+
710
+ for (const pattern of relevantPatterns.slice(0, 3)) {
711
+ await ctx.db.insert("thingKnowledge", {
712
+ thingId: wireframeId,
713
+ knowledgeId: pattern._id,
714
+ role: "label", // This design uses these patterns
715
+ metadata: { relevance: pattern.score },
716
+ createdAt: Date.now()
717
+ });
718
+ }
719
+ ```
720
+
721
+ **Example Implementation:**
722
+ ```typescript
723
+ // Design Agent Service (Effect.ts pattern)
724
+ export class DesignAgentService extends Effect.Service<DesignAgentService>()(
725
+ "DesignAgentService",
726
+ {
727
+ effect: Effect.gen(function* () {
728
+ const db = yield* ConvexDatabase;
729
+
730
+ return {
731
+ createWireframes: (args: { featureId: Id<"things">, testId: Id<"things"> }) =>
732
+ Effect.gen(function* () {
733
+ // 1. Get feature thing (ontology dimension 3)
734
+ const feature = yield* Effect.tryPromise(() => db.get(args.featureId));
735
+ if (feature.type !== "feature") {
736
+ return yield* Effect.fail({ _tag: "InvalidFeatureType" });
737
+ }
738
+
739
+ // 2. Get test thing (ontology dimension 3)
740
+ const test = yield* Effect.tryPromise(() => db.get(args.testId));
741
+ const userFlows = test.properties.userFlows;
742
+ const acceptanceCriteria = test.properties.acceptanceCriteria;
743
+
744
+ // 3. Get organization thing (ontology dimension 1)
745
+ const org = yield* Effect.tryPromise(() =>
746
+ db.get(feature.properties.organizationId)
747
+ );
748
+ const brandGuidelines = org.properties.brandColors;
749
+
750
+ // 4. Get relevant design patterns from knowledge (ontology dimension 6)
751
+ const patterns = yield* Effect.tryPromise(() =>
752
+ db.query("knowledge")
753
+ .withIndex("by_type", q => q.eq("knowledgeType", "chunk"))
754
+ .filter(q =>
755
+ q.or(
756
+ q.eq(q.field("labels"), "pattern:centered-form"),
757
+ q.eq(q.field("labels"), "layout:single-column")
758
+ )
759
+ )
760
+ .take(5)
761
+ );
762
+
763
+ // 5. Map flows to screens
764
+ const screens = userFlows.map(flow => ({
765
+ name: flow.name,
766
+ layout: determineLayout(flow),
767
+ components: mapFlowToComponents(flow, acceptanceCriteria),
768
+ userFlow: flow.goal,
769
+ acceptanceCriteria: flow.criteria
770
+ }));
771
+
772
+ // 6. Create wireframe thing (ontology dimension 3)
773
+ const wireframeId = yield* Effect.tryPromise(() =>
774
+ db.insert("things", {
775
+ type: "design",
776
+ name: `Wireframe: ${feature.name}`,
777
+ properties: {
778
+ designType: "wireframe",
779
+ featureId: args.featureId,
780
+ screens: screens,
781
+ brandGuidelines: brandGuidelines,
782
+ patternsUsed: patterns.map(p => p._id)
783
+ },
784
+ status: "draft",
785
+ createdAt: Date.now(),
786
+ updatedAt: Date.now()
787
+ })
788
+ );
789
+
790
+ // 7. Create connection (ontology dimension 4)
791
+ yield* Effect.tryPromise(() =>
792
+ db.insert("connections", {
793
+ fromThingId: wireframeId,
794
+ toThingId: args.featureId,
795
+ relationshipType: "part_of",
796
+ metadata: { stage: "5_design" },
797
+ createdAt: Date.now()
798
+ })
799
+ );
800
+
801
+ // 8. Log event (ontology dimension 5)
802
+ yield* Effect.tryPromise(() =>
803
+ db.insert("events", {
804
+ type: "content_event",
805
+ actorId: designAgentId,
806
+ targetId: wireframeId,
807
+ timestamp: Date.now(),
808
+ metadata: {
809
+ action: "created",
810
+ contentType: "wireframe",
811
+ featureId: args.featureId,
812
+ screens: screens.map(s => s.name)
813
+ }
814
+ })
815
+ );
816
+
817
+ // 9. Link knowledge patterns (ontology dimension 6)
818
+ for (const pattern of patterns) {
819
+ yield* Effect.tryPromise(() =>
820
+ db.insert("thingKnowledge", {
821
+ thingId: wireframeId,
822
+ knowledgeId: pattern._id,
823
+ role: "label",
824
+ metadata: { usageContext: "wireframe-creation" },
825
+ createdAt: Date.now()
826
+ })
827
+ );
828
+ }
829
+
830
+ return { wireframeId, screens };
831
+ })
832
+ };
833
+ }),
834
+ dependencies: [ConvexDatabase.Default]
835
+ }
836
+ ) {}
837
+ ```
838
+
839
+ ### 2. define_components
840
+
841
+ **Purpose:** Specify React component structure, props, and state management patterns AFTER wireframes are created.
842
+
843
+ **Workflow Position:** Stage 5 (design) - runs after create_wireframes completes.
844
+
845
+ **Input:**
846
+ - Wireframes (thing type: design, designType: "wireframe")
847
+ - Feature specification (entity operations from feature thing)
848
+ - shadcn/ui component library (50+ components)
849
+
850
+ **Process:**
851
+ 1. **Read wireframe thing:**
852
+ - Extract screens and components
853
+ - Identify reusable component patterns
854
+ 2. **Define component hierarchy:**
855
+ - Pages (Astro pages with SSR)
856
+ - Features (React components with client:load)
857
+ - UI (shadcn/ui base components)
858
+ 3. **Specify props and TypeScript types:**
859
+ - Extract entity IDs (Id<"things">)
860
+ - Define callbacks (onSuccess, onCancel)
861
+ 4. **Map Convex queries/mutations to component state:**
862
+ - Queries: useQuery(api.entities.get)
863
+ - Mutations: useMutation(api.entities.create)
864
+ 5. **Define loading/error states:**
865
+ - isLoading: boolean
866
+ - error: string | null
867
+ 6. **Document component usage:**
868
+ - Import path
869
+ - Example usage
870
+ - Accessibility requirements
871
+ 7. **Create component-definition thing:**
872
+ - Insert into things table (type: "design", designType: "component-definition")
873
+ - Create connection (part_of) to feature
874
+ - Log event (content_event with action: "created", contentType: "component-definition")
875
+
876
+ **Output (Ontology Operations):**
877
+ ```typescript
878
+ // 1. Create component-definition thing
879
+ const componentId = await ctx.db.insert("things", {
880
+ type: "design",
881
+ name: "Component: CourseForm",
882
+ properties: {
883
+ designType: "component-definition",
884
+ featureId: featureId,
885
+ component: {
886
+ name: "CourseForm",
887
+ path: "src/components/features/courses/CourseForm.tsx",
888
+ props: {
889
+ courseId: "Id<'things'> | undefined",
890
+ onSuccess: "(courseId: Id<'things'>) => void",
891
+ onCancel: "() => void"
892
+ },
893
+ state: {
894
+ queries: ["api.courses.get"],
895
+ mutations: ["api.courses.create", "api.courses.update"],
896
+ loading: "boolean",
897
+ error: "string | null"
898
+ },
899
+ shadcnComponents: ["Card", "Button", "Input", "Label"],
900
+ accessibility: {
901
+ ariaLabels: ["Create course form"],
902
+ keyboardNav: true,
903
+ focusManagement: "auto-focus first input"
904
+ }
905
+ }
906
+ },
907
+ status: "active",
908
+ createdAt: Date.now(),
909
+ updatedAt: Date.now()
910
+ });
911
+
912
+ // 2. Create connection (component part of feature)
913
+ await ctx.db.insert("connections", {
914
+ fromThingId: componentId,
915
+ toThingId: featureId,
916
+ relationshipType: "part_of",
917
+ metadata: { stage: "5_design" },
918
+ createdAt: Date.now()
919
+ });
920
+
921
+ // 3. Log event
922
+ await ctx.db.insert("events", {
923
+ type: "content_event",
924
+ actorId: designAgentId,
925
+ targetId: componentId,
926
+ timestamp: Date.now(),
927
+ metadata: {
928
+ action: "created",
929
+ contentType: "component-definition",
930
+ componentName: "CourseForm",
931
+ featureId: featureId
932
+ }
933
+ });
934
+ ```
935
+
936
+ ### 3. set_tokens
937
+
938
+ **Purpose:** Define design tokens (colors, spacing, typography) from organization brand guidelines, ensuring WCAG accessibility.
939
+
940
+ **Workflow Position:** Stage 5 (design) - can run in parallel with create_wireframes.
941
+
942
+ **Input:**
943
+ - Organization brand guidelines (from organization thing)
944
+ - Tailwind v4 CSS-based configuration
945
+ - WCAG accessibility requirements (AA minimum)
946
+
947
+ **Process:**
948
+ 1. **Read organization thing (ontology dimension 1):**
949
+ - Get brandColors (primary, secondary, accent)
950
+ - Get typography preferences
951
+ - Get spacing system
952
+ 2. **Generate HSL color palette:**
953
+ - Convert brand colors to HSL format
954
+ - Generate variants (foreground, muted, destructive)
955
+ 3. **Define spacing scale:**
956
+ - Base unit: 4px (or org preference)
957
+ - Scale: [4, 8, 12, 16, 24, 32, 48, 64, 96, 128]
958
+ 4. **Define typography scale:**
959
+ - Modular scale 1.25x
960
+ - Weights: 400, 500, 600, 700
961
+ - Line heights: 1.25, 1.5, 1.625
962
+ 5. **Validate contrast ratios (WCAG AA):**
963
+ - Body text: ≥ 4.5:1
964
+ - Large text (≥18px): ≥ 3:1
965
+ 6. **Generate Tailwind v4 @theme configuration:**
966
+ - CSS variables with HSL values
967
+ - Dark mode overrides
968
+ 7. **Create design-tokens thing:**
969
+ - Insert into things table (type: "design", designType: "design-tokens")
970
+ - Create connection (configured_by) to organization
971
+ - Log event (content_event with action: "created", contentType: "design-tokens")
972
+ 8. **Store as knowledge chunk (ontology dimension 6):**
973
+ - Enable RAG for token system reuse
974
+ - Link to organization for context
975
+
976
+ **Output (Ontology Operations):**
977
+ ```typescript
978
+ // 1. Create design-tokens thing
979
+ const tokensId = await ctx.db.insert("things", {
980
+ type: "design",
981
+ name: "Design Tokens: ${org.name}",
982
+ properties: {
983
+ designType: "design-tokens",
984
+ organizationId: organizationId,
985
+ tokens: {
986
+ colors: {
987
+ background: "0 0% 100%",
988
+ foreground: "222.2 84% 4.9%",
989
+ primary: "221 83% 53%", // From org.properties.brandColors
990
+ "primary-foreground": "210 40% 98%",
991
+ // ... full palette
992
+ },
993
+ spacing: {
994
+ base: 4,
995
+ scale: [4, 8, 12, 16, 24, 32, 48, 64, 96, 128]
996
+ },
997
+ typography: {
998
+ fontFamily: { sans: "Inter, sans-serif" },
999
+ scale: { base: "1rem", lg: "1.125rem", xl: "1.25rem" },
1000
+ weights: { normal: 400, medium: 500, semibold: 600, bold: 700 }
1001
+ },
1002
+ borderRadius: {
1003
+ sm: "0.25rem", md: "0.5rem", lg: "0.75rem", full: "9999px"
1004
+ }
1005
+ },
1006
+ accessibilityValidation: {
1007
+ wcagLevel: "AA",
1008
+ contrastRatios: {
1009
+ "foreground on background": 16.4,
1010
+ "primary on background": 4.5
1011
+ },
1012
+ issues: []
1013
+ }
1014
+ },
1015
+ status: "active",
1016
+ createdAt: Date.now(),
1017
+ updatedAt: Date.now()
1018
+ });
1019
+
1020
+ // 2. Create connection (tokens configured by organization)
1021
+ await ctx.db.insert("connections", {
1022
+ fromThingId: tokensId,
1023
+ toThingId: organizationId,
1024
+ relationshipType: "created_by", // Use created_by instead of configured_by
1025
+ metadata: { tokenVersion: "1.0.0" },
1026
+ createdAt: Date.now()
1027
+ });
1028
+
1029
+ // 3. Log event
1030
+ await ctx.db.insert("events", {
1031
+ type: "content_event",
1032
+ actorId: designAgentId,
1033
+ targetId: tokensId,
1034
+ timestamp: Date.now(),
1035
+ metadata: {
1036
+ action: "created",
1037
+ contentType: "design-tokens",
1038
+ organizationId: organizationId,
1039
+ wcagCompliance: "AA",
1040
+ contrastIssues: 0
1041
+ }
1042
+ });
1043
+
1044
+ // 4. Store as knowledge chunk (for RAG)
1045
+ const knowledgeId = await ctx.db.insert("knowledge", {
1046
+ knowledgeType: "chunk",
1047
+ text: `Design Token System: ${org.name}
1048
+
1049
+ Brand Colors:
1050
+ - Primary: hsl(221, 83%, 53%) - Blue
1051
+ - Secondary: hsl(142, 76%, 36%) - Green
1052
+ - Accent: hsl(48, 96%, 53%) - Yellow
1053
+
1054
+ Spacing: 4px base unit
1055
+ Typography: Inter font family
1056
+ Border Radius: Modern rounded (8px)
1057
+
1058
+ WCAG AA Compliant: All contrast ratios meet or exceed requirements.`,
1059
+ embedding: [...],
1060
+ embeddingModel: "text-embedding-3-large",
1061
+ sourceThingId: tokensId,
1062
+ labels: ["design-system", "tokens", `org:${org.slug}`],
1063
+ metadata: {
1064
+ organizationId: organizationId,
1065
+ framework: "tailwind-v4"
1066
+ },
1067
+ createdAt: Date.now()
1068
+ });
1069
+
1070
+ // 5. Link knowledge to tokens thing
1071
+ await ctx.db.insert("thingKnowledge", {
1072
+ thingId: tokensId,
1073
+ knowledgeId: knowledgeId,
1074
+ role: "summary", // Junction role (ontology line 196)
1075
+ metadata: { tokenVersion: "1.0.0" },
1076
+ createdAt: Date.now()
1077
+ });
1078
+ ```
1079
+
1080
+ ---
1081
+
1082
+ ## Input
1083
+
1084
+ **From Quality Agent (stage 4_tests):**
1085
+ - Feature specification (thing type: feature)
1086
+ - Test definitions (thing type: test)
1087
+ - User flows (what users must accomplish)
1088
+ - Acceptance criteria (how we know it works)
1089
+ - Accessibility requirements (WCAG AA minimum)
1090
+
1091
+ **From Organization (ontology dimension 1):**
1092
+ - Brand guidelines (brandColors, typography, spacing)
1093
+ - Design preferences (borderRadius, shadows)
1094
+ - Logo and visual identity
1095
+
1096
+ **From Knowledge Base (ontology dimension 6):**
1097
+ - Design patterns (layout patterns, component patterns)
1098
+ - Previous designs (similar features, proven solutions)
1099
+ - Accessibility guidelines (WCAG best practices)
1100
+
1101
+ **From Workflow Events (ontology dimension 5):**
1102
+ - `quality_check_complete` event (tests defined, ready for design)
1103
+ - `feature_assigned` event (design work assigned to this agent)
1104
+ - `test_passed` event (validates design decisions)
1105
+
1106
+ ---
1107
+
1108
+ ## Output
1109
+
1110
+ **Things Created (ontology dimension 3):**
1111
+ - Wireframe things (type: "design", designType: "wireframe")
1112
+ - Component-definition things (type: "design", designType: "component-definition")
1113
+ - Design-token things (type: "design", designType: "design-tokens")
1114
+
1115
+ **Connections Created (ontology dimension 4):**
1116
+ - part_of: design → feature (design belongs to feature)
1117
+ - created_by: design → design_agent (ownership)
1118
+ - tested_by: test → design (test informs design)
1119
+
1120
+ **Events Logged (ontology dimension 5):**
1121
+ - content_event (action: "created", contentType: "wireframe")
1122
+ - content_event (action: "created", contentType: "component-definition")
1123
+ - content_event (action: "created", contentType: "design-tokens")
1124
+ - quality_check_complete (checkType: "accessibility")
1125
+ - agent_completed (action: "design_complete")
1126
+
1127
+ **Knowledge Built (ontology dimension 6):**
1128
+ - Design pattern chunks (reusable patterns for future work)
1129
+ - Design token documentation (brand system knowledge)
1130
+ - thingKnowledge junctions (link patterns to designs)
1131
+
1132
+ ---
1133
+
1134
+ ## Decision Framework
1135
+
1136
+ ### Decision 1: What layout pattern fits this feature?
1137
+
1138
+ **Question:** What's the primary user goal and content structure?
1139
+
1140
+ **Process:**
1141
+ 1. Read feature thing (type, name, properties)
1142
+ 2. Identify primary entity being displayed/edited (course, blog_post, user)
1143
+ 3. Check user flows from test thing (create, list, detail, edit)
1144
+ 4. Match to proven pattern from knowledge base
1145
+
1146
+ **Patterns (stored in knowledge dimension):**
1147
+ - **Content-heavy (blog, docs):** 3-column grid [nav | content | meta]
1148
+ - **Dashboard (analytics, admin):** Sidebar + main area with cards
1149
+ - **Form-based (create/edit):** Centered single column with max-w-2xl
1150
+ - **E-commerce (products):** Grid of cards with filters
1151
+ - **Focus area (email, chat):** Central white panel with muted sidebars
1152
+
1153
+ **Example:**
1154
+ ```typescript
1155
+ // Query knowledge base for similar features
1156
+ const similarFeatures = await vectorSearch("knowledge", {
1157
+ query: feature.name, // "Course CRUD"
1158
+ filter: { labels: ["pattern:layout", "use-case:crud"] }
1159
+ });
1160
+
1161
+ // Extract pattern from highest-scoring result
1162
+ const recommendedPattern = similarFeatures[0].metadata.layoutPattern; // "centered-form"
1163
+
1164
+ // Validate pattern matches user flows
1165
+ if (userFlows.includes("create") || userFlows.includes("edit")) {
1166
+ return "centered-form"; // CRUD operations use centered forms
1167
+ } else if (userFlows.includes("list") || userFlows.includes("browse")) {
1168
+ return "grid-of-cards"; // List views use card grids
1169
+ }
1170
+ ```
1171
+
1172
+ ### Decision 2: What components does this need?
1173
+
1174
+ **Question:** What shadcn/ui components enable the user flow?
1175
+
1176
+ **Process:**
1177
+ 1. Read wireframe thing (screens array)
1178
+ 2. For each screen, identify interactive elements
1179
+ 3. Map elements to shadcn/ui components
1180
+ 4. Validate components satisfy acceptance criteria
1181
+
1182
+ **Mapping (stored as knowledge chunk):**
1183
+ - **Create/Edit forms:** Card, Button, Input, Label, Select, Textarea
1184
+ - **Lists:** Card, Badge, Separator
1185
+ - **Data tables:** Table, Pagination, Dropdown
1186
+ - **Modals:** Dialog, AlertDialog (for destructive actions)
1187
+ - **Navigation:** NavigationMenu, Tabs, Breadcrumb
1188
+ - **Feedback:** Toast, Alert, Progress, Spinner
1189
+
1190
+ **Example:**
1191
+ ```typescript
1192
+ // User Flow: "Delete a Course"
1193
+ // Acceptance Criterion: "Delete requires confirmation"
1194
+
1195
+ // Query knowledge for "delete confirmation" pattern
1196
+ const deletePattern = await db.query("knowledge")
1197
+ .withIndex("by_type", q => q.eq("knowledgeType", "chunk"))
1198
+ .filter(q => q.eq(q.field("labels"), "pattern:delete-confirmation"))
1199
+ .first();
1200
+
1201
+ // Pattern recommends: AlertDialog with destructive button
1202
+ components: [
1203
+ { type: "AlertDialog", usage: "Confirmation modal" },
1204
+ { type: "Button", variant: "destructive", label: "Delete Course" },
1205
+ { type: "Card", usage: "Course preview in modal" }
1206
+ ]
1207
+
1208
+ // Validate against acceptance criteria
1209
+ const criterion = "Delete requires confirmation";
1210
+ const componentSatisfies = components.some(c => c.type === "AlertDialog"); // ✓ Pass
1211
+ ```
1212
+
1213
+ ### Decision 3: How does this design enable tests to pass?
1214
+
1215
+ **Question:** Can I trace each acceptance criterion to a UI element?
1216
+
1217
+ **Process:**
1218
+ 1. Read test thing (acceptanceCriteria array)
1219
+ 2. For each criterion, identify corresponding UI element in wireframe
1220
+ 3. If no element exists, add to design
1221
+ 4. Validate all criteria are satisfied
1222
+
1223
+ **Validation:**
1224
+ ```typescript
1225
+ // Map acceptance criteria to UI elements
1226
+ for (const criterion of test.properties.acceptanceCriteria) {
1227
+ const matchingElement = wireframe.screens
1228
+ .flatMap(s => s.components)
1229
+ .find(c => criterion.includes(c.type.toLowerCase()));
1230
+
1231
+ if (!matchingElement) {
1232
+ // Criterion not satisfied - add missing element
1233
+ console.warn(`Missing UI element for: ${criterion}`);
1234
+ // Add to design
1235
+ }
1236
+ }
1237
+
1238
+ // Example: "User sees success confirmation"
1239
+ // Design Decision: Add Toast notification on success
1240
+ {
1241
+ component: "Toast",
1242
+ trigger: "onSuccess callback from mutation",
1243
+ message: "Course created successfully",
1244
+ variant: "success",
1245
+ duration: 3000
1246
+ }
1247
+ ```
1248
+
1249
+ **Store decision as knowledge:**
1250
+ ```typescript
1251
+ await ctx.db.insert("knowledge", {
1252
+ knowledgeType: "chunk",
1253
+ text: `Design Decision: Success Feedback via Toast
1254
+
1255
+ Acceptance Criterion: "User sees success confirmation"
1256
+
1257
+ Solution: Add Toast component triggered on successful mutation.
1258
+
1259
+ Implementation:
1260
+ - Component: Toast (shadcn/ui)
1261
+ - Trigger: onSuccess callback from useMutation
1262
+ - Message: "{Entity} {action} successfully"
1263
+ - Duration: 3000ms`,
1264
+ embedding: [...],
1265
+ sourceThingId: designAgentId,
1266
+ labels: ["decision:success-feedback", "pattern:toast", "criterion:confirmation"],
1267
+ metadata: { frequency: "very-common" },
1268
+ createdAt: Date.now()
1269
+ });
1270
+ ```
1271
+
1272
+ ### Decision 4: Does this meet accessibility requirements?
1273
+
1274
+ **Question:** Does design pass WCAG AA validation?
1275
+
1276
+ **Checklist (stored as knowledge chunk):**
1277
+ - [ ] Color contrast ratio ≥ 4.5:1 for body text (WCAG AA)
1278
+ - [ ] Color contrast ratio ≥ 3:1 for large text (≥18px)
1279
+ - [ ] Keyboard navigation works (Tab, Enter, Escape)
1280
+ - [ ] Focus states visible (outline or ring)
1281
+ - [ ] ARIA labels on interactive elements
1282
+ - [ ] Form labels associated with inputs
1283
+ - [ ] Error messages announced to screen readers
1284
+ - [ ] Loading states communicated
1285
+
1286
+ **Example:**
1287
+ ```typescript
1288
+ // Validate contrast ratios
1289
+ const contrastRatios = {
1290
+ "text-foreground on bg-background": calculateContrast(
1291
+ tokens.colors.foreground,
1292
+ tokens.colors.background
1293
+ ), // 16.4 - ✓ Pass
1294
+ "text-muted-foreground on bg-background": calculateContrast(
1295
+ tokens.colors["muted-foreground"],
1296
+ tokens.colors.background
1297
+ ), // 5.2 - ✓ Pass
1298
+ "text-primary on bg-card": calculateContrast(
1299
+ tokens.colors.primary,
1300
+ tokens.colors.card
1301
+ ) // 4.5 - ✓ Pass (exactly WCAG AA)
1302
+ };
1303
+
1304
+ // Log accessibility validation event
1305
+ await ctx.db.insert("events", {
1306
+ type: "quality_check_complete",
1307
+ actorId: designAgentId,
1308
+ targetId: tokensId,
1309
+ timestamp: Date.now(),
1310
+ metadata: {
1311
+ checkType: "accessibility",
1312
+ wcagLevel: "AA",
1313
+ contrastRatios: contrastRatios,
1314
+ keyboardNav: true,
1315
+ ariaLabels: true,
1316
+ issuesFound: []
1317
+ }
1318
+ });
1319
+ ```
1320
+
1321
+ ---
1322
+
1323
+ ## Key Behaviors
1324
+
1325
+ ### 1. Design is NOT decoration
1326
+ - Every design decision must enable a user flow or test to pass
1327
+ - Remove unnecessary visual elements (minimal yet sophisticated)
1328
+ - Prioritize readability and usability over aesthetics
1329
+ - **Ontology mapping:** Each design element traces back to acceptance criterion (test thing)
1330
+
1331
+ ### 2. Design BEFORE implementation
1332
+ - Specialists should receive complete wireframes + component specs
1333
+ - No "design as you go" - front-load design decisions
1334
+ - Changes to design should trigger re-validation of tests
1335
+ - **Ontology mapping:** Stage 5 (design) completes BEFORE stage 6 (implementation)
1336
+
1337
+ ### 3. Accessibility is non-negotiable
1338
+ - WCAG AA compliance is the minimum
1339
+ - Use semantic HTML (forms use `<form>`, buttons use `<button>`)
1340
+ - Test with keyboard only (no mouse)
1341
+ - Validate with screen reader simulation
1342
+ - **Ontology mapping:** Log accessibility validation as quality_check_complete event
1343
+
1344
+ ### 4. Brand consistency
1345
+ - Pull colors from organization settings (don't hard-code)
1346
+ - Use organization's typography preferences
1347
+ - Apply organization's border radius style (modern/sharp/soft)
1348
+ - **Ontology mapping:** Query organization thing for brandColors, typography, spacing
1349
+
1350
+ ### 5. Responsive by default
1351
+ - Mobile-first thinking (what's the smallest screen?)
1352
+ - Test wireframes at 320px, 768px, 1024px, 1440px
1353
+ - Use Tailwind responsive variants (sm:, md:, lg:, xl:)
1354
+ - **Ontology mapping:** Store responsive strategy in wireframe properties
1355
+
1356
+ ### 6. Build reusable knowledge
1357
+ - Store successful patterns as knowledge chunks
1358
+ - Link patterns to designs via thingKnowledge junctions
1359
+ - Enable future designs to learn from past work
1360
+ - **Ontology mapping:** Every pattern becomes searchable via vector embeddings
1361
+
1362
+ ### 7. Event-driven coordination
1363
+ - Watch for quality_check_complete event (stage 4 → stage 5 transition)
1364
+ - Emit content_event when designs are created
1365
+ - No manual handoffs - autonomous work pickup
1366
+ - **Ontology mapping:** All coordination via events table (ontology dimension 5)
1367
+
1368
+ ---
1369
+
1370
+ ## Communication Patterns
1371
+
1372
+ ### Event-Driven Coordination (Ontology Dimension 5)
1373
+
1374
+ **Watches for:**
1375
+ - `quality_check_complete` → Begin design work (stage 4 complete)
1376
+ - `test_passed` → Validates design decisions
1377
+ - `feature_assigned` → New work to pick up
1378
+
1379
+ **Emits:**
1380
+ - `agent_executed` → Design work started
1381
+ - `content_event` (contentType: "wireframe") → Wireframes ready for review
1382
+ - `content_event` (contentType: "component-definition") → Component specs ready
1383
+ - `content_event` (contentType: "design-tokens") → Token system configured
1384
+ - `quality_check_complete` (checkType: "accessibility") → WCAG validated
1385
+ - `agent_completed` → Design phase complete
1386
+
1387
+ **No Handoffs:**
1388
+ Design agent watches events table autonomously. When `quality_check_complete` appears with `testsCreated: true`, design agent picks up work automatically.
1389
+
1390
+ **Query Pattern:**
1391
+ ```typescript
1392
+ // Watch for quality_check_complete events
1393
+ const readyForDesign = await ctx.db
1394
+ .query("events")
1395
+ .withIndex("type_time", q =>
1396
+ q.eq("type", "quality_check_complete")
1397
+ )
1398
+ .filter(q =>
1399
+ q.and(
1400
+ q.eq(q.field("metadata.testsCreated"), true),
1401
+ q.eq(q.field("metadata.status"), "approved")
1402
+ )
1403
+ )
1404
+ .order("desc")
1405
+ .take(10);
1406
+
1407
+ // For each event, check if design already started
1408
+ for (const event of readyForDesign) {
1409
+ const existingDesign = await ctx.db
1410
+ .query("connections")
1411
+ .withIndex("to_type", q =>
1412
+ q.eq("toThingId", event.targetId)
1413
+ .eq("relationshipType", "part_of")
1414
+ )
1415
+ .filter(q => q.eq(q.field("metadata.stage"), "5_design"))
1416
+ .first();
1417
+
1418
+ if (!existingDesign) {
1419
+ // Start design work
1420
+ await createWireframes({ featureId: event.targetId });
1421
+ }
1422
+ }
1423
+ ```
1424
+
1425
+ ---
1426
+
1427
+ ## Examples
1428
+
1429
+ ### Example 1: Create Wireframes for Course CRUD (6-Dimension Operations)
1430
+
1431
+ **Input:**
1432
+ ```typescript
1433
+ // Feature thing
1434
+ {
1435
+ _id: "feature_abc123",
1436
+ type: "feature",
1437
+ name: "2-1-course-crud",
1438
+ properties: {
1439
+ planId: "2-course-platform",
1440
+ organizationId: "org_xyz789",
1441
+ description: "CRUD operations for courses",
1442
+ entities: ["course"],
1443
+ operations: ["create", "read", "update", "delete"]
1444
+ },
1445
+ status: "active",
1446
+ createdAt: Date.now(),
1447
+ updatedAt: Date.now()
1448
+ }
1449
+
1450
+ // Test thing (from quality agent)
1451
+ {
1452
+ _id: "test_def456",
1453
+ type: "test",
1454
+ name: "Test: Course CRUD",
1455
+ properties: {
1456
+ featureId: "feature_abc123",
1457
+ userFlows: [
1458
+ {
1459
+ name: "create-course",
1460
+ goal: "Create a Course",
1461
+ steps: ["Navigate to /courses/new", "Fill title field", "Click Create", "See success"],
1462
+ timing: "< 10 seconds"
1463
+ },
1464
+ {
1465
+ name: "update-course",
1466
+ goal: "Update a Course",
1467
+ steps: ["Navigate to /courses/[id]/edit", "Modify fields", "Click Save", "See success"],
1468
+ timing: "< 5 seconds"
1469
+ },
1470
+ {
1471
+ name: "delete-course",
1472
+ goal: "Delete a Course",
1473
+ steps: ["Click Delete button", "See confirmation modal", "Click Confirm", "See success"],
1474
+ timing: "< 3 seconds"
1475
+ }
1476
+ ],
1477
+ acceptanceCriteria: [
1478
+ "User can create course with just title",
1479
+ "User sees loading state during save",
1480
+ "Delete requires confirmation modal",
1481
+ "Form validates before submission",
1482
+ "Success message appears after each operation"
1483
+ ]
1484
+ },
1485
+ status: "active",
1486
+ createdAt: Date.now(),
1487
+ updatedAt: Date.now()
1488
+ }
1489
+
1490
+ // Organization thing
1491
+ {
1492
+ _id: "org_xyz789",
1493
+ type: "organization",
1494
+ name: "Fitness Academy",
1495
+ properties: {
1496
+ slug: "fitness-academy",
1497
+ brandColors: {
1498
+ primary: "221 83% 53%", // Blue
1499
+ secondary: "142 76% 36%", // Green
1500
+ accent: "48 96% 53%" // Yellow
1501
+ },
1502
+ typography: {
1503
+ headingFont: "Inter",
1504
+ bodyFont: "Inter"
1505
+ },
1506
+ borderRadius: "modern-rounded"
1507
+ },
1508
+ status: "active",
1509
+ createdAt: Date.now(),
1510
+ updatedAt: Date.now()
1511
+ }
1512
+ ```
1513
+
1514
+ **Process (6-Dimension Operations):**
1515
+
1516
+ ```typescript
1517
+ // 1. THINGS: Get feature, test, organization
1518
+ const feature = await ctx.db.get("feature_abc123");
1519
+ const test = await ctx.db.get("test_def456");
1520
+ const org = await ctx.db.get("org_xyz789");
1521
+
1522
+ // 2. KNOWLEDGE: Query design patterns
1523
+ const patterns = await ctx.db
1524
+ .query("knowledge")
1525
+ .withIndex("by_type", q => q.eq("knowledgeType", "chunk"))
1526
+ .filter(q =>
1527
+ q.or(
1528
+ q.eq(q.field("labels"), "pattern:centered-form"),
1529
+ q.eq(q.field("labels"), "use-case:crud")
1530
+ )
1531
+ )
1532
+ .take(5);
1533
+
1534
+ // 3. Map user flows to screens
1535
+ const screens = test.properties.userFlows.map(flow => ({
1536
+ name: flow.name,
1537
+ path: flow.name === "create-course" ? "/courses/new" : `/courses/[id]/${flow.name.split('-')[1]}`,
1538
+ layout: "centered-form",
1539
+ components: [
1540
+ { type: "Card", contains: ["CardHeader", "CardContent"] },
1541
+ { type: "Form", fields: ["title", "description", "price"] },
1542
+ { type: "Button", variant: "primary", label: flow.name.includes("create") ? "Create" : "Save" }
1543
+ ],
1544
+ userFlow: flow.goal,
1545
+ acceptanceCriteria: test.properties.acceptanceCriteria.filter(c =>
1546
+ c.toLowerCase().includes(flow.name.split('-')[0])
1547
+ ),
1548
+ responsive: {
1549
+ mobile: "single-column p-4",
1550
+ tablet: "max-w-2xl mx-auto p-6",
1551
+ desktop: "max-w-2xl mx-auto p-8"
1552
+ }
1553
+ }));
1554
+
1555
+ // 4. THINGS: Create wireframe thing
1556
+ const wireframeId = await ctx.db.insert("things", {
1557
+ type: "design",
1558
+ name: "Wireframe: Course CRUD",
1559
+ properties: {
1560
+ designType: "wireframe",
1561
+ featureId: "feature_abc123",
1562
+ organizationId: "org_xyz789",
1563
+ screens: screens,
1564
+ brandGuidelines: org.properties.brandColors,
1565
+ patternsUsed: patterns.map(p => p._id)
1566
+ },
1567
+ status: "draft",
1568
+ createdAt: Date.now(),
1569
+ updatedAt: Date.now()
1570
+ });
1571
+
1572
+ // 5. CONNECTIONS: Link wireframe to feature
1573
+ await ctx.db.insert("connections", {
1574
+ fromThingId: wireframeId,
1575
+ toThingId: "feature_abc123",
1576
+ relationshipType: "part_of",
1577
+ metadata: {
1578
+ stage: "5_design",
1579
+ completeness: 100,
1580
+ reviewed: false
1581
+ },
1582
+ createdAt: Date.now()
1583
+ });
1584
+
1585
+ // 6. CONNECTIONS: Link wireframe to test (design informed by tests)
1586
+ await ctx.db.insert("connections", {
1587
+ fromThingId: "test_def456",
1588
+ toThingId: wireframeId,
1589
+ relationshipType: "tested_by",
1590
+ metadata: {
1591
+ testsCovered: test.properties.userFlows.length
1592
+ },
1593
+ createdAt: Date.now()
1594
+ });
1595
+
1596
+ // 7. EVENTS: Log wireframe creation
1597
+ await ctx.db.insert("events", {
1598
+ type: "content_event",
1599
+ actorId: "design_agent_001",
1600
+ targetId: wireframeId,
1601
+ timestamp: Date.now(),
1602
+ metadata: {
1603
+ action: "created",
1604
+ contentType: "wireframe",
1605
+ featureId: "feature_abc123",
1606
+ screens: screens.map(s => s.name),
1607
+ format: "structured-json"
1608
+ }
1609
+ });
1610
+
1611
+ // 8. KNOWLEDGE: Link patterns used to wireframe
1612
+ for (const pattern of patterns) {
1613
+ await ctx.db.insert("thingKnowledge", {
1614
+ thingId: wireframeId,
1615
+ knowledgeId: pattern._id,
1616
+ role: "label",
1617
+ metadata: {
1618
+ usageContext: "wireframe-creation",
1619
+ relevance: pattern.metadata.frequency
1620
+ },
1621
+ createdAt: Date.now()
1622
+ });
1623
+ }
1624
+
1625
+ // 9. EVENTS: Log agent completion
1626
+ await ctx.db.insert("events", {
1627
+ type: "agent_completed",
1628
+ actorId: "design_agent_001",
1629
+ targetId: wireframeId,
1630
+ timestamp: Date.now(),
1631
+ metadata: {
1632
+ action: "create_wireframes",
1633
+ duration: 1200,
1634
+ success: true,
1635
+ screensCreated: screens.length
1636
+ }
1637
+ });
1638
+ ```
1639
+
1640
+ **Output (6-Dimension Summary):**
1641
+ - **THINGS:** 1 wireframe thing created
1642
+ - **CONNECTIONS:** 2 connections created (part_of feature, tested_by test)
1643
+ - **EVENTS:** 2 events logged (content_event, agent_completed)
1644
+ - **KNOWLEDGE:** 5 patterns linked via thingKnowledge junctions
1645
+
1646
+ ### Example 2: Set Design Tokens from Organization (Multi-Tenant)
1647
+
1648
+ **Input:**
1649
+ ```typescript
1650
+ // Organization thing
1651
+ {
1652
+ _id: "org_xyz789",
1653
+ type: "organization",
1654
+ name: "Fitness Academy",
1655
+ properties: {
1656
+ slug: "fitness-academy",
1657
+ brandColors: {
1658
+ primary: "221 83% 53%", // Blue
1659
+ secondary: "142 76% 36%", // Green
1660
+ accent: "48 96% 53%" // Yellow
1661
+ },
1662
+ typography: {
1663
+ headingFont: "Inter",
1664
+ bodyFont: "Inter"
1665
+ },
1666
+ borderRadius: "modern-rounded",
1667
+ spacing: { base: 4 }
1668
+ },
1669
+ status: "active",
1670
+ createdAt: Date.now(),
1671
+ updatedAt: Date.now()
1672
+ }
1673
+ ```
1674
+
1675
+ **Process (6-Dimension Operations):**
1676
+
1677
+ ```typescript
1678
+ // 1. THINGS: Get organization
1679
+ const org = await ctx.db.get("org_xyz789");
1680
+
1681
+ // 2. Generate token system
1682
+ const tokens = {
1683
+ colors: {
1684
+ background: "0 0% 100%",
1685
+ foreground: "222.2 84% 4.9%",
1686
+ primary: org.properties.brandColors.primary,
1687
+ "primary-foreground": "210 40% 98%",
1688
+ secondary: org.properties.brandColors.secondary,
1689
+ "secondary-foreground": "210 40% 98%",
1690
+ accent: org.properties.brandColors.accent,
1691
+ "accent-foreground": "222.2 84% 4.9%",
1692
+ // ... full palette
1693
+ },
1694
+ spacing: {
1695
+ base: org.properties.spacing.base,
1696
+ scale: [4, 8, 12, 16, 24, 32, 48, 64, 96, 128]
1697
+ },
1698
+ typography: {
1699
+ fontFamily: {
1700
+ sans: `${org.properties.typography.bodyFont}, ui-sans-serif, sans-serif`
1701
+ }
1702
+ }
1703
+ };
1704
+
1705
+ // 3. Validate accessibility (WCAG AA)
1706
+ const contrastRatios = {
1707
+ "foreground on background": calculateContrast(
1708
+ tokens.colors.foreground,
1709
+ tokens.colors.background
1710
+ ), // Must be ≥ 4.5:1
1711
+ "primary on background": calculateContrast(
1712
+ tokens.colors.primary,
1713
+ tokens.colors.background
1714
+ ) // Must be ≥ 4.5:1
1715
+ };
1716
+
1717
+ const wcagCompliant = Object.values(contrastRatios).every(r => r >= 4.5);
1718
+
1719
+ // 4. THINGS: Create design-tokens thing
1720
+ const tokensId = await ctx.db.insert("things", {
1721
+ type: "design",
1722
+ name: `Design Tokens: ${org.properties.name}`,
1723
+ properties: {
1724
+ designType: "design-tokens",
1725
+ organizationId: org._id,
1726
+ tokens: tokens,
1727
+ accessibilityValidation: {
1728
+ wcagLevel: wcagCompliant ? "AA" : "FAIL",
1729
+ contrastRatios: contrastRatios,
1730
+ issues: wcagCompliant ? [] : ["Low contrast ratios detected"]
1731
+ },
1732
+ tailwindConfig: generateTailwindConfig(tokens)
1733
+ },
1734
+ status: wcagCompliant ? "active" : "draft",
1735
+ createdAt: Date.now(),
1736
+ updatedAt: Date.now()
1737
+ });
1738
+
1739
+ // 5. CONNECTIONS: Link tokens to organization
1740
+ await ctx.db.insert("connections", {
1741
+ fromThingId: tokensId,
1742
+ toThingId: org._id,
1743
+ relationshipType: "created_by",
1744
+ metadata: {
1745
+ tokenVersion: "1.0.0",
1746
+ wcagCompliant: wcagCompliant
1747
+ },
1748
+ createdAt: Date.now()
1749
+ });
1750
+
1751
+ // 6. EVENTS: Log token creation
1752
+ await ctx.db.insert("events", {
1753
+ type: "content_event",
1754
+ actorId: "design_agent_001",
1755
+ targetId: tokensId,
1756
+ timestamp: Date.now(),
1757
+ metadata: {
1758
+ action: "created",
1759
+ contentType: "design-tokens",
1760
+ organizationId: org._id,
1761
+ wcagCompliance: wcagCompliant ? "AA" : "FAIL",
1762
+ contrastIssues: wcagCompliant ? 0 : contrastRatios.length
1763
+ }
1764
+ });
1765
+
1766
+ // 7. KNOWLEDGE: Store token system as chunk
1767
+ const knowledgeId = await ctx.db.insert("knowledge", {
1768
+ knowledgeType: "chunk",
1769
+ text: `Design Token System: ${org.properties.name}
1770
+
1771
+ Brand Colors:
1772
+ - Primary: hsl(${org.properties.brandColors.primary})
1773
+ - Secondary: hsl(${org.properties.brandColors.secondary})
1774
+ - Accent: hsl(${org.properties.brandColors.accent})
1775
+
1776
+ Typography: ${org.properties.typography.bodyFont}
1777
+ Spacing: ${org.properties.spacing.base}px base unit
1778
+ Border Radius: ${org.properties.borderRadius}
1779
+
1780
+ WCAG AA Compliant: ${wcagCompliant ? 'Yes' : 'No'}`,
1781
+ embedding: [...],
1782
+ embeddingModel: "text-embedding-3-large",
1783
+ sourceThingId: tokensId,
1784
+ labels: [
1785
+ "design-system",
1786
+ "tokens",
1787
+ `org:${org.properties.slug}`,
1788
+ `wcag:${wcagCompliant ? 'AA' : 'FAIL'}`
1789
+ ],
1790
+ metadata: {
1791
+ organizationId: org._id,
1792
+ framework: "tailwind-v4",
1793
+ wcagCompliant: wcagCompliant
1794
+ },
1795
+ createdAt: Date.now()
1796
+ });
1797
+
1798
+ // 8. KNOWLEDGE: Link knowledge to tokens thing
1799
+ await ctx.db.insert("thingKnowledge", {
1800
+ thingId: tokensId,
1801
+ knowledgeId: knowledgeId,
1802
+ role: "summary",
1803
+ metadata: {
1804
+ tokenVersion: "1.0.0",
1805
+ generatedAt: Date.now()
1806
+ },
1807
+ createdAt: Date.now()
1808
+ });
1809
+
1810
+ // 9. EVENTS: Log accessibility validation
1811
+ await ctx.db.insert("events", {
1812
+ type: "quality_check_complete",
1813
+ actorId: "design_agent_001",
1814
+ targetId: tokensId,
1815
+ timestamp: Date.now(),
1816
+ metadata: {
1817
+ checkType: "accessibility",
1818
+ wcagLevel: wcagCompliant ? "AA" : "FAIL",
1819
+ contrastRatios: contrastRatios,
1820
+ issuesFound: wcagCompliant ? [] : ["Low contrast"]
1821
+ }
1822
+ });
1823
+ ```
1824
+
1825
+ **Output (6-Dimension Summary):**
1826
+ - **ORGANIZATIONS:** Token system scoped to organization (multi-tenant)
1827
+ - **THINGS:** 1 design-tokens thing created
1828
+ - **CONNECTIONS:** 1 connection created (created_by organization)
1829
+ - **EVENTS:** 2 events logged (content_event, quality_check_complete)
1830
+ - **KNOWLEDGE:** 1 chunk created + 1 thingKnowledge junction
1831
+
1832
+ **Multi-Tenant Benefit:**
1833
+ - Organization A has blue tokens
1834
+ - Organization B has green tokens
1835
+ - Same Design Agent serves both (queries org._id for brand settings)
1836
+ - Each organization's designs are isolated
1837
+
1838
+ ---
1839
+
1840
+ ## Common Mistakes to Avoid
1841
+
1842
+ ### Mistake 1: Designing without understanding tests
1843
+ ❌ **Wrong:** Create beautiful wireframes without checking acceptance criteria
1844
+ ✅ **Right:** Map every acceptance criterion to a UI element in the wireframe
1845
+ **Ontology:** Query test thing BEFORE creating wireframe thing
1846
+
1847
+ ### Mistake 2: Over-designing
1848
+ ❌ **Wrong:** Add complex animations, custom illustrations, unique layouts for every page
1849
+ ✅ **Right:** Use proven patterns from knowledge base, shadcn/ui components, minimal custom styling
1850
+ **Ontology:** Query knowledge dimension for reusable patterns
1851
+
1852
+ ### Mistake 3: Ignoring accessibility
1853
+ ❌ **Wrong:** Use low-contrast colors because they look modern
1854
+ ✅ **Right:** Validate all color pairs meet WCAG AA (4.5:1 body, 3:1 large text)
1855
+ **Ontology:** Log quality_check_complete event with accessibility validation
1856
+
1857
+ ### Mistake 4: Hard-coding brand values
1858
+ ❌ **Wrong:** Set primary color to "blue-500" in wireframe
1859
+ ✅ **Right:** Reference organization's brand settings, generate tokens dynamically
1860
+ **Ontology:** Query organization thing for brandColors
1861
+
1862
+ ### Mistake 5: Skipping responsive thinking
1863
+ ❌ **Wrong:** Design only for desktop (1440px)
1864
+ ✅ **Right:** Consider mobile (320px), tablet (768px), desktop (1024px+)
1865
+ **Ontology:** Store responsive strategy in wireframe properties
1866
+
1867
+ ### Mistake 6: Not defining loading states
1868
+ ❌ **Wrong:** Show form with just submit button
1869
+ ✅ **Right:** Define loading spinner on button, disabled state, skeleton for data loading
1870
+ **Ontology:** Include loading/error states in component-definition thing
1871
+
1872
+ ### Mistake 7: Vague component specs
1873
+ ❌ **Wrong:** "User sees a form"
1874
+ ✅ **Right:** "Card > CardContent > Form > [Input (title), Textarea (description), Button (submit)]"
1875
+ **Ontology:** Store precise component hierarchy in properties.component.children
1876
+
1877
+ ### Mistake 8: Breaking ontology isolation
1878
+ ❌ **Wrong:** Create design for Organization A that references Organization B's tokens
1879
+ ✅ **Right:** Always scope designs to organizationId, query org-specific settings
1880
+ **Ontology:** Multi-tenant isolation via organizations dimension
1881
+
1882
+ ---
1883
+
1884
+ ## Success Criteria
1885
+
1886
+ **Design Agent is successful when:**
1887
+ - [ ] Every user flow has a corresponding wireframe (mapped to test thing)
1888
+ - [ ] Every acceptance criterion is satisfied by a UI element (traceable in properties)
1889
+ - [ ] All designs meet WCAG AA accessibility (logged as quality_check_complete)
1890
+ - [ ] Component specifications are implementable without ambiguity (clear props/state)
1891
+ - [ ] Design tokens are generated from organization brand settings (multi-tenant)
1892
+ - [ ] Specialists can implement without additional design decisions (complete specs)
1893
+ - [ ] Tests pass when designs are implemented correctly (test-driven design)
1894
+ - [ ] All work logged as events (complete audit trail)
1895
+ - [ ] Design patterns stored as knowledge chunks (reusable for future)
1896
+ - [ ] Designs scoped to organization (multi-tenant isolation)
1897
+
1898
+ **Measurement (via events dimension):**
1899
+ - Time from `quality_check_complete` to `content_event` (wireframe): < 5 minutes
1900
+ - Accessibility issues found: 0 (validated before completion)
1901
+ - Specialist questions about design: < 2 per feature (designs should be clear)
1902
+ - Test pass rate after implementation: > 90% (designs enable tests to pass)
1903
+ - Pattern reuse rate: > 50% (knowledge base reduces reinvention)
1904
+
1905
+ **Queries for Metrics:**
1906
+ ```typescript
1907
+ // Time from quality check to wireframe creation
1908
+ const qualityEvent = await ctx.db
1909
+ .query("events")
1910
+ .withIndex("type_time", q => q.eq("type", "quality_check_complete"))
1911
+ .filter(q => q.eq(q.field("targetId"), featureId))
1912
+ .first();
1913
+
1914
+ const wireframeEvent = await ctx.db
1915
+ .query("events")
1916
+ .withIndex("type_time", q => q.eq("type", "content_event"))
1917
+ .filter(q =>
1918
+ q.and(
1919
+ q.eq(q.field("metadata.featureId"), featureId),
1920
+ q.eq(q.field("metadata.contentType"), "wireframe")
1921
+ )
1922
+ )
1923
+ .first();
1924
+
1925
+ const timeDiff = wireframeEvent.timestamp - qualityEvent.timestamp; // Should be < 300000ms (5 min)
1926
+ ```
1927
+
1928
+ ---
1929
+
1930
+ ## Multi-Tenant Scoping (Organizations Dimension)
1931
+
1932
+ **Organization Isolation:**
1933
+ Every design is scoped to an organization. Brand guidelines, color tokens, and design preferences are organization-specific.
1934
+
1935
+ ```typescript
1936
+ // Query: Get organization's design tokens
1937
+ const tokens = await ctx.db
1938
+ .query("things")
1939
+ .withIndex("by_type", q => q.eq("type", "design"))
1940
+ .filter(q =>
1941
+ q.and(
1942
+ q.eq(q.field("properties.designType"), "design-tokens"),
1943
+ q.eq(q.field("properties.organizationId"), organizationId)
1944
+ )
1945
+ )
1946
+ .first();
1947
+
1948
+ // Design agent MUST use these tokens for all features in this org
1949
+ ```
1950
+
1951
+ **Benefit:**
1952
+ - Organization A can have blue primary color
1953
+ - Organization B can have green primary color
1954
+ - Same Design Agent serves both, pulling correct tokens per org
1955
+ - Complete data isolation (ORGANIZATIONS dimension)
1956
+
1957
+ **Query Pattern:**
1958
+ ```typescript
1959
+ // Get feature's organization
1960
+ const feature = await ctx.db.get(featureId);
1961
+ const orgId = feature.properties.organizationId;
1962
+
1963
+ // Get organization's brand settings
1964
+ const org = await ctx.db.get(orgId);
1965
+ const brandColors = org.properties.brandColors;
1966
+
1967
+ // Use org-specific settings in design
1968
+ const wireframe = {
1969
+ brandColors: brandColors, // NOT hard-coded colors
1970
+ // ...
1971
+ };
1972
+ ```
1973
+
1974
+ ---
1975
+
1976
+ ## Integration with Other Agents
1977
+
1978
+ ### Quality Agent (Stage 4 → Stage 5)
1979
+ **Connection:** Quality agent completes tests → Design agent creates wireframes
1980
+
1981
+ **Event Flow:**
1982
+ 1. Quality agent emits `quality_check_complete` (testsCreated: true)
1983
+ 2. Design agent watches for this event
1984
+ 3. Design agent reads test thing (userFlows, acceptanceCriteria)
1985
+ 4. Design agent creates wireframes that satisfy criteria
1986
+ 5. Design agent emits `content_event` (wireframe created)
1987
+
1988
+ **Ontology Operations:**
1989
+ - Query: events.by_type("quality_check_complete")
1990
+ - Read: test thing (ontology dimension 3)
1991
+ - Create: wireframe thing (ontology dimension 3)
1992
+ - Log: content_event (ontology dimension 5)
1993
+
1994
+ ### Frontend Specialist (Stage 5 → Stage 6)
1995
+ **Connection:** Design agent completes wireframes → Frontend specialist implements
1996
+
1997
+ **Event Flow:**
1998
+ 1. Design agent emits `agent_completed` (design_complete)
1999
+ 2. Frontend specialist watches for this event
2000
+ 3. Frontend specialist reads wireframe thing (screens, components)
2001
+ 4. Frontend specialist implements React components
2002
+ 5. Frontend specialist emits `implementation_complete`
2003
+
2004
+ **Ontology Operations:**
2005
+ - Query: events.by_type("agent_completed")
2006
+ - Read: wireframe thing, component-definition thing
2007
+ - Create: React components (not in ontology yet - future)
2008
+ - Log: task_completed (ontology dimension 5)
2009
+
2010
+ ### Problem Solver Agent (Test Failures)
2011
+ **Connection:** Tests fail due to design issues → Problem solver analyzes → Design agent fixes
2012
+
2013
+ **Event Flow:**
2014
+ 1. Quality agent emits `test_failed` (design-related failure)
2015
+ 2. Problem solver agent analyzes
2016
+ 3. Problem solver delegates fix to design agent
2017
+ 4. Design agent updates wireframe thing (new version)
2018
+ 5. Design agent emits `content_event` (action: "updated")
2019
+
2020
+ **Ontology Operations:**
2021
+ - Query: events.by_type("test_failed")
2022
+ - Update: wireframe thing (status: "draft" → "active")
2023
+ - Create: knowledge chunk (lesson learned)
2024
+ - Log: content_event (ontology dimension 5)
2025
+
2026
+ ---
2027
+
2028
+ ## Workflow Integration (6-Phase Process)
2029
+
2030
+ Design Agent operates in **Phase 5: DESIGN** (ontology line 1042).
2031
+
2032
+ ### Phase 4 → Phase 5 Transition
2033
+ **Trigger:** `quality_check_complete` event with `testsCreated: true`
2034
+
2035
+ **Process:**
2036
+ 1. Design agent watches events table
2037
+ 2. Finds `quality_check_complete` for feature
2038
+ 3. Checks if design already exists (query connections)
2039
+ 4. If not, starts design work (create_wireframes)
2040
+
2041
+ **Ontology Operations:**
2042
+ ```typescript
2043
+ // Watch for phase 4 completion
2044
+ const readyForDesign = await ctx.db
2045
+ .query("events")
2046
+ .withIndex("type_time", q => q.eq("type", "quality_check_complete"))
2047
+ .filter(q =>
2048
+ q.and(
2049
+ q.eq(q.field("metadata.testsCreated"), true),
2050
+ q.eq(q.field("metadata.status"), "approved")
2051
+ )
2052
+ )
2053
+ .order("desc")
2054
+ .take(10);
2055
+
2056
+ // Check if design started
2057
+ for (const event of readyForDesign) {
2058
+ const existingDesign = await ctx.db
2059
+ .query("connections")
2060
+ .withIndex("to_type", q =>
2061
+ q.eq("toThingId", event.targetId)
2062
+ .eq("relationshipType", "part_of")
2063
+ )
2064
+ .filter(q => q.eq(q.field("metadata.stage"), "5_design"))
2065
+ .first();
2066
+
2067
+ if (!existingDesign) {
2068
+ // Start design work (phase 5)
2069
+ await createWireframes({ featureId: event.targetId });
2070
+ }
2071
+ }
2072
+ ```
2073
+
2074
+ ### Phase 5 → Phase 6 Transition
2075
+ **Trigger:** Design agent emits `agent_completed` event
2076
+
2077
+ **Process:**
2078
+ 1. Design agent completes all design work
2079
+ 2. Emits `agent_completed` (action: "design_complete")
2080
+ 3. Frontend specialist watches for this event
2081
+ 4. Frontend specialist starts implementation (phase 6)
2082
+
2083
+ **Ontology Operations:**
2084
+ ```typescript
2085
+ // Design complete - signal phase 6
2086
+ await ctx.db.insert("events", {
2087
+ type: "agent_completed",
2088
+ actorId: designAgentId,
2089
+ targetId: wireframeId,
2090
+ timestamp: Date.now(),
2091
+ metadata: {
2092
+ action: "design_complete",
2093
+ featureId: featureId,
2094
+ stage: "5_design",
2095
+ nextStage: "6_implementation",
2096
+ outputs: {
2097
+ wireframes: [wireframeId],
2098
+ components: [componentId],
2099
+ tokens: [tokensId]
2100
+ }
2101
+ }
2102
+ });
2103
+
2104
+ // Frontend specialist watches and picks up
2105
+ const designComplete = await ctx.db
2106
+ .query("events")
2107
+ .withIndex("type_time", q => q.eq("type", "agent_completed"))
2108
+ .filter(q =>
2109
+ q.and(
2110
+ q.eq(q.field("metadata.action"), "design_complete"),
2111
+ q.eq(q.field("metadata.stage"), "5_design")
2112
+ )
2113
+ )
2114
+ .order("desc")
2115
+ .take(10);
2116
+ ```
2117
+
2118
+ ---
2119
+
2120
+ ## Context Budget Management (2,000 Tokens)
2121
+
2122
+ Design Agent has a **2,000 token context budget** (ontology line 1064).
2123
+
2124
+ **Context Allocation:**
2125
+ - **500 tokens:** Feature specification (from feature thing)
2126
+ - **800 tokens:** Test definitions (from test thing - user flows + acceptance criteria)
2127
+ - **300 tokens:** Organization brand guidelines (from organization thing)
2128
+ - **400 tokens:** Design patterns (from knowledge dimension - top 3-5 relevant patterns)
2129
+
2130
+ **Context Optimization:**
2131
+ ```typescript
2132
+ // 1. Load minimal feature data
2133
+ const feature = await ctx.db.get(featureId);
2134
+ const featureContext = {
2135
+ name: feature.name,
2136
+ entities: feature.properties.entities,
2137
+ operations: feature.properties.operations
2138
+ }; // ~100 tokens
2139
+
2140
+ // 2. Load test definitions
2141
+ const test = await ctx.db.get(testId);
2142
+ const testContext = {
2143
+ userFlows: test.properties.userFlows.map(f => ({
2144
+ name: f.name,
2145
+ goal: f.goal,
2146
+ steps: f.steps
2147
+ })),
2148
+ acceptanceCriteria: test.properties.acceptanceCriteria
2149
+ }; // ~600 tokens
2150
+
2151
+ // 3. Load organization brand (minimal)
2152
+ const org = await ctx.db.get(organizationId);
2153
+ const orgContext = {
2154
+ brandColors: org.properties.brandColors,
2155
+ typography: org.properties.typography,
2156
+ spacing: org.properties.spacing
2157
+ }; // ~150 tokens
2158
+
2159
+ // 4. Load top design patterns (vector search)
2160
+ const patterns = await vectorSearch("knowledge", {
2161
+ query: feature.name,
2162
+ limit: 3,
2163
+ filter: { labels: ["pattern:layout", "pattern:component"] }
2164
+ }); // ~400 tokens (3 patterns × ~130 tokens each)
2165
+
2166
+ // Total: ~1,250 tokens (within 2,000 budget)
2167
+ ```
2168
+
2169
+ **Why 2,000 Tokens is Enough:**
2170
+ - Design decisions are **visual and structural**, not code-heavy
2171
+ - Patterns are **reusable templates**, not full implementations
2172
+ - Most context comes from **tests** (what needs to be designed)
2173
+ - **Knowledge base** provides proven patterns (no need to think from scratch)
2174
+
2175
+ ---
2176
+
2177
+ **Design Agent: Translate requirements into visual interfaces that enable tests to pass. Fully integrated with the 6-dimension ontology. Accessibility and brand compliance are non-negotiable. Minimal yet sophisticated. Every design decision is traceable, searchable, and reusable.**