auq-mcp-server 2.6.4 → 2.7.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 (96) hide show
  1. package/README.md +56 -2
  2. package/dist/bin/auq.js +36 -3
  3. package/dist/bin/tui-app.js +27 -6
  4. package/dist/package.json +7 -2
  5. package/dist/src/__tests__/schema-validation.test.js +61 -1
  6. package/dist/src/cli/commands/__tests__/fetch-answers.test.js +310 -0
  7. package/dist/src/cli/commands/__tests__/history.test.js +211 -0
  8. package/dist/src/cli/commands/answer.js +11 -0
  9. package/dist/src/cli/commands/config.js +48 -0
  10. package/dist/src/cli/commands/fetch-answers.js +205 -0
  11. package/dist/src/cli/commands/history.js +375 -0
  12. package/dist/src/config/__tests__/ConfigLoader.test.js +38 -0
  13. package/dist/src/config/defaults.js +1 -0
  14. package/dist/src/config/types.js +1 -0
  15. package/dist/src/core/ask-user-questions.js +63 -0
  16. package/dist/src/i18n/locales/en.js +2 -2
  17. package/dist/src/server.js +59 -2
  18. package/dist/src/session/ResponseFormatter.js +79 -2
  19. package/dist/src/session/SessionManager.js +36 -0
  20. package/dist/src/session/__tests__/ResponseFormatter.test.js +86 -0
  21. package/dist/src/session/__tests__/SessionManager.test.js +129 -0
  22. package/dist/src/shared/schemas.js +8 -0
  23. package/dist/src/tui/ThemeProvider.js +3 -3
  24. package/dist/src/tui/components/Header.js +2 -1
  25. package/dist/src/tui/components/OptionsList.js +1 -1
  26. package/dist/src/tui/components/SessionPicker.js +1 -1
  27. package/dist/src/tui/components/StepperView.js +1 -1
  28. package/dist/src/tui/components/__tests__/ConfirmationDialog.test.js +1 -1
  29. package/dist/src/tui/components/__tests__/Footer.test.js +1 -1
  30. package/dist/src/tui/components/__tests__/MarkdownPrompt.test.js +1 -1
  31. package/dist/src/tui/components/__tests__/ReviewScreen.test.js +1 -1
  32. package/dist/src/tui/components/__tests__/SessionDots.test.js +1 -1
  33. package/dist/src/tui/components/__tests__/SessionPicker.test.js +1 -1
  34. package/dist/src/tui/components/__tests__/StepperView.abandoned.test.js +1 -1
  35. package/dist/src/tui/components/__tests__/StepperView.keyboard.test.js +1 -1
  36. package/dist/src/tui/components/__tests__/StepperView.state.test.js +1 -1
  37. package/dist/src/tui/components/__tests__/WaitingScreen.test.js +1 -1
  38. package/dist/src/tui/shared/session-events.js +4 -0
  39. package/dist/src/tui/shared/themes/catppuccin-latte.js +130 -0
  40. package/dist/src/tui/shared/themes/catppuccin-mocha.js +131 -0
  41. package/dist/src/tui/shared/themes/dark.js +131 -0
  42. package/dist/src/tui/shared/themes/dracula.js +131 -0
  43. package/dist/src/tui/shared/themes/github-dark.js +129 -0
  44. package/dist/src/tui/shared/themes/github-light.js +129 -0
  45. package/dist/src/tui/shared/themes/gruvbox-dark.js +130 -0
  46. package/dist/src/tui/shared/themes/gruvbox-light.js +130 -0
  47. package/dist/src/tui/shared/themes/index.js +70 -0
  48. package/dist/src/tui/shared/themes/light.js +130 -0
  49. package/dist/src/tui/shared/themes/loader.js +111 -0
  50. package/dist/src/tui/shared/themes/monokai.js +132 -0
  51. package/dist/src/tui/shared/themes/nord.js +130 -0
  52. package/dist/src/tui/shared/themes/one-dark.js +131 -0
  53. package/dist/src/tui/shared/themes/rose-pine.js +131 -0
  54. package/dist/src/tui/shared/themes/solarized-dark.js +130 -0
  55. package/dist/src/tui/shared/themes/solarized-light.js +130 -0
  56. package/dist/src/tui/shared/themes/tokyo-night.js +131 -0
  57. package/dist/src/tui/shared/themes/types.js +1 -0
  58. package/dist/src/tui/shared/types.js +1 -0
  59. package/dist/src/tui/shared/utils/config.js +80 -0
  60. package/dist/src/tui/shared/utils/detectTheme.js +33 -0
  61. package/dist/src/tui/shared/utils/index.js +6 -0
  62. package/dist/src/tui/shared/utils/recommended.js +52 -0
  63. package/dist/src/tui/shared/utils/relativeTime.js +24 -0
  64. package/dist/src/tui/shared/utils/sessionSwitching.js +56 -0
  65. package/dist/src/tui/shared/utils/staleDetection.js +51 -0
  66. package/dist/src/tui/themes/catppuccin-latte.js +2 -127
  67. package/dist/src/tui/themes/catppuccin-mocha.js +2 -127
  68. package/dist/src/tui/themes/dark.js +2 -128
  69. package/dist/src/tui/themes/dracula.js +2 -127
  70. package/dist/src/tui/themes/github-dark.js +2 -126
  71. package/dist/src/tui/themes/github-light.js +2 -126
  72. package/dist/src/tui/themes/gruvbox-dark.js +2 -127
  73. package/dist/src/tui/themes/gruvbox-light.js +2 -127
  74. package/dist/src/tui/themes/index.js +2 -70
  75. package/dist/src/tui/themes/light.js +2 -127
  76. package/dist/src/tui/themes/loader.js +2 -111
  77. package/dist/src/tui/themes/monokai.js +2 -128
  78. package/dist/src/tui/themes/nord.js +2 -127
  79. package/dist/src/tui/themes/one-dark.js +2 -127
  80. package/dist/src/tui/themes/rose-pine.js +2 -128
  81. package/dist/src/tui/themes/solarized-dark.js +2 -127
  82. package/dist/src/tui/themes/solarized-light.js +2 -127
  83. package/dist/src/tui/themes/tokyo-night.js +2 -127
  84. package/dist/src/tui/themes/types.js +2 -1
  85. package/dist/src/tui/types.js +1 -1
  86. package/dist/src/tui/utils/__tests__/recommended.test.js +1 -1
  87. package/dist/src/tui/utils/__tests__/relativeTime.test.js +1 -1
  88. package/dist/src/tui/utils/__tests__/sessionSwitching.test.js +1 -1
  89. package/dist/src/tui/utils/__tests__/staleDetection.test.js +1 -1
  90. package/dist/src/tui/utils/config.js +1 -80
  91. package/dist/src/tui/utils/detectTheme.js +1 -22
  92. package/dist/src/tui/utils/recommended.js +1 -52
  93. package/dist/src/tui/utils/relativeTime.js +1 -24
  94. package/dist/src/tui/utils/sessionSwitching.js +1 -56
  95. package/dist/src/tui/utils/staleDetection.js +1 -51
  96. package/package.json +7 -2
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Solarized Dark Theme
3
+ * Precision colors for machines and people.
4
+ * https://ethanschoonover.com/solarized/
5
+ */
6
+ export const solarizedDarkTheme = {
7
+ name: "solarized-dark",
8
+ gradient: {
9
+ start: "#268bd2", // blue
10
+ middle: "#2aa198", // cyan
11
+ end: "#268bd2",
12
+ },
13
+ colors: {
14
+ bg: "#002B36",
15
+ surface: "#073642",
16
+ surfaceAlt: "#0A4050",
17
+ primary: "#268bd2", // blue
18
+ success: "#859900", // green
19
+ warning: "#b58900", // yellow
20
+ error: "#dc322f", // red
21
+ info: "#2aa198", // cyan
22
+ focused: "#268bd2",
23
+ selected: "#859900",
24
+ pending: "#b58900",
25
+ unansweredHighlight: "#dc322f",
26
+ text: "#93A1A1", // base1 - brighter for readability
27
+ textDim: "#7D8E95", // base01 brightened for contrast
28
+ textBold: "#EEE8D5", // base2 - clearly bold
29
+ },
30
+ borders: {
31
+ primary: "#268bd2",
32
+ warning: "#b58900",
33
+ error: "#dc322f",
34
+ neutral: "#073642", // base02
35
+ },
36
+ components: {
37
+ header: {
38
+ border: "#586e75", // base01 - slightly more visible
39
+ queueActive: "#268bd2",
40
+ queueEmpty: "#6c7c83",
41
+ queueFlash: "#2aa198",
42
+ pillBg: "#073642",
43
+ },
44
+ directory: {
45
+ label: "#6c7c83",
46
+ path: "#839496",
47
+ },
48
+ tabBar: {
49
+ selected: "#93a1a1",
50
+ selectedBg: "#073642",
51
+ default: "#6c7c83",
52
+ answered: "#859900",
53
+ unanswered: "#6c7c83",
54
+ divider: "#073642",
55
+ },
56
+ options: {
57
+ focused: "#859900",
58
+ focusedBg: "#073642",
59
+ selected: "#268bd2",
60
+ selectedBg: "#073642",
61
+ default: "#839496",
62
+ description: "#93a1a1", // base1 - lighter for readability
63
+ hint: "#93a1a1", // base1 - lighter for readability
64
+ },
65
+ input: {
66
+ border: "#073642",
67
+ borderFocused: "#268bd2",
68
+ placeholder: "#6c7c83",
69
+ cursor: "#268bd2",
70
+ cursorDim: "#2aa198",
71
+ },
72
+ review: {
73
+ border: "#073642",
74
+ confirmBorder: "#268bd2",
75
+ selectedOption: "#859900",
76
+ customAnswer: "#b58900",
77
+ questionId: "#6c7c83",
78
+ divider: "#073642",
79
+ },
80
+ questionDisplay: {
81
+ questionId: "#268bd2",
82
+ typeIndicator: "#6c7c83",
83
+ elapsed: "#6c7c83",
84
+ },
85
+ footer: {
86
+ border: "#073642",
87
+ keyBg: "#073642",
88
+ keyFg: "#268bd2",
89
+ action: "#839496", // base0 - brighter for visibility
90
+ separator: "#073642",
91
+ },
92
+ toast: {
93
+ success: "#859900",
94
+ successPillBg: "#073642",
95
+ error: "#dc322f",
96
+ info: "#268bd2",
97
+ warning: "#b58900",
98
+ border: "#073642",
99
+ },
100
+ markdown: {
101
+ codeBlockBg: "#002b36",
102
+ codeBlockText: "#839496",
103
+ codeBlockBorder: "#073642",
104
+ },
105
+ sessionDots: {
106
+ active: "#268bd2",
107
+ answered: "#859900",
108
+ inProgress: "#b58900",
109
+ untouched: "#6c7c83",
110
+ number: "#839496",
111
+ activeNumber: "#268bd2",
112
+ stale: "#b58900",
113
+ abandoned: "#dc322f",
114
+ },
115
+ sessionPicker: {
116
+ border: "#268bd2",
117
+ title: "#268bd2",
118
+ rowText: "#839496",
119
+ rowDim: "#6c7c83",
120
+ highlightBg: "#073642",
121
+ highlightFg: "#859900",
122
+ activeMark: "#268bd2",
123
+ progress: "#2aa198",
124
+ staleIcon: "#b58900",
125
+ staleText: "#b58900",
126
+ staleAge: "#b58900",
127
+ staleSubtitle: "#6c7c83",
128
+ },
129
+ },
130
+ };
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Solarized Light Theme
3
+ * Precision colors for machines and people - light variant.
4
+ * https://ethanschoonover.com/solarized/
5
+ */
6
+ export const solarizedLightTheme = {
7
+ name: "solarized-light",
8
+ gradient: {
9
+ start: "#268bd2", // blue
10
+ middle: "#2aa198", // cyan
11
+ end: "#268bd2",
12
+ },
13
+ colors: {
14
+ bg: "#FDF6E3",
15
+ surface: "#EEE8D5",
16
+ surfaceAlt: "#DDD6C1",
17
+ primary: "#268bd2", // blue
18
+ success: "#859900", // green
19
+ warning: "#b58900", // yellow
20
+ error: "#dc322f", // red
21
+ info: "#2aa198", // cyan
22
+ focused: "#268bd2",
23
+ selected: "#859900",
24
+ pending: "#b58900",
25
+ unansweredHighlight: "#dc322f",
26
+ text: "#657b83", // base00
27
+ textDim: "#8A9899", // base1 darkened for contrast on cream
28
+ textBold: "#586e75", // base01
29
+ },
30
+ borders: {
31
+ primary: "#268bd2",
32
+ warning: "#b58900",
33
+ error: "#dc322f",
34
+ neutral: "#eee8d5", // base2
35
+ },
36
+ components: {
37
+ header: {
38
+ border: "#93a1a1", // base1 - slightly more visible
39
+ queueActive: "#268bd2",
40
+ queueEmpty: "#a3b1b1",
41
+ queueFlash: "#2aa198",
42
+ pillBg: "#eee8d5",
43
+ },
44
+ directory: {
45
+ label: "#8A9899",
46
+ path: "#657b83",
47
+ },
48
+ tabBar: {
49
+ selected: "#586e75",
50
+ selectedBg: "#eee8d5",
51
+ default: "#8A9899",
52
+ answered: "#859900",
53
+ unanswered: "#a3b1b1",
54
+ divider: "#eee8d5",
55
+ },
56
+ options: {
57
+ focused: "#859900",
58
+ focusedBg: "#eee8d5",
59
+ selected: "#268bd2",
60
+ selectedBg: "#eee8d5",
61
+ default: "#657b83",
62
+ description: "#586e75", // base01 - darker for readability
63
+ hint: "#586e75", // base01 - darker for readability
64
+ },
65
+ input: {
66
+ border: "#eee8d5",
67
+ borderFocused: "#268bd2",
68
+ placeholder: "#a3b1b1",
69
+ cursor: "#268bd2",
70
+ cursorDim: "#2aa198",
71
+ },
72
+ review: {
73
+ border: "#eee8d5",
74
+ confirmBorder: "#268bd2",
75
+ selectedOption: "#859900",
76
+ customAnswer: "#b58900",
77
+ questionId: "#a3b1b1",
78
+ divider: "#eee8d5",
79
+ },
80
+ questionDisplay: {
81
+ questionId: "#268bd2",
82
+ typeIndicator: "#a3b1b1",
83
+ elapsed: "#a3b1b1",
84
+ },
85
+ footer: {
86
+ border: "#eee8d5",
87
+ keyBg: "#eee8d5",
88
+ keyFg: "#268bd2",
89
+ action: "#657b83", // base00 - darker for visibility
90
+ separator: "#eee8d5",
91
+ },
92
+ toast: {
93
+ success: "#859900",
94
+ successPillBg: "#eee8d5",
95
+ error: "#dc322f",
96
+ info: "#268bd2",
97
+ warning: "#b58900",
98
+ border: "#eee8d5",
99
+ },
100
+ markdown: {
101
+ codeBlockBg: "#fdf6e3",
102
+ codeBlockText: "#657b83",
103
+ codeBlockBorder: "#eee8d5",
104
+ },
105
+ sessionDots: {
106
+ active: "#268bd2",
107
+ answered: "#859900",
108
+ inProgress: "#b58900",
109
+ untouched: "#a3b1b1",
110
+ number: "#657b83",
111
+ activeNumber: "#268bd2",
112
+ stale: "#b58900",
113
+ abandoned: "#dc322f",
114
+ },
115
+ sessionPicker: {
116
+ border: "#268bd2",
117
+ title: "#268bd2",
118
+ rowText: "#657b83",
119
+ rowDim: "#a3b1b1",
120
+ highlightBg: "#eee8d5",
121
+ highlightFg: "#859900",
122
+ activeMark: "#268bd2",
123
+ progress: "#2aa198",
124
+ staleIcon: "#b58900",
125
+ staleText: "#b58900",
126
+ staleAge: "#b58900",
127
+ staleSubtitle: "#a3b1b1",
128
+ },
129
+ },
130
+ };
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Tokyo Night Theme
3
+ * A clean, dark theme celebrating the lights of downtown Tokyo.
4
+ * https://github.com/enkia/tokyo-night-vscode-theme
5
+ */
6
+ export const tokyoNightTheme = {
7
+ name: "tokyo-night",
8
+ gradient: {
9
+ start: "#7aa2f7", // blue
10
+ middle: "#7dcfff", // cyan
11
+ end: "#7aa2f7",
12
+ },
13
+ colors: {
14
+ // Background layers (OpenCode-style filled surfaces)
15
+ bg: "#1A1B26",
16
+ surface: "#1F2335",
17
+ surfaceAlt: "#292E42",
18
+ primary: "#7aa2f7", // blue
19
+ success: "#9ece6a", // green
20
+ warning: "#e0af68", // yellow
21
+ error: "#f7768e", // red
22
+ info: "#7dcfff", // cyan
23
+ focused: "#7aa2f7",
24
+ selected: "#9ece6a",
25
+ pending: "#e0af68",
26
+ unansweredHighlight: "#f7768e",
27
+ text: "#c0caf5", // foreground
28
+ textDim: "#7F87B5", // comment brightened
29
+ textBold: "#c0caf5",
30
+ },
31
+ borders: {
32
+ primary: "#7aa2f7",
33
+ warning: "#e0af68",
34
+ error: "#f7768e",
35
+ neutral: "#24283b", // storm bg
36
+ },
37
+ components: {
38
+ header: {
39
+ border: "#3b4261", // slightly more visible
40
+ queueActive: "#7aa2f7",
41
+ queueEmpty: "#7078A3",
42
+ queueFlash: "#7dcfff",
43
+ pillBg: "#24283b",
44
+ },
45
+ directory: {
46
+ label: "#7078A3",
47
+ path: "#c0caf5",
48
+ },
49
+ tabBar: {
50
+ selected: "#c0caf5",
51
+ selectedBg: "#24283b",
52
+ default: "#7078A3",
53
+ answered: "#9ece6a",
54
+ unanswered: "#7078A3",
55
+ divider: "#24283b",
56
+ },
57
+ options: {
58
+ focused: "#9ece6a",
59
+ focusedBg: "#24283b",
60
+ selected: "#7aa2f7",
61
+ selectedBg: "#24283b",
62
+ default: "#c0caf5",
63
+ description: "#9aa5ce", // lighter for readability
64
+ hint: "#9aa5ce", // lighter for readability
65
+ },
66
+ input: {
67
+ border: "#24283b",
68
+ borderFocused: "#7aa2f7",
69
+ placeholder: "#7078A3",
70
+ cursor: "#7aa2f7",
71
+ cursorDim: "#7dcfff",
72
+ },
73
+ review: {
74
+ border: "#24283b",
75
+ confirmBorder: "#7aa2f7",
76
+ selectedOption: "#9ece6a",
77
+ customAnswer: "#e0af68",
78
+ questionId: "#7078A3",
79
+ divider: "#24283b",
80
+ },
81
+ questionDisplay: {
82
+ questionId: "#7aa2f7",
83
+ typeIndicator: "#7078A3",
84
+ elapsed: "#7078A3",
85
+ },
86
+ footer: {
87
+ border: "#24283b",
88
+ keyBg: "#24283b",
89
+ keyFg: "#7aa2f7",
90
+ action: "#8E9AB5",
91
+ separator: "#24283b",
92
+ },
93
+ toast: {
94
+ success: "#9ece6a",
95
+ successPillBg: "#1a1b26",
96
+ error: "#f7768e",
97
+ info: "#7aa2f7",
98
+ warning: "#e0af68",
99
+ border: "#24283b",
100
+ },
101
+ markdown: {
102
+ codeBlockBg: "#1a1b26",
103
+ codeBlockText: "#c0caf5",
104
+ codeBlockBorder: "#24283b",
105
+ },
106
+ sessionDots: {
107
+ active: "#7aa2f7",
108
+ answered: "#9ece6a",
109
+ inProgress: "#e0af68",
110
+ untouched: "#7078A3",
111
+ number: "#c0caf5",
112
+ activeNumber: "#7aa2f7",
113
+ stale: "#e0af68",
114
+ abandoned: "#f7768e",
115
+ },
116
+ sessionPicker: {
117
+ border: "#7aa2f7",
118
+ title: "#7aa2f7",
119
+ rowText: "#c0caf5",
120
+ rowDim: "#7078A3",
121
+ highlightBg: "#24283b",
122
+ highlightFg: "#9ece6a",
123
+ activeMark: "#7aa2f7",
124
+ progress: "#7dcfff",
125
+ staleIcon: "#e0af68",
126
+ staleText: "#e0af68",
127
+ staleAge: "#e0af68",
128
+ staleSubtitle: "#7078A3",
129
+ },
130
+ },
131
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,80 @@
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import * as os from "node:os";
4
+ /**
5
+ * Get the config directory for AUQ
6
+ * Respects XDG_CONFIG_HOME on Linux, defaults to ~/.config/auq
7
+ */
8
+ function getConfigDirectory() {
9
+ const xdgConfig = process.env.XDG_CONFIG_HOME;
10
+ const baseConfig = xdgConfig || path.join(os.homedir(), ".config");
11
+ return path.join(baseConfig, "auq");
12
+ }
13
+ /**
14
+ * Get the config file path
15
+ */
16
+ function getConfigPath() {
17
+ return path.join(getConfigDirectory(), "config.json");
18
+ }
19
+ /**
20
+ * Load config from file
21
+ * Returns empty config if file doesn't exist or is invalid
22
+ */
23
+ export function loadConfig() {
24
+ try {
25
+ const configPath = getConfigPath();
26
+ if (!fs.existsSync(configPath)) {
27
+ return {};
28
+ }
29
+ const content = fs.readFileSync(configPath, "utf-8");
30
+ const data = JSON.parse(content);
31
+ if (typeof data !== "object" || data === null) {
32
+ return {};
33
+ }
34
+ return data;
35
+ }
36
+ catch {
37
+ // Silently return empty config on any error
38
+ return {};
39
+ }
40
+ }
41
+ /**
42
+ * Save config to file
43
+ * Creates the config directory if it doesn't exist
44
+ */
45
+ export function saveConfig(config) {
46
+ try {
47
+ const configDir = getConfigDirectory();
48
+ const configPath = getConfigPath();
49
+ // Ensure directory exists
50
+ if (!fs.existsSync(configDir)) {
51
+ fs.mkdirSync(configDir, { recursive: true });
52
+ }
53
+ // Merge with existing config to preserve other settings
54
+ const existingConfig = loadConfig();
55
+ const mergedConfig = { ...existingConfig, ...config };
56
+ fs.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2) + "\n");
57
+ }
58
+ catch {
59
+ // Silently ignore save errors - config is optional
60
+ }
61
+ }
62
+ /**
63
+ * Get saved theme from config
64
+ */
65
+ export function getSavedTheme() {
66
+ const config = loadConfig();
67
+ return config.theme;
68
+ }
69
+ /**
70
+ * Save theme to config
71
+ */
72
+ export function saveTheme(themeName) {
73
+ saveConfig({ theme: themeName });
74
+ }
75
+ /**
76
+ * Get the config directory path (for display purposes)
77
+ */
78
+ export function getConfigDirectoryPath() {
79
+ return getConfigDirectory();
80
+ }
@@ -0,0 +1,33 @@
1
+ let cachedResult = null;
2
+ /**
3
+ * Detect whether the system prefers dark or light mode.
4
+ * Uses the COLORFGBG environment variable if available, otherwise defaults to dark.
5
+ * Results are cached for performance.
6
+ *
7
+ * @returns The resolved theme name ("AUQ dark" or "AUQ light")
8
+ */
9
+ export function detectSystemTheme() {
10
+ if (cachedResult !== null) {
11
+ return cachedResult;
12
+ }
13
+ const colorfgbg = process.env.COLORFGBG;
14
+ if (colorfgbg) {
15
+ const parts = colorfgbg.split(";");
16
+ if (parts.length >= 2) {
17
+ const bg = parseInt(parts[1], 10);
18
+ if (!isNaN(bg)) {
19
+ cachedResult = bg < 8 ? "AUQ dark" : "AUQ light";
20
+ return cachedResult;
21
+ }
22
+ }
23
+ }
24
+ cachedResult = "AUQ dark";
25
+ return cachedResult;
26
+ }
27
+ /**
28
+ * Clear the cached theme detection result.
29
+ * Call this when the system theme may have changed.
30
+ */
31
+ export function clearDetectionCache() {
32
+ cachedResult = null;
33
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./staleDetection.js";
2
+ export * from "./sessionSwitching.js";
3
+ export * from "./relativeTime.js";
4
+ export * from "./recommended.js";
5
+ export * from "./config.js";
6
+ export * from "./detectTheme.js";
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Utility for detecting recommended options in question labels.
3
+ * Supports multiple languages and bracket styles.
4
+ */
5
+ /**
6
+ * Regex patterns for detecting recommended markers in labels.
7
+ * Requires matching delimiters: either (word) or [word].
8
+ * Matches case-insensitively and supports both parentheses and brackets.
9
+ */
10
+ export const RECOMMENDED_PATTERNS = {
11
+ /** Matches (recommended) or [recommended] - case insensitive, requires matching delimiters */
12
+ EN: /(?:\(recommended\)|\[recommended\])/i,
13
+ /** Matches (추천) or [추천] - requires matching delimiters */
14
+ KO: /(?:\(추천\)|\[추천\])/,
15
+ };
16
+ /**
17
+ * Combined regex for detecting any recommended pattern.
18
+ * Requires matching delimiters: either (word) or [word].
19
+ * Matches case-insensitively for English, exactly for Korean.
20
+ */
21
+ const RECOMMENDED_REGEX = /(?:\(recommended\)|\[recommended\]|\(추천\)|\[추천\])/i;
22
+ /**
23
+ * Detects if a label contains a recommended pattern.
24
+ * Supports English "recommended" and Korean "추천" in parentheses or brackets.
25
+ * Case-insensitive matching.
26
+ *
27
+ * @param label - The option label to check
28
+ * @returns true if the label contains a recommended marker
29
+ *
30
+ * @example
31
+ * isRecommendedOption("Option A (recommended)") // true
32
+ * isRecommendedOption("[추천] Option B") // true
33
+ * isRecommendedOption("Option C") // false
34
+ */
35
+ export function isRecommendedOption(label) {
36
+ return RECOMMENDED_REGEX.test(label);
37
+ }
38
+ /**
39
+ * Extracts the clean label by removing recommended markers.
40
+ * Removes recommended patterns and trims whitespace.
41
+ *
42
+ * @param label - The option label with potential recommended marker
43
+ * @returns The clean label without recommended markers
44
+ *
45
+ * @example
46
+ * extractCleanLabel("Option A (recommended)") // "Option A"
47
+ * extractCleanLabel("[추천] Option B") // "Option B"
48
+ * extractCleanLabel(" Option C ") // "Option C"
49
+ */
50
+ export function extractCleanLabel(label) {
51
+ return label.replace(RECOMMENDED_REGEX, "").trim().replace(/\s+/g, " ");
52
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Format a timestamp as a concise relative time string.
3
+ *
4
+ * @param date - A Date object or a numeric epoch-ms timestamp
5
+ * @returns Human-readable label such as "just now", "12s ago", "3m ago"
6
+ */
7
+ export function formatRelativeTime(date) {
8
+ const now = Date.now();
9
+ const then = typeof date === "number" ? date : date.getTime();
10
+ const diffMs = Math.max(0, now - then);
11
+ const diffSec = Math.floor(diffMs / 1000);
12
+ if (diffSec < 5)
13
+ return "just now";
14
+ if (diffSec < 60)
15
+ return `${diffSec}s ago`;
16
+ const diffMin = Math.floor(diffSec / 60);
17
+ if (diffMin < 60)
18
+ return `${diffMin}m ago`;
19
+ const diffHr = Math.floor(diffMin / 60);
20
+ if (diffHr < 24)
21
+ return `${diffHr}h ago`;
22
+ const diffDay = Math.floor(diffHr / 24);
23
+ return `${diffDay}d ago`;
24
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Calculate the next session index with cyclic wrap-around.
3
+ * Returns current index if queue has <= 1 item.
4
+ */
5
+ export function getNextSessionIndex(currentIndex, queueLength) {
6
+ if (queueLength <= 1) {
7
+ return currentIndex;
8
+ }
9
+ return (currentIndex + 1) % queueLength;
10
+ }
11
+ /**
12
+ * Calculate the previous session index with cyclic wrap-around.
13
+ * Returns current index if queue has <= 1 item.
14
+ */
15
+ export function getPrevSessionIndex(currentIndex, queueLength) {
16
+ if (queueLength <= 1) {
17
+ return currentIndex;
18
+ }
19
+ return (currentIndex - 1 + queueLength) % queueLength;
20
+ }
21
+ /**
22
+ * Validate and return the target index for a direct jump (1-based input).
23
+ * Returns null if the jump is invalid (out of range, same as current).
24
+ */
25
+ export function getDirectJumpIndex(keyNumber, currentIndex, queueLength) {
26
+ if (keyNumber < 1 || keyNumber > 9) {
27
+ return null;
28
+ }
29
+ const targetIndex = keyNumber - 1;
30
+ if (targetIndex >= queueLength) {
31
+ return null;
32
+ }
33
+ if (targetIndex === currentIndex) {
34
+ return null;
35
+ }
36
+ return targetIndex;
37
+ }
38
+ /**
39
+ * Calculate the new active session index after removing a session.
40
+ * Handles: removal before active, removal at active, removal after active, queue becoming empty.
41
+ */
42
+ export function getAdjustedIndexAfterRemoval(removedIndex, activeIndex, newQueueLength) {
43
+ if (newQueueLength === 0) {
44
+ return 0;
45
+ }
46
+ if (removedIndex < activeIndex) {
47
+ return activeIndex - 1;
48
+ }
49
+ if (removedIndex > activeIndex) {
50
+ return activeIndex;
51
+ }
52
+ if (removedIndex < newQueueLength) {
53
+ return removedIndex;
54
+ }
55
+ return newQueueLength - 1;
56
+ }