@join-pantheon/cli 0.35.0-rc.2 → 0.35.1-rc.1

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 (51) hide show
  1. package/dist/agent-outage.js +156 -36
  2. package/dist/agent-token.js +5 -3
  3. package/dist/approvals-list.js +87 -0
  4. package/dist/board.js +472 -87
  5. package/dist/brief.js +17 -0
  6. package/dist/cli.js +687 -95
  7. package/dist/client.js +159 -19
  8. package/dist/config.js +3 -2
  9. package/dist/continued.js +56 -1
  10. package/dist/decision-ui.js +5 -3
  11. package/dist/doctor.js +81 -15
  12. package/dist/file-lock.js +39 -4
  13. package/dist/flow-stats.js +18 -1
  14. package/dist/home-guard.js +317 -54
  15. package/dist/home-safety.js +2 -0
  16. package/dist/hud-queue.js +91 -0
  17. package/dist/install.js +15 -1
  18. package/dist/mcp-instructions.js +55 -20
  19. package/dist/mcp.js +114 -24
  20. package/dist/notice-linux.js +15 -4
  21. package/dist/notice-windows.js +2 -2
  22. package/dist/notifier.js +2 -1
  23. package/dist/notify.js +8 -4
  24. package/dist/open-in.js +4 -3
  25. package/dist/pickup.js +17 -0
  26. package/dist/plain.js +139 -3
  27. package/dist/profile.js +12 -8
  28. package/dist/protocol.js +1 -1
  29. package/dist/question-goal.js +74 -0
  30. package/dist/readiness-alert.js +24 -3
  31. package/dist/refusal.js +2 -2
  32. package/dist/relay.js +142 -28
  33. package/dist/removed.js +4 -4
  34. package/dist/run-control.js +4 -3
  35. package/dist/run-failure.js +67 -10
  36. package/dist/setup-changes.js +7 -6
  37. package/dist/signed-out.js +144 -21
  38. package/dist/spend.js +2 -2
  39. package/dist/tray.js +24 -6
  40. package/dist/update-check.js +2 -1
  41. package/dist/uri-handler.js +10 -2
  42. package/dist/which.js +2 -0
  43. package/dist/worker-policy.js +212 -10
  44. package/dist/worker.js +847 -114
  45. package/dist/worklist.js +31 -1
  46. package/helper/macos/main.swift +42 -3
  47. package/helper/macos/menubar.swift +482 -87
  48. package/helper/macos/prebuilt/manifest.json +5 -5
  49. package/helper/macos/prebuilt/pantheon-hud +0 -0
  50. package/helper/macos/prebuilt/pantheon-tray +0 -0
  51. package/package.json +1 -1
package/dist/worklist.js CHANGED
@@ -1,6 +1,19 @@
1
1
  export function goalKindLabel(g) {
2
- return g.kind === "worklist" ? " [worklist — one person's own list; nobody owes anything here, and it does not keep you in the loop]" : "";
2
+ if (g.kind === "worklist")
3
+ return " [worklist — one person's own list; nobody owes anything here, and it does not keep you in the loop]";
4
+ return isQuestionGoal(g) ? " [question — one question and its answer; it does not keep you in the loop]" : "";
3
5
  }
