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,1660 @@
1
+ // ============================================================================
2
+ // ONE DSL - Domain Specific Language
3
+ // Purpose: Declare features in high-level syntax that compiles to Effect.ts
4
+ // ============================================================================
5
+
6
+ /**
7
+ * DSL SYNTAX SPECIFICATION
8
+ *
9
+ * The ONE DSL is a declarative language for defining features on the ONE platform.
10
+ * It compiles to TypeScript with Effect.ts and plain Convex schemas (no Convex Ents).
11
+ *
12
+ * Core principles:
13
+ * 1. Declarative - describe WHAT, not HOW
14
+ * 2. Type-safe - validates against ontology
15
+ * 3. Composable - features built from primitives
16
+ * 4. Auditable - generates readable TypeScript
17
+ * 5. Metadata-based - uses metadata field for type consolidation
18
+ *
19
+ * Hybrid Type Strategy:
20
+ * - 25 connection types (18 specific + 7 consolidated via metadata)
21
+ * - 35 event types (24 specific + 11 consolidated via metadata)
22
+ * - Specific types for core domain concepts (tokens, courses, clones)
23
+ * - Consolidated types for protocol-agnostic patterns (payment, content, communication)
24
+ * - Metadata field stores variants and protocol identity
25
+ */
26
+
27
+ // ============================================================================
28
+ // DSL PRIMITIVES
29
+ // ============================================================================
30
+
31
+ /**
32
+ * ENTITY DECLARATION
33
+ * Creates a new entity in the ontology
34
+ */
35
+ type EntityDeclaration = {
36
+ entity: {
37
+ type: EntityType;
38
+ name: string;
39
+ properties: Record<string, any>;
40
+ status?: "active" | "inactive" | "draft";
41
+ };
42
+ };
43
+
44
+ /**
45
+ * CONNECTION DECLARATION
46
+ * Creates relationship between entities
47
+ *
48
+ * 25 HYBRID CONNECTION TYPES:
49
+ *
50
+ * Specific Types (18):
51
+ * - Ownership: "owns", "created_by"
52
+ * - AI: "clone_of", "trained_on", "powers"
53
+ * - Content: "authored", "generated_by", "published_to", "part_of", "references"
54
+ * - Community: "member_of", "following", "moderates", "participated_in"
55
+ * - Business: "manages", "reports_to", "collaborates_with"
56
+ * - Tokens: "holds_tokens", "staked_in", "earned_from"
57
+ * - Products: "purchased", "enrolled_in", "completed", "teaching"
58
+ *
59
+ * Consolidated Types (7) - use metadata:
60
+ * - "transacted" (metadata.transactionType + protocol)
61
+ * - "notified" (metadata.channel + notificationType)
62
+ * - "referred" (metadata.referralType)
63
+ * - "communicated" (metadata.protocol + messageType)
64
+ * - "delegated" (metadata.protocol + taskType)
65
+ * - "approved" (metadata.approvalType + protocol)
66
+ * - "fulfilled" (metadata.fulfillmentType + protocol)
67
+ */
68
+ type ConnectionDeclaration = {
69
+ connect: {
70
+ from: EntityReference;
71
+ to: EntityReference;
72
+ type: ConnectionType; // One of 24 consolidated types
73
+ metadata?: {
74
+ // Type-specific metadata for consolidated types
75
+ paymentType?: "subscription" | "purchase" | "tip" | "refund";
76
+ livestreamType?: "hosted" | "attended" | "moderated" | "banned_from";
77
+ notificationType?: "sent" | "received" | "read";
78
+ referralType?: "referred" | "earned_from";
79
+ actionType?: string; // For admin_action
80
+ // Custom fields
81
+ [key: string]: any;
82
+ };
83
+ };
84
+ };
85
+
86
+ /**
87
+ * EVENT DECLARATION
88
+ * Logs an event
89
+ *
90
+ * 35 HYBRID EVENT TYPES:
91
+ *
92
+ * Specific Types (24):
93
+ * - Entity Lifecycle: "entity_created", "entity_updated", "entity_deleted", "entity_archived"
94
+ * - User: "user_registered", "user_verified", "user_login", "user_logout", "profile_updated"
95
+ * - AI/Clone: "clone_created", "clone_updated", "voice_cloned", "appearance_cloned"
96
+ * - Agent: "agent_created", "agent_executed", "agent_completed", "agent_failed"
97
+ * - Token: "token_created", "token_minted", "token_burned", "tokens_purchased", "tokens_staked", "tokens_unstaked", "tokens_transferred"
98
+ * - Course: "course_created", "course_enrolled", "lesson_completed", "course_completed", "certificate_earned"
99
+ * - Analytics: "metric_calculated", "insight_generated", "prediction_made", "optimization_applied", "report_generated"
100
+ *
101
+ * Consolidated Types (11) - use metadata:
102
+ * - "content_event" (metadata.action: created|updated|deleted|viewed|shared|liked)
103
+ * - "payment_event" (metadata.status: requested|verified|processed + protocol)
104
+ * - "subscription_event" (metadata.action: started|renewed|cancelled)
105
+ * - "commerce_event" (metadata.eventType + protocol: ACP, AP2)
106
+ * - "livestream_event" (metadata.status + metadata.action)
107
+ * - "notification_event" (metadata.channel + deliveryStatus)
108
+ * - "referral_event" (metadata.action: created|completed|rewarded)
109
+ * - "communication_event" (metadata.protocol + messageType: A2A, ACP, AG-UI)
110
+ * - "task_event" (metadata.action: delegated|completed|failed + protocol)
111
+ * - "mandate_event" (metadata.mandateType: intent|cart + protocol: AP2)
112
+ * - "price_event" (metadata.action: checked|changed)
113
+ */
114
+ type EventDeclaration = {
115
+ event: {
116
+ entity: EntityReference;
117
+ type: EventType; // One of 38 consolidated types
118
+ actor?: EntityReference;
119
+ metadata?: {
120
+ // Type-specific metadata for consolidated types
121
+ contentType?: "created" | "published" | "edited" | "deleted" | "viewed" | "shared";
122
+ paymentType?: "initiated" | "completed" | "failed" | "refunded" | "subscription_created" | "subscription_cancelled";
123
+ livestreamType?: "started" | "ended" | "viewer_joined" | "viewer_left" | "chat_message" | "donation_received";
124
+ notificationType?: "sent" | "delivered" | "read" | "clicked";
125
+ referralType?: "created" | "completed" | "reward_paid";
126
+ actionType?: string; // For admin_action
127
+ // Custom fields
128
+ [key: string]: any;
129
+ };
130
+ };
131
+ };
132
+
133
+ /**
134
+ * QUERY DECLARATION
135
+ * Retrieves entities/connections/events
136
+ */
137
+ type QueryDeclaration = {
138
+ query: {
139
+ from: "entities" | "connections" | "events";
140
+ where?: Array<{
141
+ field: string;
142
+ operator: "eq" | "gt" | "lt" | "contains";
143
+ value: any;
144
+ }>;
145
+ limit?: number;
146
+ orderBy?: { field: string; direction: "asc" | "desc" };
147
+ };
148
+ };
149
+
150
+ /**
151
+ * FLOW DECLARATION
152
+ * Multi-step workflow with branching logic
153
+ */
154
+ type FlowDeclaration = {
155
+ flow: {
156
+ name: string;
157
+ steps: Array<StepDeclaration>;
158
+ error?: ErrorHandler;
159
+ };
160
+ };
161
+
162
+ /**
163
+ * SERVICE DECLARATION
164
+ * Calls external provider
165
+ */
166
+ type ServiceDeclaration = {
167
+ service: {
168
+ provider:
169
+ | "openai" // OpenAI GPT models
170
+ | "elevenlabs" // Voice cloning
171
+ | "stripe" // Payment processing
172
+ | "blockchain" // Blockchain interactions
173
+ | "resend" // Email service
174
+ | "d-id" // Appearance cloning (D-ID)
175
+ | "heygen" // Alternative appearance cloning
176
+ | "uniswap" // DEX integration for token trading
177
+ | "alchemy" // Blockchain provider/API
178
+ | "twilio" // SMS and voice communications
179
+ | "sendgrid" // Email service (alternative)
180
+ | "aws" // Media storage (S3)
181
+ | "cloudflare"; // CDN and live streaming
182
+ method: string;
183
+ params: Record<string, any>;
184
+ };
185
+ };
186
+
187
+ // ============================================================================
188
+ // METADATA PATTERNS - Examples of Consolidated Types
189
+ // ============================================================================
190
+
191
+ /**
192
+ * PAYMENT CONNECTION EXAMPLES
193
+ * Single "payment" type with metadata.paymentType
194
+ */
195
+ const paymentSubscriptionExample = {
196
+ connect: {
197
+ from: "$userId",
198
+ to: "$creatorId",
199
+ type: "payment",
200
+ metadata: {
201
+ paymentType: "subscription",
202
+ amount: 999,
203
+ currency: "usd",
204
+ interval: "monthly",
205
+ stripeSubscriptionId: "sub_123",
206
+ },
207
+ },
208
+ };
209
+
210
+ const paymentTipExample = {
211
+ connect: {
212
+ from: "$userId",
213
+ to: "$creatorId",
214
+ type: "payment",
215
+ metadata: {
216
+ paymentType: "tip",
217
+ amount: 500,
218
+ currency: "usd",
219
+ message: "Great content!",
220
+ },
221
+ },
222
+ };
223
+
224
+ /**
225
+ * CONTENT EVENT EXAMPLES
226
+ * Single "content" type with metadata.contentType
227
+ */
228
+ const contentPublishedEvent = {
229
+ event: {
230
+ entity: "$contentId",
231
+ type: "content",
232
+ actor: "$userId",
233
+ metadata: {
234
+ contentType: "published",
235
+ title: "My Blog Post",
236
+ visibility: "public",
237
+ },
238
+ },
239
+ };
240
+
241
+ const contentViewedEvent = {
242
+ event: {
243
+ entity: "$contentId",
244
+ type: "content",
245
+ actor: "$viewerId",
246
+ metadata: {
247
+ contentType: "viewed",
248
+ duration: 120, // seconds
249
+ source: "feed",
250
+ },
251
+ },
252
+ };
253
+
254
+ /**
255
+ * LIVESTREAM EVENT EXAMPLES
256
+ * Single "livestream" type with metadata.livestreamType
257
+ */
258
+ const livestreamStartedEvent = {
259
+ event: {
260
+ entity: "$livestreamId",
261
+ type: "livestream",
262
+ actor: "$hostId",
263
+ metadata: {
264
+ livestreamType: "started",
265
+ title: "Q&A Session",
266
+ expectedDuration: 3600,
267
+ },
268
+ },
269
+ };
270
+
271
+ const livestreamDonationEvent = {
272
+ event: {
273
+ entity: "$livestreamId",
274
+ type: "livestream",
275
+ actor: "$donorId",
276
+ metadata: {
277
+ livestreamType: "donation_received",
278
+ amount: 1000,
279
+ currency: "usd",
280
+ message: "Love your work!",
281
+ },
282
+ },
283
+ };
284
+
285
+ /**
286
+ * NOTIFICATION CONNECTION EXAMPLES
287
+ * Single "notification" type with metadata.notificationType
288
+ */
289
+ const notificationSentConnection = {
290
+ connect: {
291
+ from: "$systemId",
292
+ to: "$userId",
293
+ type: "notification",
294
+ metadata: {
295
+ notificationType: "sent",
296
+ title: "New follower",
297
+ body: "John Doe started following you",
298
+ priority: "medium",
299
+ },
300
+ },
301
+ };
302
+
303
+ /**
304
+ * REFERRAL CONNECTION EXAMPLES
305
+ * Single "referral" type with metadata.referralType
306
+ */
307
+ const referralConnection = {
308
+ connect: {
309
+ from: "$referrerId",
310
+ to: "$referredUserId",
311
+ type: "referral",
312
+ metadata: {
313
+ referralType: "referred",
314
+ code: "FRIEND50",
315
+ reward: 500,
316
+ status: "pending",
317
+ },
318
+ },
319
+ };
320
+
321
+ // ============================================================================
322
+ // PLAIN CONVEX SCHEMA - How DSL Compiles
323
+ // ============================================================================
324
+
325
+ /**
326
+ * The DSL compiles to plain Convex schemas (NO Convex Ents)
327
+ *
328
+ * This is the actual Convex schema that the DSL generates:
329
+ */
330
+
331
+ // convex/schema.ts (Generated from DSL)
332
+ import { defineSchema, defineTable } from "convex/server";
333
+ import { v } from "convex/values";
334
+
335
+ export default defineSchema({
336
+ // Entity table - all entities stored here
337
+ entities: defineTable({
338
+ type: v.string(), // Entity type (creator, ai_clone, token, etc.)
339
+ name: v.string(),
340
+ properties: v.any(), // Type-specific properties
341
+ status: v.union(v.literal("active"), v.literal("inactive"), v.literal("draft")),
342
+ createdAt: v.number(),
343
+ updatedAt: v.number(),
344
+ })
345
+ .index("by_type", ["type"])
346
+ .index("by_status", ["status"])
347
+ .index("by_created", ["createdAt"]),
348
+
349
+ // Connection table - 24 consolidated types
350
+ connections: defineTable({
351
+ fromEntityId: v.id("entities"),
352
+ toEntityId: v.id("entities"),
353
+ relationshipType: v.string(), // One of 24 consolidated types
354
+ metadata: v.optional(v.any()), // Stores paymentType, livestreamType, etc.
355
+ createdAt: v.number(),
356
+ })
357
+ .index("by_from", ["fromEntityId"])
358
+ .index("by_to", ["toEntityId"])
359
+ .index("by_type", ["relationshipType"])
360
+ .index("by_from_and_type", ["fromEntityId", "relationshipType"])
361
+ .index("by_to_and_type", ["toEntityId", "relationshipType"]),
362
+
363
+ // Event table - 38 consolidated types
364
+ events: defineTable({
365
+ entityId: v.id("entities"),
366
+ eventType: v.string(), // One of 38 consolidated types
367
+ timestamp: v.number(),
368
+ actorType: v.union(v.literal("user"), v.literal("system")),
369
+ actorId: v.optional(v.id("entities")),
370
+ metadata: v.optional(v.any()), // Stores contentType, paymentType, etc.
371
+ })
372
+ .index("by_entity", ["entityId"])
373
+ .index("by_type", ["eventType"])
374
+ .index("by_timestamp", ["timestamp"])
375
+ .index("by_entity_and_type", ["entityId", "eventType"])
376
+ .index("by_actor", ["actorId"]),
377
+ });
378
+
379
+ /**
380
+ * KEY DIFFERENCES FROM CONVEX ENTS:
381
+ *
382
+ * 1. NO ent() definitions - just plain defineTable()
383
+ * 2. NO edge() definitions - connections stored as regular rows
384
+ * 3. NO automatic relationship traversal - use manual queries
385
+ * 4. Metadata field (v.any()) stores type-specific data
386
+ * 5. Simpler, more flexible, easier to understand
387
+ * 6. Better for AI agents - less magic, more explicit
388
+ */
389
+
390
+ // ============================================================================
391
+ // EXAMPLE 1: Create AI Clone (DSL)
392
+ // ============================================================================
393
+
394
+ const createAICloneDSL = {
395
+ feature: "CreateAIClone",
396
+ input: {
397
+ creatorId: "Id<entities>",
398
+ videoUrls: "string[]",
399
+ },
400
+ output: {
401
+ cloneId: "Id<entities>",
402
+ voiceId: "string",
403
+ },
404
+
405
+ flow: [
406
+ // Step 1: Validate input
407
+ {
408
+ validate: {
409
+ creatorId: { exists: true, type: "creator" },
410
+ videoUrls: { minLength: 3 },
411
+ },
412
+ onError: { return: { error: "InsufficientContent" } },
413
+ },
414
+
415
+ // Step 2: Extract audio samples
416
+ {
417
+ service: {
418
+ provider: "openai",
419
+ method: "extractAudioFromVideos",
420
+ params: { urls: "$input.videoUrls" },
421
+ output: "audioSamples",
422
+ },
423
+ },
424
+
425
+ // Step 3: Clone voice
426
+ {
427
+ service: {
428
+ provider: "elevenlabs",
429
+ method: "cloneVoice",
430
+ params: {
431
+ name: "$creator.name + ' Voice'",
432
+ samples: "$audioSamples",
433
+ },
434
+ output: "voiceId",
435
+ retry: { times: 3, delay: "5s" },
436
+ timeout: "5m",
437
+ },
438
+ },
439
+
440
+ // Step 4: Analyze personality
441
+ {
442
+ service: {
443
+ provider: "openai",
444
+ method: "analyzePersonality",
445
+ params: {
446
+ videos: "$input.videoUrls",
447
+ posts: "$creator.properties.recentPosts",
448
+ },
449
+ output: "personality",
450
+ },
451
+ },
452
+
453
+ // Step 5: Create AI clone entity
454
+ {
455
+ entity: {
456
+ type: "ai_clone",
457
+ name: "$creator.name + ' AI Clone'",
458
+ properties: {
459
+ voiceId: "$voiceId",
460
+ voiceProvider: "elevenlabs",
461
+ systemPrompt: "$personality.systemPrompt",
462
+ temperature: 0.7,
463
+ totalInteractions: 0,
464
+ },
465
+ status: "active",
466
+ },
467
+ output: "cloneId",
468
+ },
469
+
470
+ // Step 6: Create ownership connection
471
+ {
472
+ connect: {
473
+ from: "$input.creatorId",
474
+ to: "$cloneId",
475
+ type: "owns",
476
+ },
477
+ },
478
+
479
+ // Step 7: Log creation event
480
+ {
481
+ event: {
482
+ entity: "$cloneId",
483
+ type: "clone_created",
484
+ actor: "$input.creatorId",
485
+ metadata: {
486
+ voiceId: "$voiceId",
487
+ personality: "$personality.traits",
488
+ },
489
+ },
490
+ },
491
+
492
+ // Step 8: Return result
493
+ {
494
+ return: {
495
+ cloneId: "$cloneId",
496
+ voiceId: "$voiceId",
497
+ },
498
+ },
499
+ ],
500
+ };
501
+
502
+ // ============================================================================
503
+ // EXAMPLE 2: Token Purchase (DSL)
504
+ // ============================================================================
505
+
506
+ const tokenPurchaseDSL = {
507
+ feature: "PurchaseTokens",
508
+ input: {
509
+ userId: "Id<entities>",
510
+ tokenId: "Id<entities>",
511
+ amount: "number",
512
+ usdAmount: "number",
513
+ },
514
+ output: {
515
+ paymentId: "string",
516
+ txHash: "string",
517
+ },
518
+
519
+ flow: [
520
+ // Step 1: Validate inputs
521
+ {
522
+ validate: {
523
+ userId: { exists: true, type: "audience_member" },
524
+ tokenId: { exists: true, type: "token" },
525
+ amount: { gt: 0 },
526
+ usdAmount: { gt: 0 },
527
+ },
528
+ },
529
+
530
+ // Step 2: Charge payment (atomic with step 3)
531
+ {
532
+ atomic: [
533
+ // 2a: Stripe payment
534
+ {
535
+ service: {
536
+ provider: "stripe",
537
+ method: "charge",
538
+ params: {
539
+ amount: "$input.usdAmount * 100",
540
+ currency: "usd",
541
+ metadata: {
542
+ userId: "$input.userId",
543
+ tokenId: "$input.tokenId",
544
+ },
545
+ },
546
+ output: "payment",
547
+ },
548
+ },
549
+
550
+ // 2b: Mint tokens on blockchain
551
+ {
552
+ service: {
553
+ provider: "blockchain",
554
+ method: "mint",
555
+ params: {
556
+ contractAddress: "$token.properties.contractAddress",
557
+ toAddress: "$input.userId",
558
+ amount: "$input.amount",
559
+ },
560
+ output: "mintTx",
561
+ },
562
+ },
563
+ ],
564
+ onError: {
565
+ rollback: [
566
+ {
567
+ service: {
568
+ provider: "stripe",
569
+ method: "refund",
570
+ params: { paymentIntentId: "$payment.id" },
571
+ },
572
+ },
573
+ {
574
+ service: {
575
+ provider: "blockchain",
576
+ method: "burn",
577
+ params: {
578
+ contractAddress: "$token.properties.contractAddress",
579
+ amount: "$input.amount",
580
+ },
581
+ },
582
+ },
583
+ ],
584
+ },
585
+ },
586
+
587
+ // Step 3a: Log payment event (using consolidated "payment" event type)
588
+ {
589
+ event: {
590
+ entity: "$input.userId",
591
+ type: "payment",
592
+ actor: "$input.userId",
593
+ metadata: {
594
+ paymentType: "completed",
595
+ amount: "$input.usdAmount",
596
+ currency: "usd",
597
+ paymentId: "$payment.id",
598
+ purpose: "token_purchase",
599
+ tokenId: "$input.tokenId",
600
+ tokenAmount: "$input.amount",
601
+ },
602
+ },
603
+ },
604
+
605
+ // Step 3b: Log token purchase event
606
+ {
607
+ event: {
608
+ entity: "$input.tokenId",
609
+ type: "tokens_purchased",
610
+ actor: "$input.userId",
611
+ metadata: {
612
+ amount: "$input.amount",
613
+ usdAmount: "$input.usdAmount",
614
+ paymentId: "$payment.id",
615
+ txHash: "$mintTx.transactionHash",
616
+ },
617
+ },
618
+ },
619
+
620
+ // Step 4: Update token balance
621
+ {
622
+ query: {
623
+ from: "connections",
624
+ where: [
625
+ { field: "fromEntityId", operator: "eq", value: "$input.userId" },
626
+ { field: "toEntityId", operator: "eq", value: "$input.tokenId" },
627
+ { field: "relationshipType", operator: "eq", value: "holds_tokens" },
628
+ ],
629
+ limit: 1,
630
+ },
631
+ output: "existingConnection",
632
+ },
633
+
634
+ {
635
+ if: {
636
+ condition: "$existingConnection != null",
637
+ then: [
638
+ {
639
+ update: {
640
+ connection: "$existingConnection._id",
641
+ set: {
642
+ metadata: {
643
+ balance:
644
+ "$existingConnection.metadata.balance + $input.amount",
645
+ },
646
+ },
647
+ },
648
+ },
649
+ ],
650
+ else: [
651
+ {
652
+ connect: {
653
+ from: "$input.userId",
654
+ to: "$input.tokenId",
655
+ type: "holds_tokens",
656
+ metadata: {
657
+ balance: "$input.amount",
658
+ firstPurchaseDate: Date.now(),
659
+ txHash: "$mintTx.transactionHash",
660
+ },
661
+ },
662
+ },
663
+ ],
664
+ },
665
+ },
666
+
667
+ // Step 5a: Create payment connection record (using consolidated "payment" type)
668
+ {
669
+ connect: {
670
+ from: "$input.userId",
671
+ to: "$input.tokenId",
672
+ type: "payment",
673
+ metadata: {
674
+ paymentType: "purchase",
675
+ amount: "$input.usdAmount",
676
+ currency: "usd",
677
+ tokenAmount: "$input.amount",
678
+ paymentId: "$payment.id",
679
+ txHash: "$mintTx.transactionHash",
680
+ },
681
+ },
682
+ },
683
+
684
+ // Step 6: Return result
685
+ {
686
+ return: {
687
+ paymentId: "$payment.id",
688
+ txHash: "$mintTx.transactionHash",
689
+ },
690
+ },
691
+ ],
692
+ };
693
+
694
+ // ============================================================================
695
+ // EXAMPLE 2B: Token Purchase with Referral (DSL)
696
+ // Shows referral metadata pattern
697
+ // ============================================================================
698
+
699
+ const tokenPurchaseWithReferralDSL = {
700
+ feature: "PurchaseTokensWithReferral",
701
+ input: {
702
+ userId: "Id<entities>",
703
+ tokenId: "Id<entities>",
704
+ amount: "number",
705
+ usdAmount: "number",
706
+ referralCode: "string",
707
+ },
708
+ output: {
709
+ paymentId: "string",
710
+ txHash: "string",
711
+ referralReward: "number",
712
+ },
713
+
714
+ flow: [
715
+ // Step 1: Find referral connection
716
+ {
717
+ query: {
718
+ from: "connections",
719
+ where: [
720
+ { field: "toEntityId", operator: "eq", value: "$input.userId" },
721
+ { field: "relationshipType", operator: "eq", value: "referral" },
722
+ {
723
+ field: "metadata.code",
724
+ operator: "eq",
725
+ value: "$input.referralCode",
726
+ },
727
+ { field: "metadata.status", operator: "eq", value: "pending" },
728
+ ],
729
+ limit: 1,
730
+ },
731
+ output: "referralConnection",
732
+ },
733
+
734
+ // Step 2: Process payment (same as before)
735
+ // ... payment steps ...
736
+
737
+ // Step 3: Update referral status if found
738
+ {
739
+ if: {
740
+ condition: "$referralConnection != null",
741
+ then: [
742
+ {
743
+ update: {
744
+ connection: "$referralConnection._id",
745
+ set: {
746
+ metadata: {
747
+ referralType: "completed",
748
+ code: "$input.referralCode",
749
+ reward: 500,
750
+ status: "completed",
751
+ completedAt: Date.now(),
752
+ },
753
+ },
754
+ },
755
+ },
756
+ {
757
+ event: {
758
+ entity: "$referralConnection.fromEntityId",
759
+ type: "referral",
760
+ actor: "$input.userId",
761
+ metadata: {
762
+ referralType: "completed",
763
+ code: "$input.referralCode",
764
+ reward: 500,
765
+ referredUserId: "$input.userId",
766
+ },
767
+ },
768
+ },
769
+ ],
770
+ },
771
+ },
772
+
773
+ // Step 4: Return result
774
+ {
775
+ return: {
776
+ paymentId: "$payment.id",
777
+ txHash: "$mintTx.transactionHash",
778
+ referralReward:
779
+ "$referralConnection != null ? $referralConnection.metadata.reward : 0",
780
+ },
781
+ },
782
+ ],
783
+ };
784
+
785
+ // ============================================================================
786
+ // EXAMPLE 3: Livestream with Notifications (DSL)
787
+ // Shows livestream and notification metadata patterns
788
+ // ============================================================================
789
+
790
+ const livestreamWithNotificationsDSL = {
791
+ feature: "StartLivestreamWithNotifications",
792
+ input: {
793
+ hostId: "Id<entities>",
794
+ title: "string",
795
+ description: "string",
796
+ },
797
+ output: {
798
+ livestreamId: "Id<entities>",
799
+ notificationsSent: "number",
800
+ },
801
+
802
+ flow: [
803
+ // Step 1: Create livestream entity
804
+ {
805
+ entity: {
806
+ type: "livestream",
807
+ name: "$input.title",
808
+ properties: {
809
+ description: "$input.description",
810
+ status: "live",
811
+ viewerCount: 0,
812
+ startedAt: Date.now(),
813
+ },
814
+ status: "active",
815
+ },
816
+ output: "livestreamId",
817
+ },
818
+
819
+ // Step 2: Create livestream connection (using consolidated type)
820
+ {
821
+ connect: {
822
+ from: "$input.hostId",
823
+ to: "$livestreamId",
824
+ type: "livestream",
825
+ metadata: {
826
+ livestreamType: "hosted",
827
+ role: "host",
828
+ startedAt: Date.now(),
829
+ },
830
+ },
831
+ },
832
+
833
+ // Step 3: Log livestream started event (using consolidated type)
834
+ {
835
+ event: {
836
+ entity: "$livestreamId",
837
+ type: "livestream",
838
+ actor: "$input.hostId",
839
+ metadata: {
840
+ livestreamType: "started",
841
+ title: "$input.title",
842
+ expectedDuration: 3600,
843
+ },
844
+ },
845
+ },
846
+
847
+ // Step 4: Get all followers
848
+ {
849
+ query: {
850
+ from: "connections",
851
+ where: [
852
+ { field: "toEntityId", operator: "eq", value: "$input.hostId" },
853
+ { field: "relationshipType", operator: "eq", value: "following" },
854
+ ],
855
+ },
856
+ output: "followers",
857
+ },
858
+
859
+ // Step 5: Send notifications to all followers
860
+ {
861
+ forEach: {
862
+ array: "$followers",
863
+ do: [
864
+ {
865
+ connect: {
866
+ from: "$input.hostId",
867
+ to: "$item.fromEntityId",
868
+ type: "notification",
869
+ metadata: {
870
+ notificationType: "sent",
871
+ title: "Livestream started!",
872
+ body: "$input.title",
873
+ livestreamId: "$livestreamId",
874
+ sentAt: Date.now(),
875
+ priority: "high",
876
+ },
877
+ },
878
+ },
879
+ {
880
+ event: {
881
+ entity: "$item.fromEntityId",
882
+ type: "notification",
883
+ actor: "$input.hostId",
884
+ metadata: {
885
+ notificationType: "sent",
886
+ channel: "push",
887
+ livestreamId: "$livestreamId",
888
+ },
889
+ },
890
+ },
891
+ ],
892
+ output: "notificationResults",
893
+ },
894
+ },
895
+
896
+ // Step 6: Return result
897
+ {
898
+ return: {
899
+ livestreamId: "$livestreamId",
900
+ notificationsSent: "$notificationResults.length",
901
+ },
902
+ },
903
+ ],
904
+ };
905
+
906
+ // ============================================================================
907
+ // EXAMPLE 4: ELEVATE Journey (DSL)
908
+ // ============================================================================
909
+
910
+ const elevateJourneyDSL = {
911
+ feature: "ELEVATEJourney",
912
+ input: {
913
+ userId: "Id<entities>",
914
+ },
915
+ output: {
916
+ completed: "boolean",
917
+ },
918
+
919
+ flow: [
920
+ // Step 1: Hook - Free AI analysis
921
+ {
922
+ step: "hook",
923
+ actions: [
924
+ {
925
+ service: {
926
+ provider: "openai",
927
+ method: "generateBusinessAnalysis",
928
+ params: { userId: "$input.userId" },
929
+ output: "analysis",
930
+ },
931
+ },
932
+ {
933
+ event: {
934
+ entity: "$input.userId",
935
+ type: "elevate_step_completed",
936
+ metadata: { step: "hook", output: "$analysis" },
937
+ },
938
+ },
939
+ ],
940
+ },
941
+
942
+ // Wait 24 hours
943
+ { wait: "24h" },
944
+
945
+ // Step 2: Gift - Send insights
946
+ {
947
+ step: "gift",
948
+ actions: [
949
+ {
950
+ service: {
951
+ provider: "resend",
952
+ method: "sendInsightsReport",
953
+ params: {
954
+ to: "$user.properties.email",
955
+ insights: "$analysis",
956
+ },
957
+ },
958
+ },
959
+ {
960
+ event: {
961
+ entity: "$input.userId",
962
+ type: "elevate_step_completed",
963
+ metadata: { step: "gift" },
964
+ },
965
+ },
966
+ ],
967
+ },
968
+
969
+ // Step 3: Identify - Payment gate
970
+ {
971
+ step: "identify",
972
+ actions: [
973
+ {
974
+ service: {
975
+ provider: "stripe",
976
+ method: "createCheckoutSession",
977
+ params: {
978
+ amount: 10000,
979
+ currency: "usd",
980
+ successUrl: "$baseUrl/elevate/success",
981
+ cancelUrl: "$baseUrl/elevate/cancel",
982
+ },
983
+ output: "checkout",
984
+ },
985
+ },
986
+ {
987
+ waitForEvent: {
988
+ eventType: "payment_completed",
989
+ entityId: "$input.userId",
990
+ timeout: "7d",
991
+ },
992
+ output: "paymentCompleted",
993
+ },
994
+ {
995
+ if: {
996
+ condition: "$paymentCompleted == false",
997
+ then: [{ return: { completed: false } }],
998
+ },
999
+ },
1000
+ ],
1001
+ },
1002
+
1003
+ // Steps 4-9 continue...
1004
+
1005
+ { return: { completed: true } },
1006
+ ],
1007
+ };
1008
+
1009
+ // ============================================================================
1010
+ // EXAMPLE 4: Query Pattern (DSL)
1011
+ // ============================================================================
1012
+
1013
+ const getCreatorWithContentDSL = {
1014
+ feature: "GetCreatorWithContent",
1015
+ input: {
1016
+ creatorId: "Id<entities>",
1017
+ },
1018
+ output: {
1019
+ creator: "Entity",
1020
+ content: "Entity[]",
1021
+ followerCount: "number",
1022
+ },
1023
+
1024
+ flow: [
1025
+ // Step 1: Get creator entity
1026
+ {
1027
+ query: {
1028
+ from: "entities",
1029
+ where: [
1030
+ { field: "_id", operator: "eq", value: "$input.creatorId" },
1031
+ { field: "type", operator: "eq", value: "creator" },
1032
+ ],
1033
+ limit: 1,
1034
+ },
1035
+ output: "creator",
1036
+ },
1037
+
1038
+ // Step 2: Get authored content
1039
+ {
1040
+ query: {
1041
+ from: "connections",
1042
+ where: [
1043
+ { field: "fromEntityId", operator: "eq", value: "$input.creatorId" },
1044
+ { field: "relationshipType", operator: "eq", value: "authored" },
1045
+ ],
1046
+ },
1047
+ output: "contentConnections",
1048
+ },
1049
+
1050
+ // Step 3: Hydrate content entities
1051
+ {
1052
+ forEach: {
1053
+ array: "$contentConnections",
1054
+ do: [
1055
+ {
1056
+ query: {
1057
+ from: "entities",
1058
+ where: [
1059
+ { field: "_id", operator: "eq", value: "$item.toEntityId" },
1060
+ ],
1061
+ },
1062
+ },
1063
+ ],
1064
+ output: "content",
1065
+ },
1066
+ },
1067
+
1068
+ // Step 4: Count followers
1069
+ {
1070
+ query: {
1071
+ from: "connections",
1072
+ where: [
1073
+ { field: "toEntityId", operator: "eq", value: "$input.creatorId" },
1074
+ { field: "relationshipType", operator: "eq", value: "following" },
1075
+ ],
1076
+ },
1077
+ output: "followers",
1078
+ },
1079
+
1080
+ // Step 5: Return result
1081
+ {
1082
+ return: {
1083
+ creator: "$creator",
1084
+ content: "$content",
1085
+ followerCount: "$followers.length",
1086
+ },
1087
+ },
1088
+ ],
1089
+ };
1090
+
1091
+ // ============================================================================
1092
+ // DSL COMPILER
1093
+ // Compiles DSL to TypeScript with Effect.ts and Plain Convex
1094
+ // ============================================================================
1095
+
1096
+ class ONECompiler {
1097
+ /**
1098
+ * Compiles DSL to TypeScript with Effect.ts
1099
+ *
1100
+ * Key Features:
1101
+ * - Generates plain Convex queries/mutations (NO Convex Ents)
1102
+ * - Uses ctx.db.insert/query/patch directly
1103
+ * - Metadata field stores type-specific data
1104
+ * - Effect.ts for composition and error handling
1105
+ */
1106
+ compile(dsl: any): string {
1107
+ const feature = dsl.feature;
1108
+ const input = dsl.input;
1109
+ const output = dsl.output;
1110
+ const flow = dsl.flow;
1111
+
1112
+ let code = `// Generated from ONE DSL
1113
+ // Compiles to Plain Convex (NO Convex Ents) + Effect.ts
1114
+ import { Effect } from "effect";
1115
+ import { mutation, query, internalMutation } from "./_generated/server";
1116
+ import { v } from "convex/values";
1117
+ import { OpenAIProvider, ElevenLabsProvider, StripeProvider, BlockchainProvider, ResendProvider } from "@/convex/services/providers";
1118
+
1119
+ /**
1120
+ * Generated ${feature} function
1121
+ * Uses plain Convex with Effect.ts for composition
1122
+ */
1123
+ export const ${this.toCamelCase(feature)} = mutation({
1124
+ args: ${this.generateInputArgs(input)},
1125
+ handler: async (ctx, args) => {
1126
+ return await Effect.runPromise(
1127
+ Effect.gen(function* () {
1128
+ `;
1129
+
1130
+ // Compile each step in flow
1131
+ for (const step of flow) {
1132
+ code += this.compileStep(step, 4);
1133
+ }
1134
+
1135
+ code += ` })
1136
+ );
1137
+ },
1138
+ });
1139
+ `;
1140
+
1141
+ return code;
1142
+ }
1143
+
1144
+ private compileStep(step: any, indent: number): string {
1145
+ const ind = " ".repeat(indent);
1146
+
1147
+ // Entity creation (Plain Convex - NO Convex Ents)
1148
+ if (step.entity) {
1149
+ return `${ind}// Create entity using plain Convex ctx.db.insert
1150
+ ${ind}const ${step.output || "entity"} = yield* Effect.promise(() =>
1151
+ ${ind} ctx.db.insert("entities", {
1152
+ ${ind} type: "${step.entity.type}",
1153
+ ${ind} name: ${this.compileExpression(step.entity.name)},
1154
+ ${ind} properties: ${JSON.stringify(step.entity.properties, null, 2).replace(/\n/g, "\n" + ind + " ")},
1155
+ ${ind} status: "${step.entity.status || "active"}",
1156
+ ${ind} createdAt: Date.now(),
1157
+ ${ind} updatedAt: Date.now(),
1158
+ ${ind} })
1159
+ ${ind});
1160
+ `;
1161
+ }
1162
+
1163
+ // Connection creation (Plain Convex - stores metadata)
1164
+ if (step.connect) {
1165
+ const metadataStr = step.connect.metadata
1166
+ ? JSON.stringify(step.connect.metadata, null, 2).replace(
1167
+ /\n/g,
1168
+ "\n" + ind + " "
1169
+ )
1170
+ : "undefined";
1171
+ return `${ind}// Create connection using plain Convex ctx.db.insert
1172
+ ${ind}yield* Effect.promise(() =>
1173
+ ${ind} ctx.db.insert("connections", {
1174
+ ${ind} fromEntityId: ${this.compileExpression(step.connect.from)},
1175
+ ${ind} toEntityId: ${this.compileExpression(step.connect.to)},
1176
+ ${ind} relationshipType: "${step.connect.type}",
1177
+ ${ind} metadata: ${metadataStr},
1178
+ ${ind} createdAt: Date.now(),
1179
+ ${ind} })
1180
+ ${ind});
1181
+ `;
1182
+ }
1183
+
1184
+ // Event logging (Plain Convex - stores metadata)
1185
+ if (step.event) {
1186
+ const metadataStr = step.event.metadata
1187
+ ? JSON.stringify(step.event.metadata, null, 2).replace(
1188
+ /\n/g,
1189
+ "\n" + ind + " "
1190
+ )
1191
+ : "undefined";
1192
+ return `${ind}// Log event using plain Convex ctx.db.insert
1193
+ ${ind}yield* Effect.promise(() =>
1194
+ ${ind} ctx.db.insert("events", {
1195
+ ${ind} entityId: ${this.compileExpression(step.event.entity)},
1196
+ ${ind} eventType: "${step.event.type}",
1197
+ ${ind} actorId: ${this.compileExpression(step.event.actor || '"system"')},
1198
+ ${ind} timestamp: Date.now(),
1199
+ ${ind} actorType: "${step.event.actor ? "user" : "system"}",
1200
+ ${ind} metadata: ${metadataStr},
1201
+ ${ind} })
1202
+ ${ind});
1203
+ `;
1204
+ }
1205
+
1206
+ // Service call
1207
+ if (step.service) {
1208
+ const provider = this.capitalizeFirst(step.service.provider);
1209
+ return `${ind}const ${step.output || "result"} = yield* Effect.gen(function* () {
1210
+ ${ind} const ${step.service.provider} = yield* ${provider}Provider;
1211
+ ${ind} return yield* ${step.service.provider}.${step.service.method}(${JSON.stringify(step.service.params)});
1212
+ ${ind}})${step.retry ? `.pipe(Effect.retry({ times: ${step.retry.times} }))` : ""}${step.timeout ? `.pipe(Effect.timeout("${step.timeout}"))` : ""};
1213
+ `;
1214
+ }
1215
+
1216
+ // Query (Plain Convex - uses ctx.db.query)
1217
+ if (step.query) {
1218
+ return `${ind}// Query using plain Convex ctx.db.query
1219
+ ${ind}const ${step.output || "queryResult"} = yield* Effect.promise(async () => {
1220
+ ${ind} let query = ctx.db.query("${step.query.from}");
1221
+ ${this.compileQueryFilters(step.query.where || [], indent + 1)}
1222
+ ${step.query.limit ? `${ind} query = query.take(${step.query.limit});` : ""}
1223
+ ${ind} return await query.collect();
1224
+ ${ind}});
1225
+ `;
1226
+ }
1227
+
1228
+ // Conditional
1229
+ if (step.if) {
1230
+ let code = `${ind}if (${this.compileExpression(step.if.condition)}) {
1231
+ `;
1232
+ for (const thenStep of step.if.then) {
1233
+ code += this.compileStep(thenStep, indent + 1);
1234
+ }
1235
+ if (step.if.else) {
1236
+ code += `${ind}} else {
1237
+ `;
1238
+ for (const elseStep of step.if.else) {
1239
+ code += this.compileStep(elseStep, indent + 1);
1240
+ }
1241
+ }
1242
+ code += `${ind}}
1243
+ `;
1244
+ return code;
1245
+ }
1246
+
1247
+ // Return
1248
+ if (step.return) {
1249
+ return `${ind}return ${JSON.stringify(step.return)};
1250
+ `;
1251
+ }
1252
+
1253
+ return `${ind}// Unknown step type
1254
+ `;
1255
+ }
1256
+
1257
+ private compileExpression(expr: string): string {
1258
+ if (expr.startsWith("$")) {
1259
+ // Variable reference
1260
+ return expr.substring(1).replace(/\./g, "?.");
1261
+ }
1262
+ return `"${expr}"`;
1263
+ }
1264
+
1265
+ private compileQueryFilters(filters: any[], indent: number): string {
1266
+ const ind = " ".repeat(indent);
1267
+ let code = "";
1268
+ for (const filter of filters) {
1269
+ // Plain Convex filter syntax (no Convex Ents)
1270
+ code += `${ind}query = query.filter((q) => q.eq(q.field("${filter.field}"), ${this.compileExpression(filter.value)}));\n`;
1271
+ }
1272
+ return code;
1273
+ }
1274
+
1275
+ private generateInputArgs(input: Record<string, string>): string {
1276
+ // Generate Convex args validator object
1277
+ const args = Object.entries(input)
1278
+ .map(([key, type]) => {
1279
+ const convexType = this.typeToConvexValidator(type);
1280
+ return ` ${key}: ${convexType}`;
1281
+ })
1282
+ .join(",\n");
1283
+ return `{\n${args}\n }`;
1284
+ }
1285
+
1286
+ private typeToConvexValidator(type: string): string {
1287
+ // Map DSL types to Convex validators
1288
+ if (type.includes("Id<")) return "v.id('entities')";
1289
+ if (type === "string") return "v.string()";
1290
+ if (type === "number") return "v.number()";
1291
+ if (type === "boolean") return "v.boolean()";
1292
+ if (type.includes("[]")) {
1293
+ const innerType = type.replace("[]", "");
1294
+ return `v.array(${this.typeToConvexValidator(innerType)})`;
1295
+ }
1296
+ return "v.any()";
1297
+ }
1298
+
1299
+ private toCamelCase(str: string): string {
1300
+ return str.charAt(0).toLowerCase() + str.slice(1);
1301
+ }
1302
+
1303
+ private capitalizeFirst(str: string): string {
1304
+ return str.charAt(0).toUpperCase() + str.slice(1);
1305
+ }
1306
+ }
1307
+
1308
+ // ============================================================================
1309
+ // DSL VALIDATOR
1310
+ // Validates DSL against ontology before compilation
1311
+ // ============================================================================
1312
+
1313
+ class ONEValidator {
1314
+ private ontology: {
1315
+ entityTypes: string[];
1316
+ connectionTypes: string[]; // 24 consolidated types
1317
+ eventTypes: string[]; // 38 consolidated types
1318
+ };
1319
+
1320
+ constructor(ontology: any) {
1321
+ this.ontology = ontology;
1322
+ }
1323
+
1324
+ validate(dsl: any): { valid: boolean; errors: string[] } {
1325
+ const errors: string[] = [];
1326
+
1327
+ // Validate all entity types used exist in ontology
1328
+ this.validateEntities(dsl.flow, errors);
1329
+
1330
+ // Validate all connection types used exist in ontology
1331
+ this.validateConnections(dsl.flow, errors);
1332
+
1333
+ // Validate all event types used exist in ontology
1334
+ this.validateEvents(dsl.flow, errors);
1335
+
1336
+ // Validate metadata patterns for consolidated types
1337
+ this.validateMetadata(dsl.flow, errors);
1338
+
1339
+ return {
1340
+ valid: errors.length === 0,
1341
+ errors,
1342
+ };
1343
+ }
1344
+
1345
+ private validateEntities(flow: any[], errors: string[]): void {
1346
+ for (const step of flow) {
1347
+ if (step.entity && !this.ontology.entityTypes.includes(step.entity.type)) {
1348
+ errors.push(
1349
+ `Invalid entity type: ${step.entity.type}. Must be one of: ${this.ontology.entityTypes.join(", ")}`
1350
+ );
1351
+ }
1352
+ }
1353
+ }
1354
+
1355
+ private validateConnections(flow: any[], errors: string[]): void {
1356
+ for (const step of flow) {
1357
+ if (
1358
+ step.connect &&
1359
+ !this.ontology.connectionTypes.includes(step.connect.type)
1360
+ ) {
1361
+ errors.push(
1362
+ `Invalid connection type: ${step.connect.type}. Must be one of 24 consolidated types: ${this.ontology.connectionTypes.join(", ")}`
1363
+ );
1364
+ }
1365
+ }
1366
+ }
1367
+
1368
+ private validateEvents(flow: any[], errors: string[]): void {
1369
+ for (const step of flow) {
1370
+ if (step.event && !this.ontology.eventTypes.includes(step.event.type)) {
1371
+ errors.push(
1372
+ `Invalid event type: ${step.event.type}. Must be one of 38 consolidated types: ${this.ontology.eventTypes.join(", ")}`
1373
+ );
1374
+ }
1375
+ }
1376
+ }
1377
+
1378
+ private validateMetadata(flow: any[], errors: string[]): void {
1379
+ const consolidatedTypes = {
1380
+ payment: ["subscription", "purchase", "tip", "refund"],
1381
+ livestream: ["hosted", "attended", "moderated", "banned_from"],
1382
+ notification: ["sent", "received", "read"],
1383
+ referral: ["referred", "earned_from"],
1384
+ content: ["created", "published", "edited", "deleted", "viewed", "shared"],
1385
+ };
1386
+
1387
+ for (const step of flow) {
1388
+ // Validate connection metadata
1389
+ if (step.connect && step.connect.metadata) {
1390
+ const type = step.connect.type;
1391
+ if (consolidatedTypes[type]) {
1392
+ const metadataType = step.connect.metadata[`${type}Type`];
1393
+ if (
1394
+ metadataType &&
1395
+ !consolidatedTypes[type].includes(metadataType)
1396
+ ) {
1397
+ errors.push(
1398
+ `Invalid ${type}Type: ${metadataType}. Must be one of: ${consolidatedTypes[type].join(", ")}`
1399
+ );
1400
+ }
1401
+ }
1402
+ }
1403
+
1404
+ // Validate event metadata
1405
+ if (step.event && step.event.metadata) {
1406
+ const type = step.event.type;
1407
+ if (consolidatedTypes[type]) {
1408
+ const metadataType = step.event.metadata[`${type}Type`];
1409
+ if (
1410
+ metadataType &&
1411
+ !consolidatedTypes[type].includes(metadataType)
1412
+ ) {
1413
+ errors.push(
1414
+ `Invalid ${type}Type: ${metadataType}. Must be one of: ${consolidatedTypes[type].join(", ")}`
1415
+ );
1416
+ }
1417
+ }
1418
+ }
1419
+ }
1420
+ }
1421
+ }
1422
+
1423
+ // ============================================================================
1424
+ // USAGE EXAMPLE - Full Ontology with 24+38 Consolidated Types
1425
+ // ============================================================================
1426
+
1427
+ /**
1428
+ * Complete ontology with hybrid type strategy
1429
+ */
1430
+ const FULL_ONTOLOGY = {
1431
+ entityTypes: [
1432
+ "creator",
1433
+ "ai_clone",
1434
+ "token",
1435
+ "audience_member",
1436
+ "content",
1437
+ "course",
1438
+ "livestream",
1439
+ "subscription",
1440
+ "notification",
1441
+ ],
1442
+
1443
+ // 25 HYBRID CONNECTION TYPES
1444
+ connectionTypes: [
1445
+ // Specific Types (18)
1446
+ "owns", "created_by",
1447
+ "clone_of", "trained_on", "powers",
1448
+ "authored", "generated_by", "published_to", "part_of", "references",
1449
+ "member_of", "following", "moderates", "participated_in",
1450
+ "manages", "reports_to", "collaborates_with",
1451
+ "holds_tokens", "staked_in", "earned_from",
1452
+ "purchased", "enrolled_in", "completed", "teaching",
1453
+ // Consolidated Types (7) - use metadata
1454
+ "transacted", // metadata.transactionType + protocol
1455
+ "notified", // metadata.channel + notificationType
1456
+ "referred", // metadata.referralType
1457
+ "communicated", // metadata.protocol + messageType
1458
+ "delegated", // metadata.protocol + taskType
1459
+ "approved", // metadata.approvalType + protocol
1460
+ "fulfilled", // metadata.fulfillmentType + protocol
1461
+ ],
1462
+
1463
+ // 35 HYBRID EVENT TYPES
1464
+ eventTypes: [
1465
+ // Specific Types (24)
1466
+ "entity_created", "entity_updated", "entity_deleted", "entity_archived",
1467
+ "user_registered", "user_verified", "user_login", "user_logout", "profile_updated",
1468
+ "clone_created", "clone_updated", "voice_cloned", "appearance_cloned",
1469
+ "agent_created", "agent_executed", "agent_completed", "agent_failed",
1470
+ "token_created", "token_minted", "token_burned", "tokens_purchased", "tokens_staked", "tokens_unstaked", "tokens_transferred",
1471
+ "course_created", "course_enrolled", "lesson_completed", "course_completed", "certificate_earned",
1472
+ "metric_calculated", "insight_generated", "prediction_made", "optimization_applied", "report_generated",
1473
+ // Consolidated Types (11) - use metadata
1474
+ "content_event", // metadata.action + protocol
1475
+ "payment_event", // metadata.status + protocol
1476
+ "subscription_event", // metadata.action
1477
+ "commerce_event", // metadata.eventType + protocol
1478
+ "livestream_event", // metadata.status + metadata.action
1479
+ "notification_event", // metadata.channel + deliveryStatus
1480
+ "referral_event", // metadata.action
1481
+ "communication_event", // metadata.protocol + messageType
1482
+ "task_event", // metadata.action + protocol
1483
+ "mandate_event", // metadata.mandateType + protocol
1484
+ "price_event", // metadata.action
1485
+ ],
1486
+ };
1487
+
1488
+ // 1. Define feature in DSL
1489
+ const myFeature = livestreamWithNotificationsDSL;
1490
+
1491
+ // 2. Validate against full ontology
1492
+ const validator = new ONEValidator(FULL_ONTOLOGY);
1493
+
1494
+ const validation = validator.validate(myFeature);
1495
+ if (!validation.valid) {
1496
+ console.error("DSL validation failed:", validation.errors);
1497
+ process.exit(1);
1498
+ }
1499
+
1500
+ // 3. Compile to TypeScript with Plain Convex
1501
+ const compiler = new ONECompiler();
1502
+ const generatedCode = compiler.compile(myFeature);
1503
+
1504
+ // 4. Write to file
1505
+ // fs.writeFileSync("convex/features/startLivestream.ts", generatedCode);
1506
+
1507
+ console.log("Generated Plain Convex code:");
1508
+ console.log(generatedCode);
1509
+
1510
+ /**
1511
+ * EXAMPLE OUTPUT - What the compiler generates:
1512
+ *
1513
+ * // Generated from ONE DSL
1514
+ * // Compiles to Plain Convex (NO Convex Ents) + Effect.ts
1515
+ * import { Effect } from "effect";
1516
+ * import { mutation } from "./_generated/server";
1517
+ * import { v } from "convex/values";
1518
+ *
1519
+ * export const startLivestreamWithNotifications = mutation({
1520
+ * args: {
1521
+ * hostId: v.id('entities'),
1522
+ * title: v.string(),
1523
+ * description: v.string()
1524
+ * },
1525
+ * handler: async (ctx, args) => {
1526
+ * return await Effect.runPromise(
1527
+ * Effect.gen(function* () {
1528
+ * // Create entity using plain Convex ctx.db.insert
1529
+ * const livestreamId = yield* Effect.promise(() =>
1530
+ * ctx.db.insert("entities", {
1531
+ * type: "livestream",
1532
+ * name: args.title,
1533
+ * properties: { ... },
1534
+ * ...
1535
+ * })
1536
+ * );
1537
+ *
1538
+ * // Create connection with metadata
1539
+ * yield* Effect.promise(() =>
1540
+ * ctx.db.insert("connections", {
1541
+ * fromEntityId: args.hostId,
1542
+ * toEntityId: livestreamId,
1543
+ * relationshipType: "livestream",
1544
+ * metadata: {
1545
+ * livestreamType: "hosted",
1546
+ * ...
1547
+ * }
1548
+ * })
1549
+ * );
1550
+ * // ... rest of generated code
1551
+ * })
1552
+ * );
1553
+ * }
1554
+ * });
1555
+ */
1556
+
1557
+ // ============================================================================
1558
+ // DSL SYNTAX SUMMARY - Plain English vs Technical DSL
1559
+ // ============================================================================
1560
+
1561
+ /**
1562
+ * The ONE DSL supports TWO syntax styles:
1563
+ *
1564
+ * 1. PLAIN ENGLISH DSL (Non-technical users)
1565
+ * - Natural language commands
1566
+ * - Example: "Create a token named 'MyToken' with supply 1000000"
1567
+ * - Example: "When user purchases tokens, send them a confirmation email"
1568
+ *
1569
+ * 2. TECHNICAL DSL (Developers and AI agents)
1570
+ * - Structured declarative syntax (shown in this file)
1571
+ * - Type-safe with validation
1572
+ * - Compiles to Effect.ts + Plain Convex
1573
+ *
1574
+ * Both syntaxes are maintained separately but compile to the same output.
1575
+ *
1576
+ * WHY TWO SYNTAXES?
1577
+ * - Plain English: For product managers, designers, non-technical stakeholders
1578
+ * - Technical DSL: For developers, AI agents who need precision and type safety
1579
+ *
1580
+ * CURRENT STATUS:
1581
+ * - Technical DSL: Fully specified in this file
1582
+ * - Plain English DSL: Defined in separate documentation
1583
+ * - Both will be implemented in the compiler
1584
+ */
1585
+
1586
+ // ============================================================================
1587
+ // KEY ARCHITECTURAL DECISIONS
1588
+ // ============================================================================
1589
+
1590
+ /**
1591
+ * 1. PLAIN CONVEX (NO CONVEX ENTS)
1592
+ * - Uses defineTable() not ent()
1593
+ * - Manual relationship queries
1594
+ * - More explicit, easier for AI agents
1595
+ * - Better for metadata-based patterns
1596
+ *
1597
+ * 2. 25 HYBRID CONNECTION TYPES
1598
+ * - 18 specific semantic types for core domain
1599
+ * - 7 consolidated types with metadata variants
1600
+ * - Protocol-agnostic via metadata.protocol
1601
+ * - Simpler queries, better AI comprehension
1602
+ *
1603
+ * 3. 35 HYBRID EVENT TYPES
1604
+ * - 24 specific types for core domain events
1605
+ * - 11 consolidated types with metadata variants
1606
+ * - Protocol identification via metadata
1607
+ * - Balance between specificity and flexibility
1608
+ *
1609
+ * 4. METADATA-BASED PATTERNS
1610
+ * - Consolidated types use metadata for variants
1611
+ * - Protocol identity in metadata.protocol
1612
+ * - Reduces schema complexity
1613
+ * - Maintains queryability
1614
+ * - Flexible for future protocols
1615
+ *
1616
+ * 5. EFFECT.TS INTEGRATION
1617
+ * - All compiled code uses Effect.ts
1618
+ * - Composable, type-safe operations
1619
+ * - Standardized error handling
1620
+ * - Better testability
1621
+ *
1622
+ * 6. VALIDATOR WITH METADATA CHECKING
1623
+ * - Validates base types (24 connections, 38 events)
1624
+ * - Validates metadata patterns for consolidated types
1625
+ * - Ensures type safety before compilation
1626
+ * - Prevents invalid metadata.typeType values
1627
+ */
1628
+
1629
+ // ============================================================================
1630
+ // NEXT STEPS FOR IMPLEMENTATION
1631
+ // ============================================================================
1632
+
1633
+ /**
1634
+ * 1. Implement Plain English parser
1635
+ * - Parse natural language to Technical DSL AST
1636
+ * - Use LLM for intent extraction
1637
+ * - Map to Technical DSL constructs
1638
+ *
1639
+ * 2. Complete compiler implementation
1640
+ * - Add support for all DSL primitives
1641
+ * - Generate Effect.ts code
1642
+ * - Generate plain Convex mutations/queries
1643
+ * - Add error handling and retry logic
1644
+ *
1645
+ * 3. Add schema generator
1646
+ * - Generate Convex schema from DSL features
1647
+ * - Create indices based on query patterns
1648
+ * - Generate TypeScript types
1649
+ *
1650
+ * 4. Build testing infrastructure
1651
+ * - DSL validator tests
1652
+ * - Compiler output tests
1653
+ * - Generated code integration tests
1654
+ *
1655
+ * 5. Create developer tools
1656
+ * - VS Code extension for DSL syntax
1657
+ * - Real-time validation
1658
+ * - Auto-completion
1659
+ * - DSL playground
1660
+ */