markupr 2.1.8 → 2.5.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 +292 -15
  2. package/dist/cli/index.mjs +3593 -0
  3. package/dist/main/index.mjs +743 -220
  4. package/dist/mcp/index.mjs +4053 -0
  5. package/package.json +32 -7
  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,791 +0,0 @@
1
- /**
2
- * MarkdownGenerator - AI-Ready Output Generator for markupr
3
- *
4
- * Generates structured Markdown documents following llms.txt-inspired format.
5
- * Designed to be easily parsed by AI coding assistants like Claude Code.
6
- *
7
- * Features:
8
- * - Full document with all feedback items, screenshots, and metadata
9
- * - Clipboard summary (<1500 chars) for quick sharing
10
- * - File references for images (no base64 bloat)
11
- * - Consistent FB-XXX item numbering
12
- */
13
-
14
- import * as path from 'path';
15
- import type { FeedbackSession, Screenshot, TranscriptionSegment } from '../../shared/types';
16
- import type { PostProcessResult, TranscriptSegment, ExtractedFrame } from '../pipeline/PostProcessor';
17
-
18
- const REPORT_SUPPORT_LINE = '*If this report saved you time, support development: [Ko-fi](https://ko-fi.com/eddiesanjuan)*';
19
-
20
- // ============================================================================
21
- // Types for Enhanced Output Generation
22
- // ============================================================================
23
-
24
- /**
25
- * Category types for feedback items
26
- */
27
- export type FeedbackCategory = 'Bug' | 'UX Issue' | 'Suggestion' | 'Performance' | 'Question' | 'General';
28
-
29
- /**
30
- * Severity levels for prioritization
31
- */
32
- export type FeedbackSeverity = 'Critical' | 'High' | 'Medium' | 'Low';
33
-
34
- /**
35
- * A single feedback item with transcription and associated screenshots
36
- */
37
- export interface FeedbackItem {
38
- id: string;
39
- transcription: string;
40
- timestamp: number;
41
- screenshots: Screenshot[];
42
- title?: string;
43
- keywords?: string[];
44
- category?: FeedbackCategory;
45
- severity?: FeedbackSeverity;
46
- }
47
-
48
- /**
49
- * Session metadata for context
50
- */
51
- export interface SessionMetadata {
52
- os?: string;
53
- sourceName?: string;
54
- sourceType?: 'screen' | 'window';
55
- }
56
-
57
- /**
58
- * Enhanced session structure for markdown generation
59
- */
60
- export interface Session {
61
- id: string;
62
- startTime: number;
63
- endTime?: number;
64
- feedbackItems: FeedbackItem[];
65
- metadata?: SessionMetadata;
66
- }
67
-
68
- /**
69
- * Options for generating the full markdown document
70
- */
71
- export interface GenerateOptions {
72
- projectName: string;
73
- screenshotDir: string; // Relative path for image references
74
- }
75
-
76
- /**
77
- * The generated markdown document with metadata
78
- */
79
- export interface MarkdownDocument {
80
- content: string;
81
- filename: string;
82
- metadata: {
83
- itemCount: number;
84
- screenshotCount: number;
85
- duration: number;
86
- types: Record<string, number>;
87
- };
88
- }
89
-
90
- /**
91
- * Interface for the MarkdownGenerator
92
- */
93
- export interface IMarkdownGenerator {
94
- generateFullDocument(session: Session, options: GenerateOptions): MarkdownDocument;
95
- generateFromPostProcess(result: PostProcessResult, sessionDir: string): string;
96
- generateClipboardSummary(session: Session, projectName?: string): string;
97
- generateFeedbackItemId(index: number): string;
98
- }
99
-
100
- // ============================================================================
101
- // Adapter: Convert FeedbackSession to Session
102
- // ============================================================================
103
-
104
- /**
105
- * Convert the existing FeedbackSession type to the enhanced Session type.
106
- * Groups transcription segments with their associated screenshots.
107
- */
108
- export function adaptFeedbackSession(
109
- feedbackSession: FeedbackSession,
110
- options?: { pauseThresholdMs?: number }
111
- ): Session {
112
- const pauseThreshold = options?.pauseThresholdMs ?? 1500;
113
- const { id, startedAt, endedAt, screenshots, transcription } = feedbackSession;
114
-
115
- // Group transcription segments into feedback items
116
- // A new item starts when there's a significant pause between segments
117
- const feedbackItems: FeedbackItem[] = [];
118
- let currentItem: FeedbackItem | null = null;
119
-
120
- const sortedTranscription = [...transcription].sort((a, b) => a.startTime - b.startTime);
121
- const sortedScreenshots = [...screenshots].sort((a, b) => a.timestamp - b.timestamp);
122
-
123
- for (const segment of sortedTranscription) {
124
- const shouldStartNewItem =
125
- !currentItem ||
126
- (segment.startTime - (currentItem.timestamp + getPreviousSegmentDuration(currentItem, sortedTranscription))) > pauseThreshold;
127
-
128
- if (shouldStartNewItem) {
129
- // Save previous item
130
- if (currentItem) {
131
- feedbackItems.push(currentItem);
132
- }
133
-
134
- // Start new item
135
- currentItem = {
136
- id: `item-${feedbackItems.length + 1}`,
137
- transcription: segment.text,
138
- timestamp: segment.startTime,
139
- screenshots: [],
140
- category: inferCategory(segment.text),
141
- };
142
- } else if (currentItem) {
143
- // Continue current item
144
- currentItem.transcription += ' ' + segment.text;
145
- }
146
- }
147
-
148
- // Don't forget the last item
149
- if (currentItem) {
150
- feedbackItems.push(currentItem);
151
- }
152
-
153
- // Associate screenshots with feedback items
154
- for (const screenshot of sortedScreenshots) {
155
- // Find the feedback item that this screenshot belongs to
156
- // (screenshot timestamp falls within or just after the item's timeframe)
157
- const matchingItem = findMatchingItem(feedbackItems, screenshot.timestamp, pauseThreshold);
158
- if (matchingItem) {
159
- matchingItem.screenshots.push(screenshot);
160
- } else if (feedbackItems.length > 0) {
161
- // Associate with the last item if no match found
162
- feedbackItems[feedbackItems.length - 1].screenshots.push(screenshot);
163
- }
164
- }
165
-
166
- return {
167
- id,
168
- startTime: startedAt,
169
- endTime: endedAt,
170
- feedbackItems,
171
- metadata: {
172
- os: process?.platform || 'Unknown',
173
- sourceName: 'markupr Session',
174
- sourceType: 'screen',
175
- },
176
- };
177
- }
178
-
179
- function getPreviousSegmentDuration(item: FeedbackItem, _allSegments: TranscriptionSegment[]): number {
180
- // Estimate duration based on transcription length (rough: 150 words/min)
181
- const words = item.transcription.split(/\s+/).length;
182
- return (words / 150) * 60 * 1000; // ms
183
- }
184
-
185
- function findMatchingItem(
186
- items: FeedbackItem[],
187
- timestamp: number,
188
- threshold: number
189
- ): FeedbackItem | undefined {
190
- // Find item where screenshot timestamp is within item timeframe + threshold
191
- for (let i = items.length - 1; i >= 0; i--) {
192
- const item = items[i];
193
- const estimatedDuration = (item.transcription.split(/\s+/).length / 150) * 60 * 1000;
194
- const itemEnd = item.timestamp + estimatedDuration + threshold;
195
-
196
- if (timestamp >= item.timestamp && timestamp <= itemEnd) {
197
- return item;
198
- }
199
- }
200
- return undefined;
201
- }
202
-
203
- function inferCategory(text: string): FeedbackCategory {
204
- const lowerText = text.toLowerCase();
205
-
206
- if (lowerText.includes('bug') || lowerText.includes('broken') || lowerText.includes('error') ||
207
- lowerText.includes('crash') || lowerText.includes('doesn\'t work') || lowerText.includes('not working')) {
208
- return 'Bug';
209
- }
210
-
211
- if (lowerText.includes('confusing') || lowerText.includes('hard to') || lowerText.includes('unclear') ||
212
- lowerText.includes('ux') || lowerText.includes('user experience') || lowerText.includes('usability')) {
213
- return 'UX Issue';
214
- }
215
-
216
- if (lowerText.includes('slow') || lowerText.includes('lag') || lowerText.includes('sluggish') ||
217
- lowerText.includes('performance') || lowerText.includes('latency') || lowerText.includes('janky')) {
218
- return 'Performance';
219
- }
220
-
221
- if (lowerText.includes('should') || lowerText.includes('could') || lowerText.includes('would be nice') ||
222
- lowerText.includes('suggestion') || lowerText.includes('feature') || lowerText.includes('add')) {
223
- return 'Suggestion';
224
- }
225
-
226
- if (lowerText.includes('?') || lowerText.includes('how') || lowerText.includes('why') ||
227
- lowerText.includes('what') || lowerText.includes('question')) {
228
- return 'Question';
229
- }
230
-
231
- return 'General';
232
- }
233
-
234
- // ============================================================================
235
- // MarkdownGenerator Implementation
236
- // ============================================================================
237
-
238
- class MarkdownGeneratorImpl implements IMarkdownGenerator {
239
- /**
240
- * Generate a full markdown document with all feedback items and metadata.
241
- * Follows llms.txt-inspired format for AI readability.
242
- */
243
- generateFullDocument(session: Session, options: GenerateOptions): MarkdownDocument {
244
- const { projectName, screenshotDir } = options;
245
- const items = session.feedbackItems;
246
- const duration = session.endTime
247
- ? this.formatDuration(session.endTime - session.startTime)
248
- : 'In Progress';
249
- const timestamp = this.formatTimestamp(session.endTime || Date.now());
250
- const filename = this.generateFilename(projectName, session.startTime);
251
-
252
- // Early return for empty sessions — produce a clean minimal document
253
- if (items.length === 0) {
254
- const content = `# ${projectName} Feedback Report
255
- > Generated by markupr on ${timestamp}
256
- > Duration: ${duration}
257
-
258
- _No feedback items were captured during this session._
259
-
260
- ---
261
- *Generated by [markupr](https://markupr.com)*
262
- ${REPORT_SUPPORT_LINE}
263
- `;
264
- return {
265
- content,
266
- filename,
267
- metadata: {
268
- itemCount: 0,
269
- screenshotCount: 0,
270
- duration: session.endTime ? session.endTime - session.startTime : 0,
271
- types: {},
272
- },
273
- };
274
- }
275
-
276
- // Count types
277
- const typeCounts = this.countTypes(items);
278
- const severityCounts = this.countSeverities(items);
279
- const screenshotCount = this.countScreenshots(items);
280
- const topThemes = this.extractTopThemes(items);
281
- const highImpactCount = (severityCounts.Critical || 0) + (severityCounts.High || 0);
282
-
283
- let content = `# ${projectName} Feedback Report
284
- > Generated by markupr on ${timestamp}
285
- > Duration: ${duration} | Items: ${items.length} | Screenshots: ${screenshotCount}
286
-
287
- ## Session Overview
288
- - **Session ID:** \`${session.id}\`
289
- - **Source:** ${session.metadata?.sourceName || 'Unknown'} (${session.metadata?.sourceType || 'screen'})
290
- - **Environment:** ${session.metadata?.os || 'Unknown'}
291
- - **High-impact items:** ${highImpactCount}
292
-
293
- ---
294
-
295
- ## Executive Summary
296
-
297
- - ${items.length} total feedback items were captured.
298
- - ${highImpactCount} items are categorized as **Critical** or **High** priority.
299
- - ${screenshotCount} screenshots were aligned to spoken context.
300
- `;
301
-
302
- if (topThemes.length > 0) {
303
- content += `- Top themes: ${topThemes.join(', ')}.\n`;
304
- }
305
-
306
- content += `
307
- ---
308
-
309
- ## Actionable Feedback
310
-
311
- `;
312
-
313
- items.forEach((item, index) => {
314
- const id = this.generateFeedbackItemId(index);
315
- const title = item.title || this.generateTitle(item.transcription);
316
- const itemTimestamp = this.formatItemTimestamp(item.timestamp - session.startTime);
317
- const category = item.category || 'General';
318
- const severity = item.severity || this.defaultSeverityForCategory(category);
319
- const signals = item.keywords?.slice(0, 5) || [];
320
- const suggestedAction = this.suggestAction(category, severity, item.transcription);
321
-
322
- content += `### ${id}: ${title}
323
- - **Severity:** ${severity}
324
- - **Type:** ${category}
325
- - **Timestamp:** ${itemTimestamp}
326
- `;
327
-
328
- if (signals.length > 0) {
329
- content += `- **Signals:** ${signals.join(', ')}\n`;
330
- }
331
-
332
- content += `
333
- #### What Happened
334
-
335
- > ${this.wrapTranscription(item.transcription)}
336
-
337
- `;
338
-
339
- if (item.screenshots.length > 0) {
340
- content += `#### Evidence\n`;
341
- item.screenshots.forEach((ss, ssIndex) => {
342
- // Use the item's position index (not the FB-XXX display ID) for the
343
- // filename so it stays aligned with FileManager.saveSession which
344
- // names files by the original feedbackItems array index.
345
- const screenshotFilename = this.generateScreenshotFilename(index, ssIndex, item.screenshots.length);
346
- content += `![${id}${item.screenshots.length > 1 ? `-${ssIndex + 1}` : ''}](${screenshotDir}/${screenshotFilename})\n\n`;
347
- });
348
- } else {
349
- content += `#### Evidence\n_No screenshot captured for this item._\n\n`;
350
- }
351
-
352
- content += `#### Suggested Next Step
353
- - ${suggestedAction}
354
-
355
- `;
356
-
357
- content += `---
358
-
359
- `;
360
- });
361
-
362
- // Summary tables
363
- content += `## Summary
364
-
365
- | Type | Count |
366
- |------|-------|
367
- `;
368
- Object.entries(typeCounts).forEach(([type, count]) => {
369
- content += `| ${type} | ${count} |\n`;
370
- });
371
- content += `| **Total** | **${items.length}** |\n`;
372
-
373
- content += `
374
- | Severity | Count |
375
- |----------|-------|
376
- `;
377
- Object.entries(severityCounts).forEach(([severity, count]) => {
378
- content += `| ${severity} | ${count} |\n`;
379
- });
380
- content += `| **Total** | **${items.length}** |\n`;
381
-
382
- content += `
383
- ---
384
- *Generated by [markupr](https://markupr.com)*
385
- ${REPORT_SUPPORT_LINE}
386
- `;
387
-
388
- return {
389
- content,
390
- filename,
391
- metadata: {
392
- itemCount: items.length,
393
- screenshotCount,
394
- duration: session.endTime ? session.endTime - session.startTime : 0,
395
- types: typeCounts,
396
- },
397
- };
398
- }
399
-
400
- /**
401
- * Generate markdown from a PostProcessResult (post-recording pipeline output).
402
- *
403
- * Produces a clean, AI-readable document with:
404
- * - Session header with human-readable timestamp
405
- * - Each transcript segment as a heading with [M:SS] timestamp
406
- * - Blockquoted transcript text
407
- * - Associated frame images referenced as relative paths
408
- *
409
- * @param result - The combined transcript + frame output from PostProcessor
410
- * @param sessionDir - Absolute path to the session directory (used to compute relative frame paths)
411
- * @returns The generated markdown string
412
- */
413
- generateFromPostProcess(result: PostProcessResult, sessionDir: string): string {
414
- const { transcriptSegments, extractedFrames } = result;
415
- const now = new Date();
416
- const sessionTimestamp = now.toLocaleString('en-US', {
417
- year: 'numeric',
418
- month: 'short',
419
- day: 'numeric',
420
- hour: '2-digit',
421
- minute: '2-digit',
422
- });
423
-
424
- let md = `# markupr Session — ${sessionTimestamp}\n\n`;
425
-
426
- if (transcriptSegments.length === 0) {
427
- md += `_No speech was detected during this recording._\n`;
428
- return md;
429
- }
430
-
431
- md += `## Transcript\n\n`;
432
-
433
- // Build a map from transcript segment index to associated frames.
434
- // A frame is associated with the segment whose time range contains the
435
- // frame timestamp, or the closest segment by start time.
436
- const segmentFrameMap = this.mapFramesToSegments(transcriptSegments, extractedFrames);
437
-
438
- for (let i = 0; i < transcriptSegments.length; i++) {
439
- const segment = transcriptSegments[i];
440
- const formattedTime = this.formatPostProcessTimestamp(segment.startTime);
441
- const title = this.generateSegmentTitle(segment.text);
442
-
443
- md += `### [${formattedTime}] ${title}\n`;
444
- md += `> ${this.wrapTranscription(segment.text)}\n\n`;
445
-
446
- // Append any frames associated with this segment
447
- const frames = segmentFrameMap.get(i);
448
- if (frames && frames.length > 0) {
449
- for (const frame of frames) {
450
- const frameTimestamp = this.formatPostProcessTimestamp(frame.timestamp);
451
- const relativePath = this.computeRelativeFramePath(frame.path, sessionDir);
452
- md += `![Frame at ${frameTimestamp}](${relativePath})\n\n`;
453
- }
454
- }
455
- }
456
-
457
- md += `---\n*Generated by [markupr](https://markupr.com)*\n${REPORT_SUPPORT_LINE}\n`;
458
-
459
- return md;
460
- }
461
-
462
- /**
463
- * Map extracted frames to their closest transcript segments.
464
- * Returns a Map from segment index to an array of frames.
465
- */
466
- private mapFramesToSegments(
467
- segments: TranscriptSegment[],
468
- frames: ExtractedFrame[]
469
- ): Map<number, ExtractedFrame[]> {
470
- const map = new Map<number, ExtractedFrame[]>();
471
-
472
- for (const frame of frames) {
473
- let bestIndex = 0;
474
- let bestDistance = Infinity;
475
-
476
- for (let i = 0; i < segments.length; i++) {
477
- const seg = segments[i];
478
-
479
- // If the frame timestamp falls within the segment range, it is a direct match
480
- if (frame.timestamp >= seg.startTime && frame.timestamp <= seg.endTime) {
481
- bestIndex = i;
482
- bestDistance = 0;
483
- break;
484
- }
485
-
486
- // Otherwise track the closest segment by start time
487
- const distance = Math.abs(frame.timestamp - seg.startTime);
488
- if (distance < bestDistance) {
489
- bestDistance = distance;
490
- bestIndex = i;
491
- }
492
- }
493
-
494
- const existing = map.get(bestIndex) || [];
495
- existing.push(frame);
496
- map.set(bestIndex, existing);
497
- }
498
-
499
- // Sort frames within each segment by timestamp
500
- for (const [, frameList] of map) {
501
- frameList.sort((a, b) => a.timestamp - b.timestamp);
502
- }
503
-
504
- return map;
505
- }
506
-
507
- /**
508
- * Compute a relative path for a frame image from the session directory.
509
- * If the frame path is already relative, return it as-is.
510
- * If absolute, compute the relative path from sessionDir.
511
- */
512
- private computeRelativeFramePath(framePath: string, sessionDir: string): string {
513
- if (!path.isAbsolute(framePath)) {
514
- return framePath;
515
- }
516
- return path.relative(sessionDir, framePath);
517
- }
518
-
519
- /**
520
- * Format a timestamp in seconds to M:SS format for post-process output.
521
- * Examples: 0 -> "0:00", 15.3 -> "0:15", 125 -> "2:05"
522
- */
523
- private formatPostProcessTimestamp(seconds: number): string {
524
- const totalSeconds = Math.max(0, Math.floor(seconds));
525
- const mins = Math.floor(totalSeconds / 60);
526
- const secs = totalSeconds % 60;
527
- return `${mins}:${secs.toString().padStart(2, '0')}`;
528
- }
529
-
530
- /**
531
- * Generate a short title from transcript text (first sentence, max 60 chars).
532
- */
533
- private generateSegmentTitle(text: string): string {
534
- const firstSentence = text.split(/[.!?]/)[0].trim();
535
- if (firstSentence.length <= 60) return firstSentence;
536
- return firstSentence.slice(0, 57) + '...';
537
- }
538
-
539
- /**
540
- * Generate a clipboard-friendly summary (<1500 chars).
541
- * Includes priority items and a reference to the full report.
542
- */
543
- generateClipboardSummary(session: Session, projectName?: string): string {
544
- const name = projectName || session.metadata?.sourceName || 'Project';
545
- const items = session.feedbackItems;
546
-
547
- let summary = `# Feedback: ${name} - ${items.length} items\n\n`;
548
-
549
- // Priority items (first 3)
550
- const maxPriorityItems = 3;
551
- summary += `## Priority Items\n`;
552
-
553
- items.slice(0, maxPriorityItems).forEach((item, index) => {
554
- const id = this.generateFeedbackItemId(index);
555
- const title = this.generateTitle(item.transcription);
556
- const oneLineSummary = this.truncateText(item.transcription, 60);
557
- summary += `- **${id}:** ${title} - ${oneLineSummary}\n`;
558
- });
559
-
560
- if (items.length > maxPriorityItems) {
561
- const remainingIds = items
562
- .slice(maxPriorityItems)
563
- .map((_, i) => this.generateFeedbackItemId(i + maxPriorityItems))
564
- .join(', ');
565
- summary += `\n## Other\n- ${remainingIds} (see full report)\n`;
566
- }
567
-
568
- summary += `\n**Full report:** ./feedback-report.md`;
569
-
570
- // Ensure we stay under 1500 chars
571
- if (summary.length > 1500) {
572
- summary = summary.slice(0, 1497) + '...';
573
- }
574
-
575
- return summary;
576
- }
577
-
578
- /**
579
- * Generate a feedback item ID (FB-001, FB-002, etc.)
580
- */
581
- generateFeedbackItemId(index: number): string {
582
- return `FB-${(index + 1).toString().padStart(3, '0')}`;
583
- }
584
-
585
- // ==========================================================================
586
- // Private Helper Methods
587
- // ==========================================================================
588
-
589
- /**
590
- * Generate a title from the transcription (first sentence or 50 chars)
591
- */
592
- private generateTitle(transcription: string): string {
593
- // Extract first sentence
594
- const firstSentence = transcription.split(/[.!?]/)[0].trim();
595
- if (firstSentence.length <= 50) return firstSentence;
596
- return firstSentence.slice(0, 47) + '...';
597
- }
598
-
599
- /**
600
- * Truncate text to specified length
601
- */
602
- private truncateText(text: string, maxLength: number): string {
603
- if (text.length <= maxLength) return text;
604
- return text.slice(0, maxLength - 3) + '...';
605
- }
606
-
607
- /**
608
- * Wrap transcription for markdown blockquote (handle multi-line)
609
- */
610
- private wrapTranscription(transcription: string): string {
611
- // Split by natural sentence breaks for readability
612
- const sentences = transcription.match(/[^.!?]+[.!?]+/g);
613
- if (!sentences) return transcription;
614
-
615
- // Append any trailing text that doesn't end with punctuation.
616
- // Whisper transcripts frequently end mid-sentence.
617
- const lastMatch = sentences[sentences.length - 1];
618
- const lastMatchEnd = transcription.lastIndexOf(lastMatch) + lastMatch.length;
619
- const remainder = transcription.slice(lastMatchEnd).trim();
620
- if (remainder) {
621
- sentences.push(remainder);
622
- }
623
-
624
- if (sentences.length <= 2) return transcription;
625
-
626
- // For longer transcriptions, add line breaks between sentences
627
- return sentences.map(s => s.trim()).join('\n> ');
628
- }
629
-
630
- /**
631
- * Format duration from milliseconds to M:SS
632
- */
633
- private formatDuration(ms: number): string {
634
- const totalSeconds = Math.floor(ms / 1000);
635
- const mins = Math.floor(totalSeconds / 60);
636
- const secs = totalSeconds % 60;
637
- return `${mins}:${secs.toString().padStart(2, '0')}`;
638
- }
639
-
640
- /**
641
- * Format timestamp to locale string
642
- */
643
- private formatTimestamp(ms: number): string {
644
- return new Date(ms).toLocaleString('en-US', {
645
- year: 'numeric',
646
- month: 'short',
647
- day: 'numeric',
648
- hour: '2-digit',
649
- minute: '2-digit',
650
- });
651
- }
652
-
653
- /**
654
- * Format item timestamp as MM:SS from session start
655
- */
656
- private formatItemTimestamp(ms: number): string {
657
- const totalSeconds = Math.max(0, Math.floor(ms / 1000));
658
- const mins = Math.floor(totalSeconds / 60);
659
- const secs = totalSeconds % 60;
660
- return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
661
- }
662
-
663
- /**
664
- * Generate filename following pattern: {project}-feedback-{YYYYMMDD-HHmmss}.md
665
- */
666
- private generateFilename(projectName: string, startTime: number): string {
667
- const date = new Date(startTime);
668
- const year = date.getFullYear();
669
- const month = (date.getMonth() + 1).toString().padStart(2, '0');
670
- const day = date.getDate().toString().padStart(2, '0');
671
- const hours = date.getHours().toString().padStart(2, '0');
672
- const minutes = date.getMinutes().toString().padStart(2, '0');
673
- const seconds = date.getSeconds().toString().padStart(2, '0');
674
-
675
- const dateStr = `${year}${month}${day}`;
676
- const timeStr = `${hours}${minutes}${seconds}`;
677
- const safeName = projectName.toLowerCase().replace(/[^a-z0-9]/g, '-').replace(/-+/g, '-');
678
-
679
- return `${safeName}-feedback-${dateStr}-${timeStr}.md`;
680
- }
681
-
682
- /**
683
- * Generate screenshot filename for a feedback item.
684
- * Uses the item's position index to produce `fb-{NNN}.png`, matching the
685
- * naming convention in FileManager.saveSession.
686
- */
687
- private generateScreenshotFilename(itemIndex: number, screenshotIndex: number, total: number): string {
688
- const num = (itemIndex + 1).toString().padStart(3, '0');
689
- const suffix = total > 1 ? `-${screenshotIndex + 1}` : '';
690
- return `fb-${num}${suffix}.png`;
691
- }
692
-
693
- /**
694
- * Provide a severity fallback when upstream analysis is unavailable.
695
- */
696
- private defaultSeverityForCategory(category: FeedbackCategory): FeedbackSeverity {
697
- switch (category) {
698
- case 'Bug':
699
- return 'High';
700
- case 'Performance':
701
- return 'High';
702
- case 'UX Issue':
703
- return 'Medium';
704
- case 'Suggestion':
705
- return 'Low';
706
- case 'Question':
707
- return 'Low';
708
- default:
709
- return 'Medium';
710
- }
711
- }
712
-
713
- private countSeverities(items: FeedbackItem[]): Record<string, number> {
714
- return items.reduce((acc, item) => {
715
- const severity = item.severity || this.defaultSeverityForCategory(item.category || 'General');
716
- acc[severity] = (acc[severity] || 0) + 1;
717
- return acc;
718
- }, {} as Record<string, number>);
719
- }
720
-
721
- private extractTopThemes(items: FeedbackItem[]): string[] {
722
- const counts = new Map<string, number>();
723
-
724
- items.forEach((item) => {
725
- (item.keywords || []).forEach((keyword) => {
726
- const normalized = keyword.toLowerCase();
727
- counts.set(normalized, (counts.get(normalized) || 0) + 1);
728
- });
729
- });
730
-
731
- return Array.from(counts.entries())
732
- .sort((a, b) => b[1] - a[1])
733
- .slice(0, 5)
734
- .map(([keyword]) => keyword);
735
- }
736
-
737
- private suggestAction(
738
- category: FeedbackCategory,
739
- severity: FeedbackSeverity,
740
- transcription: string
741
- ): string {
742
- const excerpt = this.truncateText(transcription, 120);
743
-
744
- switch (category) {
745
- case 'Bug':
746
- return `Reproduce and patch this defect, then add a regression test that validates: "${excerpt}".`;
747
- case 'Performance':
748
- return `Profile this flow, target the slow step first, and validate before/after metrics for: "${excerpt}".`;
749
- case 'UX Issue':
750
- return `Revise the UI interaction and run a quick usability check focused on: "${excerpt}".`;
751
- case 'Suggestion':
752
- return severity === 'High' || severity === 'Critical'
753
- ? `Treat this suggestion as near-term roadmap work and define implementation scope for: "${excerpt}".`
754
- : `Track this as an enhancement request and prioritize against current sprint goals: "${excerpt}".`;
755
- case 'Question':
756
- return `Answer this explicitly in product/docs so future reviews don't block on: "${excerpt}".`;
757
- default:
758
- return `Investigate this item and convert it into a concrete engineering task: "${excerpt}".`;
759
- }
760
- }
761
-
762
- /**
763
- * Count feedback items by type/category
764
- */
765
- private countTypes(items: FeedbackItem[]): Record<string, number> {
766
- return items.reduce((acc, item) => {
767
- const type = item.category || 'General';
768
- acc[type] = (acc[type] || 0) + 1;
769
- return acc;
770
- }, {} as Record<string, number>);
771
- }
772
-
773
- /**
774
- * Count total screenshots across all items
775
- */
776
- private countScreenshots(items: FeedbackItem[]): number {
777
- return items.reduce((sum, item) => sum + item.screenshots.length, 0);
778
- }
779
- }
780
-
781
- // ============================================================================
782
- // Exports
783
- // ============================================================================
784
-
785
- /**
786
- * Singleton instance for easy import
787
- */
788
- export const markdownGenerator = new MarkdownGeneratorImpl();
789
-
790
- // Re-export the class for testing
791
- export { MarkdownGeneratorImpl as MarkdownGenerator };