faf-cli 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +227 -0
  3. package/dist/cli.d.ts +8 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +1249 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/ai-analyze.d.ts +18 -0
  8. package/dist/commands/ai-analyze.d.ts.map +1 -0
  9. package/dist/commands/ai-analyze.js +226 -0
  10. package/dist/commands/ai-analyze.js.map +1 -0
  11. package/dist/commands/ai-enhance.d.ts +17 -0
  12. package/dist/commands/ai-enhance.d.ts.map +1 -0
  13. package/dist/commands/ai-enhance.js +278 -0
  14. package/dist/commands/ai-enhance.js.map +1 -0
  15. package/dist/commands/audit.d.ts +11 -0
  16. package/dist/commands/audit.d.ts.map +1 -0
  17. package/dist/commands/audit.js +180 -0
  18. package/dist/commands/audit.js.map +1 -0
  19. package/dist/commands/auto.d.ts +27 -0
  20. package/dist/commands/auto.d.ts.map +1 -0
  21. package/dist/commands/auto.js +106 -0
  22. package/dist/commands/auto.js.map +1 -0
  23. package/dist/commands/bi-sync.d.ts +43 -0
  24. package/dist/commands/bi-sync.d.ts.map +1 -0
  25. package/dist/commands/bi-sync.js +224 -0
  26. package/dist/commands/bi-sync.js.map +1 -0
  27. package/dist/commands/chat.d.ts +6 -0
  28. package/dist/commands/chat.d.ts.map +1 -0
  29. package/dist/commands/chat.js +227 -0
  30. package/dist/commands/chat.js.map +1 -0
  31. package/dist/commands/check.d.ts +15 -0
  32. package/dist/commands/check.d.ts.map +1 -0
  33. package/dist/commands/check.js +58 -0
  34. package/dist/commands/check.js.map +1 -0
  35. package/dist/commands/clear.d.ts +15 -0
  36. package/dist/commands/clear.d.ts.map +1 -0
  37. package/dist/commands/clear.js +167 -0
  38. package/dist/commands/clear.js.map +1 -0
  39. package/dist/commands/commit.d.ts +8 -0
  40. package/dist/commands/commit.d.ts.map +1 -0
  41. package/dist/commands/commit.js +164 -0
  42. package/dist/commands/commit.js.map +1 -0
  43. package/dist/commands/convert.d.ts +19 -0
  44. package/dist/commands/convert.d.ts.map +1 -0
  45. package/dist/commands/convert.js +102 -0
  46. package/dist/commands/convert.js.map +1 -0
  47. package/dist/commands/credit.d.ts +13 -0
  48. package/dist/commands/credit.d.ts.map +1 -0
  49. package/dist/commands/credit.js +149 -0
  50. package/dist/commands/credit.js.map +1 -0
  51. package/dist/commands/edit-helper.d.ts +6 -0
  52. package/dist/commands/edit-helper.d.ts.map +1 -0
  53. package/dist/commands/edit-helper.js +55 -0
  54. package/dist/commands/edit-helper.js.map +1 -0
  55. package/dist/commands/edit.d.ts +14 -0
  56. package/dist/commands/edit.d.ts.map +1 -0
  57. package/dist/commands/edit.js +196 -0
  58. package/dist/commands/edit.js.map +1 -0
  59. package/dist/commands/faf-auth.d.ts +10 -0
  60. package/dist/commands/faf-auth.d.ts.map +1 -0
  61. package/dist/commands/faf-auth.js +162 -0
  62. package/dist/commands/faf-auth.js.map +1 -0
  63. package/dist/commands/faf-dna.d.ts +9 -0
  64. package/dist/commands/faf-dna.d.ts.map +1 -0
  65. package/dist/commands/faf-dna.js +141 -0
  66. package/dist/commands/faf-dna.js.map +1 -0
  67. package/dist/commands/faf-log.d.ts +9 -0
  68. package/dist/commands/faf-log.d.ts.map +1 -0
  69. package/dist/commands/faf-log.js +135 -0
  70. package/dist/commands/faf-log.js.map +1 -0
  71. package/dist/commands/faf-recover.d.ts +3 -0
  72. package/dist/commands/faf-recover.d.ts.map +1 -0
  73. package/dist/commands/faf-recover.js +299 -0
  74. package/dist/commands/faf-recover.js.map +1 -0
  75. package/dist/commands/faf-update.d.ts +9 -0
  76. package/dist/commands/faf-update.d.ts.map +1 -0
  77. package/dist/commands/faf-update.js +68 -0
  78. package/dist/commands/faf-update.js.map +1 -0
  79. package/dist/commands/faq.d.ts +12 -0
  80. package/dist/commands/faq.d.ts.map +1 -0
  81. package/dist/commands/faq.js +84 -0
  82. package/dist/commands/faq.js.map +1 -0
  83. package/dist/commands/flow.d.ts +11 -0
  84. package/dist/commands/flow.d.ts.map +1 -0
  85. package/dist/commands/flow.js +117 -0
  86. package/dist/commands/flow.js.map +1 -0
  87. package/dist/commands/formats.d.ts +12 -0
  88. package/dist/commands/formats.d.ts.map +1 -0
  89. package/dist/commands/formats.js +109 -0
  90. package/dist/commands/formats.js.map +1 -0
  91. package/dist/commands/index.d.ts +14 -0
  92. package/dist/commands/index.d.ts.map +1 -0
  93. package/dist/commands/index.js +443 -0
  94. package/dist/commands/index.js.map +1 -0
  95. package/dist/commands/init.d.ts +14 -0
  96. package/dist/commands/init.d.ts.map +1 -0
  97. package/dist/commands/init.js +202 -0
  98. package/dist/commands/init.js.map +1 -0
  99. package/dist/commands/lint.d.ts +11 -0
  100. package/dist/commands/lint.d.ts.map +1 -0
  101. package/dist/commands/lint.js +269 -0
  102. package/dist/commands/lint.js.map +1 -0
  103. package/dist/commands/mirror.d.ts +7 -0
  104. package/dist/commands/mirror.d.ts.map +1 -0
  105. package/dist/commands/mirror.js +130 -0
  106. package/dist/commands/mirror.js.map +1 -0
  107. package/dist/commands/score.d.ts +11 -0
  108. package/dist/commands/score.d.ts.map +1 -0
  109. package/dist/commands/score.js +192 -0
  110. package/dist/commands/score.js.map +1 -0
  111. package/dist/commands/search.d.ts +16 -0
  112. package/dist/commands/search.d.ts.map +1 -0
  113. package/dist/commands/search.js +174 -0
  114. package/dist/commands/search.js.map +1 -0
  115. package/dist/commands/share.d.ts +17 -0
  116. package/dist/commands/share.d.ts.map +1 -0
  117. package/dist/commands/share.js +260 -0
  118. package/dist/commands/share.js.map +1 -0
  119. package/dist/commands/show.d.ts +10 -0
  120. package/dist/commands/show.d.ts.map +1 -0
  121. package/dist/commands/show.js +167 -0
  122. package/dist/commands/show.js.map +1 -0
  123. package/dist/commands/stacks.d.ts +51 -0
  124. package/dist/commands/stacks.d.ts.map +1 -0
  125. package/dist/commands/stacks.js +180 -0
  126. package/dist/commands/stacks.js.map +1 -0
  127. package/dist/commands/status.d.ts +13 -0
  128. package/dist/commands/status.d.ts.map +1 -0
  129. package/dist/commands/status.js +158 -0
  130. package/dist/commands/status.js.map +1 -0
  131. package/dist/commands/sync.d.ts +11 -0
  132. package/dist/commands/sync.d.ts.map +1 -0
  133. package/dist/commands/sync.js +300 -0
  134. package/dist/commands/sync.js.map +1 -0
  135. package/dist/commands/todo.d.ts +14 -0
  136. package/dist/commands/todo.d.ts.map +1 -0
  137. package/dist/commands/todo.js +279 -0
  138. package/dist/commands/todo.js.map +1 -0
  139. package/dist/commands/trust.d.ts +33 -0
  140. package/dist/commands/trust.d.ts.map +1 -0
  141. package/dist/commands/trust.js +316 -0
  142. package/dist/commands/trust.js.map +1 -0
  143. package/dist/commands/validate.d.ts +11 -0
  144. package/dist/commands/validate.d.ts.map +1 -0
  145. package/dist/commands/validate.js +100 -0
  146. package/dist/commands/validate.js.map +1 -0
  147. package/dist/commands/verify.d.ts +36 -0
  148. package/dist/commands/verify.d.ts.map +1 -0
  149. package/dist/commands/verify.js +194 -0
  150. package/dist/commands/verify.js.map +1 -0
  151. package/dist/commands/version.d.ts +5 -0
  152. package/dist/commands/version.d.ts.map +1 -0
  153. package/dist/commands/version.js +33 -0
  154. package/dist/commands/version.js.map +1 -0
  155. package/dist/commands/vibe.d.ts +7 -0
  156. package/dist/commands/vibe.d.ts.map +1 -0
  157. package/dist/commands/vibe.js +78 -0
  158. package/dist/commands/vibe.js.map +1 -0
  159. package/dist/converters/faf-converters.d.ts +43 -0
  160. package/dist/converters/faf-converters.d.ts.map +1 -0
  161. package/dist/converters/faf-converters.js +186 -0
  162. package/dist/converters/faf-converters.js.map +1 -0
  163. package/dist/engine-bridge.d.ts +35 -0
  164. package/dist/engine-bridge.d.ts.map +1 -0
  165. package/dist/engine-bridge.js +76 -0
  166. package/dist/engine-bridge.js.map +1 -0
  167. package/dist/engines/claude-todo-engine.d.ts +115 -0
  168. package/dist/engines/claude-todo-engine.d.ts.map +1 -0
  169. package/dist/engines/claude-todo-engine.js +346 -0
  170. package/dist/engines/claude-todo-engine.js.map +1 -0
  171. package/dist/engines/drop-coach.d.ts +64 -0
  172. package/dist/engines/drop-coach.d.ts.map +1 -0
  173. package/dist/engines/drop-coach.js +222 -0
  174. package/dist/engines/drop-coach.js.map +1 -0
  175. package/dist/engines/fab-formats-processor.d.ts +167 -0
  176. package/dist/engines/fab-formats-processor.d.ts.map +1 -0
  177. package/dist/engines/fab-formats-processor.js +1274 -0
  178. package/dist/engines/fab-formats-processor.js.map +1 -0
  179. package/dist/engines/faf-dna.d.ts +160 -0
  180. package/dist/engines/faf-dna.d.ts.map +1 -0
  181. package/dist/engines/faf-dna.js +522 -0
  182. package/dist/engines/faf-dna.js.map +1 -0
  183. package/dist/engines/relentless-context-extractor.d.ts +101 -0
  184. package/dist/engines/relentless-context-extractor.d.ts.map +1 -0
  185. package/dist/engines/relentless-context-extractor.js +625 -0
  186. package/dist/engines/relentless-context-extractor.js.map +1 -0
  187. package/dist/fix-once/colors.d.ts +83 -0
  188. package/dist/fix-once/colors.d.ts.map +1 -0
  189. package/dist/fix-once/colors.js +145 -0
  190. package/dist/fix-once/colors.js.map +1 -0
  191. package/dist/fix-once/types.d.ts +258 -0
  192. package/dist/fix-once/types.d.ts.map +1 -0
  193. package/dist/fix-once/types.js +26 -0
  194. package/dist/fix-once/types.js.map +1 -0
  195. package/dist/framework-detector.d.ts +286 -0
  196. package/dist/framework-detector.d.ts.map +1 -0
  197. package/dist/framework-detector.js +782 -0
  198. package/dist/framework-detector.js.map +1 -0
  199. package/dist/generators/faf-generator-championship.d.ts +11 -0
  200. package/dist/generators/faf-generator-championship.d.ts.map +1 -0
  201. package/dist/generators/faf-generator-championship.js +371 -0
  202. package/dist/generators/faf-generator-championship.js.map +1 -0
  203. package/dist/index.d.ts +18 -0
  204. package/dist/index.d.ts.map +1 -0
  205. package/dist/index.js +34 -0
  206. package/dist/index.js.map +1 -0
  207. package/dist/output/experience-manager.d.ts +58 -0
  208. package/dist/output/experience-manager.d.ts.map +1 -0
  209. package/dist/output/experience-manager.js +212 -0
  210. package/dist/output/experience-manager.js.map +1 -0
  211. package/dist/schema/faf-schema.d.ts +92 -0
  212. package/dist/schema/faf-schema.d.ts.map +1 -0
  213. package/dist/schema/faf-schema.js +173 -0
  214. package/dist/schema/faf-schema.js.map +1 -0
  215. package/dist/scoring/championship-scorer.d.ts +114 -0
  216. package/dist/scoring/championship-scorer.d.ts.map +1 -0
  217. package/dist/scoring/championship-scorer.js +380 -0
  218. package/dist/scoring/championship-scorer.js.map +1 -0
  219. package/dist/scoring/score-calculator.d.ts +29 -0
  220. package/dist/scoring/score-calculator.d.ts.map +1 -0
  221. package/dist/scoring/score-calculator.js +520 -0
  222. package/dist/scoring/score-calculator.js.map +1 -0
  223. package/dist/telemetry/analytics.d.ts +74 -0
  224. package/dist/telemetry/analytics.d.ts.map +1 -0
  225. package/dist/telemetry/analytics.js +370 -0
  226. package/dist/telemetry/analytics.js.map +1 -0
  227. package/dist/utils/balance-visualizer.d.ts +38 -0
  228. package/dist/utils/balance-visualizer.d.ts.map +1 -0
  229. package/dist/utils/balance-visualizer.js +196 -0
  230. package/dist/utils/balance-visualizer.js.map +1 -0
  231. package/dist/utils/championship-style.d.ts +110 -0
  232. package/dist/utils/championship-style.d.ts.map +1 -0
  233. package/dist/utils/championship-style.js +213 -0
  234. package/dist/utils/championship-style.js.map +1 -0
  235. package/dist/utils/color-utils.d.ts +17 -0
  236. package/dist/utils/color-utils.d.ts.map +1 -0
  237. package/dist/utils/color-utils.js +96 -0
  238. package/dist/utils/color-utils.js.map +1 -0
  239. package/dist/utils/fab-formats-engine.d.ts +76 -0
  240. package/dist/utils/fab-formats-engine.d.ts.map +1 -0
  241. package/dist/utils/fab-formats-engine.js +424 -0
  242. package/dist/utils/fab-formats-engine.js.map +1 -0
  243. package/dist/utils/fafignore-parser.d.ts +21 -0
  244. package/dist/utils/fafignore-parser.d.ts.map +1 -0
  245. package/dist/utils/fafignore-parser.js +178 -0
  246. package/dist/utils/fafignore-parser.js.map +1 -0
  247. package/dist/utils/file-utils.d.ts +65 -0
  248. package/dist/utils/file-utils.d.ts.map +1 -0
  249. package/dist/utils/file-utils.js +598 -0
  250. package/dist/utils/file-utils.js.map +1 -0
  251. package/dist/utils/platform-detector.d.ts +31 -0
  252. package/dist/utils/platform-detector.d.ts.map +1 -0
  253. package/dist/utils/platform-detector.js +218 -0
  254. package/dist/utils/platform-detector.js.map +1 -0
  255. package/dist/utils/technical-credit.d.ts +36 -0
  256. package/dist/utils/technical-credit.d.ts.map +1 -0
  257. package/dist/utils/technical-credit.js +286 -0
  258. package/dist/utils/technical-credit.js.map +1 -0
  259. package/dist/utils/trust-cache.d.ts +29 -0
  260. package/dist/utils/trust-cache.d.ts.map +1 -0
  261. package/dist/utils/trust-cache.js +123 -0
  262. package/dist/utils/trust-cache.js.map +1 -0
  263. package/dist/utils/turbo-cat-knowledge.d.ts +82 -0
  264. package/dist/utils/turbo-cat-knowledge.d.ts.map +1 -0
  265. package/dist/utils/turbo-cat-knowledge.js +1346 -0
  266. package/dist/utils/turbo-cat-knowledge.js.map +1 -0
  267. package/dist/utils/turbo-cat-pyramid.d.ts +38 -0
  268. package/dist/utils/turbo-cat-pyramid.d.ts.map +1 -0
  269. package/dist/utils/turbo-cat-pyramid.js +287 -0
  270. package/dist/utils/turbo-cat-pyramid.js.map +1 -0
  271. package/dist/utils/turbo-cat.d.ts +92 -0
  272. package/dist/utils/turbo-cat.d.ts.map +1 -0
  273. package/dist/utils/turbo-cat.js +412 -0
  274. package/dist/utils/turbo-cat.js.map +1 -0
  275. package/dist/utils/vibe-sync.d.ts +25 -0
  276. package/dist/utils/vibe-sync.d.ts.map +1 -0
  277. package/dist/utils/vibe-sync.js +169 -0
  278. package/dist/utils/vibe-sync.js.map +1 -0
  279. package/dist/utils/yaml-generator.d.ts +39 -0
  280. package/dist/utils/yaml-generator.d.ts.map +1 -0
  281. package/dist/utils/yaml-generator.js +345 -0
  282. package/dist/utils/yaml-generator.js.map +1 -0
  283. package/package.json +96 -0
