@mks2508/better-logger 0.0.2-alpha.2 → 0.3.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 (326) hide show
  1. package/.claude/settings.local.json +18 -2
  2. package/.github/workflows/ci-quality.yml +357 -0
  3. package/.github/workflows/docs-demo.yml +119 -0
  4. package/.github/workflows/releases-core.yml +512 -0
  5. package/.github/workflows/releases-full.yml +582 -0
  6. package/.github/{workflows → workflows-backup}/ci.yml +12 -110
  7. package/.github/workflows-backup/nightly.yml +196 -0
  8. package/.github/workflows-backup/release-optimized.yml +373 -0
  9. package/.release-notes-0.2.0.md +129 -0
  10. package/.yamllint +28 -0
  11. package/CHANGELOG.json +783 -0
  12. package/CLAUDE.md +92 -1
  13. package/README.md +198 -490
  14. package/bun.lock +323 -0
  15. package/demo.html +9 -2
  16. package/dist/.tsbuildinfo +1 -0
  17. package/dist/Logger.d.ts +272 -0
  18. package/dist/Logger.d.ts.map +1 -0
  19. package/dist/Logger.js +680 -0
  20. package/dist/ScopedLogger.d.ts +126 -0
  21. package/dist/ScopedLogger.d.ts.map +1 -0
  22. package/dist/ScopedLogger.js +234 -0
  23. package/dist/chunks/Logger-BpeuYIxR.js +2 -0
  24. package/dist/chunks/Logger-BpeuYIxR.js.map +1 -0
  25. package/dist/chunks/Logger-Didxtr23.js +3275 -0
  26. package/dist/chunks/Logger-Didxtr23.js.map +1 -0
  27. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
  28. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
  29. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
  30. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
  31. package/dist/chunks/environment-Bxbnw4pd.js +544 -0
  32. package/dist/chunks/environment-Bxbnw4pd.js.map +1 -0
  33. package/dist/chunks/environment-Dm66zOML.js +4 -0
  34. package/dist/chunks/environment-Dm66zOML.js.map +1 -0
  35. package/dist/chunks/formatting-C0riPC5_.js +95 -0
  36. package/dist/chunks/formatting-C0riPC5_.js.map +1 -0
  37. package/dist/chunks/formatting-DNCAV66-.js +2 -0
  38. package/dist/chunks/formatting-DNCAV66-.js.map +1 -0
  39. package/dist/cli/CommandProcessor.d.ts +103 -0
  40. package/dist/cli/CommandProcessor.d.ts.map +1 -0
  41. package/dist/cli/CommandProcessor.js +184 -0
  42. package/dist/cli/commands/ConfigCommand.d.ts +17 -0
  43. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
  44. package/dist/cli/commands/ConfigCommand.js +88 -0
  45. package/dist/cli/commands/ExportCommand.d.ts +51 -0
  46. package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
  47. package/dist/cli/commands/ExportCommand.js +243 -0
  48. package/dist/cli/commands/HistoryCommand.d.ts +50 -0
  49. package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
  50. package/dist/cli/commands/HistoryCommand.js +96 -0
  51. package/dist/cli/commands/StatusCommand.d.ts +33 -0
  52. package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
  53. package/dist/cli/commands/StatusCommand.js +93 -0
  54. package/dist/cli/commands/ThemeCommand.d.ts +33 -0
  55. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
  56. package/dist/cli/commands/ThemeCommand.js +79 -0
  57. package/dist/cli/help.d.ts +15 -0
  58. package/dist/cli/help.d.ts.map +1 -0
  59. package/dist/cli/help.js +118 -0
  60. package/dist/cli/index.d.ts +15 -0
  61. package/dist/cli/index.d.ts.map +1 -0
  62. package/dist/cli/index.js +46 -0
  63. package/dist/constants.d.ts +122 -0
  64. package/dist/constants.d.ts.map +1 -0
  65. package/dist/constants.js +159 -0
  66. package/dist/core.cjs +1 -1
  67. package/dist/core.cjs.map +1 -1
  68. package/dist/core.d.ts +134 -0
  69. package/dist/core.d.ts.map +1 -0
  70. package/dist/core.js +315 -242
  71. package/dist/core.js.map +1 -1
  72. package/dist/example.d.ts +18 -0
  73. package/dist/example.d.ts.map +1 -0
  74. package/dist/example.js +154 -0
  75. package/dist/exports-module.d.ts +203 -0
  76. package/dist/exports-module.d.ts.map +1 -0
  77. package/dist/exports-module.js +260 -0
  78. package/dist/exports.cjs +1 -1
  79. package/dist/exports.cjs.map +1 -1
  80. package/dist/exports.js +5 -4
  81. package/dist/exports.js.map +1 -1
  82. package/dist/handlers/AnalyticsLogHandler.d.ts +11 -0
  83. package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  84. package/dist/handlers/AnalyticsLogHandler.js +19 -0
  85. package/dist/handlers/ExportLogHandler.d.ts +103 -0
  86. package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
  87. package/dist/handlers/ExportLogHandler.js +516 -0
  88. package/dist/handlers/FileLogHandler.d.ts +36 -0
  89. package/dist/handlers/FileLogHandler.d.ts.map +1 -0
  90. package/dist/handlers/FileLogHandler.js +156 -0
  91. package/dist/handlers/RemoteLogHandler.d.ts +14 -0
  92. package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
  93. package/dist/handlers/RemoteLogHandler.js +37 -0
  94. package/dist/handlers/index.d.ts +8 -0
  95. package/dist/handlers/index.d.ts.map +1 -0
  96. package/dist/handlers/index.js +7 -0
  97. package/dist/index.cjs +1 -1
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.ts +86 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +89 -103
  102. package/dist/index.js.map +1 -1
  103. package/dist/main.d.ts +2 -0
  104. package/dist/main.d.ts.map +1 -0
  105. package/dist/main.js +139 -0
  106. package/dist/styling/LogStyleBuilder.d.ts +149 -0
  107. package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
  108. package/dist/styling/LogStyleBuilder.js +289 -0
  109. package/dist/styling/SemanticStyles.d.ts +181 -0
  110. package/dist/styling/SemanticStyles.d.ts.map +1 -0
  111. package/dist/styling/SemanticStyles.js +339 -0
  112. package/dist/styling/SmartPresets.d.ts +25 -0
  113. package/dist/styling/SmartPresets.d.ts.map +1 -0
  114. package/dist/styling/SmartPresets.js +276 -0
  115. package/dist/styling/StyleBuilder.d.ts +140 -0
  116. package/dist/styling/StyleBuilder.d.ts.map +1 -0
  117. package/dist/styling/StyleBuilder.js +280 -0
  118. package/dist/styling/banners.d.ts +45 -0
  119. package/dist/styling/banners.d.ts.map +1 -0
  120. package/dist/styling/banners.js +155 -0
  121. package/dist/styling/index.d.ts +10 -0
  122. package/dist/styling/index.d.ts.map +1 -0
  123. package/dist/styling/index.js +9 -0
  124. package/dist/styling/themes.d.ts +10 -0
  125. package/dist/styling/themes.d.ts.map +1 -0
  126. package/dist/styling/themes.js +231 -0
  127. package/dist/styling-module.d.ts +185 -0
  128. package/dist/styling-module.d.ts.map +1 -0
  129. package/dist/styling-module.js +199 -0
  130. package/dist/styling.cjs +1 -1
  131. package/dist/styling.cjs.map +1 -1
  132. package/dist/styling.js +6 -6
  133. package/dist/styling.js.map +1 -1
  134. package/dist/types/Logger.d.ts +268 -0
  135. package/dist/types/Logger.d.ts.map +1 -0
  136. package/dist/types/ScopedLogger.d.ts +123 -0
  137. package/dist/types/ScopedLogger.d.ts.map +1 -0
  138. package/dist/types/cli/CommandProcessor.d.ts +100 -0
  139. package/dist/types/cli/CommandProcessor.d.ts.map +1 -0
  140. package/dist/types/cli/commands/ConfigCommand.d.ts +14 -0
  141. package/dist/types/cli/commands/ConfigCommand.d.ts.map +1 -0
  142. package/dist/types/cli/commands/ExportCommand.d.ts +48 -0
  143. package/dist/types/cli/commands/ExportCommand.d.ts.map +1 -0
  144. package/dist/types/cli/commands/HistoryCommand.d.ts +47 -0
  145. package/dist/types/cli/commands/HistoryCommand.d.ts.map +1 -0
  146. package/dist/types/cli/commands/StatusCommand.d.ts +30 -0
  147. package/dist/types/cli/commands/StatusCommand.d.ts.map +1 -0
  148. package/dist/types/cli/commands/ThemeCommand.d.ts +30 -0
  149. package/dist/types/cli/commands/ThemeCommand.d.ts.map +1 -0
  150. package/dist/types/cli/help.d.ts +12 -0
  151. package/dist/types/cli/help.d.ts.map +1 -0
  152. package/dist/types/cli/index.d.ts +15 -0
  153. package/dist/types/cli/index.d.ts.map +1 -0
  154. package/dist/types/constants.d.ts +119 -0
  155. package/dist/types/constants.d.ts.map +1 -0
  156. package/dist/types/core.d.ts +125 -211
  157. package/dist/types/core.d.ts.map +1 -0
  158. package/dist/types/core.js +13 -0
  159. package/dist/types/example.d.ts +18 -0
  160. package/dist/types/example.d.ts.map +1 -0
  161. package/dist/types/exports-module.d.ts +196 -0
  162. package/dist/types/exports-module.d.ts.map +1 -0
  163. package/dist/types/handlers/AnalyticsLogHandler.d.ts +8 -0
  164. package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  165. package/dist/types/handlers/ExportLogHandler.d.ts +100 -0
  166. package/dist/types/handlers/ExportLogHandler.d.ts.map +1 -0
  167. package/dist/types/handlers/FileLogHandler.d.ts +33 -0
  168. package/dist/types/handlers/FileLogHandler.d.ts.map +1 -0
  169. package/dist/types/handlers/RemoteLogHandler.d.ts +11 -0
  170. package/dist/types/handlers/RemoteLogHandler.d.ts.map +1 -0
  171. package/dist/types/handlers/index.d.ts +8 -0
  172. package/dist/types/handlers/index.d.ts.map +1 -0
  173. package/dist/types/handlers.d.ts +88 -0
  174. package/dist/types/handlers.d.ts.map +1 -0
  175. package/dist/types/handlers.js +4 -0
  176. package/dist/types/index.d.ts +7 -675
  177. package/dist/types/index.d.ts.map +1 -0
  178. package/dist/types/index.js +4 -0
  179. package/dist/types/main.d.ts +2 -0
  180. package/dist/types/main.d.ts.map +1 -0
  181. package/dist/types/styling/LogStyleBuilder.d.ts +146 -0
  182. package/dist/types/styling/LogStyleBuilder.d.ts.map +1 -0
  183. package/dist/types/styling/SemanticStyles.d.ts +178 -0
  184. package/dist/types/styling/SemanticStyles.d.ts.map +1 -0
  185. package/dist/types/styling/SmartPresets.d.ts +22 -0
  186. package/dist/types/styling/SmartPresets.d.ts.map +1 -0
  187. package/dist/types/styling/StyleBuilder.d.ts +140 -0
  188. package/dist/types/styling/StyleBuilder.d.ts.map +1 -0
  189. package/dist/types/styling/banners.d.ts +42 -0
  190. package/dist/types/styling/banners.d.ts.map +1 -0
  191. package/dist/types/styling/index.d.ts +10 -0
  192. package/dist/types/styling/index.d.ts.map +1 -0
  193. package/dist/types/styling/themes.d.ts +7 -0
  194. package/dist/types/styling/themes.d.ts.map +1 -0
  195. package/dist/types/styling-module.d.ts +178 -0
  196. package/dist/types/styling-module.d.ts.map +1 -0
  197. package/dist/types/types/core.d.ts +125 -0
  198. package/dist/types/types/core.d.ts.map +1 -0
  199. package/dist/types/types/handlers.d.ts +85 -0
  200. package/dist/types/types/handlers.d.ts.map +1 -0
  201. package/dist/types/types/index.d.ts +7 -0
  202. package/dist/types/types/index.d.ts.map +1 -0
  203. package/dist/types/utils/environment.d.ts +47 -0
  204. package/dist/types/utils/environment.d.ts.map +1 -0
  205. package/dist/types/utils/formatting.d.ts +37 -0
  206. package/dist/types/utils/formatting.d.ts.map +1 -0
  207. package/dist/types/utils/index.d.ts +7 -0
  208. package/dist/types/utils/index.d.ts.map +1 -0
  209. package/dist/types/utils/opentui-detection.d.ts +34 -0
  210. package/dist/types/utils/opentui-detection.d.ts.map +1 -0
  211. package/dist/types/utils/output.d.ts +41 -0
  212. package/dist/types/utils/output.d.ts.map +1 -0
  213. package/dist/types/utils/stackTrace.d.ts +6 -0
  214. package/dist/types/utils/stackTrace.d.ts.map +1 -0
  215. package/dist/types/utils/timestamps.d.ts +20 -0
  216. package/dist/types/utils/timestamps.d.ts.map +1 -0
  217. package/dist/utils/environment.d.ts +47 -0
  218. package/dist/utils/environment.d.ts.map +1 -0
  219. package/dist/utils/environment.js +85 -0
  220. package/dist/utils/formatting.d.ts +40 -0
  221. package/dist/utils/formatting.d.ts.map +1 -0
  222. package/dist/utils/formatting.js +117 -0
  223. package/dist/utils/index.d.ts +7 -0
  224. package/dist/utils/index.d.ts.map +1 -0
  225. package/dist/utils/index.js +6 -0
  226. package/dist/utils/opentui-detection.d.ts +34 -0
  227. package/dist/utils/opentui-detection.d.ts.map +1 -0
  228. package/dist/utils/opentui-detection.js +116 -0
  229. package/dist/utils/output.d.ts +44 -0
  230. package/dist/utils/output.d.ts.map +1 -0
  231. package/dist/utils/output.js +150 -0
  232. package/dist/utils/stackTrace.d.ts +9 -0
  233. package/dist/utils/stackTrace.d.ts.map +1 -0
  234. package/dist/utils/stackTrace.js +81 -0
  235. package/dist/utils/timestamps.d.ts +20 -0
  236. package/dist/utils/timestamps.d.ts.map +1 -0
  237. package/dist/utils/timestamps.js +71 -0
  238. package/docs/API.md +691 -0
  239. package/docs/CORE.md +10 -10
  240. package/docs/DEVELOPMENT.md +731 -0
  241. package/docs/PACKAGES.md +244 -0
  242. package/docs/_config.yml +36 -0
  243. package/docs/index.md +179 -0
  244. package/examples/README.md +208 -0
  245. package/examples/basic-logging.js +75 -0
  246. package/examples/data-export.js +234 -0
  247. package/examples/package.json +16 -0
  248. package/examples/performance-timing.js +170 -0
  249. package/examples/simplified-api.js +124 -0
  250. package/examples/styling-themes.js +207 -0
  251. package/package.json +37 -21
  252. package/packages/core/package.json +57 -0
  253. package/packages/exports/package.json +41 -0
  254. package/packages/nodejs-opentui/README.md +232 -0
  255. package/packages/nodejs-opentui/package.json +72 -0
  256. package/packages/nodejs-opentui/src/LogRenderer.ts +171 -0
  257. package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +178 -0
  258. package/packages/nodejs-opentui/src/components/LogBadge.tsx +131 -0
  259. package/packages/nodejs-opentui/src/index.ts +133 -0
  260. package/packages/nodejs-opentui/src/types.ts +158 -0
  261. package/packages/nodejs-opentui/tsconfig.json +20 -0
  262. package/packages/styling/package.json +41 -0
  263. package/project-utils/README.md +172 -0
  264. package/project-utils/auto-release-gemini.ts +1193 -0
  265. package/project-utils/auto-release-ui.ts +1329 -0
  266. package/project-utils/commit-generator.ts +1385 -0
  267. package/project-utils/commit-ui.ts +264 -0
  268. package/project-utils/git-utils.ts +199 -0
  269. package/project-utils/github-release-manager.ts +466 -0
  270. package/project-utils/project-config.ts +260 -0
  271. package/project-utils/prompt-templates.js +345 -0
  272. package/project-utils/prompt-templates.ts +422 -0
  273. package/project-utils/version-manager.ts +1078 -0
  274. package/src/Logger.ts +251 -16
  275. package/src/ScopedLogger.ts +262 -0
  276. package/src/cli/CommandProcessor.ts +173 -2
  277. package/src/cli/commands/HistoryCommand.ts +117 -0
  278. package/src/cli/index.ts +12 -0
  279. package/src/constants.ts +84 -2
  280. package/src/core.ts +119 -46
  281. package/src/example.ts +4 -4
  282. package/src/exports-module.ts +1 -1
  283. package/src/handlers/ExportLogHandler.ts +141 -0
  284. package/src/handlers/FileLogHandler.ts +144 -5
  285. package/src/index.ts +1 -1
  286. package/src/main.ts +3 -3
  287. package/src/styling/LogStyleBuilder.ts +355 -0
  288. package/src/styling/SemanticStyles.ts +380 -0
  289. package/src/styling/SmartPresets.ts +288 -0
  290. package/src/styling/StyleBuilder.ts +14 -0
  291. package/src/styling/index.ts +16 -1
  292. package/src/styling-module.ts +1 -1
  293. package/src/types/core.ts +60 -0
  294. package/src/types/index.ts +6 -0
  295. package/src/utils/environment.ts +94 -0
  296. package/src/utils/formatting.ts +142 -0
  297. package/src/utils/index.ts +3 -0
  298. package/src/utils/opentui-detection.ts +138 -0
  299. package/src/utils/output.ts +66 -8
  300. package/test-core-browser.html +237 -0
  301. package/test-core-node.js +63 -0
  302. package/tests/test-conflict-resolution.ts +391 -0
  303. package/tests/validate-workflows.sh +131 -0
  304. package/tests/yaml-autofix.sh +146 -0
  305. package/vite.config.ts +189 -50
  306. package/.npmrc.bak +0 -1
  307. package/dist/chunks/Logger-BQhMKy_T.js +0 -2
  308. package/dist/chunks/Logger-BQhMKy_T.js.map +0 -1
  309. package/dist/chunks/Logger-BrFKFZcD.js +0 -978
  310. package/dist/chunks/Logger-BrFKFZcD.js.map +0 -1
  311. package/dist/chunks/core-2opW4Pi3.js +0 -194
  312. package/dist/chunks/core-2opW4Pi3.js.map +0 -1
  313. package/dist/chunks/core-DyugwSYZ.js +0 -4
  314. package/dist/chunks/core-DyugwSYZ.js.map +0 -1
  315. package/dist/chunks/exports-BNP3R7dp.js +0 -421
  316. package/dist/chunks/exports-BNP3R7dp.js.map +0 -1
  317. package/dist/chunks/exports-U1xLBXrY.js +0 -2
  318. package/dist/chunks/exports-U1xLBXrY.js.map +0 -1
  319. package/dist/chunks/styling-DhUDzwlE.js +0 -654
  320. package/dist/chunks/styling-DhUDzwlE.js.map +0 -1
  321. package/dist/chunks/styling-tmRDI28D.js +0 -2
  322. package/dist/chunks/styling-tmRDI28D.js.map +0 -1
  323. package/dist/types/exports.d.ts +0 -600
  324. package/dist/types/styling.d.ts +0 -751
  325. package/src/Logger.ts.backup +0 -1684
  326. /package/.github/{workflows → workflows-backup}/release.yml +0 -0