6
+ export function questionAcceptance(who) {
7
+ return `${who.join(", ")} answers`;
8
+ }
9
+ export function isQuestionGoal(g) {
10
+ return g.kind === "question" && g.sig?.kind === "question";
11
+ }
12
+ export const WORK_ACTS = new Set(["PROPOSE", "CONTRACT", "COMMIT", "DELIVERED"]);
13
+ export function workedIn(acts, openedBy) {
14
+ return acts.some((a) => WORK_ACTS.has(a.act)) || acts.filter((a) => a.act === "ASK" && a.from === openedBy).length > 1;
15
+ }
16
+ export const keepsInLoop = (g) => g.state !== "CLOSED" && g.kind !== "worklist" && !isQuestionGoal(g);
4
17
  export function questionTitle(text) {
5
18
  const line = text.replace(/\s+/g, " ").trim();
6
19
  const sentence = /^(.{12,}?[?.!])(\s|$)/.exec(line)?.[1] ?? line;
@@ -20,4 +33,21 @@ export function openedText(id, title, askedWorklist, seen, deadlineLine = "") {
20
33
  `(with its deadline in the body), NOTE for a reminder. Nobody owes anything here, PEER_TURN never fires, ` +
21
34
  `and this goal does not keep you in the loop — the act budget still applies.`;
22
35
  }
36
+ export function afterSendLine(act, inQuestion, woken) {
37
+ if (woken && (act === "ANSWER" || act === "CLOSE" || act === "DELIVERED")) {
38
+ return woken.owesMore
39
+ ? "\n\nYou replied. You still owe something here (pantheon_status lists it): handle that, then finish."
40
+ : "\n\nYou replied — finish now. Nothing else is owed by you; a peer's next message wakes a new run.";
41
+ }
42
+ if (woken && (act === "ESCALATE" || act === "HUMAN_REQUIRED")) {
43
+ return woken.owesMore
44
+ ? "\n\nThat waits for a person now. You still owe something here (pantheon_status lists it): handle that, then finish."
45
+ : "\n\nThat waits for a person now — finish. Nothing else is owed by you; a peer's next message wakes a new run.";
46
+ }
47
+ if (inQuestion && act === "ASK")
48
+ return "\n\nCarry on with your work: the answer reaches you with your next pantheon call. Call pantheon_wait only if you cannot go on without it.";
49
+ if (inQuestion && act === "ANSWER")
50
+ return "\n\nThat answers their question. If it asked you to do work and you are doing it, send COMMIT in this goal saying what you will deliver: it then keeps you both in the loop until you DELIVER.";
51
+ return "\n\nNow call pantheon_wait to hear back.";
52
+ }
23
53
  //# sourceMappingURL=worklist.js.map
@@ -200,6 +200,9 @@ private func label(_ text: String, font: NSFont, colour: NSColor, lines: Int) ->
200
200
  final class AppDelegate: NSObject, NSApplicationDelegate {
201
201
  private var panel: NSPanel?
202
202
  private var timer: DispatchWorkItem?
203
+ /// The heading and body as drawn: Done says its verdict in them when it is not plainly done (round 3).
204
+ private var headingField: NSTextField?
205
+ private var bodyField: NSTextField?
203
206
  private var hovering = false {
204
207
  // While the pointer is on this alert, an update of it waits (an alert being read is never swapped under the pointer).
205
208
  didSet { if hovering != oldValue { markHover(hovering) } }
@@ -269,7 +272,19 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
269
272
  /// Done: write the action, run the CLI without a Terminal, close. The CLI answers the decision as handled.
270
273
  @objc func markDone(_ sender: Any?) {
271
274
  guard !notice.bin_dir.isEmpty, let decision = notice.details?.decision else { NSApp.terminate(nil); return }
272
- runQuietly(["action": "done", "decision": decision, "act": notice.details?.act as Any, "space": notice.space as Any].compactMapValues { $0 is NSNull ? nil : $0 })
275
+ runQuietly(["action": "done", "decision": decision, "act": notice.details?.act as Any, "space": notice.space as Any].compactMapValues { $0 is NSNull ? nil : $0 }, verdict: true)
276
+ }
277
+
278
+ /// What the CLI's last line says, as every other surface says it: "unconfirmed: …" — the answer may have
279
+ /// landed — is "Not confirmed — check the thread"; "not sent: …" is "Not marked done"; no line at all is
280
+ /// not known either (round 3: the alert's Done used to throw its outcome away).
281
+ static func doneVerdict(code: Int32, out: String) -> (heading: String, body: String)? {
282
+ if code == 0 { return nil }
283
+ let lines = out.split(separator: "\n").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty && !$0.hasPrefix("action ") }
284
+ let said = lines.last ?? ""
285
+ if said.hasPrefix("not sent: ") { return ("Not marked done", String(said.dropFirst("not sent: ".count))) }
286
+ if said.hasPrefix("unconfirmed: ") { return ("Not confirmed — check the thread", String(said.dropFirst("unconfirmed: ".count))) }
287
+ return ("Not confirmed — check the thread", "It may have been marked done — open the board to check it.")
273
288
  }
274
289
 
275
290
  /// Approve / Keep as is, Take over / Stop: the first button is tag 0. The CLI does it, silently.
@@ -283,7 +298,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
283
298
  }
284
299
 
285
300
  /// Write the action for `pantheon explain --queued` and run it without a Terminal, then close.
286
- private func runQuietly(_ payload: [String: Any]) {
301
+ private func runQuietly(_ payload: [String: Any], verdict: Bool = false) {
287
302
  let dir = URL(fileURLWithPath: notice.bin_dir)
288
303
  if let data = try? JSONSerialization.data(withJSONObject: payload) {
289
304
  try? data.write(to: dir.appendingPathComponent(".hud-action.json"), options: .atomic)
@@ -293,6 +308,24 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
293
308
  let p = Process()
294
309
  p.executableURL = URL(fileURLWithPath: "/bin/sh")
295
310
  // --silent: no Terminal is here, so where the CLI cannot open the Claude app it opens one itself.
311
+ if verdict {
312
+ // Done: its outcome is read, and shown here for a few seconds when it is not plainly done.
313
+ p.arguments = ["-lc", "\(quoted) explain --queued --silent 2>/dev/null"]
314
+ let pipe = Pipe()
315
+ p.standardOutput = pipe
316
+ p.terminationHandler = { proc in
317
+ let out = String(data: pipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? ""
318
+ DispatchQueue.main.async {
319
+ guard let v = AppDelegate.doneVerdict(code: proc.terminationStatus, out: out) else { NSApp.terminate(nil); return }
320
+ self.timer?.cancel()
321
+ self.headingField?.stringValue = v.heading
322
+ self.bodyField?.stringValue = v.body
323
+ DispatchQueue.main.asyncAfter(deadline: .now() + 8) { NSApp.terminate(nil) }
324
+ }
325
+ }
326
+ do { try p.run() } catch { NSApp.terminate(nil) }
327
+ return
328
+ }
296
329
  p.arguments = ["-lc", "\(quoted) explain --queued --silent >/dev/null 2>&1"] // login shell: PATH with node, as the user's own terminal has
297
330
  try? p.run()
298
331
  NSApp.terminate(nil)
@@ -384,6 +417,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
384
417
  let context = label(notice.context, font: .systemFont(ofSize: 12, weight: .medium), colour: readableDim, lines: whole ? 0 : 1)
385
418
  // The reading colour: the secondary grey fell under 4.5:1 on the light panel (0.33.9 design review).
386
419
  let body = label(notice.body, font: .systemFont(ofSize: 13), colour: .labelColor, lines: whole ? 0 : 3)
420
+ headingField = heading; bodyField = body
387
421
 
388
422
  let close = NSButton(title: "×", target: self, action: #selector(dismiss(_:)))
389
423
  close.isBordered = false
@@ -550,10 +584,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
550
584
  }
551
585
  }
552
586
 
587
+ /// libproc's proc_pidpath, declared here: older Swift toolchains (5.8) do not bring libproc.h into scope
588
+ /// through AppKit, and the source fallback must build there too (#87). It lives in libSystem on every macOS.
589
+ @_silgen_name("proc_pidpath")
590
+ private func pantheonProcPidpath(_ pid: Int32, _ buffer: UnsafeMutableRawPointer?, _ size: UInt32) -> Int32
591
+
553
592
  /// The executable a pid runs, or nil: a pid is ended only when it is this same helper (never a reused pid's process).
554
593
  func executablePath(_ pid: Int32) -> String? {
555
594
  var buf = [CChar](repeating: 0, count: 4096)
556
- let n = proc_pidpath(pid, &buf, UInt32(buf.count))
595
+ let n = buf.withUnsafeMutableBytes { pantheonProcPidpath(pid, $0.baseAddress, UInt32($0.count)) }
557
596
  return n > 0 ? URL(fileURLWithPath: String(cString: buf)).resolvingSymlinksInPath().path : nil
558
597
  }
559
598