diff --git a/package-lock.json b/package-lock.json index 748fd0255..9f0ce7e21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,20 +12,15 @@ "@clack/core": "^1.0.0", "@clack/prompts": "^1.0.0", "@kayvan/markdown-tree-parser": "^1.6.1", - "boxen": "^5.1.2", "chalk": "^4.1.2", - "cli-table3": "^0.6.5", "commander": "^14.0.0", "csv-parse": "^6.1.0", - "figlet": "^1.8.0", "fs-extra": "^11.3.0", "glob": "^11.0.3", "ignore": "^7.0.5", "js-yaml": "^4.1.0", - "ora": "^5.4.1", "picocolors": "^1.1.1", "semver": "^7.6.3", - "wrap-ansi": "^7.0.0", "xml2js": "^0.6.2", "yaml": "^2.7.0" }, @@ -777,16 +772,6 @@ "sisteransi": "^1.0.5" } }, - "node_modules/@colors/colors": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.5.0.tgz", - "integrity": "sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==", - "license": "MIT", - "optional": true, - "engines": { - "node": ">=0.1.90" - } - }, "node_modules/@ctrl/tinycolor": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/@ctrl/tinycolor/-/tinycolor-4.2.0.tgz", @@ -2029,9 +2014,9 @@ } }, "node_modules/@isaacs/brace-expansion": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.1.tgz", - "integrity": "sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", + "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", "license": "MIT", "dependencies": { "@isaacs/balanced-match": "^4.0.1" @@ -3993,6 +3978,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/ansi-align/-/ansi-align-3.0.1.tgz", "integrity": "sha512-IOfwwBF5iczOjp/WeY4YxyjqAFMQoZufdQWDd19SEExbVLNXqvpzSJ/M7Za4/sCPmQ0+GRquoA7bGcINcxew6w==", + "dev": true, "license": "ISC", "dependencies": { "string-width": "^4.1.0" @@ -4985,26 +4971,6 @@ "dev": true, "license": "MIT" }, - "node_modules/base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/baseline-browser-mapping": { "version": "2.9.19", "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.9.19.tgz", @@ -5042,59 +5008,12 @@ "url": "https://github.com/sponsors/wooorm" } }, - "node_modules/bl": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "license": "MIT", - "dependencies": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - } - }, - "node_modules/bl/node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", "license": "ISC" }, - "node_modules/boxen": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/boxen/-/boxen-5.1.2.tgz", - "integrity": "sha512-9gYgQKXx+1nP8mP7CzFyaUARhg7D3n1dF/FnErWmu9l6JvGpNUN278h0aSb+QjoiKSWG+iZ3uHrcqk0qrY9RQQ==", - "license": "MIT", - "dependencies": { - "ansi-align": "^3.0.0", - "camelcase": "^6.2.0", - "chalk": "^4.1.0", - "cli-boxes": "^2.2.1", - "string-width": "^4.2.2", - "type-fest": "^0.20.2", - "widest-line": "^3.1.0", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/brace-expansion": { "version": "1.1.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", @@ -5163,30 +5082,6 @@ "node-int64": "^0.4.0" } }, - "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, "node_modules/buffer-from": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", @@ -5255,6 +5150,7 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -5433,18 +5329,6 @@ "node": ">=0.8.0" } }, - "node_modules/cli-boxes": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.1.tgz", - "integrity": "sha512-y4coMcylgSCdVinjiDBuR8PCC2bLjyGTwEmPb9NHR/QaNU6EUOXcTY/s6VjGMD6ENSEaeQYHCY0GNGS5jfMwPw==", - "license": "MIT", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/cli-cursor": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", @@ -5461,33 +5345,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cli-spinners": { - "version": "2.9.2", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", - "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", - "license": "MIT", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/cli-table3": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.6.5.tgz", - "integrity": "sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==", - "license": "MIT", - "dependencies": { - "string-width": "^4.2.0" - }, - "engines": { - "node": "10.* || >= 12.*" - }, - "optionalDependencies": { - "@colors/colors": "1.5.0" - } - }, "node_modules/cli-truncate": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-5.1.1.tgz", @@ -5560,15 +5417,6 @@ "node": ">=8" } }, - "node_modules/clone": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", - "license": "MIT", - "engines": { - "node": ">=0.8" - } - }, "node_modules/clsx": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", @@ -5942,18 +5790,6 @@ "node": ">=0.10.0" } }, - "node_modules/defaults": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", - "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", - "license": "MIT", - "dependencies": { - "clone": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/defu": { "version": "6.1.4", "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", @@ -7034,21 +6870,6 @@ } } }, - "node_modules/figlet": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/figlet/-/figlet-1.10.0.tgz", - "integrity": "sha512-aktIwEZZ6Gp9AWdMXW4YCi0J2Ahuxo67fNJRUIWD81w8pQ0t9TS8FFpbl27ChlTLF06VkwjDesZSzEVzN75rzA==", - "license": "MIT", - "dependencies": { - "commander": "^14.0.0" - }, - "bin": { - "figlet": "bin/index.js" - }, - "engines": { - "node": ">= 17.0.0" - } - }, "node_modules/file-entry-cache": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", @@ -7906,26 +7727,6 @@ "@babel/runtime": "^7.23.2" } }, - "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "BSD-3-Clause" - }, "node_modules/ignore": { "version": "7.0.5", "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz", @@ -8022,6 +7823,7 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, "license": "ISC" }, "node_modules/ini": { @@ -8206,15 +8008,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-interactive": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", - "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -8250,18 +8043,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "license": "MIT", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-wsl": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz", @@ -9523,22 +9304,6 @@ "dev": true, "license": "MIT" }, - "node_modules/log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "license": "MIT", - "dependencies": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/log-update": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/log-update/-/log-update-6.1.0.tgz", @@ -10985,6 +10750,7 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -11296,6 +11062,7 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, "license": "MIT", "dependencies": { "mimic-fn": "^2.1.0" @@ -11344,81 +11111,6 @@ "node": ">= 0.8.0" } }, - "node_modules/ora": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", - "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", - "license": "MIT", - "dependencies": { - "bl": "^4.1.0", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-spinners": "^2.5.0", - "is-interactive": "^1.0.0", - "is-unicode-supported": "^0.1.0", - "log-symbols": "^4.1.0", - "strip-ansi": "^6.0.0", - "wcwidth": "^1.0.1" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/ora/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "license": "MIT", - "engines": { - "node": ">=8" - } - }, - "node_modules/ora/node_modules/cli-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", - "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", - "license": "MIT", - "dependencies": { - "restore-cursor": "^3.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/ora/node_modules/restore-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", - "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", - "license": "MIT", - "dependencies": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/ora/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "license": "ISC" - }, - "node_modules/ora/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "license": "MIT", - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/p-limit": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-6.2.0.tgz", @@ -12726,26 +12418,6 @@ "queue-microtask": "^1.2.2" } }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, "node_modules/sax": { "version": "1.4.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.4.tgz", @@ -13098,15 +12770,6 @@ "dev": true, "license": "MIT" }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, "node_modules/string-argv": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", @@ -13691,18 +13354,6 @@ "node": ">=4" } }, - "node_modules/type-fest": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", - "license": "(MIT OR CC0-1.0)", - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/uc.micro": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-2.1.0.tgz", @@ -14152,6 +13803,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, "license": "MIT" }, "node_modules/v8-to-istanbul": { @@ -14317,15 +13969,6 @@ "makeerror": "1.0.12" } }, - "node_modules/wcwidth": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", - "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", - "license": "MIT", - "dependencies": { - "defaults": "^1.0.3" - } - }, "node_modules/web-namespaces": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz", @@ -14362,18 +14005,6 @@ "node": ">=4" } }, - "node_modules/widest-line": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-3.1.0.tgz", - "integrity": "sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==", - "license": "MIT", - "dependencies": { - "string-width": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -14388,6 +14019,7 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", @@ -14444,6 +14076,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -14453,6 +14086,7 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" diff --git a/package.json b/package.json index 8102b499c..54d9646a0 100644 --- a/package.json +++ b/package.json @@ -68,20 +68,15 @@ "@clack/core": "^1.0.0", "@clack/prompts": "^1.0.0", "@kayvan/markdown-tree-parser": "^1.6.1", - "boxen": "^5.1.2", "chalk": "^4.1.2", - "cli-table3": "^0.6.5", "commander": "^14.0.0", "csv-parse": "^6.1.0", - "figlet": "^1.8.0", "fs-extra": "^11.3.0", "glob": "^11.0.3", "ignore": "^7.0.5", "js-yaml": "^4.1.0", - "ora": "^5.4.1", "picocolors": "^1.1.1", "semver": "^7.6.3", - "wrap-ansi": "^7.0.0", "xml2js": "^0.6.2", "yaml": "^2.7.0" }, diff --git a/tools/cli/bmad-cli.js b/tools/cli/bmad-cli.js index 2a5b8d387..bcd599293 100755 --- a/tools/cli/bmad-cli.js +++ b/tools/cli/bmad-cli.js @@ -2,6 +2,14 @@ const { program } = require('commander'); const path = require('node:path'); const fs = require('node:fs'); const { execSync } = require('node:child_process'); +const prompts = require('./lib/prompts'); + +// The installer flow uses many sequential @clack/prompts, each adding keypress +// listeners to stdin. Raise the limit to avoid spurious EventEmitter warnings. +if (process.stdin?.setMaxListeners) { + const currentLimit = process.stdin.getMaxListeners(); + process.stdin.setMaxListeners(Math.max(currentLimit, 50)); +} // Check for updates - do this asynchronously so it doesn't block startup const packageJson = require('../../package.json'); @@ -27,17 +35,17 @@ async function checkForUpdate() { }).trim(); if (result && result !== packageJson.version) { - console.warn(''); - console.warn(' ╔═══════════════════════════════════════════════════════════════════════════════╗'); - console.warn(' ║ UPDATE AVAILABLE ║'); - console.warn(' ║ ║'); - console.warn(` ║ You are using version ${packageJson.version} but ${result} is available. ║`); - console.warn(' ║ ║'); - console.warn(' ║ To update,exir and first run: ║'); - console.warn(` ║ npm cache clean --force && npx bmad-method@${tag} install ║`); - console.warn(' ║ ║'); - console.warn(' ╚═══════════════════════════════════════════════════════════════════════════════╝'); - console.warn(''); + const color = await prompts.getColor(); + const updateMsg = [ + `You are using version ${packageJson.version} but ${result} is available.`, + '', + 'To update, exit and first run:', + ` npm cache clean --force && npx bmad-method@${tag} install`, + ].join('\n'); + await prompts.box(updateMsg, 'Update Available', { + rounded: true, + formatBorder: color.yellow, + }); } } catch { // Silently fail - network issues or npm not available diff --git a/tools/cli/commands/install.js b/tools/cli/commands/install.js index 6a6622d1d..961a1a9fa 100644 --- a/tools/cli/commands/install.js +++ b/tools/cli/commands/install.js @@ -1,5 +1,5 @@ -const chalk = require('chalk'); const path = require('node:path'); +const prompts = require('../lib/prompts'); const { Installer } = require('../installers/lib/core/installer'); const { UI } = require('../lib/ui'); @@ -30,14 +30,14 @@ module.exports = { // Set debug flag as environment variable for all components if (options.debug) { process.env.BMAD_DEBUG_MANIFEST = 'true'; - console.log(chalk.cyan('Debug mode enabled\n')); + await prompts.log.info('Debug mode enabled'); } const config = await ui.promptInstall(options); // Handle cancel if (config.actionType === 'cancel') { - console.log(chalk.yellow('Installation cancelled.')); + await prompts.log.warn('Installation cancelled.'); process.exit(0); return; } @@ -45,13 +45,13 @@ module.exports = { // Handle quick update separately if (config.actionType === 'quick-update') { const result = await installer.quickUpdate(config); - console.log(chalk.green('\n✨ Quick update complete!')); - console.log(chalk.cyan(`Updated ${result.moduleCount} modules with preserved settings (${result.modules.join(', ')})`)); + await prompts.log.success('Quick update complete!'); + await prompts.log.info(`Updated ${result.moduleCount} modules with preserved settings (${result.modules.join(', ')})`); // Display version-specific end message const { MessageLoader } = require('../installers/lib/message-loader'); const messageLoader = new MessageLoader(); - messageLoader.displayEndMessage(); + await messageLoader.displayEndMessage(); process.exit(0); return; @@ -60,8 +60,8 @@ module.exports = { // Handle compile agents separately if (config.actionType === 'compile-agents') { const result = await installer.compileAgents(config); - console.log(chalk.green('\n✨ Agent recompilation complete!')); - console.log(chalk.cyan(`Recompiled ${result.agentCount} agents with customizations applied`)); + await prompts.log.success('Agent recompilation complete!'); + await prompts.log.info(`Recompiled ${result.agentCount} agents with customizations applied`); process.exit(0); return; } @@ -80,21 +80,22 @@ module.exports = { // Display version-specific end message from install-messages.yaml const { MessageLoader } = require('../installers/lib/message-loader'); const messageLoader = new MessageLoader(); - messageLoader.displayEndMessage(); + await messageLoader.displayEndMessage(); process.exit(0); } } catch (error) { - // Check if error has a complete formatted message - if (error.fullMessage) { - console.error(error.fullMessage); - if (error.stack) { - console.error('\n' + chalk.dim(error.stack)); + try { + if (error.fullMessage) { + await prompts.log.error(error.fullMessage); + } else { + await prompts.log.error(`Installation failed: ${error.message}`); } - } else { - // Generic error handling for all other errors - console.error(chalk.red('Installation failed:'), error.message); - console.error(chalk.dim(error.stack)); + if (error.stack) { + await prompts.log.message(error.stack); + } + } catch { + console.error(error.fullMessage || error.message || error); } process.exit(1); } diff --git a/tools/cli/commands/status.js b/tools/cli/commands/status.js index 5df2cfacd..ec931fe46 100644 --- a/tools/cli/commands/status.js +++ b/tools/cli/commands/status.js @@ -1,5 +1,5 @@ -const chalk = require('chalk'); const path = require('node:path'); +const prompts = require('../lib/prompts'); const { Installer } = require('../installers/lib/core/installer'); const { Manifest } = require('../installers/lib/core/manifest'); const { UI } = require('../lib/ui'); @@ -21,9 +21,9 @@ module.exports = { // Check if bmad directory exists const fs = require('fs-extra'); if (!(await fs.pathExists(bmadDir))) { - console.log(chalk.yellow('No BMAD installation found in the current directory.')); - console.log(chalk.dim(`Expected location: ${bmadDir}`)); - console.log(chalk.dim('\nRun "bmad install" to set up a new installation.')); + await prompts.log.warn('No BMAD installation found in the current directory.'); + await prompts.log.message(`Expected location: ${bmadDir}`); + await prompts.log.message('Run "bmad install" to set up a new installation.'); process.exit(0); return; } @@ -32,8 +32,8 @@ module.exports = { const manifestData = await manifest._readRaw(bmadDir); if (!manifestData) { - console.log(chalk.yellow('No BMAD installation manifest found.')); - console.log(chalk.dim('\nRun "bmad install" to set up a new installation.')); + await prompts.log.warn('No BMAD installation manifest found.'); + await prompts.log.message('Run "bmad install" to set up a new installation.'); process.exit(0); return; } @@ -46,7 +46,7 @@ module.exports = { const availableUpdates = await manifest.checkForUpdates(bmadDir); // Display status - ui.displayStatus({ + await ui.displayStatus({ installation, modules, availableUpdates, @@ -55,9 +55,9 @@ module.exports = { process.exit(0); } catch (error) { - console.error(chalk.red('Status check failed:'), error.message); + await prompts.log.error(`Status check failed: ${error.message}`); if (process.env.BMAD_DEBUG) { - console.error(chalk.dim(error.stack)); + await prompts.log.message(error.stack); } process.exit(1); } diff --git a/tools/cli/installers/lib/core/config-collector.js b/tools/cli/installers/lib/core/config-collector.js index b49075ae0..1a0f50d29 100644 --- a/tools/cli/installers/lib/core/config-collector.js +++ b/tools/cli/installers/lib/core/config-collector.js @@ -1,7 +1,6 @@ const path = require('node:path'); const fs = require('fs-extra'); const yaml = require('yaml'); -const chalk = require('chalk'); const { getProjectRoot, getModulePath } = require('../../../lib/project-root'); const { CLIUtils } = require('../../../lib/cli-utils'); const prompts = require('../../../lib/prompts'); @@ -260,15 +259,9 @@ class ConfigCollector { // If module has no config keys at all, handle it specially if (hasNoConfig && moduleConfig.subheader) { - // Add blank line for better readability (matches other modules) - console.log(); const moduleDisplayName = moduleConfig.header || `${moduleName.toUpperCase()} Module`; - - // Display the module name in color first (matches other modules) - console.log(chalk.cyan('?') + ' ' + chalk.magenta(moduleDisplayName)); - - // Show the subheader since there's no configuration to ask about - console.log(chalk.dim(` ✓ ${moduleConfig.subheader}`)); + await prompts.log.step(moduleDisplayName); + await prompts.log.message(` \u2713 ${moduleConfig.subheader}`); return false; // No new fields } @@ -322,7 +315,7 @@ class ConfigCollector { } // Show "no config" message for modules with no new questions (that have config keys) - console.log(chalk.dim(` ✓ ${moduleName.toUpperCase()} module already up to date`)); + await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module already up to date`); return false; // No new fields } @@ -350,15 +343,15 @@ class ConfigCollector { if (questions.length > 0) { // Only show header if we actually have questions - CLIUtils.displayModuleConfigHeader(moduleName, moduleConfig.header, moduleConfig.subheader); - console.log(); // Line break before questions + await CLIUtils.displayModuleConfigHeader(moduleName, moduleConfig.header, moduleConfig.subheader); + await prompts.log.message(''); const promptedAnswers = await prompts.prompt(questions); // Merge prompted answers with static answers Object.assign(allAnswers, promptedAnswers); } else if (newStaticKeys.length > 0) { // Only static fields, no questions - show no config message - console.log(chalk.dim(` ✓ ${moduleName.toUpperCase()} module configuration updated`)); + await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module configuration updated`); } // Store all answers for cross-referencing @@ -588,7 +581,7 @@ class ConfigCollector { // Skip prompts mode: use all defaults without asking if (this.skipPrompts) { - console.log(chalk.cyan('Using default configuration for'), chalk.magenta(moduleDisplayName)); + await prompts.log.info(`Using default configuration for ${moduleDisplayName}`); // Use defaults for all questions for (const question of questions) { const hasDefault = question.default !== undefined && question.default !== null && question.default !== ''; @@ -597,12 +590,10 @@ class ConfigCollector { } } } else { - console.log(); - console.log(chalk.cyan('?') + ' ' + chalk.magenta(moduleDisplayName)); + await prompts.log.step(moduleDisplayName); let customize = true; if (moduleName === 'core') { - // Core module: no confirm prompt, so add spacing manually to match visual style - console.log(chalk.gray('│')); + // Core module: no confirm prompt, continues directly } else { // Non-core modules: show "Accept Defaults?" confirm prompt (clack adds spacing) const customizeAnswer = await prompts.prompt([ @@ -621,7 +612,7 @@ class ConfigCollector { const questionsWithoutDefaults = questions.filter((q) => q.default === undefined || q.default === null || q.default === ''); if (questionsWithoutDefaults.length > 0) { - console.log(chalk.dim(`\n Asking required questions for ${moduleName.toUpperCase()}...`)); + await prompts.log.message(` Asking required questions for ${moduleName.toUpperCase()}...`); const promptedAnswers = await prompts.prompt(questionsWithoutDefaults); Object.assign(allAnswers, promptedAnswers); } @@ -747,32 +738,15 @@ class ConfigCollector { const hasNoConfig = actualConfigKeys.length === 0; if (hasNoConfig && (moduleConfig.subheader || moduleConfig.header)) { - // Module explicitly has no configuration - show with special styling - // Add blank line for better readability (matches other modules) - console.log(); - - // Display the module name in color first (matches other modules) - console.log(chalk.cyan('?') + ' ' + chalk.magenta(moduleDisplayName)); - - // Ask user if they want to accept defaults or customize on the next line - const { customize } = await prompts.prompt([ - { - type: 'confirm', - name: 'customize', - message: 'Accept Defaults (no to customize)?', - default: true, - }, - ]); - - // Show the subheader if available, otherwise show a default message + await prompts.log.step(moduleDisplayName); if (moduleConfig.subheader) { - console.log(chalk.dim(` ✓ ${moduleConfig.subheader}`)); + await prompts.log.message(` \u2713 ${moduleConfig.subheader}`); } else { - console.log(chalk.dim(` ✓ No custom configuration required`)); + await prompts.log.message(` \u2713 No custom configuration required`); } } else { // Module has config but just no questions to ask - console.log(chalk.dim(` ✓ ${moduleName.toUpperCase()} module configured`)); + await prompts.log.message(` \u2713 ${moduleName.toUpperCase()} module configured`); } } @@ -981,14 +955,15 @@ class ConfigCollector { } // Add current value indicator for existing configs + const color = await prompts.getColor(); if (existingValue !== null && existingValue !== undefined) { if (typeof existingValue === 'boolean') { - message += chalk.dim(` (current: ${existingValue ? 'true' : 'false'})`); + message += color.dim(` (current: ${existingValue ? 'true' : 'false'})`); } else if (Array.isArray(existingValue)) { - message += chalk.dim(` (current: ${existingValue.join(', ')})`); + message += color.dim(` (current: ${existingValue.join(', ')})`); } else if (questionType !== 'list') { // Show the cleaned value (without {project-root}/) for display - message += chalk.dim(` (current: ${existingValue})`); + message += color.dim(` (current: ${existingValue})`); } } else if (item.example && questionType === 'input') { // Show example for input fields @@ -998,7 +973,7 @@ class ConfigCollector { exampleText = this.replacePlaceholders(exampleText, moduleName, moduleConfig); exampleText = exampleText.replace('{project-root}/', ''); } - message += chalk.dim(` (e.g., ${exampleText})`); + message += color.dim(` (e.g., ${exampleText})`); } // Build the question object diff --git a/tools/cli/installers/lib/core/dependency-resolver.js b/tools/cli/installers/lib/core/dependency-resolver.js index ee8a8a124..3fb282c5d 100644 --- a/tools/cli/installers/lib/core/dependency-resolver.js +++ b/tools/cli/installers/lib/core/dependency-resolver.js @@ -1,8 +1,8 @@ const fs = require('fs-extra'); const path = require('node:path'); const glob = require('glob'); -const chalk = require('chalk'); const yaml = require('yaml'); +const prompts = require('../../../lib/prompts'); /** * Dependency Resolver for BMAD modules @@ -24,7 +24,7 @@ class DependencyResolver { */ async resolve(bmadDir, selectedModules = [], options = {}) { if (options.verbose) { - console.log(chalk.cyan('Resolving module dependencies...')); + await prompts.log.info('Resolving module dependencies...'); } // Always include core as base @@ -50,7 +50,7 @@ class DependencyResolver { // Report results (only in verbose mode) if (options.verbose) { - this.reportResults(organizedFiles, selectedModules); + await this.reportResults(organizedFiles, selectedModules); } return { @@ -90,8 +90,12 @@ class DependencyResolver { } } + if (!moduleDir) { + continue; + } + if (!(await fs.pathExists(moduleDir))) { - console.warn(chalk.yellow(`Module directory not found: ${moduleDir}`)); + await prompts.log.warn('Module directory not found: ' + moduleDir); continue; } @@ -179,7 +183,7 @@ class DependencyResolver { } } } catch (error) { - console.warn(chalk.yellow(`Failed to parse frontmatter in ${file.name}: ${error.message}`)); + await prompts.log.warn('Failed to parse frontmatter in ' + file.name + ': ' + error.message); } } @@ -658,8 +662,8 @@ class DependencyResolver { /** * Report resolution results */ - reportResults(organized, selectedModules) { - console.log(chalk.green('\n✓ Dependency resolution complete')); + async reportResults(organized, selectedModules) { + await prompts.log.success('Dependency resolution complete'); for (const [module, files] of Object.entries(organized)) { const isSelected = selectedModules.includes(module) || module === 'core'; @@ -667,31 +671,31 @@ class DependencyResolver { files.agents.length + files.tasks.length + files.tools.length + files.templates.length + files.data.length + files.other.length; if (totalFiles > 0) { - console.log(chalk.cyan(`\n ${module.toUpperCase()} module:`)); - console.log(chalk.dim(` Status: ${isSelected ? 'Selected' : 'Dependencies only'}`)); + await prompts.log.info(` ${module.toUpperCase()} module:`); + await prompts.log.message(` Status: ${isSelected ? 'Selected' : 'Dependencies only'}`); if (files.agents.length > 0) { - console.log(chalk.dim(` Agents: ${files.agents.length}`)); + await prompts.log.message(` Agents: ${files.agents.length}`); } if (files.tasks.length > 0) { - console.log(chalk.dim(` Tasks: ${files.tasks.length}`)); + await prompts.log.message(` Tasks: ${files.tasks.length}`); } if (files.templates.length > 0) { - console.log(chalk.dim(` Templates: ${files.templates.length}`)); + await prompts.log.message(` Templates: ${files.templates.length}`); } if (files.data.length > 0) { - console.log(chalk.dim(` Data files: ${files.data.length}`)); + await prompts.log.message(` Data files: ${files.data.length}`); } if (files.other.length > 0) { - console.log(chalk.dim(` Other files: ${files.other.length}`)); + await prompts.log.message(` Other files: ${files.other.length}`); } } } if (this.missingDependencies.size > 0) { - console.log(chalk.yellow('\n ⚠ Missing dependencies:')); + await prompts.log.warn('Missing dependencies:'); for (const missing of this.missingDependencies) { - console.log(chalk.yellow(` - ${missing}`)); + await prompts.log.warn(` - ${missing}`); } } } diff --git a/tools/cli/installers/lib/core/installer.js b/tools/cli/installers/lib/core/installer.js index cfba0ab94..1e161bdc8 100644 --- a/tools/cli/installers/lib/core/installer.js +++ b/tools/cli/installers/lib/core/installer.js @@ -1,7 +1,5 @@ const path = require('node:path'); const fs = require('fs-extra'); -const chalk = require('chalk'); -const ora = require('ora'); const { Detector } = require('./detector'); const { Manifest } = require('./manifest'); const { ModuleManager } = require('../modules/manager'); @@ -166,32 +164,32 @@ class Installer { const newlySelectedIdes = toolConfig.ides.filter((ide) => !previouslyConfiguredIdes.includes(ide)); if (newlySelectedIdes.length > 0) { - console.log('\n'); // Add spacing before IDE questions - // Collect configuration for IDEs that support it for (const ide of newlySelectedIdes) { try { const handler = this.ideManager.handlers.get(ide); if (!handler) { - console.warn(chalk.yellow(`Warning: IDE '${ide}' handler not found`)); + await prompts.log.warn(`Warning: IDE '${ide}' handler not found`); continue; } // Check if this IDE handler has a collectConfiguration method // (custom installers like Codex, Kilo, Kiro-cli may have this) if (typeof handler.collectConfiguration === 'function') { - console.log(chalk.cyan(`\nConfiguring ${ide}...`)); + await prompts.log.info(`Configuring ${ide}...`); ideConfigurations[ide] = await handler.collectConfiguration({ selectedModules: selectedModules || [], projectDir, bmadDir, }); + } else { + // Config-driven IDEs don't need configuration - mark as ready + ideConfigurations[ide] = { _noConfigNeeded: true }; } - // Most config-driven IDEs don't need configuration - silently skip } catch (error) { // IDE doesn't support configuration or has an error - console.warn(chalk.yellow(`Warning: Could not load configuration for ${ide}: ${error.message}`)); + await prompts.log.warn(`Warning: Could not load configuration for ${ide}: ${error.message}`); } } } @@ -199,7 +197,7 @@ class Installer { // Log which IDEs are already configured and being kept const keptIdes = toolConfig.ides.filter((ide) => previouslyConfiguredIdes.includes(ide)); if (keptIdes.length > 0) { - console.log(chalk.dim(`\nKeeping existing configuration for: ${keptIdes.join(', ')}`)); + await prompts.log.message(`Keeping existing configuration for: ${keptIdes.join(', ')}`); } } @@ -229,16 +227,17 @@ class Installer { // Only display logo if core config wasn't already collected (meaning we're not continuing from UI) if (!hasCoreConfig) { // Display BMAD logo - CLIUtils.displayLogo(); + await CLIUtils.displayLogo(); // Display welcome message - CLIUtils.displaySection('BMad™ Installation', 'Version ' + require(path.join(getProjectRoot(), 'package.json')).version); + await CLIUtils.displaySection('BMad™ Installation', 'Version ' + require(path.join(getProjectRoot(), 'package.json')).version); } // Note: Legacy V4 detection now happens earlier in UI.promptInstall() // before any config collection, so we don't need to check again here const projectDir = path.resolve(config.directory); + const bmadDir = path.join(projectDir, BMAD_FOLDER_NAME); // If core config was pre-collected (from interactive mode), use it if (config.coreConfig && Object.keys(config.coreConfig).length > 0) { @@ -372,41 +371,36 @@ class Installer { // Tool selection will be collected after we determine if it's a reinstall/update/new install - const spinner = ora('Preparing installation...').start(); + const spinner = await prompts.spinner(); + spinner.start('Preparing installation...'); try { - // Resolve target directory (path.resolve handles platform differences) - const projectDir = path.resolve(config.directory); - - // Always use the standard _bmad folder name - const bmadDir = path.join(projectDir, BMAD_FOLDER_NAME); - // Create a project directory if it doesn't exist (user already confirmed) if (!(await fs.pathExists(projectDir))) { - spinner.text = 'Creating installation directory...'; + spinner.message('Creating installation directory...'); try { // fs.ensureDir handles platform-specific directory creation // It will recursively create all necessary parent directories await fs.ensureDir(projectDir); } catch (error) { - spinner.fail('Failed to create installation directory'); - console.error(chalk.red(`Error: ${error.message}`)); + spinner.error('Failed to create installation directory'); + await prompts.log.error(`Error: ${error.message}`); // More detailed error for common issues if (error.code === 'EACCES') { - console.error(chalk.red('Permission denied. Check parent directory permissions.')); + await prompts.log.error('Permission denied. Check parent directory permissions.'); } else if (error.code === 'ENOSPC') { - console.error(chalk.red('No space left on device.')); + await prompts.log.error('No space left on device.'); } throw new Error(`Cannot create directory: ${projectDir}`); } } // Check existing installation - spinner.text = 'Checking for existing installation...'; + spinner.message('Checking for existing installation...'); const existingInstall = await this.detector.detect(bmadDir); if (existingInstall.installed && !config.force && !config._quickUpdate) { - spinner.stop(); + spinner.stop('Existing installation detected'); // Check if user already decided what to do (from early menu in ui.js) let action = null; @@ -414,9 +408,9 @@ class Installer { action = 'update'; } else { // Fallback: Ask the user (backwards compatibility for other code paths) - console.log(chalk.yellow('\n⚠️ Existing BMAD installation detected')); - console.log(chalk.dim(` Location: ${bmadDir}`)); - console.log(chalk.dim(` Version: ${existingInstall.version}`)); + await prompts.log.warn('Existing BMAD installation detected'); + await prompts.log.message(` Location: ${bmadDir}`); + await prompts.log.message(` Version: ${existingInstall.version}`); const promptResult = await this.promptUpdateAction(); action = promptResult.action; @@ -438,17 +432,17 @@ class Installer { // If there are modules to remove, ask for confirmation if (modulesToRemove.length > 0) { const prompts = require('../../../lib/prompts'); - spinner.stop(); + if (spinner.isSpinning) { + spinner.stop('Reviewing module changes'); + } - console.log(''); - console.log(chalk.yellow.bold('⚠️ Modules to be removed:')); + await prompts.log.warn('Modules to be removed:'); for (const moduleId of modulesToRemove) { const moduleInfo = existingInstall.modules.find((m) => m.id === moduleId); const displayName = moduleInfo?.name || moduleId; const modulePath = path.join(bmadDir, moduleId); - console.log(chalk.red(` - ${displayName} (${modulePath})`)); + await prompts.log.error(` - ${displayName} (${modulePath})`); } - console.log(''); const confirmRemoval = await prompts.confirm({ message: `Remove ${modulesToRemove.length} module(s) from BMAD installation?`, @@ -462,15 +456,15 @@ class Installer { try { if (await fs.pathExists(modulePath)) { await fs.remove(modulePath); - console.log(chalk.dim(` ✓ Removed: ${moduleId}`)); + await prompts.log.message(` Removed: ${moduleId}`); } } catch (error) { - console.warn(chalk.yellow(` Warning: Failed to remove ${moduleId}: ${error.message}`)); + await prompts.log.warn(` Warning: Failed to remove ${moduleId}: ${error.message}`); } } - console.log(chalk.green(` ✓ Removed ${modulesToRemove.length} module(s)`)); + await prompts.log.success(` Removed ${modulesToRemove.length} module(s)`); } else { - console.log(chalk.dim(' → Module removal cancelled')); + await prompts.log.message(' Module removal cancelled'); // Add the modules back to the selection since user cancelled removal for (const moduleId of modulesToRemove) { if (!config.modules) config.modules = []; @@ -503,7 +497,7 @@ class Installer { // Also store in configCollector for use during config collection this.configCollector.collectedConfig.core = existingCoreConfig; } catch (error) { - console.warn(chalk.yellow(`Warning: Could not read existing core config: ${error.message}`)); + await prompts.log.warn(`Warning: Could not read existing core config: ${error.message}`); } } @@ -554,7 +548,7 @@ class Installer { await fs.ensureDir(path.dirname(backupPath)); await fs.copy(customFile, backupPath); } - spinner.succeed(`Backed up ${customFiles.length} custom files`); + spinner.stop(`Backed up ${customFiles.length} custom files`); config._tempBackupDir = tempBackupDir; } @@ -571,14 +565,14 @@ class Installer { await fs.ensureDir(path.dirname(tempBackupPath)); await fs.copy(modifiedFile.path, tempBackupPath, { overwrite: true }); } - spinner.succeed(`Backed up ${modifiedFiles.length} modified files`); + spinner.stop(`Backed up ${modifiedFiles.length} modified files`); config._tempModifiedBackupDir = tempModifiedBackupDir; } } } else if (existingInstall.installed && config._quickUpdate) { // Quick update mode - automatically treat as update without prompting - spinner.text = 'Preparing quick update...'; + spinner.message('Preparing quick update...'); config._isUpdate = true; config._existingInstall = existingInstall; @@ -636,7 +630,7 @@ class Installer { await fs.ensureDir(path.dirname(backupPath)); await fs.copy(customFile, backupPath); } - spinner.succeed(`Backed up ${customFiles.length} custom files`); + spinner.stop(`Backed up ${customFiles.length} custom files`); config._tempBackupDir = tempBackupDir; } @@ -652,14 +646,14 @@ class Installer { await fs.ensureDir(path.dirname(tempBackupPath)); await fs.copy(modifiedFile.path, tempBackupPath, { overwrite: true }); } - spinner.succeed(`Backed up ${modifiedFiles.length} modified files`); + spinner.stop(`Backed up ${modifiedFiles.length} modified files`); config._tempModifiedBackupDir = tempModifiedBackupDir; } } // Now collect tool configurations after we know if it's a reinstall // Skip for quick update since we already have the IDE list - spinner.stop(); + spinner.stop('Pre-checks complete'); let toolSelection; if (config._quickUpdate) { // Quick update already has IDEs configured, use saved configurations @@ -698,19 +692,23 @@ class Installer { config.skipIde = toolSelection.skipIde; const ideConfigurations = toolSelection.configurations; + // Results collector for consolidated summary + const results = []; + const addResult = (step, status, detail = '') => results.push({ step, status, detail }); + if (spinner.isSpinning) { - spinner.text = 'Continuing installation...'; + spinner.message('Installing...'); } else { - spinner.start('Continuing installation...'); + spinner.start('Installing...'); } // Create bmad directory structure - spinner.text = 'Creating directory structure...'; + spinner.message('Creating directory structure...'); await this.createDirectoryStructure(bmadDir); // Cache custom modules if any if (customModulePaths && customModulePaths.size > 0) { - spinner.text = 'Caching custom modules...'; + spinner.message('Caching custom modules...'); const { CustomModuleCache } = require('./custom-module-cache'); const customCache = new CustomModuleCache(bmadDir); @@ -725,16 +723,16 @@ class Installer { // Update module manager with the cached paths this.moduleManager.setCustomModulePaths(customModulePaths); - spinner.succeed('Custom modules cached'); + addResult('Custom modules cached', 'ok'); } const projectRoot = getProjectRoot(); // Step 1: Install core module first (if requested) if (config.installCore) { - spinner.start('Installing BMAD core...'); + spinner.message('Installing BMAD core...'); await this.installCoreWithDependencies(bmadDir, { core: {} }); - spinner.succeed('Core installed'); + addResult('Core', 'ok', 'installed'); // Generate core config file await this.generateModuleConfigs(bmadDir, { core: config.coreConfig || {} }); @@ -804,13 +802,13 @@ class Installer { bmadDir: bmadDir, // Pass bmadDir so we can check cache }); + spinner.message('Resolving dependencies...'); + const resolution = await this.dependencyResolver.resolve(projectRoot, regularModulesForResolution, { verbose: config.verbose, moduleManager: tempModuleManager, }); - spinner.succeed('Dependencies resolved'); - // Install modules with their dependencies if (allModules && allModules.length > 0) { const installedModuleNames = new Set(); @@ -824,7 +822,7 @@ class Installer { // Show appropriate message based on whether this is a quick update const isQuickUpdate = config._quickUpdate || false; - spinner.start(`${isQuickUpdate ? 'Updating' : 'Installing'} module: ${moduleName}...`); + spinner.message(`${isQuickUpdate ? 'Updating' : 'Installing'} module: ${moduleName}...`); // Check if this is a custom module let isCustomModule = false; @@ -898,6 +896,7 @@ class Installer { moduleConfig: collectedModuleConfig, isQuickUpdate: config._quickUpdate || false, installer: this, + silent: true, }, ); @@ -915,7 +914,7 @@ class Installer { } } - spinner.succeed(`Module ${isQuickUpdate ? 'updated' : 'installed'}: ${moduleName}`); + addResult(`Module: ${moduleName}`, 'ok', isQuickUpdate ? 'updated' : 'installed'); } // Install partial modules (only dependencies) @@ -929,9 +928,8 @@ class Installer { files.data.length + files.other.length; if (totalFiles > 0) { - spinner.start(`Installing ${module} dependencies...`); + spinner.message(`Installing ${module} dependencies...`); await this.installPartialModule(module, bmadDir, files); - spinner.succeed(`${module} dependencies installed`); } } } @@ -940,9 +938,9 @@ class Installer { // All content is now installed as modules - no separate custom content handling needed // Generate clean config.yaml files for each installed module - spinner.start('Generating module configurations...'); + spinner.message('Generating module configurations...'); await this.generateModuleConfigs(bmadDir, moduleConfigs); - spinner.succeed('Module configurations generated'); + addResult('Configurations', 'ok', 'generated'); // Create agent configuration files // Note: Legacy createAgentConfigs removed - using YAML customize system instead @@ -957,7 +955,7 @@ class Installer { // Generate CSV manifests for workflows, agents, tasks AND ALL FILES with hashes BEFORE IDE setup // This must happen BEFORE mergeModuleHelpCatalogs because it depends on agent-manifest.csv - spinner.start('Generating workflow and agent manifests...'); + spinner.message('Generating workflow and agent manifests...'); const manifestGen = new ManifestGenerator(); // For quick update, we need ALL installed modules in the manifest @@ -985,15 +983,17 @@ class Installer { // Custom modules are now included in the main modules list - no separate tracking needed - spinner.succeed( - `Manifests generated: ${manifestStats.workflows} workflows, ${manifestStats.agents} agents, ${manifestStats.tasks} tasks, ${manifestStats.tools} tools, ${manifestStats.files} files`, + addResult( + 'Manifests', + 'ok', + `${manifestStats.workflows} workflows, ${manifestStats.agents} agents, ${manifestStats.tasks} tasks, ${manifestStats.tools} tools`, ); // Merge all module-help.csv files into bmad-help.csv // This must happen AFTER generateManifests because it depends on agent-manifest.csv - spinner.start('Generating workflow help catalog...'); + spinner.message('Generating workflow help catalog...'); await this.mergeModuleHelpCatalogs(bmadDir); - spinner.succeed('Workflow help catalog generated'); + addResult('Help catalog', 'ok'); // Configure IDEs and copy documentation if (!config.skipIde && config.ides && config.ides.length > 0) { @@ -1004,64 +1004,63 @@ class Installer { const validIdes = config.ides.filter((ide) => ide && typeof ide === 'string'); if (validIdes.length === 0) { - console.log(chalk.yellow('⚠️ No valid IDEs selected. Skipping IDE configuration.')); + addResult('IDE configuration', 'warn', 'no valid IDEs selected'); } else { // Check if any IDE might need prompting (no pre-collected config) const needsPrompting = validIdes.some((ide) => !ideConfigurations[ide]); - if (!needsPrompting) { - spinner.start('Configuring IDEs...'); - } - // Temporarily suppress console output if not verbose const originalLog = console.log; if (!config.verbose) { console.log = () => {}; } - for (const ide of validIdes) { - // Only show spinner if we have pre-collected config (no prompts expected) - if (ideConfigurations[ide] && !needsPrompting) { - spinner.text = `Configuring ${ide}...`; - } else if (!ideConfigurations[ide]) { - // Stop spinner before prompting - if (spinner.isSpinning) { - spinner.stop(); + try { + for (const ide of validIdes) { + if (!needsPrompting || ideConfigurations[ide]) { + // All IDEs pre-configured, or this specific IDE has config: keep spinner running + spinner.message(`Configuring ${ide}...`); + } else { + // This IDE needs prompting: stop spinner to allow user interaction + if (spinner.isSpinning) { + spinner.stop('Ready for IDE configuration'); + } + } + + // Silent when this IDE has pre-collected config (no prompts for THIS IDE) + const ideHasConfig = Boolean(ideConfigurations[ide]); + const setupResult = await this.ideManager.setup(ide, projectDir, bmadDir, { + selectedModules: allModules || [], + preCollectedConfig: ideConfigurations[ide] || null, + verbose: config.verbose, + silent: ideHasConfig, + }); + + // Save IDE configuration for future updates + if (ideConfigurations[ide] && !ideConfigurations[ide]._alreadyConfigured) { + await this.ideConfigManager.saveIdeConfig(bmadDir, ide, ideConfigurations[ide]); + } + + // Collect result for summary + if (setupResult.success) { + addResult(ide, 'ok', setupResult.detail || ''); + } else { + addResult(ide, 'error', setupResult.error || 'failed'); + } + + // Restart spinner if we stopped it for prompting + if (needsPrompting && !spinner.isSpinning) { + spinner.start('Configuring IDEs...'); } - console.log(chalk.cyan(`\nConfiguring ${ide}...`)); } - - // Pass pre-collected configuration to avoid re-prompting - await this.ideManager.setup(ide, projectDir, bmadDir, { - selectedModules: allModules || [], - preCollectedConfig: ideConfigurations[ide] || null, - verbose: config.verbose, - }); - - // Save IDE configuration for future updates - if (ideConfigurations[ide] && !ideConfigurations[ide]._alreadyConfigured) { - await this.ideConfigManager.saveIdeConfig(bmadDir, ide, ideConfigurations[ide]); - } - - // Restart spinner if we stopped it - if (!ideConfigurations[ide] && !spinner.isSpinning) { - spinner.start('Configuring IDEs...'); - } - } - - // Restore console.log - console.log = originalLog; - - if (spinner.isSpinning) { - spinner.succeed(`Configured: ${validIdes.join(', ')}`); - } else { - console.log(chalk.green(`✓ Configured: ${validIdes.join(', ')}`)); + } finally { + console.log = originalLog; } } } // Run module-specific installers after IDE setup - spinner.start('Running module-specific installers...'); + spinner.message('Running module-specific installers...'); // Create a conditional logger based on verbose mode const verboseMode = process.env.BMAD_VERBOSE_INSTALL === 'true' || config.verbose; @@ -1073,20 +1072,21 @@ class Installer { // Run core module installer if core was installed if (config.installCore || resolution.byModule.core) { - spinner.text = 'Running core module installer...'; + spinner.message('Running core module installer...'); await this.moduleManager.runModuleInstaller('core', bmadDir, { installedIDEs: config.ides || [], moduleConfig: moduleConfigs.core || {}, coreConfig: moduleConfigs.core || {}, logger: moduleLogger, + silent: true, }); } // Run installers for user-selected modules if (config.modules && config.modules.length > 0) { for (const moduleName of config.modules) { - spinner.text = `Running ${moduleName} module installer...`; + spinner.message(`Running ${moduleName} module installer...`); // Pass installed IDEs and module config to module installer await this.moduleManager.runModuleInstaller(moduleName, bmadDir, { @@ -1094,11 +1094,12 @@ class Installer { moduleConfig: moduleConfigs[moduleName] || {}, coreConfig: moduleConfigs.core || {}, logger: moduleLogger, + silent: true, }); } } - spinner.succeed('Module-specific installers completed'); + addResult('Module installers', 'ok'); // Note: Manifest files are already created by ManifestGenerator above // No need to create legacy manifest.csv anymore @@ -1108,7 +1109,7 @@ class Installer { let modifiedFiles = []; if (config._isUpdate) { if (config._customFiles && config._customFiles.length > 0) { - spinner.start(`Restoring ${config._customFiles.length} custom files...`); + spinner.message(`Restoring ${config._customFiles.length} custom files...`); for (const originalPath of config._customFiles) { const relativePath = path.relative(bmadDir, originalPath); @@ -1125,7 +1126,6 @@ class Installer { await fs.remove(config._tempBackupDir); } - spinner.succeed(`Restored ${config._customFiles.length} custom files`); customFiles = config._customFiles; } @@ -1134,7 +1134,7 @@ class Installer { // Restore modified files as .bak files if (config._tempModifiedBackupDir && (await fs.pathExists(config._tempModifiedBackupDir))) { - spinner.start(`Restoring ${modifiedFiles.length} modified files as .bak...`); + spinner.message(`Restoring ${modifiedFiles.length} modified files as .bak...`); for (const modifiedFile of modifiedFiles) { const relativePath = path.relative(bmadDir, modifiedFile.path); @@ -1149,37 +1149,20 @@ class Installer { // Clean up temp backup await fs.remove(config._tempModifiedBackupDir); - - spinner.succeed(`Restored ${modifiedFiles.length} modified files as .bak`); } } } - spinner.stop(); + // Stop the single installation spinner + spinner.stop('Installation complete'); - // Report custom and modified files if any were found - if (customFiles.length > 0) { - console.log(chalk.cyan(`\n📁 Custom files preserved: ${customFiles.length}`)); - } - - if (modifiedFiles.length > 0) { - console.log(chalk.yellow(`\n⚠️ User modified files detected: ${modifiedFiles.length}`)); - console.log( - chalk.dim( - '\nThese user modified files have been updated with the new version, search the project for .bak files that had your customizations.', - ), - ); - console.log(chalk.dim('Remove these .bak files it no longer needed\n')); - } - - // Display completion message - const { UI } = require('../../../lib/ui'); - const ui = new UI(); - ui.showInstallSummary({ - path: bmadDir, + // Render consolidated summary + await this.renderInstallSummary(results, { + bmadDir, modules: config.modules, ides: config.ides, customFiles: customFiles.length > 0 ? customFiles : undefined, + modifiedFiles: modifiedFiles.length > 0 ? modifiedFiles : undefined, }); return { @@ -1190,16 +1173,63 @@ class Installer { projectDir: projectDir, }; } catch (error) { - spinner.fail('Installation failed'); + spinner.error('Installation failed'); throw error; } } + /** + * Render a consolidated install summary using prompts.note() + * @param {Array} results - Array of {step, status: 'ok'|'error'|'warn', detail} + * @param {Object} context - {bmadDir, modules, ides, customFiles, modifiedFiles} + */ + async renderInstallSummary(results, context = {}) { + const color = await prompts.getColor(); + + // Build step lines with status indicators + const lines = []; + for (const r of results) { + let icon; + if (r.status === 'ok') { + icon = color.green('\u2713'); + } else if (r.status === 'warn') { + icon = color.yellow('!'); + } else { + icon = color.red('\u2717'); + } + const detail = r.detail ? color.dim(` (${r.detail})`) : ''; + lines.push(` ${icon} ${r.step}${detail}`); + } + + // Add context info + lines.push(''); + if (context.bmadDir) { + lines.push(` Installed to: ${color.dim(context.bmadDir)}`); + } + if (context.modules && context.modules.length > 0) { + lines.push(` Modules: ${color.dim(context.modules.join(', '))}`); + } + if (context.ides && context.ides.length > 0) { + lines.push(` Tools: ${color.dim(context.ides.join(', '))}`); + } + + // Custom/modified file warnings + if (context.customFiles && context.customFiles.length > 0) { + lines.push(` ${color.cyan(`Custom files preserved: ${context.customFiles.length}`)}`); + } + if (context.modifiedFiles && context.modifiedFiles.length > 0) { + lines.push(` ${color.yellow(`Modified files backed up (.bak): ${context.modifiedFiles.length}`)}`); + } + + await prompts.note(lines.join('\n'), 'BMAD is ready to use!'); + } + /** * Update existing installation */ async update(config) { - const spinner = ora('Checking installation...').start(); + const spinner = await prompts.spinner(); + spinner.start('Checking installation...'); try { const projectDir = path.resolve(config.directory); @@ -1207,11 +1237,11 @@ class Installer { const existingInstall = await this.detector.detect(bmadDir); if (!existingInstall.installed) { - spinner.fail('No BMAD installation found'); + spinner.stop('No BMAD installation found'); throw new Error(`No BMAD installation found at ${bmadDir}`); } - spinner.text = 'Analyzing update requirements...'; + spinner.message('Analyzing update requirements...'); // Compare versions and determine what needs updating const currentVersion = existingInstall.version; @@ -1265,8 +1295,8 @@ class Installer { } if (customModuleSources.size > 0) { - spinner.stop(); - console.log(chalk.yellow('\nChecking custom module sources before update...')); + spinner.stop('Update analysis complete'); + await prompts.log.warn('Checking custom module sources before update...'); const projectRoot = getProjectRoot(); await this.handleMissingCustomSources( @@ -1281,43 +1311,43 @@ class Installer { } if (config.dryRun) { - spinner.stop(); - console.log(chalk.cyan('\n🔍 Update Preview (Dry Run)\n')); - console.log(chalk.bold('Current version:'), currentVersion); - console.log(chalk.bold('New version:'), newVersion); - console.log(chalk.bold('Core:'), existingInstall.hasCore ? 'Will be updated' : 'Not installed'); + spinner.stop('Dry run analysis complete'); + let dryRunContent = `Current version: ${currentVersion}\n`; + dryRunContent += `New version: ${newVersion}\n`; + dryRunContent += `Core: ${existingInstall.hasCore ? 'Will be updated' : 'Not installed'}`; if (existingInstall.modules.length > 0) { - console.log(chalk.bold('\nModules to update:')); + dryRunContent += '\n\nModules to update:'; for (const mod of existingInstall.modules) { - console.log(` - ${mod.id}`); + dryRunContent += `\n - ${mod.id}`; } } + await prompts.note(dryRunContent, 'Update Preview (Dry Run)'); return; } // Perform actual update if (existingInstall.hasCore) { - spinner.text = 'Updating core...'; + spinner.message('Updating core...'); await this.updateCore(bmadDir, config.force); } for (const module of existingInstall.modules) { - spinner.text = `Updating module: ${module.id}...`; - await this.moduleManager.update(module.id, bmadDir, config.force); + spinner.message(`Updating module: ${module.id}...`); + await this.moduleManager.update(module.id, bmadDir, config.force, { installer: this }); } // Update manifest - spinner.text = 'Updating manifest...'; + spinner.message('Updating manifest...'); await this.manifest.update(bmadDir, { version: newVersion, updateDate: new Date().toISOString(), }); - spinner.succeed('Update complete'); + spinner.stop('Update complete'); return { success: true }; } catch (error) { - spinner.fail('Update failed'); + spinner.error('Update failed'); throw error; } } @@ -1492,10 +1522,10 @@ class Installer { } if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Merged module-help from: ${moduleName}`)); + await prompts.log.message(` Merged module-help from: ${moduleName}`); } } catch (error) { - console.warn(chalk.yellow(` Warning: Failed to read module-help.csv from ${moduleName}:`, error.message)); + await prompts.log.warn(` Warning: Failed to read module-help.csv from ${moduleName}: ${error.message}`); } } } @@ -1537,7 +1567,7 @@ class Installer { this.installedFiles.add(outputPath); if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Generated bmad-help.csv: ${allRows.length} workflows`)); + await prompts.log.message(` Generated bmad-help.csv: ${allRows.length} workflows`); } } @@ -1728,6 +1758,7 @@ class Installer { skipModuleInstaller: true, // We'll run it later after IDE setup moduleConfig: moduleConfig, // Pass module config for conditional filtering installer: this, + silent: true, }, ); @@ -1907,7 +1938,7 @@ class Installer { // Check for localskip="true" in the agent tag const agentMatch = content.match(/]*\slocalskip="true"[^>]*>/); if (agentMatch) { - console.log(chalk.dim(` Skipping web-only agent: ${path.basename(file)}`)); + await prompts.log.message(` Skipping web-only agent: ${path.basename(file)}`); continue; // Skip this agent } } @@ -1994,7 +2025,7 @@ class Installer { if (await fs.pathExists(genericTemplatePath)) { await this.copyFileWithPlaceholderReplacement(genericTemplatePath, customizePath); if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Created customize: ${moduleName}-${agentName}.customize.yaml`)); + await prompts.log.message(` Created customize: ${moduleName}-${agentName}.customize.yaml`); } } } @@ -2029,8 +2060,8 @@ class Installer { * @returns {Object} Update result */ async quickUpdate(config) { - const ora = require('ora'); - const spinner = ora('Starting quick update...').start(); + const spinner = await prompts.spinner(); + spinner.start('Starting quick update...'); try { const projectDir = path.resolve(config.directory); @@ -2038,11 +2069,11 @@ class Installer { // Check if bmad directory exists if (!(await fs.pathExists(bmadDir))) { - spinner.fail('No BMAD installation found'); + spinner.stop('No BMAD installation found'); throw new Error(`BMAD not installed at ${bmadDir}. Use regular install for first-time setup.`); } - spinner.text = 'Detecting installed modules and configuration...'; + spinner.message('Detecting installed modules and configuration...'); // Detect existing installation const existingInstall = await this.detector.detect(bmadDir); @@ -2169,14 +2200,14 @@ class Installer { } } - spinner.succeed(`Found ${modulesToUpdate.length} module(s) to update and ${configuredIdes.length} configured tool(s)`); + spinner.stop(`Found ${modulesToUpdate.length} module(s) to update and ${configuredIdes.length} configured tool(s)`); if (skippedModules.length > 0) { - console.log(chalk.yellow(`⚠️ Skipping ${skippedModules.length} module(s) - no source available: ${skippedModules.join(', ')}`)); + await prompts.log.warn(`Skipping ${skippedModules.length} module(s) - no source available: ${skippedModules.join(', ')}`); } // Load existing configs and collect new fields (if any) - console.log(chalk.cyan('\n📋 Checking for new configuration options...')); + await prompts.log.info('Checking for new configuration options...'); await this.configCollector.loadExistingConfig(projectDir); let promptedForNewFields = false; @@ -2196,7 +2227,7 @@ class Installer { } if (!promptedForNewFields) { - console.log(chalk.green('✓ All configuration is up to date, no new options to configure')); + await prompts.log.success('All configuration is up to date, no new options to configure'); } // Add metadata @@ -2228,7 +2259,7 @@ class Installer { // Only succeed the spinner if it's still spinning // (install method might have stopped it if folder name changed) if (spinner.isSpinning) { - spinner.succeed('Quick update complete!'); + spinner.stop('Quick update complete!'); } return { @@ -2240,7 +2271,7 @@ class Installer { ides: configuredIdes, }; } catch (error) { - spinner.fail('Quick update failed'); + spinner.error('Quick update failed'); throw error; } } @@ -2251,12 +2282,12 @@ class Installer { * @returns {Object} Compilation result */ async compileAgents(config) { - const ora = require('ora'); - const chalk = require('chalk'); + // Using @clack prompts const { ModuleManager } = require('../modules/manager'); const { getSourcePath } = require('../../../lib/project-root'); - const spinner = ora('Recompiling agents with customizations...').start(); + const spinner = await prompts.spinner(); + spinner.start('Recompiling agents with customizations...'); try { const projectDir = path.resolve(config.directory); @@ -2264,7 +2295,7 @@ class Installer { // Check if bmad directory exists if (!(await fs.pathExists(bmadDir))) { - spinner.fail('No BMAD installation found'); + spinner.stop('No BMAD installation found'); throw new Error(`BMAD not installed at ${bmadDir}. Use regular install for first-time setup.`); } @@ -2306,7 +2337,7 @@ class Installer { // Process each installed module for (const moduleId of installedModules) { - spinner.text = `Recompiling agents in ${moduleId}...`; + spinner.message(`Recompiling agents in ${moduleId}...`); // Get source path let sourcePath; @@ -2322,7 +2353,7 @@ class Installer { } if (!sourcePath) { - console.log(chalk.yellow(` Warning: Source not found for module ${moduleId}, skipping...`)); + await prompts.log.warn(`Source not found for module ${moduleId}, skipping...`); continue; } @@ -2340,7 +2371,7 @@ class Installer { } } - spinner.succeed('Agent recompilation complete!'); + spinner.stop('Agent recompilation complete!'); return { success: true, @@ -2348,7 +2379,7 @@ class Installer { modules: installedModules, }; } catch (error) { - spinner.fail('Agent recompilation failed'); + spinner.error('Agent recompilation failed'); throw error; } } @@ -2370,19 +2401,14 @@ class Installer { * @param {Object} _legacyV4 - Legacy V4 detection result (unused in simplified version) */ async handleLegacyV4Migration(_projectDir, _legacyV4) { - console.log(''); - console.log(chalk.yellow.bold('⚠️ Legacy BMAD v4 detected')); - console.log(chalk.yellow('─'.repeat(80))); - console.log(chalk.yellow('Found .bmad-method folder from BMAD v4 installation.')); - console.log(''); - - console.log(chalk.dim('Before continuing with installation, we recommend:')); - console.log(chalk.dim(' 1. Remove the .bmad-method folder, OR')); - console.log(chalk.dim(' 2. Back it up by renaming it to another name (e.g., bmad-method-backup)')); - console.log(''); - - console.log(chalk.dim('If your v4 installation set up rules or commands, you should remove those as well.')); - console.log(''); + await prompts.note( + 'Found .bmad-method folder from BMAD v4 installation.\n\n' + + 'Before continuing with installation, we recommend:\n' + + ' 1. Remove the .bmad-method folder, OR\n' + + ' 2. Back it up by renaming it to another name (e.g., bmad-method-backup)\n\n' + + 'If your v4 installation set up rules or commands, you should remove those as well.', + 'Legacy BMAD v4 detected', + ); const proceed = await prompts.select({ message: 'What would you like to do?', @@ -2402,16 +2428,11 @@ class Installer { }); if (proceed === 'exit') { - console.log(''); - console.log(chalk.cyan('Please remove the .bmad-method folder and any v4 rules/commands,')); - console.log(chalk.cyan('then run the installer again.')); - console.log(''); + await prompts.log.info('Please remove the .bmad-method folder and any v4 rules/commands, then run the installer again.'); process.exit(0); } - console.log(''); - console.log(chalk.yellow('⚠️ Proceeding with installation despite legacy v4 folder')); - console.log(''); + await prompts.log.warn('Proceeding with installation despite legacy v4 folder'); } /** @@ -2465,7 +2486,7 @@ class Installer { return files; } catch (error) { - console.warn('Warning: Could not read files-manifest.csv:', error.message); + await prompts.log.warn('Could not read files-manifest.csv: ' + error.message); return []; } } @@ -2637,22 +2658,16 @@ class Installer { }; } - // Stop any spinner for interactive prompts - const currentSpinner = ora(); - if (currentSpinner.isSpinning) { - currentSpinner.stop(); - } - - console.log(chalk.yellow(`\n⚠️ Found ${customModulesWithMissingSources.length} custom module(s) with missing sources:`)); + await prompts.log.warn(`Found ${customModulesWithMissingSources.length} custom module(s) with missing sources:`); let keptCount = 0; let updatedCount = 0; let removedCount = 0; for (const missing of customModulesWithMissingSources) { - console.log(chalk.dim(` • ${missing.name} (${missing.id})`)); - console.log(chalk.dim(` Original source: ${missing.relativePath}`)); - console.log(chalk.dim(` Full path: ${missing.sourcePath}`)); + await prompts.log.message( + `${missing.name} (${missing.id})\n Original source: ${missing.relativePath}\n Full path: ${missing.sourcePath}`, + ); const choices = [ { @@ -2722,26 +2737,27 @@ class Installer { }); updatedCount++; - console.log(chalk.green(`✓ Updated source location`)); + await prompts.log.success('Updated source location'); break; } case 'remove': { // Extra confirmation for destructive remove - console.log(chalk.red.bold(`\n⚠️ WARNING: This will PERMANENTLY DELETE "${missing.name}" and all its files!`)); - console.log(chalk.red(` Module location: ${path.join(bmadDir, missing.id)}`)); + await prompts.log.error( + `WARNING: This will PERMANENTLY DELETE "${missing.name}" and all its files!\n Module location: ${path.join(bmadDir, missing.id)}`, + ); const confirmDelete = await prompts.confirm({ - message: chalk.red.bold('Are you absolutely sure you want to delete this module?'), + message: 'Are you absolutely sure you want to delete this module?', default: false, }); if (confirmDelete) { const typedConfirm = await prompts.text({ - message: chalk.red.bold('Type "DELETE" to confirm permanent deletion:'), + message: 'Type "DELETE" to confirm permanent deletion:', validate: (input) => { if (input !== 'DELETE') { - return chalk.red('You must type "DELETE" exactly to proceed'); + return 'You must type "DELETE" exactly to proceed'; } return; // clack expects undefined for valid input }, @@ -2753,12 +2769,12 @@ class Installer { if (await fs.pathExists(modulePath)) { const fsExtra = require('fs-extra'); await fsExtra.remove(modulePath); - console.log(chalk.yellow(` ✓ Deleted module directory: ${path.relative(projectRoot, modulePath)}`)); + await prompts.log.warn(`Deleted module directory: ${path.relative(projectRoot, modulePath)}`); } await this.manifest.removeModule(bmadDir, missing.id); await this.manifest.removeCustomModule(bmadDir, missing.id); - console.log(chalk.yellow(` ✓ Removed from manifest`)); + await prompts.log.warn('Removed from manifest'); // Also remove from installedModules list if (installedModules && installedModules.includes(missing.id)) { @@ -2769,13 +2785,13 @@ class Installer { } removedCount++; - console.log(chalk.red.bold(`✓ "${missing.name}" has been permanently removed`)); + await prompts.log.error(`"${missing.name}" has been permanently removed`); } else { - console.log(chalk.dim(' Removal cancelled - module will be kept')); + await prompts.log.message('Removal cancelled - module will be kept'); keptCount++; } } else { - console.log(chalk.dim(' Removal cancelled - module will be kept')); + await prompts.log.message('Removal cancelled - module will be kept'); keptCount++; } @@ -2784,7 +2800,7 @@ class Installer { case 'keep': { keptCount++; keptModulesWithoutSources.push(missing.id); - console.log(chalk.dim(` Module will be kept as-is`)); + await prompts.log.message('Module will be kept as-is'); break; } @@ -2794,10 +2810,11 @@ class Installer { // Show summary if (keptCount > 0 || updatedCount > 0 || removedCount > 0) { - console.log(chalk.dim(`\nSummary for custom modules with missing sources:`)); - if (keptCount > 0) console.log(chalk.dim(` • ${keptCount} module(s) kept as-is`)); - if (updatedCount > 0) console.log(chalk.dim(` • ${updatedCount} module(s) updated with new sources`)); - if (removedCount > 0) console.log(chalk.red(` • ${removedCount} module(s) permanently deleted`)); + let summary = 'Summary for custom modules with missing sources:'; + if (keptCount > 0) summary += `\n • ${keptCount} module(s) kept as-is`; + if (updatedCount > 0) summary += `\n • ${updatedCount} module(s) updated with new sources`; + if (removedCount > 0) summary += `\n • ${removedCount} module(s) permanently deleted`; + await prompts.log.message(summary); } return { diff --git a/tools/cli/installers/lib/custom/handler.js b/tools/cli/installers/lib/custom/handler.js index 8c730cf32..6256e3cd2 100644 --- a/tools/cli/installers/lib/custom/handler.js +++ b/tools/cli/installers/lib/custom/handler.js @@ -1,7 +1,7 @@ const path = require('node:path'); const fs = require('fs-extra'); -const chalk = require('chalk'); const yaml = require('yaml'); +const prompts = require('../../../lib/prompts'); const { FileOps } = require('../../../lib/file-ops'); const { XmlHandler } = require('../../../lib/xml-handler'); @@ -88,7 +88,7 @@ class CustomHandler { try { config = yaml.parse(configContent); } catch (parseError) { - console.warn(chalk.yellow(`Warning: YAML parse error in ${configPath}:`, parseError.message)); + await prompts.log.warn('YAML parse error in ' + configPath + ': ' + parseError.message); return null; } @@ -111,7 +111,7 @@ class CustomHandler { isInstallConfig: isInstallConfig, // Track which type this is }; } catch (error) { - console.warn(chalk.yellow(`Warning: Failed to read ${configPath}:`, error.message)); + await prompts.log.warn('Failed to read ' + configPath + ': ' + error.message); return null; } } @@ -268,14 +268,13 @@ class CustomHandler { } results.filesCopied++; + if (entry.name.endsWith('.md')) { + results.workflowsInstalled++; + } if (fileTrackingCallback) { fileTrackingCallback(targetPath); } } - - if (entry.name.endsWith('.md')) { - results.workflowsInstalled++; - } } catch (error) { results.errors.push(`Failed to copy ${entry.name}: ${error.message}`); } @@ -322,7 +321,7 @@ class CustomHandler { await fs.writeFile(customizePath, templateContent, 'utf8'); // Only show customize creation in verbose mode if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Created customize: custom-${agentName}.customize.yaml`)); + await prompts.log.message(' Created customize: custom-' + agentName + '.customize.yaml'); } } } @@ -346,14 +345,10 @@ class CustomHandler { // Only show compilation details in verbose mode if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log( - chalk.dim( - ` Compiled agent: ${agentName} -> ${path.relative(targetAgentsPath, targetMdPath)}${hasSidecar ? ' (with sidecar)' : ''}`, - ), - ); + await prompts.log.message(' Compiled agent: ' + agentName + ' -> ' + path.relative(targetAgentsPath, targetMdPath)); } } catch (error) { - console.warn(chalk.yellow(` Failed to compile agent ${agentName}:`, error.message)); + await prompts.log.warn(' Failed to compile agent ' + agentName + ': ' + error.message); results.errors.push(`Failed to compile agent ${agentName}: ${error.message}`); } } diff --git a/tools/cli/installers/lib/ide/_base-ide.js b/tools/cli/installers/lib/ide/_base-ide.js index dce8aee9f..9bfbdcf30 100644 --- a/tools/cli/installers/lib/ide/_base-ide.js +++ b/tools/cli/installers/lib/ide/_base-ide.js @@ -1,7 +1,7 @@ const path = require('node:path'); const fs = require('fs-extra'); -const chalk = require('chalk'); const { XmlHandler } = require('../../../lib/xml-handler'); +const prompts = require('../../../lib/prompts'); const { getSourcePath } = require('../../../lib/project-root'); const { BMAD_FOLDER_NAME } = require('./shared/path-utils'); @@ -53,7 +53,7 @@ class BaseIdeSetup { * Cleanup IDE configuration * @param {string} projectDir - Project directory */ - async cleanup(projectDir) { + async cleanup(projectDir, options = {}) { // Default implementation - can be overridden if (this.configDir) { const configPath = path.join(projectDir, this.configDir); @@ -61,7 +61,7 @@ class BaseIdeSetup { const bmadRulesPath = path.join(configPath, BMAD_FOLDER_NAME); if (await fs.pathExists(bmadRulesPath)) { await fs.remove(bmadRulesPath); - console.log(chalk.dim(`Removed ${this.name} BMAD configuration`)); + if (!options.silent) await prompts.log.message(`Removed ${this.name} BMAD configuration`); } } } diff --git a/tools/cli/installers/lib/ide/_config-driven.js b/tools/cli/installers/lib/ide/_config-driven.js index 486889267..7eb2533ed 100644 --- a/tools/cli/installers/lib/ide/_config-driven.js +++ b/tools/cli/installers/lib/ide/_config-driven.js @@ -1,7 +1,7 @@ const path = require('node:path'); const fs = require('fs-extra'); -const chalk = require('chalk'); const { BaseIdeSetup } = require('./_base-ide'); +const prompts = require('../../../lib/prompts'); const { AgentCommandGenerator } = require('./shared/agent-command-generator'); const { WorkflowCommandGenerator } = require('./shared/workflow-command-generator'); const { TaskToolCommandGenerator } = require('./shared/task-tool-command-generator'); @@ -34,10 +34,10 @@ class ConfigDrivenIdeSetup extends BaseIdeSetup { * @returns {Promise} Setup result */ async setup(projectDir, bmadDir, options = {}) { - console.log(chalk.cyan(`Setting up ${this.name}...`)); + if (!options.silent) await prompts.log.info(`Setting up ${this.name}...`); // Clean up any old BMAD installation first - await this.cleanup(projectDir); + await this.cleanup(projectDir, options); if (!this.installerConfig) { return { success: false, reason: 'no-config' }; @@ -102,7 +102,7 @@ class ConfigDrivenIdeSetup extends BaseIdeSetup { results.tools = taskToolResult.tools || 0; } - this.printSummary(results, target_dir); + await this.printSummary(results, target_dir, options); return { success: true, results }; } @@ -439,32 +439,28 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} * @param {Object} results - Installation results * @param {string} targetDir - Target directory (relative) */ - printSummary(results, targetDir) { - console.log(chalk.green(`\n✓ ${this.name} configured:`)); - if (results.agents > 0) { - console.log(chalk.dim(` - ${results.agents} agents installed`)); - } - if (results.workflows > 0) { - console.log(chalk.dim(` - ${results.workflows} workflow commands generated`)); - } - if (results.tasks > 0 || results.tools > 0) { - console.log(chalk.dim(` - ${results.tasks + results.tools} task/tool commands generated`)); - } - console.log(chalk.dim(` - Destination: ${targetDir}`)); + async printSummary(results, targetDir, options = {}) { + if (options.silent) return; + const parts = []; + if (results.agents > 0) parts.push(`${results.agents} agents`); + if (results.workflows > 0) parts.push(`${results.workflows} workflows`); + if (results.tasks > 0) parts.push(`${results.tasks} tasks`); + if (results.tools > 0) parts.push(`${results.tools} tools`); + await prompts.log.success(`${this.name} configured: ${parts.join(', ')} → ${targetDir}`); } /** * Cleanup IDE configuration * @param {string} projectDir - Project directory */ - async cleanup(projectDir) { + async cleanup(projectDir, options = {}) { // Clean all target directories if (this.installerConfig?.targets) { for (const target of this.installerConfig.targets) { - await this.cleanupTarget(projectDir, target.target_dir); + await this.cleanupTarget(projectDir, target.target_dir, options); } } else if (this.installerConfig?.target_dir) { - await this.cleanupTarget(projectDir, this.installerConfig.target_dir); + await this.cleanupTarget(projectDir, this.installerConfig.target_dir, options); } } @@ -473,7 +469,7 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} * @param {string} projectDir - Project directory * @param {string} targetDir - Target directory to clean */ - async cleanupTarget(projectDir, targetDir) { + async cleanupTarget(projectDir, targetDir, options = {}) { const targetPath = path.join(projectDir, targetDir); if (!(await fs.pathExists(targetPath))) { @@ -496,25 +492,22 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} let removedCount = 0; for (const entry of entries) { - // Skip non-strings or undefined entries if (!entry || typeof entry !== 'string') { continue; } if (entry.startsWith('bmad')) { const entryPath = path.join(targetPath, entry); - const stat = await fs.stat(entryPath); - if (stat.isFile()) { - await fs.remove(entryPath); - removedCount++; - } else if (stat.isDirectory()) { + try { await fs.remove(entryPath); removedCount++; + } catch { + // Skip entries that can't be removed (broken symlinks, permission errors) } } } - if (removedCount > 0) { - console.log(chalk.dim(` Cleaned ${removedCount} BMAD files from ${targetDir}`)); + if (removedCount > 0 && !options.silent) { + await prompts.log.message(` Cleaned ${removedCount} BMAD files from ${targetDir}`); } } } diff --git a/tools/cli/installers/lib/ide/codex.js b/tools/cli/installers/lib/ide/codex.js index 29f595f6c..8e91e003b 100644 --- a/tools/cli/installers/lib/ide/codex.js +++ b/tools/cli/installers/lib/ide/codex.js @@ -1,7 +1,6 @@ const path = require('node:path'); const fs = require('fs-extra'); const os = require('node:os'); -const chalk = require('chalk'); const { BaseIdeSetup } = require('./_base-ide'); const { WorkflowCommandGenerator } = require('./shared/workflow-command-generator'); const { AgentCommandGenerator } = require('./shared/agent-command-generator'); @@ -43,12 +42,11 @@ class CodexSetup extends BaseIdeSetup { default: 'global', }); - // Display detailed instructions for the chosen option - console.log(''); + // Show brief confirmation hint (detailed instructions available via verbose) if (installLocation === 'project') { - console.log(this.getProjectSpecificInstructions()); + await prompts.log.info('Prompts installed to: /.codex/prompts (requires CODEX_HOME)'); } else { - console.log(this.getGlobalInstructions()); + await prompts.log.info('Prompts installed to: ~/.codex/prompts'); } // Confirm the choice @@ -58,7 +56,7 @@ class CodexSetup extends BaseIdeSetup { }); if (!confirmed) { - console.log(chalk.yellow("\n Let's choose a different installation option.\n")); + await prompts.log.warn("Let's choose a different installation option."); } } @@ -72,7 +70,7 @@ class CodexSetup extends BaseIdeSetup { * @param {Object} options - Setup options */ async setup(projectDir, bmadDir, options = {}) { - console.log(chalk.cyan(`Setting up ${this.name}...`)); + if (!options.silent) await prompts.log.info(`Setting up ${this.name}...`); // Always use CLI mode const mode = 'cli'; @@ -84,7 +82,7 @@ class CodexSetup extends BaseIdeSetup { const destDir = this.getCodexPromptDir(projectDir, installLocation); await fs.ensureDir(destDir); - await this.clearOldBmadFiles(destDir); + await this.clearOldBmadFiles(destDir, options); // Collect artifacts and write using underscore format const agentGen = new AgentCommandGenerator(this.bmadFolderName); @@ -124,16 +122,11 @@ class CodexSetup extends BaseIdeSetup { const written = agentCount + workflowCount + tasksWritten; - console.log(chalk.green(`✓ ${this.name} configured:`)); - console.log(chalk.dim(` - Mode: CLI`)); - console.log(chalk.dim(` - ${counts.agents} agents exported`)); - console.log(chalk.dim(` - ${counts.tasks} tasks exported`)); - console.log(chalk.dim(` - ${counts.workflows} workflow commands exported`)); - if (counts.workflowLaunchers > 0) { - console.log(chalk.dim(` - ${counts.workflowLaunchers} workflow launchers exported`)); + if (!options.silent) { + await prompts.log.success( + `${this.name} configured: ${counts.agents} agents, ${counts.workflows} workflows, ${counts.tasks} tasks, ${written} files → ${destDir}`, + ); } - console.log(chalk.dim(` - ${written} Codex prompt files written`)); - console.log(chalk.dim(` - Destination: ${destDir}`)); return { success: true, @@ -262,7 +255,7 @@ class CodexSetup extends BaseIdeSetup { return written; } - async clearOldBmadFiles(destDir) { + async clearOldBmadFiles(destDir, options = {}) { if (!(await fs.pathExists(destDir))) { return; } @@ -272,7 +265,7 @@ class CodexSetup extends BaseIdeSetup { entries = await fs.readdir(destDir); } catch (error) { // Directory exists but can't be read - skip cleanup - console.warn(chalk.yellow(`Warning: Could not read directory ${destDir}: ${error.message}`)); + if (!options.silent) await prompts.log.warn(`Warning: Could not read directory ${destDir}: ${error.message}`); return; } @@ -291,15 +284,11 @@ class CodexSetup extends BaseIdeSetup { const entryPath = path.join(destDir, entry); try { - const stat = await fs.stat(entryPath); - if (stat.isFile()) { - await fs.remove(entryPath); - } else if (stat.isDirectory()) { - await fs.remove(entryPath); - } + await fs.remove(entryPath); } catch (error) { - // Skip files that can't be processed - console.warn(chalk.dim(` Skipping ${entry}: ${error.message}`)); + if (!options.silent) { + await prompts.log.message(` Skipping ${entry}: ${error.message}`); + } } } } @@ -315,22 +304,16 @@ class CodexSetup extends BaseIdeSetup { */ getGlobalInstructions(destDir) { const lines = [ + 'IMPORTANT: Codex Configuration', '', - chalk.bold.cyan('═'.repeat(70)), - chalk.bold.yellow(' IMPORTANT: Codex Configuration'), - chalk.bold.cyan('═'.repeat(70)), + '/prompts installed globally to your HOME DIRECTORY.', '', - chalk.white(' /prompts installed globally to your HOME DIRECTORY.'), - '', - chalk.yellow(' ⚠️ These prompts reference a specific _bmad path'), - chalk.dim(" To use with other projects, you'd need to copy the _bmad dir"), - '', - chalk.green(' ✓ You can now use /commands in Codex CLI'), - chalk.dim(' Example: /bmad_bmm_pm'), - chalk.dim(' Type / to see all available commands'), - '', - chalk.bold.cyan('═'.repeat(70)), + 'These prompts reference a specific _bmad path.', + "To use with other projects, you'd need to copy the _bmad dir.", '', + 'You can now use /commands in Codex CLI', + ' Example: /bmad_bmm_pm', + ' Type / to see all available commands', ]; return lines.join('\n'); } @@ -345,43 +328,34 @@ class CodexSetup extends BaseIdeSetup { const isWindows = os.platform() === 'win32'; const commonLines = [ + 'Project-Specific Codex Configuration', '', - chalk.bold.cyan('═'.repeat(70)), - chalk.bold.yellow(' Project-Specific Codex Configuration'), - chalk.bold.cyan('═'.repeat(70)), + `Prompts will be installed to: ${destDir || '/.codex/prompts'}`, '', - chalk.white(' Prompts will be installed to: ') + chalk.cyan(destDir || '/.codex/prompts'), - '', - chalk.bold.yellow(' ⚠️ REQUIRED: You must set CODEX_HOME to use these prompts'), + 'REQUIRED: You must set CODEX_HOME to use these prompts', '', ]; const windowsLines = [ - chalk.bold(' Create a codex.cmd file in your project root:'), + 'Create a codex.cmd file in your project root:', '', - chalk.green(' @echo off'), - chalk.green(' set CODEX_HOME=%~dp0.codex'), - chalk.green(' codex %*'), + ' @echo off', + ' set CODEX_HOME=%~dp0.codex', + ' codex %*', '', - chalk.dim(String.raw` Then run: .\codex instead of codex`), - chalk.dim(' (The %~dp0 gets the directory of the .cmd file)'), + String.raw`Then run: .\codex instead of codex`, + '(The %~dp0 gets the directory of the .cmd file)', ]; const unixLines = [ - chalk.bold(' Add this alias to your ~/.bashrc or ~/.zshrc:'), + 'Add this alias to your ~/.bashrc or ~/.zshrc:', '', - chalk.green(' alias codex=\'CODEX_HOME="$PWD/.codex" codex\''), - '', - chalk.dim(' After adding, run: source ~/.bashrc (or source ~/.zshrc)'), - chalk.dim(' (The $PWD uses your current working directory)'), - ]; - const closingLines = [ - '', - chalk.dim(' This tells Codex CLI to use prompts from this project instead of ~/.codex'), - '', - chalk.bold.cyan('═'.repeat(70)), + ' alias codex=\'CODEX_HOME="$PWD/.codex" codex\'', '', + 'After adding, run: source ~/.bashrc (or source ~/.zshrc)', + '(The $PWD uses your current working directory)', ]; + const closingLines = ['', 'This tells Codex CLI to use prompts from this project instead of ~/.codex']; const lines = [...commonLines, ...(isWindows ? windowsLines : unixLines), ...closingLines]; diff --git a/tools/cli/installers/lib/ide/kilo.js b/tools/cli/installers/lib/ide/kilo.js index 52fd17c90..2e5734391 100644 --- a/tools/cli/installers/lib/ide/kilo.js +++ b/tools/cli/installers/lib/ide/kilo.js @@ -1,7 +1,7 @@ const path = require('node:path'); const { BaseIdeSetup } = require('./_base-ide'); -const chalk = require('chalk'); const yaml = require('yaml'); +const prompts = require('../../../lib/prompts'); const { AgentCommandGenerator } = require('./shared/agent-command-generator'); const { WorkflowCommandGenerator } = require('./shared/workflow-command-generator'); const { TaskToolCommandGenerator } = require('./shared/task-tool-command-generator'); @@ -23,10 +23,10 @@ class KiloSetup extends BaseIdeSetup { * @param {Object} options - Setup options */ async setup(projectDir, bmadDir, options = {}) { - console.log(chalk.cyan(`Setting up ${this.name}...`)); + if (!options.silent) await prompts.log.info(`Setting up ${this.name}...`); // Clean up any old BMAD installation first - await this.cleanup(projectDir); + await this.cleanup(projectDir, options); // Load existing config (may contain non-BMAD modes and other settings) const kiloModesPath = path.join(projectDir, this.configFile); @@ -38,7 +38,7 @@ class KiloSetup extends BaseIdeSetup { config = yaml.parse(existingContent) || {}; } catch { // If parsing fails, start fresh but warn user - console.log(chalk.yellow('Warning: Could not parse existing .kilocodemodes, starting fresh')); + await prompts.log.warn('Warning: Could not parse existing .kilocodemodes, starting fresh'); config = {}; } } @@ -88,14 +88,11 @@ class KiloSetup extends BaseIdeSetup { const taskCount = taskToolCounts.tasks || 0; const toolCount = taskToolCounts.tools || 0; - console.log(chalk.green(`✓ ${this.name} configured:`)); - console.log(chalk.dim(` - ${addedCount} modes added`)); - console.log(chalk.dim(` - ${workflowCount} workflows exported`)); - console.log(chalk.dim(` - ${taskCount} tasks exported`)); - console.log(chalk.dim(` - ${toolCount} tools exported`)); - console.log(chalk.dim(` - Configuration file: ${this.configFile}`)); - console.log(chalk.dim(` - Workflows directory: .kilocode/workflows/`)); - console.log(chalk.dim('\n Modes will be available when you open this project in KiloCode')); + if (!options.silent) { + await prompts.log.success( + `${this.name} configured: ${addedCount} modes, ${workflowCount} workflows, ${taskCount} tasks, ${toolCount} tools → ${this.configFile}`, + ); + } return { success: true, @@ -174,7 +171,7 @@ class KiloSetup extends BaseIdeSetup { /** * Cleanup KiloCode configuration */ - async cleanup(projectDir) { + async cleanup(projectDir, options = {}) { const fs = require('fs-extra'); const kiloModesPath = path.join(projectDir, this.configFile); @@ -192,12 +189,12 @@ class KiloSetup extends BaseIdeSetup { if (removedCount > 0) { await fs.writeFile(kiloModesPath, yaml.stringify(config, { lineWidth: 0 })); - console.log(chalk.dim(`Removed ${removedCount} BMAD modes from .kilocodemodes`)); + if (!options.silent) await prompts.log.message(`Removed ${removedCount} BMAD modes from .kilocodemodes`); } } } catch { // If parsing fails, leave file as-is - console.log(chalk.yellow('Warning: Could not parse .kilocodemodes for cleanup')); + if (!options.silent) await prompts.log.warn('Warning: Could not parse .kilocodemodes for cleanup'); } } diff --git a/tools/cli/installers/lib/ide/kiro-cli.js b/tools/cli/installers/lib/ide/kiro-cli.js index 612ea5fa4..150dca189 100644 --- a/tools/cli/installers/lib/ide/kiro-cli.js +++ b/tools/cli/installers/lib/ide/kiro-cli.js @@ -1,7 +1,7 @@ const path = require('node:path'); const { BaseIdeSetup } = require('./_base-ide'); -const chalk = require('chalk'); const fs = require('fs-extra'); +const prompts = require('../../../lib/prompts'); const yaml = require('yaml'); /** @@ -18,7 +18,7 @@ class KiroCliSetup extends BaseIdeSetup { * Cleanup old BMAD installation before reinstalling * @param {string} projectDir - Project directory */ - async cleanup(projectDir) { + async cleanup(projectDir, options = {}) { const bmadAgentsDir = path.join(projectDir, this.configDir, this.agentsDir); if (await fs.pathExists(bmadAgentsDir)) { @@ -29,7 +29,7 @@ class KiroCliSetup extends BaseIdeSetup { await fs.remove(path.join(bmadAgentsDir, file)); } } - console.log(chalk.dim(` Cleaned old BMAD agents from ${this.name}`)); + if (!options.silent) await prompts.log.message(` Cleaned old BMAD agents from ${this.name}`); } } @@ -40,9 +40,9 @@ class KiroCliSetup extends BaseIdeSetup { * @param {Object} options - Setup options */ async setup(projectDir, bmadDir, options = {}) { - console.log(chalk.cyan(`Setting up ${this.name}...`)); + if (!options.silent) await prompts.log.info(`Setting up ${this.name}...`); - await this.cleanup(projectDir); + await this.cleanup(projectDir, options); const kiroDir = path.join(projectDir, this.configDir); const agentsDir = path.join(kiroDir, this.agentsDir); @@ -52,7 +52,7 @@ class KiroCliSetup extends BaseIdeSetup { // Create BMad agents from source YAML files await this.createBmadAgentsFromSource(agentsDir, projectDir); - console.log(chalk.green(`✓ ${this.name} configured with BMad agents`)); + if (!options.silent) await prompts.log.success(`${this.name} configured with BMad agents`); } /** @@ -70,7 +70,7 @@ class KiroCliSetup extends BaseIdeSetup { try { await this.processAgentFile(agentFile, agentsDir, projectDir); } catch (error) { - console.warn(chalk.yellow(`⚠️ Failed to process ${agentFile}: ${error.message}`)); + await prompts.log.warn(`Failed to process ${agentFile}: ${error.message}`); } } } diff --git a/tools/cli/installers/lib/ide/manager.js b/tools/cli/installers/lib/ide/manager.js index 7d00588c0..ad3352502 100644 --- a/tools/cli/installers/lib/ide/manager.js +++ b/tools/cli/installers/lib/ide/manager.js @@ -1,7 +1,7 @@ const fs = require('fs-extra'); const path = require('node:path'); -const chalk = require('chalk'); const { BMAD_FOLDER_NAME } = require('./shared/path-utils'); +const prompts = require('../../../lib/prompts'); /** * IDE Manager - handles IDE-specific setup @@ -49,7 +49,7 @@ class IdeManager { */ async loadHandlers() { // Load custom installer files - this.loadCustomInstallerFiles(); + await this.loadCustomInstallerFiles(); // Load config-driven handlers from platform-codes.yaml await this.loadConfigDrivenHandlers(); @@ -59,7 +59,7 @@ class IdeManager { * Load custom installer files (unique installation logic) * These files have special installation patterns that don't fit the config-driven model */ - loadCustomInstallerFiles() { + async loadCustomInstallerFiles() { const ideDir = __dirname; const customFiles = ['codex.js', 'kilo.js', 'kiro-cli.js']; @@ -81,7 +81,7 @@ class IdeManager { } } } catch (error) { - console.log(chalk.yellow(` Warning: Could not load ${file}: ${error.message}`)); + await prompts.log.warn(`Warning: Could not load ${file}: ${error.message}`); } } } @@ -171,17 +171,45 @@ class IdeManager { const handler = this.handlers.get(ideName.toLowerCase()); if (!handler) { - console.warn(chalk.yellow(`⚠️ IDE '${ideName}' is not yet supported`)); - console.log(chalk.dim('Supported IDEs:', [...this.handlers.keys()].join(', '))); - return { success: false, reason: 'unsupported' }; + await prompts.log.warn(`IDE '${ideName}' is not yet supported`); + await prompts.log.message(`Supported IDEs: ${[...this.handlers.keys()].join(', ')}`); + return { success: false, ide: ideName, error: 'unsupported IDE' }; } try { - await handler.setup(projectDir, bmadDir, options); - return { success: true, ide: ideName }; + const handlerResult = await handler.setup(projectDir, bmadDir, options); + // Build detail string from handler-returned data + let detail = ''; + if (handlerResult && handlerResult.results) { + // Config-driven handlers return { success, results: { agents, workflows, tasks, tools } } + const r = handlerResult.results; + const parts = []; + if (r.agents > 0) parts.push(`${r.agents} agents`); + if (r.workflows > 0) parts.push(`${r.workflows} workflows`); + if (r.tasks > 0) parts.push(`${r.tasks} tasks`); + if (r.tools > 0) parts.push(`${r.tools} tools`); + detail = parts.join(', '); + } else if (handlerResult && handlerResult.counts) { + // Codex handler returns { success, counts: { agents, workflows, tasks }, written } + const c = handlerResult.counts; + const parts = []; + if (c.agents > 0) parts.push(`${c.agents} agents`); + if (c.workflows > 0) parts.push(`${c.workflows} workflows`); + if (c.tasks > 0) parts.push(`${c.tasks} tasks`); + detail = parts.join(', '); + } else if (handlerResult && handlerResult.modes !== undefined) { + // Kilo handler returns { success, modes, workflows, tasks, tools } + const parts = []; + if (handlerResult.modes > 0) parts.push(`${handlerResult.modes} modes`); + if (handlerResult.workflows > 0) parts.push(`${handlerResult.workflows} workflows`); + if (handlerResult.tasks > 0) parts.push(`${handlerResult.tasks} tasks`); + if (handlerResult.tools > 0) parts.push(`${handlerResult.tools} tools`); + detail = parts.join(', '); + } + return { success: true, ide: ideName, detail, handlerResult }; } catch (error) { - console.error(chalk.red(`Failed to setup ${ideName}:`), error.message); - return { success: false, error: error.message }; + await prompts.log.error(`Failed to setup ${ideName}: ${error.message}`); + return { success: false, ide: ideName, error: error.message }; } } @@ -254,7 +282,7 @@ class IdeManager { const handler = this.handlers.get(ideName.toLowerCase()); if (!handler) { - console.warn(chalk.yellow(`⚠️ IDE '${ideName}' is not yet supported for custom agent installation`)); + await prompts.log.warn(`IDE '${ideName}' is not yet supported for custom agent installation`); continue; } @@ -266,7 +294,7 @@ class IdeManager { } } } catch (error) { - console.warn(chalk.yellow(`⚠️ Failed to install ${ideName} launcher: ${error.message}`)); + await prompts.log.warn(`Failed to install ${ideName} launcher: ${error.message}`); } } diff --git a/tools/cli/installers/lib/ide/shared/agent-command-generator.js b/tools/cli/installers/lib/ide/shared/agent-command-generator.js index caf60614f..0915c306b 100644 --- a/tools/cli/installers/lib/ide/shared/agent-command-generator.js +++ b/tools/cli/installers/lib/ide/shared/agent-command-generator.js @@ -1,6 +1,5 @@ const path = require('node:path'); const fs = require('fs-extra'); -const chalk = require('chalk'); const { toColonPath, toDashPath, customAgentColonName, customAgentDashName, BMAD_FOLDER_NAME } = require('./path-utils'); /** diff --git a/tools/cli/installers/lib/ide/shared/task-tool-command-generator.js b/tools/cli/installers/lib/ide/shared/task-tool-command-generator.js index b293fc0e0..ece1c8630 100644 --- a/tools/cli/installers/lib/ide/shared/task-tool-command-generator.js +++ b/tools/cli/installers/lib/ide/shared/task-tool-command-generator.js @@ -1,7 +1,6 @@ const path = require('node:path'); const fs = require('fs-extra'); const csv = require('csv-parse/sync'); -const chalk = require('chalk'); const { toColonName, toColonPath, toDashPath, BMAD_FOLDER_NAME } = require('./path-utils'); /** diff --git a/tools/cli/installers/lib/ide/shared/workflow-command-generator.js b/tools/cli/installers/lib/ide/shared/workflow-command-generator.js index 5a23fda2f..d94e77db1 100644 --- a/tools/cli/installers/lib/ide/shared/workflow-command-generator.js +++ b/tools/cli/installers/lib/ide/shared/workflow-command-generator.js @@ -1,7 +1,7 @@ const path = require('node:path'); const fs = require('fs-extra'); const csv = require('csv-parse/sync'); -const chalk = require('chalk'); +const prompts = require('../../../../lib/prompts'); const { toColonPath, toDashPath, customAgentColonName, customAgentDashName, BMAD_FOLDER_NAME } = require('./path-utils'); /** @@ -22,7 +22,7 @@ class WorkflowCommandGenerator { const workflows = await this.loadWorkflowManifest(bmadDir); if (!workflows) { - console.log(chalk.yellow('Workflow manifest not found. Skipping command generation.')); + await prompts.log.warn('Workflow manifest not found. Skipping command generation.'); return { generated: 0 }; } @@ -157,8 +157,7 @@ class WorkflowCommandGenerator { .replaceAll('{{module}}', workflow.module) .replaceAll('{{description}}', workflow.description) .replaceAll('{{workflow_path}}', workflowPath) - .replaceAll('_bmad', this.bmadFolderName) - .replaceAll('_bmad', '_bmad'); + .replaceAll('_bmad', this.bmadFolderName); } /** @@ -238,15 +237,15 @@ When running any workflow: const match = workflowPath.match(/\/src\/bmm\/(.+)/); if (match) { transformed = `{project-root}/${this.bmadFolderName}/bmm/${match[1]}`; - } else if (workflowPath.includes('/src/core/')) { - const match = workflowPath.match(/\/src\/core\/(.+)/); - if (match) { - transformed = `{project-root}/${this.bmadFolderName}/core/${match[1]}`; - } } - - return transformed; + } else if (workflowPath.includes('/src/core/')) { + const match = workflowPath.match(/\/src\/core\/(.+)/); + if (match) { + transformed = `{project-root}/${this.bmadFolderName}/core/${match[1]}`; + } } + + return transformed; } async loadWorkflowManifest(bmadDir) { diff --git a/tools/cli/installers/lib/message-loader.js b/tools/cli/installers/lib/message-loader.js index dd1126693..7198f0328 100644 --- a/tools/cli/installers/lib/message-loader.js +++ b/tools/cli/installers/lib/message-loader.js @@ -1,7 +1,7 @@ const fs = require('fs-extra'); const path = require('node:path'); const yaml = require('yaml'); -const chalk = require('chalk'); +const prompts = require('../../lib/prompts'); /** * Load and display installer messages from messages.yaml @@ -51,22 +51,20 @@ class MessageLoader { /** * Display the start message (after logo, before prompts) */ - displayStartMessage() { + async displayStartMessage() { const message = this.getStartMessage(); if (message) { - console.log(chalk.cyan(message)); - console.log(); + await prompts.log.info(message); } } /** * Display the end message (after installation completes) */ - displayEndMessage() { + async displayEndMessage() { const message = this.getEndMessage(); if (message) { - console.log(); - console.log(chalk.cyan(message)); + await prompts.log.info(message); } } diff --git a/tools/cli/installers/lib/modules/manager.js b/tools/cli/installers/lib/modules/manager.js index c55dae838..0af4312fc 100644 --- a/tools/cli/installers/lib/modules/manager.js +++ b/tools/cli/installers/lib/modules/manager.js @@ -1,8 +1,7 @@ const path = require('node:path'); const fs = require('fs-extra'); const yaml = require('yaml'); -const chalk = require('chalk'); -const ora = require('ora'); +const prompts = require('../../../lib/prompts'); const { XmlHandler } = require('../../../lib/xml-handler'); const { getProjectRoot, getSourcePath, getModulePath } = require('../../../lib/project-root'); const { filterCustomizationData } = require('../../../lib/agent/compiler'); @@ -17,7 +16,7 @@ const { BMAD_FOLDER_NAME } = require('../ide/shared/path-utils'); * @class ModuleManager * @requires fs-extra * @requires yaml - * @requires chalk + * @requires prompts * @requires XmlHandler * * @example @@ -152,26 +151,26 @@ class ModuleManager { // File hasn't been modified by user, safe to update await this.copyFileWithPlaceholderReplacement(sourceFilePath, targetFilePath, true); if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Updated sidecar file: ${relativeToBmad}`)); + await prompts.log.message(` Updated sidecar file: ${relativeToBmad}`); } } else { // User has modified the file, preserve it if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Preserving user-modified file: ${relativeToBmad}`)); + await prompts.log.message(` Preserving user-modified file: ${relativeToBmad}`); } } } else { // First time seeing this file in manifest, copy it await this.copyFileWithPlaceholderReplacement(sourceFilePath, targetFilePath, true); if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Added new sidecar file: ${relativeToBmad}`)); + await prompts.log.message(` Added new sidecar file: ${relativeToBmad}`); } } } else { // New installation await this.copyFileWithPlaceholderReplacement(sourceFilePath, targetFilePath, true); if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Copied sidecar file: ${relativeToBmad}`)); + await prompts.log.message(` Copied sidecar file: ${relativeToBmad}`); } } @@ -288,7 +287,7 @@ class ModuleManager { moduleInfo.dependencies = config.dependencies || []; moduleInfo.defaultSelected = config.default_selected === undefined ? false : config.default_selected; } catch (error) { - console.warn(`Failed to read config for ${defaultName}:`, error.message); + await prompts.log.warn(`Failed to read config for ${defaultName}: ${error.message}`); } return moduleInfo; @@ -299,7 +298,7 @@ class ModuleManager { * @param {string} moduleCode - Code of the module to find (from module.yaml) * @returns {string|null} Path to the module source or null if not found */ - async findModuleSource(moduleCode) { + async findModuleSource(moduleCode, options = {}) { const projectRoot = getProjectRoot(); // First check custom module paths if they exist @@ -316,7 +315,7 @@ class ModuleManager { } // Check external official modules - const externalSource = await this.findExternalModuleSource(moduleCode); + const externalSource = await this.findExternalModuleSource(moduleCode, options); if (externalSource) { return externalSource; } @@ -348,7 +347,7 @@ class ModuleManager { * @param {string} moduleCode - Code of the external module * @returns {string} Path to the cloned repository */ - async cloneExternalModule(moduleCode) { + async cloneExternalModule(moduleCode, options = {}) { const { execSync } = require('node:child_process'); const moduleInfo = await this.externalModuleManager.getModuleByCode(moduleCode); @@ -358,10 +357,32 @@ class ModuleManager { const cacheDir = this.getExternalCacheDir(); const moduleCacheDir = path.join(cacheDir, moduleCode); + const silent = options.silent || false; // Create cache directory if it doesn't exist await fs.ensureDir(cacheDir); + // Helper to create a spinner or a no-op when silent + const createSpinner = async () => { + if (silent) { + return { + start() {}, + stop() {}, + error() {}, + message() {}, + cancel() {}, + clear() {}, + get isSpinning() { + return false; + }, + get isCancelled() { + return false; + }, + }; + } + return await prompts.spinner(); + }; + // Track if we need to install dependencies let needsDependencyInstall = false; let wasNewClone = false; @@ -369,21 +390,30 @@ class ModuleManager { // Check if already cloned if (await fs.pathExists(moduleCacheDir)) { // Try to update if it's a git repo - const fetchSpinner = ora(`Fetching ${moduleInfo.name}...`).start(); + const fetchSpinner = await createSpinner(); + fetchSpinner.start(`Fetching ${moduleInfo.name}...`); try { const currentRef = execSync('git rev-parse HEAD', { cwd: moduleCacheDir, stdio: 'pipe' }).toString().trim(); // Fetch and reset to remote - works better with shallow clones than pull - execSync('git fetch origin --depth 1', { cwd: moduleCacheDir, stdio: 'pipe' }); - execSync('git reset --hard origin/HEAD', { cwd: moduleCacheDir, stdio: 'pipe' }); + execSync('git fetch origin --depth 1', { + cwd: moduleCacheDir, + stdio: ['ignore', 'pipe', 'pipe'], + env: { ...process.env, GIT_TERMINAL_PROMPT: '0' }, + }); + execSync('git reset --hard origin/HEAD', { + cwd: moduleCacheDir, + stdio: ['ignore', 'pipe', 'pipe'], + env: { ...process.env, GIT_TERMINAL_PROMPT: '0' }, + }); const newRef = execSync('git rev-parse HEAD', { cwd: moduleCacheDir, stdio: 'pipe' }).toString().trim(); - fetchSpinner.succeed(`Fetched ${moduleInfo.name}`); + fetchSpinner.stop(`Fetched ${moduleInfo.name}`); // Force dependency install if we got new code if (currentRef !== newRef) { needsDependencyInstall = true; } } catch { - fetchSpinner.warn(`Fetch failed, re-downloading ${moduleInfo.name}`); + fetchSpinner.error(`Fetch failed, re-downloading ${moduleInfo.name}`); // If update fails, remove and re-clone await fs.remove(moduleCacheDir); wasNewClone = true; @@ -394,14 +424,16 @@ class ModuleManager { // Clone if not exists or was removed if (wasNewClone) { - const fetchSpinner = ora(`Fetching ${moduleInfo.name}...`).start(); + const fetchSpinner = await createSpinner(); + fetchSpinner.start(`Fetching ${moduleInfo.name}...`); try { execSync(`git clone --depth 1 "${moduleInfo.url}" "${moduleCacheDir}"`, { - stdio: 'pipe', + stdio: ['ignore', 'pipe', 'pipe'], + env: { ...process.env, GIT_TERMINAL_PROMPT: '0' }, }); - fetchSpinner.succeed(`Fetched ${moduleInfo.name}`); + fetchSpinner.stop(`Fetched ${moduleInfo.name}`); } catch (error) { - fetchSpinner.fail(`Failed to fetch ${moduleInfo.name}`); + fetchSpinner.error(`Failed to fetch ${moduleInfo.name}`); throw new Error(`Failed to clone external module '${moduleCode}': ${error.message}`); } } @@ -415,17 +447,18 @@ class ModuleManager { // Force install if we updated or cloned new if (needsDependencyInstall || wasNewClone || nodeModulesMissing) { - const installSpinner = ora(`Installing dependencies for ${moduleInfo.name}...`).start(); + const installSpinner = await createSpinner(); + installSpinner.start(`Installing dependencies for ${moduleInfo.name}...`); try { execSync('npm install --omit=dev --no-audit --no-fund --no-progress --legacy-peer-deps', { cwd: moduleCacheDir, - stdio: 'pipe', + stdio: ['ignore', 'pipe', 'pipe'], timeout: 120_000, // 2 minute timeout }); - installSpinner.succeed(`Installed dependencies for ${moduleInfo.name}`); + installSpinner.stop(`Installed dependencies for ${moduleInfo.name}`); } catch (error) { - installSpinner.warn(`Failed to install dependencies for ${moduleInfo.name}`); - console.warn(chalk.yellow(` Warning: ${error.message}`)); + installSpinner.error(`Failed to install dependencies for ${moduleInfo.name}`); + if (!silent) await prompts.log.warn(` Warning: ${error.message}`); } } else { // Check if package.json is newer than node_modules @@ -440,17 +473,18 @@ class ModuleManager { } if (packageJsonNewer) { - const installSpinner = ora(`Installing dependencies for ${moduleInfo.name}...`).start(); + const installSpinner = await createSpinner(); + installSpinner.start(`Installing dependencies for ${moduleInfo.name}...`); try { execSync('npm install --omit=dev --no-audit --no-fund --no-progress --legacy-peer-deps', { cwd: moduleCacheDir, - stdio: 'pipe', + stdio: ['ignore', 'pipe', 'pipe'], timeout: 120_000, // 2 minute timeout }); - installSpinner.succeed(`Installed dependencies for ${moduleInfo.name}`); + installSpinner.stop(`Installed dependencies for ${moduleInfo.name}`); } catch (error) { - installSpinner.warn(`Failed to install dependencies for ${moduleInfo.name}`); - console.warn(chalk.yellow(` Warning: ${error.message}`)); + installSpinner.error(`Failed to install dependencies for ${moduleInfo.name}`); + if (!silent) await prompts.log.warn(` Warning: ${error.message}`); } } } @@ -464,7 +498,7 @@ class ModuleManager { * @param {string} moduleCode - Code of the external module * @returns {string|null} Path to the module source or null if not found */ - async findExternalModuleSource(moduleCode) { + async findExternalModuleSource(moduleCode, options = {}) { const moduleInfo = await this.externalModuleManager.getModuleByCode(moduleCode); if (!moduleInfo) { @@ -472,7 +506,7 @@ class ModuleManager { } // Clone the external module repo - const cloneDir = await this.cloneExternalModule(moduleCode); + const cloneDir = await this.cloneExternalModule(moduleCode, options); // The module-definition specifies the path to module.yaml relative to repo root // We need to return the directory containing module.yaml @@ -493,7 +527,7 @@ class ModuleManager { * @param {Object} options.logger - Logger instance for output */ async install(moduleName, bmadDir, fileTrackingCallback = null, options = {}) { - const sourcePath = await this.findModuleSource(moduleName); + const sourcePath = await this.findModuleSource(moduleName, { silent: options.silent }); const targetPath = path.join(bmadDir, moduleName); // Check if source module exists @@ -514,14 +548,14 @@ class ModuleManager { const customContent = await fs.readFile(rootCustomConfigPath, 'utf8'); customConfig = yaml.parse(customContent); } catch (error) { - console.warn(chalk.yellow(`Warning: Failed to read custom.yaml for ${moduleName}:`, error.message)); + await prompts.log.warn(`Warning: Failed to read custom.yaml for ${moduleName}: ${error.message}`); } } else if (await fs.pathExists(moduleInstallerCustomPath)) { try { const customContent = await fs.readFile(moduleInstallerCustomPath, 'utf8'); customConfig = yaml.parse(customContent); } catch (error) { - console.warn(chalk.yellow(`Warning: Failed to read custom.yaml for ${moduleName}:`, error.message)); + await prompts.log.warn(`Warning: Failed to read custom.yaml for ${moduleName}: ${error.message}`); } } @@ -529,7 +563,7 @@ class ModuleManager { if (customConfig) { options.moduleConfig = { ...options.moduleConfig, ...customConfig }; if (options.logger) { - options.logger.log(chalk.cyan(` Merged custom configuration for ${moduleName}`)); + options.logger.log(` Merged custom configuration for ${moduleName}`); } } @@ -582,7 +616,7 @@ class ModuleManager { * @param {string} bmadDir - Target bmad directory * @param {boolean} force - Force update (overwrite modifications) */ - async update(moduleName, bmadDir, force = false) { + async update(moduleName, bmadDir, force = false, options = {}) { const sourcePath = await this.findModuleSource(moduleName); const targetPath = path.join(bmadDir, moduleName); @@ -599,7 +633,7 @@ class ModuleManager { if (force) { // Force update - remove and reinstall await fs.remove(targetPath); - return await this.install(moduleName, bmadDir); + return await this.install(moduleName, bmadDir, null, { installer: options.installer }); } else { // Selective update - preserve user modifications await this.syncModule(sourcePath, targetPath); @@ -673,7 +707,7 @@ class ModuleManager { const config = yaml.parse(configContent); Object.assign(moduleInfo, config); } catch (error) { - console.warn(`Failed to read installed module config:`, error.message); + await prompts.log.warn(`Failed to read installed module config: ${error.message}`); } } @@ -735,7 +769,7 @@ class ModuleManager { // Check for localskip="true" in the agent tag const agentMatch = content.match(/]*\slocalskip="true"[^>]*>/); if (agentMatch) { - console.log(chalk.dim(` Skipping web-only agent: ${path.basename(file)}`)); + await prompts.log.message(` Skipping web-only agent: ${path.basename(file)}`); continue; // Skip this agent } } @@ -768,7 +802,6 @@ class ModuleManager { // IMPORTANT: Replace escape sequence and placeholder BEFORE parsing YAML // Otherwise parsing will fail on the placeholder - yamlContent = yamlContent.replaceAll('_bmad', '_bmad'); yamlContent = yamlContent.replaceAll('_bmad', this.bmadFolderName); try { @@ -838,7 +871,7 @@ class ModuleManager { await fs.writeFile(targetFile, strippedYaml, 'utf8'); } catch { // If anything fails, just copy the file as-is - console.warn(chalk.yellow(` Warning: Could not process ${path.basename(sourceFile)}, copying as-is`)); + await prompts.log.warn(` Warning: Could not process ${path.basename(sourceFile)}, copying as-is`); await fs.copy(sourceFile, targetFile, { overwrite: true }); } } @@ -890,7 +923,7 @@ class ModuleManager { await this.copyFileWithPlaceholderReplacement(genericTemplatePath, customizePath); // Only show customize creation in verbose mode if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.dim(` Created customize: ${moduleName}-${agentName}.customize.yaml`)); + await prompts.log.message(` Created customize: ${moduleName}-${agentName}.customize.yaml`); } // Store original hash for modification detection @@ -990,10 +1023,10 @@ class ModuleManager { const copiedFiles = await this.copySidecarToMemory(sourceSidecarPath, agentName, bmadMemoryPath, isUpdate, bmadDir, installer); if (process.env.BMAD_VERBOSE_INSTALL === 'true' && copiedFiles.length > 0) { - console.log(chalk.dim(` Sidecar files processed: ${copiedFiles.length} files`)); + await prompts.log.message(` Sidecar files processed: ${copiedFiles.length} files`); } } else if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log(chalk.yellow(` Warning: Agent marked as having sidecar but ${sidecarDirName} directory not found`)); + await prompts.log.warn(` Warning: Agent marked as having sidecar but ${sidecarDirName} directory not found`); } } @@ -1012,14 +1045,12 @@ class ModuleManager { // Only show compilation details in verbose mode if (process.env.BMAD_VERBOSE_INSTALL === 'true') { - console.log( - chalk.dim( - ` Compiled agent: ${agentName} -> ${path.relative(targetPath, targetMdPath)}${hasSidecar ? ' (with sidecar)' : ''}`, - ), + await prompts.log.message( + ` Compiled agent: ${agentName} -> ${path.relative(targetPath, targetMdPath)}${hasSidecar ? ' (with sidecar)' : ''}`, ); } } catch (error) { - console.warn(chalk.yellow(` Failed to compile agent ${agentName}:`, error.message)); + await prompts.log.warn(` Failed to compile agent ${agentName}: ${error.message}`); } } } @@ -1139,11 +1170,11 @@ class ModuleManager { } if (!workflowsVendored) { - console.log(chalk.cyan(`\n Vendoring cross-module workflows for ${moduleName}...`)); + await prompts.log.info(`\n Vendoring cross-module workflows for ${moduleName}...`); workflowsVendored = true; } - console.log(chalk.dim(` Processing: ${agentFile}`)); + await prompts.log.message(` Processing: ${agentFile}`); for (const item of workflowInstallItems) { const sourceWorkflowPath = item.workflow; // Where to copy FROM @@ -1155,7 +1186,7 @@ class ModuleManager { // Or: {project-root}/bmad/bmm/workflows/4-implementation/create-story/workflow.yaml const sourceMatch = sourceWorkflowPath.match(/\{project-root\}\/(?:_bmad)\/([^/]+)\/workflows\/(.+)/); if (!sourceMatch) { - console.warn(chalk.yellow(` Could not parse workflow path: ${sourceWorkflowPath}`)); + await prompts.log.warn(` Could not parse workflow path: ${sourceWorkflowPath}`); continue; } @@ -1166,7 +1197,7 @@ class ModuleManager { // Example: {project-root}/_bmad/bmgd/workflows/4-production/create-story/workflow.yaml const installMatch = installWorkflowPath.match(/\{project-root\}\/(_bmad)\/([^/]+)\/workflows\/(.+)/); if (!installMatch) { - console.warn(chalk.yellow(` Could not parse workflow-install path: ${installWorkflowPath}`)); + await prompts.log.warn(` Could not parse workflow-install path: ${installWorkflowPath}`); continue; } @@ -1179,15 +1210,13 @@ class ModuleManager { // Check if source workflow exists if (!(await fs.pathExists(actualSourceWorkflowPath))) { - console.warn(chalk.yellow(` Source workflow not found: ${actualSourceWorkflowPath}`)); + await prompts.log.warn(` Source workflow not found: ${actualSourceWorkflowPath}`); continue; } // Copy the entire workflow folder - console.log( - chalk.dim( - ` Vendoring: ${sourceModule}/workflows/${sourceWorkflowSubPath.replace(/\/workflow\.yaml$/, '')} → ${moduleName}/workflows/${installWorkflowSubPath.replace(/\/workflow\.yaml$/, '')}`, - ), + await prompts.log.message( + ` Vendoring: ${sourceModule}/workflows/${sourceWorkflowSubPath.replace(/\/workflow\.yaml$/, '')} → ${moduleName}/workflows/${installWorkflowSubPath.replace(/\/workflow\.yaml$/, '')}`, ); await fs.ensureDir(path.dirname(actualDestWorkflowPath)); @@ -1203,7 +1232,7 @@ class ModuleManager { } if (workflowsVendored) { - console.log(chalk.green(` ✓ Workflow vendoring complete\n`)); + await prompts.log.success(` Workflow vendoring complete\n`); } } @@ -1225,7 +1254,7 @@ class ModuleManager { if (updatedYaml !== yamlContent) { await fs.writeFile(workflowYamlPath, updatedYaml, 'utf8'); - console.log(chalk.dim(` Updated config_source to: ${this.bmadFolderName}/${newModuleName}/config.yaml`)); + await prompts.log.message(` Updated config_source to: ${this.bmadFolderName}/${newModuleName}/config.yaml`); } } @@ -1241,7 +1270,7 @@ class ModuleManager { if (moduleName === 'core') { sourcePath = getSourcePath('core'); } else { - sourcePath = await this.findModuleSource(moduleName); + sourcePath = await this.findModuleSource(moduleName, { silent: options.silent }); if (!sourcePath) { // No source found, skip module installer return; @@ -1280,11 +1309,11 @@ class ModuleManager { }); if (!result) { - console.warn(chalk.yellow(`Module installer for ${moduleName} returned false`)); + await prompts.log.warn(`Module installer for ${moduleName} returned false`); } } } catch (error) { - console.error(chalk.red(`Error running module installer for ${moduleName}: ${error.message}`)); + await prompts.log.error(`Error running module installer for ${moduleName}: ${error.message}`); } } @@ -1306,7 +1335,7 @@ class ModuleManager { await fs.writeFile(configPath, configContent, 'utf8'); } catch (error) { - console.warn(`Failed to process module config:`, error.message); + await prompts.log.warn(`Failed to process module config: ${error.message}`); } } } diff --git a/tools/cli/lib/agent/installer.js b/tools/cli/lib/agent/installer.js index a76504530..c9e0dd916 100644 --- a/tools/cli/lib/agent/installer.js +++ b/tools/cli/lib/agent/installer.js @@ -6,7 +6,7 @@ const fs = require('node:fs'); const path = require('node:path'); const yaml = require('yaml'); -const readline = require('node:readline'); +const prompts = require('../prompts'); const { compileAgent, compileAgentFile } = require('./compiler'); const { extractInstallConfig, getDefaultValues } = require('./template-engine'); @@ -149,83 +149,47 @@ async function promptInstallQuestions(installConfig, defaults, presetAnswers = { return { ...defaults, ...presetAnswers }; } - const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, - }); - - const question = (prompt) => - new Promise((resolve) => { - rl.question(prompt, resolve); - }); - const answers = { ...defaults, ...presetAnswers }; - console.log('\n📝 Agent Configuration\n'); - if (installConfig.description) { - console.log(` ${installConfig.description}\n`); - } + await prompts.note(installConfig.description || '', 'Agent Configuration'); for (const q of installConfig.questions) { // Skip questions for variables that are already set (e.g., custom_name set upfront) if (answers[q.var] !== undefined && answers[q.var] !== defaults[q.var]) { - console.log(chalk.dim(` ${q.var}: ${answers[q.var]} (already set)`)); + await prompts.log.message(` ${q.var}: ${answers[q.var]} (already set)`); continue; } - let response; - switch (q.type) { case 'text': { - const defaultHint = q.default ? ` (default: ${q.default})` : ''; - response = await question(` ${q.prompt}${defaultHint}: `); - answers[q.var] = response || q.default || ''; - + const response = await prompts.text({ + message: q.prompt, + default: q.default ?? '', + }); + answers[q.var] = response ?? q.default ?? ''; break; } case 'boolean': { - const defaultHint = q.default ? ' [Y/n]' : ' [y/N]'; - response = await question(` ${q.prompt}${defaultHint}: `); - if (response === '') { - answers[q.var] = q.default; - } else { - answers[q.var] = response.toLowerCase().startsWith('y'); - } - + const response = await prompts.confirm({ + message: q.prompt, + default: q.default, + }); + answers[q.var] = response; break; } case 'choice': { - console.log(` ${q.prompt}`); - for (const [idx, opt] of q.options.entries()) { - const marker = opt.value === q.default ? '* ' : ' '; - console.log(` ${marker}${idx + 1}. ${opt.label}`); - } - const defaultIdx = q.options.findIndex((o) => o.value === q.default) + 1; - let validChoice = false; - let choiceIdx; - while (!validChoice) { - response = await question(` Choice (default: ${defaultIdx}): `); - if (response) { - choiceIdx = parseInt(response, 10) - 1; - if (isNaN(choiceIdx) || choiceIdx < 0 || choiceIdx >= q.options.length) { - console.log(` Invalid choice. Please enter 1-${q.options.length}`); - } else { - validChoice = true; - } - } else { - choiceIdx = defaultIdx - 1; - validChoice = true; - } - } - answers[q.var] = q.options[choiceIdx].value; - + const response = await prompts.select({ + message: q.prompt, + options: q.options.map((o) => ({ value: o.value, label: o.label })), + initialValue: q.default, + }); + answers[q.var] = response; break; } // No default } } - rl.close(); return answers; } diff --git a/tools/cli/lib/cli-utils.js b/tools/cli/lib/cli-utils.js index da1933631..569f1c44c 100644 --- a/tools/cli/lib/cli-utils.js +++ b/tools/cli/lib/cli-utils.js @@ -1,9 +1,6 @@ -const chalk = require('chalk'); -const boxen = require('boxen'); -const wrapAnsi = require('wrap-ansi'); -const figlet = require('figlet'); const path = require('node:path'); const os = require('node:os'); +const prompts = require('./prompts'); const CLIUtils = { /** @@ -19,27 +16,32 @@ const CLIUtils = { }, /** - * Display BMAD logo - * @param {boolean} clearScreen - Whether to clear the screen first (default: true for initial display only) + * Display BMAD logo using @clack intro + box + * @param {boolean} _clearScreen - Deprecated, ignored (no longer clears screen) */ - displayLogo(clearScreen = true) { - if (clearScreen) { - console.clear(); - } - + async displayLogo(_clearScreen = true) { const version = this.getVersion(); + const color = await prompts.getColor(); // ASCII art logo - const logo = ` - ██████╗ ███╗ ███╗ █████╗ ██████╗ ™ - ██╔══██╗████╗ ████║██╔══██╗██╔══██╗ - ██████╔╝██╔████╔██║███████║██║ ██║ - ██╔══██╗██║╚██╔╝██║██╔══██║██║ ██║ - ██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝ - ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝`; + const logo = [ + ' ██████╗ ███╗ ███╗ █████╗ ██████╗ ™', + ' ██╔══██╗████╗ ████║██╔══██╗██╔══██╗', + ' ██████╔╝██╔████╔██║███████║██║ ██║', + ' ██╔══██╗██║╚██╔╝██║██╔══██║██║ ██║', + ' ██████╔╝██║ ╚═╝ ██║██║ ██║██████╔╝', + ' ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝', + ] + .map((line) => color.yellow(line)) + .join('\n'); - console.log(chalk.cyan(logo)); - console.log(chalk.dim(` Build More, Architect Dreams`) + chalk.cyan.bold(` v${version}`) + '\n'); + const tagline = ' Build More, Architect Dreams'; + + await prompts.box(`${logo}\n${tagline}`, `v${version}`, { + contentAlign: 'center', + rounded: true, + formatBorder: color.blue, + }); }, /** @@ -47,13 +49,8 @@ const CLIUtils = { * @param {string} title - Section title * @param {string} subtitle - Optional subtitle */ - displaySection(title, subtitle = null) { - console.log('\n' + chalk.cyan('═'.repeat(80))); - console.log(chalk.cyan.bold(` ${title}`)); - if (subtitle) { - console.log(chalk.dim(` ${subtitle}`)); - } - console.log(chalk.cyan('═'.repeat(80)) + '\n'); + async displaySection(title, subtitle = null) { + await prompts.note(subtitle || '', title); }, /** @@ -61,25 +58,21 @@ const CLIUtils = { * @param {string|Array} content - Content to display * @param {Object} options - Box options */ - displayBox(content, options = {}) { - const defaultOptions = { - padding: 1, - margin: 1, - borderStyle: 'round', - borderColor: 'cyan', - ...options, - }; - - // Handle array content + async displayBox(content, options = {}) { let text = content; if (Array.isArray(content)) { text = content.join('\n\n'); } - // Wrap text to prevent overflow - const wrapped = wrapAnsi(text, 76, { hard: true, wordWrap: true }); + const color = await prompts.getColor(); + const borderColor = options.borderColor || 'cyan'; + const colorMap = { green: color.green, red: color.red, yellow: color.yellow, cyan: color.cyan, blue: color.blue }; + const formatBorder = colorMap[borderColor] || color.cyan; - console.log(boxen(wrapped, defaultOptions)); + await prompts.box(text, options.title, { + rounded: options.borderStyle === 'round' || options.borderStyle === undefined, + formatBorder, + }); }, /** @@ -88,14 +81,9 @@ const CLIUtils = { * @param {string} header - Custom header from module.yaml * @param {string} subheader - Custom subheader from module.yaml */ - displayModuleConfigHeader(moduleName, header = null, subheader = null) { - // Simple blue banner with custom header/subheader if provided - console.log('\n' + chalk.cyan('─'.repeat(80))); - console.log(chalk.cyan(header || `Configuring ${moduleName.toUpperCase()} Module`)); - if (subheader) { - console.log(chalk.dim(`${subheader}`)); - } - console.log(chalk.cyan('─'.repeat(80)) + '\n'); + async displayModuleConfigHeader(moduleName, header = null, subheader = null) { + const title = header || `Configuring ${moduleName.toUpperCase()} Module`; + await prompts.note(subheader || '', title); }, /** @@ -104,14 +92,9 @@ const CLIUtils = { * @param {string} header - Custom header from module.yaml * @param {string} subheader - Custom subheader from module.yaml */ - displayModuleNoConfig(moduleName, header = null, subheader = null) { - // Show full banner with header/subheader, just like modules with config - console.log('\n' + chalk.cyan('─'.repeat(80))); - console.log(chalk.cyan(header || `${moduleName.toUpperCase()} Module - No Custom Configuration`)); - if (subheader) { - console.log(chalk.dim(`${subheader}`)); - } - console.log(chalk.cyan('─'.repeat(80)) + '\n'); + async displayModuleNoConfig(moduleName, header = null, subheader = null) { + const title = header || `${moduleName.toUpperCase()} Module - No Custom Configuration`; + await prompts.note(subheader || '', title); }, /** @@ -120,42 +103,33 @@ const CLIUtils = { * @param {number} total - Total steps * @param {string} description - Step description */ - displayStep(current, total, description) { + async displayStep(current, total, description) { const progress = `[${current}/${total}]`; - console.log('\n' + chalk.cyan(progress) + ' ' + chalk.bold(description)); - console.log(chalk.dim('─'.repeat(80 - progress.length - 1)) + '\n'); + await prompts.log.step(`${progress} ${description}`); }, /** * Display completion message * @param {string} message - Completion message */ - displayComplete(message) { - console.log( - '\n' + - boxen(chalk.green('✨ ' + message), { - padding: 1, - margin: 1, - borderStyle: 'round', - borderColor: 'green', - }), - ); + async displayComplete(message) { + const color = await prompts.getColor(); + await prompts.box(`\u2728 ${message}`, 'Complete', { + rounded: true, + formatBorder: color.green, + }); }, /** * Display error message * @param {string} message - Error message */ - displayError(message) { - console.log( - '\n' + - boxen(chalk.red('✗ ' + message), { - padding: 1, - margin: 1, - borderStyle: 'round', - borderColor: 'red', - }), - ); + async displayError(message) { + const color = await prompts.getColor(); + await prompts.box(`\u2717 ${message}`, 'Error', { + rounded: true, + formatBorder: color.red, + }); }, /** @@ -163,7 +137,7 @@ const CLIUtils = { * @param {Array} items - Items to display * @param {string} prefix - Item prefix */ - formatList(items, prefix = '•') { + formatList(items, prefix = '\u2022') { return items.map((item) => ` ${prefix} ${item}`).join('\n'); }, @@ -178,25 +152,6 @@ const CLIUtils = { } }, - /** - * Display table - * @param {Array} data - Table data - * @param {Object} options - Table options - */ - displayTable(data, options = {}) { - const Table = require('cli-table3'); - const table = new Table({ - style: { - head: ['cyan'], - border: ['dim'], - }, - ...options, - }); - - for (const row of data) table.push(row); - console.log(table.toString()); - }, - /** * Display module completion message * @param {string} moduleName - Name of the completed module diff --git a/tools/cli/lib/prompts.js b/tools/cli/lib/prompts.js index c51d68d19..24500700b 100644 --- a/tools/cli/lib/prompts.js +++ b/tools/cli/lib/prompts.js @@ -89,11 +89,51 @@ async function note(message, title) { /** * Display a spinner for async operations - * @returns {Object} Spinner controller with start, stop, message methods + * Wraps @clack/prompts spinner with isSpinning state tracking + * @returns {Object} Spinner controller with start, stop, message, error, cancel, clear, isSpinning */ async function spinner() { const clack = await getClack(); - return clack.spinner(); + const s = clack.spinner(); + let spinning = false; + + return { + start: (msg) => { + if (spinning) { + s.message(msg); + } else { + spinning = true; + s.start(msg); + } + }, + stop: (msg) => { + if (spinning) { + spinning = false; + s.stop(msg); + } + }, + message: (msg) => { + if (spinning) s.message(msg); + }, + error: (msg) => { + spinning = false; + s.error(msg); + }, + cancel: (msg) => { + spinning = false; + s.cancel(msg); + }, + clear: () => { + spinning = false; + s.clear(); + }, + get isSpinning() { + return spinning; + }, + get isCancelled() { + return s.isCancelled; + }, + }; } /** @@ -190,31 +230,6 @@ async function multiselect(options) { return result; } -/** - * Grouped multi-select prompt for categorized options - * @param {Object} options - Prompt options - * @param {string} options.message - The question to ask - * @param {Object} options.options - Object mapping group names to arrays of choices - * @param {Array} [options.initialValues] - Array of initially selected values - * @param {boolean} [options.required=false] - Whether at least one must be selected - * @param {boolean} [options.selectableGroups=false] - Whether groups can be selected as a whole - * @returns {Promise} Array of selected values - */ -async function groupMultiselect(options) { - const clack = await getClack(); - - const result = await clack.groupMultiselect({ - message: options.message, - options: options.options, - initialValues: options.initialValues, - required: options.required || false, - selectableGroups: options.selectableGroups || false, - }); - - await handleCancel(result); - return result; -} - /** * Default filter function for autocomplete - case-insensitive label matching * @param {string} search - Search string @@ -237,6 +252,7 @@ function defaultAutocompleteFilter(search, option) { * @param {boolean} [options.required=false] - Whether at least one must be selected * @param {number} [options.maxItems=5] - Maximum visible items in scrollable list * @param {Function} [options.filter] - Custom filter function (search, option) => boolean + * @param {Array} [options.lockedValues] - Values that are always selected and cannot be toggled off * @returns {Promise} Array of selected values */ async function autocompleteMultiselect(options) { @@ -245,6 +261,7 @@ async function autocompleteMultiselect(options) { const color = await getPicocolors(); const filterFn = options.filter ?? defaultAutocompleteFilter; + const lockedSet = new Set(options.lockedValues || []); const prompt = new core.AutocompletePrompt({ options: options.options, @@ -255,7 +272,7 @@ async function autocompleteMultiselect(options) { return 'Please select at least one item'; } }, - initialValue: options.initialValues, + initialValue: [...new Set([...(options.initialValues || []), ...(options.lockedValues || [])])], render() { const barColor = this.state === 'error' ? color.yellow : color.cyan; const bar = barColor(clack.S_BAR); @@ -280,9 +297,17 @@ async function autocompleteMultiselect(options) { // Render option with checkbox const renderOption = (opt, isHighlighted) => { const isSelected = this.selectedValues.includes(opt.value); + const isLocked = lockedSet.has(opt.value); const label = opt.label ?? String(opt.value ?? ''); - const hintText = opt.hint && opt.value === this.focusedValue ? color.dim(` (${opt.hint})`) : ''; - const checkbox = isSelected ? color.green(clack.S_CHECKBOX_SELECTED) : color.dim(clack.S_CHECKBOX_INACTIVE); + const hintText = opt.hint && isHighlighted ? color.dim(` (${opt.hint})`) : ''; + + let checkbox; + if (isLocked) { + checkbox = color.green(clack.S_CHECKBOX_SELECTED); + const lockHint = color.dim(' (always installed)'); + return isHighlighted ? `${checkbox} ${label}${lockHint}` : `${checkbox} ${color.dim(label)}${lockHint}`; + } + checkbox = isSelected ? color.green(clack.S_CHECKBOX_SELECTED) : color.dim(clack.S_CHECKBOX_INACTIVE); return isHighlighted ? `${checkbox} ${label}${hintText}` : `${checkbox} ${color.dim(label)}`; }; @@ -322,6 +347,18 @@ async function autocompleteMultiselect(options) { }, }); + // Prevent locked values from being toggled off + if (lockedSet.size > 0) { + const originalToggle = prompt.toggleSelected.bind(prompt); + prompt.toggleSelected = function (value) { + // If locked and already selected, skip the toggle (would deselect) + if (lockedSet.has(value) && this.selectedValues.includes(value)) { + return; + } + originalToggle(value); + }; + } + // === FIX: Make SPACE always act as selection key (not search input) === // Override _isActionKey to treat SPACE like TAB - always an action key // This prevents SPACE from being added to the search input @@ -335,8 +372,9 @@ async function autocompleteMultiselect(options) { // Handle SPACE toggle when NOT navigating (internal code only handles it when isNavigating=true) prompt.on('key', (char, key) => { - if (key && key.name === 'space' && !prompt.isNavigating && prompt.focusedValue !== undefined) { - prompt.toggleSelected(prompt.focusedValue); + if (key && key.name === 'space' && !prompt.isNavigating) { + const focused = prompt.filteredOptions[prompt.cursor]; + if (focused) prompt.toggleSelected(focused.value); } }); // === END FIX === @@ -520,6 +558,131 @@ const log = { }, }; +/** + * Display cancellation message + * @param {string} [message='Operation cancelled'] - The cancellation message + */ +async function cancel(message = 'Operation cancelled') { + const clack = await getClack(); + clack.cancel(message); +} + +/** + * Display content in a styled box + * @param {string} content - The box content + * @param {string} [title] - Optional title + * @param {Object} [options] - Box options (contentAlign, titleAlign, width, rounded, formatBorder, etc.) + */ +async function box(content, title, options) { + const clack = await getClack(); + clack.box(content, title, options); +} + +/** + * Create a progress bar for visualizing task completion + * @param {Object} [options] - Progress options (max, style, etc.) + * @returns {Promise} Progress controller with start, advance, stop methods + */ +async function progress(options) { + const clack = await getClack(); + return clack.progress(options); +} + +/** + * Create a task log for displaying scrolling subprocess output + * @param {Object} options - TaskLog options (title, limit, retainLog) + * @returns {Promise} TaskLog controller with message, success, error methods + */ +async function taskLog(options) { + const clack = await getClack(); + return clack.taskLog(options); +} + +/** + * File system path prompt with autocomplete + * @param {Object} options - Path options + * @param {string} options.message - The prompt message + * @param {string} [options.initialValue] - Initial path value + * @param {boolean} [options.directory=false] - Only allow directories + * @param {Function} [options.validate] - Validation function + * @returns {Promise} Selected path + */ +async function pathPrompt(options) { + const clack = await getClack(); + const result = await clack.path(options); + await handleCancel(result); + return result; +} + +/** + * Autocomplete single-select prompt with type-ahead filtering + * @param {Object} options - Autocomplete options + * @param {string} options.message - The prompt message + * @param {Array} options.options - Array of choices [{value, label, hint?}] + * @param {string} [options.placeholder] - Placeholder text + * @param {number} [options.maxItems] - Maximum visible items + * @param {Function} [options.filter] - Custom filter function + * @returns {Promise} Selected value + */ +async function autocomplete(options) { + const clack = await getClack(); + const result = await clack.autocomplete(options); + await handleCancel(result); + return result; +} + +/** + * Key-based instant selection prompt + * @param {Object} options - SelectKey options + * @param {string} options.message - The prompt message + * @param {Array} options.options - Array of choices [{value, label, hint?}] + * @returns {Promise} Selected value + */ +async function selectKey(options) { + const clack = await getClack(); + const result = await clack.selectKey(options); + await handleCancel(result); + return result; +} + +/** + * Stream messages with dynamic content (for LLMs, generators, etc.) + */ +const stream = { + async info(generator) { + const clack = await getClack(); + return clack.stream.info(generator); + }, + async success(generator) { + const clack = await getClack(); + return clack.stream.success(generator); + }, + async step(generator) { + const clack = await getClack(); + return clack.stream.step(generator); + }, + async warn(generator) { + const clack = await getClack(); + return clack.stream.warn(generator); + }, + async error(generator) { + const clack = await getClack(); + return clack.stream.error(generator); + }, + async message(generator, options) { + const clack = await getClack(); + return clack.stream.message(generator, options); + }, +}; + +/** + * Get the color utility (picocolors instance from @clack/prompts) + * @returns {Promise} The color utility (picocolors) + */ +async function getColor() { + return await getPicocolors(); +} + /** * Execute an array of Inquirer-style questions using @clack/prompts * This provides compatibility with dynamic question arrays @@ -619,20 +782,28 @@ async function prompt(questions) { module.exports = { getClack, + getColor, handleCancel, intro, outro, + cancel, note, + box, spinner, + progress, + taskLog, select, multiselect, - groupMultiselect, autocompleteMultiselect, + autocomplete, + selectKey, confirm, text, + path: pathPrompt, password, group, tasks, log, + stream, prompt, }; diff --git a/tools/cli/lib/ui.js b/tools/cli/lib/ui.js index 811931f5f..9134b4e28 100644 --- a/tools/cli/lib/ui.js +++ b/tools/cli/lib/ui.js @@ -1,4 +1,3 @@ -const chalk = require('chalk'); const path = require('node:path'); const os = require('node:os'); const fs = require('fs-extra'); @@ -30,12 +29,12 @@ class UI { * @returns {Object} Installation configuration */ async promptInstall(options = {}) { - CLIUtils.displayLogo(); + await CLIUtils.displayLogo(); // Display version-specific start message from install-messages.yaml const { MessageLoader } = require('../installers/lib/message-loader'); const messageLoader = new MessageLoader(); - messageLoader.displayStartMessage(); + await messageLoader.displayStartMessage(); // Get directory from options or prompt let confirmedDirectory; @@ -47,7 +46,7 @@ class UI { throw new Error(`Invalid directory: ${validation}`); } confirmedDirectory = expandedDir; - console.log(chalk.cyan('Using directory from command-line:'), chalk.bold(confirmedDirectory)); + await prompts.log.info(`Using directory from command-line: ${confirmedDirectory}`); } else { confirmedDirectory = await this.getConfirmedDirectory(); } @@ -75,7 +74,7 @@ class UI { for (const entry of entries) { if (entry.isDirectory() && (entry.name === '.bmad' || entry.name === 'bmad')) { hasLegacyBmadFolder = true; - legacyBmadPath = path.join(confirmedDirectory, '.bmad'); + legacyBmadPath = path.join(confirmedDirectory, entry.name); bmadDir = legacyBmadPath; // Check if it has _cfg folder @@ -98,38 +97,30 @@ class UI { // Handle legacy .bmad or _cfg folder - these are very old (v4 or alpha) // Show version warning instead of offering conversion if (hasLegacyBmadFolder || hasLegacyCfg) { - console.log(''); - console.log(chalk.yellow.bold('⚠️ LEGACY INSTALLATION DETECTED')); - console.log(chalk.yellow('─'.repeat(80))); - console.log( - chalk.yellow( - 'Found a ".bmad"/"bmad" folder, or a legacy "_cfg" folder under the bmad folder - this is from a old BMAD version that is out of date for automatic upgrade, manual intervention required.', - ), + await prompts.log.warn('LEGACY INSTALLATION DETECTED'); + await prompts.note( + 'Found a ".bmad"/"bmad" folder, or a legacy "_cfg" folder under the bmad folder -\n' + + 'this is from an old BMAD version that is out of date for automatic upgrade,\n' + + 'manual intervention required.\n\n' + + 'You have a legacy version installed (v4 or alpha).\n' + + 'Legacy installations may have compatibility issues.\n\n' + + 'For the best experience, we strongly recommend:\n' + + ' 1. Delete your current BMAD installation folder (.bmad or bmad)\n' + + ' 2. Run a fresh installation\n\n' + + 'If you do not want to start fresh, you can attempt to proceed beyond this\n' + + 'point IF you have ensured the bmad folder is named _bmad, and under it there\n' + + 'is a _config folder. If you have a folder under your bmad folder named _cfg,\n' + + 'you would need to rename it _config, and then restart the installer.\n\n' + + 'Benefits of a fresh install:\n' + + ' \u2022 Cleaner configuration without legacy artifacts\n' + + ' \u2022 All new features properly configured\n' + + ' \u2022 Fewer potential conflicts\n\n' + + 'If you have already produced output from an earlier alpha version, you can\n' + + 'still retain those artifacts. After installation, ensure you configured during\n' + + 'install the proper file locations for artifacts depending on the module you\n' + + 'are using, or move the files to the proper locations.', + 'Legacy Installation Detected', ); - console.log(chalk.yellow('You have a legacy version installed (v4 or alpha).')); - console.log(''); - console.log(chalk.dim('Legacy installations may have compatibility issues.')); - console.log(''); - console.log(chalk.dim('For the best experience, we strongly recommend:')); - console.log(chalk.dim(' 1. Delete your current BMAD installation folder (.bmad or bmad)')); - console.log( - chalk.dim( - ' 2. Run a fresh installation\n\nIf you do not want to start fresh, you can attempt to proceed beyond this point IF you have ensured the bmad folder is named _bmad, and under it there is a _config folder. If you have a folder under your bmad folder named _cfg, you would need to rename it _config, and then restart the installer.', - ), - ); - console.log(''); - console.log(chalk.dim('Benefits of a fresh install:')); - console.log(chalk.dim(' • Cleaner configuration without legacy artifacts')); - console.log(chalk.dim(' • All new features properly configured')); - console.log(chalk.dim(' • Fewer potential conflicts')); - console.log(chalk.dim('')); - console.log( - chalk.dim( - 'If you have already produced output from an earlier alpha version, you can still retain those artifacts. After installation, ensure you configured during install the proper file locations for artifacts depending on the module you are using, or move the files to the proper locations.', - ), - ); - console.log(chalk.yellow('─'.repeat(80))); - console.log(''); const proceed = await prompts.select({ message: 'How would you like to proceed?', @@ -147,37 +138,33 @@ class UI { }); if (proceed === 'cancel') { - console.log(''); - console.log(chalk.cyan('To do a fresh install:')); - console.log(chalk.dim(' 1. Delete the existing bmad folder in your project')); - console.log(chalk.dim(" 2. Run 'bmad install' again")); - console.log(''); + await prompts.note('1. Delete the existing bmad folder in your project\n' + "2. Run 'bmad install' again", 'To do a fresh install'); process.exit(0); return; } - const ora = require('ora'); - const spinner = ora('Updating folder structure...').start(); + const s = await prompts.spinner(); + s.start('Updating folder structure...'); try { // Handle .bmad folder if (hasLegacyBmadFolder) { const newBmadPath = path.join(confirmedDirectory, '_bmad'); await fs.move(legacyBmadPath, newBmadPath); bmadDir = newBmadPath; - spinner.succeed('Renamed ".bmad" to "_bmad"'); + s.stop(`Renamed "${path.basename(legacyBmadPath)}" to "_bmad"`); } // Handle _cfg folder (either from .bmad or standalone) const cfgPath = path.join(bmadDir, '_cfg'); if (await fs.pathExists(cfgPath)) { - spinner.start('Renaming configuration folder...'); + s.start('Renaming configuration folder...'); const newCfgPath = path.join(bmadDir, '_config'); await fs.move(cfgPath, newCfgPath); - spinner.succeed('Renamed "_cfg" to "_config"'); + s.stop('Renamed "_cfg" to "_config"'); } } catch (error) { - spinner.fail('Failed to update folder structure'); - console.error(chalk.red(`Error: ${error.message}`)); + s.stop('Failed to update folder structure'); + await prompts.log.error(`Error: ${error.message}`); process.exit(1); } } @@ -239,7 +226,7 @@ class UI { throw new Error(`Invalid action: ${options.action}. Valid actions: ${validActions.join(', ')}`); } actionType = options.action; - console.log(chalk.cyan('Using action from command-line:'), chalk.bold(actionType)); + await prompts.log.info(`Using action from command-line: ${actionType}`); } else { actionType = await prompts.select({ message: 'How would you like to proceed?', @@ -274,7 +261,7 @@ class UI { // Get existing installation info const { installedModuleIds } = await this.getExistingInstallation(confirmedDirectory); - console.log(chalk.dim(` Found existing modules: ${[...installedModuleIds].join(', ')}`)); + await prompts.log.message(`Found existing modules: ${[...installedModuleIds].join(', ')}`); // Unified module selection - all modules in one grouped multiselect let selectedModules; @@ -284,13 +271,13 @@ class UI { .split(',') .map((m) => m.trim()) .filter(Boolean); - console.log(chalk.cyan('Using modules from command-line:'), chalk.bold(selectedModules.join(', '))); + await prompts.log.info(`Using modules from command-line: ${selectedModules.join(', ')}`); } else { selectedModules = await this.selectAllModules(installedModuleIds); + selectedModules = selectedModules.filter((m) => m !== 'core'); } // After module selection, ask about custom modules - console.log(''); let customModuleResult = { selectedCustomModules: [], customContentConfig: { hasCustomContent: false } }; if (options.customContent) { @@ -299,7 +286,7 @@ class UI { .split(',') .map((p) => p.trim()) .filter(Boolean); - console.log(chalk.cyan('Using custom content from command-line:'), chalk.bold(paths.join(', '))); + await prompts.log.info(`Using custom content from command-line: ${paths.join(', ')}`); // Build custom content config similar to promptCustomContentSource const customPaths = []; @@ -309,7 +296,7 @@ class UI { const expandedPath = this.expandUserPath(customPath); const validation = this.validateCustomContentPathSync(expandedPath); if (validation) { - console.log(chalk.yellow(`⚠️ Skipping invalid custom content path: ${customPath} - ${validation}`)); + await prompts.log.warn(`Skipping invalid custom content path: ${customPath} - ${validation}`); continue; } @@ -321,12 +308,12 @@ class UI { const yaml = require('yaml'); moduleMeta = yaml.parse(moduleYaml); } catch (error) { - console.log(chalk.yellow(`⚠️ Skipping custom content path: ${customPath} - failed to read module.yaml: ${error.message}`)); + await prompts.log.warn(`Skipping custom content path: ${customPath} - failed to read module.yaml: ${error.message}`); continue; } if (!moduleMeta.code) { - console.log(chalk.yellow(`⚠️ Skipping custom content path: ${customPath} - module.yaml missing 'code' field`)); + await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`); continue; } @@ -404,11 +391,11 @@ class UI { .split(',') .map((m) => m.trim()) .filter(Boolean); - console.log(chalk.cyan('Using modules from command-line:'), chalk.bold(selectedModules.join(', '))); + await prompts.log.info(`Using modules from command-line: ${selectedModules.join(', ')}`); } else if (options.yes) { // Use default modules when --yes flag is set selectedModules = await this.getDefaultModules(installedModuleIds); - console.log(chalk.cyan('Using default modules (--yes flag):'), chalk.bold(selectedModules.join(', '))); + await prompts.log.info(`Using default modules (--yes flag): ${selectedModules.join(', ')}`); } else { selectedModules = await this.selectAllModules(installedModuleIds); } @@ -420,7 +407,7 @@ class UI { .split(',') .map((p) => p.trim()) .filter(Boolean); - console.log(chalk.cyan('Using custom content from command-line:'), chalk.bold(paths.join(', '))); + await prompts.log.info(`Using custom content from command-line: ${paths.join(', ')}`); // Build custom content config similar to promptCustomContentSource const customPaths = []; @@ -430,7 +417,7 @@ class UI { const expandedPath = this.expandUserPath(customPath); const validation = this.validateCustomContentPathSync(expandedPath); if (validation) { - console.log(chalk.yellow(`⚠️ Skipping invalid custom content path: ${customPath} - ${validation}`)); + await prompts.log.warn(`Skipping invalid custom content path: ${customPath} - ${validation}`); continue; } @@ -442,12 +429,12 @@ class UI { const yaml = require('yaml'); moduleMeta = yaml.parse(moduleYaml); } catch (error) { - console.log(chalk.yellow(`⚠️ Skipping custom content path: ${customPath} - failed to read module.yaml: ${error.message}`)); + await prompts.log.warn(`Skipping custom content path: ${customPath} - failed to read module.yaml: ${error.message}`); continue; } if (!moduleMeta.code) { - console.log(chalk.yellow(`⚠️ Skipping custom content path: ${customPath} - module.yaml missing 'code' field`)); + await prompts.log.warn(`Skipping custom content path: ${customPath} - module.yaml missing 'code' field`); continue; } @@ -531,7 +518,7 @@ class UI { const allKnownValues = new Set([...preferredIdes, ...otherIdes].map((ide) => ide.value)); const unknownTools = configuredIdes.filter((id) => id && typeof id === 'string' && !allKnownValues.has(id)); if (unknownTools.length > 0) { - console.log(chalk.yellow(`⚠️ Previously configured tools are no longer available: ${unknownTools.join(', ')}`)); + await prompts.log.warn(`Previously configured tools are no longer available: ${unknownTools.join(', ')}`); } // ───────────────────────────────────────────────────────────────────────────── @@ -569,21 +556,20 @@ class UI { const selectedIdes = upgradeSelected || []; if (selectedIdes.length === 0) { - console.log(''); const confirmNoTools = await prompts.confirm({ message: 'No tools selected. Continue without installing any tools?', default: false, }); if (!confirmNoTools) { - return this.promptToolSelection(projectDir); + return this.promptToolSelection(projectDir, options); } return { ides: [], skipIde: true }; } // Display selected tools - this.displaySelectedTools(selectedIdes, preferredIdes, allTools); + await this.displaySelectedTools(selectedIdes, preferredIdes, allTools); return { ides: selectedIdes, skipIde: false }; } @@ -609,25 +595,25 @@ class UI { if (options.tools) { // Check for explicit "none" value to skip tool installation if (options.tools.toLowerCase() === 'none') { - console.log(chalk.cyan('Skipping tool configuration (--tools none)')); + await prompts.log.info('Skipping tool configuration (--tools none)'); return { ides: [], skipIde: true }; } else { selectedIdes = options.tools .split(',') .map((t) => t.trim()) .filter(Boolean); - console.log(chalk.cyan('Using tools from command-line:'), chalk.bold(selectedIdes.join(', '))); - this.displaySelectedTools(selectedIdes, preferredIdes, allTools); + await prompts.log.info(`Using tools from command-line: ${selectedIdes.join(', ')}`); + await this.displaySelectedTools(selectedIdes, preferredIdes, allTools); return { ides: selectedIdes, skipIde: false }; } } else if (options.yes) { // If --yes flag is set, skip tool prompt and use previously configured tools or empty if (configuredIdes.length > 0) { - console.log(chalk.cyan('Using previously configured tools (--yes flag):'), chalk.bold(configuredIdes.join(', '))); - this.displaySelectedTools(configuredIdes, preferredIdes, allTools); + await prompts.log.info(`Using previously configured tools (--yes flag): ${configuredIdes.join(', ')}`); + await this.displaySelectedTools(configuredIdes, preferredIdes, allTools); return { ides: configuredIdes, skipIde: false }; } else { - console.log(chalk.cyan('Skipping tool configuration (--yes flag, no previous tools)')); + await prompts.log.info('Skipping tool configuration (--yes flag, no previous tools)'); return { ides: [], skipIde: true }; } } @@ -647,7 +633,6 @@ class UI { // STEP 3: Confirm if no tools selected // ───────────────────────────────────────────────────────────────────────────── if (selectedIdes.length === 0) { - console.log(''); const confirmNoTools = await prompts.confirm({ message: 'No tools selected. Continue without installing any tools?', default: false, @@ -655,7 +640,7 @@ class UI { if (!confirmNoTools) { // User wants to select tools - recurse - return this.promptToolSelection(projectDir); + return this.promptToolSelection(projectDir, options); } return { @@ -665,7 +650,7 @@ class UI { } // Display selected tools - this.displaySelectedTools(selectedIdes, preferredIdes, allTools); + await this.displaySelectedTools(selectedIdes, preferredIdes, allTools); return { ides: selectedIdes, @@ -708,15 +693,12 @@ class UI { * Display installation summary * @param {Object} result - Installation result */ - showInstallSummary(result) { - // Clean, simple completion message - console.log('\n' + chalk.green.bold('✨ BMAD is ready to use!')); - - // Show installation summary in a simple format - console.log(chalk.dim(`Installed to: ${result.path}`)); + async showInstallSummary(result) { + let summary = `Installed to: ${result.path}`; if (result.modules && result.modules.length > 0) { - console.log(chalk.dim(`Modules: ${result.modules.join(', ')}`)); + summary += `\nModules: ${result.modules.join(', ')}`; } + await prompts.note(summary, 'BMAD is ready to use!'); } /** @@ -769,19 +751,19 @@ class UI { const coreConfig = {}; if (options.userName) { coreConfig.user_name = options.userName; - console.log(chalk.cyan('Using user name from command-line:'), chalk.bold(options.userName)); + await prompts.log.info(`Using user name from command-line: ${options.userName}`); } if (options.communicationLanguage) { coreConfig.communication_language = options.communicationLanguage; - console.log(chalk.cyan('Using communication language from command-line:'), chalk.bold(options.communicationLanguage)); + await prompts.log.info(`Using communication language from command-line: ${options.communicationLanguage}`); } if (options.documentOutputLanguage) { coreConfig.document_output_language = options.documentOutputLanguage; - console.log(chalk.cyan('Using document output language from command-line:'), chalk.bold(options.documentOutputLanguage)); + await prompts.log.info(`Using document output language from command-line: ${options.documentOutputLanguage}`); } if (options.outputFolder) { coreConfig.output_folder = options.outputFolder; - console.log(chalk.cyan('Using output folder from command-line:'), chalk.bold(options.outputFolder)); + await prompts.log.info(`Using output folder from command-line: ${options.outputFolder}`); } // Load existing config to merge with provided options @@ -818,7 +800,7 @@ class UI { document_output_language: 'English', output_folder: '_bmad-output', }; - console.log(chalk.cyan('Using default configuration (--yes flag)')); + await prompts.log.info('Using default configuration (--yes flag)'); } } else { // Load existing configs first if they exist @@ -839,11 +821,11 @@ class UI { * @returns {Array} Module choices for prompt */ async getModuleChoices(installedModuleIds, customContentConfig = null) { + const color = await prompts.getColor(); const moduleChoices = []; const isNewInstallation = installedModuleIds.size === 0; const customContentItems = []; - const hasCustomContentItems = false; // Add custom content items if (customContentConfig && customContentConfig.hasCustomContent && customContentConfig.customPath) { @@ -855,7 +837,7 @@ class UI { const customInfo = await customHandler.getCustomInfo(customFile); if (customInfo) { customContentItems.push({ - name: `${chalk.cyan('✓')} ${customInfo.name} ${chalk.gray(`(${customInfo.relativePath})`)}`, + name: `${color.cyan('\u2713')} ${customInfo.name} ${color.dim(`(${customInfo.relativePath})`)}`, value: `__CUSTOM_CONTENT__${customFile}`, // Unique value for each custom content checked: true, // Default to selected since user chose to provide custom content path: customInfo.path, // Track path to avoid duplicates @@ -883,7 +865,7 @@ class UI { if (!isDuplicate) { allCustomModules.push({ - name: `${chalk.cyan('✓')} ${mod.name} ${chalk.gray(`(cached)`)}`, + name: `${color.cyan('\u2713')} ${mod.name} ${color.dim('(cached)')}`, value: mod.id, checked: isNewInstallation ? mod.defaultSelected || false : installedModuleIds.has(mod.id), hint: mod.description || undefined, @@ -934,22 +916,20 @@ class UI { ...choicesWithDefaults, { value: '__NONE__', - label: '⚠ None / I changed my mind - skip module installation', + label: '\u26A0 None / I changed my mind - skip module installation', checked: false, }, ]; const selected = await prompts.multiselect({ - message: `Select modules to install ${chalk.dim('(↑/↓ navigates, SPACE toggles, ENTER to confirm)')}:`, + message: 'Select modules to install (use arrow keys, space to toggle):', choices: choicesWithSkipOption, required: true, }); // If user selected both "__NONE__" and other items, honor the "None" choice if (selected && selected.includes('__NONE__') && selected.length > 1) { - console.log(); - console.log(chalk.yellow('⚠️ "None / I changed my mind" was selected, so no modules will be installed.')); - console.log(); + await prompts.log.warn('"None / I changed my mind" was selected, so no modules will be installed.'); return []; } @@ -982,8 +962,7 @@ class UI { */ async selectExternalModules(externalModuleChoices, defaultSelections = []) { // Build a message showing available modules - const availableNames = externalModuleChoices.map((c) => c.name).join(', '); - const message = `Select official BMad modules to install ${chalk.dim('(↑/↓ navigates, SPACE toggles, ENTER to confirm)')}:`; + const message = 'Select official BMad modules to install (use arrow keys, space to toggle):'; // Mark choices as checked based on defaultSelections const choicesWithDefaults = externalModuleChoices.map((choice) => ({ @@ -1009,9 +988,7 @@ class UI { // If user selected both "__NONE__" and other items, honor the "None" choice if (selected && selected.includes('__NONE__') && selected.length > 1) { - console.log(); - console.log(chalk.yellow('⚠️ "None / I changed my mind" was selected, so no external modules will be installed.')); - console.log(); + await prompts.log.warn('"None / I changed my mind" was selected, so no external modules will be installed.'); return []; } @@ -1033,100 +1010,98 @@ class UI { const externalManager = new ExternalModuleManager(); const externalModules = await externalManager.listAvailable(); - // Build grouped options - const groupedOptions = {}; + // Build flat options list with group hints for autocompleteMultiselect + const allOptions = []; const initialValues = []; + const lockedValues = ['core']; + + // Core module is always installed — show it locked at the top + allOptions.push({ label: 'BMad Core Module', value: 'core', hint: 'Core configuration and shared resources' }); + initialValues.push('core'); // Helper to build module entry with proper sorting and selection - const buildModuleEntry = (mod, value) => { + const buildModuleEntry = (mod, value, group) => { const isInstalled = installedModuleIds.has(value); - const isDefault = mod.defaultSelected === true; return { - label: mod.description ? `${mod.name} — ${mod.description}` : mod.name, + label: mod.name, value, - // For sorting: defaultSelected=0, others=1 - sortKey: isDefault ? 0 : 1, - // Pre-select if default selected OR already installed - selected: isDefault || isInstalled, + hint: mod.description || group, + // Pre-select only if already installed (not on fresh install) + selected: isInstalled, }; }; - // Group 1: BMad Core (BMM, BMB) - const coreModules = []; + // Local modules (BMM, BMB, etc.) + const localEntries = []; for (const mod of localModules) { - if (!mod.isCustom && (mod.id === 'bmm' || mod.id === 'bmb')) { - const entry = buildModuleEntry(mod, mod.id); - coreModules.push(entry); + if (!mod.isCustom && mod.id !== 'core') { + const entry = buildModuleEntry(mod, mod.id, 'Local'); + localEntries.push(entry); if (entry.selected) { initialValues.push(mod.id); } } } - // Sort: defaultSelected first, then others - coreModules.sort((a, b) => a.sortKey - b.sortKey); - // Remove sortKey from final entries - if (coreModules.length > 0) { - groupedOptions['BMad Core'] = coreModules.map(({ label, value }) => ({ label, value })); - } + allOptions.push(...localEntries.map(({ label, value, hint }) => ({ label, value, hint }))); // Group 2: BMad Official Modules (type: bmad-org) const officialModules = []; for (const mod of externalModules) { if (mod.type === 'bmad-org') { - const entry = buildModuleEntry(mod, mod.code); + const entry = buildModuleEntry(mod, mod.code, 'Official'); officialModules.push(entry); if (entry.selected) { initialValues.push(mod.code); } } } - officialModules.sort((a, b) => a.sortKey - b.sortKey); - if (officialModules.length > 0) { - groupedOptions['BMad Official Modules'] = officialModules.map(({ label, value }) => ({ label, value })); - } + allOptions.push(...officialModules.map(({ label, value, hint }) => ({ label, value, hint }))); // Group 3: Community Modules (type: community) const communityModules = []; for (const mod of externalModules) { if (mod.type === 'community') { - const entry = buildModuleEntry(mod, mod.code); + const entry = buildModuleEntry(mod, mod.code, 'Community'); communityModules.push(entry); if (entry.selected) { initialValues.push(mod.code); } } } - communityModules.sort((a, b) => a.sortKey - b.sortKey); - if (communityModules.length > 0) { - groupedOptions['Community Modules'] = communityModules.map(({ label, value }) => ({ label, value })); - } + allOptions.push(...communityModules.map(({ label, value, hint }) => ({ label, value, hint })), { + // "None" option at the end + label: '\u26A0 None - Skip module installation', + value: '__NONE__', + }); - // Add "None" option at the end - groupedOptions[' '] = [ - { - label: '⚠ None - Skip module installation', - value: '__NONE__', - }, - ]; - - const selected = await prompts.groupMultiselect({ - message: `Select modules to install ${chalk.dim('(↑/↓ navigates, SPACE toggles, ENTER to confirm)')}:`, - options: groupedOptions, + const selected = await prompts.autocompleteMultiselect({ + message: 'Select modules to install:', + options: allOptions, initialValues: initialValues.length > 0 ? initialValues : undefined, + lockedValues, required: true, - selectableGroups: false, + maxItems: allOptions.length, }); // If user selected both "__NONE__" and other items, honor the "None" choice if (selected && selected.includes('__NONE__') && selected.length > 1) { - console.log(); - console.log(chalk.yellow('⚠️ "None" was selected, so no modules will be installed.')); - console.log(); + await prompts.log.warn('"None" was selected, so no modules will be installed.'); return []; } // Filter out the special '__NONE__' value - return selected ? selected.filter((m) => m !== '__NONE__') : []; + const result = selected ? selected.filter((m) => m !== '__NONE__') : []; + + // Display selected modules as bulleted list + if (result.length > 0) { + const moduleLines = result.map((moduleId) => { + const opt = allOptions.find((o) => o.value === moduleId); + return ` \u2022 ${opt?.label || moduleId}`; + }); + await prompts.log.message('Selected modules:\n' + moduleLines.join('\n')); + } + + return result; } /** @@ -1185,7 +1160,7 @@ class UI { * @param {string} directory - The directory path */ async displayDirectoryInfo(directory) { - console.log(chalk.cyan('\nResolved installation path:'), chalk.bold(directory)); + await prompts.log.info(`Resolved installation path: ${directory}`); const dirExists = await fs.pathExists(directory); if (dirExists) { @@ -1201,12 +1176,10 @@ class UI { const hasBmadInstall = (await fs.pathExists(bmadResult.bmadDir)) && (await fs.pathExists(path.join(bmadResult.bmadDir, '_config', 'manifest.yaml'))); - console.log( - chalk.gray(`Directory exists and contains ${files.length} item(s)`) + - (hasBmadInstall ? chalk.yellow(` including existing BMAD installation (${path.basename(bmadResult.bmadDir)})`) : ''), - ); + const bmadNote = hasBmadInstall ? ` including existing BMAD installation (${path.basename(bmadResult.bmadDir)})` : ''; + await prompts.log.message(`Directory exists and contains ${files.length} item(s)${bmadNote}`); } else { - console.log(chalk.gray('Directory exists and is empty')); + await prompts.log.message('Directory exists and is empty'); } } } @@ -1227,7 +1200,7 @@ class UI { }); if (!proceed) { - console.log(chalk.yellow("\nLet's try again with a different path.\n")); + await prompts.log.warn("Let's try again with a different path."); } return proceed; @@ -1239,7 +1212,7 @@ class UI { }); if (!create) { - console.log(chalk.yellow("\nLet's try again with a different path.\n")); + await prompts.log.warn("Let's try again with a different path."); } return create; @@ -1459,7 +1432,7 @@ class UI { return configs; } catch { // If loading fails, return empty configs - console.warn('Warning: Could not load existing configurations'); + await prompts.log.warn('Could not load existing configurations'); return configs; } } @@ -1590,7 +1563,7 @@ class UI { name: moduleData.name || moduleData.code, }); - console.log(chalk.green(`✓ Confirmed local custom module: ${moduleData.name || moduleData.code}`)); + await prompts.log.success(`Confirmed local custom module: ${moduleData.name || moduleData.code}`); } // Ask if user wants to add these to the installation @@ -1656,11 +1629,11 @@ class UI { }; // Ask user about custom modules - console.log(chalk.cyan('\n⚙️ Custom Modules')); + await prompts.log.info('Custom Modules'); if (cachedCustomModules.length > 0) { - console.log(chalk.dim('Found custom modules in your installation:')); + await prompts.log.message('Found custom modules in your installation:'); } else { - console.log(chalk.dim('No custom modules currently installed.')); + await prompts.log.message('No custom modules currently installed.'); } // Build choices dynamically based on whether we have existing modules @@ -1686,14 +1659,14 @@ class UI { case 'keep': { // Keep all existing custom modules result.selectedCustomModules = cachedCustomModules.map((m) => m.id); - console.log(chalk.dim(`Keeping ${result.selectedCustomModules.length} custom module(s)`)); + await prompts.log.message(`Keeping ${result.selectedCustomModules.length} custom module(s)`); break; } case 'select': { // Let user choose which to keep const selectChoices = cachedCustomModules.map((m) => ({ - name: `${m.name} ${chalk.gray(`(${m.id})`)}`, + name: `${m.name} (${m.id})`, value: m.id, checked: m.checked, })); @@ -1709,16 +1682,14 @@ class UI { ]; const keepModules = await prompts.multiselect({ - message: `Select custom modules to keep ${chalk.dim('(↑/↓ navigates, SPACE toggles, ENTER to confirm)')}:`, + message: 'Select custom modules to keep (use arrow keys, space to toggle):', choices: choicesWithSkip, required: true, }); // If user selected both "__NONE__" and other modules, honor the "None" choice if (keepModules && keepModules.includes('__NONE__') && keepModules.length > 1) { - console.log(); - console.log(chalk.yellow('⚠️ "None / I changed my mind" was selected, so no custom modules will be kept.')); - console.log(); + await prompts.log.warn('"None / I changed my mind" was selected, so no custom modules will be kept.'); result.selectedCustomModules = []; } else { // Filter out the special '__NONE__' value @@ -1743,13 +1714,13 @@ class UI { case 'remove': { // Remove all custom modules - console.log(chalk.yellow('All custom modules will be removed from the installation')); + await prompts.log.warn('All custom modules will be removed from the installation'); break; } case 'cancel': { // User cancelled - no custom modules - console.log(chalk.dim('No custom modules will be added')); + await prompts.log.message('No custom modules will be added'); break; } } @@ -1782,30 +1753,26 @@ class UI { return true; // Not legacy, proceed } - console.log(''); - console.log(chalk.yellow.bold('⚠️ VERSION WARNING')); - console.log(chalk.yellow('─'.repeat(80))); - + let warningContent; if (installedVersion === 'unknown') { - console.log(chalk.yellow('Unable to detect your installed BMAD version.')); - console.log(chalk.yellow('This appears to be a legacy or unsupported installation.')); + warningContent = 'Unable to detect your installed BMAD version.\n' + 'This appears to be a legacy or unsupported installation.'; } else { - console.log(chalk.yellow(`You are updating from ${installedVersion} to ${currentVersion}.`)); - console.log(chalk.yellow('You have a legacy version installed (v4 or alpha).')); + warningContent = + `You are updating from ${installedVersion} to ${currentVersion}.\n` + 'You have a legacy version installed (v4 or alpha).'; } - console.log(''); - console.log(chalk.dim('For the best experience, we recommend:')); - console.log(chalk.dim(' 1. Delete your current BMAD installation folder')); - console.log(chalk.dim(` (the "${bmadFolderName}/" folder in your project)`)); - console.log(chalk.dim(' 2. Run a fresh installation')); - console.log(''); - console.log(chalk.dim('Benefits of a fresh install:')); - console.log(chalk.dim(' • Cleaner configuration without legacy artifacts')); - console.log(chalk.dim(' • All new features properly configured')); - console.log(chalk.dim(' • Fewer potential conflicts')); - console.log(chalk.yellow('─'.repeat(80))); - console.log(''); + warningContent += + '\n\nFor the best experience, we recommend:\n' + + ' 1. Delete your current BMAD installation folder\n' + + ` (the "${bmadFolderName}/" folder in your project)\n` + + ' 2. Run a fresh installation\n\n' + + 'Benefits of a fresh install:\n' + + ' \u2022 Cleaner configuration without legacy artifacts\n' + + ' \u2022 All new features properly configured\n' + + ' \u2022 Fewer potential conflicts'; + + await prompts.log.warn('VERSION WARNING'); + await prompts.note(warningContent, 'Version Warning'); const proceed = await prompts.select({ message: 'How would you like to proceed?', @@ -1823,11 +1790,10 @@ class UI { }); if (proceed === 'cancel') { - console.log(''); - console.log(chalk.cyan('To do a fresh install:')); - console.log(chalk.dim(` 1. Delete the "${bmadFolderName}/" folder in your project`)); - console.log(chalk.dim(" 2. Run 'bmad install' again")); - console.log(''); + await prompts.note( + `1. Delete the "${bmadFolderName}/" folder in your project\n` + "2. Run 'bmad install' again", + 'To do a fresh install', + ); } return proceed === 'proceed'; @@ -1838,41 +1804,34 @@ class UI { * @param {Array} modules - Array of module info objects with version info * @param {Array} availableUpdates - Array of available updates */ - displayModuleVersions(modules, availableUpdates = []) { - console.log(''); - console.log(chalk.cyan.bold('📦 Module Versions')); - console.log(chalk.gray('─'.repeat(80))); - + async displayModuleVersions(modules, availableUpdates = []) { // Group modules by source const builtIn = modules.filter((m) => m.source === 'built-in'); const external = modules.filter((m) => m.source === 'external'); const custom = modules.filter((m) => m.source === 'custom'); const unknown = modules.filter((m) => m.source === 'unknown'); - const displayGroup = (group, title) => { + const lines = []; + const formatGroup = (group, title) => { if (group.length === 0) return; - - console.log(chalk.yellow(`\n${title}`)); - for (const module of group) { - const updateInfo = availableUpdates.find((u) => u.name === module.name); - const versionDisplay = module.version || chalk.gray('unknown'); - + lines.push(title); + for (const mod of group) { + const updateInfo = availableUpdates.find((u) => u.name === mod.name); + const versionDisplay = mod.version || 'unknown'; if (updateInfo) { - console.log( - ` ${chalk.cyan(module.name.padEnd(20))} ${versionDisplay} → ${chalk.green(updateInfo.latestVersion)} ${chalk.green('↑')}`, - ); + lines.push(` ${mod.name.padEnd(20)} ${versionDisplay} \u2192 ${updateInfo.latestVersion} \u2191`); } else { - console.log(` ${chalk.cyan(module.name.padEnd(20))} ${versionDisplay} ${chalk.gray('✓')}`); + lines.push(` ${mod.name.padEnd(20)} ${versionDisplay} \u2713`); } } }; - displayGroup(builtIn, 'Built-in Modules'); - displayGroup(external, 'External Modules (Official)'); - displayGroup(custom, 'Custom Modules'); - displayGroup(unknown, 'Other Modules'); + formatGroup(builtIn, 'Built-in Modules'); + formatGroup(external, 'External Modules (Official)'); + formatGroup(custom, 'Custom Modules'); + formatGroup(unknown, 'Other Modules'); - console.log(''); + await prompts.note(lines.join('\n'), 'Module Versions'); } /** @@ -1885,12 +1844,10 @@ class UI { return []; } - console.log(''); - console.log(chalk.cyan.bold('🔄 Available Updates')); - console.log(chalk.gray('─'.repeat(80))); + await prompts.log.info('Available Updates'); const choices = availableUpdates.map((update) => ({ - name: `${update.name} ${chalk.dim(`(v${update.installedVersion} → v${update.latestVersion})`)}`, + name: `${update.name} (v${update.installedVersion} \u2192 v${update.latestVersion})`, value: update.name, checked: true, // Default to selecting all updates })); @@ -1916,7 +1873,7 @@ class UI { // Allow specific selection const selected = await prompts.multiselect({ - message: `Select modules to update ${chalk.dim('(↑/↓ navigates, SPACE toggles, ENTER to confirm)')}:`, + message: 'Select modules to update (use arrow keys, space to toggle):', choices: choices, required: true, }); @@ -1928,34 +1885,29 @@ class UI { * Display status of all installed modules * @param {Object} statusData - Status data with modules, installation info, and available updates */ - displayStatus(statusData) { + async displayStatus(statusData) { const { installation, modules, availableUpdates, bmadDir } = statusData; - console.log(''); - console.log(chalk.cyan.bold('📋 BMAD Status')); - console.log(chalk.gray('─'.repeat(80))); - // Installation info - console.log(chalk.yellow('\nInstallation')); - console.log(` ${chalk.gray('Version:'.padEnd(20))} ${installation.version || chalk.gray('unknown')}`); - console.log(` ${chalk.gray('Location:'.padEnd(20))} ${bmadDir}`); - console.log(` ${chalk.gray('Installed:'.padEnd(20))} ${new Date(installation.installDate).toLocaleDateString()}`); - console.log( - ` ${chalk.gray('Last Updated:'.padEnd(20))} ${installation.lastUpdated ? new Date(installation.lastUpdated).toLocaleDateString() : chalk.gray('unknown')}`, - ); + const infoLines = [ + `Version: ${installation.version || 'unknown'}`, + `Location: ${bmadDir}`, + `Installed: ${new Date(installation.installDate).toLocaleDateString()}`, + `Last Updated: ${installation.lastUpdated ? new Date(installation.lastUpdated).toLocaleDateString() : 'unknown'}`, + ]; + + await prompts.note(infoLines.join('\n'), 'BMAD Status'); // Module versions - this.displayModuleVersions(modules, availableUpdates); + await this.displayModuleVersions(modules, availableUpdates); // Update summary if (availableUpdates.length > 0) { - console.log(chalk.yellow.bold(`\n⚠️ ${availableUpdates.length} update(s) available`)); - console.log(chalk.dim(` Run 'bmad install' and select "Quick Update" to update`)); + await prompts.log.warn(`${availableUpdates.length} update(s) available`); + await prompts.log.message('Run \'bmad install\' and select "Quick Update" to update'); } else { - console.log(chalk.green.bold('\n✓ All modules are up to date')); + await prompts.log.success('All modules are up to date'); } - - console.log(''); } /** @@ -1964,19 +1916,17 @@ class UI { * @param {Array} preferredIdes - Array of preferred IDE objects * @param {Array} allTools - Array of all tool objects */ - displaySelectedTools(selectedIdes, preferredIdes, allTools) { + async displaySelectedTools(selectedIdes, preferredIdes, allTools) { if (selectedIdes.length === 0) return; const preferredValues = new Set(preferredIdes.map((ide) => ide.value)); - - console.log(''); - console.log(chalk.dim(' Selected tools:')); - for (const ideValue of selectedIdes) { + const toolLines = selectedIdes.map((ideValue) => { const tool = allTools.find((t) => t.value === ideValue); const name = tool?.name || ideValue; - const marker = preferredValues.has(ideValue) ? ' ⭐' : ''; - console.log(chalk.dim(` • ${name}${marker}`)); - } + const marker = preferredValues.has(ideValue) ? ' \u2B50' : ''; + return ` \u2022 ${name}${marker}`; + }); + await prompts.log.message('Selected tools:\n' + toolLines.join('\n')); } }