@@ -11,20 +11,101 @@ export interface ICommand {
11
11
  name: string;
12
12
  description: string;
13
13
  usage: string;
14
+ category?: string;
15
+ aliases?: string[];
14
16
  execute(args: string, logger: Logger): void | Promise<void>;
15
17
  }
16
18
 
19
+ /**
20
+ * Plugin interface for extending CLI functionality
21
+ */
22
+ export interface ICLIPlugin {
23
+ name: string;
24
+ version: string;
25
+ description: string;
26
+ commands: ICommand[];
27
+ initialize?(processor: CommandProcessor, logger: Logger): void;
28
+ cleanup?(): void;
29
+ }
30
+
31
+ /**
32
+ * Command history entry
33
+ */
34
+ interface HistoryEntry {
35
+ command: string;
36
+ timestamp: Date;
37
+ success: boolean;
38
+ }
39
+
17
40
  /**
18
41
  * CLI command processor
19
42
  */
20
43
  export class CommandProcessor {
21
44
  private commands: Map<string, ICommand> = new Map();
45
+ private aliases: Map<string, string> = new Map();
46
+ private plugins: Map<string, ICLIPlugin> = new Map();
47
+ private history: HistoryEntry[] = [];
48
+ private maxHistorySize: number = 100;
49
+ private isInteractiveMode: boolean = false;
22
50
 
23
51
  /**
24
52
  * Register a command
25
53
  */
26
54
  registerCommand(command: ICommand): void {
27
55
  this.commands.set(command.name, command);
56
+
57
+ // Register aliases
58
+ if (command.aliases) {
59
+ for (const alias of command.aliases) {
60
+ this.aliases.set(alias, command.name);
61
+ }
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Register a plugin
67
+ */
68
+ registerPlugin(plugin: ICLIPlugin, logger?: Logger): void {
69
+ if (this.plugins.has(plugin.name)) {
70
+ throw new Error(`Plugin ${plugin.name} is already registered`);
71
+ }
72
+
73
+ this.plugins.set(plugin.name, plugin);
74
+
75
+ // Register plugin commands
76
+ for (const command of plugin.commands) {
77
+ this.registerCommand(command);
78
+ }
79
+
80
+ // Initialize plugin
81
+ if (plugin.initialize && logger) {
82
+ plugin.initialize(this, logger);
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Unregister a plugin
88
+ */
89
+ unregisterPlugin(pluginName: string): void {
90
+ const plugin = this.plugins.get(pluginName);
91
+ if (!plugin) return;
92
+
93
+ // Remove plugin commands
94
+ for (const command of plugin.commands) {
95
+ this.commands.delete(command.name);
96
+ if (command.aliases) {
97
+ for (const alias of command.aliases) {
98
+ this.aliases.delete(alias);
99
+ }
100
+ }
101
+ }
102
+
103
+ // Cleanup plugin
104
+ if (plugin.cleanup) {
105
+ plugin.cleanup();
106
+ }
107
+
108
+ this.plugins.delete(pluginName);
28
109
  }
29
110
 
30
111
  /**
@@ -38,7 +119,70 @@ export class CommandProcessor {
38
119
  * Get a specific command
39
120
  */
40
121
  getCommand(name: string): ICommand | undefined {
41
- return this.commands.get(name);
122
+ // Check direct command name
123
+ let command = this.commands.get(name);
124
+ if (command) return command;
125
+
126
+ // Check aliases
127
+ const aliasTarget = this.aliases.get(name);
128
+ if (aliasTarget) {
129
+ return this.commands.get(aliasTarget);
130
+ }
131
+
132
+ return undefined;
133
+ }
134
+
135
+ /**
136
+ * Get command history
137
+ */
138
+ getHistory(): HistoryEntry[] {
139
+ return [...this.history];
140
+ }
141
+
142
+ /**
143
+ * Clear command history
144
+ */
145
+ clearHistory(): void {
146
+ this.history = [];
147
+ }
148
+
149
+ /**
150
+ * Get registered plugins
151
+ */
152
+ getPlugins(): ICLIPlugin[] {
153
+ return Array.from(this.plugins.values());
154
+ }
155
+
156
+ /**
157
+ * Enter interactive mode
158
+ */
159
+ enterInteractiveMode(logger: Logger): void {
160
+ this.isInteractiveMode = true;
161
+ logger.info('🔧 Interactive CLI mode activated. Type /exit to quit, /help for commands.');
162
+
163
+ // Set up browser console listener for interactive commands
164
+ if (typeof window !== 'undefined') {
165
+ this.setupBrowserInteractiveMode(logger);
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Exit interactive mode
171
+ */
172
+ exitInteractiveMode(): void {
173
+ this.isInteractiveMode = false;
174
+ }
175
+
176
+ /**
177
+ * Setup browser interactive mode
178
+ */
179
+ private setupBrowserInteractiveMode(logger: Logger): void {
180
+ // Add global CLI function for browser usage
181
+ (window as any).cli = (commandString: string) => {
182
+ return this.processCommand(`/${commandString}`, logger);
183
+ };
184
+
185
+ logger.info('💡 Use cli("command") to execute CLI commands in browser console.');
42
186
  }
43
187
 
44
188
  /**
@@ -47,6 +191,7 @@ export class CommandProcessor {
47
191
  async processCommand(commandString: string, logger: Logger): Promise<void> {
48
192
  if (!commandString.startsWith('/')) {
49
193
  logger.error('Invalid command. Commands must start with /');
194
+ this.addToHistory(commandString, false);
50
195
  return;
51
196
  }
52
197
 
@@ -54,16 +199,42 @@ export class CommandProcessor {
54
199
  const commandName = parts[0] || '';
55
200
  const args = parts.slice(1).join(' ');
56
201
 
57
- const command = this.commands.get(commandName);
202
+ const command = this.getCommand(commandName);
58
203
  if (!command) {
59
204
  logger.error(`Unknown command: ${commandName}. Type /help for available commands.`);
205
+
206
+ // Suggest similar commands
207
+ const suggestions = this.getSuggestions(commandName);
208
+ if (suggestions.length > 0) {
209
+ logger.info(`📋 Did you mean: ${suggestions.slice(0, 3).join(', ')}?`);
210
+ }
211
+
212
+ this.addToHistory(commandString, false);
60
213
  return;
61
214
  }
62
215
 
63
216
  try {
64
217
  await command.execute(args || '', logger);
218
+ this.addToHistory(commandString, true);
65
219
  } catch (error) {
66
220
  logger.error(`Command '${commandName}' failed:`, error);
221
+ this.addToHistory(commandString, false);
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Add command to history
227
+ */
228
+ private addToHistory(command: string, success: boolean): void {
229
+ this.history.unshift({
230
+ command,
231
+ timestamp: new Date(),
232
+ success
233
+ });
234
+
235
+ // Limit history size
236
+ if (this.history.length > this.maxHistorySize) {
237
+ this.history = this.history.slice(0, this.maxHistorySize);
67
238
  }
68
239
  }
69
240
 
@@ -0,0 +1,117 @@
1
+ /**
2
+ * @fileoverview History management commands for CLI
3
+ */
4
+
5
+ import type { ICommand } from '../CommandProcessor.js';
6
+ import type { Logger } from '../../Logger.js';
7
+
8
+ /**
9
+ * Show command history
10
+ */
11
+ export class HistoryCommand implements ICommand {
12
+ name = 'history';
13
+ description = 'Show command execution history';
14
+ usage = '/history [limit] - Show recent commands (default: 10)';
15
+ category = 'system';
16
+ aliases = ['hist', 'h'];
17
+
18
+ execute(args: string, logger: Logger): void {
19
+ const processor = (logger as any).cliProcessor;
20
+ if (!processor) {
21
+ logger.error('CLI processor not available');
22
+ return;
23
+ }
24
+
25
+ const limit = parseInt(args) || 10;
26
+ const history = processor.getHistory().slice(0, limit);
27
+
28
+ if (history.length === 0) {
29
+ logger.info('📝 No command history available');
30
+ return;
31
+ }
32
+
33
+ logger.info(`📋 Last ${history.length} commands:`);
34
+
35
+ history.forEach((entry: any, index: number) => {
36
+ const status = entry.success ? '✅' : '❌';
37
+ const time = entry.timestamp.toLocaleTimeString();
38
+ logger.info(`${status} [${time}] ${entry.command}`);
39
+ });
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Clear command history
45
+ */
46
+ export class ClearHistoryCommand implements ICommand {
47
+ name = 'clearhistory';
48
+ description = 'Clear command execution history';
49
+ usage = '/clearhistory - Remove all command history';
50
+ category = 'system';
51
+ aliases = ['clrhist'];
52
+
53
+ execute(args: string, logger: Logger): void {
54
+ const processor = (logger as any).cliProcessor;
55
+ if (!processor) {
56
+ logger.error('CLI processor not available');
57
+ return;
58
+ }
59
+
60
+ processor.clearHistory();
61
+ logger.success('đŸ—‘ī¸ Command history cleared');
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Interactive mode command
67
+ */
68
+ export class InteractiveCommand implements ICommand {
69
+ name = 'interactive';
70
+ description = 'Enter interactive CLI mode';
71
+ usage = '/interactive - Start interactive command mode';
72
+ category = 'system';
73
+ aliases = ['i', 'repl'];
74
+
75
+ execute(args: string, logger: Logger): void {
76
+ const processor = (logger as any).cliProcessor;
77
+ if (!processor) {
78
+ logger.error('CLI processor not available');
79
+ return;
80
+ }
81
+
82
+ processor.enterInteractiveMode(logger);
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Plugin management command
88
+ */
89
+ export class PluginsCommand implements ICommand {
90
+ name = 'plugins';
91
+ description = 'List loaded CLI plugins';
92
+ usage = '/plugins - Show all registered plugins';
93
+ category = 'system';
94
+ aliases = ['plug'];
95
+
96
+ execute(args: string, logger: Logger): void {
97
+ const processor = (logger as any).cliProcessor;
98
+ if (!processor) {
99
+ logger.error('CLI processor not available');
100
+ return;
101
+ }
102
+
103
+ const plugins = processor.getPlugins();
104
+
105
+ if (plugins.length === 0) {
106
+ logger.info('🔌 No plugins registered');
107
+ return;
108
+ }
109
+
110
+ logger.info(`🔌 Loaded plugins (${plugins.length}):`);
111
+
112
+ plugins.forEach((plugin: any) => {
113
+ logger.info(` đŸ“Ļ ${plugin.name} v${plugin.version} - ${plugin.description}`);
114
+ logger.info(` Commands: ${plugin.commands.map((c: any) => c.name).join(', ')}`);
115
+ });
116
+ }
117
+ }
package/src/cli/index.ts CHANGED
@@ -33,6 +33,12 @@ import {
33
33
  ClearBufferCommand,
34
34
  BufferInfoCommand
35
35
  } from './commands/ExportCommand.js';
36
+ import {
37
+ HistoryCommand,
38
+ ClearHistoryCommand,
39
+ InteractiveCommand,
40
+ PluginsCommand
41
+ } from './commands/HistoryCommand.js';
36
42
 
37
43
  /**
38
44
  * Create and configure default CLI processor
@@ -55,5 +61,11 @@ export function createDefaultCLI(): CommandProcessor {
55
61
  processor.registerCommand(new ClearBufferCommand());
56
62
  processor.registerCommand(new BufferInfoCommand());
57
63
 
64
+ // Register new enhanced commands
65
+ processor.registerCommand(new HistoryCommand());
66
+ processor.registerCommand(new ClearHistoryCommand());
67
+ processor.registerCommand(new InteractiveCommand());
68
+ processor.registerCommand(new PluginsCommand());
69
+
58
70
  return processor;
59
71
  }
package/src/constants.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  * @fileoverview Global constants for Advanced Logger
3
3
  */
4
4
 
5
- import type { LogLevel } from './types/index.js';
5
+ import type { LogLevel, AdaptiveColors } from './types/index.js';
6
+ import type { LevelStyleConfig } from './utils/index.js';
6
7
 
7
8
  /**
8
9
  * Default configuration values
@@ -15,6 +16,61 @@ export const DEFAULT_CONFIG = {
15
16
  theme: 'default' as const,
16
17
  bannerType: 'simple' as const,
17
18
  bufferSize: 1000,
19
+ autoDetectTheme: true,
20
+ } as const;
21
+
22
+ /**
23
+ * Basic level styles for core module (minimal CSS styling)
24
+ */
25
+ export const LEVEL_STYLES: Record<LogLevel | 'success', LevelStyleConfig> = {
26
+ debug: {
27
+ emoji: '🔍',
28
+ label: 'DEBUG',
29
+ background: 'linear-gradient(90deg, #6c757d, #495057)',
30
+ color: '#ffffff',
31
+ border: '1px solid #6c757d',
32
+ shadow: '0 2px 4px rgba(108, 117, 125, 0.3)'
33
+ },
34
+ info: {
35
+ emoji: 'â„šī¸',
36
+ label: 'INFO',
37
+ background: 'linear-gradient(90deg, #007bff, #0056b3)',
38
+ color: '#ffffff',
39
+ border: '1px solid #007bff',
40
+ shadow: '0 2px 4px rgba(0, 123, 255, 0.3)'
41
+ },
42
+ warn: {
43
+ emoji: 'âš ī¸',
44
+ label: 'WARN',
45
+ background: 'linear-gradient(90deg, #ffc107, #e0a800)',
46
+ color: '#000000',
47
+ border: '1px solid #ffc107',
48
+ shadow: '0 2px 4px rgba(255, 193, 7, 0.3)'
49
+ },
50
+ error: {
51
+ emoji: '❌',
52
+ label: 'ERROR',
53
+ background: 'linear-gradient(90deg, #dc3545, #c82333)',
54
+ color: '#ffffff',
55
+ border: '1px solid #dc3545',
56
+ shadow: '0 2px 4px rgba(220, 53, 69, 0.3)'
57
+ },
58
+ critical: {
59
+ emoji: '🚨',
60
+ label: 'CRITICAL',
61
+ background: 'linear-gradient(90deg, #8B0000, #FF0000)',
62
+ color: '#ffffff',
63
+ border: '2px solid #FF0000',
64
+ shadow: '0 4px 8px rgba(255, 0, 0, 0.4)'
65
+ },
66
+ success: {
67
+ emoji: '✅',
68
+ label: 'SUCCESS',
69
+ background: 'linear-gradient(90deg, #28a745, #1e7e34)',
70
+ color: '#ffffff',
71
+ border: '1px solid #28a745',
72
+ shadow: '0 2px 4px rgba(40, 167, 69, 0.3)'
73
+ }
18
74
  } as const;
19
75
 
20
76
  /**
@@ -86,4 +142,30 @@ export const LEVEL_PRIORITIES: Record<LogLevel, number> = {
86
142
  warn: 2,
87
143
  error: 3,
88
144
  critical: 4,
89
- } as const;
145
+ } as const;
146
+
147
+ /**
148
+ * Adaptive color configurations for DevTools theme compatibility
149
+ */
150
+ export const ADAPTIVE_COLORS = {
151
+ timestamp: {
152
+ light: '#666666',
153
+ dark: '#a0a0a0',
154
+ },
155
+ messageText: {
156
+ light: '#2d3748',
157
+ dark: '#f7fafc',
158
+ },
159
+ prefix: {
160
+ light: '#2d3748',
161
+ dark: '#e2e8f0',
162
+ },
163
+ prefixBackground: {
164
+ light: '#2d3748',
165
+ dark: '#4a5568',
166
+ },
167
+ location: {
168
+ light: '#718096',
169
+ dark: '#a0aec0',
170
+ },
171
+ } as const satisfies Record<string, AdaptiveColors>;