sprag-cli 3.136.0 → 3.137.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.
- package/mac/SpragBar.swift +304 -262
- package/package.json +1 -1
- package/src/agent-activity.js +44 -2
- package/src/agent-detail.js +41 -0
- package/src/bar-app.js +129 -4
- package/src/commands/bar.js +11 -2
package/mac/SpragBar.swift
CHANGED
|
@@ -36,7 +36,12 @@ struct Session: Decodable, Identifiable {
|
|
|
36
36
|
let cpu: Double?; let rssMb: Double?; let procs: Int?
|
|
37
37
|
let cpuPct: Double?; let model: String?; let modelName: String?; let effort: String?; let context: Ctx?; let usage: SUsage?
|
|
38
38
|
let compactions: Int? // times the conversation was compacted; optional so a snapshot from an older sprag still decodes
|
|
39
|
+
let title: String? // what the session is about (rename, last prompt, topic); optional so a snapshot from an older sprag still decodes
|
|
39
40
|
var id: Int { pid }
|
|
41
|
+
/** What a row calls the session: its title, else Claude Code's own name, which is often the folder plus a number. */
|
|
42
|
+
var label: String { if let t = title, !t.isEmpty { return t }; return name ?? agent }
|
|
43
|
+
/** The tooltip form: the title and the name under it, or one of them when they are the same. */
|
|
44
|
+
var fullName: String { let n = name ?? agent; return label == n ? n : label + "\n" + n }
|
|
40
45
|
}
|
|
41
46
|
struct Totals: Decodable { let sessions: Int; let busy: Int; let subagents: Int; let cpu: Double?; let rssMb: Double?; let procs: Int?; let costUsd: Double? }
|
|
42
47
|
struct Animal: Decodable { let grade: String; let emoji: String }
|
|
@@ -263,14 +268,30 @@ func exactTab(_ s: Session) -> (tool: String, args: [String])? {
|
|
|
263
268
|
let dir = env["ORCA_CLI_BIN_DIR"], dir.hasSuffix(".app/Contents/Resources/bin"), FileManager.default.isExecutableFile(atPath: dir + "/orca") else { return nil }
|
|
264
269
|
return (dir + "/orca", ["terminal", "switch", "--terminal", handle])
|
|
265
270
|
}
|
|
266
|
-
/**
|
|
271
|
+
/** Whether an app has a normal window on the current screen. Minimized and hidden windows are not on screen. Owner and layer are readable without the screen recording permission. */
|
|
272
|
+
func hasWindowOnScreen(_ pid: pid_t) -> Bool {
|
|
273
|
+
guard let list = CGWindowListCopyWindowInfo([.optionOnScreenOnly, .excludeDesktopElements], kCGNullWindowID) as? [[String: Any]] else { return true }
|
|
274
|
+
return list.contains { ($0[kCGWindowOwnerPID as String] as? Int) == Int(pid) && ($0[kCGWindowLayer as String] as? Int) == 0 }
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Go to a session: show its tab where the terminal allows it, then bring the terminal app to the front.
|
|
278
|
+
* activate() only raises windows that are already open, so a terminal whose windows all sit in the Dock came forward with
|
|
279
|
+
* nothing to show. Opening the running app again sends it the same reopen event a Dock click does, which restores a
|
|
280
|
+
* minimized window (and unhides a hidden app) without asking for any permission. It is sent only when nothing of the
|
|
281
|
+
* app is on screen, because some apps open a new window on every reopen.
|
|
282
|
+
*/
|
|
267
283
|
func jump(to s: Session) {
|
|
268
284
|
if let tab = exactTab(s) {
|
|
269
285
|
let p = Process(); p.executableURL = URL(fileURLWithPath: tab.tool); p.arguments = tab.args
|
|
270
286
|
p.standardOutput = FileHandle.nullDevice; p.standardError = FileHandle.nullDevice
|
|
271
287
|
try? p.run()
|
|
272
288
|
}
|
|
273
|
-
owningApp(s.pid)
|
|
289
|
+
guard let app = owningApp(s.pid) else { return }
|
|
290
|
+
app.activate(options: [.activateAllWindows])
|
|
291
|
+
if let url = app.bundleURL, app.isHidden || !hasWindowOnScreen(app.processIdentifier) {
|
|
292
|
+
let cfg = NSWorkspace.OpenConfiguration(); cfg.activates = true
|
|
293
|
+
NSWorkspace.shared.openApplication(at: url, configuration: cfg)
|
|
294
|
+
}
|
|
274
295
|
}
|
|
275
296
|
/** The folder a Claude session worked in, read from its transcript (`<config>/projects/<folder>/<id>.jsonl`, whose lines carry `cwd`). */
|
|
276
297
|
func sessionCwd(_ sid: String) -> String? {
|
|
@@ -667,7 +688,7 @@ final class Model: ObservableObject {
|
|
|
667
688
|
for s in sessions {
|
|
668
689
|
let mine = gpuUse.filter { $0.session == s.pid }
|
|
669
690
|
guard !mine.isEmpty else { continue }
|
|
670
|
-
out.append(GpuLine(id: "s\(s.pid)", label: s.
|
|
691
|
+
out.append(GpuLine(id: "s\(s.pid)", label: s.label, note: mine.prefix(2).map { $0.name }.joined(separator: ", "), share: min(1, mine.reduce(0) { $0 + $1.share }), agent: s.agent, pid: s.pid))
|
|
671
692
|
}
|
|
672
693
|
for u in gpuUse where u.session == nil { out.append(GpuLine(id: "p\(u.pid)", label: u.name, note: u.left ? "끝난 세션이 남긴 것" : "", share: u.share, agent: u.left ? "left" : nil)) }
|
|
673
694
|
return Array(out.sorted { $0.share > $1.share }.prefix(n))
|
|
@@ -949,264 +970,271 @@ func oval(_ c: NSPoint, _ rx: CGFloat, _ ry: CGFloat) { NSBezierPath(ovalIn: NSR
|
|
|
949
970
|
|
|
950
971
|
func runner(_ sp: Sp, frame: Int, idle: Bool) -> NSImage {
|
|
951
972
|
let size = NSSize(width: 31 * RUNNER_SCALE, height: 21.4 * RUNNER_SCALE)
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
let
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
oval(tip, 1.8, 1.6)
|
|
1035
|
-
case .thinLong, .monkey:
|
|
1036
|
-
tail.lineWidth = sp.tail == .monkey ? 1.1 : 0.75
|
|
1037
|
-
let end = NSPoint(x: tb.x - 7.4, y: tb.y + (sp.tail == .monkey ? 4.2 : 0.2) - flex * 1.2 + lag * 1.4)
|
|
1038
|
-
tail.move(to: tb)
|
|
1039
|
-
tail.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.8, y: tb.y - 1.6 - lag), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y - 2.4 + lag))
|
|
1040
|
-
if sp.tail == .monkey { tail.appendArc(withCenter: NSPoint(x: end.x + 0.9, y: end.y), radius: 0.9, startAngle: 180, endAngle: 450, clockwise: false) }
|
|
1041
|
-
tail.stroke()
|
|
1042
|
-
case .flow: // a horse's tail: a few strands streaming back
|
|
1043
|
-
for (dy, w) in [(0.0, 1.5), (-0.9, 1.1), (0.8, 1.0)] as [(CGFloat, CGFloat)] {
|
|
1044
|
-
let t = NSBezierPath(); t.lineWidth = w; t.lineCapStyle = .round
|
|
1045
|
-
let end = NSPoint(x: tb.x - 6.4, y: tb.y - 2.2 + dy - flex * 1.2 + lag * 1.4)
|
|
1046
|
-
t.move(to: NSPoint(x: tb.x, y: tb.y + 0.6)); t.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.4, y: tb.y + 1.4 + dy), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y + 1.2 - lag)); t.stroke()
|
|
1047
|
-
}
|
|
1048
|
-
case .wag: // a puppy's short tail, held up and wagging
|
|
1049
|
-
line2(NSPoint(x: tb.x + 0.3, y: tb.y + 0.4), NSPoint(x: tb.x - 1.8 + lag * 0.9, y: tb.y + 3.0), 1.4)
|
|
1050
|
-
case .short:
|
|
1051
|
-
oval(NSPoint(x: tb.x - 0.4, y: tb.y + 1.2), 0.9, 1.3)
|
|
1052
|
-
case .rope: // an elephant's thin tail with a tuft
|
|
1053
|
-
let e = NSPoint(x: tb.x - 1.6 + lag * 0.5, y: tb.y - 2.8)
|
|
1054
|
-
line2(tb, e, 0.7); oval(e, 0.6, 0.8)
|
|
1055
|
-
}
|
|
1056
|
-
// wings beat once a stride, the downstroke as the body rises; the far wing goes behind the body
|
|
1057
|
-
let wingFlap: CGFloat = idle ? -0.15 : sin(ph + 0.6)
|
|
1058
|
-
let wingRoot = rot(NSPoint(x: c.x + half - 1.8, y: y0 + CGFloat(sp.chest) * 0.75), c, pitch)
|
|
1059
|
-
if sp.x.contains("wings") { featherWing(NSPoint(x: wingRoot.x + 0.6, y: wingRoot.y + 0.3), flap: idle ? -0.15 : sin(ph + 0.25), span: idle ? 5.5 : 7.6, near: false) }
|
|
1060
|
-
// torso: hip and chest masses joined along a spine that bends
|
|
1061
|
-
let sp2 = NSBezierPath(); sp2.lineWidth = CGFloat(min(sp.chest, sp.hip)) * 2.15; sp2.lineCapStyle = .round
|
|
1062
|
-
sp2.move(to: H); sp2.curve(to: S, controlPoint1: M, controlPoint2: M); sp2.stroke()
|
|
1063
|
-
let sq = 1 - 0.09 * max(0, -lift) // squashed a little on landing
|
|
1064
|
-
oval(NSPoint(x: H.x + 0.3, y: H.y), CGFloat(sp.hip) * (2 - sq), CGFloat(sp.hip) * 0.95 * sq)
|
|
1065
|
-
oval(NSPoint(x: S.x - 0.2, y: S.y - 0.25), CGFloat(sp.chest) * (2 - sq), CGFloat(sp.chest) * sq)
|
|
1066
|
-
if sp.hump { oval(rot(NSPoint(x: S.x - 1.4, y: S.y + CGFloat(sp.chest) * 0.62), S, pitch), CGFloat(sp.chest) * 0.78, CGFloat(sp.chest) * 0.62) }
|
|
1067
|
-
let br = CGFloat(min(sp.chest, sp.hip)) * 1.07
|
|
1068
|
-
func along(_ t: CGFloat) -> NSPoint { // a point on the spine, t = 0 at the hip and 1 at the shoulder
|
|
1069
|
-
let u = 1 - t; return NSPoint(x: u * u * u * H.x + 3 * u * u * t * M.x + 3 * u * t * t * M.x + t * t * t * S.x, y: u * u * u * H.y + 3 * u * u * t * M.y + 3 * u * t * t * M.y + t * t * t * S.y)
|
|
1070
|
-
}
|
|
1071
|
-
if sp.x.contains("wool") { // a white fleece with a scalloped outline: the puffs drawn dark, then hollowed out
|
|
1072
|
-
leg(sh, k.fn, CGFloat(sp.legF) * LEGK, true); leg(hp, k.hn, CGFloat(sp.legH) * LEGK, true) // under the fleece
|
|
1073
|
-
var puffs: [(NSPoint, CGFloat)] = []
|
|
1074
|
-
for i in 0...5 { let p = along(CGFloat(i) / 5); puffs.append((NSPoint(x: p.x, y: p.y + br * 0.8), br * 0.62)); puffs.append((NSPoint(x: p.x, y: p.y - br * 0.55), br * 0.58)) }
|
|
1075
|
-
puffs.append((NSPoint(x: H.x - br * 0.8, y: H.y + 0.2), br * 0.62)); puffs.append((NSPoint(x: S.x + br * 0.55, y: S.y + br * 0.35), br * 0.6))
|
|
1076
|
-
for (c3, r) in puffs { oval(c3, r, r) }
|
|
1077
|
-
oval(along(0.5), br * 1.6, br * 1.1)
|
|
973
|
+
// The drawing is its own function. Swift 6.0 type-checks a multi-statement closure together with the call that
|
|
974
|
+
// takes it, and this body inside NSImage(size:flipped:) gave up with "unable to type-check this expression in
|
|
975
|
+
// reasonable time" (#22). A function body is checked statement by statement.
|
|
976
|
+
let img = NSImage(size: size, flipped: false) { _ in drawRunner(sp, frame: frame, idle: idle); return true }
|
|
977
|
+
img.isTemplate = true
|
|
978
|
+
return img
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
func drawRunner(_ sp: Sp, frame: Int, idle: Bool) {
|
|
982
|
+
let t = NSAffineTransform(); t.scale(by: RUNNER_SCALE); t.concat()
|
|
983
|
+
NSColor.black.setFill(); NSColor.black.setStroke()
|
|
984
|
+
if sp.waddle { penguin(frame: frame, idle: idle); return }
|
|
985
|
+
if sp.fly > 0 { flyer(sp, frame: frame, idle: idle); return }
|
|
986
|
+
if sp.kind == 4 { frog(frame: frame, idle: idle); return }
|
|
987
|
+
if sp.kind == 5 || sp.kind == 6 { biped(chick: sp.kind == 6, frame: frame, idle: idle); return }
|
|
988
|
+
if sp.kind == 7 { ghost(frame: frame, idle: idle); return }
|
|
989
|
+
let k = idle ? STAND2 : GAL[frame % GAL.count]
|
|
990
|
+
let n = GAL.count, ph = 2 * CGFloat.pi * CGFloat(frame % n) / CGFloat(n)
|
|
991
|
+
let flex = CGFloat(k.flex * sp.flexAmp), lift = CGFloat(k.lift * sp.liftAmp) * 1.2
|
|
992
|
+
let pitch = CGFloat(k.pitch * sp.pitchAmp) * .pi / 180
|
|
993
|
+
let ground: CGFloat = 1.3
|
|
994
|
+
let airborne = sp.x.contains("wings") && !idle // runs on air: the hooves never touch the ground
|
|
995
|
+
let standY: CGFloat = ground + CGFloat(sp.legH) * LEGK * 0.86 + 0.9
|
|
996
|
+
let bob: CGFloat = idle ? 0.12 * sin(ph) : 0
|
|
997
|
+
let hover: CGFloat = airborne ? 1.2 : 0
|
|
998
|
+
let y0: CGFloat = standY + lift + bob + hover
|
|
999
|
+
let c = NSPoint(x: 14.6, y: y0)
|
|
1000
|
+
let half = CGFloat(sp.len) * BODYK / 2 * (1 + 0.17 * flex)
|
|
1001
|
+
let arch = flex < 0 ? -flex * 1.5 : -flex * 0.3 // gathered: the back humps up; stretched: nearly flat
|
|
1002
|
+
let H = rot(NSPoint(x: c.x - half, y: y0), c, pitch), S = rot(NSPoint(x: c.x + half, y: y0), c, pitch)
|
|
1003
|
+
let M = rot(NSPoint(x: c.x, y: y0 + arch * 2), c, pitch)
|
|
1004
|
+
func leg(_ joint: NSPoint, _ a: (Double, Double), _ len: CGFloat, _ near: Bool) {
|
|
1005
|
+
let a1 = CGFloat(a.0) * .pi / 180, a2 = CGFloat(a.1) * .pi / 180
|
|
1006
|
+
let u = len * 0.5, l = len * 0.52
|
|
1007
|
+
let knee = NSPoint(x: joint.x + sin(a1) * u, y: joint.y - cos(a1) * u)
|
|
1008
|
+
var foot = NSPoint(x: knee.x + sin(a2) * l, y: knee.y - cos(a2) * l)
|
|
1009
|
+
foot.y = max(foot.y, airborne ? 1.1 : ground)
|
|
1010
|
+
let w = CGFloat(sp.legW) * (near ? 1 : 0.86)
|
|
1011
|
+
taper(joint, knee, 3.6 * w, 2.0 * w); taper(knee, foot, 2.0 * w, 1.35 * w)
|
|
1012
|
+
oval(NSPoint(x: foot.x + 0.35, y: foot.y + 0.05), 1.0 * w, 0.72 * w)
|
|
1013
|
+
}
|
|
1014
|
+
let sh = NSPoint(x: S.x - 0.4, y: S.y - CGFloat(sp.chest) * 0.35), hp = NSPoint(x: H.x + 0.5, y: H.y - CGFloat(sp.hip) * 0.3)
|
|
1015
|
+
// far legs
|
|
1016
|
+
leg(sh, k.ff, CGFloat(sp.legF) * LEGK, false); leg(hp, k.hf, CGFloat(sp.legH) * LEGK, false)
|
|
1017
|
+
// tail, trailing the body by a quarter stride
|
|
1018
|
+
let lag = sin(ph - .pi / 2), tb = rot(NSPoint(x: c.x - half - 0.6, y: y0 + 0.8), c, pitch)
|
|
1019
|
+
let tail = NSBezierPath(); tail.lineCapStyle = .round; tail.lineJoinStyle = .round
|
|
1020
|
+
switch sp.tail {
|
|
1021
|
+
case .curl:
|
|
1022
|
+
tail.lineWidth = 3.1
|
|
1023
|
+
tail.move(to: tb)
|
|
1024
|
+
tail.curve(to: NSPoint(x: tb.x + 1.0 + flex * 0.4, y: tb.y + 5.2 - flex * 0.6), controlPoint1: NSPoint(x: tb.x - 5.0, y: tb.y + 0.4), controlPoint2: NSPoint(x: tb.x - 5.0 + lag, y: tb.y + 6.2))
|
|
1025
|
+
tail.stroke()
|
|
1026
|
+
case .long, .tuft, .thin:
|
|
1027
|
+
tail.lineWidth = sp.tail == .tuft ? 1.4 : 1.6
|
|
1028
|
+
let end = NSPoint(x: tb.x - 7.0 + abs(flex) * 0.6, y: tb.y + 1.2 - flex * 2.4 + lag * 1.6)
|
|
1029
|
+
tail.move(to: tb)
|
|
1030
|
+
tail.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.6, y: tb.y - 1.4 - lag), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y - 2.2 + lag * 1.4))
|
|
1031
|
+
tail.stroke()
|
|
1032
|
+
if sp.tail == .tuft { oval(end, 1.3, 1.1) }
|
|
1033
|
+
case .bushy:
|
|
1034
|
+
let end = NSPoint(x: tb.x - 7.2, y: tb.y - 0.4 - flex * 1.6 + lag * 1.2)
|
|
1035
|
+
let b = NSBezierPath()
|
|
1036
|
+
b.move(to: NSPoint(x: tb.x + 0.4, y: tb.y + 1.2))
|
|
1037
|
+
b.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.6, y: tb.y + 2.4 + lag * 0.6), controlPoint2: NSPoint(x: end.x + 2.4, y: end.y + 2.2))
|
|
1038
|
+
b.curve(to: NSPoint(x: tb.x + 0.4, y: tb.y - 1.2), controlPoint1: NSPoint(x: end.x + 1.6, y: end.y - 1.8), controlPoint2: NSPoint(x: tb.x - 2.8, y: tb.y - 2.0 + lag * 0.6))
|
|
1039
|
+
b.close(); b.fill()
|
|
1040
|
+
case .stub:
|
|
1041
|
+
oval(NSPoint(x: tb.x + 0.6, y: tb.y + 0.6), 1.5, 1.4)
|
|
1042
|
+
case .none: break
|
|
1043
|
+
case .curly: // a pig's corkscrew
|
|
1044
|
+
let cc = NSPoint(x: tb.x - 1.2, y: tb.y + 1.0 + lag * 0.3), t = NSBezierPath(); t.lineWidth = 0.85; t.lineCapStyle = .round
|
|
1045
|
+
t.move(to: NSPoint(x: tb.x + 0.2, y: tb.y + 0.2))
|
|
1046
|
+
t.appendArc(withCenter: cc, radius: 0.95, startAngle: -20, endAngle: 300, clockwise: false); t.stroke()
|
|
1047
|
+
case .ringed, .hang:
|
|
1048
|
+
let end = sp.tail == .hang ? NSPoint(x: tb.x - 5.6, y: tb.y - 3.6 + lag * 0.9 - flex * 0.6) : NSPoint(x: tb.x - 7.0, y: tb.y + 0.4 - flex * 1.4 + lag * 1.2)
|
|
1049
|
+
let b = NSBezierPath()
|
|
1050
|
+
b.move(to: NSPoint(x: tb.x + 0.4, y: tb.y + 1.2))
|
|
1051
|
+
b.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.4, y: tb.y + 1.6 + lag * 0.5), controlPoint2: NSPoint(x: end.x + 2.0, y: end.y + 2.0))
|
|
1052
|
+
b.curve(to: NSPoint(x: tb.x + 0.4, y: tb.y - 1.2), controlPoint1: NSPoint(x: end.x + 1.4, y: end.y - 1.6), controlPoint2: NSPoint(x: tb.x - 2.6, y: tb.y - 1.8 + lag * 0.5))
|
|
1053
|
+
b.close(); b.fill()
|
|
1054
|
+
if sp.tail == .ringed { // dark and pale rings: two gaps cut across the tail
|
|
1078
1055
|
NSGraphicsContext.current?.compositingOperation = .clear
|
|
1079
|
-
for
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
}
|
|
1083
|
-
if sp.x.contains("spikes") { // a hedgehog's coat: spines over the back, pointing back
|
|
1084
|
-
for i in 0..<10 {
|
|
1085
|
-
let t = 0.05 + CGFloat(i) / 10, p = along(t), up = br * (0.6 + 0.4 * sin(t * .pi))
|
|
1086
|
-
let b0 = NSPoint(x: p.x - 0.8, y: p.y + up * 0.7), b1 = NSPoint(x: p.x + 0.8, y: p.y + up * 0.75)
|
|
1087
|
-
let tip = NSPoint(x: p.x - 2.6 - lag * 0.2, y: p.y + up + 2.8)
|
|
1088
|
-
let sp3 = NSBezierPath(); sp3.move(to: b0); sp3.line(to: tip); sp3.line(to: b1); sp3.close(); sp3.fill()
|
|
1056
|
+
for t in [0.42, 0.7] as [CGFloat] {
|
|
1057
|
+
let m = NSPoint(x: tb.x + (end.x - tb.x) * t, y: tb.y + (end.y - tb.y) * t + 0.3)
|
|
1058
|
+
line2(NSPoint(x: m.x + 0.5, y: m.y + 2.2), NSPoint(x: m.x - 0.5, y: m.y - 2.2), 0.6)
|
|
1089
1059
|
}
|
|
1090
|
-
for i in 0..<3 { let p = along(0.02); let sp3 = NSBezierPath(); sp3.move(to: NSPoint(x: p.x - 0.4, y: p.y + CGFloat(i) - 0.6)); sp3.line(to: NSPoint(x: p.x - br - 1.6, y: p.y + CGFloat(i) * 1.2 - 0.6)); sp3.line(to: NSPoint(x: p.x - 0.4, y: p.y + CGFloat(i) + 0.4)); sp3.close(); sp3.fill() }
|
|
1091
|
-
}
|
|
1092
|
-
if sp.x.contains("stripes") {
|
|
1093
|
-
NSGraphicsContext.current?.compositingOperation = .clear
|
|
1094
|
-
// a tiger's stripes, cut across the back
|
|
1095
|
-
for t in [0.12, 0.32, 0.52, 0.72] as [CGFloat] { let p = along(t); line2(NSPoint(x: p.x - 0.4, y: p.y + br * 1.05), NSPoint(x: p.x + 0.4, y: p.y + br * 0.15), 0.55) }
|
|
1096
1060
|
NSGraphicsContext.current?.compositingOperation = .sourceOver
|
|
1097
1061
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
let
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1062
|
+
case .squirrel: // a big plume carried up over the back, its tip curling forward
|
|
1063
|
+
let t = NSBezierPath(); t.lineWidth = 3.6; t.lineCapStyle = .round
|
|
1064
|
+
let tip = NSPoint(x: tb.x + 0.8 + lag * 0.4, y: tb.y + 8.6 - flex * 0.6)
|
|
1065
|
+
t.move(to: tb); t.curve(to: tip, controlPoint1: NSPoint(x: tb.x - 5.2, y: tb.y + 1.4), controlPoint2: NSPoint(x: tb.x - 4.4 + lag * 0.5, y: tb.y + 9.4)); t.stroke()
|
|
1066
|
+
oval(tip, 1.8, 1.6)
|
|
1067
|
+
case .thinLong, .monkey:
|
|
1068
|
+
tail.lineWidth = sp.tail == .monkey ? 1.1 : 0.75
|
|
1069
|
+
let end = NSPoint(x: tb.x - 7.4, y: tb.y + (sp.tail == .monkey ? 4.2 : 0.2) - flex * 1.2 + lag * 1.4)
|
|
1070
|
+
tail.move(to: tb)
|
|
1071
|
+
tail.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.8, y: tb.y - 1.6 - lag), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y - 2.4 + lag))
|
|
1072
|
+
if sp.tail == .monkey { tail.appendArc(withCenter: NSPoint(x: end.x + 0.9, y: end.y), radius: 0.9, startAngle: 180, endAngle: 450, clockwise: false) }
|
|
1073
|
+
tail.stroke()
|
|
1074
|
+
case .flow: // a horse's tail: a few strands streaming back
|
|
1075
|
+
for (dy, w) in [(0.0, 1.5), (-0.9, 1.1), (0.8, 1.0)] as [(CGFloat, CGFloat)] {
|
|
1076
|
+
let t = NSBezierPath(); t.lineWidth = w; t.lineCapStyle = .round
|
|
1077
|
+
let end = NSPoint(x: tb.x - 6.4, y: tb.y - 2.2 + dy - flex * 1.2 + lag * 1.4)
|
|
1078
|
+
t.move(to: NSPoint(x: tb.x, y: tb.y + 0.6)); t.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.4, y: tb.y + 1.4 + dy), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y + 1.2 - lag)); t.stroke()
|
|
1113
1079
|
}
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
case .pig: ear(-hr * 0.85, -hr * 0.15, hr * 0.1, hr * 1.35); ear(hr * 0.0, hr * 0.7, hr * 0.95, hr * 1.2)
|
|
1156
|
-
}
|
|
1157
|
-
// head features
|
|
1158
|
-
if sp.x.contains("horn") {
|
|
1159
|
-
let a = rot(NSPoint(x: hc.x + hr * 0.15, y: hc.y + hr * 0.8), hc, hpitch), b = rot(NSPoint(x: hc.x + hr * 0.65, y: hc.y + hr * 0.85), hc, hpitch), t = rot(NSPoint(x: hc.x + hr * 1.15, y: hc.y + hr * 2.25), hc, hpitch)
|
|
1160
|
-
let h = NSBezierPath(); h.move(to: a); h.line(to: t); h.line(to: b); h.close(); h.fill()
|
|
1080
|
+
case .wag: // a puppy's short tail, held up and wagging
|
|
1081
|
+
line2(NSPoint(x: tb.x + 0.3, y: tb.y + 0.4), NSPoint(x: tb.x - 1.8 + lag * 0.9, y: tb.y + 3.0), 1.4)
|
|
1082
|
+
case .short:
|
|
1083
|
+
oval(NSPoint(x: tb.x - 0.4, y: tb.y + 1.2), 0.9, 1.3)
|
|
1084
|
+
case .rope: // an elephant's thin tail with a tuft
|
|
1085
|
+
let e = NSPoint(x: tb.x - 1.6 + lag * 0.5, y: tb.y - 2.8)
|
|
1086
|
+
line2(tb, e, 0.7); oval(e, 0.6, 0.8)
|
|
1087
|
+
}
|
|
1088
|
+
// wings beat once a stride, the downstroke as the body rises; the far wing goes behind the body
|
|
1089
|
+
let wingFlap: CGFloat = idle ? -0.15 : sin(ph + 0.6)
|
|
1090
|
+
let wingRoot = rot(NSPoint(x: c.x + half - 1.8, y: y0 + CGFloat(sp.chest) * 0.75), c, pitch)
|
|
1091
|
+
if sp.x.contains("wings") { featherWing(NSPoint(x: wingRoot.x + 0.6, y: wingRoot.y + 0.3), flap: idle ? -0.15 : sin(ph + 0.25), span: idle ? 5.5 : 7.6, near: false) }
|
|
1092
|
+
// torso: hip and chest masses joined along a spine that bends
|
|
1093
|
+
let sp2 = NSBezierPath(); sp2.lineWidth = CGFloat(min(sp.chest, sp.hip)) * 2.15; sp2.lineCapStyle = .round
|
|
1094
|
+
sp2.move(to: H); sp2.curve(to: S, controlPoint1: M, controlPoint2: M); sp2.stroke()
|
|
1095
|
+
let sq = 1 - 0.09 * max(0, -lift) // squashed a little on landing
|
|
1096
|
+
oval(NSPoint(x: H.x + 0.3, y: H.y), CGFloat(sp.hip) * (2 - sq), CGFloat(sp.hip) * 0.95 * sq)
|
|
1097
|
+
oval(NSPoint(x: S.x - 0.2, y: S.y - 0.25), CGFloat(sp.chest) * (2 - sq), CGFloat(sp.chest) * sq)
|
|
1098
|
+
if sp.hump { oval(rot(NSPoint(x: S.x - 1.4, y: S.y + CGFloat(sp.chest) * 0.62), S, pitch), CGFloat(sp.chest) * 0.78, CGFloat(sp.chest) * 0.62) }
|
|
1099
|
+
let br = CGFloat(min(sp.chest, sp.hip)) * 1.07
|
|
1100
|
+
func along(_ t: CGFloat) -> NSPoint { // a point on the spine, t = 0 at the hip and 1 at the shoulder
|
|
1101
|
+
let u = 1 - t; return NSPoint(x: u * u * u * H.x + 3 * u * u * t * M.x + 3 * u * t * t * M.x + t * t * t * S.x, y: u * u * u * H.y + 3 * u * u * t * M.y + 3 * u * t * t * M.y + t * t * t * S.y)
|
|
1102
|
+
}
|
|
1103
|
+
if sp.x.contains("wool") { // a white fleece with a scalloped outline: the puffs drawn dark, then hollowed out
|
|
1104
|
+
leg(sh, k.fn, CGFloat(sp.legF) * LEGK, true); leg(hp, k.hn, CGFloat(sp.legH) * LEGK, true) // under the fleece
|
|
1105
|
+
var puffs: [(NSPoint, CGFloat)] = []
|
|
1106
|
+
for i in 0...5 { let p = along(CGFloat(i) / 5); puffs.append((NSPoint(x: p.x, y: p.y + br * 0.8), br * 0.62)); puffs.append((NSPoint(x: p.x, y: p.y - br * 0.55), br * 0.58)) }
|
|
1107
|
+
puffs.append((NSPoint(x: H.x - br * 0.8, y: H.y + 0.2), br * 0.62)); puffs.append((NSPoint(x: S.x + br * 0.55, y: S.y + br * 0.35), br * 0.6))
|
|
1108
|
+
for (c3, r) in puffs { oval(c3, r, r) }
|
|
1109
|
+
oval(along(0.5), br * 1.6, br * 1.1)
|
|
1110
|
+
NSGraphicsContext.current?.compositingOperation = .clear
|
|
1111
|
+
for (c3, r) in puffs { oval(c3, r - 0.75, r - 0.75) }
|
|
1112
|
+
oval(along(0.5), br * 1.6 - 0.75, br * 1.1 - 0.75)
|
|
1113
|
+
NSGraphicsContext.current?.compositingOperation = .sourceOver
|
|
1114
|
+
}
|
|
1115
|
+
if sp.x.contains("spikes") { // a hedgehog's coat: spines over the back, pointing back
|
|
1116
|
+
for i in 0..<10 {
|
|
1117
|
+
let t = 0.05 + CGFloat(i) / 10, p = along(t), up = br * (0.6 + 0.4 * sin(t * .pi))
|
|
1118
|
+
let b0 = NSPoint(x: p.x - 0.8, y: p.y + up * 0.7), b1 = NSPoint(x: p.x + 0.8, y: p.y + up * 0.75)
|
|
1119
|
+
let tip = NSPoint(x: p.x - 2.6 - lag * 0.2, y: p.y + up + 2.8)
|
|
1120
|
+
let sp3 = NSBezierPath(); sp3.move(to: b0); sp3.line(to: tip); sp3.line(to: b1); sp3.close(); sp3.fill()
|
|
1161
1121
|
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1122
|
+
for i in 0..<3 { let p = along(0.02); let sp3 = NSBezierPath(); sp3.move(to: NSPoint(x: p.x - 0.4, y: p.y + CGFloat(i) - 0.6)); sp3.line(to: NSPoint(x: p.x - br - 1.6, y: p.y + CGFloat(i) * 1.2 - 0.6)); sp3.line(to: NSPoint(x: p.x - 0.4, y: p.y + CGFloat(i) + 0.4)); sp3.close(); sp3.fill() }
|
|
1123
|
+
}
|
|
1124
|
+
if sp.x.contains("stripes") {
|
|
1125
|
+
NSGraphicsContext.current?.compositingOperation = .clear
|
|
1126
|
+
// a tiger's stripes, cut across the back
|
|
1127
|
+
for t in [0.12, 0.32, 0.52, 0.72] as [CGFloat] { let p = along(t); line2(NSPoint(x: p.x - 0.4, y: p.y + br * 1.05), NSPoint(x: p.x + 0.4, y: p.y + br * 0.15), 0.55) }
|
|
1128
|
+
NSGraphicsContext.current?.compositingOperation = .sourceOver
|
|
1129
|
+
}
|
|
1130
|
+
if sp.x.contains("wings") { featherWing(wingRoot, flap: wingFlap, span: idle ? 6.0 : 9.0, near: true) }
|
|
1131
|
+
// neck and head, turned three-quarters toward the viewer so both eyes show; the head stays steadier than the body
|
|
1132
|
+
let hpitch = pitch * 0.35, hr = CGFloat(sp.head) * HEADK
|
|
1133
|
+
let hc = NSPoint(x: S.x + CGFloat(sp.neckX) * 0.62 * cos(pitch) - CGFloat(sp.neckY) * 0.4 * sin(pitch),
|
|
1134
|
+
y: S.y + CGFloat(sp.neckY) * 0.62 - lift * 0.3 + CGFloat(sp.neckX) * 0.8 * sin(pitch))
|
|
1135
|
+
line2(NSPoint(x: S.x + 0.4, y: S.y + 0.4), hc, hr * 1.3)
|
|
1136
|
+
if sp.mane {
|
|
1137
|
+
lionMane(hc, hr, sweep: idle ? 0.05 : 0.32 + 0.12 * lag)
|
|
1138
|
+
}
|
|
1139
|
+
oval(hc, hr * 1.05, hr)
|
|
1140
|
+
let sn = CGFloat(sp.snout), sh2 = CGFloat(sp.snoutH)
|
|
1141
|
+
if sn > 1.6 { // a dog's or fox's muzzle points forward and down from the turned face
|
|
1142
|
+
let mc = rot(NSPoint(x: hc.x + hr * 0.62 + sn * 0.2, y: hc.y - hr * 0.45), hc, hpitch)
|
|
1143
|
+
oval(mc, hr * 0.42 + sn * 0.24, sh2 * 0.7 + 0.45)
|
|
1144
|
+
if sp.hump { oval(rot(NSPoint(x: mc.x + hr * 0.42 + sn * 0.2, y: mc.y + sh2 * 0.5), mc, 0), 0.85, 0.7) } // a bear's nose at the tip
|
|
1145
|
+
}
|
|
1146
|
+
let back = (lift > 0.8 ? 0.35 : 0.0) + (idle ? 0 : 0.12)
|
|
1147
|
+
func ear(_ base0: CGFloat, _ base1: CGFloat, _ tipX: CGFloat, _ tipY: CGFloat) {
|
|
1148
|
+
let a = rot(NSPoint(x: hc.x + base0, y: hc.y + hr * 0.55), hc, hpitch), b = rot(NSPoint(x: hc.x + base1, y: hc.y + hr * 0.7), hc, hpitch)
|
|
1149
|
+
let tip = rot(NSPoint(x: hc.x + tipX, y: hc.y + tipY), hc, hpitch + CGFloat(back))
|
|
1150
|
+
let e = NSBezierPath(); e.move(to: a); e.line(to: tip); e.line(to: b); e.close(); e.fill()
|
|
1151
|
+
}
|
|
1152
|
+
switch sp.ear {
|
|
1153
|
+
case .pricked: ear(-hr * 0.9, -hr * 0.15, -hr * 0.7, hr * 1.75); ear(hr * 0.05, hr * 0.85, hr * 0.55, hr * 1.75)
|
|
1154
|
+
case .cat: ear(-hr * 0.95, -hr * 0.2, -hr * 0.72, hr * 1.55); ear(hr * 0.0, hr * 0.85, hr * 0.5, hr * 1.55)
|
|
1155
|
+
case .round:
|
|
1156
|
+
for dx in [-hr * 0.6, hr * 0.45] { let p = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.82), hc, hpitch); oval(p, hr * 0.38, hr * 0.38) }
|
|
1157
|
+
case .long:
|
|
1158
|
+
for (dx, sw) in [(-hr * 0.45, 0.1), (hr * 0.2, 0.3)] as [(CGFloat, CGFloat)] {
|
|
1159
|
+
let base = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.6), hc, hpitch)
|
|
1160
|
+
let ang = hpitch + CGFloat(back) * 1.6 + 0.3 + sw - lag * 0.15
|
|
1161
|
+
let tip = NSPoint(x: base.x - sin(ang) * hr * 1.55, y: base.y + cos(ang) * hr * 1.55)
|
|
1162
|
+
taper(base, tip, hr * 0.42, hr * 0.36)
|
|
1168
1163
|
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1164
|
+
case .tiny, .none: break
|
|
1165
|
+
case .floppy: // a puppy's ears hang and swing
|
|
1166
|
+
// the far ear peeks over the crown; the near one hangs by the cheek, set off from the head by a thin gap
|
|
1167
|
+
let fb = rot(NSPoint(x: hc.x + hr * 0.55, y: hc.y + hr * 0.75), hc, hpitch)
|
|
1168
|
+
taper(fb, NSPoint(x: fb.x + hr * 0.35, y: fb.y - hr * 0.35), hr * 0.5, hr * 0.45)
|
|
1169
|
+
let base = rot(NSPoint(x: hc.x - hr * 0.88, y: hc.y + hr * 0.55), hc, hpitch)
|
|
1170
|
+
let tip = NSPoint(x: base.x - hr * 0.55 - lag * hr * 0.3, y: base.y - hr * 1.4 + (lift > 0.8 ? hr * 0.55 : 0))
|
|
1171
|
+
NSGraphicsContext.current?.compositingOperation = .clear
|
|
1172
|
+
taper(base, tip, hr * 0.5 + 1.0, hr * 0.66 + 1.0)
|
|
1173
|
+
NSGraphicsContext.current?.compositingOperation = .sourceOver
|
|
1174
|
+
taper(base, tip, hr * 0.5, hr * 0.66)
|
|
1175
|
+
case .side: // round ears on the sides: big and fluffy on a koala
|
|
1176
|
+
let big = sp.x.contains("koalanose")
|
|
1177
|
+
for (dx, dy, r) in [(-hr * (big ? 0.95 : 1.0), hr * (big ? 0.55 : 0.15), hr * (big ? 0.62 : 0.36)), (hr * (big ? 0.8 : 0.95), hr * (big ? 0.6 : 0.2), hr * (big ? 0.5 : 0.3))] as [(CGFloat, CGFloat, CGFloat)] {
|
|
1178
|
+
let ec = rot(NSPoint(x: hc.x + dx, y: hc.y + dy), hc, hpitch)
|
|
1179
|
+
oval(ec, r, r)
|
|
1180
|
+
if big { NSGraphicsContext.current?.compositingOperation = .clear; oval(NSPoint(x: ec.x + (dx < 0 ? -r * 0.12 : r * 0.12), y: ec.y + r * 0.05), r * 0.55, r * 0.55); NSGraphicsContext.current?.compositingOperation = .sourceOver }
|
|
1175
1181
|
}
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1182
|
+
case .mouse:
|
|
1183
|
+
for (dx, r) in [(-hr * 0.55, hr * 0.62), (hr * 0.45, hr * 0.55)] as [(CGFloat, CGFloat)] { oval(rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 1.0), hc, hpitch), r, r) }
|
|
1184
|
+
case .horse: ear(-hr * 0.6, -hr * 0.15, -hr * 0.55, hr * 1.6); ear(hr * 0.0, hr * 0.4, hr * 0.15, hr * 1.55)
|
|
1185
|
+
case .sheep:
|
|
1186
|
+
for (dx, f) in [(-hr * 0.7, 1.0), (hr * 0.4, 0.8)] as [(CGFloat, CGFloat)] { let b = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.45), hc, hpitch); taper(b, NSPoint(x: b.x - hr * 0.9 * f, y: b.y - hr * 0.1 + lag * 0.2), hr * 0.42, hr * 0.32) }
|
|
1187
|
+
case .pig: ear(-hr * 0.85, -hr * 0.15, hr * 0.1, hr * 1.35); ear(hr * 0.0, hr * 0.7, hr * 0.95, hr * 1.2)
|
|
1188
|
+
}
|
|
1189
|
+
// head features
|
|
1190
|
+
if sp.x.contains("horn") {
|
|
1191
|
+
let a = rot(NSPoint(x: hc.x + hr * 0.15, y: hc.y + hr * 0.8), hc, hpitch), b = rot(NSPoint(x: hc.x + hr * 0.65, y: hc.y + hr * 0.85), hc, hpitch), t = rot(NSPoint(x: hc.x + hr * 1.15, y: hc.y + hr * 2.25), hc, hpitch)
|
|
1192
|
+
let h = NSBezierPath(); h.move(to: a); h.line(to: t); h.line(to: b); h.close(); h.fill()
|
|
1193
|
+
}
|
|
1194
|
+
if sp.x.contains("neckmane") { // a mane down the back of the neck, streaming in the run
|
|
1195
|
+
for i in 0..<5 {
|
|
1196
|
+
let t = CGFloat(i) / 4, base = NSPoint(x: hc.x - hr * 0.75 + (S.x - 0.6 - hc.x + hr * 0.75) * t, y: hc.y + hr * 0.55 + (S.y + CGFloat(sp.chest) * 0.7 - hc.y - hr * 0.55) * t)
|
|
1197
|
+
let tip = NSPoint(x: base.x - 2.2 - lag * 0.5, y: base.y + 0.4 - t * 0.6)
|
|
1198
|
+
let m = NSBezierPath(); m.move(to: NSPoint(x: base.x + 0.7, y: base.y + 0.4)); m.line(to: tip); m.line(to: NSPoint(x: base.x + 0.3, y: base.y - 0.9)); m.close(); m.fill()
|
|
1184
1199
|
}
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1200
|
+
}
|
|
1201
|
+
if sp.x.contains("antlers") {
|
|
1202
|
+
for (dx, f) in [(-hr * 0.35, 1.0), (hr * 0.2, 0.85)] as [(CGFloat, CGFloat)] {
|
|
1203
|
+
let b = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.8), hc, hpitch)
|
|
1204
|
+
let top = NSPoint(x: b.x - hr * 0.7 * f, y: b.y + hr * 1.7 * f), m1 = NSPoint(x: b.x - hr * 0.25 * f, y: b.y + hr * 0.75 * f), m2 = NSPoint(x: b.x - hr * 0.5 * f, y: b.y + hr * 1.25 * f)
|
|
1205
|
+
line2(b, top, 0.75); line2(m1, NSPoint(x: m1.x + hr * 0.55 * f, y: m1.y + hr * 0.45 * f), 0.65); line2(m2, NSPoint(x: m2.x + hr * 0.5 * f, y: m2.y + hr * 0.55 * f), 0.6)
|
|
1191
1206
|
}
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1207
|
+
}
|
|
1208
|
+
if sp.x.contains("trunk") { // an elephant: a big ear set apart from the head, and a swinging trunk
|
|
1209
|
+
let ec = rot(NSPoint(x: hc.x - hr * 0.95, y: hc.y - hr * 0.05), hc, hpitch)
|
|
1210
|
+
NSGraphicsContext.current?.compositingOperation = .clear
|
|
1211
|
+
NSBezierPath(ovalIn: NSRect(x: ec.x - hr * 0.78, y: ec.y - hr * 0.98, width: hr * 1.56, height: hr * 1.96)).fill()
|
|
1212
|
+
NSGraphicsContext.current?.compositingOperation = .sourceOver
|
|
1213
|
+
oval(ec, hr * 0.68 + lag * 0.15, hr * 0.88)
|
|
1214
|
+
let r0 = rot(NSPoint(x: hc.x + hr * 0.8, y: hc.y - hr * 0.25), hc, hpitch), mid = NSPoint(x: r0.x + hr * 0.55, y: r0.y - hr * 0.8), tip = NSPoint(x: r0.x + hr * 0.6 + lag * hr * 0.35, y: r0.y - hr * 1.7)
|
|
1215
|
+
taper(r0, mid, hr * 0.7, hr * 0.5); taper(mid, tip, hr * 0.5, hr * 0.38)
|
|
1216
|
+
}
|
|
1217
|
+
if sp.x.contains("pigsnout") {
|
|
1218
|
+
let c2 = rot(NSPoint(x: hc.x + hr * 1.0, y: hc.y - hr * 0.3), hc, hpitch)
|
|
1219
|
+
oval(c2, hr * 0.38, hr * 0.48)
|
|
1220
|
+
NSGraphicsContext.current?.compositingOperation = .clear
|
|
1221
|
+
for dy in [hr * 0.15, -hr * 0.17] { oval(NSPoint(x: c2.x + hr * 0.12, y: c2.y + dy), hr * 0.09, hr * 0.12) }
|
|
1222
|
+
NSGraphicsContext.current?.compositingOperation = .sourceOver
|
|
1223
|
+
}
|
|
1224
|
+
if sp.x.contains("koalanose") { oval(rot(NSPoint(x: hc.x + hr * 1.0, y: hc.y - hr * 0.2), hc, hpitch), hr * 0.38, hr * 0.5) }
|
|
1225
|
+
if sp.x.contains("panda") { // pale face, dark eye patches
|
|
1226
|
+
NSGraphicsContext.current?.compositingOperation = .clear
|
|
1227
|
+
oval(hc, hr * 0.84, hr * 0.8)
|
|
1228
|
+
NSGraphicsContext.current?.compositingOperation = .sourceOver
|
|
1229
|
+
for (x, y, r) in [(0.42, 0.06, 0.36), (-0.2, 0.1, 0.3)] as [(CGFloat, CGFloat, CGFloat)] {
|
|
1230
|
+
let p = NSBezierPath(ovalIn: NSRect(x: -r * hr, y: -r * hr * 0.8, width: 2 * r * hr, height: 1.6 * r * hr))
|
|
1231
|
+
let tr = NSAffineTransform(); tr.translateX(by: hc.x + hr * x, yBy: hc.y + hr * y); tr.rotate(byRadians: -0.5); p.transform(using: tr as AffineTransform); p.fill()
|
|
1202
1232
|
}
|
|
1203
|
-
|
|
1204
|
-
if !sp.x.contains("wool") { leg(sh, k.fn, CGFloat(sp.legF) * LEGK, true); leg(hp, k.hn, CGFloat(sp.legH) * LEGK, true) }
|
|
1205
|
-
eyes(NSPoint(x: hc.x + hr * CGFloat(sp.eyeDx), y: hc.y), hr, hpitch, CGFloat(sp.eyeK))
|
|
1206
|
-
return true
|
|
1233
|
+
oval(NSPoint(x: hc.x + hr * 0.78, y: hc.y - hr * 0.32), hr * 0.17, hr * 0.13)
|
|
1207
1234
|
}
|
|
1208
|
-
|
|
1209
|
-
|
|
1235
|
+
// near legs
|
|
1236
|
+
if !sp.x.contains("wool") { leg(sh, k.fn, CGFloat(sp.legF) * LEGK, true); leg(hp, k.hn, CGFloat(sp.legH) * LEGK, true) }
|
|
1237
|
+
eyes(NSPoint(x: hc.x + hr * CGFloat(sp.eyeDx), y: hc.y), hr, hpitch, CGFloat(sp.eyeK))
|
|
1210
1238
|
}
|
|
1211
1239
|
|
|
1212
1240
|
/** A penguin does not gallop: it waddles, rocking side to side with the flippers out. */
|
|
@@ -1663,7 +1691,7 @@ struct SessionRow: View {
|
|
|
1663
1691
|
VStack(alignment: .leading, spacing: 4) {
|
|
1664
1692
|
HStack(alignment: .center, spacing: 6) {
|
|
1665
1693
|
Badge(agent: s.agent)
|
|
1666
|
-
Text(s.
|
|
1694
|
+
Text(s.label).font(.system(size: 13, weight: .semibold)).lineLimit(2).multilineTextAlignment(.leading).fixedSize(horizontal: false, vertical: true)
|
|
1667
1695
|
Spacer(minLength: 6)
|
|
1668
1696
|
if let c = s.usage?.costUsd { Text(String(format: "$%.2f", c)).font(.system(size: 12.5, weight: .medium)).monospacedDigit().fixedSize().help("이 세션의 비용, 정가 환산") }
|
|
1669
1697
|
}
|
|
@@ -2258,7 +2286,7 @@ struct SessionView: View {
|
|
|
2258
2286
|
if let s = s {
|
|
2259
2287
|
FitScroll(limit: limit - 70, still: still) {
|
|
2260
2288
|
VStack(alignment: .leading, spacing: 6) {
|
|
2261
|
-
HStack(spacing: 7) { Badge(agent: s.agent); Text(s.
|
|
2289
|
+
HStack(spacing: 7) { Badge(agent: s.agent); Text(s.label).font(.system(size: 15, weight: .semibold)).lineLimit(1).truncationMode(.middle) }
|
|
2262
2290
|
if let c = s.cwd { Text(c).font(.system(size: 10.5, design: .monospaced)).foregroundColor(.secondary).lineLimit(1).truncationMode(.head).textSelection(.enabled) }
|
|
2263
2291
|
HStack(spacing: 6) { Circle().fill(stateColor(s)).frame(width: 7, height: 7); Text(activity(s, now: now)).font(.system(size: 12)) }
|
|
2264
2292
|
Divider().padding(.vertical, 2)
|
|
@@ -2453,7 +2481,7 @@ struct SubTile: View {
|
|
|
2453
2481
|
HStack(spacing: 7) {
|
|
2454
2482
|
Image(systemName: "arrow.turn.down.right").font(.system(size: 10, weight: .semibold)).foregroundColor(pal.text2)
|
|
2455
2483
|
if phase == .active { LiveDot(color: edge) } else { Image(systemName: mark.symbol).font(.system(size: 10.5)).foregroundColor(phase == .idle ? pal.text2 : edge).frame(width: 12) }
|
|
2456
|
-
Text(s.
|
|
2484
|
+
Text(s.label).font(.system(size: 12, weight: .medium)).foregroundColor(pal.text).lineLimit(1).truncationMode(.tail)
|
|
2457
2485
|
Spacer(minLength: 4)
|
|
2458
2486
|
Text("\(mark.label) \(sinceText(s.stateSince, now: now))").font(.system(size: 10.5)).foregroundColor(pal.text2).lineLimit(1).fixedSize()
|
|
2459
2487
|
if let c = s.context { Text(c.pct.map { "\(Int($0))%" } ?? tokText(c.tokens)).font(.system(size: 11, weight: .medium)).monospacedDigit().foregroundColor(pal.text).fixedSize().help("컨텍스트") }
|
|
@@ -2496,7 +2524,7 @@ struct SessionTile: View {
|
|
|
2496
2524
|
HStack(spacing: 7) {
|
|
2497
2525
|
Text(s.agent == "codex" ? "Codex" : "Claude").font(.system(size: 9.5, weight: .bold)).foregroundColor(.white).padding(.horizontal, 6).padding(.vertical, 2).background(Capsule().fill(tint)).fixedSize()
|
|
2498
2526
|
if let up = parentName { Image(systemName: "arrow.turn.down.right").font(.system(size: 10.5, weight: .semibold)).foregroundColor(pal.text2).help("\(up) 세션이 띄운 세션") }
|
|
2499
|
-
Text(s.
|
|
2527
|
+
Text(s.label).font(.system(size: 13.5, weight: .semibold)).foregroundColor(pal.text).lineLimit(1).truncationMode(.middle).help(s.fullName)
|
|
2500
2528
|
Spacer(minLength: 6)
|
|
2501
2529
|
}
|
|
2502
2530
|
HStack(spacing: 5) {
|
|
@@ -2831,7 +2859,7 @@ struct DashboardView: View {
|
|
|
2831
2859
|
func inspector(_ s: Session, _ snap: Snapshot, _ pal: Pal) -> some View {
|
|
2832
2860
|
let body = VStack(alignment: .leading, spacing: 6) {
|
|
2833
2861
|
HStack(spacing: 7) {
|
|
2834
|
-
Text(s.
|
|
2862
|
+
Text(s.label).font(.system(size: 15, weight: .semibold)).lineLimit(1).truncationMode(.middle)
|
|
2835
2863
|
Spacer(minLength: 6)
|
|
2836
2864
|
Button(action: { jump(to: s) }) { HStack(spacing: 4) { Image(systemName: "arrow.up.forward.app"); Text("세션으로 이동") }.font(.system(size: 11.5, weight: .medium)).padding(.horizontal, 8).padding(.vertical, 4).background(RoundedRectangle(cornerRadius: 6).fill(pal.well)).contentShape(Rectangle()) }
|
|
2837
2865
|
.buttonStyle(HoverStyle(radius: 6)).help("이 세션이 열려 있는 터미널 앱을 앞으로 가져옵니다")
|
|
@@ -2947,7 +2975,7 @@ struct DashboardView: View {
|
|
|
2947
2975
|
let sm = model.samples, ses = snap.sessions
|
|
2948
2976
|
let cpu = cpuSplit(snap, pal), mem = memSplit(snap, pal)
|
|
2949
2977
|
func tops(_ pick: (AppLoad) -> Double, _ of: (Session) -> Double, _ part: (Work) -> Double, _ show: (Double) -> String) -> [Top] {
|
|
2950
|
-
var t = ses.map { s in Top(id: "s\(s.pid)", name: s.
|
|
2978
|
+
var t = ses.map { s in Top(id: "s\(s.pid)", name: s.label, value: of(s), color: pal.agent(s.agent), pid: s.pid, program: heaviest(s, total: of(s), part, show), doing: doingNow(s)) }
|
|
2951
2979
|
t += model.leftoverItems.map { Top(id: "l\($0.id)", name: $0.name, value: pick($0), color: pal.left, origin: leftOrigin($0.id)) }
|
|
2952
2980
|
t += model.others.map { Top(id: "o\($0.id)", name: $0.name, value: pick($0), color: pal.neutral, origin: "세션과 무관한 프로그램", originSymbol: "macwindow") }
|
|
2953
2981
|
return Array(t.sorted { $0.value > $1.value }.prefix(5))
|
|
@@ -3056,7 +3084,7 @@ struct DashboardView: View {
|
|
|
3056
3084
|
let gap: CGFloat = 12, minCell: CGFloat = 318
|
|
3057
3085
|
let cols = max(1, Int((width + gap) / (minCell + gap)))
|
|
3058
3086
|
let cell = (width - CGFloat(cols - 1) * gap) / CGFloat(cols)
|
|
3059
|
-
let names = Dictionary(snap.sessions.map { ($0.pid, $0.
|
|
3087
|
+
let names = Dictionary(snap.sessions.map { ($0.pid, $0.label) }, uniquingKeysWith: { a, _ in a })
|
|
3060
3088
|
// A group is as wide as its main sessions need, and at least wide enough to lay its started sessions side by side.
|
|
3061
3089
|
let isSub: (Session, SessionGroup) -> Bool = { s, g in model.parentSession[s.pid].map { up in g.sessions.contains { $0.pid == up } } ?? false }
|
|
3062
3090
|
let spanOf: (SessionGroup) -> Int = { g in
|
|
@@ -3134,7 +3162,7 @@ struct DashboardView: View {
|
|
|
3134
3162
|
let ph = model.phase(s), tint = pal.state(ph), mark = stateMark(s)
|
|
3135
3163
|
let byLoad = ph == .active && s.state != "busy" && s.state != "shell" && s.subagents == 0
|
|
3136
3164
|
let pending = (s.detail?.recent ?? []).last { $0.pending == true }
|
|
3137
|
-
let name = Text(s.
|
|
3165
|
+
let name = Text(s.label).font(.system(size: 12.5, weight: .semibold)).foregroundColor(pal.text)
|
|
3138
3166
|
let row = VStack(alignment: .leading, spacing: 6) {
|
|
3139
3167
|
HStack(alignment: dense ? .top : .center, spacing: 6) {
|
|
3140
3168
|
if ph == .active { LiveDot(color: tint) } else { Image(systemName: mark.symbol).font(.system(size: 11)).foregroundColor(tint).frame(width: 12) }
|
|
@@ -3190,7 +3218,7 @@ struct DashboardView: View {
|
|
|
3190
3218
|
}
|
|
3191
3219
|
/** A session resting at its prompt: one quiet line. */
|
|
3192
3220
|
func idleRow(_ s: Session, _ snap: Snapshot, _ pal: Pal, dense: Bool, pick: @escaping (Session) -> Void) -> some View {
|
|
3193
|
-
let name = Text(s.
|
|
3221
|
+
let name = Text(s.label).font(.system(size: 12)).foregroundColor(pal.text2)
|
|
3194
3222
|
return Pressable(radius: 6, action: { pick(s) }) {
|
|
3195
3223
|
HStack(alignment: dense ? .top : .center, spacing: 6) {
|
|
3196
3224
|
Image(systemName: "pause.circle").font(.system(size: 11)).foregroundColor(pal.text2).frame(width: 12)
|
|
@@ -3584,6 +3612,16 @@ final class FloatPanel: NSPanel { override var canBecomeKey: Bool { true } }
|
|
|
3584
3612
|
* species that runs in the menu bar. It is one still frame, redrawn only when the grade changes; a running Dock icon
|
|
3585
3613
|
* would spend CPU and pull the eye away from the dashboard. Drawn on the macOS icon grid (an 824 square in 1024).
|
|
3586
3614
|
*/
|
|
3615
|
+
/**
|
|
3616
|
+
* Give the launcher bundle the CLI writes (~/Applications/Sprag Bar.app, src/bar-app.js installLauncher) the same icon
|
|
3617
|
+
* as the Dock, so Spotlight and Launchpad show the runner instead of a blank app. Only a bundle whose Info.plist names
|
|
3618
|
+
* the launcher's id is touched; a missing one is left for the CLI to write.
|
|
3619
|
+
*/
|
|
3620
|
+
func paintLauncher(_ icon: NSImage) {
|
|
3621
|
+
let path = NSHomeDirectory() + "/Applications/Sprag Bar.app"
|
|
3622
|
+
guard let plist = try? String(contentsOfFile: path + "/Contents/Info.plist", encoding: .utf8), plist.contains("io.sprag.bar-launcher") else { return }
|
|
3623
|
+
NSWorkspace.shared.setIcon(icon, forFile: path, options: [])
|
|
3624
|
+
}
|
|
3587
3625
|
func dockIcon(_ grade: String?) -> NSImage {
|
|
3588
3626
|
let sp = runnerSpecies(grade)
|
|
3589
3627
|
// a frame that reads as that animal at rest in motion: wings up for fliers, mid-leap for the frog, a stride otherwise
|
|
@@ -3766,10 +3804,14 @@ final class App: NSObject {
|
|
|
3766
3804
|
b.toolTip = model.sysCpu != nil ? String(format: "기기 전체 CPU %.0f%%, 그중 AI 세션 %.0f%%. 세션 %d개 실행 중", (model.sysCpu ?? 0) * 100, model.share(nil), s.totals.sessions) : "작업 중인 세션 수 / 실행 중인 세션 수"
|
|
3767
3805
|
}
|
|
3768
3806
|
var dockGrade: String? = nil // the grade the Dock icon was drawn for
|
|
3807
|
+
var launcherGrade: String?? = .none // the grade the launcher's icon was drawn for, .none until the first snapshot
|
|
3769
3808
|
func animate() {
|
|
3770
3809
|
if NSApp.activationPolicy() == .regular, model.snap?.animal?.grade != dockGrade {
|
|
3771
3810
|
dockGrade = model.snap?.animal?.grade; NSApp.applicationIconImage = dockIcon(dockGrade)
|
|
3772
3811
|
}
|
|
3812
|
+
if selftest == nil, let snap = model.snap, launcherGrade != .some(snap.animal?.grade) {
|
|
3813
|
+
launcherGrade = .some(snap.animal?.grade); paintLauncher(dockIcon(snap.animal?.grade))
|
|
3814
|
+
}
|
|
3773
3815
|
// RunCat's rule, on the same thing RunCat measures: the whole machine. A runner that strolls while the machine is
|
|
3774
3816
|
// flat out, because the agent sessions' own share happens to be small, reads as wrong.
|
|
3775
3817
|
let load = min(100, max(0, (model.sysCpu ?? 0) * 100))
|
|
@@ -4073,8 +4115,8 @@ func dashboardTest(_ prefix: String) {
|
|
|
4073
4115
|
if let icon = NSApp.applicationIconImage { png(icon, "\(prefix)-dock.png") }
|
|
4074
4116
|
print("DOCK icon drawn for grade \(main.dockGrade ?? "none") (species \(runnerSpecies(main.dockGrade).id))")
|
|
4075
4117
|
print("DOCK regular app while the dashboard is open: \(NSApp.activationPolicy() == .regular) | icon set \(NSApp.applicationIconImage != nil) | menu \(NSApp.mainMenu != nil) | reopen handler \(NSApp.delegate is App)")
|
|
4076
|
-
print("STARTED BY " + (m.parentSession.isEmpty ? "none" : m.parentSession.map { c, up in "\(m.snap?.sessions.first { $0.pid == c }?.
|
|
4077
|
-
print("PHASE " + (m.snap?.sessions ?? []).map { s in "\(s.
|
|
4118
|
+
print("STARTED BY " + (m.parentSession.isEmpty ? "none" : m.parentSession.map { c, up in "\(m.snap?.sessions.first { $0.pid == c }?.label ?? "\(c)") <- \(m.snap?.sessions.first { $0.pid == up }?.label ?? "\(up)")" }.sorted().joined(separator: " | ")))
|
|
4119
|
+
print("PHASE " + (m.snap?.sessions ?? []).map { s in "\(s.label) \(m.phase(s)) [" + m.working(s, max: 3).map { "\($0.name) cpu \(pct1($0.w.cpu * 100)) gpu \(pct1($0.w.gpu * 100)) \(memText($0.w.mem))" }.joined(separator: "; ") + "]" }.joined(separator: " | "))
|
|
4078
4120
|
render(DashboardView(model: m, still: true).frame(width: 1480), "\(prefix)-dashboard-dark.png")
|
|
4079
4121
|
render(DashboardView(model: m, still: true, width: 340).frame(width: 340), "\(prefix)-dashboard-mini-dark.png")
|
|
4080
4122
|
render(DashboardView(model: m, still: true, width: 780).frame(width: 780), "\(prefix)-dashboard-medium-dark.png")
|
|
@@ -4088,8 +4130,8 @@ func dashboardTest(_ prefix: String) {
|
|
|
4088
4130
|
let oth = m.others.reduce(Load()) { var l = $0; l.cpu += $1.cpu; l.mem += $1.mem; l.n += $1.n; return l }
|
|
4089
4131
|
print("CENSUS machine CPU \(pct1((m.sysCpu ?? 0) * 100)) mem \(memText(m.sysMemMb)) | session trees \(pct1(tree.cpu * 100)) \(memText(tree.mem)) (\(tree.n)) | detached \(pct1(det.cpu * 100)) \(memText(det.mem)) (\(det.n)) | left by ended sessions \(pct1(m.leftover.cpu * 100)) \(memText(m.leftover.mem)) (\(m.leftover.n)) | other programs \(pct1(oth.cpu * 100)) \(memText(oth.mem)) (\(oth.n))")
|
|
4090
4132
|
print("CENSUS CLI figures for the same sessions: CPU \(pct1((m.snap?.sessions ?? []).reduce(0) { $0 + Model.raw($1) })) mem \(memText((m.snap?.sessions ?? []).reduce(0) { $0 + ($1.rssMb ?? 0) })) | leftover kinds \(m.leftoverItems.count) | other apps \(m.others.count)")
|
|
4091
|
-
print("CPUOF " + (m.snap?.sessions ?? []).map { "\($0.
|
|
4092
|
-
print("JUMP " + (m.snap?.sessions ?? []).map { "\($0.
|
|
4133
|
+
print("CPUOF " + (m.snap?.sessions ?? []).map { "\($0.label) \(pct1(m.cpuOf($0))) \(memText(m.memOf($0)))" }.joined(separator: " | "))
|
|
4134
|
+
print("JUMP " + (m.snap?.sessions ?? []).map { "\($0.label) opens \(owningApp($0.pid)?.localizedName ?? "nothing found")\(exactTab($0) == nil ? ", app only" : ", its own tab")" }.joined(separator: " | ") + " | responsible-process lookup \(RESPONSIBLE == nil ? "missing" : "present")")
|
|
4093
4135
|
print("LEFT " + m.leftoverItems.prefix(6).map { "\($0.name) x\($0.n) \(memText($0.mem))" }.joined(separator: " | "))
|
|
4094
4136
|
print("OTHER " + m.others.sorted { $0.cpu > $1.cpu }.prefix(5).map { "\($0.name) \(pct1($0.cpu * 100)) \(memText($0.mem))" }.joined(separator: " | "))
|
|
4095
4137
|
print("GROUPS " + groupSessions(m.snap?.sessions ?? [], parents: m.parentSession).map { "\($0.name) x\($0.sessions.count)" }.joined(separator: " | ") + " | started by another session \(m.parentSession.count)")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprag-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.137.0",
|
|
4
4
|
"description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/agent-activity.js
CHANGED
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
* - Model, context window use, tokens, cost and the account limits come from
|
|
31
31
|
* agent-usage.js: the transcript tail, the statusline's caches in the user
|
|
32
32
|
* data folder, and the Codex rollout files.
|
|
33
|
+
* - A Claude row's `title` is what tells sessions apart on screen, where `name`
|
|
34
|
+
* is often the folder plus a number: a name given with /rename, else the last
|
|
35
|
+
* prompt or Claude Code's topic title from the transcript tail (agent-detail.js
|
|
36
|
+
* sessionTitleHints). null when there is none; Codex rows are always null.
|
|
37
|
+
* Rows are still sorted by `name`, so a new prompt does not reorder them.
|
|
33
38
|
* - A Claude row's effort level is the one the statusline recorded in the user
|
|
34
39
|
* data folder (session-effort.js); Codex rows read theirs from the rollout.
|
|
35
40
|
* - With `detail`, each row also carries the session's latest typed request, its
|
|
@@ -58,7 +63,7 @@ import { loadCache } from './session-cache.js';
|
|
|
58
63
|
import { codexUserDir } from './agent.js';
|
|
59
64
|
import { userLanguage } from './config.js';
|
|
60
65
|
import { readSessionEffort } from './session-effort.js';
|
|
61
|
-
import { sessionDetail } from './agent-detail.js';
|
|
66
|
+
import { sessionDetail, sessionTitleHints } from './agent-detail.js';
|
|
62
67
|
import { writeStateFile } from './state-file.js';
|
|
63
68
|
import { currentWarnings } from './agent-warnings.js';
|
|
64
69
|
import {
|
|
@@ -246,6 +251,40 @@ function standingFor(st, { lang, org }) {
|
|
|
246
251
|
const defaultCores = () => os.availableParallelism?.() ?? os.cpus().length;
|
|
247
252
|
const dirName = (cwd) => (typeof cwd === 'string' && cwd ? basename(cwd) || null : null);
|
|
248
253
|
|
|
254
|
+
const TITLE_MAX = 80;
|
|
255
|
+
/** A prompt this short (spaces not counted) says little by itself: "ok", "승인완료". */
|
|
256
|
+
const TITLE_MIN_CHARS = 5;
|
|
257
|
+
|
|
258
|
+
function clipTitle(text) {
|
|
259
|
+
const chars = Array.from(text);
|
|
260
|
+
return chars.length > TITLE_MAX ? `${chars.slice(0, TITLE_MAX).join('')}…` : text;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* What tells one session from another on screen. Claude Code names a session
|
|
265
|
+
* after its folder plus a number (`sprag-6b`, nameSource "derived"), which does
|
|
266
|
+
* not. In order: a name the user gave with /rename, the last prompt when it is
|
|
267
|
+
* substantial, Claude Code's own topic title, any last prompt, else null (the
|
|
268
|
+
* caller falls back to `name`). Pure; `hints` is sessionTitleHints()'s result.
|
|
269
|
+
*
|
|
270
|
+
* @param {{ name?: unknown, nameSource?: unknown }} file the session file
|
|
271
|
+
* @param {{ lastPrompt?: string|null, aiTitle?: string|null }} hints
|
|
272
|
+
* @returns {string|null}
|
|
273
|
+
*/
|
|
274
|
+
export function pickTitle(file, hints) {
|
|
275
|
+
const given = typeof file?.name === 'string' ? file.name.trim() : '';
|
|
276
|
+
if (typeof file?.nameSource === 'string' && file.nameSource !== 'derived' && given) return clipTitle(given);
|
|
277
|
+
const raw = typeof hints?.lastPrompt === 'string' ? hints.lastPrompt : '';
|
|
278
|
+
const firstLine = raw.split(/\r?\n/).find((l) => l.trim() !== '') ?? '';
|
|
279
|
+
const prompt = firstLine.replace(/\s+/g, ' ').trim();
|
|
280
|
+
const substantial = prompt !== '' && !prompt.startsWith('/') && !prompt.startsWith('<')
|
|
281
|
+
&& Array.from(prompt.replace(/\s/g, '')).length >= TITLE_MIN_CHARS;
|
|
282
|
+
if (substantial) return clipTitle(prompt);
|
|
283
|
+
const ai = typeof hints?.aiTitle === 'string' ? hints.aiTitle.trim() : '';
|
|
284
|
+
if (ai) return clipTitle(ai);
|
|
285
|
+
return prompt ? clipTitle(prompt) : null;
|
|
286
|
+
}
|
|
287
|
+
|
|
249
288
|
function claudeRow(file, { claudeDir, dataDir, now, table, env, getCache, detail, promptCache }) {
|
|
250
289
|
const cwd = typeof file.cwd === 'string' && file.cwd ? file.cwd : null;
|
|
251
290
|
const project = dirName(cwd);
|
|
@@ -262,11 +301,14 @@ function claudeRow(file, { claudeDir, dataDir, now, table, env, getCache, detail
|
|
|
262
301
|
const usage = claudeSessionDetail({ sessionId: file.sessionId, transcript, dataDir, cache: getCache(), env, now });
|
|
263
302
|
let effort = null;
|
|
264
303
|
try { effort = readSessionEffort(file.sessionId, { dir: dataDir }); } catch { effort = null; }
|
|
304
|
+
let title = null;
|
|
305
|
+
try { title = pickTitle(file, transcript ? sessionTitleHints({ transcript }) : {}); } catch { title = null; }
|
|
265
306
|
const row = {
|
|
266
307
|
agent: 'claude',
|
|
267
308
|
pid: file.pid,
|
|
268
309
|
sessionId: file.sessionId,
|
|
269
310
|
name,
|
|
311
|
+
title,
|
|
270
312
|
project,
|
|
271
313
|
cwd,
|
|
272
314
|
kind: typeof file.kind === 'string' ? file.kind : null,
|
|
@@ -358,7 +400,7 @@ export function collectActivity({
|
|
|
358
400
|
}
|
|
359
401
|
if (nested) continue;
|
|
360
402
|
const row = {
|
|
361
|
-
agent: 'codex', pid: p.pid, sessionId: null, name: 'codex', project: null, cwd: null, kind: null,
|
|
403
|
+
agent: 'codex', pid: p.pid, sessionId: null, name: 'codex', title: null, project: null, cwd: null, kind: null,
|
|
362
404
|
state: null, stateSince: null, tools: [], subagents: 0,
|
|
363
405
|
model: null, modelName: null, effort: null, context: null, usage: null,
|
|
364
406
|
cpu: 0, cpuPct: null, rssMb: 0, procs: 0,
|
package/src/agent-detail.js
CHANGED
|
@@ -208,6 +208,47 @@ function scanBack(fd, lo, hi, chunkBytes) {
|
|
|
208
208
|
return null;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* The two lines Claude Code writes to name a session in its own picker: the last
|
|
213
|
+
* typed prompt (`last-prompt`, rewritten every turn) and a title it makes from the
|
|
214
|
+
* opening topic (`ai-title`, absent in a brand new session). Only the last
|
|
215
|
+
* `tailBytes` are read, and a line is parsed only when it carries one of the two
|
|
216
|
+
* type markers; the newest of each wins. Never throws.
|
|
217
|
+
*
|
|
218
|
+
* @returns {{ lastPrompt: string|null, aiTitle: string|null }}
|
|
219
|
+
*/
|
|
220
|
+
export function sessionTitleHints({ transcript, tailBytes = TRANSCRIPT_TAIL } = {}) {
|
|
221
|
+
const out = { lastPrompt: null, aiTitle: null };
|
|
222
|
+
if (typeof transcript !== 'string' || transcript === '') return out;
|
|
223
|
+
let fd;
|
|
224
|
+
try {
|
|
225
|
+
fd = openSync(transcript, 'r');
|
|
226
|
+
const size = fstatSync(fd).size;
|
|
227
|
+
if (size <= 0) return out;
|
|
228
|
+
const tailStart = Math.max(0, size - tailBytes);
|
|
229
|
+
const lines = readRange(fd, tailStart, size - tailStart).toString('utf8').split('\n');
|
|
230
|
+
if (tailStart > 0) lines.shift();
|
|
231
|
+
for (const line of lines) {
|
|
232
|
+
const isPrompt = line.includes('"type":"last-prompt"');
|
|
233
|
+
const isTitle = !isPrompt && line.includes('"type":"ai-title"');
|
|
234
|
+
if (!isPrompt && !isTitle) continue;
|
|
235
|
+
try {
|
|
236
|
+
const entry = JSON.parse(line);
|
|
237
|
+
if (!entry || typeof entry !== 'object') continue;
|
|
238
|
+
if (isPrompt && entry.type === 'last-prompt' && typeof entry.lastPrompt === 'string') out.lastPrompt = entry.lastPrompt;
|
|
239
|
+
if (isTitle && entry.type === 'ai-title' && typeof entry.aiTitle === 'string') out.aiTitle = entry.aiTitle;
|
|
240
|
+
} catch { /* partial or foreign line */ }
|
|
241
|
+
}
|
|
242
|
+
return out;
|
|
243
|
+
} catch {
|
|
244
|
+
return { lastPrompt: null, aiTitle: null };
|
|
245
|
+
} finally {
|
|
246
|
+
if (fd !== undefined) {
|
|
247
|
+
try { closeSync(fd); } catch { /* nothing to release */ }
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
211
252
|
/**
|
|
212
253
|
* The newest typed request, the newest text reply and the last 12 tool calls of
|
|
213
254
|
* a transcript. Never throws.
|
package/src/bar-app.js
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* The first session on a Mac with the Xcode command line tools compiles it
|
|
7
7
|
* once per sprag version into <dataDir>/bar/<version>/sprag-bar and starts it.
|
|
8
8
|
* `sprag bar off` turns the whole thing off, and `sprag bar on` brings it back.
|
|
9
|
+
* Starting the app also writes a launcher, ~/Applications/Sprag Bar.app, a shell
|
|
10
|
+
* script bundle that runs `sprag bar on`, so Spotlight, Launchpad and Finder can
|
|
11
|
+
* bring the app back without a terminal.
|
|
9
12
|
*
|
|
10
13
|
* Every outside effect goes through an injectable dependency (run, spawn, kill,
|
|
11
14
|
* exists, clock, dataDir, version), so the tests start no process and touch no
|
|
@@ -18,6 +21,7 @@ import {
|
|
|
18
21
|
} from 'node:fs';
|
|
19
22
|
import { createRequire } from 'node:module';
|
|
20
23
|
import { createHash } from 'node:crypto';
|
|
24
|
+
import { homedir } from 'node:os';
|
|
21
25
|
import { basename, join } from 'node:path';
|
|
22
26
|
import { fileURLToPath } from 'node:url';
|
|
23
27
|
import { CLI_ENTRY, DETACHED_CHILD_VAR, isDetachedChild, spawnDetachedCli } from './cli-entry.js';
|
|
@@ -40,6 +44,13 @@ const TRANSIENT_ERROR = /was modified during the build/i;
|
|
|
40
44
|
const ERROR_TAIL = 600;
|
|
41
45
|
const BINARY_NAME = 'sprag-bar';
|
|
42
46
|
|
|
47
|
+
export const LAUNCHER_NAME = 'Sprag Bar.app';
|
|
48
|
+
export const LAUNCHER_ID = 'io.sprag.bar-launcher';
|
|
49
|
+
const LAUNCHER_EXECUTABLE = 'sprag-bar-launcher';
|
|
50
|
+
const LSREGISTER = '/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister';
|
|
51
|
+
/** What LaunchServices does not hand to an app it starts, and the app's data and config folders depend on. */
|
|
52
|
+
const LAUNCHER_ENV_KEYS = ['XDG_CONFIG_HOME', 'CLAUDE_CONFIG_DIR', 'CODEX_HOME'];
|
|
53
|
+
|
|
43
54
|
/** The bar is on unless the user ran `sprag bar off`. */
|
|
44
55
|
export function barEnabled(cfg = loadConfig()) {
|
|
45
56
|
return cfg?.bar !== false;
|
|
@@ -71,9 +82,12 @@ export function barBuildId(source = BAR_SOURCE) {
|
|
|
71
82
|
}
|
|
72
83
|
|
|
73
84
|
/** `version` is the build id above; the name is kept because the app's pid file calls it that. */
|
|
74
|
-
export function barPaths({ dataDir = userDataDir(), version = barBuildId() } = {}) {
|
|
85
|
+
export function barPaths({ dataDir = userDataDir(), version = barBuildId(), appsDir, home } = {}) {
|
|
75
86
|
const dir = join(dataDir, 'bar');
|
|
87
|
+
const apps = appsDir ?? join(home ?? homedir(), 'Applications');
|
|
76
88
|
return {
|
|
89
|
+
appsDir: apps,
|
|
90
|
+
launcher: join(apps, LAUNCHER_NAME),
|
|
77
91
|
dataDir,
|
|
78
92
|
dir,
|
|
79
93
|
version,
|
|
@@ -284,9 +298,115 @@ export function barChildEnv(env = process.env) {
|
|
|
284
298
|
return out;
|
|
285
299
|
}
|
|
286
300
|
|
|
301
|
+
const shQuote = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
|
|
302
|
+
const xmlEscape = (s) => String(s)
|
|
303
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* The two files of the launcher bundle. Opening the bundle runs `sprag bar on`.
|
|
307
|
+
* LaunchServices starts it without the user's shell environment, so the folders
|
|
308
|
+
* that decide where sprag keeps its data and finds Claude's settings are written
|
|
309
|
+
* into the script. A launcher without them would turn on a bar that reads other folders.
|
|
310
|
+
*/
|
|
311
|
+
export function launcherFiles({ execPath, cliEntry, env = {}, version }) {
|
|
312
|
+
const exportLines = LAUNCHER_ENV_KEYS
|
|
313
|
+
.filter((key) => typeof env?.[key] === 'string' && env[key] !== '')
|
|
314
|
+
.map((key) => `export ${key}=${shQuote(env[key])}`);
|
|
315
|
+
const script = [
|
|
316
|
+
'#!/bin/sh',
|
|
317
|
+
'# Written by sprag. Opening Sprag Bar runs `sprag bar on`, which turns the menu bar app on and starts it.',
|
|
318
|
+
...exportLines,
|
|
319
|
+
`exec ${shQuote(execPath)} ${shQuote(cliEntry)} bar on`,
|
|
320
|
+
'',
|
|
321
|
+
].join('\n');
|
|
322
|
+
const entries = [
|
|
323
|
+
['CFBundleIdentifier', `<string>${xmlEscape(LAUNCHER_ID)}</string>`],
|
|
324
|
+
['CFBundleName', '<string>Sprag Bar</string>'],
|
|
325
|
+
['CFBundleDisplayName', '<string>Sprag Bar</string>'],
|
|
326
|
+
['CFBundleExecutable', `<string>${LAUNCHER_EXECUTABLE}</string>`],
|
|
327
|
+
['CFBundlePackageType', '<string>APPL</string>'],
|
|
328
|
+
['CFBundleShortVersionString', `<string>${xmlEscape(version)}</string>`],
|
|
329
|
+
['LSUIElement', '<true/>'],
|
|
330
|
+
];
|
|
331
|
+
const plist = [
|
|
332
|
+
'<?xml version="1.0" encoding="UTF-8"?>',
|
|
333
|
+
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">',
|
|
334
|
+
'<plist version="1.0">',
|
|
335
|
+
'<dict>',
|
|
336
|
+
...entries.flatMap(([key, value]) => [` <key>${key}</key>`, ` ${value}`]),
|
|
337
|
+
'</dict>',
|
|
338
|
+
'</plist>',
|
|
339
|
+
'',
|
|
340
|
+
].join('\n');
|
|
341
|
+
return { plist, script };
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function launcherFilePaths(paths) {
|
|
345
|
+
return {
|
|
346
|
+
plist: join(paths.launcher, 'Contents', 'Info.plist'),
|
|
347
|
+
script: join(paths.launcher, 'Contents', 'MacOS', LAUNCHER_EXECUTABLE),
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** The text of a file, or null when it cannot be read. */
|
|
352
|
+
function readText(file) {
|
|
353
|
+
try { return readFileSync(file, 'utf8'); } catch { return null; }
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Write ~/Applications/Sprag Bar.app so Spotlight, Launchpad and Finder can start the app again.
|
|
358
|
+
* Never throws. Returns 'created', 'updated', 'unchanged', 'foreign' (a bundle or file of that name
|
|
359
|
+
* that is not ours is left alone), 'not-mac' or 'error'.
|
|
360
|
+
*/
|
|
361
|
+
export function installLauncher(deps = {}) {
|
|
362
|
+
try {
|
|
363
|
+
if ((deps.platform ?? process.platform) !== 'darwin') return 'not-mac';
|
|
364
|
+
const paths = barPaths(deps);
|
|
365
|
+
const files = launcherFilePaths(paths);
|
|
366
|
+
if (existsSync(paths.launcher) && !statSync(paths.launcher).isDirectory()) return 'foreign';
|
|
367
|
+
const oldPlist = readText(files.plist);
|
|
368
|
+
if (oldPlist !== null && !oldPlist.includes(LAUNCHER_ID)) return 'foreign';
|
|
369
|
+
const want = launcherFiles({
|
|
370
|
+
execPath: deps.execPath ?? process.execPath,
|
|
371
|
+
cliEntry: deps.cliEntry ?? CLI_ENTRY,
|
|
372
|
+
env: deps.env ?? process.env,
|
|
373
|
+
version: PKG_VERSION,
|
|
374
|
+
});
|
|
375
|
+
// Windows keeps no execute bits, so there the check would call every launcher stale (only the tests write one there).
|
|
376
|
+
let executable = false;
|
|
377
|
+
try { executable = process.platform === 'win32' || (statSync(files.script).mode & 0o111) !== 0; } catch { /* a missing script is rewritten */ }
|
|
378
|
+
if (oldPlist === want.plist && readText(files.script) === want.script && executable) return 'unchanged';
|
|
379
|
+
mkdirSync(join(paths.launcher, 'Contents', 'MacOS'), { recursive: true });
|
|
380
|
+
writeFileSync(files.plist, want.plist);
|
|
381
|
+
writeFileSync(files.script, want.script);
|
|
382
|
+
chmodSync(files.script, 0o755);
|
|
383
|
+
if (oldPlist !== null) return 'updated';
|
|
384
|
+
// A new bundle is registered once so Spotlight and Launchpad list it without waiting for their own scan.
|
|
385
|
+
try { runOf(deps)(LSREGISTER, ['-f', paths.launcher]); } catch { /* the bundle works without it */ }
|
|
386
|
+
return 'created';
|
|
387
|
+
} catch {
|
|
388
|
+
return 'error';
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** Delete the launcher, only when its Info.plist names our bundle id. True when it was deleted. Never throws. */
|
|
393
|
+
export function removeLauncher(deps = {}) {
|
|
394
|
+
try {
|
|
395
|
+
const paths = barPaths(deps);
|
|
396
|
+
const plist = readText(launcherFilePaths(paths).plist);
|
|
397
|
+
if (plist === null || !plist.includes(LAUNCHER_ID)) return false;
|
|
398
|
+
rmSync(paths.launcher, { recursive: true, force: true });
|
|
399
|
+
return true;
|
|
400
|
+
} catch {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
287
405
|
/** Start the compiled app detached from this process. The caller has checked the binary exists. */
|
|
288
406
|
export function launchBar(deps = {}) {
|
|
289
407
|
const paths = barPaths(deps);
|
|
408
|
+
// The launcher is a convenience: a failure to write it never keeps the app from starting.
|
|
409
|
+
try { installLauncher(deps); } catch { /* the app starts regardless */ }
|
|
290
410
|
const spawn = deps.spawn ?? childProcess.spawn;
|
|
291
411
|
const child = spawn(paths.binary, [
|
|
292
412
|
'--node', deps.execPath ?? process.execPath,
|
|
@@ -335,12 +455,16 @@ export function ensureBar({ platform = process.platform, env = process.env, cfg,
|
|
|
335
455
|
if (isDetachedChild(env)) return 'child';
|
|
336
456
|
if (envVar('NO_BAR', env) === '1') return 'off';
|
|
337
457
|
if (!barEnabled(cfg)) return 'off';
|
|
338
|
-
const d = { ...deps, env };
|
|
458
|
+
const d = { ...deps, env, platform };
|
|
339
459
|
const paths = barPaths(d);
|
|
340
460
|
let restart = false;
|
|
341
461
|
const running = barRunning(d);
|
|
342
462
|
if (running) {
|
|
343
|
-
if (running.version === paths.version)
|
|
463
|
+
if (running.version === paths.version) {
|
|
464
|
+
// An app that stays up across upgrades would otherwise never get the launcher, or a launcher naming a new node.
|
|
465
|
+
installLauncher(d);
|
|
466
|
+
return 'running';
|
|
467
|
+
}
|
|
344
468
|
stopBar(d);
|
|
345
469
|
restart = true;
|
|
346
470
|
}
|
|
@@ -363,10 +487,11 @@ export function ensureBar({ platform = process.platform, env = process.env, cfg,
|
|
|
363
487
|
}
|
|
364
488
|
}
|
|
365
489
|
|
|
366
|
-
/** Uninstall: stop the app and delete everything this module wrote under the data directory. */
|
|
490
|
+
/** Uninstall: stop the app and delete everything this module wrote under the data directory, and the launcher. */
|
|
367
491
|
export function removeBarFiles(deps = {}) {
|
|
368
492
|
const paths = barPaths(deps);
|
|
369
493
|
try { stopBar(deps); } catch { /* the files go regardless */ }
|
|
494
|
+
removeLauncher(deps);
|
|
370
495
|
for (const target of [paths.dir, paths.pidFile, paths.buildState, paths.buildLock]) {
|
|
371
496
|
try { rmSync(target, { recursive: true, force: true }); } catch { /* best effort */ }
|
|
372
497
|
}
|
package/src/commands/bar.js
CHANGED
|
@@ -145,7 +145,7 @@ export function renderText(snapshot) {
|
|
|
145
145
|
for (const g of limitGroups(snapshot)) head += ` · ${g.name} ${g.words.join(' ')}`;
|
|
146
146
|
const cells = sessions.map((r) => ({
|
|
147
147
|
dot: dot(r.state),
|
|
148
|
-
name: fit(r.name, NAME_WIDTH),
|
|
148
|
+
name: fit(r.title ?? r.name, NAME_WIDTH),
|
|
149
149
|
agent: agentText(r),
|
|
150
150
|
state: stateText(r, snapshot.at),
|
|
151
151
|
activity: fit(activityLabel(r), ACTIVITY_WIDTH),
|
|
@@ -182,7 +182,7 @@ export function renderSwiftBar(snapshot) {
|
|
|
182
182
|
out.push('No agent sessions running');
|
|
183
183
|
} else {
|
|
184
184
|
for (const r of sessions) {
|
|
185
|
-
const parts = [r.name, agentText(r), stateText(r, snapshot.at)];
|
|
185
|
+
const parts = [r.title ?? r.name, agentText(r), stateText(r, snapshot.at)];
|
|
186
186
|
const label = activityLabel(r);
|
|
187
187
|
if (label) parts.push(label);
|
|
188
188
|
for (const extra of [ctxText(r), costText(r)]) if (extra) parts.push(extra);
|
|
@@ -244,6 +244,7 @@ async function runSubcommand(sub, { hasFlag, deps }) {
|
|
|
244
244
|
if (sub === 'off') {
|
|
245
245
|
bar.setBarEnabled(false);
|
|
246
246
|
bar.stopBar(barDeps);
|
|
247
|
+
bar.removeLauncher(barDeps);
|
|
247
248
|
say('✓ The menu bar app is off and will not be started again. `sprag bar on` brings it back.',
|
|
248
249
|
'✓ 메뉴 막대 앱을 껐고 다시 시작하지 않습니다. 다시 켜려면 `sprag bar on` 을 실행하십시오.');
|
|
249
250
|
return;
|
|
@@ -255,6 +256,7 @@ async function runSubcommand(sub, { hasFlag, deps }) {
|
|
|
255
256
|
const paths = bar.barPaths(barDeps);
|
|
256
257
|
const running = bar.barRunning(barDeps);
|
|
257
258
|
if (running && running.version === paths.version) {
|
|
259
|
+
bar.installLauncher({ ...barDeps, platform });
|
|
258
260
|
say(`✓ The menu bar app is already running (pid ${running.pid}, build ${running.version}).`,
|
|
259
261
|
`✓ 메뉴 막대 앱이 이미 실행 중입니다 (pid ${running.pid}, 빌드 ${running.version}).`);
|
|
260
262
|
return;
|
|
@@ -279,6 +281,8 @@ async function runSubcommand(sub, { hasFlag, deps }) {
|
|
|
279
281
|
}
|
|
280
282
|
bar.launchBar(barDeps);
|
|
281
283
|
say('✓ The menu bar app is in the menu bar.', '✓ 메뉴 막대에 앱을 띄웠습니다.');
|
|
284
|
+
say('Open "Sprag Bar" from Spotlight or Launchpad to start it again later.',
|
|
285
|
+
'나중에 다시 켤 때는 Spotlight나 Launchpad에서 Sprag Bar를 여십시오.');
|
|
282
286
|
return;
|
|
283
287
|
}
|
|
284
288
|
|
|
@@ -326,6 +330,11 @@ async function runSubcommand(sub, { hasFlag, deps }) {
|
|
|
326
330
|
} else {
|
|
327
331
|
say('Swift toolchain: not needed, the app only works on macOS', 'Swift 도구: 필요 없음, 앱은 macOS에서만 동작합니다');
|
|
328
332
|
}
|
|
333
|
+
if (exists(paths.launcher)) {
|
|
334
|
+
say(`Launcher app: yes (${paths.launcher})`, `응용 프로그램 실행기: 있음 (${paths.launcher})`);
|
|
335
|
+
} else {
|
|
336
|
+
say('Launcher app: no', '응용 프로그램 실행기: 없음');
|
|
337
|
+
}
|
|
329
338
|
const state = bar.readBuildState(barDeps);
|
|
330
339
|
if (state?.error) {
|
|
331
340
|
say(`Last build error (${state.version ?? 'unknown build'}):\n${indent(state.error)}`,
|