create-byan-agent 2.0.1 → 2.1.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 (240) hide show
  1. package/API-BYAN-V2.md +741 -0
  2. package/BMAD-QUICK-REFERENCE.md +370 -0
  3. package/CHANGELOG-v2.1.0.md +371 -0
  4. package/LICENSE +1 -1
  5. package/MIGRATION-v2.0-to-v2.1.md +430 -0
  6. package/README-BYAN-V2.md +446 -0
  7. package/README.md +264 -201
  8. package/install/.eslintrc.js +20 -0
  9. package/install/.prettierrc +7 -0
  10. package/install/BUGFIX-CHALK.md +173 -0
  11. package/install/BUGFIX-DOCUMENTATION-INDEX.md +299 -0
  12. package/install/BUGFIX-PATH-RESOLUTION.md +293 -0
  13. package/install/BUGFIX-QUICKSTART.md +184 -0
  14. package/install/BUGFIX-SUMMARY.txt +91 -0
  15. package/install/BUGFIX-VISUAL-SUMMARY.md +253 -0
  16. package/install/DEPLOYMENT-GUIDE-V2.md +431 -0
  17. package/install/DOCS-INDEX.md +261 -0
  18. package/install/GUIDE-INSTALLATION-BYAN-SIMPLE.md +1083 -0
  19. package/install/INSTALLER-V2-CHANGES.md +472 -0
  20. package/install/LICENSE +21 -0
  21. package/install/PUBLICATION-CHECKLIST.md +265 -0
  22. package/install/PUBLISH-GUIDE.md +190 -0
  23. package/install/QUICKSTART.md +311 -0
  24. package/install/README-NPM-PUBLISH.md +298 -0
  25. package/install/README-NPM-SHORT.md +298 -0
  26. package/install/README-NPM.md +433 -0
  27. package/install/README-RACHID.md +302 -0
  28. package/install/README-V2-INDEX.md +306 -0
  29. package/install/README.md +298 -0
  30. package/install/RESUME-EXECUTIF-YAN.md +408 -0
  31. package/install/UPDATE-SUMMARY.md +205 -0
  32. package/install/__tests__/integration/detection-flow.test.js +154 -0
  33. package/install/__tests__/platforms/claude-code.test.js +175 -0
  34. package/install/__tests__/platforms/codex.test.js +80 -0
  35. package/install/__tests__/platforms/copilot-cli.test.js +118 -0
  36. package/install/__tests__/platforms/vscode.test.js +67 -0
  37. package/install/__tests__/utils/file-utils.test.js +87 -0
  38. package/install/__tests__/utils/git-detector.test.js +80 -0
  39. package/install/__tests__/utils/logger.test.js +83 -0
  40. package/install/__tests__/utils/node-detector.test.js +71 -0
  41. package/install/__tests__/utils/os-detector.test.js +63 -0
  42. package/install/__tests__/utils/yaml-utils.test.js +85 -0
  43. package/install/__tests__/yanstaller/detector.test.js +210 -0
  44. package/install/coverage/clover.xml +219 -0
  45. package/install/coverage/coverage-final.json +13 -0
  46. package/install/coverage/lcov-report/base.css +224 -0
  47. package/install/coverage/lcov-report/block-navigation.js +87 -0
  48. package/install/coverage/lcov-report/favicon.png +0 -0
  49. package/install/coverage/lcov-report/index.html +146 -0
  50. package/install/coverage/lcov-report/lib/errors.js.html +268 -0
  51. package/install/coverage/lcov-report/lib/exit-codes.js.html +247 -0
  52. package/install/coverage/lcov-report/lib/index.html +131 -0
  53. package/install/coverage/lcov-report/lib/platforms/claude-code.js.html +343 -0
  54. package/install/coverage/lcov-report/lib/platforms/codex.js.html +361 -0
  55. package/install/coverage/lcov-report/lib/platforms/copilot-cli.js.html +454 -0
  56. package/install/coverage/lcov-report/lib/platforms/index.html +176 -0
  57. package/install/coverage/lcov-report/lib/platforms/index.js.html +127 -0
  58. package/install/coverage/lcov-report/lib/platforms/vscode.js.html +238 -0
  59. package/install/coverage/lcov-report/lib/utils/config-loader.js.html +322 -0
  60. package/install/coverage/lcov-report/lib/utils/file-utils.js.html +397 -0
  61. package/install/coverage/lcov-report/lib/utils/git-detector.js.html +190 -0
  62. package/install/coverage/lcov-report/lib/utils/index.html +206 -0
  63. package/install/coverage/lcov-report/lib/utils/logger.js.html +277 -0
  64. package/install/coverage/lcov-report/lib/utils/node-detector.js.html +259 -0
  65. package/install/coverage/lcov-report/lib/utils/os-detector.js.html +307 -0
  66. package/install/coverage/lcov-report/lib/utils/yaml-utils.js.html +346 -0
  67. package/install/coverage/lcov-report/lib/yanstaller/backuper.js.html +409 -0
  68. package/install/coverage/lcov-report/lib/yanstaller/detector.js.html +508 -0
  69. package/install/coverage/lcov-report/lib/yanstaller/index.html +236 -0
  70. package/install/coverage/lcov-report/lib/yanstaller/index.js.html +364 -0
  71. package/install/coverage/lcov-report/lib/yanstaller/installer.js.html +505 -0
  72. package/install/coverage/lcov-report/lib/yanstaller/interviewer.js.html +349 -0
  73. package/install/coverage/lcov-report/lib/yanstaller/recommender.js.html +379 -0
  74. package/install/coverage/lcov-report/lib/yanstaller/troubleshooter.js.html +352 -0
  75. package/install/coverage/lcov-report/lib/yanstaller/validator.js.html +679 -0
  76. package/install/coverage/lcov-report/lib/yanstaller/wizard.js.html +412 -0
  77. package/install/coverage/lcov-report/platforms/claude-code.js.html +343 -0
  78. package/install/coverage/lcov-report/platforms/codex.js.html +361 -0
  79. package/install/coverage/lcov-report/platforms/copilot-cli.js.html +454 -0
  80. package/install/coverage/lcov-report/platforms/index.html +176 -0
  81. package/install/coverage/lcov-report/platforms/index.js.html +127 -0
  82. package/install/coverage/lcov-report/platforms/vscode.js.html +238 -0
  83. package/install/coverage/lcov-report/prettify.css +1 -0
  84. package/install/coverage/lcov-report/prettify.js +2 -0
  85. package/install/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  86. package/install/coverage/lcov-report/sorter.js +210 -0
  87. package/install/coverage/lcov-report/utils/file-utils.js.html +397 -0
  88. package/install/coverage/lcov-report/utils/git-detector.js.html +190 -0
  89. package/install/coverage/lcov-report/utils/index.html +191 -0
  90. package/install/coverage/lcov-report/utils/logger.js.html +277 -0
  91. package/install/coverage/lcov-report/utils/node-detector.js.html +259 -0
  92. package/install/coverage/lcov-report/utils/os-detector.js.html +307 -0
  93. package/install/coverage/lcov-report/utils/yaml-utils.js.html +346 -0
  94. package/install/coverage/lcov-report/yanstaller/detector.js.html +508 -0
  95. package/install/coverage/lcov-report/yanstaller/index.html +116 -0
  96. package/install/coverage/lcov.info +414 -0
  97. package/install/install.sh +239 -0
  98. package/install/jest.config.js +33 -0
  99. package/install/lib/errors.js +61 -0
  100. package/install/lib/exit-codes.js +54 -0
  101. package/install/lib/platforms/claude-code.js +86 -0
  102. package/install/lib/platforms/codex.js +92 -0
  103. package/install/lib/platforms/copilot-cli.js +123 -0
  104. package/install/lib/platforms/index.js +14 -0
  105. package/install/lib/platforms/vscode.js +51 -0
  106. package/install/lib/utils/config-loader.js +79 -0
  107. package/install/lib/utils/file-utils.js +104 -0
  108. package/install/lib/utils/git-detector.js +35 -0
  109. package/install/lib/utils/logger.js +64 -0
  110. package/install/lib/utils/node-detector.js +58 -0
  111. package/install/lib/utils/os-detector.js +74 -0
  112. package/install/lib/utils/yaml-utils.js +87 -0
  113. package/install/lib/yanstaller/backuper.js +108 -0
  114. package/install/lib/yanstaller/detector.js +141 -0
  115. package/install/lib/yanstaller/index.js +93 -0
  116. package/install/lib/yanstaller/installer.js +140 -0
  117. package/install/lib/yanstaller/interviewer.js +88 -0
  118. package/install/lib/yanstaller/recommender.js +98 -0
  119. package/install/lib/yanstaller/troubleshooter.js +89 -0
  120. package/install/lib/yanstaller/validator.js +198 -0
  121. package/install/lib/yanstaller/wizard.js +109 -0
  122. package/install/package-npm.json +55 -0
  123. package/install/package.json +63 -0
  124. package/install/src/byan-v2/context/copilot-context.js +79 -0
  125. package/install/src/byan-v2/context/session-state.js +98 -0
  126. package/install/src/byan-v2/dispatcher/complexity-scorer.js +232 -0
  127. package/install/src/byan-v2/dispatcher/local-executor.js +221 -0
  128. package/install/src/byan-v2/dispatcher/task-router.js +122 -0
  129. package/install/src/byan-v2/dispatcher/task-tool-interface-mock.js +134 -0
  130. package/install/src/byan-v2/dispatcher/task-tool-interface.js +123 -0
  131. package/install/src/byan-v2/generation/agent-profile-validator.js +113 -0
  132. package/install/src/byan-v2/generation/profile-template.js +113 -0
  133. package/install/src/byan-v2/generation/templates/default-agent.md +49 -0
  134. package/install/src/byan-v2/generation/templates/test-template.md +1 -0
  135. package/install/src/byan-v2/index.js +199 -0
  136. package/install/src/byan-v2/observability/error-tracker.js +105 -0
  137. package/install/src/byan-v2/observability/logger.js +154 -0
  138. package/install/src/byan-v2/observability/metrics-collector.js +194 -0
  139. package/install/src/byan-v2/orchestrator/analysis-state.js +268 -0
  140. package/install/src/byan-v2/orchestrator/generation-state.js +340 -0
  141. package/install/src/byan-v2/orchestrator/interview-state.js +271 -0
  142. package/install/src/byan-v2/orchestrator/state-machine.js +204 -0
  143. package/install/src/core/cache/cache.js +126 -0
  144. package/install/src/core/context/context.js +86 -0
  145. package/install/src/core/dispatcher/dispatcher.js +135 -0
  146. package/install/src/core/worker-pool/worker-pool.js +194 -0
  147. package/install/src/core/workflow/workflow-executor.js +220 -0
  148. package/install/src/index.js +139 -0
  149. package/install/src/observability/dashboard/dashboard.js +191 -0
  150. package/install/src/observability/logger/structured-logger.js +254 -0
  151. package/install/src/observability/metrics/metrics-collector.js +325 -0
  152. package/install/switch-to-v2.sh +126 -0
  153. package/install/test-chalk-fix.sh +210 -0
  154. package/install/test-installer-v2.sh +204 -0
  155. package/install/test-path-resolution.sh +200 -0
  156. package/package.json +53 -33
  157. package/src/byan-v2/context/copilot-context.js +79 -0
  158. package/src/byan-v2/context/session-state.js +98 -0
  159. package/src/byan-v2/data/mantras.json +852 -0
  160. package/src/byan-v2/dispatcher/complexity-scorer.js +232 -0
  161. package/src/byan-v2/dispatcher/five-whys-analyzer.js +310 -0
  162. package/src/byan-v2/dispatcher/local-executor.js +221 -0
  163. package/src/byan-v2/dispatcher/task-router.js +122 -0
  164. package/src/byan-v2/dispatcher/task-tool-interface-mock.js +134 -0
  165. package/src/byan-v2/dispatcher/task-tool-interface.js +123 -0
  166. package/src/byan-v2/generation/agent-profile-validator.js +113 -0
  167. package/src/byan-v2/generation/mantra-validator.js +416 -0
  168. package/src/byan-v2/generation/profile-template.js +113 -0
  169. package/src/byan-v2/generation/templates/default-agent.md +49 -0
  170. package/src/byan-v2/generation/templates/test-template.md +1 -0
  171. package/src/byan-v2/index.js +652 -0
  172. package/src/byan-v2/integration/voice-integration.js +295 -0
  173. package/src/byan-v2/observability/error-tracker.js +105 -0
  174. package/src/byan-v2/observability/logger.js +154 -0
  175. package/src/byan-v2/observability/metrics-collector.js +194 -0
  176. package/src/byan-v2/orchestrator/active-listener.js +541 -0
  177. package/src/byan-v2/orchestrator/analysis-state.js +268 -0
  178. package/src/byan-v2/orchestrator/generation-state.js +340 -0
  179. package/src/byan-v2/orchestrator/glossary-builder.js +431 -0
  180. package/src/byan-v2/orchestrator/interview-state.js +353 -0
  181. package/src/byan-v2/orchestrator/state-machine.js +253 -0
  182. package/src/core/cache/cache.js +126 -0
  183. package/src/core/context/context.js +86 -0
  184. package/src/core/dispatcher/dispatcher.js +135 -0
  185. package/src/core/worker-pool/worker-pool.js +194 -0
  186. package/src/core/workflow/workflow-executor.js +220 -0
  187. package/src/index.js +139 -0
  188. package/src/observability/dashboard/dashboard.js +191 -0
  189. package/src/observability/logger/structured-logger.js +254 -0
  190. package/src/observability/metrics/metrics-collector.js +325 -0
  191. package/templates/.github/agents/bmad-agent-test-dynamic.md +0 -21
  192. package/templates/.github/agents/franck.md +0 -379
  193. /package/{CHANGELOG.md → install/CHANGELOG.md} +0 -0
  194. /package/{bin → install/bin}/create-byan-agent-backup.js +0 -0
  195. /package/{bin → install/bin}/create-byan-agent-fixed.js +0 -0
  196. /package/{bin → install/bin}/create-byan-agent-v2.js +0 -0
  197. /package/{bin → install/bin}/create-byan-agent.js +0 -0
  198. /package/{templates → install/templates}/.github/agents/bmad-agent-bmad-master.md +0 -0
  199. /package/{templates → install/templates}/.github/agents/bmad-agent-bmb-agent-builder.md +0 -0
  200. /package/{templates → install/templates}/.github/agents/bmad-agent-bmb-module-builder.md +0 -0
  201. /package/{templates → install/templates}/.github/agents/bmad-agent-bmb-workflow-builder.md +0 -0
  202. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-analyst.md +0 -0
  203. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-architect.md +0 -0
  204. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-dev.md +0 -0
  205. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-pm.md +0 -0
  206. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-quick-flow-solo-dev.md +0 -0
  207. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-quinn.md +0 -0
  208. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-sm.md +0 -0
  209. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-tech-writer.md +0 -0
  210. /package/{templates → install/templates}/.github/agents/bmad-agent-bmm-ux-designer.md +0 -0
  211. /package/{templates → install/templates}/.github/agents/bmad-agent-byan-test.md +0 -0
  212. /package/{templates → install/templates}/.github/agents/bmad-agent-byan.md +0 -0
  213. /package/{templates → install/templates}/.github/agents/bmad-agent-carmack.md +0 -0
  214. /package/{templates → install/templates}/.github/agents/bmad-agent-cis-brainstorming-coach.md +0 -0
  215. /package/{templates → install/templates}/.github/agents/bmad-agent-cis-creative-problem-solver.md +0 -0
  216. /package/{templates → install/templates}/.github/agents/bmad-agent-cis-design-thinking-coach.md +0 -0
  217. /package/{templates → install/templates}/.github/agents/bmad-agent-cis-innovation-strategist.md +0 -0
  218. /package/{templates → install/templates}/.github/agents/bmad-agent-cis-presentation-master.md +0 -0
  219. /package/{templates → install/templates}/.github/agents/bmad-agent-cis-storyteller.md +0 -0
  220. /package/{templates → install/templates}/.github/agents/bmad-agent-marc.md +0 -0
  221. /package/{templates → install/templates}/.github/agents/bmad-agent-patnote.md +0 -0
  222. /package/{templates → install/templates}/.github/agents/bmad-agent-rachid.md +0 -0
  223. /package/{templates → install/templates}/.github/agents/bmad-agent-tea-tea.md +0 -0
  224. /package/{templates → install/templates}/_bmad/bmb/agents/agent-builder.md +0 -0
  225. /package/{templates → install/templates}/_bmad/bmb/agents/byan-test.md +0 -0
  226. /package/{templates → install/templates}/_bmad/bmb/agents/byan.md +0 -0
  227. /package/{templates → install/templates}/_bmad/bmb/agents/marc.md +0 -0
  228. /package/{templates → install/templates}/_bmad/bmb/agents/module-builder.md +0 -0
  229. /package/{templates → install/templates}/_bmad/bmb/agents/patnote.md +0 -0
  230. /package/{templates → install/templates}/_bmad/bmb/agents/rachid.md +0 -0
  231. /package/{templates → install/templates}/_bmad/bmb/agents/workflow-builder.md +0 -0
  232. /package/{templates → install/templates}/_bmad/bmb/workflows/byan/data/mantras.yaml +0 -0
  233. /package/{templates → install/templates}/_bmad/bmb/workflows/byan/data/templates.yaml +0 -0
  234. /package/{templates → install/templates}/_bmad/bmb/workflows/byan/delete-agent-workflow.md +0 -0
  235. /package/{templates → install/templates}/_bmad/bmb/workflows/byan/edit-agent-workflow.md +0 -0
  236. /package/{templates → install/templates}/_bmad/bmb/workflows/byan/interview-workflow.md +0 -0
  237. /package/{templates → install/templates}/_bmad/bmb/workflows/byan/quick-create-workflow.md +0 -0
  238. /package/{templates → install/templates}/_bmad/bmb/workflows/byan/templates/base-agent-template.md +0 -0
  239. /package/{templates → install/templates}/_bmad/bmb/workflows/byan/validate-agent-workflow.md +0 -0
  240. /package/{templates → install/templates}/_bmad/core/agents/carmack.md +0 -0
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Logger Utility
3
+ *
4
+ * Wrapper around chalk and console for colored logging.
5
+ *
6
+ * @module utils/logger
7
+ */
8
+
9
+ const chalk = require('chalk');
10
+
11
+ /**
12
+ * Log info message
13
+ *
14
+ * @param {string} message - Message to log
15
+ */
16
+ function info(message) {
17
+ console.log(chalk.blue('ℹ'), message);
18
+ }
19
+
20
+ /**
21
+ * Log success message
22
+ *
23
+ * @param {string} message - Message to log
24
+ */
25
+ function success(message) {
26
+ console.log(chalk.green('✓'), message);
27
+ }
28
+
29
+ /**
30
+ * Log warning message
31
+ *
32
+ * @param {string} message - Message to log
33
+ */
34
+ function warn(message) {
35
+ console.log(chalk.yellow('⚠'), message);
36
+ }
37
+
38
+ /**
39
+ * Log error message
40
+ *
41
+ * @param {string} message - Message to log
42
+ */
43
+ function error(message) {
44
+ console.error(chalk.red('✖'), message);
45
+ }
46
+
47
+ /**
48
+ * Log debug message (only if DEBUG env var set)
49
+ *
50
+ * @param {string} message - Message to log
51
+ */
52
+ function debug(message) {
53
+ if (process.env.DEBUG) {
54
+ console.log(chalk.gray('[DEBUG]'), message);
55
+ }
56
+ }
57
+
58
+ module.exports = {
59
+ info,
60
+ success,
61
+ warn,
62
+ error,
63
+ debug
64
+ };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Node.js Detector Utility
3
+ *
4
+ * Detects Node.js version.
5
+ *
6
+ * @module utils/node-detector
7
+ */
8
+
9
+ /**
10
+ * Detect Node.js version
11
+ *
12
+ * @returns {string} - Version string (e.g., '18.19.0')
13
+ */
14
+ function detect() {
15
+ return process.version.slice(1); // Remove 'v' prefix
16
+ }
17
+
18
+ /**
19
+ * Compare two semver versions
20
+ *
21
+ * Strips version suffixes (-beta, -rc1, etc.) before comparison.
22
+ *
23
+ * @param {string} version1 - First version
24
+ * @param {string} version2 - Second version
25
+ * @returns {number} - -1 if v1 < v2, 0 if equal, 1 if v1 > v2
26
+ */
27
+ function compareVersions(version1, version2) {
28
+ // Strip suffixes: '18.0.0-beta' → '18.0.0'
29
+ const cleanV1 = version1.replace(/-.*$/, '');
30
+ const cleanV2 = version2.replace(/-.*$/, '');
31
+
32
+ const v1Parts = cleanV1.split('.').map(Number);
33
+ const v2Parts = cleanV2.split('.').map(Number);
34
+
35
+ for (let i = 0; i < 3; i++) {
36
+ if (v1Parts[i] > v2Parts[i]) return 1;
37
+ if (v1Parts[i] < v2Parts[i]) return -1;
38
+ }
39
+
40
+ return 0;
41
+ }
42
+
43
+ /**
44
+ * Check if Node version meets minimum requirement
45
+ *
46
+ * @param {string} currentVersion - Current Node version
47
+ * @param {string} requiredVersion - Required Node version
48
+ * @returns {boolean}
49
+ */
50
+ function meetsRequirement(currentVersion, requiredVersion) {
51
+ return compareVersions(currentVersion, requiredVersion) >= 0;
52
+ }
53
+
54
+ module.exports = {
55
+ detect,
56
+ compareVersions,
57
+ meetsRequirement
58
+ };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * OS Detector Utility
3
+ *
4
+ * Detects operating system and version.
5
+ *
6
+ * @module utils/os-detector
7
+ */
8
+
9
+ const os = require('os');
10
+
11
+ /**
12
+ * Detect operating system
13
+ *
14
+ * @returns {{name: string, version: string, platform: string}}
15
+ */
16
+ function detect() {
17
+ const platform = os.platform();
18
+ const release = os.release();
19
+
20
+ let name;
21
+ switch (platform) {
22
+ case 'win32':
23
+ name = 'windows';
24
+ break;
25
+ case 'darwin':
26
+ name = 'macos';
27
+ break;
28
+ case 'linux':
29
+ name = 'linux';
30
+ break;
31
+ default:
32
+ name = 'unknown';
33
+ }
34
+
35
+ return {
36
+ name,
37
+ version: release,
38
+ platform
39
+ };
40
+ }
41
+
42
+ /**
43
+ * Check if running on Windows
44
+ *
45
+ * @returns {boolean}
46
+ */
47
+ function isWindows() {
48
+ return os.platform() === 'win32';
49
+ }
50
+
51
+ /**
52
+ * Check if running on macOS
53
+ *
54
+ * @returns {boolean}
55
+ */
56
+ function isMacOS() {
57
+ return os.platform() === 'darwin';
58
+ }
59
+
60
+ /**
61
+ * Check if running on Linux
62
+ *
63
+ * @returns {boolean}
64
+ */
65
+ function isLinux() {
66
+ return os.platform() === 'linux';
67
+ }
68
+
69
+ module.exports = {
70
+ detect,
71
+ isWindows,
72
+ isMacOS,
73
+ isLinux
74
+ };
@@ -0,0 +1,87 @@
1
+ /**
2
+ * YAML Utilities
3
+ *
4
+ * Wrapper around js-yaml for YAML parsing/dumping.
5
+ *
6
+ * @module utils/yaml-utils
7
+ */
8
+
9
+ const yaml = require('js-yaml');
10
+ const fileUtils = require('./file-utils');
11
+
12
+ /**
13
+ * Parse YAML string
14
+ *
15
+ * @param {string} yamlString - YAML string
16
+ * @returns {Object}
17
+ */
18
+ function parse(yamlString) {
19
+ return yaml.load(yamlString);
20
+ }
21
+
22
+ /**
23
+ * Dump object to YAML string
24
+ *
25
+ * @param {Object} obj - Object to dump
26
+ * @returns {string}
27
+ */
28
+ function dump(obj) {
29
+ return yaml.dump(obj, {
30
+ indent: 2,
31
+ lineWidth: -1
32
+ });
33
+ }
34
+
35
+ /**
36
+ * Read YAML file
37
+ *
38
+ * @param {string} filePath - YAML file path
39
+ * @returns {Promise<Object>}
40
+ */
41
+ async function readYAML(filePath) {
42
+ const content = await fileUtils.readFile(filePath);
43
+ return parse(content);
44
+ }
45
+
46
+ /**
47
+ * Write YAML file
48
+ *
49
+ * @param {string} filePath - YAML file path
50
+ * @param {Object} data - Data to write
51
+ * @returns {Promise<void>}
52
+ */
53
+ async function writeYAML(filePath, data) {
54
+ const yamlString = dump(data);
55
+ await fileUtils.writeFile(filePath, yamlString);
56
+ }
57
+
58
+ /**
59
+ * Extract YAML frontmatter from markdown
60
+ *
61
+ * @param {string} markdownContent - Markdown content
62
+ * @returns {{frontmatter: Object | null, content: string}}
63
+ */
64
+ function extractFrontmatter(markdownContent) {
65
+ const frontmatterRegex = /^---\n([\s\S]+?)\n---\n([\s\S]*)$/;
66
+ const match = markdownContent.match(frontmatterRegex);
67
+
68
+ if (!match) {
69
+ return {
70
+ frontmatter: null,
71
+ content: markdownContent
72
+ };
73
+ }
74
+
75
+ return {
76
+ frontmatter: parse(match[1]),
77
+ content: match[2]
78
+ };
79
+ }
80
+
81
+ module.exports = {
82
+ parse,
83
+ dump,
84
+ readYAML,
85
+ writeYAML,
86
+ extractFrontmatter
87
+ };
@@ -0,0 +1,108 @@
1
+ /**
2
+ * BACKUPER Module
3
+ *
4
+ * Backs up and restores _bmad/ directory.
5
+ *
6
+ * Phase 6: 24h development
7
+ *
8
+ * @module yanstaller/backuper
9
+ */
10
+
11
+ const path = require('path');
12
+ const fileUtils = require('../utils/file-utils');
13
+
14
+ /**
15
+ * @typedef {Object} BackupResult
16
+ * @property {boolean} success
17
+ * @property {string} backupPath - Path to backup directory
18
+ * @property {number} filesBackedUp
19
+ * @property {number} size - Backup size in bytes
20
+ */
21
+
22
+ /**
23
+ * Backup _bmad/ directory
24
+ *
25
+ * @param {string} bmadPath - Path to _bmad/ directory
26
+ * @returns {Promise<BackupResult>}
27
+ */
28
+ async function backup(bmadPath) {
29
+ const timestamp = Date.now();
30
+ const backupPath = `${bmadPath}.backup-${timestamp}`;
31
+
32
+ try {
33
+ // TODO: Copy entire _bmad/ to backup path
34
+ // await fileUtils.copy(bmadPath, backupPath);
35
+
36
+ return {
37
+ success: true,
38
+ backupPath,
39
+ filesBackedUp: 0,
40
+ size: 0
41
+ };
42
+ } catch (error) {
43
+ throw new BackupError(`Failed to backup ${bmadPath}`, { cause: error });
44
+ }
45
+ }
46
+
47
+ /**
48
+ * Restore from backup
49
+ *
50
+ * @param {string} backupPath - Path to backup directory
51
+ * @param {string} targetPath - Target restoration path
52
+ * @returns {Promise<void>}
53
+ */
54
+ async function restore(backupPath, targetPath) {
55
+ // TODO: Remove current _bmad/, copy backup to target
56
+ // await fileUtils.remove(targetPath);
57
+ // await fileUtils.copy(backupPath, targetPath);
58
+ }
59
+
60
+ /**
61
+ * List available backups
62
+ *
63
+ * @param {string} projectRoot - Project root directory
64
+ * @returns {Promise<string[]>} - Array of backup paths
65
+ */
66
+ async function listBackups(projectRoot) {
67
+ // TODO: Find all _bmad.backup-* directories
68
+ return [];
69
+ }
70
+
71
+ /**
72
+ * Clean old backups (keep last N)
73
+ *
74
+ * @param {string} projectRoot - Project root directory
75
+ * @param {number} keep - Number of backups to keep
76
+ * @returns {Promise<number>} - Number of backups deleted
77
+ */
78
+ async function cleanOldBackups(projectRoot, keep = 3) {
79
+ // TODO: Sort by timestamp, delete oldest
80
+ return 0;
81
+ }
82
+
83
+ /**
84
+ * Get backup size
85
+ *
86
+ * @param {string} backupPath - Path to backup directory
87
+ * @returns {Promise<number>} - Size in bytes
88
+ */
89
+ async function getBackupSize(backupPath) {
90
+ // TODO: Recursively calculate directory size
91
+ return 0;
92
+ }
93
+
94
+ class BackupError extends Error {
95
+ constructor(message, options) {
96
+ super(message, options);
97
+ this.name = 'BackupError';
98
+ }
99
+ }
100
+
101
+ module.exports = {
102
+ backup,
103
+ restore,
104
+ listBackups,
105
+ cleanOldBackups,
106
+ getBackupSize,
107
+ BackupError
108
+ };
@@ -0,0 +1,141 @@
1
+ /**
2
+ * DETECTOR Module
3
+ *
4
+ * Detects OS, Node.js version, Git, and installed platforms.
5
+ *
6
+ * Phase 1: 40h development
7
+ *
8
+ * @module yanstaller/detector
9
+ */
10
+
11
+ const osDetector = require('../utils/os-detector');
12
+ const nodeDetector = require('../utils/node-detector');
13
+ const gitDetector = require('../utils/git-detector');
14
+ const platforms = require('../platforms');
15
+
16
+ /**
17
+ * @typedef {Object} DetectionResult
18
+ * @property {string} os - 'windows' | 'linux' | 'macos'
19
+ * @property {string} osVersion - e.g., '11' for Windows 11
20
+ * @property {string} nodeVersion - e.g., '18.19.0'
21
+ * @property {boolean} hasGit
22
+ * @property {string} [gitVersion] - e.g., '2.43.0'
23
+ * @property {PlatformInfo[]} platforms - Detected platforms
24
+ */
25
+
26
+ /**
27
+ * @typedef {Object} PlatformInfo
28
+ * @property {string} name - 'copilot-cli' | 'vscode' | 'claude' | 'codex'
29
+ * @property {boolean} detected
30
+ * @property {string} [path] - Installation path if detected
31
+ * @property {string} [version] - Version if detected
32
+ */
33
+
34
+ const logger = require('../utils/logger');
35
+
36
+ /**
37
+ * Detect full environment
38
+ *
39
+ * Runs parallel detection for speed.
40
+ * Non-blocking: platform detection failures are caught and logged.
41
+ *
42
+ * @returns {Promise<DetectionResult>}
43
+ */
44
+ async function detect() {
45
+ // Parallel detection for speed (Mantra #7 KISS)
46
+ const [osInfo, nodeVersion, gitInfo] = await Promise.all([
47
+ osDetector.detect(),
48
+ Promise.resolve(nodeDetector.detect()), // Sync wrapped in Promise
49
+ gitDetector.detect()
50
+ ]);
51
+
52
+ // Platform detection with timeout protection
53
+ const platformNames = ['copilot-cli', 'vscode', 'claude', 'codex'];
54
+ const platformsInfo = await Promise.all(
55
+ platformNames.map(name => detectPlatform(name))
56
+ );
57
+
58
+ // Check if ALL platforms failed
59
+ const allFailed = platformsInfo.every(p => !p.detected);
60
+ if (allFailed) {
61
+ const errors = platformsInfo
62
+ .filter(p => p.error)
63
+ .map(p => `${p.name}: ${p.error}`)
64
+ .join(', ');
65
+ if (errors) {
66
+ logger.warn(`0/4 platforms detected. Errors: [${errors}]`);
67
+ }
68
+ }
69
+
70
+ return {
71
+ os: osInfo.name,
72
+ osVersion: osInfo.version,
73
+ nodeVersion,
74
+ hasGit: gitInfo.installed,
75
+ gitVersion: gitInfo.version,
76
+ platforms: platformsInfo
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Check if Node.js version meets minimum requirement
82
+ *
83
+ * Handles version suffixes (-beta, -rc1) by stripping them.
84
+ *
85
+ * @param {string} currentVersion - e.g., '18.19.0'
86
+ * @param {string} requiredVersion - e.g., '18.0.0'
87
+ * @returns {boolean}
88
+ */
89
+ function isNodeVersionValid(currentVersion, requiredVersion) {
90
+ return nodeDetector.meetsRequirement(currentVersion, requiredVersion);
91
+ }
92
+
93
+ /**
94
+ * Detect specific platform
95
+ *
96
+ * Non-blocking: errors are caught and returned in result.
97
+ *
98
+ * @param {string} platformName - 'copilot-cli' | 'vscode' | 'claude' | 'codex'
99
+ * @returns {Promise<PlatformInfo>}
100
+ */
101
+ async function detectPlatform(platformName) {
102
+ const platform = platforms[platformName];
103
+ if (!platform) {
104
+ throw new Error(`Unknown platform: ${platformName}`);
105
+ }
106
+
107
+ try {
108
+ const detected = await platform.detect();
109
+
110
+ // Handle timeout response format (object with detected + error)
111
+ if (typeof detected === 'object' && 'error' in detected) {
112
+ logger.warn(`Platform ${platformName} detection failed: ${detected.error}`);
113
+ return {
114
+ name: platformName,
115
+ detected: false,
116
+ error: detected.error
117
+ };
118
+ }
119
+
120
+ return {
121
+ name: platformName,
122
+ detected: !!detected,
123
+ path: detected ? platform.getPath() : undefined
124
+ };
125
+ } catch (error) {
126
+ // Non-blocking: platform detection failure shouldn't crash detection
127
+ // Error UX: Log warning and include in report for user visibility
128
+ logger.warn(`Platform ${platformName} detection failed: ${error.message}`);
129
+ return {
130
+ name: platformName,
131
+ detected: false,
132
+ error: error.message
133
+ };
134
+ }
135
+ }
136
+
137
+ module.exports = {
138
+ detect,
139
+ isNodeVersionValid,
140
+ detectPlatform
141
+ };
@@ -0,0 +1,93 @@
1
+ /**
2
+ * YANSTALLER - Main Orchestrator
3
+ *
4
+ * Coordinates all YANSTALLER modules to perform intelligent BYAN installation.
5
+ *
6
+ * @module yanstaller
7
+ */
8
+
9
+ const detector = require('./detector');
10
+ const recommender = require('./recommender');
11
+ const installer = require('./installer');
12
+ const validator = require('./validator');
13
+ const troubleshooter = require('./troubleshooter');
14
+ const interviewer = require('./interviewer');
15
+ const backuper = require('./backuper');
16
+ const wizard = require('./wizard');
17
+ const logger = require('../utils/logger');
18
+
19
+ /**
20
+ * @typedef {Object} YanInstallerOptions
21
+ * @property {boolean} [yes] - Skip confirmations (--yes flag)
22
+ * @property {string} [mode] - Installation mode: 'full' | 'minimal' | 'custom'
23
+ * @property {boolean} [verbose] - Verbose output
24
+ * @property {boolean} [quiet] - Minimal output
25
+ */
26
+
27
+ /**
28
+ * Main installation flow
29
+ *
30
+ * @param {YanInstallerOptions} [options={}] - Installation options
31
+ * @returns {Promise<void>}
32
+ */
33
+ async function install(options = {}) {
34
+ let backupPath = null;
35
+
36
+ try {
37
+ // TODO: Implement Phase 1-8 orchestration
38
+ // 1. Detect environment
39
+ // 2. Validate Node version (FAIL FAST)
40
+ // 3. Recommend configuration
41
+ // 4. Run interview (unless --yes)
42
+ // 5. Backup existing installation
43
+ // backupPath = await backuper.backup('_bmad');
44
+ // 6. Install agents
45
+ // 7. Validate installation
46
+ // 8. Show post-install wizard
47
+ } catch (error) {
48
+ // ROLLBACK STRATEGY: Leave partial state + clear message
49
+ // Rationale (Mantra #37 Ockham's Razor):
50
+ // - Installation = mostly file copies (low risk)
51
+ // - User can re-run (idempotent)
52
+ // - Backup exists for manual restore
53
+ // - Auto-rollback risks losing working partial install
54
+
55
+ logger.error('Installation failed:', error.message);
56
+
57
+ if (backupPath) {
58
+ logger.info('\nPartial installation completed.');
59
+ logger.info(`Backup available at: ${backupPath}`);
60
+ logger.info('\nOptions:');
61
+ logger.info('1. Re-run: npx create-byan-agent');
62
+ logger.info(`2. Restore backup: yanstaller restore ${backupPath}`);
63
+ logger.info('3. Troubleshoot: yanstaller doctor');
64
+ }
65
+
66
+ throw error; // Re-throw for exit code handling
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Uninstall BYAN
72
+ *
73
+ * @returns {Promise<void>}
74
+ */
75
+ async function uninstall() {
76
+ // TODO: Remove _bmad/, .github/agents/ stubs
77
+ }
78
+
79
+ /**
80
+ * Update existing BYAN installation
81
+ *
82
+ * @param {string} version - Target version
83
+ * @returns {Promise<void>}
84
+ */
85
+ async function update(version) {
86
+ // TODO: Backup → Update agents → Merge configs
87
+ }
88
+
89
+ module.exports = {
90
+ install,
91
+ uninstall,
92
+ update
93
+ };