package/dist/cli.js ADDED
@@ -0,0 +1,1249 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * 🚀 .faf CLI - Command Line Interface
5
+ * Universal AI Context Format Tooling
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || (function () {
24
+ var ownKeys = function(o) {
25
+ ownKeys = Object.getOwnPropertyNames || function (o) {
26
+ var ar = [];
27
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
28
+ return ar;
29
+ };
30
+ return ownKeys(o);
31
+ };
32
+ return function (mod) {
33
+ if (mod && mod.__esModule) return mod;
34
+ var result = {};
35
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
36
+ __setModuleDefault(result, mod);
37
+ return result;
38
+ };
39
+ })();
40
+ var __importDefault = (this && this.__importDefault) || function (mod) {
41
+ return (mod && mod.__esModule) ? mod : { "default": mod };
42
+ };
43
+ Object.defineProperty(exports, "__esModule", { value: true });
44
+ exports.program = void 0;
45
+ const commander_1 = require("commander");
46
+ Object.defineProperty(exports, "program", { enumerable: true, get: function () { return commander_1.program; } });
47
+ const chalk_1 = __importDefault(require("chalk"));
48
+ const inquirer_1 = __importDefault(require("inquirer"));
49
+ const validate_1 = require("./commands/validate");
50
+ const init_1 = require("./commands/init");
51
+ const score_1 = require("./commands/score");
52
+ const show_1 = require("./commands/show");
53
+ const edit_helper_1 = require("./commands/edit-helper");
54
+ const auto_1 = require("./commands/auto");
55
+ const formats_1 = require("./commands/formats");
56
+ const version_1 = require("./commands/version");
57
+ const sync_1 = require("./commands/sync");
58
+ const audit_1 = require("./commands/audit");
59
+ const lint_1 = require("./commands/lint");
60
+ const ai_enhance_1 = require("./commands/ai-enhance");
61
+ const ai_analyze_1 = require("./commands/ai-analyze");
62
+ const trust_1 = require("./commands/trust");
63
+ const status_1 = require("./commands/status");
64
+ const verify_1 = require("./commands/verify");
65
+ const stacks_1 = require("./commands/stacks");
66
+ const bi_sync_1 = require("./commands/bi-sync");
67
+ const credit_1 = require("./commands/credit");
68
+ const todo_1 = require("./commands/todo");
69
+ const check_1 = require("./commands/check");
70
+ const clear_1 = require("./commands/clear");
71
+ const edit_1 = require("./commands/edit");
72
+ const search_1 = require("./commands/search");
73
+ const index_1 = require("./commands/index");
74
+ const share_1 = require("./commands/share");
75
+ const chat_1 = require("./commands/chat");
76
+ const convert_1 = require("./commands/convert");
77
+ const flow_1 = require("./commands/flow");
78
+ const color_utils_1 = require("./utils/color-utils");
79
+ const championship_style_1 = require("./utils/championship-style");
80
+ const analytics_1 = require("./telemetry/analytics");
81
+ const file_utils_1 = require("./utils/file-utils");
82
+ const score_calculator_1 = require("./scoring/score-calculator");
83
+ const trust_cache_1 = require("./utils/trust-cache");
84
+ const YAML = __importStar(require("yaml"));
85
+ const version = require('../package.json').version;
86
+ /**
87
+ * Show current score as footer
88
+ */
89
+ async function showScoreFooter(context) {
90
+ console.log('');
91
+ // Show context status line
92
+ if (context === 'device') {
93
+ console.log(chalk_1.default.dim('Using Device CLI'));
94
+ }
95
+ else if (context === 'faf') {
96
+ console.log(chalk_1.default.dim('Using faf CLI'));
97
+ }
98
+ else if (context === 'chat') {
99
+ console.log(chalk_1.default.dim('Using faf chat'));
100
+ }
101
+ try {
102
+ const existingFafPath = await (0, file_utils_1.findFafFile)();
103
+ if (existingFafPath) {
104
+ const fs = await Promise.resolve().then(() => __importStar(require('fs'))).then(m => m.promises);
105
+ const fafContent = await fs.readFile(existingFafPath, 'utf-8');
106
+ const fafData = YAML.parse(fafContent);
107
+ const scoreResult = await (0, score_calculator_1.calculateFafScore)(fafData, existingFafPath);
108
+ const percentage = Math.round(scoreResult.totalScore);
109
+ // Get AI readiness from trust cache
110
+ const trustCache = await (0, trust_cache_1.getTrustCache)(existingFafPath);
111
+ const aiReadiness = trustCache?.aiCompatibilityScore || 0;
112
+ // Style the scores with championship colors
113
+ const scoreColor = percentage >= 85 ? championship_style_1.FAF_COLORS.fafGreen : percentage >= 70 ? championship_style_1.FAF_COLORS.fafCyan : championship_style_1.FAF_COLORS.fafOrange;
114
+ // RULE: Only show AI-Predictive if it's greater than FAF Score
115
+ if (aiReadiness > percentage) {
116
+ console.log(`Current Score: ${scoreColor(percentage + '%')} > AI-Predictive: ${championship_style_1.FAF_COLORS.fafCyan(aiReadiness + '%')}`);
117
+ }
118
+ else {
119
+ console.log(`Current Score: ${scoreColor(percentage + '%')}`);
120
+ }
121
+ }
122
+ else {
123
+ console.log(`Current Score: 0% > AI-Predictive: ${championship_style_1.FAF_COLORS.fafCyan('0%')}`);
124
+ }
125
+ }
126
+ catch {
127
+ console.log(`Current Score: 0% > AI-Predictive: ${championship_style_1.FAF_COLORS.fafCyan('0%')}`);
128
+ }
129
+ }
130
+ /**
131
+ * Analytics tracking wrapper for commands
132
+ */
133
+ function withAnalyticsTracking(commandName, fn) {
134
+ return (async (...args) => {
135
+ const start = Date.now();
136
+ const commandArgs = process.argv.slice(2);
137
+ try {
138
+ const result = await fn(...args);
139
+ const duration = Date.now() - start;
140
+ await (0, analytics_1.trackCommand)(commandName, commandArgs, duration, true);
141
+ // Show score footer after every command
142
+ await showScoreFooter('device');
143
+ return result;
144
+ }
145
+ catch (error) {
146
+ const duration = Date.now() - start;
147
+ await (0, analytics_1.trackCommand)(commandName, commandArgs, duration, false);
148
+ await (0, analytics_1.trackError)(error, commandName, commandArgs);
149
+ throw error;
150
+ }
151
+ });
152
+ }
153
+ function showHeaderIfAppropriate(commandName) {
154
+ const showHeaderCommands = ['help', 'init', 'clear', 'enhance', 'analyze', 'chat', 'formats', 'score', 'version'];
155
+ if (!commandName || showHeaderCommands.includes(commandName)) {
156
+ console.log((0, championship_style_1.generateFAFHeader)());
157
+ }
158
+ }
159
+ commander_1.program
160
+ .name('faf')
161
+ .description('.faf = THE JPEG for AI | Foundational AI-context Format | SPEEDY AI you can TRUST! đŸ§ĄâšĄī¸')
162
+ .version(version)
163
+ .option('--no-color', 'Disable colored output for accessibility')
164
+ .option('--color-scheme <scheme>', 'Color scheme for colorblind accessibility: normal|deuteranopia|protanopia|tritanopia', 'normal')
165
+ .option('--auto', 'Auto mode - menu-driven interface for learning and exploration')
166
+ .option('--manual', 'Manual mode - direct command-line interface for power users')
167
+ .addHelpText('after', `
168
+ ${championship_style_1.FAF_COLORS.fafOrange('💡 In Terminal:')} Use ${chalk_1.default.cyan('faf')} prefix - like ${chalk_1.default.cyan('faf init')}, ${chalk_1.default.cyan('faf faq')}
169
+
170
+ ${championship_style_1.FAF_COLORS.fafCyan('🚀 Quick Start - Get Perfect AI Context:')}
171
+
172
+ ${chalk_1.default.bold.green('FASTEST:')} ${chalk_1.default.cyan('faf auto')} ${chalk_1.default.gray('# ONE COMMAND - Zero to Championship!')}
173
+
174
+ ${chalk_1.default.gray('Or step by step:')}
175
+ ${championship_style_1.FAF_COLORS.fafOrange('1.')} ${chalk_1.default.cyan('faf init')} ${chalk_1.default.gray('# Get your .faf file')}
176
+ ${championship_style_1.FAF_COLORS.fafOrange('2.')} ${chalk_1.default.cyan('faf score')} ${chalk_1.default.gray('# Get a high score (70%+)')}
177
+ ${championship_style_1.FAF_COLORS.fafOrange('3.')} ${chalk_1.default.cyan('faf trust')} ${chalk_1.default.gray('# Build AI trust & confidence')}
178
+ ${championship_style_1.FAF_COLORS.fafOrange('4.')} ${chalk_1.default.cyan('faf bi-sync')} ${chalk_1.default.gray('# Set & forget - persistent context-mirroring')}
179
+
180
+ ${championship_style_1.FAF_COLORS.fafCyan('đŸŽ¯ What is .faf?')}
181
+ .faf = Foundational AI-context Format (THE JPEG for AI!)
182
+ Just like JPEG makes images universal, .faf makes projects AI-readable.
183
+ bi-sync = persistent context-mirroring through thick and thin
184
+ Get high score, build trust, share freely!
185
+
186
+ ${championship_style_1.FAF_COLORS.fafOrange('📚 Need more?')} ${chalk_1.default.cyan('faf index')} ${chalk_1.default.gray('# Complete A-Z reference guide')}
187
+ ${championship_style_1.FAF_COLORS.fafOrange('đŸŽ¯ VS Coders?')} ${chalk_1.default.cyan('faf faq')} ${chalk_1.default.gray('# VS Code extension & Command Palette info!')}
188
+ `);
189
+ // đŸ§ĄâšĄī¸ faf flow - The Complete Three-Step Flow (NEW!)
190
+ commander_1.program
191
+ .command('flow [directory]')
192
+ .description('đŸ§ĄâšĄī¸ Get .faffed → Mirror → Commit | Complete 3-step flow to 99%')
193
+ .addHelpText('after', `
194
+ Examples:
195
+ $ faf flow # Complete 3-step flow
196
+ $ faf flow ./my-project # Flow for specific directory
197
+
198
+ đŸ§ĄâšĄī¸ The Three-Step Flow:
199
+ 1. Get .faffed - Create/validate your .faf file (85%)
200
+ 2. Mirror - Context-Mirroring with CLAUDE.md (95%)
201
+ 3. Commit - Lock in excellence at 99%+
202
+
203
+ "The JPEG for AIâ„ĸ" - One command to 99% AI-readiness!`)
204
+ .action(withAnalyticsTracking('flow', flow_1.flow));
205
+ // 🔄 faf mirror - Context-Mirroring (Step 2)
206
+ commander_1.program
207
+ .command('mirror [directory]')
208
+ .description('🔄 Context-Mirroring - Bi-sync .faf â†”ī¸ CLAUDE.md (95% score)')
209
+ .addHelpText('after', `
210
+ Examples:
211
+ $ faf mirror # Mirror context with CLAUDE.md
212
+ $ faf mirror ./my-project # Mirror specific directory
213
+
214
+ Context-Mirroringâ„ĸ:
215
+ â€ĸ Creates CLAUDE.md if missing
216
+ â€ĸ Bi-directional sync established
217
+ â€ĸ Increases score to 95%
218
+ â€ĸ Real-time context alignment`)
219
+ .action(withAnalyticsTracking('mirror', flow_1.mirrorCommand));
220
+ // 🏆 faf commit - Context-Commitment (Step 3)
221
+ commander_1.program
222
+ .command('commit [directory]')
223
+ .description('🏆 Context-Commitmentâ„ĸ - Lock in 99%+ excellence forever')
224
+ .addHelpText('after', `
225
+ Examples:
226
+ $ faf commit # Commit to 99%+ excellence
227
+ $ faf commit ./my-project # Commit specific directory
228
+
229
+ Context-Commitmentâ„ĸ:
230
+ â€ĸ Locks in 99%+ AI-readiness
231
+ â€ĸ Eternal-Syncâ„ĸ activated
232
+ â€ĸ Self-healing enabled
233
+ â€ĸ One-way improvements only
234
+ â€ĸ Degradation prevented
235
+
236
+ Your AI context becomes bulletproof!`)
237
+ .action(withAnalyticsTracking('commit', flow_1.commitCommand));
238
+ // đŸŽī¸ faf auto - The One Command Championship (PRIORITY #1)
239
+ commander_1.program
240
+ .command('auto [directory]')
241
+ .description('đŸŽī¸ ONE COMMAND TO RULE THEM ALL - Zero to Championship instantly!')
242
+ .option('-f, --force', 'Force overwrite existing files')
243
+ .option('-a, --ai', 'Include AI enhancement (requires API key)')
244
+ .option('--no-show', 'Skip showing scorecard at end')
245
+ .addHelpText('after', `
246
+ Examples:
247
+ $ faf auto # Transform current directory to Championship
248
+ $ faf auto ./my-project # Transform specific project
249
+ $ faf auto --ai # Include AI enhancements
250
+ $ faf auto --force # Overwrite everything, fresh start
251
+
252
+ đŸŽī¸ What FAF AUTO Does (in 30 seconds):
253
+ 1. Creates perfect .faf file
254
+ 2. Syncs all dependencies
255
+ 3. Generates CLAUDE.md
256
+ 4. Sets up bi-directional sync
257
+ 5. Shows your Championship scorecard
258
+
259
+ From 0% to 99% in one command. No faffing about!`)
260
+ .action(withAnalyticsTracking('auto', auto_1.autoCommand));
261
+ // Add all the command definitions back
262
+ commander_1.program
263
+ .command('init [directory]')
264
+ .description('Create .faf file from your project (detects React, Python, Node.js, etc.)')
265
+ .option('-f, --force', 'Overwrite existing .faf file')
266
+ .option('-n, --new', 'Create a fresh .faf file (friendlier than --force)')
267
+ .option('-c, --choose', 'Interactive choice when .faf exists')
268
+ .option('-t, --template <type>', 'Use specific template (svelte, react, vue, node)', 'auto')
269
+ .option('-o, --output <file>', 'Output file path')
270
+ .addHelpText('after', `
271
+ Examples:
272
+ $ faf init # Detect project type automatically
273
+ $ faf init --new # Create a fresh .faf file
274
+ $ faf init --choose # Interactive choice when .faf exists
275
+ $ faf init my-app # Create .faf for different directory
276
+ $ faf init -t react # Force React template`)
277
+ .action(withAnalyticsTracking('init', (directory, options) => (0, init_1.initFafFile)(directory, options)));
278
+ // đŸ§Ŧ faf dna - Show your journey at a glance
279
+ commander_1.program
280
+ .command('dna')
281
+ .description('đŸ§Ŧ Show your FAF DNA journey (22% → 85% → 99% ← 92%)')
282
+ .addHelpText('after', `
283
+ Examples:
284
+ $ faf dna # See your journey at a glance
285
+
286
+ đŸ§Ŧ Shows instantly:
287
+ â€ĸ Your complete journey line
288
+ â€ĸ Quick stats and growth
289
+ â€ĸ Achievements unlocked
290
+ â€ĸ Links to detailed info`)
291
+ .action(withAnalyticsTracking('dna', () => {
292
+ const dnaCommand = require('./commands/faf-dna');
293
+ return dnaCommand.default?.();
294
+ }));
295
+ // 🔐 faf auth - Authenticate your FAF DNA
296
+ commander_1.program
297
+ .command('auth')
298
+ .description('🔐 Authenticate your FAF project with a birth certificate')
299
+ .option('--verify <certificate>', 'Verify an existing certificate')
300
+ .option('--show', 'Show current authentication status')
301
+ .addHelpText('after', `
302
+ Examples:
303
+ $ faf auth # Authenticate your project
304
+ $ faf auth --show # Show authentication status
305
+ $ faf auth --verify FAF-2025-PROJECT-XXXX # Verify certificate
306
+
307
+ 🔐 Birth Certificate:
308
+ â€ĸ Proves origin of your context
309
+ â€ĸ Tracks evolution from birth weight
310
+ â€ĸ Enables Context-Mirroring guarantee`)
311
+ .action(withAnalyticsTracking('auth', () => {
312
+ const authCommand = require('./commands/faf-auth');
313
+ return authCommand.default?.();
314
+ }));
315
+ // 📜 faf log - View context evolution history
316
+ commander_1.program
317
+ .command('log')
318
+ .description('📜 View complete evolution history of your FAF context')
319
+ .option('--milestones', 'Show milestones only')
320
+ .option('--analytics', 'Show growth analytics')
321
+ .option('--json', 'Output as JSON')
322
+ .addHelpText('after', `
323
+ Examples:
324
+ $ faf log # Full evolution history
325
+ $ faf log --milestones # Key milestones only
326
+ $ faf log --analytics # Growth analytics
327
+ $ faf log --json # Export as JSON
328
+
329
+ 📜 Shows Your Journey:
330
+ â€ĸ Birth weight (from CLAUDE.md)
331
+ â€ĸ Every version and growth
332
+ â€ĸ Milestones achieved
333
+ â€ĸ Current position vs peak`)
334
+ .action(withAnalyticsTracking('log', () => {
335
+ const logCommand = require('./commands/faf-log');
336
+ return logCommand.default?.();
337
+ }));
338
+ // 💾 faf update - Save your current version
339
+ commander_1.program
340
+ .command('update')
341
+ .description('💾 Save your current FAF version (checkpoint your progress)')
342
+ .addHelpText('after', `
343
+ Examples:
344
+ $ faf update # Save current version
345
+
346
+ 💾 Simple checkpoint:
347
+ â€ĸ Marks current state as good
348
+ â€ĸ Creates reference point
349
+ â€ĸ Track future changes from here`)
350
+ .action(withAnalyticsTracking('update', () => {
351
+ const updateCommand = require('./commands/faf-update');
352
+ return updateCommand.default?.();
353
+ }));
354
+ // 🚨 faf recover - Disaster Recovery
355
+ commander_1.program
356
+ .command('recover')
357
+ .description('🚨 Disaster recovery for corrupted or missing FAF files')
358
+ .option('--auto', 'Attempt automatic recovery')
359
+ .option('--backup', 'List available backups')
360
+ .option('--check', 'Check health without recovery')
361
+ .option('--force', 'Force recovery even if risky')
362
+ .addHelpText('after', `
363
+ Examples:
364
+ $ faf recover # Interactive recovery
365
+ $ faf recover --auto # Try automatic fix
366
+ $ faf recover --backup # List backups
367
+ $ faf recover --check # Health check only
368
+
369
+ 🚨 Emergency Commands:
370
+ â€ĸ faf recover --auto: Try automatic recovery
371
+ â€ĸ git checkout HEAD -- .faf: Restore from git
372
+ â€ĸ faf init --force: Start fresh (loses history)`)
373
+ .action(withAnalyticsTracking('recover', (options) => {
374
+ const { spawn } = require('child_process');
375
+ const recoverPath = require('path').join(__dirname, 'commands', 'faf-recover.ts');
376
+ const args = ['ts-node', recoverPath];
377
+ if (options.auto)
378
+ args.push('--auto');
379
+ if (options.backup)
380
+ args.push('--backup');
381
+ if (options.check)
382
+ args.push('--check');
383
+ if (options.force)
384
+ args.push('--force');
385
+ const child = spawn('npx', args, { stdio: 'inherit' });
386
+ child.on('exit', (code) => {
387
+ process.exit(code || 0);
388
+ });
389
+ }));
390
+ // đŸ˜Ŋ faf formats - TURBO-CAT Format Discovery
391
+ commander_1.program
392
+ .command('formats [directory]')
393
+ .description('đŸ˜Ŋ TURBO-CATâ„ĸ discovers all formats in your project (154 validated types!)')
394
+ .option('-e, --export', 'Export as JSON')
395
+ .option('-c, --category', 'Show by category')
396
+ .addHelpText('after', `
397
+ Examples:
398
+ $ faf formats # List all discovered formats
399
+ $ faf formats --category # Show by category
400
+ $ faf formats --export # Export as JSON`)
401
+ .action(withAnalyticsTracking('formats', (directory, options) => (0, formats_1.formatsCommand)(directory, options)));
402
+ // 🏆 faf version - Show version with MK2 status
403
+ commander_1.program
404
+ .command('version')
405
+ .description('🏆 Show FAF version with MK2 Engine and TURBO-CAT status')
406
+ .action(withAnalyticsTracking('version', () => (0, version_1.versionCommand)()));
407
+ // 🧡 faf trust - Consolidated Trust Dashboard (The Emotional Core)
408
+ commander_1.program
409
+ .command('trust')
410
+ .description('🧡 Unified trust dashboard - confidence, garage, panic, guarantee modes')
411
+ .option('-d, --detailed', 'Show detailed trust metrics')
412
+ .option('--confidence', 'Show AI confidence analysis')
413
+ .option('--garage', 'Safe experimentation mode with backup')
414
+ .option('--panic', 'Emergency context repair mode')
415
+ .option('--guarantee', 'Quality assurance mode (85%+ threshold)')
416
+ .addHelpText('after', `
417
+ Examples:
418
+ $ faf trust # Main trust dashboard
419
+ $ faf trust --detailed # Detailed metrics breakdown
420
+ $ faf trust --confidence # AI confidence analysis
421
+ $ faf trust --garage # Safe experiment mode
422
+ $ faf trust --panic # Emergency repair
423
+ $ faf trust --guarantee # Quality guarantee check
424
+
425
+ Trust Modes:
426
+ â€ĸ Confidence: AI confidence levels and boosting tips
427
+ â€ĸ Garage: Safe experimentation with automatic backup
428
+ â€ĸ Panic: Emergency repair and restoration
429
+ â€ĸ Guarantee: Championship quality assurance (85%+ standard)`)
430
+ .action(withAnalyticsTracking('trust', (options) => (0, trust_1.trustCommand)(options)));
431
+ // âšĄī¸ faf vibe - No-Code/Low-Code Builder Edition
432
+ commander_1.program
433
+ .command('vibe')
434
+ .description('âšĄī¸ FAF VIBE - Check $9 tier eligibility for no-code builders')
435
+ .option('-p, --preview', 'Preview TURBO-CAT discovery')
436
+ .addHelpText('after', `
437
+ Examples:
438
+ $ faf vibe # Check platform & pricing
439
+ $ faf vibe --preview # Include TURBO-CAT preview
440
+
441
+ âšĄī¸ FAF VIBE Features:
442
+ â€ĸ Auto-detects no-code platforms (Replit, Lovable, Wix, etc.)
443
+ â€ĸ $9/month FOREVER (limited time offer)
444
+ â€ĸ Same features as $100 Pro Plan
445
+ â€ĸ TURBO-CAT format discovery
446
+ â€ĸ Lightning not rainbows!`)
447
+ .action(withAnalyticsTracking('vibe', (options) => {
448
+ const { vibeCommand } = require('./commands/vibe');
449
+ return vibeCommand(options);
450
+ }));
451
+ // 🚀 faf status - Quick context health check (git status equivalent)
452
+ commander_1.program
453
+ .command('status')
454
+ .description('Show quick .faf context health status (<200ms)')
455
+ .addHelpText('after', `
456
+ Examples:
457
+ $ faf status # Quick health check
458
+
459
+ Shows:
460
+ â€ĸ Context health score (0-100%)
461
+ â€ĸ Files tracked and last sync time
462
+ â€ĸ AI readiness status
463
+ â€ĸ Performance metrics
464
+ â€ĸ Bi-sync (claude.md) status`)
465
+ .action(withAnalyticsTracking('status', () => (0, status_1.statusCommand)()));
466
+ // 💎 faf credit - Technical Credit Dashboard (Revolutionary Psychology)
467
+ commander_1.program
468
+ .command('credit')
469
+ .description('💎 Technical Credit Dashboard - See your accumulated development credits')
470
+ .option('-d, --detailed', 'Show detailed credit breakdown by category')
471
+ .option('-h, --history', 'Show credit earning history')
472
+ .option('-c, --clear', 'Clear credit history (confirmation required)')
473
+ .addHelpText('after', `
474
+ Examples:
475
+ $ faf credit # Show credit dashboard
476
+ $ faf credit --detailed # Detailed breakdown by category
477
+ $ faf credit --history # See credit earning timeline
478
+
479
+ 💎 Technical Credit System:
480
+ â€ĸ Earn credit for every improvement (vs. technical debt)
481
+ â€ĸ Transform developer psychology from anxiety to confidence
482
+ â€ĸ Track AI happiness improvements and context quality
483
+ â€ĸ Build trust through measurable technical achievements
484
+ â€ĸ Championship levels: Beginner → Professional → Championship
485
+
486
+ Expected Impact:
487
+ 😰 "I hope this works" → 😎 "I trust my context"`)
488
+ .action((options) => (0, credit_1.creditCommand)(options));
489
+ // 📝 faf todo - Claude-Inspired Todo System (The Gamifier)
490
+ commander_1.program
491
+ .command('todo')
492
+ .description('📝 Claude-inspired todo system - gamify your context improvements')
493
+ .option('-s, --show', 'Show current todo list')
494
+ .option('-c, --complete <task>', 'Mark task as completed (by number or keyword)')
495
+ .option('-r, --reset', 'Reset current todo list')
496
+ .addHelpText('after', `
497
+ Examples:
498
+ $ faf todo # Generate new improvement plan
499
+ $ faf todo --show # View current todo list
500
+ $ faf todo --complete 1 # Complete task #1
501
+ $ faf todo --complete readme # Complete README task
502
+ $ faf todo --reset # Start fresh
503
+
504
+ Philosophy:
505
+ â€ĸ Transform low scores into exciting improvement games
506
+ â€ĸ Claude-inspired task prioritization and celebrations
507
+ â€ĸ Gamified progress tracking with championship rewards
508
+ â€ĸ Turn "I need better context" → "I'm completing achievements!"
509
+
510
+ Expected Impact:
511
+ 📉 47% score → 📈 85% score through guided achievements`)
512
+ .action((options) => (0, todo_1.todoCommand)(options));
513
+ // 📚 faf index - Universal A-Z Reference (The Everything Catalog)
514
+ commander_1.program
515
+ .command('index [term]')
516
+ .description('📚 Universal A-Z reference - commands, concepts, features, everything!')
517
+ .option('--category <category>', 'Filter by category (core, ai, trust, utilities, etc.)')
518
+ .option('--search <query>', 'Search within index entries')
519
+ .option('--examples', 'Show usage examples for commands')
520
+ .addHelpText('after', `
521
+ Examples:
522
+ $ faf index # Full A-Z catalog
523
+ $ faf index trust # Everything about trust
524
+ $ faf index --category ai # All AI-related entries
525
+ $ faf index --search "context" # Search for "context"
526
+ $ faf index --examples # Show usage examples
527
+
528
+ The Everything Catalog:
529
+ â€ĸ âšĄī¸ Commands: All available commands with usage
530
+ â€ĸ 💡 Concepts: Core FAF concepts (bi-sync, technical-credit, etc.)
531
+ â€ĸ 🧡 Features: Specialized features (garage, panic, guarantee modes)
532
+ â€ĸ 📂 Categories: core, ai, trust, utilities, improvement, psychology
533
+
534
+ Perfect for:
535
+ â€ĸ New users: "What can FAF do?" → faf index
536
+ â€ĸ Power users: "What were trust options?" → faf index trust
537
+ â€ĸ Discovery: "Show me AI features" → faf index --category ai`)
538
+ .action((term, options) => (0, index_1.indexCommand)(term, options));
539
+ // 🚀 faf share - Universal .faf Distribution System
540
+ commander_1.program
541
+ .command('share [file]')
542
+ .description('🚀 Secure .faf sharing with auto-sanitization')
543
+ .option('-p, --private', 'Keep sensitive info (default: sanitize)')
544
+ .option('-f, --format <format>', 'Output format: yaml|json|url', 'yaml')
545
+ .option('-e, --expires <duration>', 'Expiration: 24h|7d|30d', '7d')
546
+ .option('--password <password>', 'Password protect shared .faf')
547
+ .option('-d, --description <text>', 'Share description')
548
+ .option('-a, --anonymous', 'Remove author information')
549
+ .addHelpText('after', `
550
+ Examples:
551
+ $ faf share # Share with auto-sanitization
552
+ $ faf share --private # Share with sensitive info intact
553
+ $ faf share --format json # Share as JSON format
554
+ $ faf share --expires 24h # Expire in 24 hours
555
+ $ faf share --anonymous # Remove author info
556
+ $ faf share --password secret123 # Password protect
557
+
558
+ Security Features:
559
+ â€ĸ 🔒 Auto-sanitization removes sensitive data by default
560
+ â€ĸ 🎭 Anonymous sharing option removes author info
561
+ â€ĸ ⏰ Configurable expiration (24h, 7d, 30d)
562
+ â€ĸ 🔐 Optional password protection
563
+ â€ĸ 📝 Multiple formats: YAML, JSON, shareable URLs
564
+
565
+ Perfect for:
566
+ â€ĸ Team handoffs: Clean context sharing
567
+ â€ĸ Community help: Sanitized project sharing
568
+ â€ĸ Documentation: Shareable project examples`)
569
+ .action((file, options) => (0, share_1.shareCommand)(file, options));
570
+ // 🏆 GOLDEN RULE: faf convert - YAML to MD/TXT
571
+ commander_1.program
572
+ .command('convert [file]')
573
+ .alias('to-md')
574
+ .description('🔄 Convert .faf YAML to Markdown or Text (Golden Rule: We SPEAK YAML)')
575
+ .option('-f, --format <type>', 'Output format (md|txt)', 'md')
576
+ .option('-o, --output <file>', 'Output file path')
577
+ .option('-s, --save', 'Save to file (.faf.md or .faf.txt)')
578
+ .addHelpText('after', `
579
+ Examples:
580
+ $ faf convert # Convert .faf to Markdown (console output)
581
+ $ faf convert --save # Save as .faf.md
582
+ $ faf to-md # Quick alias for Markdown
583
+ $ faf convert -f txt # Convert to plain text
584
+ $ faf convert -f txt -s # Save as .faf.txt
585
+
586
+ 🏆 GOLDEN RULE: .faf = YAML ONLY
587
+ â€ĸ One source of truth: Pure YAML
588
+ â€ĸ Convert when needed: MD for docs, TXT for sharing
589
+ â€ĸ No parse errors ever again!`)
590
+ .action(withAnalyticsTracking('convert', async (file, options) => {
591
+ await (0, convert_1.convertCommand)(file, options);
592
+ }));
593
+ commander_1.program
594
+ .command('to-txt [file]')
595
+ .description('📝 Quick convert .faf YAML to plain text')
596
+ .action(withAnalyticsTracking('to-txt', async (file) => {
597
+ await (0, convert_1.toText)(file);
598
+ }));
599
+ // đŸ—Ŗī¸ faf chat - Natural Language .faf Generation
600
+ commander_1.program
601
+ .command('chat')
602
+ .description('đŸ—Ŗī¸ Natural language .faf generation - conversation-driven context building')
603
+ .addHelpText('after', `
604
+ Examples:
605
+ $ faf chat # Start conversational .faf creation
606
+
607
+ đŸ—Ŗī¸ Simple Natural Language Interface:
608
+ â€ĸ Answer simple questions about your project
609
+ â€ĸ Choose from numbered options (KISS method)
610
+ â€ĸ Get perfect .faf file without technical flags
611
+ â€ĸ Same championship output, accessible input
612
+
613
+ Perfect for:
614
+ â€ĸ Non-technical team members
615
+ â€ĸ Quick project setup
616
+ â€ĸ Learning FAF concepts through conversation`)
617
+ .action(withAnalyticsTracking('chat', () => (0, chat_1.chatCommand)()));
618
+ // 🤖 faf verify - AI Verification System (The Trust Builder)
619
+ commander_1.program
620
+ .command('verify')
621
+ .description('🤖 Test .faf context with Claude, ChatGPT & Gemini - prove AI understanding')
622
+ .option('-d, --detailed', 'Show detailed verification results')
623
+ .option('-m, --models <models>', 'Specify models to test (comma-separated)', 'claude,chatgpt,gemini')
624
+ .option('-t, --timeout <ms>', 'Verification timeout in milliseconds', '30000')
625
+ .addHelpText('after', `
626
+ Examples:
627
+ $ faf verify # Test with all AI models
628
+ $ faf verify --detailed # Show detailed results & suggestions
629
+ $ faf verify -m claude,chatgpt # Test with specific models only
630
+
631
+ AI Verification Tests:
632
+ â€ĸ Claude: Context understanding & confidence
633
+ â€ĸ ChatGPT: Project comprehension & clarity
634
+ â€ĸ Gemini: Technical stack recognition
635
+ â€ĸ Trust Score: Updated based on AI feedback
636
+
637
+ Expected Transformation:
638
+ 🔴 Needs improvement → â˜‘ī¸ Perfect context`)
639
+ .action((options) => {
640
+ const models = options.models ? options.models.split(',').map((m) => m.trim()) : undefined;
641
+ (0, verify_1.verifyCommand)({
642
+ models,
643
+ timeout: parseInt(options.timeout),
644
+ detailed: options.detailed
645
+ });
646
+ });
647
+ // 📊 faf stacks - STACKTISTICS: Stack Discovery & Collection
648
+ commander_1.program
649
+ .command('stacks')
650
+ .description('📊 Discover and collect technology stack signatures')
651
+ .option('-s, --scan', 'Scan current project for stack signature')
652
+ .option('-e, --export-gallery', 'Export stacks for Gallery-Svelte')
653
+ .addHelpText('after', `
654
+ 📊 STACKTISTICS Examples:
655
+ $ faf stacks # List your discovered stacks
656
+ $ faf stacks --scan # Discover current project stack
657
+ $ faf stacks --export-gallery # Export for Gallery-Svelte
658
+
659
+ Stack Discovery:
660
+ â€ĸ Extends fab-formats intelligence - zero performance impact
661
+ â€ĸ Simple YAML lookup of known stack patterns
662
+ â€ĸ Builds collection of your technology experiences`)
663
+ .action(async (options) => {
664
+ if (options.scan) {
665
+ await (0, stacks_1.scanCurrentProject)();
666
+ }
667
+ else if (options['export-gallery']) {
668
+ await (0, stacks_1.exportForGallery)();
669
+ }
670
+ else {
671
+ await (0, stacks_1.listStacks)();
672
+ }
673
+ });
674
+ // 🔍 faf check - Comprehensive validation & audit (merged validate + audit)
675
+ commander_1.program
676
+ .command('check')
677
+ .description('🔍 Comprehensive .faf validation and freshness check')
678
+ .option('--format', 'Check format/validity only (old validate)')
679
+ .option('--fresh', 'Check freshness/completeness only (old audit)')
680
+ .option('--fix', 'Auto-fix issues where possible')
681
+ .option('-d, --detailed', 'Show detailed check results')
682
+ .addHelpText('after', `
683
+ Examples:
684
+ $ faf check # Full check (format + freshness)
685
+ $ faf check --format # Format validation only
686
+ $ faf check --fresh # Freshness audit only
687
+ $ faf check --fix # Auto-fix issues
688
+ $ faf check --detailed # Detailed diagnostics
689
+
690
+ Combines old validate + audit:
691
+ â€ĸ Format validation (schema, YAML syntax, required fields)
692
+ â€ĸ Freshness audit (up-to-date, completeness, staleness)
693
+ â€ĸ Auto-fix capabilities for common issues`)
694
+ .action((options) => (0, check_1.checkCommand)(options));
695
+ // ✅ faf validate - Check if .faf file is valid
696
+ commander_1.program
697
+ .command('validate [file]')
698
+ .description('Validate .faf file structure and content')
699
+ .option('-v, --verbose', 'Show detailed validation output')
700
+ .option('-s, --schema <path>', 'Custom schema file to validate against')
701
+ .addHelpText('after', `
702
+ Examples:
703
+ $ faf validate # Validate current .faf file
704
+ $ faf validate --verbose # Show detailed validation report`)
705
+ .action(withAnalyticsTracking('validate', validate_1.validateFafFile));
706
+ // 🔍 faf audit - Check freshness and quality
707
+ commander_1.program
708
+ .command('audit [file]')
709
+ .description('Check .faf file freshness and identify improvement areas')
710
+ .option('-w, --warn-days <days>', 'Days before warning about staleness', '7')
711
+ .option('-e, --error-days <days>', 'Days before marking as stale', '30')
712
+ .addHelpText('after', `
713
+ Examples:
714
+ $ faf audit # Check freshness and quality
715
+ $ faf audit --warn-days 3 # Warn if older than 3 days`)
716
+ .action(withAnalyticsTracking('audit', audit_1.auditFafFile));
717
+ // 📈 faf score - See how complete your context is
718
+ commander_1.program
719
+ .command('score [file]')
720
+ .description('Rate your .faf completeness (0-100%). Aim for 70%+ for good AI context.')
721
+ .option('-d, --details', 'Show detailed scoring breakdown')
722
+ .option('-m, --minimum <score>', 'Minimum required score (fails if below)')
723
+ .addHelpText('after', `
724
+ Examples:
725
+ $ faf score # Quick score check
726
+ $ faf score --details # See what's missing for higher score
727
+ $ faf score --minimum 80 # Fail if score below 80%`)
728
+ .action(withAnalyticsTracking('score', score_1.scoreFafFile));
729
+ // 📝 faf edit - Edit helper
730
+ commander_1.program
731
+ .command('edit [file]')
732
+ .description('Get guidance on editing your .faf file to improve score')
733
+ .option('-o, --open', 'Open in default editor')
734
+ .addHelpText('after', `
735
+ Examples:
736
+ $ faf edit # Show what to edit
737
+ $ faf edit --open # Open in $EDITOR
738
+
739
+ Helps you understand which fields to fill for a higher score.`)
740
+ .action(withAnalyticsTracking('edit', edit_helper_1.editFafFile));
741
+ // đŸŽī¸ faf show - Championship Score Card Display
742
+ commander_1.program
743
+ .command('show [directory]')
744
+ .description('đŸŽī¸ Display FAF Championship Score Card with clean markdown output')
745
+ .option('-r, --raw', 'Output raw markdown (for piping)')
746
+ .addHelpText('after', `
747
+ Examples:
748
+ $ faf show # Show score card for current directory
749
+ $ faf show ./my-project # Show score card for specific directory
750
+ $ faf show --raw # Output raw markdown for piping
751
+ $ faf show --raw | pbcopy # Copy score card to clipboard
752
+
753
+ đŸĢ🍊 CHOCOLATE ORANGE - NO WRAPPERS!
754
+ Clean markdown output that displays naturally.`)
755
+ .action(withAnalyticsTracking('show', show_1.showFafScoreCard));
756
+ // 🔄 faf sync - Keep .faf up-to-date automatically + Bi-directional sync
757
+ commander_1.program
758
+ .command('sync [file]')
759
+ .description('Update .faf when dependencies change OR sync with claude.md (bi-directional sync)')
760
+ .option('-a, --auto', 'Automatically apply detected changes')
761
+ .option('-d, --dry-run', 'Show changes without applying')
762
+ .option('-b, --bi-sync', '🔗 Bi-directional sync .faf ↔ claude.md')
763
+ .option('-w, --watch', 'Start real-time file watching (with --bi-sync)')
764
+ .addHelpText('after', `
765
+ Examples:
766
+ $ faf sync # Show what needs updating
767
+ $ faf sync --auto # Update automatically
768
+ $ faf sync --dry-run # Preview changes only
769
+
770
+ 🔗 Bi-Sync Examples:
771
+ $ faf sync --bi-sync # Real-time .faf ↔ claude.md sync
772
+ $ faf sync --bi-sync --watch # Continuous real-time monitoring
773
+ $ faf sync --bi-sync --auto # Automatic conflict-free sync
774
+
775
+ Championship Bi-Sync Features:
776
+ â€ĸ ⚡ Sub-40ms sync time (faster than most file operations)
777
+ â€ĸ 🧠 Smart merge algorithms prevent conflicts and data corruption
778
+ â€ĸ 🔄 Self-healing: Auto-recovers from file locks/system issues
779
+ â€ĸ 💎 Credit propagation: Technical credit updates both files
780
+ â€ĸ 🧡 Trust synchronization: AI compatibility scores stay aligned
781
+ â€ĸ đŸ›Ąī¸ Conflict prevention: Detects simultaneous edits safely`)
782
+ .action(async (file, options) => {
783
+ if (options.biSync) {
784
+ // Bi-directional sync mode
785
+ await (0, bi_sync_1.biSyncCommand)({
786
+ auto: options.auto,
787
+ watch: options.watch,
788
+ force: false
789
+ });
790
+ }
791
+ else {
792
+ // Original sync functionality
793
+ await (0, sync_1.syncFafFile)(file, options);
794
+ }
795
+ });
796
+ // 🔗 faf bi-sync - Standalone bi-directional sync command
797
+ commander_1.program
798
+ .command('bi-sync')
799
+ .description('🔗 Bi-directional sync .faf ↔ claude.md')
800
+ .option('-a, --auto', 'Automatic sync without prompts')
801
+ .option('-w, --watch', 'Start real-time file watching')
802
+ .option('-f, --force', 'Force overwrite conflicts')
803
+ .addHelpText('after', `
804
+ Examples:
805
+ $ faf bi-sync # Create claude.md and sync
806
+ $ faf bi-sync --auto # Automatic conflict-free sync
807
+ $ faf bi-sync --watch # Continuous real-time monitoring
808
+
809
+ Championship Bi-Sync Features:
810
+ â€ĸ ⚡ Sub-40ms sync time (faster than most file operations)
811
+ â€ĸ 🧠 Smart merge algorithms prevent conflicts and data corruption
812
+ â€ĸ 🔄 Self-healing: Auto-recovers from file locks/system issues
813
+ â€ĸ 💎 Credit propagation: Technical credit updates both files
814
+ â€ĸ 🧡 Trust synchronization: AI compatibility scores stay aligned
815
+ â€ĸ đŸ›Ąī¸ Conflict prevention: Detects simultaneous edits safely`)
816
+ .action(async (options) => {
817
+ await (0, bi_sync_1.biSyncCommand)({
818
+ auto: options.auto,
819
+ watch: options.watch,
820
+ force: options.force || false
821
+ });
822
+ });
823
+ // 🧹 faf clear - Reset caches and state (Claude Code consistency)
824
+ commander_1.program
825
+ .command('clear')
826
+ .description('🧹 Clear caches, temporary files, and reset state')
827
+ .option('--cache', 'Clear trust cache only')
828
+ .option('--todos', 'Clear todo lists only')
829
+ .option('--backups', 'Clear backup files only')
830
+ .option('--all', 'Clear everything (default)')
831
+ .addHelpText('after', `
832
+ Examples:
833
+ $ faf clear # Clear all caches and temp files
834
+ $ faf clear --cache # Clear trust cache only
835
+ $ faf clear --todos # Clear todo lists only
836
+ $ faf clear --backups # Clear backup files only
837
+
838
+ Claude Code Consistency:
839
+ â€ĸ Similar to /clear command in Claude Code
840
+ â€ĸ Fresh start for .faf system
841
+ â€ĸ Removes temporary files and cached data`)
842
+ .action((options) => (0, clear_1.clearCommand)(options));
843
+ // âœī¸ faf edit - Interactive .faf editor (Claude Code consistency)
844
+ commander_1.program
845
+ .command('edit')
846
+ .description('âœī¸ Interactive .faf editor with validation')
847
+ .option('--editor <editor>', 'Specific editor to use (code, vim, nano)')
848
+ .option('--section <section>', 'Edit specific section (project, stack, etc.)')
849
+ .option('--no-validate', 'Skip validation after editing')
850
+ .addHelpText('after', `
851
+ Examples:
852
+ $ faf edit # Open .faf in default editor
853
+ $ faf edit --editor vim # Use specific editor
854
+ $ faf edit --section project # Edit project section only
855
+ $ faf edit --no-validate # Skip post-edit validation
856
+
857
+ Claude Code Consistency:
858
+ â€ĸ Similar to /edit command in Claude Code
859
+ â€ĸ Automatic backup before editing
860
+ â€ĸ Post-edit validation with restore on errors`)
861
+ .action((options) => (0, edit_1.editCommand)(options));
862
+ // 🔍 faf search - Search .faf content (Claude Code consistency)
863
+ commander_1.program
864
+ .command('search <query>')
865
+ .description('🔍 Search within .faf file content with highlighting')
866
+ .option('--section <section>', 'Search in specific section only')
867
+ .option('--case', 'Case sensitive search')
868
+ .option('--keys', 'Search keys only')
869
+ .option('--values', 'Search values only')
870
+ .option('--count', 'Show match count only')
871
+ .addHelpText('after', `
872
+ Examples:
873
+ $ faf search "react" # Search for "react" anywhere
874
+ $ faf search "api" --section project # Search in project section only
875
+ $ faf search "test" --keys # Search in keys only
876
+ $ faf search "node" --case # Case sensitive search
877
+ $ faf search "component" --count # Just show match count
878
+
879
+ Claude Code Consistency:
880
+ â€ĸ Similar to /search command in Claude Code
881
+ â€ĸ Intelligent highlighting of matches
882
+ â€ĸ Section-aware searching with path display`)
883
+ .action(withAnalyticsTracking('search', (query, options) => (0, search_1.searchCommand)(query, options)));
884
+ // 📊 faf analytics - Analytics & Telemetry Management
885
+ commander_1.program
886
+ .command('analytics')
887
+ .description('📊 View usage analytics and manage telemetry settings')
888
+ .option('-s, --summary', 'Show analytics summary')
889
+ .option('-d, --disable', 'Disable telemetry collection')
890
+ .option('-e, --enable', 'Enable telemetry collection')
891
+ .option('--reset', 'Reset all analytics data')
892
+ .addHelpText('after', `
893
+ Examples:
894
+ $ faf analytics --summary # View usage statistics
895
+ $ faf analytics --disable # Turn off telemetry
896
+ $ faf analytics --enable # Turn on telemetry
897
+ $ faf analytics --reset # Clear analytics data
898
+
899
+ Championship Analytics:
900
+ â€ĸ 📊 Performance metrics (F1-inspired speed tracking)
901
+ â€ĸ 📊 Command usage patterns and favorites
902
+ â€ĸ 📈 Trust score improvements over time
903
+ â€ĸ 🔒 Privacy-first: All data anonymized and local
904
+ â€ĸ 🚀 Help make FAF better for everyone!
905
+
906
+ Privacy Controls:
907
+ â€ĸ Telemetry can be disabled anytime
908
+ â€ĸ No sensitive data collected (keys, tokens filtered)
909
+ â€ĸ All metrics stored locally first
910
+ â€ĸ Opt-in for improvement insights`)
911
+ .action(withAnalyticsTracking('analytics', async (options) => {
912
+ if (options.summary) {
913
+ await analytics_1.analytics.showAnalyticsSummary();
914
+ }
915
+ else if (options.disable) {
916
+ await analytics_1.analytics.disableTelemetry();
917
+ }
918
+ else if (options.enable) {
919
+ await analytics_1.analytics.enableTelemetry();
920
+ }
921
+ else if (options.reset) {
922
+ // Reset analytics would be implemented
923
+ console.log('🔄 Analytics reset functionality coming soon!');
924
+ }
925
+ else {
926
+ // Default: show summary
927
+ await analytics_1.analytics.showAnalyticsSummary();
928
+ }
929
+ }));
930
+ // đŸŠĩ faf faq - Show FAQ
931
+ commander_1.program
932
+ .command('faq')
933
+ .description('đŸŠĩ Frequently Asked Questions - Get help with common issues')
934
+ .option('-s, --search <term>', 'Search FAQ for specific topic')
935
+ .addHelpText('after', `
936
+ Examples:
937
+ $ faf faq # Show full FAQ
938
+ $ faf faq --search spacebar # Search for spacebar info
939
+ $ faf faq --search commands # Search for command info`)
940
+ .action(withAnalyticsTracking('faq', async (options) => {
941
+ const faqCommand = await Promise.resolve().then(() => __importStar(require('./commands/faq')));
942
+ await faqCommand.faqCommand(options);
943
+ }));
944
+ // 🔧 faf lint - Clean up formatting automatically
945
+ commander_1.program
946
+ .command('lint [file]')
947
+ .description('Fix .faf formatting and style issues')
948
+ .option('-f, --fix', 'Automatically fix formatting issues')
949
+ .option('--schema-version <version>', 'Validate against specific schema version')
950
+ .addHelpText('after', `
951
+ Examples:
952
+ $ faf lint # Check formatting issues
953
+ $ faf lint --fix # Fix formatting automatically
954
+ $ faf lint --schema-version 2.4.0 # Use specific schema`)
955
+ .action(lint_1.lintFafFile);
956
+ // 🚀 faf enhance - Claude-First, Big-3 Compatible Enhancement
957
+ commander_1.program
958
+ .command('enhance [file]')
959
+ .description('🚀 Claude-First AI Enhancement - Big-3 Compatible, Bullet-proof Universal')
960
+ .option('-m, --model <model>', 'AI model: claude|chatgpt|gemini|big3|universal', 'claude')
961
+ .option('-f, --focus <area>', 'Focus: human-context|ai-instructions|completeness|claude-exclusive', 'completeness')
962
+ .option('--consensus', 'Build consensus from multiple models')
963
+ .option('--dry-run', 'Show enhancement prompt without executing')
964
+ .addHelpText('after', `
965
+ 🤖 Claude-First Enhancement:
966
+ $ faf enhance # Claude intelligence (default)
967
+ $ faf enhance --model big3 # Big-3 consensus enhancement
968
+ $ faf enhance --focus claude-exclusive # Claude's F1-inspired specialty
969
+ $ faf enhance --consensus # Multi-model consensus
970
+ $ faf enhance --dry-run # Preview enhancement
971
+
972
+ 🚀 NO EXTERNAL DEPENDENCIES - Uses our own Big-3 verification engine!`)
973
+ .action(ai_enhance_1.enhanceFafWithAI);
974
+ // 🔍 faf analyze - Claude-First, Big-3 Compatible Analysis
975
+ commander_1.program
976
+ .command('analyze [file]')
977
+ .description('🔍 Claude-First AI Analysis - Big-3 Compatible Intelligence')
978
+ .option('-m, --model <model>', 'AI model: claude|chatgpt|gemini|big3|universal', 'claude')
979
+ .option('-f, --focus <area>', 'Focus: completeness|quality|ai-readiness|human-context|claude-exclusive')
980
+ .option('-v, --verbose', 'Show detailed section breakdown')
981
+ .option('-s, --suggestions', 'Include automated suggestions')
982
+ .option('-c, --comparative', 'Compare perspectives from multiple models')
983
+ .addHelpText('after', `
984
+ 🤖 Claude-First Analysis:
985
+ $ faf analyze # Claude intelligence (default)
986
+ $ faf analyze --model big3 # Big-3 perspective analysis
987
+ $ faf analyze --focus claude-exclusive # Claude's championship analysis
988
+ $ faf analyze --comparative # Multi-model comparison
989
+ $ faf analyze --verbose --suggestions # Detailed analysis + tips
990
+
991
+ 🚀 NO EXTERNAL DEPENDENCIES - Uses our own Big-3 verification engine!`)
992
+ .action(ai_analyze_1.analyzeFafWithAI);
993
+ // Handle unknown commands with helpful suggestions
994
+ commander_1.program
995
+ .command('*', { noHelp: true })
996
+ .action((cmd) => {
997
+ console.log(chalk_1.default.red(`❌ Unknown command: ${cmd}`));
998
+ console.log('');
999
+ console.log(championship_style_1.FAF_COLORS.fafOrange('💡 Did you mean:'));
1000
+ console.log(' ' + chalk_1.default.cyan('faf init') + ' # Create .faf file');
1001
+ console.log(' ' + chalk_1.default.cyan('faf score') + ' # Check completeness');
1002
+ console.log(' ' + chalk_1.default.cyan('faf --help') + ' # See all commands');
1003
+ process.exit(1);
1004
+ });
1005
+ /**
1006
+ * Interactive welcome screen with persistent bottom command line
1007
+ */
1008
+ async function showInteractiveWelcome() {
1009
+ // Clear screen and set up persistent layout
1010
+ console.clear();
1011
+ // ASCII Header
1012
+ console.log((0, championship_style_1.generateFAFHeader)());
1013
+ console.log('');
1014
+ console.log(chalk_1.default.dim('Using faf menu'));
1015
+ console.log('');
1016
+ // Hello User
1017
+ const username = require('os').userInfo().username;
1018
+ console.log(chalk_1.default.cyan.bold(` 👋 Hello ${username}!`));
1019
+ console.log('');
1020
+ // Ready message
1021
+ console.log(chalk_1.default.white(' Ready to make your AI happy again?'));
1022
+ console.log('');
1023
+ // Footer - show BEFORE menu
1024
+ await showScoreFooter();
1025
+ console.log('');
1026
+ try {
1027
+ const answer = await inquirer_1.default.prompt([
1028
+ {
1029
+ type: 'list',
1030
+ name: 'action',
1031
+ message: 'Select an option',
1032
+ choices: [
1033
+ { name: '1. Create your first .faf file', value: 'init' },
1034
+ { name: '2. Interactive context builder', value: 'chat' },
1035
+ { name: '3. See all commands', value: 'help' },
1036
+ { name: '4. FAQ - Get help & answers', value: 'faq' },
1037
+ { name: '5. Browse everything A-Z', value: 'index' },
1038
+ { name: '6. Switch to command line', value: 'commandline' },
1039
+ new inquirer_1.default.Separator('')
1040
+ ]
1041
+ }
1042
+ ]);
1043
+ // If user selected command line mode, switch to persistent typing
1044
+ if (answer.action === 'commandline') {
1045
+ console.clear();
1046
+ console.log((0, championship_style_1.generateFAFHeader)());
1047
+ console.log('');
1048
+ console.log(chalk_1.default.dim('Using faf CLI'));
1049
+ console.log('');
1050
+ console.log(chalk_1.default.cyan.bold('âŒ¨ī¸ Command Line Mode'));
1051
+ console.log(chalk_1.default.gray('Type commands, "menu" for menu, or "index" for the .faf A-Z'));
1052
+ console.log('');
1053
+ // Persistent command line loop with spacebar detection
1054
+ let inCommandMode = true;
1055
+ while (inCommandMode) {
1056
+ const cmdAnswer = await new Promise((resolve) => {
1057
+ let inputBuffer = '';
1058
+ // Show prompt
1059
+ process.stdout.write('> ');
1060
+ // Set up raw keyboard input for spacebar detection
1061
+ if (process.stdin.isTTY) {
1062
+ process.stdin.setRawMode(true);
1063
+ process.stdin.resume();
1064
+ process.stdin.setEncoding('utf8');
1065
+ const keyHandler = (key) => {
1066
+ // Spacebar pressed - toggle to menu
1067
+ if (key === ' ' && inputBuffer === '') {
1068
+ process.stdin.setRawMode(false);
1069
+ process.stdin.removeListener('data', keyHandler);
1070
+ console.log('\n' + chalk_1.default.dim('đŸŽ¯ Switching to menu...'));
1071
+ resolve({ command: 'menu' });
1072
+ return;
1073
+ }
1074
+ // Escape pressed - exit
1075
+ if (key === '\u001b') {
1076
+ process.stdin.setRawMode(false);
1077
+ process.stdin.removeListener('data', keyHandler);
1078
+ console.log('\n👋 Goodbye!');
1079
+ process.exit(0);
1080
+ }
1081
+ // Enter pressed - execute command
1082
+ if (key === '\r' || key === '\n') {
1083
+ process.stdin.setRawMode(false);
1084
+ process.stdin.removeListener('data', keyHandler);
1085
+ console.log('');
1086
+ resolve({ command: inputBuffer });
1087
+ return;
1088
+ }
1089
+ // Backspace
1090
+ if (key === '\u007f') {
1091
+ if (inputBuffer.length > 0) {
1092
+ inputBuffer = inputBuffer.slice(0, -1);
1093
+ process.stdout.write('\b \b');
1094
+ }
1095
+ return;
1096
+ }
1097
+ // Regular character
1098
+ if (key >= ' ' && key <= '~') {
1099
+ inputBuffer += key;
1100
+ process.stdout.write(key);
1101
+ }
1102
+ };
1103
+ process.stdin.on('data', keyHandler);
1104
+ }
1105
+ else {
1106
+ // Fallback for non-TTY - use regular inquirer
1107
+ inquirer_1.default.prompt([{
1108
+ type: 'input',
1109
+ name: 'command',
1110
+ message: '>'
1111
+ }]).then(resolve);
1112
+ }
1113
+ });
1114
+ const command = cmdAnswer.command.trim().toLowerCase();
1115
+ // Handle mode switching commands
1116
+ if (command === 'exit' || command === 'quit') {
1117
+ console.log('👋 Goodbye!');
1118
+ process.exit(0);
1119
+ }
1120
+ if (command === 'menu') {
1121
+ inCommandMode = false;
1122
+ console.log(chalk_1.default.dim('â†Šī¸ Returning to menu...'));
1123
+ console.log('');
1124
+ // Recursively call showInteractiveWelcome to return to menu
1125
+ await showInteractiveWelcome();
1126
+ return;
1127
+ }
1128
+ // Execute typed command
1129
+ switch (command) {
1130
+ case 'init':
1131
+ await (0, init_1.initFafFile)();
1132
+ break;
1133
+ case 'chat':
1134
+ await (0, chat_1.chatCommand)();
1135
+ break;
1136
+ case 'help':
1137
+ commander_1.program.help();
1138
+ break;
1139
+ case 'index':
1140
+ await (0, index_1.indexCommand)();
1141
+ break;
1142
+ case 'status':
1143
+ await (0, status_1.statusCommand)();
1144
+ break;
1145
+ case 'faq':
1146
+ const faqCommand = await Promise.resolve().then(() => __importStar(require('./commands/faq')));
1147
+ await faqCommand.faqCommand();
1148
+ break;
1149
+ case '':
1150
+ // Empty command, just continue
1151
+ break;
1152
+ default:
1153
+ // Check if user tried a slash command
1154
+ if (command.startsWith('/')) {
1155
+ const commandWithoutSlash = command.slice(1);
1156
+ console.log(chalk_1.default.red(`❌ Unknown command: ${command}`));
1157
+ console.log(championship_style_1.FAF_COLORS.fafCyan('🎉 Good news! You don\'t need a slash in FAF CLI mode'));
1158
+ console.log(championship_style_1.FAF_COLORS.fafOrange(`💡 Try: ${commandWithoutSlash} (without the /)`));
1159
+ }
1160
+ else {
1161
+ console.log(chalk_1.default.red(`❌ Unknown command: ${command}`));
1162
+ console.log(championship_style_1.FAF_COLORS.fafOrange('💡 Try: init, chat, help, index, status, score, exit'));
1163
+ }
1164
+ break;
1165
+ }
1166
+ // Show footer after each command (unless it was help which shows its own footer)
1167
+ if (command !== 'help' && command !== '') {
1168
+ await showScoreFooter('faf');
1169
+ }
1170
+ console.log('');
1171
+ }
1172
+ }
1173
+ else {
1174
+ // Execute selected menu item
1175
+ const action = answer.action;
1176
+ switch (action) {
1177
+ case 'init':
1178
+ await (0, init_1.initFafFile)();
1179
+ break;
1180
+ case 'chat':
1181
+ await (0, chat_1.chatCommand)();
1182
+ break;
1183
+ case 'help':
1184
+ commander_1.program.help();
1185
+ break;
1186
+ case 'faq':
1187
+ const faqMenuCommand = await Promise.resolve().then(() => __importStar(require('./commands/faq')));
1188
+ await faqMenuCommand.faqCommand();
1189
+ break;
1190
+ case 'index':
1191
+ await (0, index_1.indexCommand)();
1192
+ break;
1193
+ }
1194
+ }
1195
+ }
1196
+ catch (error) {
1197
+ if (error instanceof Error && error.message.includes('User force closed')) {
1198
+ console.log(`\n${chalk_1.default.cyan('👋 See you later!')}\n`);
1199
+ }
1200
+ else {
1201
+ console.error(`\n${chalk_1.default.red('❌ Error:')} ${error}\n`);
1202
+ }
1203
+ }
1204
+ }
1205
+ // Show header based on command used BEFORE parsing
1206
+ const commandUsed = process.argv[2];
1207
+ // Special case: No arguments at all - show interactive welcome
1208
+ if (!commandUsed) {
1209
+ showInteractiveWelcome().then(() => process.exit(0)).catch(err => {
1210
+ console.error(err);
1211
+ process.exit(1);
1212
+ });
1213
+ }
1214
+ else {
1215
+ // Parse CLI arguments to check for gearbox flags
1216
+ commander_1.program.parse(process.argv);
1217
+ const options = commander_1.program.opts();
1218
+ // Gearbox system: Auto/Manual mode detection
1219
+ const isAutoMode = options.auto;
1220
+ const isManualMode = options.manual;
1221
+ // Auto mode - show interactive welcome
1222
+ if (isAutoMode) {
1223
+ showInteractiveWelcome().then(() => process.exit(0)).catch(err => {
1224
+ console.error(err);
1225
+ process.exit(1);
1226
+ });
1227
+ }
1228
+ else {
1229
+ const isHelp = commandUsed === '--help' || commandUsed === '-h' || commandUsed === 'help';
1230
+ showHeaderIfAppropriate(isHelp ? 'help' : commandUsed);
1231
+ // Apply color accessibility settings after parsing
1232
+ if (options.noColor || process.env.NO_COLOR) {
1233
+ (0, color_utils_1.setColorOptions)(false);
1234
+ }
1235
+ else if (options.colorScheme) {
1236
+ const scheme = options.colorScheme;
1237
+ const validSchemes = ['normal', 'deuteranopia', 'protanopia', 'tritanopia'];
1238
+ if (validSchemes.includes(scheme)) {
1239
+ (0, color_utils_1.setColorOptions)(true, scheme);
1240
+ }
1241
+ else {
1242
+ console.log(chalk_1.default.red(`❌ Invalid color scheme: ${scheme}`));
1243
+ console.log(championship_style_1.FAF_COLORS.fafOrange(`💡 Valid schemes: ${validSchemes.join(', ')}`));
1244
+ process.exit(1);
1245
+ }
1246
+ }
1247
+ }
1248
+ }
1249
+ //# sourceMappingURL=cli.js.map