0a60006d2d
Ship user-defined Shortcut skills, companion Events/Navigate recipes, shared skill/style card chrome, and bump the build to 69.
26 lines
881 B
Swift
26 lines
881 B
Swift
// AIGenericSkillExport.swift
|
|
// OSGKeyboard · Shared
|
|
//
|
|
// Line-oriented Shortcut input for user-created export skills. Built-in
|
|
// extract-todos / extract-events keep their dedicated parsers.
|
|
|
|
import Foundation
|
|
|
|
public enum AIGenericSkillExport {
|
|
public static let maximumItems = 20
|
|
|
|
public static func items(from answer: String) -> [String] {
|
|
let trimmed = answer.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
guard !trimmed.isEmpty else { return [] }
|
|
if trimmed.compare("NONE", options: .caseInsensitive) == .orderedSame {
|
|
return []
|
|
}
|
|
let lines = trimmed
|
|
.split(whereSeparator: \.isNewline)
|
|
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
|
.filter { !$0.isEmpty }
|
|
if lines.isEmpty { return [trimmed] }
|
|
return Array(lines.prefix(maximumItems))
|
|
}
|
|
}
|