create-hq 5.3.2 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/dist/deps.d.ts +2 -2
  2. package/dist/deps.d.ts.map +1 -1
  3. package/dist/deps.js +29 -138
  4. package/dist/deps.js.map +1 -1
  5. package/dist/git.d.ts.map +1 -1
  6. package/dist/git.js +5 -0
  7. package/dist/git.js.map +1 -1
  8. package/dist/index.js +6 -3
  9. package/dist/index.js.map +1 -1
  10. package/dist/scaffold.d.ts +2 -1
  11. package/dist/scaffold.d.ts.map +1 -1
  12. package/dist/scaffold.js +238 -54
  13. package/dist/scaffold.js.map +1 -1
  14. package/dist/ui.d.ts +2 -0
  15. package/dist/ui.d.ts.map +1 -1
  16. package/dist/ui.js +31 -1
  17. package/dist/ui.js.map +1 -1
  18. package/package.json +6 -3
  19. package/template/.claude/CLAUDE.md +202 -0
  20. package/template/.claude/commands/checkpoint.md +127 -0
  21. package/template/.claude/commands/cleanup.md +307 -0
  22. package/template/.claude/commands/execute-task.md +440 -0
  23. package/template/.claude/commands/exit-plan.md +41 -0
  24. package/template/.claude/commands/handoff.md +97 -0
  25. package/template/.claude/commands/learn.md +218 -0
  26. package/template/.claude/commands/metrics.md +118 -0
  27. package/template/.claude/commands/newworker.md +162 -0
  28. package/template/.claude/commands/nexttask.md +67 -0
  29. package/template/.claude/commands/prd.md +238 -0
  30. package/template/.claude/commands/reanchor.md +51 -0
  31. package/template/.claude/commands/remember.md +126 -0
  32. package/template/.claude/commands/run-project.md +348 -0
  33. package/template/.claude/commands/run.md +110 -0
  34. package/template/.claude/commands/search-reindex.md +62 -0
  35. package/template/.claude/commands/search.md +100 -0
  36. package/template/.claude/commands/setup.md +381 -0
  37. package/template/.claude/scripts/pure-ralph-loop.ps1 +312 -0
  38. package/template/.claude/scripts/pure-ralph-loop.sh +859 -0
  39. package/template/CHANGELOG.md +220 -0
  40. package/template/LICENSE +21 -0
  41. package/template/MIGRATION.md +259 -0
  42. package/template/README.md +368 -0
  43. package/template/data/journal/.gitkeep +0 -0
  44. package/template/docs/images/ascii-banner-options.md +122 -0
  45. package/template/docs/images/hq-banner.svg +105 -0
  46. package/template/knowledge/Ralph/01-overview.md +71 -0
  47. package/template/knowledge/Ralph/02-core-concepts.md +114 -0
  48. package/template/knowledge/Ralph/03-how-ralph-works.md +184 -0
  49. package/template/knowledge/Ralph/04-back-pressure.md +222 -0
  50. package/template/knowledge/Ralph/05-specifications.md +210 -0
  51. package/template/knowledge/Ralph/06-agents-md.md +222 -0
  52. package/template/knowledge/Ralph/07-implementation.md +316 -0
  53. package/template/knowledge/Ralph/08-economics.md +182 -0
  54. package/template/knowledge/Ralph/09-resources.md +145 -0
  55. package/template/knowledge/Ralph/10-claude-code-workflow.md +212 -0
  56. package/template/knowledge/Ralph/11-team-training-guide.md +383 -0
  57. package/template/knowledge/Ralph/README.md +40 -0
  58. package/template/knowledge/ai-security-framework/CONTRIBUTING.md +139 -0
  59. package/template/knowledge/ai-security-framework/GLOSSARY.md +176 -0
  60. package/template/knowledge/ai-security-framework/LICENSE +21 -0
  61. package/template/knowledge/ai-security-framework/QUICK-START.md +172 -0
  62. package/template/knowledge/ai-security-framework/README.md +232 -0
  63. package/template/knowledge/ai-security-framework/checklists/browser-security.md +301 -0
  64. package/template/knowledge/ai-security-framework/checklists/credential-isolation.md +322 -0
  65. package/template/knowledge/ai-security-framework/checklists/incident-response.md +288 -0
  66. package/template/knowledge/ai-security-framework/checklists/pre-flight.md +249 -0
  67. package/template/knowledge/ai-security-framework/checklists/weekly-audit.md +159 -0
  68. package/template/knowledge/ai-security-framework/configs/audit-logging.md +372 -0
  69. package/template/knowledge/ai-security-framework/configs/kill-switches.md +354 -0
  70. package/template/knowledge/ai-security-framework/docs/01-core-principles.md +256 -0
  71. package/template/knowledge/ai-security-framework/docs/02-threat-landscape.md +326 -0
  72. package/template/knowledge/ai-security-framework/docs/03-security-posture.md +250 -0
  73. package/template/knowledge/ai-security-framework/templates/agents-security.md +233 -0
  74. package/template/knowledge/design-styles/README.md +42 -0
  75. package/template/knowledge/design-styles/american-industrial.md +136 -0
  76. package/template/knowledge/design-styles/ethereal-abstract.md +133 -0
  77. package/template/knowledge/design-styles/liminal-portal.md +111 -0
  78. package/template/knowledge/design-styles/swipes/american-industrial/G-3m4YPW0AADdu2.jpeg +0 -0
  79. package/template/knowledge/design-styles/swipes/american-industrial/G-JJlt5WwAABK3K.png +0 -0
  80. package/template/knowledge/design-styles/swipes/american-industrial/G-JJmj5W0AEbJ-7.png +0 -0
  81. package/template/knowledge/design-styles/swipes/american-industrial/G59fgNuXkAAKLJQ (1).jpeg +0 -0
  82. package/template/knowledge/design-styles/swipes/american-industrial/G59fgNuXkAAKLJQ.jpeg +0 -0
  83. package/template/knowledge/design-styles/swipes/american-industrial/G7fVkn3WEAAM-ST.jpeg +0 -0
  84. package/template/knowledge/design-styles/swipes/american-industrial/G8ECO5JWEAIksyn.png +0 -0
  85. package/template/knowledge/design-styles/swipes/american-industrial/G9-3GQSWoAA8eqZ.png +0 -0
  86. package/template/knowledge/design-styles/swipes/american-industrial/G9xEOqrXkAEZRcs.png +0 -0
  87. package/template/knowledge/design-styles/swipes/american-industrial/G_MVeJrXQAA8sx4.jpeg +0 -0
  88. package/template/knowledge/design-styles/swipes/american-industrial/G_RSkmGXkAAgAVZ.png +0 -0
  89. package/template/knowledge/design-styles/swipes/american-industrial/README.md +31 -0
  90. package/template/knowledge/design-styles/swipes/american-industrial/qyqtg7Dq.png +0 -0
  91. package/template/knowledge/dev-team/README.md +35 -0
  92. package/template/knowledge/dev-team/patterns/README.md +34 -0
  93. package/template/knowledge/dev-team/patterns/frontend/react-best-practices.md +178 -0
  94. package/template/knowledge/dev-team/troubleshooting/README.md +31 -0
  95. package/template/knowledge/dev-team/workflows/README.md +49 -0
  96. package/template/knowledge/hq/checkpoint-schema.json +51 -0
  97. package/template/knowledge/hq/index-md-spec.md +74 -0
  98. package/template/knowledge/hq/thread-schema.md +153 -0
  99. package/template/knowledge/hq-core/checkpoint-schema.json +51 -0
  100. package/template/knowledge/hq-core/index-md-spec.md +74 -0
  101. package/template/knowledge/hq-core/thread-schema.md +153 -0
  102. package/template/knowledge/loom/README.md +51 -0
  103. package/template/knowledge/loom/architecture.md +125 -0
  104. package/template/knowledge/loom/code-style.md +169 -0
  105. package/template/knowledge/loom/llm-proxy.md +132 -0
  106. package/template/knowledge/loom/state-machine.md +131 -0
  107. package/template/knowledge/loom/thread-system.md +117 -0
  108. package/template/knowledge/loom/tools.md +94 -0
  109. package/template/knowledge/loom/weaver.md +96 -0
  110. package/template/knowledge/loom/web-frontend.md +131 -0
  111. package/template/knowledge/projects/README.md +72 -0
  112. package/template/knowledge/projects/templates/README.template.md +28 -0
  113. package/template/knowledge/workers/README.md +195 -0
  114. package/template/knowledge/workers/ralph-loop-pattern.md +157 -0
  115. package/template/knowledge/workers/skill-schema.md +182 -0
  116. package/template/knowledge/workers/state-machine.md +102 -0
  117. package/template/knowledge/workers/templates/base-worker.yaml +73 -0
  118. package/template/knowledge/workers/templates/code-worker.yaml +85 -0
  119. package/template/knowledge/workers/templates/skill.yaml +49 -0
  120. package/template/knowledge/workers/templates/social-worker.yaml +70 -0
  121. package/template/modules/examples/full-manifest.yaml +92 -0
  122. package/template/modules/examples/minimal.yaml +14 -0
  123. package/template/modules/modules.yaml +59 -0
  124. package/template/projects/.gitkeep +0 -0
  125. package/template/projects/incorporate-workers-into-pure-ralph/prd.json +88 -0
  126. package/template/projects/pure-ralph-branch-isolation/README.md +114 -0
  127. package/template/projects/pure-ralph-branch-isolation/prd.json +123 -0
  128. package/template/projects/purist-ralph-loop/README.md +148 -0
  129. package/template/projects/purist-ralph-loop/prd.json +135 -0
  130. package/template/projects/ralph-test/prd.json +50 -0
  131. package/template/prompts/pure-ralph-base.md +551 -0
  132. package/template/settings/.gitkeep +0 -0
  133. package/template/settings/pure-ralph.json +42 -0
  134. package/template/social-content/drafts/INDEX.md +21 -0
  135. package/template/social-content/drafts/linkedin/.gitkeep +1 -0
  136. package/template/social-content/drafts/x/.gitkeep +1 -0
  137. package/template/social-content/images/.gitkeep +1 -0
  138. package/template/starter-projects/code-worker/README.md +97 -0
  139. package/template/starter-projects/code-worker/prd.json +45 -0
  140. package/template/starter-projects/personal-assistant/README.md +42 -0
  141. package/template/starter-projects/personal-assistant/prd.json +43 -0
  142. package/template/starter-projects/social-media/README.md +60 -0
  143. package/template/starter-projects/social-media/prd.json +43 -0
  144. package/template/workers/content-brand/README.md +59 -0
  145. package/template/workers/content-brand/skills/messaging-alignment.md +91 -0
  146. package/template/workers/content-brand/skills/tone-check.md +76 -0
  147. package/template/workers/content-brand/skills/voice-analysis.md +68 -0
  148. package/template/workers/content-brand/worker.yaml +81 -0
  149. package/template/workers/content-legal/README.md +80 -0
  150. package/template/workers/content-legal/skills/claim-substantiation.md +150 -0
  151. package/template/workers/content-legal/skills/compliance-scan.md +123 -0
  152. package/template/workers/content-legal/skills/disclaimer-check.md +146 -0
  153. package/template/workers/content-legal/worker.yaml +118 -0
  154. package/template/workers/content-product/README.md +77 -0
  155. package/template/workers/content-product/skills/claim-verification.md +96 -0
  156. package/template/workers/content-product/skills/feature-accuracy.md +117 -0
  157. package/template/workers/content-product/skills/stats-check.md +128 -0
  158. package/template/workers/content-product/worker.yaml +97 -0
  159. package/template/workers/content-sales/README.md +70 -0
  160. package/template/workers/content-sales/skills/conversion-analysis.md +96 -0
  161. package/template/workers/content-sales/skills/cta-audit.md +107 -0
  162. package/template/workers/content-sales/skills/value-prop-check.md +114 -0
  163. package/template/workers/content-sales/worker.yaml +93 -0
  164. package/template/workers/content-shared/cli.ts +242 -0
  165. package/template/workers/content-shared/index.ts +234 -0
  166. package/template/workers/content-shared/lib/accuracy-analyzer.ts +661 -0
  167. package/template/workers/content-shared/lib/analyze.ts +370 -0
  168. package/template/workers/content-shared/lib/brand-analyzer.ts +526 -0
  169. package/template/workers/content-shared/lib/cms-integration.ts +446 -0
  170. package/template/workers/content-shared/lib/compliance-analyzer.ts +655 -0
  171. package/template/workers/content-shared/lib/conversion-analyzer.ts +555 -0
  172. package/template/workers/content-shared/lib/github-integration.ts +582 -0
  173. package/template/workers/content-shared/lib/output.ts +373 -0
  174. package/template/workers/content-shared/lib/parser.ts +771 -0
  175. package/template/workers/content-shared/lib/priority.ts +439 -0
  176. package/template/workers/content-shared/lib/recommendations.ts +512 -0
  177. package/template/workers/content-shared/lib/reporter.ts +749 -0
  178. package/template/workers/content-shared/lib/restructure.ts +664 -0
  179. package/template/workers/content-shared/lib/scorer.ts +140 -0
  180. package/template/workers/content-shared/lib/types.ts +227 -0
  181. package/template/workers/content-shared/lib/variants.ts +595 -0
  182. package/template/workers/content-shared/package.json +51 -0
  183. package/template/workers/content-shared/pnpm-lock.yaml +39 -0
  184. package/template/workers/content-shared/test/sample-page.json +115 -0
  185. package/template/workers/content-shared/tsconfig.json +20 -0
  186. package/template/workers/dev-team/README.md +166 -0
  187. package/template/workers/dev-team/_template.yaml +70 -0
  188. package/template/workers/dev-team/architect/package.json +27 -0
  189. package/template/workers/dev-team/architect/skills/api-design.md +89 -0
  190. package/template/workers/dev-team/architect/skills/refactor-plan.md +96 -0
  191. package/template/workers/dev-team/architect/skills/system-design.md +100 -0
  192. package/template/workers/dev-team/architect/src/index.ts +49 -0
  193. package/template/workers/dev-team/architect/src/mcp-server.ts +122 -0
  194. package/template/workers/dev-team/architect/src/skills/api-design.ts +316 -0
  195. package/template/workers/dev-team/architect/src/skills/refactor-plan.ts +264 -0
  196. package/template/workers/dev-team/architect/src/skills/system-design.ts +212 -0
  197. package/template/workers/dev-team/architect/tsconfig.json +19 -0
  198. package/template/workers/dev-team/architect/worker.yaml +128 -0
  199. package/template/workers/dev-team/backend-dev/package-lock.json +1252 -0
  200. package/template/workers/dev-team/backend-dev/package.json +27 -0
  201. package/template/workers/dev-team/backend-dev/skills/implement-endpoint.md +70 -0
  202. package/template/workers/dev-team/backend-dev/skills/implement-service.md +62 -0
  203. package/template/workers/dev-team/backend-dev/src/index.ts +51 -0
  204. package/template/workers/dev-team/backend-dev/src/mcp-server.ts +109 -0
  205. package/template/workers/dev-team/backend-dev/src/skills/implement-endpoint.ts +122 -0
  206. package/template/workers/dev-team/backend-dev/src/skills/implement-service.ts +126 -0
  207. package/template/workers/dev-team/backend-dev/tsconfig.json +19 -0
  208. package/template/workers/dev-team/backend-dev/worker.yaml +128 -0
  209. package/template/workers/dev-team/code-reviewer/package-lock.json +1080 -0
  210. package/template/workers/dev-team/code-reviewer/package.json +24 -0
  211. package/template/workers/dev-team/code-reviewer/skills/merge-to-production.md +61 -0
  212. package/template/workers/dev-team/code-reviewer/skills/merge-to-staging.md +54 -0
  213. package/template/workers/dev-team/code-reviewer/skills/request-changes.md +63 -0
  214. package/template/workers/dev-team/code-reviewer/skills/review-pr.md +77 -0
  215. package/template/workers/dev-team/code-reviewer/src/index.ts +56 -0
  216. package/template/workers/dev-team/code-reviewer/src/mcp-server.ts +101 -0
  217. package/template/workers/dev-team/code-reviewer/tsconfig.json +19 -0
  218. package/template/workers/dev-team/code-reviewer/worker.yaml +90 -0
  219. package/template/workers/dev-team/database-dev/package.json +22 -0
  220. package/template/workers/dev-team/database-dev/skills/create-schema.md +48 -0
  221. package/template/workers/dev-team/database-dev/src/index.ts +50 -0
  222. package/template/workers/dev-team/database-dev/src/mcp-server.ts +76 -0
  223. package/template/workers/dev-team/database-dev/tsconfig.json +18 -0
  224. package/template/workers/dev-team/database-dev/worker.yaml +90 -0
  225. package/template/workers/dev-team/frontend-dev/package.json +22 -0
  226. package/template/workers/dev-team/frontend-dev/skills/create-component.md +26 -0
  227. package/template/workers/dev-team/frontend-dev/src/index.ts +50 -0
  228. package/template/workers/dev-team/frontend-dev/src/mcp-server.ts +77 -0
  229. package/template/workers/dev-team/frontend-dev/tsconfig.json +18 -0
  230. package/template/workers/dev-team/frontend-dev/worker.yaml +132 -0
  231. package/template/workers/dev-team/infra-dev/package.json +24 -0
  232. package/template/workers/dev-team/infra-dev/skills/add-monitoring.md +73 -0
  233. package/template/workers/dev-team/infra-dev/skills/configure-deployment.md +80 -0
  234. package/template/workers/dev-team/infra-dev/skills/create-dockerfile.md +62 -0
  235. package/template/workers/dev-team/infra-dev/skills/setup-cicd.md +63 -0
  236. package/template/workers/dev-team/infra-dev/src/index.ts +55 -0
  237. package/template/workers/dev-team/infra-dev/src/mcp-server.ts +82 -0
  238. package/template/workers/dev-team/infra-dev/tsconfig.json +19 -0
  239. package/template/workers/dev-team/infra-dev/worker.yaml +92 -0
  240. package/template/workers/dev-team/knowledge-curator/package.json +24 -0
  241. package/template/workers/dev-team/knowledge-curator/skills/curate-troubleshooting.md +63 -0
  242. package/template/workers/dev-team/knowledge-curator/skills/process-learnings.md +61 -0
  243. package/template/workers/dev-team/knowledge-curator/skills/sync-documentation.md +76 -0
  244. package/template/workers/dev-team/knowledge-curator/skills/update-patterns.md +63 -0
  245. package/template/workers/dev-team/knowledge-curator/src/index.ts +53 -0
  246. package/template/workers/dev-team/knowledge-curator/src/mcp-server.ts +92 -0
  247. package/template/workers/dev-team/knowledge-curator/tsconfig.json +19 -0
  248. package/template/workers/dev-team/knowledge-curator/worker.yaml +80 -0
  249. package/template/workers/dev-team/motion-designer/package.json +22 -0
  250. package/template/workers/dev-team/motion-designer/skills/add-animation.md +25 -0
  251. package/template/workers/dev-team/motion-designer/skills/generate-image.md +36 -0
  252. package/template/workers/dev-team/motion-designer/src/index.ts +63 -0
  253. package/template/workers/dev-team/motion-designer/src/mcp-server.ts +79 -0
  254. package/template/workers/dev-team/motion-designer/tsconfig.json +18 -0
  255. package/template/workers/dev-team/motion-designer/worker.yaml +84 -0
  256. package/template/workers/dev-team/product-planner/queue.json +4 -0
  257. package/template/workers/dev-team/product-planner/worker.yaml +220 -0
  258. package/template/workers/dev-team/project-manager/package-lock.json +1252 -0
  259. package/template/workers/dev-team/project-manager/package.json +27 -0
  260. package/template/workers/dev-team/project-manager/skills/create-prd.md +66 -0
  261. package/template/workers/dev-team/project-manager/skills/next-issue.md +51 -0
  262. package/template/workers/dev-team/project-manager/skills/project-status.md +59 -0
  263. package/template/workers/dev-team/project-manager/skills/update-learnings.md +65 -0
  264. package/template/workers/dev-team/project-manager/src/index.ts +54 -0
  265. package/template/workers/dev-team/project-manager/src/mcp-server.ts +207 -0
  266. package/template/workers/dev-team/project-manager/src/skills/create-prd.ts +86 -0
  267. package/template/workers/dev-team/project-manager/src/skills/next-issue.ts +137 -0
  268. package/template/workers/dev-team/project-manager/src/skills/project-status.ts +131 -0
  269. package/template/workers/dev-team/project-manager/src/skills/update-learnings.ts +94 -0
  270. package/template/workers/dev-team/project-manager/tsconfig.json +19 -0
  271. package/template/workers/dev-team/project-manager/worker.yaml +96 -0
  272. package/template/workers/dev-team/qa-tester/package.json +24 -0
  273. package/template/workers/dev-team/qa-tester/skills/create-demo-account.md +36 -0
  274. package/template/workers/dev-team/qa-tester/skills/run-tests.md +36 -0
  275. package/template/workers/dev-team/qa-tester/skills/write-test.md +27 -0
  276. package/template/workers/dev-team/qa-tester/src/index.ts +61 -0
  277. package/template/workers/dev-team/qa-tester/src/mcp-server.ts +88 -0
  278. package/template/workers/dev-team/qa-tester/tsconfig.json +18 -0
  279. package/template/workers/dev-team/qa-tester/worker.yaml +116 -0
  280. package/template/workers/dev-team/task-executor/package-lock.json +1252 -0
  281. package/template/workers/dev-team/task-executor/package.json +27 -0
  282. package/template/workers/dev-team/task-executor/skills/analyze-issue.md +101 -0
  283. package/template/workers/dev-team/task-executor/skills/execute.md +133 -0
  284. package/template/workers/dev-team/task-executor/skills/report-learnings.md +106 -0
  285. package/template/workers/dev-team/task-executor/skills/validate-completion.md +121 -0
  286. package/template/workers/dev-team/task-executor/src/index.ts +54 -0
  287. package/template/workers/dev-team/task-executor/src/mcp-server.ts +139 -0
  288. package/template/workers/dev-team/task-executor/src/skills/analyze-issue.ts +219 -0
  289. package/template/workers/dev-team/task-executor/src/skills/execute.ts +132 -0
  290. package/template/workers/dev-team/task-executor/src/skills/report-learnings.ts +119 -0
  291. package/template/workers/dev-team/task-executor/src/skills/validate-completion.ts +142 -0
  292. package/template/workers/dev-team/task-executor/tsconfig.json +19 -0
  293. package/template/workers/dev-team/task-executor/worker.yaml +110 -0
  294. package/template/workers/registry.yaml +171 -0
  295. package/template/workers/security-scanner/README.md +73 -0
  296. package/template/workers/security-scanner/skills/pre-deploy-check.md +205 -0
  297. package/template/workers/security-scanner/worker.yaml +26 -0
  298. package/template/workspace/checkpoints/.gitkeep +0 -0
  299. package/template/workspace/content-ideas/inbox.jsonl +0 -0
  300. package/template/workspace/drafts/.gitkeep +0 -0
  301. package/template/workspace/learnings/.gitkeep +3 -0
  302. package/template/workspace/orchestrator/.gitkeep +0 -0
  303. package/template/workspace/ralph-test/COMPLETE.md +18 -0
  304. package/template/workspace/ralph-test/hello.txt +2 -0
  305. package/template/workspace/reports/.gitkeep +0 -0
  306. package/template/workspace/scratch/.gitkeep +0 -0
  307. package/template/workspace/threads/.gitkeep +3 -0
