Skip to content

Commit

Permalink
Prep Release
Browse files Browse the repository at this point in the history
  • Loading branch information
ognistik committed Jan 17, 2025
1 parent 7088cbe commit 5e22687
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 5 deletions.
Binary file modified SuperWhisper.alfredworkflow
Binary file not shown.
129 changes: 126 additions & 3 deletions Workflow/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@
<false/>
</dict>
</array>
<key>0FD58793-7E78-4C2A-89E9-0F8C347CA6F2</key>
<array>
<dict>
<key>destinationuid</key>
<string>87A451E5-BD57-46B2-894C-08E7351C2643</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>10AB43F3-34FD-4951-85AA-8B789A0CB952</key>
<array>
<dict>
Expand Down Expand Up @@ -281,7 +294,7 @@
<array>
<dict>
<key>destinationuid</key>
<string>63351C56-0B46-4F64-B262-1634CA030B9F</string>
<string>222A5D93-9B19-4A9C-A3D9-6FCCEA4EB0E1</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
Expand All @@ -303,6 +316,19 @@
<false/>
</dict>
</array>
<key>222A5D93-9B19-4A9C-A3D9-6FCCEA4EB0E1</key>
<array>
<dict>
<key>destinationuid</key>
<string>63351C56-0B46-4F64-B262-1634CA030B9F</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>245CAF52-3483-4AD5-9FFD-53049E5DEF23</key>
<array>
<dict>
Expand Down Expand Up @@ -1017,6 +1043,19 @@
<false/>
</dict>
</array>
<key>87A451E5-BD57-46B2-894C-08E7351C2643</key>
<array>
<dict>
<key>destinationuid</key>
<string>CA907A35-F66A-4912-9E40-7E3F265701EE</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>88B4CC88-D89F-4C79-A59F-4E1F9F156B1B</key>
<array>
<dict>
Expand Down Expand Up @@ -2150,6 +2189,48 @@ end tell</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>68</integer>
<key>script</key>
<string>/usr/bin/osascript scripts/viewJson.js $1</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>87A451E5-BD57-46B2-894C-08E7351C2643</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>acceptsmulti</key>
<integer>0</integer>
<key>filetypes</key>
<array>
<string>public.json</string>
</array>
<key>name</key>
<string>View SuperWhisper JSON</string>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.action</string>
<key>uid</key>
<string>0FD58793-7E78-4C2A-89E9-0F8C347CA6F2</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -3696,6 +3777,27 @@ export session_var=$((RANDOM % 9000000 + 1))
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>matchmode</key>
<integer>1</integer>
<key>matchstring</key>
<string>\n</string>
<key>regexcaseinsensitive</key>
<false/>
<key>regexmultiline</key>
<false/>
<key>replacestring</key>
<string>\n\n</string>
</dict>
<key>type</key>
<string>alfred.workflow.utility.replace</string>
<key>uid</key>
<string>222A5D93-9B19-4A9C-A3D9-6FCCEA4EB0E1</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -5525,6 +5627,13 @@ Please be aware that since this workflow is non-official, it may require occasio
<key>ypos</key>
<real>705</real>
</dict>
<key>0FD58793-7E78-4C2A-89E9-0F8C347CA6F2</key>
<dict>
<key>xpos</key>
<real>1185</real>
<key>ypos</key>
<real>155</real>
</dict>
<key>10AB43F3-34FD-4951-85AA-8B789A0CB952</key>
<dict>
<key>xpos</key>
Expand Down Expand Up @@ -5607,6 +5716,13 @@ Please be aware that since this workflow is non-official, it may require occasio
<key>ypos</key>
<real>305</real>
</dict>
<key>222A5D93-9B19-4A9C-A3D9-6FCCEA4EB0E1</key>
<dict>
<key>xpos</key>
<real>2300</real>
<key>ypos</key>
<real>385</real>
</dict>
<key>245CAF52-3483-4AD5-9FFD-53049E5DEF23</key>
<dict>
<key>xpos</key>
Expand Down Expand Up @@ -5834,7 +5950,7 @@ Please be aware that since this workflow is non-official, it may require occasio
<key>63351C56-0B46-4F64-B262-1634CA030B9F</key>
<dict>
<key>xpos</key>
<real>2310</real>
<real>2350</real>
<key>ypos</key>
<real>355</real>
</dict>
Expand Down Expand Up @@ -6005,6 +6121,13 @@ Please be aware that since this workflow is non-official, it may require occasio
<key>ypos</key>
<real>310</real>
</dict>
<key>87A451E5-BD57-46B2-894C-08E7351C2643</key>
<dict>
<key>xpos</key>
<real>1450</real>
<key>ypos</key>
<real>155</real>
</dict>
<key>88B4CC88-D89F-4C79-A59F-4E1F9F156B1B</key>
<dict>
<key>xpos</key>
Expand Down Expand Up @@ -6810,7 +6933,7 @@ Please be aware that since this workflow is non-official, it may require occasio
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>1.1.2</string>
<string>1.1.3</string>
<key>webaddress</key>
<string>https://github.com/ognistik/alfred-superwhisper</string>
</dict>
Expand Down
16 changes: 14 additions & 2 deletions Workflow/scripts/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
109 changes: 109 additions & 0 deletions Workflow/scripts/viewJson.js
Original file line number Diff line number Diff line change
@@ -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
}
}
});
}

0 comments on commit 5e22687

Please sign in to comment.