oneie 1.2.5 → 1.3.1

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 (683) hide show
  1. package/.claude/.hookignore +67 -0
  2. package/.claude/agents/README.md +155 -0
  3. package/.claude/agents/advocacy-activation-manager.md +268 -0
  4. package/.claude/agents/advocacy-campaign-designer.md +246 -0
  5. package/.claude/agents/analyst.md +66 -0
  6. package/.claude/agents/architect.md +63 -0
  7. package/.claude/agents/bstp-token-strategist.md +401 -0
  8. package/.claude/agents/builder-agent.md +223 -0
  9. package/.claude/agents/builder.md +710 -0
  10. package/.claude/agents/bullstamp-community-builder.md +308 -0
  11. package/.claude/agents/bullstamp-marketing-orchestrator.md +240 -0
  12. package/.claude/agents/bulltilt-platform-growth.md +301 -0
  13. package/.claude/agents/company-bullstamp-character.md +321 -0
  14. package/.claude/agents/company-bullstamp-community.md +26 -0
  15. package/.claude/agents/company-bullstamp-marketing.md +26 -0
  16. package/.claude/agents/company-bullstamp-token.md +26 -0
  17. package/.claude/agents/company-bulltilt-growth.md +26 -0
  18. package/.claude/agents/content-bibliography-formatter.md +115 -0
  19. package/.claude/agents/content-calendar-planner.md +26 -0
  20. package/.claude/agents/content-chapter-formatter.md +58 -0
  21. package/.claude/agents/content-formatter.md +118 -0
  22. package/.claude/agents/content-image-formatter.md +107 -0
  23. package/.claude/agents/content-introduction-formatter.md +57 -0
  24. package/.claude/agents/content-multiplication-engine.md +240 -0
  25. package/.claude/agents/content-playbook-writer.md +26 -0
  26. package/.claude/agents/content-team-manager.md +201 -0
  27. package/.claude/agents/content-toc-formatter.md +94 -0
  28. package/.claude/agents/core-manager.md +161 -0
  29. package/.claude/agents/core-master.md +87 -0
  30. package/.claude/agents/cross-functional-manager.md +205 -0
  31. package/.claude/agents/crypto-airdrop-strategist.md +209 -0
  32. package/.claude/agents/crypto-analytics-educator.md +238 -0
  33. package/.claude/agents/crypto-community-analyst.md +26 -0
  34. package/.claude/agents/crypto-community-psychologist.md +194 -0
  35. package/.claude/agents/crypto-dex-optimization-expert.md +223 -0
  36. package/.claude/agents/crypto-dex-optimizer.md +26 -0
  37. package/.claude/agents/crypto-diamond-hands.md +26 -0
  38. package/.claude/agents/crypto-ecosystem-expansion-manager.md +239 -0
  39. package/.claude/agents/crypto-market-researcher.md +26 -0
  40. package/.claude/agents/crypto-marketing-orchestrator.md +208 -0
  41. package/.claude/agents/crypto-network-effect-amplifier.md +254 -0
  42. package/.claude/agents/crypto-optimization-analyst.md +239 -0
  43. package/.claude/agents/crypto-strategic-synthesizer.md +202 -0
  44. package/.claude/agents/crypto-team-manager.md +121 -0
  45. package/.claude/agents/crypto-token-analyst.md +26 -0
  46. package/.claude/agents/crypto-viral-content-creator.md +195 -0
  47. package/.claude/agents/crypto-wallet-identification-expert.md +215 -0
  48. package/.claude/agents/crypto-wallet-identifier.md +26 -0
  49. package/.claude/agents/customer-journey-designer.md +127 -0
  50. package/.claude/agents/customer-success-manager.md +227 -0
  51. package/.claude/agents/dev.md +57 -0
  52. package/.claude/agents/elevate-marketing-orchestrator.md +108 -0
  53. package/.claude/agents/engineering-architect.md +69 -0
  54. package/.claude/agents/engineering-business-analyst.md +220 -0
  55. package/.claude/agents/engineering-developer.md +69 -0
  56. package/.claude/agents/engineering-director.md +156 -0
  57. package/.claude/agents/engineering-product-manager.md +220 -0
  58. package/.claude/agents/engineering-product-owner.md +220 -0
  59. package/.claude/agents/engineering-project-coordinator.md +220 -0
  60. package/.claude/agents/engineering-quality-assurance.md +221 -0
  61. package/.claude/agents/engineering-team-manager.md +199 -0
  62. package/.claude/agents/engineering-user-experience.md +220 -0
  63. package/.claude/agents/framework-elevate-manager.md +26 -0
  64. package/.claude/agents/intelligence-team-manager.md +119 -0
  65. package/.claude/agents/lead-capture-expert.md +164 -0
  66. package/.claude/agents/lead-magnet-creator.md +151 -0
  67. package/.claude/agents/market-research-analyst.md +110 -0
  68. package/.claude/agents/marketing-brand-identity.md +60 -0
  69. package/.claude/agents/marketing-content-hooks.md +184 -0
  70. package/.claude/agents/marketing-content-multiplier.md +60 -0
  71. package/.claude/agents/marketing-content-poster.md +86 -0
  72. package/.claude/agents/marketing-customer-journey.md +60 -0
  73. package/.claude/agents/marketing-director.md +122 -0
  74. package/.claude/agents/marketing-engagement.md +60 -0
  75. package/.claude/agents/marketing-lead-capture.md +60 -0
  76. package/.claude/agents/marketing-lead-magnet.md +60 -0
  77. package/.claude/agents/marketing-network-effects.md +60 -0
  78. package/.claude/agents/marketing-nurture-campaigns.md +60 -0
  79. package/.claude/agents/marketing-share-optimizer.md +60 -0
  80. package/.claude/agents/marketing-team-manager.md +180 -0
  81. package/.claude/agents/marketing-viral-growth.md +195 -0
  82. package/.claude/agents/network-effect-analyst.md +286 -0
  83. package/.claude/agents/nurture-campaign-manager.md +229 -0
  84. package/.claude/agents/one-master.md +89 -0
  85. package/.claude/agents/one-orchestrator.md +136 -0
  86. package/.claude/agents/playbook-generator.md +237 -0
  87. package/.claude/agents/pm.md +60 -0
  88. package/.claude/agents/po.md +64 -0
  89. package/.claude/agents/qa.md +55 -0
  90. package/.claude/agents/research-foundation-analyst.md +26 -0
  91. package/.claude/agents/research-market-analyst.md +26 -0
  92. package/.claude/agents/research-team-manager.md +201 -0
  93. package/.claude/agents/sales-environment-optimizer.md +213 -0
  94. package/.claude/agents/sales-team-manager.md +119 -0
  95. package/.claude/agents/sales-upsell-strategist.md +26 -0
  96. package/.claude/agents/service-advocacy-campaigns.md +26 -0
  97. package/.claude/agents/service-advocacy-manager.md +26 -0
  98. package/.claude/agents/service-success-manager.md +26 -0
  99. package/.claude/agents/service-team-manager.md +119 -0
  100. package/.claude/agents/sm.md +46 -0
  101. package/.claude/agents/story-teller.md +182 -0
  102. package/.claude/agents/task-master.md +305 -0
  103. package/.claude/agents/the-bull-character-manager.md +314 -0
  104. package/.claude/agents/tools-playbook-generator.md +223 -0
  105. package/.claude/agents/upsell-strategist.md +214 -0
  106. package/.claude/agents/ux-expert.md +54 -0
  107. package/.claude/agents/viral-growth-orchestrator.md +216 -0
  108. package/.claude/claude-code-hooks.development.json +21 -0
  109. package/.claude/claude-code-hooks.json +238 -0
  110. package/.claude/claude-code-hooks.production.json +21 -0
  111. package/.claude/commands/agent.md +87 -0
  112. package/.claude/commands/analyst.md +70 -0
  113. package/.claude/commands/architect.md +67 -0
  114. package/.claude/commands/commander.md +78 -0
  115. package/.claude/commands/deploy.md +68 -0
  116. package/.claude/commands/dev.md +60 -0
  117. package/.claude/commands/mission.md +65 -0
  118. package/.claude/commands/one.md +155 -0
  119. package/.claude/commands/playbook.md +81 -0
  120. package/.claude/commands/pm.md +64 -0
  121. package/.claude/commands/po.md +68 -0
  122. package/.claude/commands/qa.md +59 -0
  123. package/.claude/commands/start.md +120 -0
  124. package/.claude/commands/story.md +68 -0
  125. package/.claude/commands/task.md +152 -0
  126. package/.claude/commands/taskmaster.md +85 -0
  127. package/.claude/commands/ux-expert.md +58 -0
  128. package/.claude/hook-bypass.json +32 -0
  129. package/.claude/one-hook.js +16 -0
  130. package/.claude/settings.local.json +54 -0
  131. package/.github/FUNDING.yaml +15 -0
  132. package/.github/ISSUE_TEMPLATE/bug_report.md +32 -0
  133. package/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
  134. package/.github/workflows/release.yaml +59 -0
  135. package/.mcp.json +48 -0
  136. package/.obsidian/app.json +10 -0
  137. package/.obsidian/appearance.json +1 -0
  138. package/.obsidian/community-plugins.json +17 -0
  139. package/.obsidian/core-plugins.json +31 -0
  140. package/.obsidian/hotkeys.json +11 -0
  141. package/.obsidian/plugins/copilot/data.json +335 -0
  142. package/.obsidian/plugins/copilot/main.js +1738 -0
  143. package/.obsidian/plugins/copilot/manifest.json +13 -0
  144. package/.obsidian/plugins/copilot/styles.css +1 -0
  145. package/.obsidian/plugins/easy-bake/main.js +361 -0
  146. package/.obsidian/plugins/easy-bake/manifest.json +11 -0
  147. package/.obsidian/plugins/easy-bake/styles.css +10 -0
  148. package/.obsidian/plugins/editing-toolbar/data.json +328 -0
  149. package/.obsidian/plugins/editing-toolbar/main.js +12 -0
  150. package/.obsidian/plugins/editing-toolbar/manifest.json +10 -0
  151. package/.obsidian/plugins/editing-toolbar/styles.css +1338 -0
  152. package/.obsidian/plugins/obsidian-enhancing-export/data.json +60 -0
  153. package/.obsidian/plugins/obsidian-enhancing-export/lua/citefilter.lua +6 -0
  154. package/.obsidian/plugins/obsidian-enhancing-export/lua/markdown+hugo.lua +5 -0
  155. package/.obsidian/plugins/obsidian-enhancing-export/lua/markdown.lua +237 -0
  156. package/.obsidian/plugins/obsidian-enhancing-export/lua/math_block.lua +68 -0
  157. package/.obsidian/plugins/obsidian-enhancing-export/lua/pdf.lua +12 -0
  158. package/.obsidian/plugins/obsidian-enhancing-export/lua/polyfill.lua +61 -0
  159. package/.obsidian/plugins/obsidian-enhancing-export/lua/url.lua +18 -0
  160. package/.obsidian/plugins/obsidian-enhancing-export/main.js +32 -0
  161. package/.obsidian/plugins/obsidian-enhancing-export/manifest.json +10 -0
  162. package/.obsidian/plugins/obsidian-enhancing-export/styles.css +1 -0
  163. package/.obsidian/plugins/obsidian-enhancing-export/textemplate/dissertation.tex +1210 -0
  164. package/.obsidian/plugins/obsidian-enhancing-export/textemplate/neurips.sty +373 -0
  165. package/.obsidian/plugins/obsidian-enhancing-export/textemplate/neurips.tex +187 -0
  166. package/.obsidian/plugins/obsidian-git/data.json +61 -0
  167. package/.obsidian/plugins/obsidian-git/obsidian_askpass.sh +23 -0
  168. package/.obsidian/plugins/terminal/data.json +147 -0
  169. package/.obsidian/plugins/terminal/main.js +192 -0
  170. package/.obsidian/plugins/terminal/manifest.json +14 -0
  171. package/.obsidian/plugins/terminal/styles.css +32 -0
  172. package/.one/agents/content-calendar-planner.md +307 -0
  173. package/.one/agents/crypto-airdrop-strategist.md +224 -0
  174. package/.one/agents/crypto-analytics-educator.md +257 -0
  175. package/.one/agents/crypto-community-psychologist.md +207 -0
  176. package/.one/agents/crypto-dex-optimization-expert.md +240 -0
  177. package/.one/agents/crypto-ecosystem-expansion-manager.md +258 -0
  178. package/.one/agents/crypto-market-researcher.md +190 -0
  179. package/.one/agents/crypto-marketing-orchestrator.md +224 -0
  180. package/.one/agents/crypto-network-effect-amplifier.md +275 -0
  181. package/.one/agents/crypto-optimization-analyst.md +258 -0
  182. package/.one/agents/crypto-strategic-synthesizer.md +217 -0
  183. package/.one/agents/crypto-token-analyst.md +183 -0
  184. package/.one/agents/crypto-viral-content-creator.md +208 -0
  185. package/.one/agents/crypto-wallet-identification-expert.md +231 -0
  186. package/.one/agents/engineering-director.md +89 -0
  187. package/.one/agents/marketing-content-poster.md +88 -0
  188. package/.one/agents/sales-environment-optimizer.md +213 -0
  189. package/.one/checklists/agent-quality-checklist.md +293 -0
  190. package/.one/checklists/architect-checklist.md +443 -0
  191. package/.one/checklists/attract-campaign-checklist.md +444 -0
  192. package/.one/checklists/brand-alignment-checklist.md +191 -0
  193. package/.one/checklists/brand-consistency-checklist.md +378 -0
  194. package/.one/checklists/change-checklist.md +182 -0
  195. package/.one/checklists/channel-coordination-checklist.md +217 -0
  196. package/.one/checklists/content-calendar-checklist.md +190 -0
  197. package/.one/checklists/convert-campaign-checklist.md +426 -0
  198. package/.one/checklists/crypto-ai-influencer-consistency.md +221 -0
  199. package/.one/checklists/crypto-diamond-formation-quality.md +285 -0
  200. package/.one/checklists/crypto-rocket-framework-validation.md +244 -0
  201. package/.one/checklists/done-checklist.md +103 -0
  202. package/.one/checklists/foundation-completeness-checklist.md +222 -0
  203. package/.one/checklists/grow-campaign-checklist.md +380 -0
  204. package/.one/checklists/idea-quality-checklist.md +225 -0
  205. package/.one/checklists/parallel-mission-quality-checklist.md +243 -0
  206. package/.one/checklists/pm-checklist.md +375 -0
  207. package/.one/checklists/po-master-checklist.md +441 -0
  208. package/.one/checklists/product-checklist.md +375 -0
  209. package/.one/checklists/professional-grade-checklist.md +127 -0
  210. package/.one/checklists/story-as-idea-quality-checklist.md +246 -0
  211. package/.one/checklists/story-dod-checklist.md +101 -0
  212. package/.one/checklists/story-draft-checklist.md +130 -0
  213. package/.one/checklists/story-quality-checklist.md +266 -0
  214. package/.one/checklists/strategic-framework-checklist.md +182 -0
  215. package/.one/checklists/task-quality-checklist.md +287 -0
  216. package/.one/hooks/file-organization-monitor.js +196 -0
  217. package/.one/infrastructure/README.md +43 -0
  218. package/.one/infrastructure/platform-validator.js +161 -0
  219. package/.one/infrastructure/validate-platform.sh +133 -0
  220. package/.one/interface.md +63 -0
  221. package/.one/one-command.js +43 -0
  222. package/.one/ontology/ontology.yaml +501 -0
  223. package/.one/stories/bullstamp-attract-module-complete.md +255 -0
  224. package/.one/stories/bullstamp-deployment-master-plan.md +518 -0
  225. package/.one/stories/bullstamp-executive-implementation-summary.md +254 -0
  226. package/.one/stories/bullstamp-project-status-complete.md +257 -0
  227. package/.one/stories/obsidian-pandoc-config.md +159 -0
  228. package/.one/stories/story-1.1-perfect-filesystem-organization.md +270 -0
  229. package/.one/stories/story-1.1.1.md +136 -0
  230. package/.one/stories/story-1.1.md +131 -0
  231. package/.one/stories/story-1.2.md +420 -0
  232. package/.one/stories/story-1.3.md +177 -0
  233. package/.one/stories/story-1.4.md +356 -0
  234. package/.one/stories/story-1.5.md +572 -0
  235. package/.one/stories/story-1.6.md +481 -0
  236. package/.one/stories/story-1.7.md +923 -0
  237. package/.one/stories/story-1.8.md +404 -0
  238. package/.one/stories/story-2.0.md +132 -0
  239. package/.one/stories/story-2.1.md +110 -0
  240. package/.one/stories/story-2.2.md +110 -0
  241. package/.one/stories/story-2.3.md +112 -0
  242. package/.one/stories/story-2.4.md +116 -0
  243. package/.one/stories/story-2.5.md +114 -0
  244. package/.one/stories/story-3.1.md +298 -0
  245. package/.one/stories/story-3.10.md +302 -0
  246. package/.one/stories/story-3.11.md +167 -0
  247. package/.one/stories/story-3.12.md +235 -0
  248. package/.one/stories/story-3.13.md +235 -0
  249. package/.one/stories/story-3.14.md +225 -0
  250. package/.one/stories/story-3.15.md +238 -0
  251. package/.one/stories/story-3.16.md +244 -0
  252. package/.one/stories/story-3.17.md +245 -0
  253. package/.one/stories/story-3.18.md +248 -0
  254. package/.one/stories/story-3.2.md +226 -0
  255. package/.one/stories/story-3.3.md +226 -0
  256. package/.one/stories/story-3.4.md +226 -0
  257. package/.one/stories/story-3.5.md +167 -0
  258. package/.one/stories/story-3.6.md +167 -0
  259. package/.one/stories/story-3.7.md +181 -0
  260. package/.one/stories/story-3.8.md +198 -0
  261. package/.one/stories/story-3.9.md +169 -0
  262. package/.one/stories/story-4.1.md +245 -0
  263. package/.one/stories/story-4.2.md +314 -0
  264. package/.one/stories/story-4.3.md +610 -0
  265. package/.one/stories/story-4.4.md +931 -0
  266. package/.one/stories/story-4.5.md +727 -0
  267. package/.one/stories/story-4.6-consistency.md +175 -0
  268. package/.one/stories/story-5.1.md +508 -0
  269. package/.one/stories/story-5.2.md +451 -0
  270. package/.one/stories/story-5.3.md +405 -0
  271. package/.one/stories/story-5.4.md +447 -0
  272. package/.one/stories/story-5.5.md +349 -0
  273. package/.one/stories/story-5.6.md +445 -0
  274. package/.one/stories/story-6.1-text-content-engine.md +144 -0
  275. package/.one/stories/story-6.2-audio-content-engine.md +145 -0
  276. package/.one/stories/story-6.3-video-content-engine.md +145 -0
  277. package/.one/stories/story-6.4-visual-content-engine.md +177 -0
  278. package/.one/stories/story-6.5-cross-platform-distribution.md +188 -0
  279. package/.one/stories/story-6.6.ai-content-generation-pipeline.md +196 -0
  280. package/.one/stories/story-6.7-character-consistency-quality-control.md +216 -0
  281. package/.one/stories/story-6.8-claude-code-content-integration.md +181 -0
  282. package/.one/stories/story-6.8-content-production-workflows.md +247 -0
  283. package/.one/stories/story-7.1-implementation.md +128 -0
  284. package/.one/stories/story-7.1.md +203 -0
  285. package/.one/stories/story-7.2-implementation.md +147 -0
  286. package/.one/stories/story-7.2.md +415 -0
  287. package/.one/stories/story-7.3-implementation.md +159 -0
  288. package/.one/stories/story-7.3.md +463 -0
  289. package/.one/stories/story-7.4-implementation.md +154 -0
  290. package/.one/stories/story-7.4.md +500 -0
  291. package/.one/stories/story-validation-report.md +169 -0
  292. package/.one/structure.yaml +135 -0
  293. package/.one/tasks/advanced-elicitation.md +119 -0
  294. package/.one/tasks/advocacy-system-design.md +1065 -0
  295. package/.one/tasks/brownfield-create-mission.md +160 -0
  296. package/.one/tasks/brownfield-create-story.md +147 -0
  297. package/.one/tasks/bull-character-content-calendar.md +241 -0
  298. package/.one/tasks/bullstamp-foundation-synthesis.md +204 -0
  299. package/.one/tasks/capture-page-optimization.md +623 -0
  300. package/.one/tasks/cascade-task-spawning.md +178 -0
  301. package/.one/tasks/company-context-workshop.md +228 -0
  302. package/.one/tasks/conflict-prevention-orchestration.md +133 -0
  303. package/.one/tasks/correct-course.md +73 -0
  304. package/.one/tasks/create-brownfield-story.md +376 -0
  305. package/.one/tasks/create-deep-research-prompt.md +301 -0
  306. package/.one/tasks/create-doc 1.md +79 -0
  307. package/.one/tasks/create-doc.md +79 -0
  308. package/.one/tasks/create-mission-brief.md +94 -0
  309. package/.one/tasks/create-next-story.md +113 -0
  310. package/.one/tasks/create-workflow-plan.md +299 -0
  311. package/.one/tasks/crypto-bookwriter-enhancement.md +193 -0
  312. package/.one/tasks/crypto-chapter-content-creation.md +278 -0
  313. package/.one/tasks/crypto-foundation-development.md +155 -0
  314. package/.one/tasks/crypto-multi-format-publishing.md +286 -0
  315. package/.one/tasks/crypto-quality-validation.md +225 -0
  316. package/.one/tasks/customer-avatar-development.md +353 -0
  317. package/.one/tasks/customer-success-program.md +984 -0
  318. package/.one/tasks/doc-migration-task.md +151 -0
  319. package/.one/tasks/document-project.md +350 -0
  320. package/.one/tasks/engagement-sequence-design.md +846 -0
  321. package/.one/tasks/execute-checklist 1.md +93 -0
  322. package/.one/tasks/execute-checklist.md +93 -0
  323. package/.one/tasks/facilitate-brainstorming-session.md +136 -0
  324. package/.one/tasks/foundation-analysis.md +149 -0
  325. package/.one/tasks/generate-ai-frontend-prompt.md +51 -0
  326. package/.one/tasks/hook-content-creation.md +555 -0
  327. package/.one/tasks/index-docs.md +178 -0
  328. package/.one/tasks/kb-mode-interaction.md +77 -0
  329. package/.one/tasks/lead-magnet-development.md +479 -0
  330. package/.one/tasks/market-intelligence-research.md +255 -0
  331. package/.one/tasks/nurture-campaign-creation.md +781 -0
  332. package/.one/tasks/parallel-task-decomposition.md +74 -0
  333. package/.one/tasks/review-story.md +164 -0
  334. package/.one/tasks/sales-environment-audit.md +806 -0
  335. package/.one/tasks/shard-doc.md +191 -0
  336. package/.one/tasks/story-qualtiy.md +225 -0
  337. package/.one/tasks/strategic-alignment-synthesis.md +414 -0
  338. package/.one/tasks/task-quality.md +232 -0
  339. package/.one/tasks/update-workflow-plan.md +252 -0
  340. package/.one/tasks/upsell-strategy-development.md +1139 -0
  341. package/.one/tasks/validate-next-story.md +134 -0
  342. package/.one/teams/team-all.yaml +14 -0
  343. package/.one/teams/team-bullstamp.yaml +12 -0
  344. package/.one/teams/team-crypto-marketing.yaml +56 -0
  345. package/.one/teams/team-fullstack.yaml +18 -0
  346. package/.one/teams/team-ide-minimal.yaml +10 -0
  347. package/.one/teams/team-marketing.yaml +21 -0
  348. package/.one/teams/team-no-ui.yaml +13 -0
  349. package/.one/templates/advocacy-campaign-blueprint-tmpl.yaml +1400 -0
  350. package/.one/templates/ai-influencer-methodology.yaml +299 -0
  351. package/.one/templates/architecture-tmpl.yaml +650 -0
  352. package/.one/templates/brainstorming-output-tmpl.yaml +156 -0
  353. package/.one/templates/brownfield-architecture-tmpl.yaml +476 -0
  354. package/.one/templates/brownfield-prd-tmpl.yaml +280 -0
  355. package/.one/templates/bullstamp-playbook-config.yaml +251 -0
  356. package/.one/templates/capture-page-template-tmpl.yaml +1498 -0
  357. package/.one/templates/channel-content-framework-tmpl.yaml +289 -0
  358. package/.one/templates/cli-app-package-template.json +47 -0
  359. package/.one/templates/company-foundation-brief-tmpl.yaml +782 -0
  360. package/.one/templates/competitor-analysis-tmpl.yaml +293 -0
  361. package/.one/templates/content-theme-planning-tmpl.yaml +319 -0
  362. package/.one/templates/crypto-chapter-structure.yaml +331 -0
  363. package/.one/templates/customer-avatar-profile-tmpl.yaml +1055 -0
  364. package/.one/templates/customer-success-program-tmpl.yaml +1360 -0
  365. package/.one/templates/daily-content-calendar-tmpl.yaml +169 -0
  366. package/.one/templates/diamond-formation-protocol.yaml +293 -0
  367. package/.one/templates/doc-template.md +325 -0
  368. package/.one/templates/engagement-sequence-plan-tmpl.yaml +2126 -0
  369. package/.one/templates/front-end-architecture-tmpl.yaml +206 -0
  370. package/.one/templates/fullstack-architecture-tmpl.yaml +805 -0
  371. package/.one/templates/hook-content-framework-tmpl.yaml +1409 -0
  372. package/.one/templates/lead-magnet-blueprint-tmpl.yaml +1051 -0
  373. package/.one/templates/market-analysis-report-tmpl.yaml +1052 -0
  374. package/.one/templates/market-research-tmpl.yaml +252 -0
  375. package/.one/templates/mission-tmpl.yaml +103 -0
  376. package/.one/templates/monthly-strategy-calendar-tmpl.yaml +302 -0
  377. package/.one/templates/nurture-campaign-architecture-tmpl.yaml +1202 -0
  378. package/.one/templates/prd-tmpl.yaml +202 -0
  379. package/.one/templates/project-brief-tmpl.yaml +221 -0
  380. package/.one/templates/repository-template-architecture.yaml +556 -0
  381. package/.one/templates/root-package-template.json +79 -0
  382. package/.one/templates/sales-optimization-audit-tmpl.yaml +1094 -0
  383. package/.one/templates/setup-one-system-template.js +341 -0
  384. package/.one/templates/story-rocket-tmpl.yaml +244 -0
  385. package/.one/templates/story-tmpl.yaml +153 -0
  386. package/.one/templates/strategic-alignment-blueprint-tmpl.yaml +752 -0
  387. package/.one/templates/turbo-config-template.json +73 -0
  388. package/.one/templates/turbo-monorepo-template.yaml +260 -0
  389. package/.one/templates/typescript-config-template.json +51 -0
  390. package/.one/templates/ui-package-template.json +66 -0
  391. package/.one/templates/upsell-strategy-framework-tmpl.yaml +1274 -0
  392. package/.one/templates/web-app-package-template.json +39 -0
  393. package/.one/templates/weekly-campaign-calendar-tmpl.yaml +277 -0
  394. package/.one/tools/README-bull-character-formats.md +272 -0
  395. package/.one/tools/bin/one-agent.js +25 -0
  396. package/.one/tools/bin/one-mission.js +25 -0
  397. package/.one/tools/bin/one-playbook.js +25 -0
  398. package/.one/tools/bin/one-story.js +25 -0
  399. package/.one/tools/bin/one-team.js +25 -0
  400. package/.one/tools/bin/one-tools.js +25 -0
  401. package/.one/tools/builders/web-builder.js +681 -0
  402. package/.one/tools/bull-character-complete-pdf.py +534 -0
  403. package/.one/tools/bull-character-docx-epub.py +245 -0
  404. package/.one/tools/bull-character-master-pdf.py +521 -0
  405. package/.one/tools/bull-character-multi-format.py +340 -0
  406. package/.one/tools/bump-all-versions.js +107 -0
  407. package/.one/tools/bump-core-version.js +57 -0
  408. package/.one/tools/bump-expansion-version.js +78 -0
  409. package/.one/tools/calendar-management.md +281 -0
  410. package/.one/tools/claude-one-command.md +36 -0
  411. package/{one → .one}/tools/cli.js +33 -332
  412. package/.one/tools/code-generators.js +1110 -0
  413. package/.one/tools/community/claudelog-pattern-analyzer.js +515 -0
  414. package/.one/tools/community/claudelog-pattern-library.json +370 -0
  415. package/.one/tools/community/community-validation-loops.js +872 -0
  416. package/.one/tools/community/plan-mode-orchestrator.js +848 -0
  417. package/.one/tools/community/terminal-native-integration.js +659 -0
  418. package/.one/tools/consciousness/system-consciousness-engine.js +684 -0
  419. package/.one/tools/content/claude-code-content-generator.js +474 -0
  420. package/.one/tools/content/one-content-command.js +289 -0
  421. package/.one/tools/context/quantum-context-engine.js +704 -0
  422. package/.one/tools/convert-wav-to-mp3.js +195 -0
  423. package/.one/tools/convert_book.py +331 -0
  424. package/.one/tools/coordination/agent-mesh-networks.js +851 -0
  425. package/.one/tools/debug/debug-naming.mjs +7 -0
  426. package/.one/tools/debug/debug-rules.mjs +6 -0
  427. package/.one/tools/demo/bull-content-engine-demo.js +273 -0
  428. package/.one/tools/demo/claude-code-integration-demo.js +222 -0
  429. package/.one/tools/demo/live-demo.js +285 -0
  430. package/.one/tools/demo/showcase-demo.js +302 -0
  431. package/.one/tools/demo/simple-bull-demo.js +186 -0
  432. package/.one/tools/enhanced-pdf-converter.py +449 -0
  433. package/.one/tools/foundation-wizard.js +331 -0
  434. package/.one/tools/frictionless-installer.js +230 -0
  435. package/.one/tools/generate-toc.js +113 -0
  436. package/.one/tools/hooks/claude-code-hooks-validation-pattern.md +211 -0
  437. package/.one/tools/html_to_pdf.py +178 -0
  438. package/.one/tools/installer/README.md +8 -0
  439. package/.one/tools/installer/bin/one.js +438 -0
  440. package/.one/tools/installer/config/ide-agent-config.yaml +58 -0
  441. package/.one/tools/installer/config/install.config.yaml +92 -0
  442. package/.one/tools/installer/lib/config-loader.js +253 -0
  443. package/.one/tools/installer/lib/file-manager.js +379 -0
  444. package/.one/tools/installer/lib/ide-setup.js +829 -0
  445. package/.one/tools/installer/lib/installer.js +1764 -0
  446. package/.one/tools/installer/package-lock.json +906 -0
  447. package/.one/tools/installer/package.json +43 -0
  448. package/.one/tools/intelligence/mission-intelligence-engine.js +955 -0
  449. package/.one/tools/md-assets/web-agent-startup-instructions.md +39 -0
  450. package/.one/tools/merge-bull-pdfs.py +127 -0
  451. package/.one/tools/minimal-generators.js +714 -0
  452. package/.one/tools/npx.js +41 -0
  453. package/.one/tools/package-bull-character.py +238 -0
  454. package/.one/tools/pdf-merger.py +94 -0
  455. package/.one/tools/performance/context-sharing-optimizer.js +584 -0
  456. package/.one/tools/performance/coordination-latency-optimizer.js +617 -0
  457. package/.one/tools/performance/intelligent-caching-system.js +683 -0
  458. package/.one/tools/performance/parallel-execution-optimizer.js +524 -0
  459. package/.one/tools/performance/performance-benchmark.js +743 -0
  460. package/.one/tools/performance/performance-optimization-summary.md +264 -0
  461. package/.one/tools/performance/resource-usage-optimizer.js +634 -0
  462. package/.one/tools/pilot-community-launch.js +487 -0
  463. package/.one/tools/playbook-generator/PRODUCTION-SUMMARY.md +138 -0
  464. package/.one/tools/playbook-generator/README.md +314 -0
  465. package/.one/tools/playbook-generator/apple-book-style.css +129 -0
  466. package/.one/tools/playbook-generator/bin/analyze-folder.js +259 -0
  467. package/.one/tools/playbook-generator/bin/contents-based-generator.js +116 -0
  468. package/.one/tools/playbook-generator/bin/debug-generator.js +74 -0
  469. package/.one/tools/playbook-generator/bin/generate-books.js +308 -0
  470. package/.one/tools/playbook-generator/bin/generate-chapters.js +74 -0
  471. package/.one/tools/playbook-generator/bin/generate-clean.js +281 -0
  472. package/.one/tools/playbook-generator/bin/generate-contents.js +287 -0
  473. package/.one/tools/playbook-generator/bin/playbook-gen +322 -0
  474. package/.one/tools/playbook-generator/bin/playbook-gen.js +279 -0
  475. package/.one/tools/playbook-generator/book-generation-system.md +363 -0
  476. package/.one/tools/playbook-generator/commands/contents.js +198 -0
  477. package/.one/tools/playbook-generator/commands/generate-chapters.js +216 -0
  478. package/.one/tools/playbook-generator/commands/generate-complete-package.js +93 -0
  479. package/.one/tools/playbook-generator/commands/generate-from-chapters.js +49 -0
  480. package/.one/tools/playbook-generator/commands/generate.js +275 -0
  481. package/.one/tools/playbook-generator/docs/API.md +579 -0
  482. package/.one/tools/playbook-generator/docs/MIGRATION.md +404 -0
  483. package/.one/tools/playbook-generator/docs/README.md +502 -0
  484. package/.one/tools/playbook-generator/index.js +102 -0
  485. package/.one/tools/playbook-generator/install.sh +107 -0
  486. package/.one/tools/playbook-generator/lib/apple-book-generator.js +552 -0
  487. package/.one/tools/playbook-generator/lib/book-generator.js +414 -0
  488. package/.one/tools/playbook-generator/lib/chapters-generator.js +292 -0
  489. package/.one/tools/playbook-generator/lib/contents-generator.js +465 -0
  490. package/.one/tools/playbook-generator/lib/cover-integrator.js +373 -0
  491. package/.one/tools/playbook-generator/lib/errors.js +198 -0
  492. package/.one/tools/playbook-generator/lib/flat-generator.js +998 -0
  493. package/.one/tools/playbook-generator/lib/folder-analyzer.js +429 -0
  494. package/.one/tools/playbook-generator/lib/generator.js +1268 -0
  495. package/.one/tools/playbook-generator/lib/manager.js +322 -0
  496. package/.one/tools/playbook-generator/lib/pdf-cover-generator.js +145 -0
  497. package/.one/tools/playbook-generator/lib/processor.js +816 -0
  498. package/.one/tools/playbook-generator/lib/security.js +199 -0
  499. package/.one/tools/playbook-generator/lib/utils.js +173 -0
  500. package/.one/tools/playbook-generator/lib/wizard.js +448 -0
  501. package/.one/tools/playbook-generator/package.json +51 -0
  502. package/.one/tools/playbook-generator/templates/apple-book.tex +249 -0
  503. package/.one/tools/playbook-generator/templates/beautiful-book.tex +136 -0
  504. package/.one/tools/playbook-generator/templates/book-config-template.yaml +24 -0
  505. package/.one/tools/playbook-generator/templates/industry-template-structure.md +156 -0
  506. package/.one/tools/playbook-generator/templates/universal-book.tex +157 -0
  507. package/.one/tools/premium-manager.js +371 -0
  508. package/.one/tools/professional-community-manager.js +505 -0
  509. package/.one/tools/quality/emergent-quality-systems.js +743 -0
  510. package/.one/tools/scripts/setup-bull-engine.sh +321 -0
  511. package/.one/tools/semantic-release-sync-installer.js +31 -0
  512. package/.one/tools/simple-pdf-merge.py +48 -0
  513. package/.one/tools/simple_convert.py +381 -0
  514. package/.one/tools/spiral-automation/README.md +204 -0
  515. package/.one/tools/spiral-automation/agents/customer-intelligence-agent.js +887 -0
  516. package/.one/tools/spiral-automation/agents/foundation-synthesizer.js +731 -0
  517. package/.one/tools/spiral-automation/agents/market-research-agent.js +915 -0
  518. package/.one/tools/spiral-automation/agents/web-scraper-agent.js +759 -0
  519. package/.one/tools/spiral-automation/cli.js +183 -0
  520. package/.one/tools/spiral-automation/dashboard/analytics-visualizer.js +780 -0
  521. package/.one/tools/spiral-automation/dashboard/dashboard-orchestrator.js +582 -0
  522. package/.one/tools/spiral-automation/dashboard/progress-dashboard.js +425 -0
  523. package/.one/tools/spiral-automation/dashboard/progress-tracker.js +576 -0
  524. package/.one/tools/spiral-automation/engine/spiral-automation-engine.js +1016 -0
  525. package/.one/tools/spiral-automation/spiral-demo.js +483 -0
  526. package/.one/tools/spiral-automation/templates/game-levels.yaml +903 -0
  527. package/.one/tools/story-writer.sh +13 -0
  528. package/.one/tools/sync-installer-version.js +34 -0
  529. package/.one/tools/templates/apple-book-parts.css +367 -0
  530. package/.one/tools/templates/apple-book-parts.tex +180 -0
  531. package/.one/tools/templates/apple-book-simple.tex +144 -0
  532. package/.one/tools/templates/apple-book.css +390 -0
  533. package/.one/tools/templates/apple-book.tex +207 -0
  534. package/.one/tools/templates/enhanced-epub.css +231 -0
  535. package/.one/tools/templates/universal-book.tex +240 -0
  536. package/.one/tools/text-to-speech.js +343 -0
  537. package/.one/tools/transformative-ai-engine.js +805 -0
  538. package/.one/tools/update-expansion-version.js +54 -0
  539. package/.one/tools/upgraders/v3-to-v4-upgrader.js +763 -0
  540. package/.one/tools/version-bump.js +79 -0
  541. package/.one/tools/viral-growth/analytics-dashboard.js +934 -0
  542. package/.one/tools/viral-growth/cli.js +459 -0
  543. package/.one/tools/viral-growth/content-multiplier.js +349 -0
  544. package/.one/tools/viral-growth/scientific-validation.js +1010 -0
  545. package/.one/tools/yaml-format.js +240 -0
  546. package/.one/workflows/bullfm.yaml +303 -0
  547. package/.one/workflows/cascade-coordination.yaml +382 -0
  548. package/.one/workflows/cascade-orchestration-system.yaml +417 -0
  549. package/.one/workflows/cascade-story-spawning-protocol.yaml +104 -0
  550. package/.one/workflows/cascade-system-technical-implementation.md +329 -0
  551. package/.one/workflows/cascade-workflow-implementation.yaml +456 -0
  552. package/.one/workflows/concurrent-task-orchestration-system.yaml +375 -0
  553. package/.one/workflows/content-engine.yaml +340 -0
  554. package/.one/workflows/continuous-validation-system.yaml +322 -0
  555. package/.one/workflows/coordination.yaml +437 -0
  556. package/.one/workflows/crypto-chapter-enhancement-workflow.yaml +163 -0
  557. package/.one/workflows/crypto-playbook-generation.yaml +158 -0
  558. package/.one/workflows/design.yaml +197 -0
  559. package/.one/workflows/developer-experience-optimization.yaml +283 -0
  560. package/.one/workflows/diamond-formation-implementation.yaml +189 -0
  561. package/.one/workflows/dynamic-personalization-matrix.yaml +197 -0
  562. package/.one/workflows/elastic-agent-pool-management.yaml +344 -0
  563. package/.one/workflows/elevate-brownfield-workflow.yaml +372 -0
  564. package/.one/workflows/elevate-greenfield-workflow.yaml +211 -0
  565. package/.one/workflows/engineering.yaml +431 -0
  566. package/.one/workflows/enhance-service.yaml +187 -0
  567. package/.one/workflows/enter-existing.yaml +297 -0
  568. package/.one/workflows/foundation-workflow.yaml +192 -0
  569. package/.one/workflows/greenfield-fullstack.yaml +240 -0
  570. package/.one/workflows/greenfield-service.yaml +206 -0
  571. package/.one/workflows/greenfield-ui.yaml +235 -0
  572. package/.one/workflows/mission-to-story-spawning.yaml +207 -0
  573. package/.one/workflows/parallel-cascade-architecture.yaml +460 -0
  574. package/.one/workflows/parallel-cascade-orchestration.yaml +516 -0
  575. package/.one/workflows/parallel-deployment-system.yaml +363 -0
  576. package/.one/workflows/parallel-story-orchestration.yaml +359 -0
  577. package/.one/workflows/quality-gate-integration-strategy.yaml +431 -0
  578. package/.one/workflows/story-4-viral-narrative-workflow.yaml +368 -0
  579. package/.one/workflows/story-to-mission-spawning-engine.yaml +364 -0
  580. package/.one/workflows/story-to-task-decomposition.yaml +226 -0
  581. package/.one/workflows/task-to-agent-assignment.yaml +247 -0
  582. package/.one/workflows/workflow-engineering.md +283 -0
  583. package/.one/workflows/workflow-marketing.md +265 -0
  584. package/.one/workflows/working-in-the-brownfield.md +361 -0
  585. package/.prettierignore +21 -0
  586. package/.prettierrc +23 -0
  587. package/.releaserc.json +18 -0
  588. package/.repomixignore +102 -0
  589. package/.vscode/settings.json +50 -0
  590. package/CLAUDE.md +568 -0
  591. package/CLI-UPGRADE.md +266 -0
  592. package/CONTRIBUTING.md +323 -0
  593. package/INSTALL.md +151 -0
  594. package/README.md +291 -315
  595. package/bin/create-turbo.js +816 -0
  596. package/bin/install.js +354 -0
  597. package/bin/oneie/index.js +264 -0
  598. package/one/archive-index.json +91 -0
  599. package/one/data/spiral-ontology.md +461 -0
  600. package/one/manifest.md +143 -0
  601. package/one/me/me.md +52 -0
  602. package/one/ontology.md +482 -0
  603. package/one/plan.md +400 -0
  604. package/one/prompts/-SystemPrompt.md +121 -0
  605. package/one/prompts/BookChapterStructure.md +181 -0
  606. package/one/prompts/BookRewriter.md +106 -0
  607. package/one/prompts/Company 1.md +225 -0
  608. package/one/prompts/Company.md +188 -0
  609. package/one/prompts/Customer.md +96 -0
  610. package/one/prompts/CustomerDeepResearch.md +86 -0
  611. package/one/prompts/DeepResearch.md +96 -0
  612. package/one/prompts/Educate.md +100 -0
  613. package/one/prompts/Engage - Copywriter.md +72 -0
  614. package/one/prompts/Engage - Pages.md +125 -0
  615. package/one/prompts/Engage.md +76 -0
  616. package/one/prompts/Foundation.md +132 -0
  617. package/one/prompts/Gift.md +173 -0
  618. package/one/prompts/Identify.md +97 -0
  619. package/one/prompts/Market.md +96 -0
  620. package/one/prompts/MarketDeepResearch.md +175 -0
  621. package/one/prompts/Nurture.md +130 -0
  622. package/one/prompts/Optimize.md +134 -0
  623. package/one/prompts/Prompts.md +167 -0
  624. package/one/prompts/Sell.md +101 -0
  625. package/one/prompts/SellPrompts.md +184 -0
  626. package/one/prompts/Share.md +143 -0
  627. package/one/prompts/Stop.md +214 -0
  628. package/one/prompts/StopElements.md +131 -0
  629. package/one/prompts/Upsell.md +95 -0
  630. package/one/prompts/business.md +1 -0
  631. package/one/prompts/content-playbook-writer-prompts.md +250 -0
  632. package/one/prompts/system.md +418 -0
  633. package/one/stories/story-1.1-structure.md +181 -0
  634. package/one/stories/story-1.1-validation.md +125 -0
  635. package/one/stories/story-1.1-value-proposition.md +19 -0
  636. package/one/stories/story-1.2-claude-directory-organization.md +130 -0
  637. package/one/stories/story-1.3-one-directory.md +252 -0
  638. package/one/stories/story-1.4-one-directory-user-workspace-optimization.md +240 -0
  639. package/one/stories/story-1.5-archive-strategy-implementation.md +199 -0
  640. package/one/stories/story-1.6-validation-documentation.md +239 -0
  641. package/one/stories/story-1.7-claude-code-integration-documentation.md +141 -0
  642. package/one/stories/story-1.8-mission-ascii-structure-enhancement.md +172 -0
  643. package/one/stories/story-1.9-cascade-coordination-infrastructure.md +325 -0
  644. package/one/stories/story-1.9-ontology-file-harmony-documentation.md +221 -0
  645. package/one/stories/story-2.0-builder-agent-design.md +280 -0
  646. package/one/stories/story-2.1-builder-agent-design.md +190 -0
  647. package/one/stories/story-2.1-core-tech-stack-subagents.md +247 -0
  648. package/one/stories/story-2.1.2-repository-template-architecture.md +370 -0
  649. package/one/stories/story-2.1.3-multi-platform-deployment-patterns.md +550 -0
  650. package/one/stories/story-2.1.4-trinity-integration-validation.md +492 -0
  651. package/one/stories/story-2.2-repository-generation-engine.md +347 -0
  652. package/one/stories/story-2.2.1-core-generation-engine.md +262 -0
  653. package/one/stories/story-2.2.2-npx-package-infrastructure.md +372 -0
  654. package/one/stories/story-2.2.3-template-system-integration.md +519 -0
  655. package/one/stories/story-2.2.4-production-validation-deployment.md +609 -0
  656. package/one/stories/story-3.1-npx-oneie-turbo-enhancement.md +327 -0
  657. package/one/stories/story-3.2-npx-connection-implementation.md +312 -0
  658. package/one/structure.yaml +158 -0
  659. package/one/tools/claude-one-command.md +36 -0
  660. package/one.md +36 -0
  661. package/package.json +6 -7
  662. package/LICENSE +0 -21
  663. package/bin/agent-integration.js +0 -499
  664. package/bin/cli-animations.js +0 -420
  665. package/bin/collaborative-install.js +0 -471
  666. package/bin/mission-system.js +0 -612
  667. package/bin/one-installer.js +0 -776
  668. package/bin/oneie.js +0 -496
  669. package/bin/story-system.js +0 -478
  670. package/bin/task-system.js +0 -717
  671. package/bin/template-generator.js +0 -661
  672. package/one/tools/agent-installer.js +0 -575
  673. package/one/tools/background-agent-loader.js +0 -609
  674. package/one/tools/generate-agent-commands.js +0 -303
  675. package/scaffold/.one/checklists/quality-checklist.yaml +0 -331
  676. package/scaffold/.one/hooks/content-validator.js +0 -466
  677. package/scaffold/.one/hooks/file-organization-monitor.js +0 -409
  678. package/scaffold/.one/spaces/default/config.yaml +0 -103
  679. package/scaffold/.one/templates/mission-template.yaml +0 -192
  680. /package/{one → .one}/tools/lib/dependency-resolver.js +0 -0
  681. /package/{one → .one}/tools/lib/template-processor.js +0 -0
  682. /package/{one → .one}/tools/lib/yaml-utils.js +0 -0
  683. /package/{one → .one}/tools/one-cli.js +0 -0