@@ -0,0 +1,661 @@
1
+ /**
2
+ * Technical Accuracy Analyzer (US-009)
3
+ * Verifies product claims and features against known product data
4
+ */
5
+
6
+ import type {
7
+ AnalysisInput,
8
+ ProductData,
9
+ AccuracyAnalysis,
10
+ Finding,
11
+ Recommendation,
12
+ } from './types.js';
13
+
14
+ // ============================================
15
+ // Default Product Data Template
16
+ // ============================================
17
+
18
+ export const DEFAULT_PRODUCT_DATA: ProductData = {
19
+ productName: 'Product',
20
+ features: [],
21
+ stats: {},
22
+ certifications: [],
23
+ integrations: [],
24
+ lastUpdated: new Date().toISOString(),
25
+ };
26
+
27
+ // ============================================
28
+ // Scoring Weights
29
+ // ============================================
30
+
31
+ const WEIGHTS = {
32
+ claimsVerification: 0.40,
33
+ statsAccuracy: 0.35,
34
+ featureConsistency: 0.25,
35
+ };
36
+
37
+ // ============================================
38
+ // Main Analysis Function
39
+ // ============================================
40
+
41
+ /**
42
+ * Analyze content for technical accuracy against known product data
43
+ */
44
+ export function analyzeAccuracy(
45
+ content: AnalysisInput,
46
+ productData: ProductData = DEFAULT_PRODUCT_DATA
47
+ ): AccuracyAnalysis {
48
+ const findings: Finding[] = [];
49
+ const recommendations: Recommendation[] = [];
50
+
51
+ // Verify claims
52
+ const claimsResult = verifyClaims(content, productData, findings, recommendations);
53
+
54
+ // Check stats accuracy
55
+ const statsResult = checkStatsAccuracy(content, productData, findings, recommendations);
56
+
57
+ // Check feature consistency
58
+ const featureResult = checkFeatureConsistency(content, productData, findings, recommendations);
59
+
60
+ // Calculate overall score
61
+ const overallScore = Math.round(
62
+ claimsResult.score * WEIGHTS.claimsVerification +
63
+ statsResult.score * WEIGHTS.statsAccuracy +
64
+ featureResult.score * WEIGHTS.featureConsistency
65
+ );
66
+
67
+ return {
68
+ overallScore,
69
+ claimsVerified: claimsResult.verified,
70
+ claimsUnverified: claimsResult.unverified,
71
+ statsFound: statsResult.found,
72
+ statsOutdated: statsResult.outdated,
73
+ findings,
74
+ recommendations,
75
+ };
76
+ }
77
+
78
+ // ============================================
79
+ // Claims Verification
80
+ // ============================================
81
+
82
+ interface ClaimsResult {
83
+ score: number;
84
+ verified: number;
85
+ unverified: number;
86
+ }
87
+
88
+ function verifyClaims(
89
+ content: AnalysisInput,
90
+ productData: ProductData,
91
+ findings: Finding[],
92
+ recommendations: Recommendation[]
93
+ ): ClaimsResult {
94
+ let verified = 0;
95
+ let unverified = 0;
96
+
97
+ if (content.claims.length === 0) {
98
+ findings.push({
99
+ severity: 'info',
100
+ category: 'Accuracy - Claims',
101
+ message: 'No verifiable claims detected in content',
102
+ });
103
+ return { score: 100, verified: 0, unverified: 0 };
104
+ }
105
+
106
+ // Categorize claims
107
+ const claimCategories = categorizeClaims(content.claims);
108
+
109
+ // Check superlative claims (highest risk)
110
+ for (const claim of claimCategories.superlatives) {
111
+ const isSubstantiated = checkSuperlativeClaim(claim, productData);
112
+ if (isSubstantiated) {
113
+ verified++;
114
+ findings.push({
115
+ severity: 'pass',
116
+ category: 'Accuracy - Claims',
117
+ message: 'Superlative claim may be supported by data',
118
+ evidence: truncate(claim, 100),
119
+ });
120
+ } else {
121
+ unverified++;
122
+ findings.push({
123
+ severity: 'warning',
124
+ category: 'Accuracy - Claims',
125
+ message: 'Superlative claim lacks verification',
126
+ evidence: truncate(claim, 100),
127
+ });
128
+ recommendations.push({
129
+ priority: 'high',
130
+ category: 'Claims',
131
+ current: truncate(claim, 80),
132
+ suggested: 'Add supporting data or soften to "one of the leading" or similar',
133
+ rationale: 'Unsubstantiated superlatives can damage credibility and raise legal concerns',
134
+ });
135
+ }
136
+ }
137
+
138
+ // Check quantitative claims
139
+ for (const claim of claimCategories.quantitative) {
140
+ const isVerifiable = checkQuantitativeClaim(claim, productData);
141
+ if (isVerifiable.verified) {
142
+ verified++;
143
+ findings.push({
144
+ severity: 'pass',
145
+ category: 'Accuracy - Claims',
146
+ message: 'Quantitative claim appears verifiable',
147
+ evidence: truncate(claim, 100),
148
+ });
149
+ } else {
150
+ unverified++;
151
+ findings.push({
152
+ severity: isVerifiable.severity,
153
+ category: 'Accuracy - Claims',
154
+ message: isVerifiable.reason,
155
+ evidence: truncate(claim, 100),
156
+ });
157
+ if (isVerifiable.suggestion) {
158
+ recommendations.push({
159
+ priority: 'medium',
160
+ category: 'Claims',
161
+ current: truncate(claim, 80),
162
+ suggested: isVerifiable.suggestion,
163
+ rationale: 'Quantitative claims should be verifiable and up-to-date',
164
+ });
165
+ }
166
+ }
167
+ }
168
+
169
+ // Check certification/compliance claims
170
+ for (const claim of claimCategories.certifications) {
171
+ const certFound = productData.certifications.some(cert =>
172
+ claim.toLowerCase().includes(cert.toLowerCase())
173
+ );
174
+ if (certFound) {
175
+ verified++;
176
+ findings.push({
177
+ severity: 'pass',
178
+ category: 'Accuracy - Claims',
179
+ message: 'Certification claim matches known certifications',
180
+ evidence: truncate(claim, 100),
181
+ });
182
+ } else {
183
+ unverified++;
184
+ findings.push({
185
+ severity: 'warning',
186
+ category: 'Accuracy - Claims',
187
+ message: 'Certification claim not found in product data',
188
+ evidence: truncate(claim, 100),
189
+ });
190
+ recommendations.push({
191
+ priority: 'high',
192
+ category: 'Claims',
193
+ current: truncate(claim, 80),
194
+ suggested: 'Verify certification status and update product data',
195
+ rationale: 'False certification claims can have serious legal consequences',
196
+ });
197
+ }
198
+ }
199
+
200
+ // Count general claims (lower priority)
201
+ verified += claimCategories.general.length;
202
+
203
+ const total = verified + unverified;
204
+ const verificationRate = total > 0 ? verified / total : 1;
205
+ const score = Math.round(verificationRate * 100);
206
+
207
+ return { score, verified, unverified };
208
+ }
209
+
210
+ // ============================================
211
+ // Stats Accuracy Check
212
+ // ============================================
213
+
214
+ interface StatsResult {
215
+ score: number;
216
+ found: number;
217
+ outdated: number;
218
+ }
219
+
220
+ function checkStatsAccuracy(
221
+ content: AnalysisInput,
222
+ productData: ProductData,
223
+ findings: Finding[],
224
+ recommendations: Recommendation[]
225
+ ): StatsResult {
226
+ let found = content.stats.length;
227
+ let outdated = 0;
228
+ let score = 100;
229
+
230
+ if (content.stats.length === 0) {
231
+ findings.push({
232
+ severity: 'info',
233
+ category: 'Accuracy - Statistics',
234
+ message: 'No statistics found in content',
235
+ });
236
+ return { score: 100, found: 0, outdated: 0 };
237
+ }
238
+
239
+ // Check stats against known product data
240
+ for (const stat of content.stats) {
241
+ const validity = checkStatValidity(stat.value, productData.stats);
242
+
243
+ if (validity.status === 'verified') {
244
+ findings.push({
245
+ severity: 'pass',
246
+ category: 'Accuracy - Statistics',
247
+ message: `Statistic verified: ${stat.value}`,
248
+ evidence: stat.label,
249
+ });
250
+ } else if (validity.status === 'outdated') {
251
+ outdated++;
252
+ findings.push({
253
+ severity: 'warning',
254
+ category: 'Accuracy - Statistics',
255
+ message: `Statistic may be outdated: ${stat.value}`,
256
+ evidence: `Current value: ${validity.currentValue}`,
257
+ });
258
+ score -= 15;
259
+ recommendations.push({
260
+ priority: 'high',
261
+ category: 'Statistics',
262
+ current: `${stat.value} (${stat.label})`,
263
+ suggested: `Update to ${validity.currentValue}`,
264
+ rationale: 'Outdated statistics undermine credibility',
265
+ });
266
+ } else if (validity.status === 'unverified') {
267
+ findings.push({
268
+ severity: 'info',
269
+ category: 'Accuracy - Statistics',
270
+ message: `Statistic not in known data: ${stat.value}`,
271
+ evidence: stat.label,
272
+ });
273
+ // Minor deduction for unverified stats
274
+ score -= 5;
275
+ }
276
+ }
277
+
278
+ // Check for stale data indicators
279
+ const lastUpdated = new Date(productData.lastUpdated);
280
+ const monthsOld = (Date.now() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24 * 30);
281
+
282
+ if (monthsOld > 6) {
283
+ findings.push({
284
+ severity: 'warning',
285
+ category: 'Accuracy - Statistics',
286
+ message: `Product data is ${Math.round(monthsOld)} months old`,
287
+ });
288
+ score -= 10;
289
+ recommendations.push({
290
+ priority: 'medium',
291
+ category: 'Statistics',
292
+ current: `Product data last updated ${Math.round(monthsOld)} months ago`,
293
+ suggested: 'Review and update product statistics',
294
+ rationale: 'Regular data updates ensure accuracy',
295
+ });
296
+ }
297
+
298
+ // Check for missing source attribution
299
+ const statsWithoutSource = content.stats.filter(s =>
300
+ !s.label.toLowerCase().includes('source') &&
301
+ !s.label.toLowerCase().includes('study') &&
302
+ !s.label.toLowerCase().includes('report')
303
+ );
304
+
305
+ if (statsWithoutSource.length > content.stats.length * 0.5) {
306
+ findings.push({
307
+ severity: 'info',
308
+ category: 'Accuracy - Statistics',
309
+ message: 'Most statistics lack source attribution',
310
+ });
311
+ recommendations.push({
312
+ priority: 'low',
313
+ category: 'Statistics',
314
+ current: 'Statistics without sources',
315
+ suggested: 'Add source attribution for third-party statistics',
316
+ rationale: 'Cited sources increase credibility',
317
+ });
318
+ }
319
+
320
+ return { score: Math.max(0, score), found, outdated };
321
+ }
322
+
323
+ /**
324
+ * Check if a statistic is valid against known product stats
325
+ */
326
+ export function checkStatValidity(
327
+ stat: string,
328
+ knownStats: Record<string, string>
329
+ ): { status: 'verified' | 'outdated' | 'unverified'; currentValue?: string } {
330
+ // Extract numeric value from stat
331
+ const numericMatch = stat.match(/[\d,.]+/);
332
+ if (!numericMatch) {
333
+ return { status: 'unverified' };
334
+ }
335
+
336
+ const statValue = numericMatch[0];
337
+
338
+ // Check against known stats
339
+ for (const [key, knownValue] of Object.entries(knownStats)) {
340
+ // Check if the stat matches this category
341
+ if (stat.toLowerCase().includes(key.toLowerCase())) {
342
+ if (knownValue === statValue || knownValue.includes(statValue)) {
343
+ return { status: 'verified' };
344
+ } else {
345
+ return { status: 'outdated', currentValue: knownValue };
346
+ }
347
+ }
348
+ }
349
+
350
+ return { status: 'unverified' };
351
+ }
352
+
353
+ // ============================================
354
+ // Feature Consistency Check
355
+ // ============================================
356
+
357
+ interface FeatureResult {
358
+ score: number;
359
+ }
360
+
361
+ function checkFeatureConsistency(
362
+ content: AnalysisInput,
363
+ productData: ProductData,
364
+ findings: Finding[],
365
+ recommendations: Recommendation[]
366
+ ): FeatureResult {
367
+ let score = 100;
368
+
369
+ if (productData.features.length === 0) {
370
+ findings.push({
371
+ severity: 'info',
372
+ category: 'Accuracy - Features',
373
+ message: 'No product features defined for verification',
374
+ });
375
+ return { score: 100 };
376
+ }
377
+
378
+ const allText = [
379
+ content.title,
380
+ ...content.headings,
381
+ ...content.paragraphs,
382
+ ].join(' ').toLowerCase();
383
+
384
+ // Check for mentioned features
385
+ const mentionedFeatures: string[] = [];
386
+ const unmentionedFeatures: string[] = [];
387
+
388
+ for (const feature of productData.features) {
389
+ // Create variations of the feature name for matching
390
+ const variations = [
391
+ feature.toLowerCase(),
392
+ feature.toLowerCase().replace(/-/g, ' '),
393
+ feature.toLowerCase().replace(/_/g, ' '),
394
+ ];
395
+
396
+ const isMentioned = variations.some(v => allText.includes(v));
397
+
398
+ if (isMentioned) {
399
+ mentionedFeatures.push(feature);
400
+ } else {
401
+ unmentionedFeatures.push(feature);
402
+ }
403
+ }
404
+
405
+ // Report findings
406
+ const coverage = mentionedFeatures.length / productData.features.length;
407
+
408
+ if (coverage >= 0.7) {
409
+ findings.push({
410
+ severity: 'pass',
411
+ category: 'Accuracy - Features',
412
+ message: `Good feature coverage: ${Math.round(coverage * 100)}%`,
413
+ evidence: `${mentionedFeatures.length}/${productData.features.length} features mentioned`,
414
+ });
415
+ } else if (coverage >= 0.4) {
416
+ findings.push({
417
+ severity: 'info',
418
+ category: 'Accuracy - Features',
419
+ message: `Moderate feature coverage: ${Math.round(coverage * 100)}%`,
420
+ evidence: `Missing: ${unmentionedFeatures.slice(0, 3).join(', ')}`,
421
+ });
422
+ score -= 15;
423
+ } else {
424
+ findings.push({
425
+ severity: 'warning',
426
+ category: 'Accuracy - Features',
427
+ message: `Low feature coverage: ${Math.round(coverage * 100)}%`,
428
+ evidence: `Many key features not mentioned`,
429
+ });
430
+ score -= 30;
431
+ recommendations.push({
432
+ priority: 'medium',
433
+ category: 'Features',
434
+ current: `Only ${mentionedFeatures.length} of ${productData.features.length} features mentioned`,
435
+ suggested: `Consider adding content about: ${unmentionedFeatures.slice(0, 3).join(', ')}`,
436
+ rationale: 'Comprehensive feature coverage improves page value',
437
+ });
438
+ }
439
+
440
+ // Check for potentially incorrect feature claims
441
+ const featureClaims = extractFeatureClaims(content);
442
+ const invalidClaims = featureClaims.filter(claim => {
443
+ const normalized = claim.toLowerCase();
444
+ return !productData.features.some(f =>
445
+ normalized.includes(f.toLowerCase()) ||
446
+ f.toLowerCase().includes(normalized)
447
+ ) && !productData.integrations.some(i =>
448
+ normalized.includes(i.toLowerCase())
449
+ );
450
+ });
451
+
452
+ if (invalidClaims.length > 0) {
453
+ findings.push({
454
+ severity: 'warning',
455
+ category: 'Accuracy - Features',
456
+ message: `${invalidClaims.length} feature claim(s) not in product data`,
457
+ evidence: invalidClaims.slice(0, 2).join('; '),
458
+ });
459
+ score -= invalidClaims.length * 5;
460
+ recommendations.push({
461
+ priority: 'medium',
462
+ category: 'Features',
463
+ current: `Claims about: ${invalidClaims.slice(0, 2).join(', ')}`,
464
+ suggested: 'Verify these features exist or update product data',
465
+ rationale: 'Feature claims should match actual product capabilities',
466
+ });
467
+ }
468
+
469
+ // Check integrations mentions
470
+ if (productData.integrations.length > 0) {
471
+ const integrationsMatch = productData.integrations.filter(integration =>
472
+ allText.includes(integration.toLowerCase())
473
+ );
474
+
475
+ if (integrationsMatch.length > 0) {
476
+ findings.push({
477
+ severity: 'pass',
478
+ category: 'Accuracy - Features',
479
+ message: `Integrations mentioned: ${integrationsMatch.length}`,
480
+ evidence: integrationsMatch.slice(0, 5).join(', '),
481
+ });
482
+ }
483
+ }
484
+
485
+ return { score: Math.max(0, score) };
486
+ }
487
+
488
+ // ============================================
489
+ // Helper Functions
490
+ // ============================================
491
+
492
+ interface CategorizedClaims {
493
+ superlatives: string[];
494
+ quantitative: string[];
495
+ certifications: string[];
496
+ general: string[];
497
+ }
498
+
499
+ /**
500
+ * Categorize claims by type
501
+ */
502
+ function categorizeClaims(claims: string[]): CategorizedClaims {
503
+ const result: CategorizedClaims = {
504
+ superlatives: [],
505
+ quantitative: [],
506
+ certifications: [],
507
+ general: [],
508
+ };
509
+
510
+ const superlativePatterns = [
511
+ /\b(best|leading|top|#1|number one|premier|fastest|only|first|most|largest)\b/i,
512
+ /\b(award-winning|industry-leading|world-class|best-in-class)\b/i,
513
+ ];
514
+
515
+ const quantitativePatterns = [
516
+ /\d+(?:\.\d+)?%/,
517
+ /\$[\d,]+/,
518
+ /\d+x/i,
519
+ /\d+(?:,\d{3})+/,
520
+ ];
521
+
522
+ const certificationPatterns = [
523
+ /\b(SOC\s*2|HIPAA|GDPR|ISO\s*\d+|PCI|FedRAMP|CCPA)\b/i,
524
+ /\b(certified|compliant|accredited)\b/i,
525
+ ];
526
+
527
+ for (const claim of claims) {
528
+ if (superlativePatterns.some(p => p.test(claim))) {
529
+ result.superlatives.push(claim);
530
+ } else if (quantitativePatterns.some(p => p.test(claim))) {
531
+ result.quantitative.push(claim);
532
+ } else if (certificationPatterns.some(p => p.test(claim))) {
533
+ result.certifications.push(claim);
534
+ } else {
535
+ result.general.push(claim);
536
+ }
537
+ }
538
+
539
+ return result;
540
+ }
541
+
542
+ /**
543
+ * Check if a superlative claim is substantiated
544
+ */
545
+ function checkSuperlativeClaim(claim: string, productData: ProductData): boolean {
546
+ // Check if there's supporting data for the claim
547
+ const claimLower = claim.toLowerCase();
548
+
549
+ // If we have relevant stats, it might be substantiated
550
+ for (const [key, value] of Object.entries(productData.stats)) {
551
+ if (claimLower.includes(key.toLowerCase())) {
552
+ return true;
553
+ }
554
+ }
555
+
556
+ // Check certifications
557
+ for (const cert of productData.certifications) {
558
+ if (claimLower.includes(cert.toLowerCase())) {
559
+ return true;
560
+ }
561
+ }
562
+
563
+ return false;
564
+ }
565
+
566
+ interface QuantitativeCheckResult {
567
+ verified: boolean;
568
+ severity: 'warning' | 'info';
569
+ reason: string;
570
+ suggestion?: string;
571
+ }
572
+
573
+ /**
574
+ * Check if a quantitative claim is verifiable
575
+ */
576
+ function checkQuantitativeClaim(
577
+ claim: string,
578
+ productData: ProductData
579
+ ): QuantitativeCheckResult {
580
+ // Extract the number from the claim
581
+ const numbers = claim.match(/[\d,.]+(?:%|x|K|M|B)?/gi);
582
+
583
+ if (!numbers || numbers.length === 0) {
584
+ return {
585
+ verified: false,
586
+ severity: 'info',
587
+ reason: 'No quantitative value found in claim',
588
+ };
589
+ }
590
+
591
+ // Check against known stats
592
+ for (const [key, value] of Object.entries(productData.stats)) {
593
+ if (claim.toLowerCase().includes(key.toLowerCase())) {
594
+ // Check if values match
595
+ if (numbers.some(n => value.includes(n) || n.includes(value.replace(/[^\d.]/g, '')))) {
596
+ return { verified: true, severity: 'info', reason: 'Verified' };
597
+ } else {
598
+ return {
599
+ verified: false,
600
+ severity: 'warning',
601
+ reason: `Value ${numbers[0]} doesn't match known value: ${value}`,
602
+ suggestion: `Update to current value: ${value}`,
603
+ };
604
+ }
605
+ }
606
+ }
607
+
608
+ // Check if it's a round number (potentially fabricated)
609
+ const roundNumberPattern = /^(10|25|50|100|1000)0*$/;
610
+ if (numbers.some(n => roundNumberPattern.test(n.replace(/[^0-9]/g, '')))) {
611
+ return {
612
+ verified: false,
613
+ severity: 'info',
614
+ reason: 'Round number may appear less credible',
615
+ suggestion: 'Use specific numbers when available for more credibility',
616
+ };
617
+ }
618
+
619
+ return {
620
+ verified: false,
621
+ severity: 'info',
622
+ reason: 'Quantitative claim not found in product data',
623
+ };
624
+ }
625
+
626
+ /**
627
+ * Extract feature-related claims from content
628
+ */
629
+ function extractFeatureClaims(content: AnalysisInput): string[] {
630
+ const featureClaims: string[] = [];
631
+
632
+ // Look for "integrates with", "supports", "works with", etc.
633
+ const featurePatterns = [
634
+ /integrates?\s+with\s+([^.]+)/gi,
635
+ /supports?\s+([^.]+)/gi,
636
+ /works?\s+with\s+([^.]+)/gi,
637
+ /compatible\s+with\s+([^.]+)/gi,
638
+ /connects?\s+to\s+([^.]+)/gi,
639
+ ];
640
+
641
+ const allText = content.paragraphs.join(' ');
642
+
643
+ for (const pattern of featurePatterns) {
644
+ const matches = allText.matchAll(pattern);
645
+ for (const match of matches) {
646
+ if (match[1] && match[1].length < 100) {
647
+ featureClaims.push(match[1].trim());
648
+ }
649
+ }
650
+ }
651
+
652
+ return featureClaims;
653
+ }
654
+
655
+ /**
656
+ * Truncate string with ellipsis
657
+ */
658
+ function truncate(str: string, maxLength: number): string {
659
+ if (str.length <= maxLength) return str;
660
+ return str.slice(0, maxLength - 3) + '...';
661
+ }