diff --git a/SuperWhisper.alfredworkflow b/SuperWhisper.alfredworkflow index 824f1b5..79df363 100644 Binary files a/SuperWhisper.alfredworkflow and b/SuperWhisper.alfredworkflow differ diff --git a/Workflow/info.plist b/Workflow/info.plist index 21d006e..b06fc79 100644 --- a/Workflow/info.plist +++ b/Workflow/info.plist @@ -173,6 +173,19 @@ + 0FD58793-7E78-4C2A-89E9-0F8C347CA6F2 + + + destinationuid + 87A451E5-BD57-46B2-894C-08E7351C2643 + modifiers + 0 + modifiersubtext + + vitoclose + + + 10AB43F3-34FD-4951-85AA-8B789A0CB952 @@ -281,7 +294,7 @@ destinationuid - 63351C56-0B46-4F64-B262-1634CA030B9F + 222A5D93-9B19-4A9C-A3D9-6FCCEA4EB0E1 modifiers 0 modifiersubtext @@ -303,6 +316,19 @@ + 222A5D93-9B19-4A9C-A3D9-6FCCEA4EB0E1 + + + destinationuid + 63351C56-0B46-4F64-B262-1634CA030B9F + modifiers + 0 + modifiersubtext + + vitoclose + + + 245CAF52-3483-4AD5-9FFD-53049E5DEF23 @@ -1017,6 +1043,19 @@ + 87A451E5-BD57-46B2-894C-08E7351C2643 + + + destinationuid + CA907A35-F66A-4912-9E40-7E3F265701EE + modifiers + 0 + modifiersubtext + + vitoclose + + + 88B4CC88-D89F-4C79-A59F-4E1F9F156B1B @@ -2150,6 +2189,48 @@ end tell version 1 + + config + + concurrently + + escaping + 68 + script + /usr/bin/osascript scripts/viewJson.js $1 + scriptargtype + 1 + scriptfile + + type + 0 + + type + alfred.workflow.action.script + uid + 87A451E5-BD57-46B2-894C-08E7351C2643 + version + 2 + + + config + + acceptsmulti + 0 + filetypes + + public.json + + name + View SuperWhisper JSON + + type + alfred.workflow.trigger.action + uid + 0FD58793-7E78-4C2A-89E9-0F8C347CA6F2 + version + 1 + config @@ -3696,6 +3777,27 @@ export session_var=$((RANDOM % 9000000 + 1)) version 1 + + config + + matchmode + 1 + matchstring + \n + regexcaseinsensitive + + regexmultiline + + replacestring + \n\n + + type + alfred.workflow.utility.replace + uid + 222A5D93-9B19-4A9C-A3D9-6FCCEA4EB0E1 + version + 2 + config @@ -5525,6 +5627,13 @@ Please be aware that since this workflow is non-official, it may require occasio ypos 705 + 0FD58793-7E78-4C2A-89E9-0F8C347CA6F2 + + xpos + 1185 + ypos + 155 + 10AB43F3-34FD-4951-85AA-8B789A0CB952 xpos @@ -5607,6 +5716,13 @@ Please be aware that since this workflow is non-official, it may require occasio ypos 305 + 222A5D93-9B19-4A9C-A3D9-6FCCEA4EB0E1 + + xpos + 2300 + ypos + 385 + 245CAF52-3483-4AD5-9FFD-53049E5DEF23 xpos @@ -5834,7 +5950,7 @@ Please be aware that since this workflow is non-official, it may require occasio 63351C56-0B46-4F64-B262-1634CA030B9F xpos - 2310 + 2350 ypos 355 @@ -6005,6 +6121,13 @@ Please be aware that since this workflow is non-official, it may require occasio ypos 310 + 87A451E5-BD57-46B2-894C-08E7351C2643 + + xpos + 1450 + ypos + 155 + 88B4CC88-D89F-4C79-A59F-4E1F9F156B1B xpos @@ -6810,7 +6933,7 @@ Please be aware that since this workflow is non-official, it may require occasio variablesdontexport version - 1.1.2 + 1.1.3 webaddress https://github.com/ognistik/alfred-superwhisper diff --git a/Workflow/scripts/actions.js b/Workflow/scripts/actions.js index aca0bcc..3db9e42 100755 --- a/Workflow/scripts/actions.js +++ b/Workflow/scripts/actions.js @@ -77,7 +77,13 @@ function run(argv) { .filter(([key]) => !desiredOrder.includes(key) && key !== 'segments' && key !== 'datetime' && key !== 'appVersion') .sort(([a], [b]) => a.localeCompare(b)) .forEach(([key, value]) => { - formattedString += `## ${key}\n${value !== undefined && value !== null ? value : 'N/A'}\n---\n`; + // Convert milliseconds to seconds for specific keys + if (['duration', 'processingTime', 'languageModelProcessingTime'].includes(key) && value !== undefined && value !== null) { + const seconds = (value / 1000).toFixed(2); + formattedString += `## ${key}\n\`${seconds}s\`\n---\n`; + } else { + formattedString += `## ${key}\n${value !== undefined && value !== null ? value : 'N/A'}\n---\n`; + } }); return { @@ -173,7 +179,13 @@ function run(argv) { .filter(([key]) => !desiredOrder.includes(key) && key !== 'segments' && key !== 'datetime' && key !== 'appVersion') .sort(([a], [b]) => a.localeCompare(b)) .forEach(([key, value]) => { - formattedString += `## ${key}\n${value !== undefined && value !== null ? value : 'N/A'}\n---\n`; + // Convert milliseconds to seconds for specific keys + if (['duration', 'processingTime', 'languageModelProcessingTime'].includes(key) && value !== undefined && value !== null) { + const seconds = (value / 1000).toFixed(2); + formattedString += `## ${key}\n\`${seconds}s\`\n---\n`; + } else { + formattedString += `## ${key}\n${value !== undefined && value !== null ? value : 'N/A'}\n---\n`; + } }); return { diff --git a/Workflow/scripts/viewJson.js b/Workflow/scripts/viewJson.js new file mode 100755 index 0000000..3d99494 --- /dev/null +++ b/Workflow/scripts/viewJson.js @@ -0,0 +1,109 @@ +function run(argv) { + const jsonPath = argv[0]; + + function processJson(filePath) { + const fileManager = $.NSFileManager.defaultManager; + + if (fileManager.fileExistsAtPath($(filePath))) { + let fileContent; + try { + fileContent = $.NSString.stringWithContentsOfFileEncodingError($(filePath), $.NSUTF8StringEncoding, $()); + if (!fileContent) { + return { notFound: 1 }; + } + } catch (readError) { + return { notFound: 1 }; + } + + try { + const jsonContent = JSON.parse(fileContent.js); + + // Convert datetime + let formattedDatetime = 'N/A'; + if (jsonContent.datetime) { + const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + const datetimeObj = new Date(jsonContent.datetime + 'Z'); + if (!isNaN(datetimeObj.getTime())) { + const localDatetime = new Date(datetimeObj.toLocaleString("en-US", {timeZone: userTimezone})); + formattedDatetime = localDatetime.getFullYear() + '-' + + String(localDatetime.getMonth() + 1).padStart(2, '0') + '-' + + String(localDatetime.getDate()).padStart(2, '0') + ' • ' + + String(localDatetime.getHours() % 12 || 12).padStart(2, '0') + ':' + + String(localDatetime.getMinutes()).padStart(2, '0') + ':' + + String(localDatetime.getSeconds()).padStart(2, '0') + ' ' + + (localDatetime.getHours() >= 12 ? 'PM' : 'AM'); + } + } + + // Extract Values + const llmResult = jsonContent.llmResult || ''; + const simpleResult = jsonContent.result || ''; + const system = jsonContent.prompt || ''; + + // Create formatted string + const desiredOrder = ['prompt', 'rawResult', 'result', 'llmResult']; + let formattedString = ''; + const entries = Object.entries(jsonContent); + + for (const key of desiredOrder) { + if (key in jsonContent) { + const value = jsonContent[key]; + formattedString += `## ${key}\n${value !== undefined && value !== null ? value : 'N/A'}\n---\n`; + } + } + + entries + .filter(([key]) => !desiredOrder.includes(key) && key !== 'segments' && key !== 'datetime' && key !== 'appVersion') + .sort(([a], [b]) => a.localeCompare(b)) + .forEach(([key, value]) => { + // Convert milliseconds to seconds for specific keys + if (['duration', 'processingTime', 'languageModelProcessingTime'].includes(key) && value !== undefined && value !== null) { + const seconds = (value / 1000).toFixed(2); + formattedString += `## ${key}\n\`${seconds}s\`\n---\n`; + } else { + formattedString += `## ${key}\n${value !== undefined && value !== null ? value : 'N/A'}\n---\n`; + } + }); + + return { + latestJson: filePath, + datetime: formattedDatetime, + llmResult: llmResult, + result: simpleResult, + system: system, + formattedContent: formattedString.trim() + }; + } catch (parseError) { + return { notFound: 1 }; + } + } + return { notFound: 1 }; + } + + const result = processJson(jsonPath); + + if (result.notFound) { + return JSON.stringify({ + alfredworkflow: { + variables: { + theAction: 'error', + theContent: 'Error processing JSON file' + } + } + }); + } + + return JSON.stringify({ + alfredworkflow: { + variables: { + theAction: 'textView', + theContent: '# ' + result.datetime + '\n---\n\n' + result.formattedContent, + copyContent: result.formattedContent, + theVoice: result.result, + theResult: result.llmResult !== '' ? result.llmResult : result.result, + theSystem: result.system, + theUrl: result.latestJson + } + } + }); +} \ No newline at end of file