@@ -0,0 +1,1268 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+ import yaml from 'js-yaml';
4
+ import { exec } from 'child_process';
5
+ import { promisify } from 'util';
6
+ import PlaybookSecurity from './security.js';
7
+ import {
8
+ ConfigurationError,
9
+ ValidationError,
10
+ SecurityError,
11
+ FileSystemError,
12
+ GenerationError,
13
+ ErrorHandler
14
+ } from './errors.js';
15
+ import {
16
+ detectHierarchicalBookStructure,
17
+ detectChapterStructure,
18
+ generateHierarchicalMarkdown,
19
+ generateConsolidatedMarkdown
20
+ } from './processor.js';
21
+
22
+ const execAsync = promisify(exec);
23
+
24
+ // Import inquirer with proper async handling
25
+ let inquirer;
26
+ async function getInquirer() {
27
+ if (!inquirer) {
28
+ inquirer = await import('inquirer');
29
+ }
30
+ return inquirer.default || inquirer;
31
+ }
32
+
33
+ class PlaybookGenerator {
34
+ constructor(options = {}) {
35
+ this.rootDir = options.rootDir || process.cwd();
36
+ this.outputDir = options.outputDir || './output/playbooks';
37
+ this.bookDir = path.join(this.rootDir, 'book');
38
+ this.playbookDir = path.join(this.rootDir, 'one/playbooks');
39
+ }
40
+
41
+ async validateConfig(configPath) {
42
+ return ErrorHandler.wrap(async () => {
43
+ // Validate path safety first
44
+ if (!PlaybookSecurity.isPathSafe(configPath, this.rootDir)) {
45
+ throw new SecurityError(`Unsafe configuration path: ${configPath}`, {
46
+ path: configPath,
47
+ suggestion: 'Use relative paths within the project directory'
48
+ });
49
+ }
50
+
51
+ const fullConfigPath = path.join(this.rootDir, configPath);
52
+
53
+ let configContent;
54
+ try {
55
+ configContent = await fs.readFile(fullConfigPath, 'utf8');
56
+ } catch (error) {
57
+ if (error.code === 'ENOENT') {
58
+ throw new FileSystemError(`Configuration file not found: ${configPath}`, {
59
+ path: fullConfigPath,
60
+ suggestion: 'Create configuration using: one create-playbook --client <name>'
61
+ });
62
+ }
63
+ throw error;
64
+ }
65
+
66
+ let config;
67
+ try {
68
+ config = yaml.load(configContent);
69
+ } catch (error) {
70
+ throw new ConfigurationError(`Invalid YAML in configuration file: ${error.message}`, {
71
+ path: configPath,
72
+ suggestion: 'Check YAML syntax at yaml-lint.com'
73
+ });
74
+ }
75
+
76
+ // Security validation
77
+ const securityResult = PlaybookSecurity.validateConfig(config);
78
+ if (!securityResult.valid) {
79
+ throw new SecurityError(`Configuration security validation failed`, {
80
+ errors: securityResult.errors,
81
+ suggestion: 'Remove dangerous paths and options from configuration'
82
+ });
83
+ }
84
+
85
+ // Required field validation
86
+ if (!config.client?.name) {
87
+ throw new ValidationError('Configuration missing required field: client.name', {
88
+ suggestion: 'Add client.name to your configuration file'
89
+ });
90
+ }
91
+
92
+ if (!config.output?.title) {
93
+ throw new ValidationError('Configuration missing required field: output.title', {
94
+ suggestion: 'Add output.title to your configuration file'
95
+ });
96
+ }
97
+
98
+ console.log(`✓ Configuration valid for: ${config.client.name}`);
99
+
100
+ // Store the config path for later use
101
+ config._configPath = configPath;
102
+
103
+ return config;
104
+ }, `validating config: ${configPath}`);
105
+ }
106
+
107
+ async generatePlaybook(configPath, options = {}) {
108
+ const config = await this.validateConfig(configPath);
109
+ const { format = 'both', verbose = false, interactive = false } = options;
110
+
111
+ if (verbose) {
112
+ console.log(`📚 Generating playbook: ${config.output.title}`);
113
+ console.log(`🎯 Industry: ${config.client.industry}`);
114
+ console.log(`📝 Format: ${format}`);
115
+ if (interactive) {
116
+ console.log(`🔄 Interactive mode: Enabled`);
117
+ }
118
+ }
119
+
120
+ // Create output directory
121
+ await this.ensureOutputDir();
122
+
123
+ // Step 1: Process book content with variable substitution
124
+ const processedBookDir = await this.processBookContent(config, verbose, interactive);
125
+
126
+ // Step 2: Generate metadata file
127
+ const metadataFile = await this.generateMetadata(config, processedBookDir);
128
+
129
+ // Step 2.5: Validate content before generation
130
+ await this.validateContent(processedBookDir, verbose);
131
+
132
+ // Step 3: Generate pandoc outputs
133
+ const generatedFiles = await this.generateOutputs(config, processedBookDir, metadataFile, format, verbose);
134
+
135
+ return {
136
+ config,
137
+ processedBookDir,
138
+ files: generatedFiles
139
+ };
140
+ }
141
+
142
+ async ensureOutputDir() {
143
+ try {
144
+ await fs.access(this.outputDir);
145
+ } catch {
146
+ await fs.mkdir(this.outputDir, { recursive: true });
147
+ }
148
+ }
149
+
150
+ async processBookContent(config, verbose = false, interactive = false) {
151
+ const timestamp = Date.now();
152
+ const processedDir = path.join(this.outputDir, `processed-${timestamp}`);
153
+ await fs.mkdir(processedDir, { recursive: true });
154
+
155
+ if (verbose) {
156
+ console.log(`📂 Processing book content into: ${processedDir}`);
157
+ }
158
+
159
+ // Determine content source - check if this is an industry configuration
160
+ const configPath = config._configPath || '';
161
+ const isIndustryConfig = configPath.includes('/industries/');
162
+
163
+ let contentDir, markdownFiles;
164
+
165
+ // Try hierarchical structure detection first for any config
166
+ contentDir = path.dirname(configPath);
167
+
168
+ // Check if this directory has hierarchical structure (numbered folders like 0-introduction, 1-foundation, etc.)
169
+ try {
170
+ const entries = await fs.readdir(contentDir, { withFileTypes: true });
171
+ const hasHierarchicalStructure = entries.some(entry =>
172
+ entry.isDirectory() && entry.name.match(/^[0-5]-/)
173
+ );
174
+
175
+ if (hasHierarchicalStructure) {
176
+ if (verbose) {
177
+ console.log(`🔍 Detected hierarchical structure in: ${contentDir}`);
178
+ }
179
+
180
+ // Use hierarchical structure detection
181
+ try {
182
+ const { detectHierarchicalBookStructure, generateHierarchicalMarkdown } = await import('./processor.js');
183
+ const imagesDir = path.join(contentDir, 'images');
184
+ const structure = await detectHierarchicalBookStructure(contentDir, imagesDir);
185
+
186
+ // Generate consolidated markdown from hierarchical structure
187
+ const consolidatedMarkdown = await generateHierarchicalMarkdown(structure, contentDir, imagesDir);
188
+ const outputFile = path.join(processedDir, 'consolidated-book.md');
189
+ await fs.writeFile(outputFile, consolidatedMarkdown);
190
+
191
+ if (verbose) {
192
+ console.log(`✓ Generated hierarchical book structure`);
193
+ }
194
+
195
+ // Copy assets
196
+ await this.copyDirectoryAssets(contentDir, processedDir, verbose);
197
+
198
+ return processedDir;
199
+ } catch (error) {
200
+ console.warn(`⚠️ Could not process hierarchical structure: ${error.message}`);
201
+ console.log(`📂 Falling back to standard book processing`);
202
+ }
203
+ }
204
+ } catch (error) {
205
+ if (verbose) {
206
+ console.log(`🔍 Could not detect structure, using config-based detection: ${error.message}`);
207
+ }
208
+ }
209
+
210
+ // Handle industry configs with specific path detection
211
+ if (isIndustryConfig) {
212
+ const industryMatch = configPath.match(/\/industries\/([^\/]+)(-config\.yaml|\/config\.yaml)$/);
213
+ if (industryMatch) {
214
+ const industryName = industryMatch[1];
215
+ contentDir = path.join(this.playbookDir, 'industries', industryName);
216
+
217
+ if (verbose) {
218
+ console.log(`🔍 Using industry config structure in: ${contentDir}`);
219
+ }
220
+
221
+ // Copy assets from industry directory
222
+ await this.copyIndustryAssets(contentDir, processedDir, verbose);
223
+ }
224
+ }
225
+
226
+ // Fallback to standard book directory processing
227
+ try {
228
+ const bookFiles = await fs.readdir(this.bookDir);
229
+ markdownFiles = bookFiles.filter(f => f.endsWith('.md')).sort();
230
+ } catch (error) {
231
+ throw new FileSystemError(`Could not read book directory: ${this.bookDir}`, {
232
+ path: this.bookDir,
233
+ suggestion: 'Ensure book directory exists with markdown content'
234
+ });
235
+ }
236
+
237
+ for (const file of markdownFiles) {
238
+ const chapterNumber = this.extractChapterNumber(file);
239
+
240
+ // Check if this chapter should be excluded
241
+ if (config.book_modifications?.exclude_chapters?.includes(chapterNumber)) {
242
+ if (verbose) {
243
+ console.log(`⏭️ Skipping excluded chapter: ${file}`);
244
+ }
245
+ continue;
246
+ }
247
+
248
+ // Interactive mode: Ask user about each chapter
249
+ if (interactive) {
250
+ const shouldProcess = await this.askChapterConfirmation(file, chapterNumber);
251
+ if (!shouldProcess) {
252
+ if (verbose) {
253
+ console.log(`⏭️ Skipping chapter by user choice: ${file}`);
254
+ }
255
+ continue;
256
+ }
257
+ }
258
+
259
+ // Check if there's custom content for this chapter
260
+ const customContentKey = `chapter_${chapterNumber}`;
261
+ if (config.book_modifications?.custom_chapter_content?.[customContentKey]) {
262
+ const customPath = config.book_modifications.custom_chapter_content[customContentKey];
263
+ await this.processCustomChapter(customPath, file, processedDir, config, verbose);
264
+ } else {
265
+ await this.processStandardChapter(file, processedDir, config, verbose);
266
+ }
267
+
268
+ // In interactive mode, offer to preview the processed chapter
269
+ if (interactive && verbose) {
270
+ await this.offerChapterPreview(path.join(processedDir, file));
271
+ }
272
+ }
273
+
274
+ // Process additional chapters
275
+ if (config.book_modifications?.additional_chapters) {
276
+ for (const [key, customPath] of Object.entries(config.book_modifications.additional_chapters)) {
277
+ const chapterNum = key.replace('chapter_', '');
278
+ const fileName = `${chapterNum}.Additional.md`;
279
+
280
+ if (interactive) {
281
+ const shouldProcess = await this.askChapterConfirmation(fileName, chapterNum, 'additional');
282
+ if (!shouldProcess) continue;
283
+ }
284
+
285
+ await this.processCustomChapter(customPath, fileName, processedDir, config, verbose);
286
+
287
+ if (interactive && verbose) {
288
+ await this.offerChapterPreview(path.join(processedDir, fileName));
289
+ }
290
+ }
291
+ }
292
+
293
+ // Copy assets
294
+ await this.copyAssets(processedDir, verbose);
295
+
296
+ return processedDir;
297
+ }
298
+
299
+ extractChapterNumber(filename) {
300
+ const match = filename.match(/^(\d+)/);
301
+ return match ? parseInt(match[1]) : 0;
302
+ }
303
+
304
+ async processStandardChapter(filename, outputDir, config, verbose = false) {
305
+ const sourcePath = path.join(this.bookDir, filename);
306
+ const outputPath = path.join(outputDir, filename);
307
+
308
+ try {
309
+ let content = await fs.readFile(sourcePath, 'utf8');
310
+ content = this.substituteVariables(content, config);
311
+ await fs.writeFile(outputPath, content);
312
+
313
+ if (verbose) {
314
+ console.log(`✓ Processed: ${filename}`);
315
+ }
316
+ } catch (error) {
317
+ console.warn(`⚠️ Warning: Could not process ${filename}: ${error.message}`);
318
+ }
319
+ }
320
+
321
+ async processCustomChapter(customPath, outputFilename, outputDir, config, verbose = false) {
322
+ const sourcePath = path.join(this.playbookDir, customPath);
323
+ const outputPath = path.join(outputDir, outputFilename);
324
+
325
+ try {
326
+ let content = await fs.readFile(sourcePath, 'utf8');
327
+ content = this.substituteVariables(content, config);
328
+ await fs.writeFile(outputPath, content);
329
+
330
+ if (verbose) {
331
+ console.log(`✓ Processed custom: ${customPath} → ${outputFilename}`);
332
+ }
333
+ } catch (error) {
334
+ console.warn(`⚠️ Warning: Could not process custom chapter ${customPath}: ${error.message}`);
335
+ }
336
+ }
337
+
338
+ substituteVariables(content, config) {
339
+ let processed = content;
340
+
341
+ // Check if content starts with YAML frontmatter or YAML-like metadata
342
+ if (content.startsWith('---\n') || this.looksLikeYamlMetadata(content)) {
343
+ // Find the first markdown heading or content after the YAML-like section
344
+ const lines = content.split('\n');
345
+ let markdownStartIndex = 0;
346
+
347
+ // Look for the first line that starts with ## (markdown heading) or # (any heading)
348
+ for (let i = 1; i < lines.length; i++) {
349
+ if (lines[i].startsWith('#') || lines[i].trim().startsWith('![')) {
350
+ markdownStartIndex = i;
351
+ break;
352
+ }
353
+ }
354
+
355
+ if (markdownStartIndex > 0) {
356
+ // Extract just the markdown content, skip the metadata section
357
+ const markdownLines = lines.slice(markdownStartIndex);
358
+ const markdownContent = markdownLines.join('\n');
359
+ processed = this.performSubstitutions(markdownContent, config);
360
+ } else {
361
+ // Fallback: process entire content
362
+ processed = this.performSubstitutions(content, config);
363
+ }
364
+ } else {
365
+ // No YAML frontmatter, process entire content
366
+ processed = this.performSubstitutions(content, config);
367
+ }
368
+
369
+ return processed;
370
+ }
371
+
372
+ looksLikeYamlMetadata(content) {
373
+ const lines = content.split('\n').slice(0, 10); // Check first 10 lines
374
+ let yamlLikeLines = 0;
375
+
376
+ for (const line of lines) {
377
+ // Count lines that look like YAML key: value pairs
378
+ if (line.includes(':') && !line.startsWith('#') && !line.startsWith('![')) {
379
+ yamlLikeLines++;
380
+ }
381
+ }
382
+
383
+ // If more than 3 lines look like YAML, treat it as metadata
384
+ return yamlLikeLines >= 3;
385
+ }
386
+
387
+ performSubstitutions(content, config) {
388
+ let processed = content;
389
+
390
+ // Fix absolute asset paths to relative paths
391
+ processed = processed.replace(/!\[\]\(\/assets\//g, '![](images/');
392
+ processed = processed.replace(/!\[([^\]]*)\]\(\/assets\//g, '![$1](images/');
393
+
394
+ // Substitute client variables
395
+ if (config.client) {
396
+ processed = processed.replace(/\{\{CLIENT_NAME\}\}/g, config.client.name || '');
397
+ processed = processed.replace(/\{\{INDUSTRY\}\}/g, config.client.industry || '');
398
+ processed = processed.replace(/\{\{BRAND_VOICE\}\}/g, config.client.brand_voice || '');
399
+ }
400
+
401
+ // Substitute customization variables
402
+ if (config.customizations) {
403
+ processed = processed.replace(/\{\{COMPANY_EXAMPLES\}\}/g, config.customizations.company_examples || '');
404
+ processed = processed.replace(/\{\{TARGET_AUDIENCE\}\}/g, config.customizations.target_audience || '');
405
+ processed = processed.replace(/\{\{KEY_METRICS\}\}/g, config.customizations.key_metrics || '');
406
+ processed = processed.replace(/\{\{PAIN_POINTS\}\}/g, config.customizations.pain_points || '');
407
+ processed = processed.replace(/\{\{SUCCESS_STORIES\}\}/g, config.customizations.success_stories || '');
408
+ }
409
+
410
+ // Substitute template variables
411
+ if (config.variables) {
412
+ for (const [key, value] of Object.entries(config.variables)) {
413
+ const pattern = new RegExp(`\\{\\{${key.toUpperCase()}\\}\\}`, 'g');
414
+ processed = processed.replace(pattern, value || '');
415
+ }
416
+ }
417
+
418
+ return processed;
419
+ }
420
+
421
+ async copyAssets(outputDir, verbose = false) {
422
+ const assetsSource = path.join(this.bookDir, 'assets');
423
+ const assetsTarget = path.join(outputDir, 'assets');
424
+
425
+ try {
426
+ await fs.access(assetsSource);
427
+ await execAsync(`cp -r "${assetsSource}" "${assetsTarget}"`);
428
+ if (verbose) {
429
+ console.log('✓ Copied assets directory');
430
+ }
431
+ } catch (error) {
432
+ if (verbose) {
433
+ console.log('⚠️ No assets directory found to copy');
434
+ }
435
+ }
436
+
437
+ // Also copy epub-style.css to the root of processed directory
438
+ const epubStyleSource = path.join(this.bookDir, 'epub-style.css');
439
+ const epubStyleTarget = path.join(outputDir, 'epub-style.css');
440
+
441
+ try {
442
+ await fs.access(epubStyleSource);
443
+ await fs.copyFile(epubStyleSource, epubStyleTarget);
444
+ if (verbose) {
445
+ console.log('✓ Copied epub-style.css');
446
+ }
447
+ } catch (error) {
448
+ // Try assets directory as fallback
449
+ const epubStyleAssetsSource = path.join(this.bookDir, 'assets', 'epub-style.css');
450
+ try {
451
+ await fs.access(epubStyleAssetsSource);
452
+ await fs.copyFile(epubStyleAssetsSource, epubStyleTarget);
453
+ if (verbose) {
454
+ console.log('✓ Copied epub-style.css from assets');
455
+ }
456
+ } catch (error2) {
457
+ if (verbose) {
458
+ console.log('⚠️ No epub-style.css found to copy');
459
+ }
460
+ }
461
+ }
462
+ }
463
+
464
+ /**
465
+ * Validate content before generation
466
+ * @param {string} processedDir - Processed content directory
467
+ * @param {boolean} verbose - Verbose logging
468
+ */
469
+ async validateContent(processedDir, verbose = false) {
470
+ try {
471
+ const consolidatedFile = path.join(processedDir, 'consolidated-book.md');
472
+
473
+ // Check if consolidated file exists
474
+ if (!await fs.access(consolidatedFile).then(() => true).catch(() => false)) {
475
+ throw new ValidationError('Consolidated book file not found', {
476
+ path: consolidatedFile,
477
+ suggestion: 'Check that content processing completed successfully'
478
+ });
479
+ }
480
+
481
+ // Read and validate consolidated content
482
+ const content = await fs.readFile(consolidatedFile, 'utf8');
483
+
484
+ // Check for common issues
485
+ const issues = [];
486
+
487
+ // Check for undefined sections
488
+ if (content.includes('# undefined')) {
489
+ issues.push('Found undefined sections in content');
490
+ }
491
+
492
+ // Check for missing image references (only warn, don't fail)
493
+ const imageMatches = content.match(/!\[([^\]]*)\]\(([^)]+)\)/g) || [];
494
+ const imagesDir = path.join(processedDir, 'images');
495
+ let missingImages = 0;
496
+
497
+ for (const imageMatch of imageMatches) {
498
+ const srcMatch = imageMatch.match(/!\[([^\]]*)\]\(([^)]+)\)/);
499
+ if (srcMatch) {
500
+ const imagePath = srcMatch[2];
501
+ // Try to resolve image path
502
+ const possiblePaths = [
503
+ path.join(imagesDir, imagePath),
504
+ path.join(processedDir, imagePath),
505
+ imagePath.startsWith('/') ? imagePath.substring(1) : imagePath
506
+ ];
507
+
508
+ let found = false;
509
+ for (const testPath of possiblePaths) {
510
+ try {
511
+ await fs.access(testPath);
512
+ found = true;
513
+ break;
514
+ } catch (err) {
515
+ // Continue
516
+ }
517
+ }
518
+
519
+ if (!found) {
520
+ missingImages++;
521
+ if (verbose) {
522
+ console.warn(`⚠️ Image may be missing: ${imagePath}`);
523
+ }
524
+ }
525
+ }
526
+ }
527
+
528
+ if (missingImages > 0 && verbose) {
529
+ console.warn(`⚠️ Found ${missingImages} potentially missing images (will attempt to resolve during generation)`);
530
+ }
531
+
532
+ // Check content length
533
+ if (content.length < 1000) {
534
+ issues.push('Content appears too short (less than 1000 characters)');
535
+ }
536
+
537
+ // Report validation results
538
+ if (issues.length > 0) {
539
+ if (verbose) {
540
+ console.warn('⚠️ Content validation issues found:');
541
+ issues.forEach(issue => console.warn(` - ${issue}`));
542
+ }
543
+ // Don't fail for issues, just warn
544
+ } else if (verbose) {
545
+ console.log('✓ Content validation passed');
546
+ }
547
+
548
+ } catch (error) {
549
+ if (verbose) {
550
+ console.warn(`⚠️ Content validation failed: ${error.message}`);
551
+ }
552
+ // Don't fail the entire process for validation issues
553
+ }
554
+ }
555
+
556
+ async copyDirectoryAssets(contentDir, outputDir, verbose = false) {
557
+ // Copy assets directory if it exists
558
+ const assetsSource = path.join(contentDir, 'assets');
559
+ const assetsTarget = path.join(outputDir, 'assets');
560
+
561
+ try {
562
+ await fs.access(assetsSource);
563
+ await execAsync(`cp -r "${assetsSource}" "${assetsTarget}"`);
564
+ if (verbose) {
565
+ console.log('✓ Copied assets directory');
566
+ }
567
+ } catch (error) {
568
+ if (verbose) {
569
+ console.log('⚠️ No assets directory found to copy');
570
+ }
571
+ }
572
+
573
+ // Copy images directory
574
+ const imagesSource = path.join(contentDir, 'images');
575
+ const imagesTarget = path.join(outputDir, 'images');
576
+
577
+ try {
578
+ await fs.access(imagesSource);
579
+ await execAsync(`cp -r "${imagesSource}" "${imagesTarget}"`);
580
+ if (verbose) {
581
+ console.log('✓ Copied images directory');
582
+ }
583
+ } catch (error) {
584
+ if (verbose) {
585
+ console.log('⚠️ No images directory found to copy');
586
+ }
587
+ }
588
+
589
+ // Copy any additional common asset files
590
+ const commonAssets = ['epub-style.css', 'cover-header.tex'];
591
+ for (const asset of commonAssets) {
592
+ try {
593
+ const sourceFile = path.join(contentDir, asset);
594
+ const targetFile = path.join(outputDir, asset);
595
+ await fs.access(sourceFile);
596
+ await fs.copyFile(sourceFile, targetFile);
597
+ if (verbose) {
598
+ console.log(`✓ Copied ${asset}`);
599
+ }
600
+ } catch (error) {
601
+ // File doesn't exist, skip silently
602
+ }
603
+ }
604
+ }
605
+
606
+ async copyIndustryAssets(contentDir, outputDir, verbose = false) {
607
+ const assetsSource = path.join(contentDir, 'assets');
608
+ const assetsTarget = path.join(outputDir, 'assets');
609
+
610
+ try {
611
+ await fs.access(assetsSource);
612
+ await execAsync(`cp -r "${assetsSource}" "${assetsTarget}"`);
613
+ if (verbose) {
614
+ console.log('✓ Copied industry assets directory');
615
+ }
616
+ } catch (error) {
617
+ if (verbose) {
618
+ console.log('⚠️ No industry assets directory found to copy');
619
+ }
620
+ }
621
+
622
+ // Also copy images directory
623
+ const imagesSource = path.join(contentDir, 'images');
624
+ const imagesTarget = path.join(outputDir, 'images');
625
+
626
+ try {
627
+ await fs.access(imagesSource);
628
+ await execAsync(`cp -r "${imagesSource}" "${imagesTarget}"`);
629
+ if (verbose) {
630
+ console.log('✓ Copied industry images directory');
631
+ }
632
+ } catch (error) {
633
+ if (verbose) {
634
+ console.log('⚠️ No industry images directory found to copy');
635
+ }
636
+ }
637
+
638
+ // Copy epub-style.css if it exists
639
+ const epubStyleSource = path.join(contentDir, 'images', 'epub-style.css');
640
+ const epubStyleTarget = path.join(outputDir, 'epub-style.css');
641
+
642
+ try {
643
+ await fs.access(epubStyleSource);
644
+ await fs.copyFile(epubStyleSource, epubStyleTarget);
645
+ if (verbose) {
646
+ console.log('✓ Copied industry epub-style.css');
647
+ }
648
+ } catch (error) {
649
+ if (verbose) {
650
+ console.log('⚠️ No industry epub-style.css found to copy');
651
+ }
652
+ }
653
+ }
654
+
655
+ async generateMetadata(config, processedDir) {
656
+ const metadataPath = path.join(processedDir, 'metadata.yaml');
657
+
658
+ const metadata = {
659
+ title: config.output.title,
660
+ subtitle: config.output.subtitle || '',
661
+ author: 'Anthony O\'Connell',
662
+ date: new Date().toISOString().split('T')[0],
663
+ language: 'en-US',
664
+ publisher: 'ONE Publishing',
665
+ rights: '© 2025 Anthony O\'Connell. All rights reserved.',
666
+ identifier: '978-1-916-12345-6',
667
+ // Custom metadata
668
+ client: config.client.name,
669
+ industry: config.client.industry,
670
+ generated: new Date().toISOString()
671
+ };
672
+
673
+ await fs.writeFile(metadataPath, yaml.dump(metadata));
674
+ return metadataPath;
675
+ }
676
+
677
+ async generateOutputs(config, processedDir, metadataFile, format, verbose = false) {
678
+ const generatedFiles = [];
679
+ const filenamePrefix = config.output.filename_prefix || 'playbook';
680
+
681
+ // Get all markdown files in order
682
+ const files = await fs.readdir(processedDir);
683
+ const markdownFiles = files
684
+ .filter(f => f.endsWith('.md'))
685
+ .sort()
686
+ .map(f => path.join(processedDir, f));
687
+
688
+ if (format === 'pdf' || format === 'both') {
689
+ const pdfFile = await this.generatePDF(markdownFiles, metadataFile, config, filenamePrefix, processedDir, verbose);
690
+ generatedFiles.push(pdfFile);
691
+ }
692
+
693
+ if (format === 'enhanced-pdf' || format === 'all') {
694
+ const enhancedPdfFile = await this.generateEnhancedPDF(markdownFiles, metadataFile, config, filenamePrefix, processedDir, verbose);
695
+ generatedFiles.push(enhancedPdfFile);
696
+ }
697
+
698
+ if (format === 'epub' || format === 'both' || format === 'all') {
699
+ const epubFile = await this.generateEPUB(markdownFiles, metadataFile, config, filenamePrefix, processedDir, verbose);
700
+ generatedFiles.push(epubFile);
701
+ }
702
+
703
+ return generatedFiles;
704
+ }
705
+
706
+ getOutputDirectory(config) {
707
+ const configPath = config._configPath || '';
708
+
709
+ // For industry configurations, output to the industry directory
710
+ const isIndustryConfig = configPath.includes('/industries/');
711
+ if (isIndustryConfig) {
712
+ const industryMatch = configPath.match(/\/industries\/([^\/]+)(-config\.yaml|\/config\.yaml)$/);
713
+ if (industryMatch) {
714
+ const industryName = industryMatch[1];
715
+ const industryDir = path.join(this.playbookDir, 'industries', industryName);
716
+ return industryDir;
717
+ }
718
+ }
719
+
720
+ // For client configurations, output to the client directory
721
+ const isClientConfig = configPath.includes('/clients/');
722
+ if (isClientConfig) {
723
+ const clientMatch = configPath.match(/\/clients\/([^\/]+)(\/config\.yaml)$/);
724
+ if (clientMatch) {
725
+ const clientName = clientMatch[1];
726
+ const clientDir = path.join(this.playbookDir, 'clients', clientName);
727
+ return clientDir;
728
+ }
729
+ }
730
+
731
+ // Default to global output directory for other configs
732
+ return this.outputDir;
733
+ }
734
+
735
+ async generatePDF(markdownFiles, metadataFile, config, filenamePrefix, processedDir, verbose = false) {
736
+ return ErrorHandler.wrap(async () => {
737
+ // Determine output directory - use industry directory for industry configs
738
+ const outputDir = this.getOutputDirectory(config);
739
+ const outputFile = path.join(outputDir, `${PlaybookSecurity.sanitizeFilename(filenamePrefix)}.pdf`);
740
+
741
+ // Convert file paths to relative paths from the processed directory
742
+ const relativeMarkdownFiles = markdownFiles.map(f => path.relative(processedDir, f));
743
+ const relativeMetadataFile = path.relative(processedDir, metadataFile);
744
+ const relativeOutputFile = path.relative(processedDir, outputFile);
745
+
746
+ // Find the universal template
747
+ let projectRoot = this.rootDir;
748
+ while (projectRoot !== path.dirname(projectRoot)) {
749
+ const toolsPath = path.join(projectRoot, 'one/tools', 'templates');
750
+ try {
751
+ await fs.access(toolsPath);
752
+ break;
753
+ } catch (err) {
754
+ projectRoot = path.dirname(projectRoot);
755
+ }
756
+ }
757
+
758
+ const templatePath = path.join(projectRoot, 'one/tools', 'templates', 'universal-book.tex');
759
+
760
+ // Enhanced PDF options with beautiful formatting and cover image
761
+ const enhancedOptions = [
762
+ '--pdf-engine=xelatex',
763
+ `--template=${templatePath}`,
764
+ '--toc',
765
+ '--number-sections',
766
+ '--toc-depth=3',
767
+ '--highlight-style=tango',
768
+ '--variable=cover-image:images/cover.png',
769
+ ...config.pandoc?.pdf_options || []
770
+ ];
771
+
772
+ // Use secure pandoc execution
773
+ await PlaybookSecurity.executePandocSafely({
774
+ format: 'pdf',
775
+ metadataFile: relativeMetadataFile,
776
+ outputFile: relativeOutputFile,
777
+ markdownFiles: relativeMarkdownFiles,
778
+ additionalOptions: enhancedOptions,
779
+ verbose,
780
+ workingDirectory: processedDir
781
+ });
782
+
783
+ if (verbose) {
784
+ console.log(`✓ PDF generated with enhanced formatting: ${outputFile}`);
785
+ }
786
+ return outputFile;
787
+ }, 'generating PDF');
788
+ }
789
+
790
+ async generateEPUB(markdownFiles, metadataFile, config, filenamePrefix, processedDir, verbose = false) {
791
+ return ErrorHandler.wrap(async () => {
792
+ // Determine output directory - use industry directory for industry configs
793
+ const outputDir = this.getOutputDirectory(config);
794
+ const outputFile = path.join(outputDir, `${PlaybookSecurity.sanitizeFilename(filenamePrefix)}.epub`);
795
+
796
+ // Convert file paths to relative paths from the processed directory
797
+ const relativeMarkdownFiles = markdownFiles.map(f => path.relative(processedDir, f));
798
+ const relativeMetadataFile = path.relative(processedDir, metadataFile);
799
+ const relativeOutputFile = path.relative(processedDir, outputFile);
800
+
801
+ // Find the enhanced CSS template
802
+ let projectRoot = this.rootDir;
803
+ while (projectRoot !== path.dirname(projectRoot)) {
804
+ const toolsPath = path.join(projectRoot, 'one/tools', 'templates');
805
+ try {
806
+ await fs.access(toolsPath);
807
+ break;
808
+ } catch (err) {
809
+ projectRoot = path.dirname(projectRoot);
810
+ }
811
+ }
812
+
813
+ const cssPath = path.join(projectRoot, 'one/tools', 'templates', 'enhanced-epub.css');
814
+
815
+ // Enhanced EPUB options with beautiful formatting and cover image
816
+ const enhancedOptions = [
817
+ `--css=${cssPath}`,
818
+ '--epub-cover-image=images/cover.png',
819
+ '--toc-depth=3',
820
+ '--highlight-style=tango',
821
+ ...config.pandoc?.epub_options || []
822
+ ];
823
+
824
+ // Use secure pandoc execution
825
+ await PlaybookSecurity.executePandocSafely({
826
+ format: 'epub',
827
+ metadataFile: relativeMetadataFile,
828
+ outputFile: relativeOutputFile,
829
+ markdownFiles: relativeMarkdownFiles,
830
+ additionalOptions: enhancedOptions,
831
+ verbose,
832
+ workingDirectory: processedDir
833
+ });
834
+
835
+ if (verbose) {
836
+ console.log(`✓ EPUB generated with enhanced styling: ${outputFile}`);
837
+ }
838
+ return outputFile;
839
+ }, 'generating EPUB');
840
+ }
841
+
842
+ async generateEnhancedPDF(markdownFiles, metadataFile, config, filenamePrefix, processedDir, verbose = false) {
843
+ return ErrorHandler.wrap(async () => {
844
+ // Determine output directory
845
+ const outputDir = this.getOutputDirectory(config);
846
+ const outputFile = path.join(outputDir, `${PlaybookSecurity.sanitizeFilename(filenamePrefix)}-enhanced.pdf`);
847
+
848
+ // Create a consolidated markdown file for the enhanced converter
849
+ const consolidatedContent = [];
850
+
851
+ // Add metadata as YAML front matter
852
+ const metadataContent = await fs.readFile(metadataFile, 'utf8');
853
+ const metadata = yaml.load(metadataContent);
854
+
855
+ consolidatedContent.push('---');
856
+ consolidatedContent.push(yaml.dump(metadata));
857
+ consolidatedContent.push('---\n');
858
+
859
+ // Combine all markdown files
860
+ for (const markdownFile of markdownFiles) {
861
+ const content = await fs.readFile(markdownFile, 'utf8');
862
+ // Remove any existing YAML front matter from individual files
863
+ const cleanContent = content.replace(/^---[\s\S]*?---\n?/, '');
864
+ consolidatedContent.push(cleanContent);
865
+ consolidatedContent.push('\n\n');
866
+ }
867
+
868
+ // Create temporary consolidated file
869
+ const tempMarkdownFile = path.join(processedDir, 'consolidated-enhanced.md');
870
+ await fs.writeFile(tempMarkdownFile, consolidatedContent.join('\n'));
871
+
872
+ try {
873
+ // Use the enhanced PDF converter
874
+ const enhancedConverterPath = path.join(this.rootDir, 'one/tools/enhanced-pdf-converter.py');
875
+ const title = config.output?.title || 'Generated Playbook';
876
+
877
+ const command = `python3 "${enhancedConverterPath}" "${tempMarkdownFile}" "${outputFile}" "${title}"`;
878
+
879
+ if (verbose) {
880
+ console.log(`🔄 Running enhanced PDF conversion: ${command}`);
881
+ }
882
+
883
+ const { stdout, stderr } = await execAsync(command, {
884
+ cwd: processedDir,
885
+ timeout: 300000 // 5 minutes timeout
886
+ });
887
+
888
+ if (verbose && stdout) {
889
+ console.log('Enhanced PDF converter output:', stdout);
890
+ }
891
+
892
+ if (stderr && verbose) {
893
+ console.warn('Enhanced PDF converter warnings:', stderr);
894
+ }
895
+
896
+ // Verify output file was created
897
+ try {
898
+ await fs.access(outputFile);
899
+ const stats = await fs.stat(outputFile);
900
+
901
+ if (verbose) {
902
+ console.log(`✓ Enhanced PDF generated with embedded images: ${outputFile} (${(stats.size / 1024 / 1024).toFixed(1)} MB)`);
903
+ }
904
+
905
+ return outputFile;
906
+ } catch (error) {
907
+ throw new GenerationError(`Enhanced PDF output file not created: ${outputFile}`);
908
+ }
909
+
910
+ } finally {
911
+ // Clean up temporary file
912
+ try {
913
+ await fs.unlink(tempMarkdownFile);
914
+ } catch (error) {
915
+ // Ignore cleanup errors
916
+ }
917
+ }
918
+ }, 'generating enhanced PDF');
919
+ }
920
+
921
+ async askChapterConfirmation(filename, chapterNumber, type = 'standard') {
922
+ const inquirer = await getInquirer();
923
+ const chapterName = this.getChapterName(filename, chapterNumber);
924
+ const typeLabel = type === 'additional' ? 'Additional' : 'Chapter';
925
+
926
+ const { action } = await inquirer.prompt([
927
+ {
928
+ type: 'list',
929
+ name: 'action',
930
+ message: `📖 ${typeLabel} ${chapterNumber}: ${chapterName}`,
931
+ choices: [
932
+ { name: '✅ Include this chapter', value: 'include' },
933
+ { name: '⏭️ Skip this chapter', value: 'skip' },
934
+ { name: '👁️ Preview first', value: 'preview' }
935
+ ]
936
+ }
937
+ ]);
938
+
939
+ if (action === 'preview') {
940
+ await this.previewChapter(filename, chapterNumber);
941
+ return await this.askChapterConfirmation(filename, chapterNumber, type);
942
+ }
943
+
944
+ return action === 'include';
945
+ }
946
+
947
+ async previewChapter(filename, chapterNumber) {
948
+ try {
949
+ const chapterPath = path.join(this.bookDir, filename);
950
+ const content = await fs.readFile(chapterPath, 'utf8');
951
+
952
+ // Show first few lines
953
+ const lines = content.split('\n').slice(0, 15);
954
+ const preview = lines.join('\n');
955
+
956
+ console.log(`\n📄 Preview of Chapter ${chapterNumber}:`);
957
+ console.log('─'.repeat(60));
958
+ console.log(preview);
959
+ if (content.split('\n').length > 15) {
960
+ console.log('\n... (truncated)');
961
+ }
962
+ console.log('─'.repeat(60));
963
+
964
+ const { continueReading } = await (await getInquirer()).prompt([
965
+ {
966
+ type: 'confirm',
967
+ name: 'continueReading',
968
+ message: 'Show full chapter content?',
969
+ default: false
970
+ }
971
+ ]);
972
+
973
+ if (continueReading) {
974
+ console.log('\n' + content);
975
+ console.log('\n' + '─'.repeat(60));
976
+ }
977
+
978
+ } catch (error) {
979
+ console.log(`⚠️ Could not preview chapter: ${error.message}`);
980
+ }
981
+ }
982
+
983
+ async offerChapterPreview(processedFilePath) {
984
+ const { wantPreview } = await (await getInquirer()).prompt([
985
+ {
986
+ type: 'confirm',
987
+ name: 'wantPreview',
988
+ message: '👁️ Preview the processed chapter?',
989
+ default: false
990
+ }
991
+ ]);
992
+
993
+ if (wantPreview) {
994
+ try {
995
+ const content = await fs.readFile(processedFilePath, 'utf8');
996
+ const lines = content.split('\n').slice(0, 20);
997
+ const preview = lines.join('\n');
998
+
999
+ console.log('\n📄 Processed Chapter Preview:');
1000
+ console.log('─'.repeat(60));
1001
+ console.log(preview);
1002
+ if (content.split('\n').length > 20) {
1003
+ console.log('\n... (truncated)');
1004
+ }
1005
+ console.log('─'.repeat(60) + '\n');
1006
+ } catch (error) {
1007
+ console.log(`⚠️ Could not preview processed chapter: ${error.message}`);
1008
+ }
1009
+ }
1010
+ }
1011
+
1012
+ getChapterName(filename, chapterNumber) {
1013
+ // Extract a readable chapter name from filename
1014
+ const nameWithoutNumber = filename.replace(/^\d+\.?/, '').replace(/\.md$/, '');
1015
+ const readable = nameWithoutNumber
1016
+ .replace(/[-_]/g, ' ')
1017
+ .replace(/\b\w/g, l => l.toUpperCase())
1018
+ .trim();
1019
+
1020
+ return readable || `Chapter ${chapterNumber}`;
1021
+ }
1022
+
1023
+ /**
1024
+ * Generate Apple-style book from content and images directories
1025
+ * @param {Object} config - Minimal book configuration
1026
+ * @param {Object} options - Generation options
1027
+ * @returns {Object} Generation result
1028
+ */
1029
+ async generateAppleBook(config, options = {}) {
1030
+ const { format = 'pdf', verbose = false, useHierarchical = true } = options;
1031
+
1032
+ // Detect book structure from content directory
1033
+ // Check if content directory exists, otherwise use root directory
1034
+ const contentDir = await fs.access(path.join(this.rootDir, 'content'))
1035
+ .then(() => path.join(this.rootDir, 'content'))
1036
+ .catch(() => this.rootDir);
1037
+
1038
+ const imagesDir = await fs.access(path.join(this.rootDir, 'images'))
1039
+ .then(() => path.join(this.rootDir, 'images'))
1040
+ .catch(async () => {
1041
+ // Try assets directory
1042
+ try {
1043
+ await fs.access(path.join(this.rootDir, 'assets'));
1044
+ return path.join(this.rootDir, 'assets');
1045
+ } catch (err) {
1046
+ // Default to images directory even if it doesn't exist
1047
+ return path.join(this.rootDir, 'images');
1048
+ }
1049
+ });
1050
+
1051
+ if (verbose) {
1052
+ console.log(`📚 Generating Apple-style book: ${config.title}`);
1053
+ console.log(`📝 Format: ${format}`);
1054
+ console.log(`🏗️ Structure: ${useHierarchical ? 'Hierarchical' : 'Legacy'}`);
1055
+ console.log(`📂 Content dir: ${contentDir}`);
1056
+ console.log(`🖼️ Images dir: ${imagesDir}`);
1057
+ }
1058
+
1059
+ let structure;
1060
+ let consolidatedMarkdown;
1061
+
1062
+ if (useHierarchical) {
1063
+ // Use new hierarchical structure
1064
+ structure = await detectHierarchicalBookStructure(contentDir, imagesDir);
1065
+
1066
+ if (verbose) {
1067
+ console.log(`📖 Found hierarchical structure:`);
1068
+ console.log(` Introduction: ${structure.introduction.files.length} files`);
1069
+ structure.parts.forEach(part => {
1070
+ console.log(` Part ${part.number} (${part.title}): ${part.chapters.length} chapters`);
1071
+ part.chapters.forEach(chapter => {
1072
+ if (chapter.file) {
1073
+ const chapterNum = chapter.chapterNumber || chapter.number;
1074
+ console.log(` Chapter ${chapterNum}: ${chapter.title} (${chapter.sections.length} sections)`);
1075
+ }
1076
+ });
1077
+ });
1078
+ console.log(` Appendix: ${structure.appendix.files.length} files`);
1079
+ }
1080
+
1081
+ consolidatedMarkdown = await generateHierarchicalMarkdown(structure, contentDir, imagesDir);
1082
+ } else {
1083
+ // Fall back to legacy structure
1084
+ structure = await detectChapterStructure(contentDir, imagesDir);
1085
+
1086
+ if (verbose) {
1087
+ console.log(`📖 Found ${structure.chapters.length} chapters`);
1088
+ for (const chapter of structure.chapters) {
1089
+ console.log(` Chapter ${chapter.number}: ${chapter.title} (${chapter.sections.length} sections)`);
1090
+ }
1091
+ }
1092
+
1093
+ consolidatedMarkdown = await generateConsolidatedMarkdown(structure, contentDir, imagesDir);
1094
+ }
1095
+
1096
+ // Create output directory
1097
+ await this.ensureOutputDir();
1098
+
1099
+ // Create temporary file for consolidated content
1100
+ const tempDir = path.join(this.outputDir, `temp-${Date.now()}`);
1101
+ await fs.mkdir(tempDir, { recursive: true });
1102
+
1103
+ const tempMarkdownPath = path.join(tempDir, 'book.md');
1104
+ await fs.writeFile(tempMarkdownPath, consolidatedMarkdown);
1105
+
1106
+ // Generate metadata for Apple book
1107
+ const metadata = {
1108
+ title: config.title,
1109
+ subtitle: config.subtitle || '',
1110
+ author: config.author || 'Author',
1111
+ date: new Date().toISOString().split('T')[0],
1112
+ language: 'en-US',
1113
+ publisher: 'ONE Publishing',
1114
+ rights: '© 2025 ONE Publishing. All rights reserved.',
1115
+ };
1116
+
1117
+ const metadataPath = path.join(tempDir, 'metadata.yaml');
1118
+ await fs.writeFile(metadataPath, yaml.dump(metadata));
1119
+
1120
+ // Generate output files
1121
+ const generatedFiles = [];
1122
+ const filename = config.filename || 'playbook';
1123
+
1124
+ if (format === 'pdf' || format === 'both') {
1125
+ const pdfFile = await this.generateApplePDF(tempMarkdownPath, metadataPath, filename, verbose, useHierarchical);
1126
+ generatedFiles.push(pdfFile);
1127
+ }
1128
+
1129
+ if (format === 'epub' || format === 'both') {
1130
+ const epubFile = await this.generateAppleEPUB(tempMarkdownPath, metadataPath, filename, verbose, useHierarchical);
1131
+ generatedFiles.push(epubFile);
1132
+ }
1133
+
1134
+ // DOCX generation disabled for now - requires reference template
1135
+ // if (format === 'docx' || format === 'both') {
1136
+ // const docxFile = await this.generateAppleDOCX(tempMarkdownPath, metadataPath, filename, verbose);
1137
+ // generatedFiles.push(docxFile);
1138
+ // }
1139
+
1140
+ // Clean up temp directory
1141
+ await fs.rm(tempDir, { recursive: true, force: true });
1142
+
1143
+ return {
1144
+ structure,
1145
+ files: generatedFiles,
1146
+ metadata
1147
+ };
1148
+ }
1149
+
1150
+ /**
1151
+ * Generate Apple-style PDF using custom LaTeX template
1152
+ */
1153
+ async generateApplePDF(markdownPath, metadataPath, filename, verbose = false, useHierarchical = true) {
1154
+ const outputFile = path.join(this.outputDir, `${filename}.pdf`);
1155
+
1156
+ // Find the project root by looking for tools directory
1157
+ let projectRoot = this.rootDir;
1158
+ while (projectRoot !== path.dirname(projectRoot)) {
1159
+ const toolsPath = path.join(projectRoot, 'tools', 'templates');
1160
+ try {
1161
+ await fs.access(toolsPath);
1162
+ break;
1163
+ } catch (err) {
1164
+ projectRoot = path.dirname(projectRoot);
1165
+ }
1166
+ }
1167
+
1168
+ const templatePath = path.join(projectRoot, 'tools', 'templates', 'apple-book-simple.tex');
1169
+
1170
+ const additionalOptions = [
1171
+ '--pdf-engine=pdflatex',
1172
+ `--template=${templatePath}`,
1173
+ '--toc-depth=4', // Increased depth for hierarchical structure
1174
+ '--highlight-style=tango'
1175
+ ];
1176
+
1177
+ await PlaybookSecurity.executePandocSafely({
1178
+ format: 'pdf',
1179
+ metadataFile: path.relative(path.dirname(markdownPath), metadataPath),
1180
+ outputFile: path.relative(path.dirname(markdownPath), outputFile),
1181
+ markdownFiles: [path.basename(markdownPath)],
1182
+ additionalOptions,
1183
+ verbose,
1184
+ workingDirectory: path.dirname(markdownPath)
1185
+ });
1186
+
1187
+ if (verbose) {
1188
+ console.log(`✓ Apple PDF generated: ${outputFile} (${useHierarchical ? 'Hierarchical' : 'Simple'} template)`);
1189
+ }
1190
+
1191
+ return outputFile;
1192
+ }
1193
+
1194
+ /**
1195
+ * Generate Apple-style EPUB using custom CSS
1196
+ */
1197
+ async generateAppleEPUB(markdownPath, metadataPath, filename, verbose = false, useHierarchical = true) {
1198
+ const outputFile = path.join(this.outputDir, `${filename}.epub`);
1199
+
1200
+ // Find the project root by looking for tools directory
1201
+ let projectRoot = this.rootDir;
1202
+ while (projectRoot !== path.dirname(projectRoot)) {
1203
+ const toolsPath = path.join(projectRoot, 'tools', 'templates');
1204
+ try {
1205
+ await fs.access(toolsPath);
1206
+ break;
1207
+ } catch (err) {
1208
+ projectRoot = path.dirname(projectRoot);
1209
+ }
1210
+ }
1211
+
1212
+ const cssPath = useHierarchical
1213
+ ? path.join(projectRoot, 'tools', 'templates', 'apple-book-parts.css')
1214
+ : path.join(projectRoot, 'tools', 'templates', 'apple-book.css');
1215
+
1216
+ const additionalOptions = [
1217
+ `--css=${cssPath}`,
1218
+ '--toc-depth=4' // Increased depth for hierarchical structure
1219
+ ];
1220
+
1221
+ await PlaybookSecurity.executePandocSafely({
1222
+ format: 'epub',
1223
+ metadataFile: path.relative(path.dirname(markdownPath), metadataPath),
1224
+ outputFile: path.relative(path.dirname(markdownPath), outputFile),
1225
+ markdownFiles: [path.basename(markdownPath)],
1226
+ additionalOptions,
1227
+ verbose,
1228
+ workingDirectory: path.dirname(markdownPath)
1229
+ });
1230
+
1231
+ if (verbose) {
1232
+ console.log(`✓ Apple EPUB generated: ${outputFile} (${useHierarchical ? 'Hierarchical' : 'Simple'} template)`);
1233
+ }
1234
+
1235
+ return outputFile;
1236
+ }
1237
+
1238
+ /**
1239
+ * Generate Apple-style DOCX using reference template
1240
+ */
1241
+ async generateAppleDOCX(markdownPath, metadataPath, filename, verbose = false) {
1242
+ const outputFile = path.join(this.outputDir, `${filename}.docx`);
1243
+ const referencePath = path.join(this.rootDir, 'tools', 'templates', 'apple-book-reference.docx');
1244
+
1245
+ const additionalOptions = [
1246
+ `--reference-doc=${referencePath}`,
1247
+ '--toc-depth=3'
1248
+ ];
1249
+
1250
+ await PlaybookSecurity.executePandocSafely({
1251
+ format: 'docx',
1252
+ metadataFile: path.relative(path.dirname(markdownPath), metadataPath),
1253
+ outputFile: path.relative(path.dirname(markdownPath), outputFile),
1254
+ markdownFiles: [path.basename(markdownPath)],
1255
+ additionalOptions,
1256
+ verbose,
1257
+ workingDirectory: path.dirname(markdownPath)
1258
+ });
1259
+
1260
+ if (verbose) {
1261
+ console.log(`✓ Apple DOCX generated: ${outputFile}`);
1262
+ }
1263
+
1264
+ return outputFile;
1265
+ }
1266
+ }
1267
+
1268
+ export default PlaybookGenerator;