markupr 2.1.8 → 2.4.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 (300) hide show
  1. package/README.md +196 -15
  2. package/dist/cli/index.mjs +2000 -0
  3. package/dist/main/index.mjs +743 -220
  4. package/dist/mcp/index.mjs +2719 -0
  5. package/package.json +21 -6
  6. package/.claude/commands/review-feedback.md +0 -47
  7. package/.eslintrc.json +0 -35
  8. package/.github/CODEOWNERS +0 -16
  9. package/.github/FUNDING.yml +0 -1
  10. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -56
  11. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -54
  12. package/.github/PULL_REQUEST_TEMPLATE.md +0 -89
  13. package/.github/dependabot.yml +0 -70
  14. package/.github/workflows/ci.yml +0 -184
  15. package/.github/workflows/deploy-landing.yml +0 -134
  16. package/.github/workflows/nightly.yml +0 -288
  17. package/.github/workflows/release.yml +0 -318
  18. package/CHANGELOG.md +0 -127
  19. package/CLAUDE.md +0 -137
  20. package/CODE_OF_CONDUCT.md +0 -9
  21. package/CONTRIBUTING.md +0 -390
  22. package/PRODUCT_VISION.md +0 -277
  23. package/SECURITY.md +0 -51
  24. package/SIGNING_INSTRUCTIONS.md +0 -284
  25. package/assets/DMG_BACKGROUND_INSTRUCTIONS.md +0 -130
  26. package/assets/svg-source/dmg-background.svg +0 -70
  27. package/assets/svg-source/icon.svg +0 -20
  28. package/assets/svg-source/tray-icon-processing.svg +0 -7
  29. package/assets/svg-source/tray-icon-recording.svg +0 -7
  30. package/assets/svg-source/tray-icon.svg +0 -6
  31. package/assets/tray-complete.png +0 -0
  32. package/assets/tray-complete@2x.png +0 -0
  33. package/assets/tray-completeTemplate.png +0 -0
  34. package/assets/tray-completeTemplate@2x.png +0 -0
  35. package/assets/tray-error.png +0 -0
  36. package/assets/tray-error@2x.png +0 -0
  37. package/assets/tray-errorTemplate.png +0 -0
  38. package/assets/tray-errorTemplate@2x.png +0 -0
  39. package/assets/tray-icon-processing.png +0 -0
  40. package/assets/tray-icon-processing@2x.png +0 -0
  41. package/assets/tray-icon-processingTemplate.png +0 -0
  42. package/assets/tray-icon-processingTemplate@2x.png +0 -0
  43. package/assets/tray-icon-recording.png +0 -0
  44. package/assets/tray-icon-recording@2x.png +0 -0
  45. package/assets/tray-icon-recordingTemplate.png +0 -0
  46. package/assets/tray-icon-recordingTemplate@2x.png +0 -0
  47. package/assets/tray-icon.png +0 -0
  48. package/assets/tray-icon@2x.png +0 -0
  49. package/assets/tray-iconTemplate.png +0 -0
  50. package/assets/tray-iconTemplate@2x.png +0 -0
  51. package/assets/tray-idle.png +0 -0
  52. package/assets/tray-idle@2x.png +0 -0
  53. package/assets/tray-idleTemplate.png +0 -0
  54. package/assets/tray-idleTemplate@2x.png +0 -0
  55. package/assets/tray-processing-0.png +0 -0
  56. package/assets/tray-processing-0@2x.png +0 -0
  57. package/assets/tray-processing-0Template.png +0 -0
  58. package/assets/tray-processing-0Template@2x.png +0 -0
  59. package/assets/tray-processing-1.png +0 -0
  60. package/assets/tray-processing-1@2x.png +0 -0
  61. package/assets/tray-processing-1Template.png +0 -0
  62. package/assets/tray-processing-1Template@2x.png +0 -0
  63. package/assets/tray-processing-2.png +0 -0
  64. package/assets/tray-processing-2@2x.png +0 -0
  65. package/assets/tray-processing-2Template.png +0 -0
  66. package/assets/tray-processing-2Template@2x.png +0 -0
  67. package/assets/tray-processing-3.png +0 -0
  68. package/assets/tray-processing-3@2x.png +0 -0
  69. package/assets/tray-processing-3Template.png +0 -0
  70. package/assets/tray-processing-3Template@2x.png +0 -0
  71. package/assets/tray-processing.png +0 -0
  72. package/assets/tray-processing@2x.png +0 -0
  73. package/assets/tray-processingTemplate.png +0 -0
  74. package/assets/tray-processingTemplate@2x.png +0 -0
  75. package/assets/tray-recording.png +0 -0
  76. package/assets/tray-recording@2x.png +0 -0
  77. package/assets/tray-recordingTemplate.png +0 -0
  78. package/assets/tray-recordingTemplate@2x.png +0 -0
  79. package/build/DMG_BACKGROUND_SPEC.md +0 -50
  80. package/build/dmg-background.png +0 -0
  81. package/build/dmg-background@2x.png +0 -0
  82. package/build/entitlements.mac.inherit.plist +0 -27
  83. package/build/entitlements.mac.plist +0 -41
  84. package/build/favicon-16.png +0 -0
  85. package/build/favicon-180.png +0 -0
  86. package/build/favicon-192.png +0 -0
  87. package/build/favicon-32.png +0 -0
  88. package/build/favicon-48.png +0 -0
  89. package/build/favicon-512.png +0 -0
  90. package/build/favicon-64.png +0 -0
  91. package/build/icon-128.png +0 -0
  92. package/build/icon-16.png +0 -0
  93. package/build/icon-24.png +0 -0
  94. package/build/icon-256.png +0 -0
  95. package/build/icon-32.png +0 -0
  96. package/build/icon-48.png +0 -0
  97. package/build/icon-64.png +0 -0
  98. package/build/icon.icns +0 -0
  99. package/build/icon.ico +0 -0
  100. package/build/icon.iconset/icon_128x128.png +0 -0
  101. package/build/icon.iconset/icon_128x128@2x.png +0 -0
  102. package/build/icon.iconset/icon_16x16.png +0 -0
  103. package/build/icon.iconset/icon_16x16@2x.png +0 -0
  104. package/build/icon.iconset/icon_256x256.png +0 -0
  105. package/build/icon.iconset/icon_256x256@2x.png +0 -0
  106. package/build/icon.iconset/icon_32x32.png +0 -0
  107. package/build/icon.iconset/icon_32x32@2x.png +0 -0
  108. package/build/icon.iconset/icon_512x512.png +0 -0
  109. package/build/icon.iconset/icon_512x512@2x.png +0 -0
  110. package/build/icon.png +0 -0
  111. package/build/installer-header.bmp +0 -0
  112. package/build/installer-header.png +0 -0
  113. package/build/installer-sidebar.bmp +0 -0
  114. package/build/installer-sidebar.png +0 -0
  115. package/build/installer.nsh +0 -45
  116. package/build/overlay-processing.png +0 -0
  117. package/build/overlay-recording.png +0 -0
  118. package/build/toolbar-record.png +0 -0
  119. package/build/toolbar-screenshot.png +0 -0
  120. package/build/toolbar-settings.png +0 -0
  121. package/build/toolbar-stop.png +0 -0
  122. package/dist/preload/index.mjs +0 -907
  123. package/dist/renderer/assets/index-CCmUjl9K.js +0 -19495
  124. package/dist/renderer/assets/index-CUqz_Gs6.css +0 -2270
  125. package/dist/renderer/index.html +0 -27
  126. package/docs/AI_AGENT_QUICKSTART.md +0 -42
  127. package/docs/AI_PIPELINE_DESIGN.md +0 -595
  128. package/docs/API.md +0 -514
  129. package/docs/ARCHITECTURE.md +0 -460
  130. package/docs/CONFIGURATION.md +0 -336
  131. package/docs/DEVELOPMENT.md +0 -508
  132. package/docs/EXPORT_FORMATS.md +0 -451
  133. package/docs/GETTING_STARTED.md +0 -236
  134. package/docs/KEYBOARD_SHORTCUTS.md +0 -334
  135. package/docs/TROUBLESHOOTING.md +0 -418
  136. package/docs/landing/index.html +0 -672
  137. package/docs/landing/script.js +0 -342
  138. package/docs/landing/styles.css +0 -1543
  139. package/electron-builder.yml +0 -140
  140. package/electron.vite.config.ts +0 -63
  141. package/railway.json +0 -12
  142. package/scripts/build.mjs +0 -51
  143. package/scripts/generate-icons.mjs +0 -314
  144. package/scripts/generate-installer-images.cjs +0 -253
  145. package/scripts/generate-tray-icons.mjs +0 -258
  146. package/scripts/notarize.cjs +0 -180
  147. package/scripts/one-click-clean-test.sh +0 -147
  148. package/scripts/postinstall.mjs +0 -36
  149. package/scripts/setup-markupr.sh +0 -55
  150. package/setup +0 -17
  151. package/site/index.html +0 -1835
  152. package/site/package.json +0 -11
  153. package/site/railway.json +0 -12
  154. package/site/server.js +0 -31
  155. package/src/main/AutoUpdater.ts +0 -392
  156. package/src/main/CrashRecovery.ts +0 -655
  157. package/src/main/ErrorHandler.ts +0 -703
  158. package/src/main/HotkeyManager.ts +0 -399
  159. package/src/main/MenuManager.ts +0 -529
  160. package/src/main/PermissionManager.ts +0 -420
  161. package/src/main/SessionController.ts +0 -1465
  162. package/src/main/TrayManager.ts +0 -540
  163. package/src/main/ai/AIPipelineManager.ts +0 -199
  164. package/src/main/ai/ClaudeAnalyzer.ts +0 -339
  165. package/src/main/ai/ImageOptimizer.ts +0 -176
  166. package/src/main/ai/StructuredMarkdownBuilder.ts +0 -379
  167. package/src/main/ai/index.ts +0 -16
  168. package/src/main/ai/types.ts +0 -258
  169. package/src/main/analysis/ClarificationGenerator.ts +0 -385
  170. package/src/main/analysis/FeedbackAnalyzer.ts +0 -531
  171. package/src/main/analysis/index.ts +0 -19
  172. package/src/main/audio/AudioCapture.ts +0 -978
  173. package/src/main/audio/audioUtils.ts +0 -100
  174. package/src/main/audio/index.ts +0 -20
  175. package/src/main/capture/index.ts +0 -1
  176. package/src/main/index.ts +0 -1693
  177. package/src/main/ipc/captureHandlers.ts +0 -272
  178. package/src/main/ipc/index.ts +0 -45
  179. package/src/main/ipc/outputHandlers.ts +0 -302
  180. package/src/main/ipc/sessionHandlers.ts +0 -56
  181. package/src/main/ipc/settingsHandlers.ts +0 -471
  182. package/src/main/ipc/types.ts +0 -56
  183. package/src/main/ipc/windowHandlers.ts +0 -277
  184. package/src/main/output/ClipboardService.ts +0 -369
  185. package/src/main/output/ExportService.ts +0 -539
  186. package/src/main/output/FileManager.ts +0 -416
  187. package/src/main/output/MarkdownGenerator.ts +0 -791
  188. package/src/main/output/MarkdownPatcher.ts +0 -299
  189. package/src/main/output/index.ts +0 -186
  190. package/src/main/output/sessionAdapter.ts +0 -207
  191. package/src/main/output/templates/html-template.ts +0 -553
  192. package/src/main/pipeline/FrameExtractor.ts +0 -330
  193. package/src/main/pipeline/PostProcessor.ts +0 -399
  194. package/src/main/pipeline/TranscriptAnalyzer.ts +0 -226
  195. package/src/main/pipeline/index.ts +0 -36
  196. package/src/main/platform/WindowsTaskbar.ts +0 -600
  197. package/src/main/platform/index.ts +0 -16
  198. package/src/main/settings/SettingsManager.ts +0 -730
  199. package/src/main/settings/index.ts +0 -19
  200. package/src/main/transcription/ModelDownloadManager.ts +0 -494
  201. package/src/main/transcription/TierManager.ts +0 -219
  202. package/src/main/transcription/TranscriptionRecoveryService.ts +0 -340
  203. package/src/main/transcription/WhisperService.ts +0 -748
  204. package/src/main/transcription/index.ts +0 -56
  205. package/src/main/transcription/types.ts +0 -135
  206. package/src/main/windows/PopoverManager.ts +0 -284
  207. package/src/main/windows/TaskbarIntegration.ts +0 -452
  208. package/src/main/windows/index.ts +0 -23
  209. package/src/preload/index.ts +0 -1047
  210. package/src/renderer/App.tsx +0 -515
  211. package/src/renderer/AppWrapper.tsx +0 -28
  212. package/src/renderer/assets/logo-dark.svg +0 -7
  213. package/src/renderer/assets/logo.svg +0 -7
  214. package/src/renderer/audio/AudioCaptureRenderer.ts +0 -454
  215. package/src/renderer/capture/ScreenRecordingRenderer.ts +0 -492
  216. package/src/renderer/components/AnnotationOverlay.tsx +0 -836
  217. package/src/renderer/components/AudioWaveform.tsx +0 -811
  218. package/src/renderer/components/ClarificationQuestions.tsx +0 -656
  219. package/src/renderer/components/CountdownTimer.tsx +0 -495
  220. package/src/renderer/components/CrashRecoveryDialog.tsx +0 -632
  221. package/src/renderer/components/DonateButton.tsx +0 -127
  222. package/src/renderer/components/ErrorBoundary.tsx +0 -308
  223. package/src/renderer/components/ExportDialog.tsx +0 -872
  224. package/src/renderer/components/HotkeyHint.tsx +0 -261
  225. package/src/renderer/components/KeyboardShortcuts.tsx +0 -787
  226. package/src/renderer/components/ModelDownloadDialog.tsx +0 -844
  227. package/src/renderer/components/Onboarding.tsx +0 -1830
  228. package/src/renderer/components/ProcessingOverlay.tsx +0 -157
  229. package/src/renderer/components/RecordingOverlay.tsx +0 -423
  230. package/src/renderer/components/SessionHistory.tsx +0 -1746
  231. package/src/renderer/components/SessionReview.tsx +0 -1321
  232. package/src/renderer/components/SettingsPanel.tsx +0 -217
  233. package/src/renderer/components/Skeleton.tsx +0 -347
  234. package/src/renderer/components/StatusIndicator.tsx +0 -86
  235. package/src/renderer/components/ThemeProvider.tsx +0 -429
  236. package/src/renderer/components/Tooltip.tsx +0 -370
  237. package/src/renderer/components/TranscriptionPreview.tsx +0 -183
  238. package/src/renderer/components/TranscriptionTierSelector.tsx +0 -640
  239. package/src/renderer/components/UpdateNotification.tsx +0 -377
  240. package/src/renderer/components/WindowSelector.tsx +0 -947
  241. package/src/renderer/components/index.ts +0 -99
  242. package/src/renderer/components/primitives/ApiKeyInput.tsx +0 -98
  243. package/src/renderer/components/primitives/ColorPicker.tsx +0 -65
  244. package/src/renderer/components/primitives/DangerButton.tsx +0 -45
  245. package/src/renderer/components/primitives/DirectoryPicker.tsx +0 -41
  246. package/src/renderer/components/primitives/Dropdown.tsx +0 -34
  247. package/src/renderer/components/primitives/KeyRecorder.tsx +0 -117
  248. package/src/renderer/components/primitives/SettingsSection.tsx +0 -32
  249. package/src/renderer/components/primitives/Slider.tsx +0 -43
  250. package/src/renderer/components/primitives/Toggle.tsx +0 -36
  251. package/src/renderer/components/primitives/index.ts +0 -10
  252. package/src/renderer/components/settings/AdvancedTab.tsx +0 -174
  253. package/src/renderer/components/settings/AppearanceTab.tsx +0 -77
  254. package/src/renderer/components/settings/GeneralTab.tsx +0 -40
  255. package/src/renderer/components/settings/HotkeysTab.tsx +0 -79
  256. package/src/renderer/components/settings/RecordingTab.tsx +0 -84
  257. package/src/renderer/components/settings/index.ts +0 -9
  258. package/src/renderer/components/settings/settingsStyles.ts +0 -673
  259. package/src/renderer/components/settings/tabConfig.tsx +0 -85
  260. package/src/renderer/components/settings/useSettingsPanel.ts +0 -447
  261. package/src/renderer/contexts/ProcessingContext.tsx +0 -227
  262. package/src/renderer/contexts/RecordingContext.tsx +0 -683
  263. package/src/renderer/contexts/UIContext.tsx +0 -326
  264. package/src/renderer/contexts/index.ts +0 -24
  265. package/src/renderer/donateMessages.ts +0 -69
  266. package/src/renderer/hooks/index.ts +0 -75
  267. package/src/renderer/hooks/useAnimation.tsx +0 -544
  268. package/src/renderer/hooks/useTheme.ts +0 -313
  269. package/src/renderer/index.html +0 -26
  270. package/src/renderer/main.tsx +0 -52
  271. package/src/renderer/styles/animations.css +0 -1093
  272. package/src/renderer/styles/app-shell.css +0 -662
  273. package/src/renderer/styles/globals.css +0 -515
  274. package/src/renderer/styles/theme.ts +0 -578
  275. package/src/renderer/types/electron.d.ts +0 -385
  276. package/src/shared/hotkeys.ts +0 -283
  277. package/src/shared/types.ts +0 -809
  278. package/tests/clipboard.test.ts +0 -228
  279. package/tests/e2e/criticalPaths.test.ts +0 -594
  280. package/tests/feedbackAnalyzer.test.ts +0 -303
  281. package/tests/integration/sessionFlow.test.ts +0 -583
  282. package/tests/markdownGenerator.test.ts +0 -418
  283. package/tests/output.test.ts +0 -96
  284. package/tests/setup.ts +0 -486
  285. package/tests/unit/appIntegration.test.ts +0 -676
  286. package/tests/unit/appViewState.test.ts +0 -281
  287. package/tests/unit/audioIpcChannels.test.ts +0 -17
  288. package/tests/unit/exportService.test.ts +0 -492
  289. package/tests/unit/hotkeys.test.ts +0 -92
  290. package/tests/unit/navigationPreload.test.ts +0 -94
  291. package/tests/unit/onboardingFlow.test.ts +0 -345
  292. package/tests/unit/permissionManager.test.ts +0 -175
  293. package/tests/unit/permissionManagerExpanded.test.ts +0 -296
  294. package/tests/unit/screenRecordingRenderer.test.ts +0 -368
  295. package/tests/unit/sessionController.test.ts +0 -515
  296. package/tests/unit/tierManager.test.ts +0 -61
  297. package/tests/unit/tierManagerExpanded.test.ts +0 -142
  298. package/tests/unit/transcriptAnalyzer.test.ts +0 -64
  299. package/tsconfig.json +0 -25
  300. package/vitest.config.ts +0 -46
@@ -1,258 +0,0 @@
1
- /**
2
- * AI Pipeline Types
3
- *
4
- * Type definitions for the AI analysis pipeline that transforms raw session data
5
- * (transcript + screenshots) into structured, actionable feedback documents using Claude.
6
- */
7
-
8
- import type { Session } from '../SessionController';
9
-
10
- // =============================================================================
11
- // Tier & Configuration
12
- // =============================================================================
13
-
14
- /**
15
- * AI analysis tier determining which pipeline is used.
16
- * - 'free': Rule-based analysis (existing pipeline, no API call)
17
- * - 'byok': User's own Anthropic API key stored in OS keychain
18
- * - 'premium': Proxied through markupr's Cloudflare Worker
19
- */
20
- export type AITier = 'free' | 'byok' | 'premium';
21
-
22
- /**
23
- * Options for the ImageOptimizer.
24
- */
25
- export interface ImageOptimizeOptions {
26
- /** Max width in pixels. Claude recommends 1568px on longest edge. */
27
- maxWidth: number;
28
- /** JPEG quality (0-100) when converting from PNG. */
29
- jpegQuality: number;
30
- /** Size threshold in bytes above which PNG is converted to JPEG. */
31
- pngToJpegThreshold: number;
32
- /** Maximum number of screenshots to send to the API. */
33
- maxScreenshots: number;
34
- }
35
-
36
- export const DEFAULT_IMAGE_OPTIMIZE_OPTIONS: ImageOptimizeOptions = {
37
- maxWidth: 1568,
38
- jpegQuality: 80,
39
- pngToJpegThreshold: 500 * 1024, // 500KB
40
- maxScreenshots: 20,
41
- };
42
-
43
- /**
44
- * Options for ClaudeAnalyzer.
45
- */
46
- export interface ClaudeAnalyzerOptions {
47
- /** Claude model ID. */
48
- model: string;
49
- /** Maximum output tokens. */
50
- maxTokens: number;
51
- /** Sampling temperature (0-1). Lower = more deterministic. */
52
- temperature: number;
53
- /** API request timeout in milliseconds. */
54
- timeoutMs: number;
55
- }
56
-
57
- export const DEFAULT_CLAUDE_ANALYZER_OPTIONS: ClaudeAnalyzerOptions = {
58
- model: 'claude-sonnet-4-5-20250929',
59
- maxTokens: 4096,
60
- temperature: 0.3,
61
- timeoutMs: 30_000,
62
- };
63
-
64
- /**
65
- * Top-level options for the AI pipeline.
66
- */
67
- export interface AIPipelineOptions {
68
- /** Which tier to use for analysis. */
69
- tier: AITier;
70
- /** Anthropic API key (required for 'byok' and 'premium' tiers). */
71
- apiKey?: string;
72
- /** Base URL for the Anthropic API (overridden for premium proxy). */
73
- baseUrl?: string;
74
- /** Image optimization settings. */
75
- imageOptions?: Partial<ImageOptimizeOptions>;
76
- /** Claude analyzer settings. */
77
- analyzerOptions?: Partial<ClaudeAnalyzerOptions>;
78
- }
79
-
80
- // =============================================================================
81
- // AI Analysis Result (Claude's structured output)
82
- // =============================================================================
83
-
84
- /**
85
- * Category assigned by Claude to each feedback item.
86
- */
87
- export type AIFeedbackCategory =
88
- | 'Bug'
89
- | 'UX Issue'
90
- | 'Performance'
91
- | 'Suggestion'
92
- | 'Question'
93
- | 'Positive Note';
94
-
95
- /**
96
- * Priority level assigned by Claude.
97
- */
98
- export type AIFeedbackPriority = 'Critical' | 'High' | 'Medium' | 'Low';
99
-
100
- /**
101
- * A single feedback item from AI analysis.
102
- * Maps directly to the JSON schema in the Claude system prompt.
103
- */
104
- export interface AIFeedbackItem {
105
- /** Short descriptive title (5-10 words). */
106
- title: string;
107
- /** Feedback category. */
108
- category: AIFeedbackCategory;
109
- /** Priority level. */
110
- priority: AIFeedbackPriority;
111
- /** User's exact words (relevant excerpt). */
112
- quote: string;
113
- /** Indices of related screenshots (0-based). */
114
- screenshotIndices: number[];
115
- /** Concrete 1-sentence action for a developer. */
116
- actionItem: string;
117
- /** Component or area of the app this relates to. */
118
- area: string;
119
- }
120
-
121
- /**
122
- * Metadata summary included in the AI analysis result.
123
- */
124
- export interface AIAnalysisMetadata {
125
- totalItems: number;
126
- criticalCount: number;
127
- highCount: number;
128
- }
129
-
130
- /**
131
- * The complete structured output from Claude's analysis.
132
- * This is the JSON response parsed from the API call.
133
- */
134
- export interface AIAnalysisResult {
135
- /** 2-3 sentence overview of key findings. */
136
- summary: string;
137
- /** Individual feedback items with categories, priorities, and actions. */
138
- items: AIFeedbackItem[];
139
- /** Cross-cutting themes identified across feedback. */
140
- themes: string[];
141
- /** Things the user explicitly praised. */
142
- positiveNotes: string[];
143
- /** Summary counts. */
144
- metadata: AIAnalysisMetadata;
145
- }
146
-
147
- // =============================================================================
148
- // Optimized Image (output of ImageOptimizer)
149
- // =============================================================================
150
-
151
- /**
152
- * Media type for images sent to the Claude API.
153
- */
154
- export type ImageMediaType = 'image/png' | 'image/jpeg';
155
-
156
- /**
157
- * An optimized image ready to be sent to the Claude Vision API.
158
- */
159
- export interface OptimizedImage {
160
- /** The image data buffer (resized and possibly re-encoded). */
161
- data: Buffer;
162
- /** MIME type of the image data. */
163
- mediaType: ImageMediaType;
164
- /** Original screenshot this was optimized from. */
165
- originalScreenshotId: string;
166
- /** Width after resize. */
167
- width: number;
168
- /** Height after resize. */
169
- height: number;
170
- }
171
-
172
- // =============================================================================
173
- // Pipeline Progress & Errors
174
- // =============================================================================
175
-
176
- /**
177
- * Progress stages emitted during AI pipeline processing.
178
- */
179
- export type AIPipelineStage =
180
- | 'optimizing-images'
181
- | 'building-prompt'
182
- | 'calling-api'
183
- | 'parsing-response'
184
- | 'building-markdown'
185
- | 'complete'
186
- | 'error'
187
- | 'fallback';
188
-
189
- /**
190
- * Progress event emitted to the renderer during processing.
191
- */
192
- export interface AIPipelineProgress {
193
- stage: AIPipelineStage;
194
- message: string;
195
- /** 0-100 progress percentage (approximate). */
196
- percent: number;
197
- }
198
-
199
- /**
200
- * Typed error codes for AI pipeline failures.
201
- */
202
- export type AIPipelineErrorCode =
203
- | 'API_TIMEOUT'
204
- | 'API_AUTH_ERROR'
205
- | 'API_RATE_LIMIT'
206
- | 'API_SERVER_ERROR'
207
- | 'NETWORK_OFFLINE'
208
- | 'INVALID_RESPONSE'
209
- | 'IMAGE_OPTIMIZATION_FAILED'
210
- | 'UNKNOWN';
211
-
212
- /**
213
- * Structured error from the AI pipeline.
214
- */
215
- export class AIPipelineError extends Error {
216
- constructor(
217
- message: string,
218
- public readonly code: AIPipelineErrorCode,
219
- public readonly cause?: Error,
220
- ) {
221
- super(message);
222
- this.name = 'AIPipelineError';
223
- }
224
- }
225
-
226
- // =============================================================================
227
- // Pipeline Input/Output
228
- // =============================================================================
229
-
230
- /**
231
- * Input to the AI pipeline — the raw session data.
232
- * Re-exported for convenience; the pipeline accepts the Session from SessionController.
233
- */
234
- export type AIPipelineInput = Session;
235
-
236
- /**
237
- * Output from the AI pipeline — either AI-enhanced or fallback markdown.
238
- */
239
- export interface AIPipelineOutput {
240
- /** The final formatted markdown document. */
241
- markdown: string;
242
- /** Whether AI analysis was used (vs. free tier fallback). */
243
- aiEnhanced: boolean;
244
- /** The raw analysis result (only present when aiEnhanced is true). */
245
- analysis?: AIAnalysisResult;
246
- /** Processing duration in milliseconds. */
247
- processingTimeMs: number;
248
- /** Which tier was used. */
249
- tier: AITier;
250
- /** Error info if AI failed and fell back to free tier. */
251
- fallbackReason?: string;
252
- }
253
-
254
- // =============================================================================
255
- // Re-exports for convenience
256
- // =============================================================================
257
-
258
- export type { Screenshot, Session } from '../SessionController';
@@ -1,385 +0,0 @@
1
- /**
2
- * ClarificationGenerator - Smart Question Generation for Ambiguous Feedback
3
- *
4
- * Detects vague or unclear feedback and generates targeted clarification questions
5
- * to help users provide more actionable context.
6
- *
7
- * Detection patterns:
8
- * - Pronouns without clear antecedent: "this", "that", "it"
9
- * - Vague locations: "here", "there", "somewhere"
10
- * - Unclear references: "the button", "the form" without specifics
11
- * - Time references: "sometimes", "occasionally", "usually"
12
- * - Vague comparisons: "too slow", "very small"
13
- *
14
- * Questions are skippable and answers are appended to feedback items.
15
- */
16
-
17
- import type { FeedbackItem } from '../output/MarkdownGenerator';
18
-
19
- // =============================================================================
20
- // Types
21
- // =============================================================================
22
-
23
- /**
24
- * Type of clarification needed
25
- */
26
- export type ClarificationType =
27
- | 'location'
28
- | 'reproduction'
29
- | 'expectation'
30
- | 'frequency'
31
- | 'reference'
32
- | 'comparison';
33
-
34
- /**
35
- * A single clarification question
36
- */
37
- export interface ClarificationQuestion {
38
- id: string;
39
- feedbackItemId: string;
40
- question: string;
41
- type: ClarificationType;
42
- placeholder: string;
43
- /** Optional: the matched text that triggered this question */
44
- matchedText?: string;
45
- }
46
-
47
- /**
48
- * Answer to a clarification question
49
- */
50
- export interface ClarificationAnswer {
51
- questionId: string;
52
- feedbackItemId: string;
53
- answer: string;
54
- }
55
-
56
- /**
57
- * Result of applying clarification answers to feedback
58
- */
59
- export interface ClarifiedFeedback {
60
- feedbackItems: FeedbackItem[];
61
- clarifications: ClarificationAnswer[];
62
- }
63
-
64
- // =============================================================================
65
- // Pattern Definitions
66
- // =============================================================================
67
-
68
- interface AmbiguityPattern {
69
- pattern: RegExp;
70
- type: ClarificationType;
71
- question: string;
72
- placeholder: string;
73
- /** Weight for prioritization (higher = more likely to ask) */
74
- weight: number;
75
- }
76
-
77
- /**
78
- * Patterns for detecting ambiguity in feedback text
79
- *
80
- * Note: Patterns use negative lookahead to avoid false positives where
81
- * the meaning is actually clear (e.g., "it doesn't work" is clear enough)
82
- */
83
- const AMBIGUITY_PATTERNS: AmbiguityPattern[] = [
84
- // Vague pronouns (when not part of common clear phrases)
85
- {
86
- pattern: /\b(this|that)\b(?!\s+(is|was|should|could|would|doesn't|does not|isn't|is not)\s)/gi,
87
- type: 'reference',
88
- question: 'What specifically are you referring to?',
89
- placeholder: 'e.g., "the save button in the header"',
90
- weight: 0.8,
91
- },
92
- {
93
- pattern: /\bit\b(?!\s+(is|was|should|could|would|doesn't|does not|works|worked))/gi,
94
- type: 'reference',
95
- question: 'What specifically does "it" refer to?',
96
- placeholder: 'e.g., "the file upload component"',
97
- weight: 0.6,
98
- },
99
-
100
- // Vague locations
101
- {
102
- pattern: /\b(here|there)\b(?!\s+(is|are|was|were)\s+(no|nothing|a|an|the))/gi,
103
- type: 'location',
104
- question: 'Where exactly in the interface?',
105
- placeholder: 'e.g., "top right corner of the settings page"',
106
- weight: 0.85,
107
- },
108
- {
109
- pattern: /\bsomewhere\b/gi,
110
- type: 'location',
111
- question: 'Can you describe where more specifically?',
112
- placeholder: 'e.g., "in the navigation menu, maybe under settings"',
113
- weight: 0.9,
114
- },
115
-
116
- // Unclear element references (without labels/names)
117
- {
118
- pattern: /\bthe\s+(button|link)\b(?!\s+(labeled|called|named|titled|that says|with|for))/gi,
119
- type: 'reference',
120
- question: 'Which button/link specifically?',
121
- placeholder: 'e.g., "the blue Submit button at the bottom of the form"',
122
- weight: 0.75,
123
- },
124
- {
125
- pattern: /\bthe\s+(form|field|input)\b(?!\s+(labeled|called|named|titled|for|where))/gi,
126
- type: 'reference',
127
- question: 'Which form/field specifically?',
128
- placeholder: 'e.g., "the email input field in the signup form"',
129
- weight: 0.75,
130
- },
131
- {
132
- pattern: /\bthe\s+(menu|dropdown|select)\b(?!\s+(labeled|called|named|titled|for|with))/gi,
133
- type: 'reference',
134
- question: 'Which menu/dropdown specifically?',
135
- placeholder: 'e.g., "the file type dropdown in the export dialog"',
136
- weight: 0.75,
137
- },
138
- {
139
- pattern: /\bthe\s+(modal|dialog|popup|panel)\b(?!\s+(labeled|called|named|titled|that))/gi,
140
- type: 'reference',
141
- question: 'Which modal/dialog specifically?',
142
- placeholder: 'e.g., "the confirmation dialog after clicking delete"',
143
- weight: 0.75,
144
- },
145
- {
146
- pattern: /\bthe\s+(page|screen|section)\b(?!\s+(labeled|called|named|titled|where|for))/gi,
147
- type: 'location',
148
- question: 'Which page/screen specifically?',
149
- placeholder: 'e.g., "the user profile settings page"',
150
- weight: 0.7,
151
- },
152
-
153
- // Intermittent issues (frequency unclear)
154
- {
155
- pattern: /\b(sometimes|occasionally|usually|often|rarely|every now and then)\b/gi,
156
- type: 'frequency',
157
- question: 'How often does this happen?',
158
- placeholder: 'e.g., "about 1 in 3 times when saving" or "only on first load"',
159
- weight: 0.9,
160
- },
161
- {
162
- pattern: /\b(intermittent(ly)?|sporadic(ally)?|random(ly)?)\b/gi,
163
- type: 'frequency',
164
- question: 'Can you estimate how frequently this occurs?',
165
- placeholder: 'e.g., "maybe 20% of the time" or "after about 5 minutes of use"',
166
- weight: 0.85,
167
- },
168
-
169
- // Vague comparisons
170
- {
171
- pattern: /\b(too|very|quite|rather|extremely)\s+(slow|fast|big|small|large|tiny|long|short)\b/gi,
172
- type: 'comparison',
173
- question: 'Can you be more specific about the expected behavior?',
174
- placeholder: 'e.g., "should load in under 2 seconds" or "should be at least 200px wide"',
175
- weight: 0.7,
176
- },
177
- {
178
- pattern: /\btakes\s+(forever|too long|a while|ages)\b/gi,
179
- type: 'comparison',
180
- question: 'How long does it actually take, and how long should it take?',
181
- placeholder: 'e.g., "takes 10 seconds but should be instant"',
182
- weight: 0.8,
183
- },
184
- ];
185
-
186
- /**
187
- * Questions for specific feedback categories (asked when no patterns match)
188
- */
189
- const CATEGORY_QUESTIONS: Record<string, { question: string; placeholder: string; type: ClarificationType }> = {
190
- bug: {
191
- question: 'What steps led to this issue?',
192
- type: 'reproduction',
193
- placeholder: 'e.g., "After clicking submit, then going back..."',
194
- },
195
- 'ux-issue': {
196
- question: 'What would be a better experience?',
197
- type: 'expectation',
198
- placeholder: 'e.g., "I expected to see a confirmation before deleting"',
199
- },
200
- suggestion: {
201
- question: 'How should it work ideally?',
202
- type: 'expectation',
203
- placeholder: 'e.g., "It should save automatically when I switch tabs"',
204
- },
205
- };
206
-
207
- // =============================================================================
208
- // ClarificationGenerator Implementation
209
- // =============================================================================
210
-
211
- class ClarificationGeneratorImpl {
212
- private readonly MAX_QUESTIONS = 5;
213
-
214
- /**
215
- * Generate clarification questions for a list of feedback items.
216
- *
217
- * Returns at most MAX_QUESTIONS to avoid overwhelming the user.
218
- * Questions are prioritized by pattern weight and relevance.
219
- */
220
- generate(feedbackItems: FeedbackItem[]): ClarificationQuestion[] {
221
- const allQuestions: Array<ClarificationQuestion & { weight: number }> = [];
222
-
223
- for (const item of feedbackItems) {
224
- const text = item.transcription;
225
- const itemId = item.id;
226
-
227
- // Track which question types we've already added for this item
228
- const addedTypes = new Set<ClarificationType>();
229
-
230
- // Check each ambiguity pattern
231
- for (const patternDef of AMBIGUITY_PATTERNS) {
232
- // Reset lastIndex for global patterns
233
- patternDef.pattern.lastIndex = 0;
234
-
235
- const match = patternDef.pattern.exec(text);
236
- if (match && !addedTypes.has(patternDef.type)) {
237
- addedTypes.add(patternDef.type);
238
-
239
- allQuestions.push({
240
- id: `${itemId}-${patternDef.type}`,
241
- feedbackItemId: itemId,
242
- question: patternDef.question,
243
- type: patternDef.type,
244
- placeholder: patternDef.placeholder,
245
- matchedText: match[0],
246
- weight: patternDef.weight,
247
- });
248
- }
249
- }
250
-
251
- // Check for category-specific questions
252
- const category = item.category?.toLowerCase().replace(' ', '-');
253
- if (category && CATEGORY_QUESTIONS[category]) {
254
- const categoryQ = CATEGORY_QUESTIONS[category];
255
-
256
- // Only add if we don't have a similar type question already
257
- if (!addedTypes.has(categoryQ.type)) {
258
- // Check if the text already provides the information
259
- const hasReproSteps = /\b(when|after|before|then|first|next|if)\b/i.test(text);
260
- const hasExpectation = /\b(should|expect|instead|ideally|rather|better)\b/i.test(text);
261
-
262
- const shouldSkip =
263
- (categoryQ.type === 'reproduction' && hasReproSteps) ||
264
- (categoryQ.type === 'expectation' && hasExpectation);
265
-
266
- if (!shouldSkip) {
267
- allQuestions.push({
268
- id: `${itemId}-category-${categoryQ.type}`,
269
- feedbackItemId: itemId,
270
- question: categoryQ.question,
271
- type: categoryQ.type,
272
- placeholder: categoryQ.placeholder,
273
- weight: 0.5, // Lower weight for category questions
274
- });
275
- }
276
- }
277
- }
278
- }
279
-
280
- // Sort by weight (higher first) and limit
281
- const sortedQuestions = allQuestions
282
- .sort((a, b) => b.weight - a.weight)
283
- .slice(0, this.MAX_QUESTIONS);
284
-
285
- // Remove the weight property before returning
286
- return sortedQuestions.map(({ weight: _weight, ...q }) => q);
287
- }
288
-
289
- /**
290
- * Apply clarification answers to feedback items.
291
- *
292
- * Answers are appended to the transcription in a structured format:
293
- * [Original text]
294
- *
295
- * **Clarification:**
296
- * - Question: Answer
297
- */
298
- applyClarifications(
299
- feedbackItems: FeedbackItem[],
300
- answers: Record<string, string>
301
- ): ClarifiedFeedback {
302
- const clarifications: ClarificationAnswer[] = [];
303
-
304
- const updatedItems = feedbackItems.map((item) => {
305
- // Find all answers for this item
306
- const itemAnswers: { question: string; answer: string }[] = [];
307
-
308
- for (const [questionId, answer] of Object.entries(answers)) {
309
- // Skip empty answers
310
- if (!answer.trim()) continue;
311
-
312
- // Check if this question belongs to this item
313
- if (questionId.startsWith(item.id)) {
314
- // Extract the question from the ID to find the original question text
315
- const questionType = questionId.replace(`${item.id}-`, '').replace('category-', '');
316
-
317
- // Find the matching pattern or category question
318
- const patternQ = AMBIGUITY_PATTERNS.find((p) => p.type === questionType);
319
- const categoryQ = Object.values(CATEGORY_QUESTIONS).find((q) => q.type === questionType);
320
-
321
- const questionText = patternQ?.question || categoryQ?.question || 'Additional context';
322
-
323
- itemAnswers.push({ question: questionText, answer });
324
-
325
- clarifications.push({
326
- questionId,
327
- feedbackItemId: item.id,
328
- answer,
329
- });
330
- }
331
- }
332
-
333
- // If we have answers, append them to the transcription
334
- if (itemAnswers.length > 0) {
335
- const clarificationText = itemAnswers
336
- .map((qa) => `- ${qa.question} ${qa.answer}`)
337
- .join('\n');
338
-
339
- return {
340
- ...item,
341
- transcription: `${item.transcription}\n\n**Clarification:**\n${clarificationText}`,
342
- };
343
- }
344
-
345
- return item;
346
- });
347
-
348
- return {
349
- feedbackItems: updatedItems,
350
- clarifications,
351
- };
352
- }
353
-
354
- /**
355
- * Check if a feedback item would benefit from clarification.
356
- * Useful for showing a "needs clarification" indicator.
357
- */
358
- needsClarification(item: FeedbackItem): boolean {
359
- const text = item.transcription;
360
-
361
- for (const patternDef of AMBIGUITY_PATTERNS) {
362
- patternDef.pattern.lastIndex = 0;
363
- if (patternDef.pattern.test(text)) {
364
- return true;
365
- }
366
- }
367
-
368
- return false;
369
- }
370
-
371
- /**
372
- * Get the count of items that need clarification.
373
- */
374
- getClarificationCount(feedbackItems: FeedbackItem[]): number {
375
- return feedbackItems.filter((item) => this.needsClarification(item)).length;
376
- }
377
- }
378
-
379
- // =============================================================================
380
- // Singleton Export
381
- // =============================================================================
382
-
383
- export const clarificationGenerator = new ClarificationGeneratorImpl();
384
- export type { ClarificationGeneratorImpl as ClarificationGenerator };
385
- export default clarificationGenerator;