@m13v/s4l 1.7.2-rc.5 → 1.7.2-rc.7

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.
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.7.2-rc.5",
3
- "installedAt": "2026-07-09T01:43:14.354Z"
2
+ "version": "1.7.2-rc.7",
3
+ "installedAt": "2026-07-09T02:45:11.565Z"
4
4
  }
package/mcp/manifest.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "dxt_version": "0.1",
3
3
  "name": "social-autoposter",
4
4
  "display_name": "S4L",
5
- "version": "1.7.2-rc.5",
5
+ "version": "1.7.2-rc.7",
6
6
  "description": "Draft, review, approve, and autopilot X/Twitter posts.",
7
7
  "long_description": "## **⚠️ The disclaimer above is generic Claude boilerplate.** Anthropic shows the same warning on every plugin regardless of what it does; any plugin has the same level of access as any app you download from the internet.\n\nS4L is an open source product developed by Mediar.ai Incorporated, a VC-backed San Francisco-based startup.\n\nTo get started:\n\n1\\. Copy this prompt: **Set me up on S4L plugin end to end**\n\n2\\. Quit with CMD+Q, reopen Claude, paste into a new chat.\n\nWhat happens next:\n\n* About every 5 minutes S4L scans X for posts that match your topics and drafts replies in your voice.\n* Drafts show up as review cards, usually the first within a few minutes. Nothing is posted automatically; you approve each one.\n* Posting autopilot stays off until you explicitly turn it on.",
8
8
  "author": {
@@ -1844,6 +1844,36 @@ def active_status():
1844
1844
  return None
1845
1845
 
1846
1846
 
1847
+ def dismiss_active():
1848
+ """Force-close the open review panel WITHOUT firing on_decision/on_complete,
1849
+ for a bulk discard whose fate for every remaining card was already decided
1850
+ elsewhere (the menu bar's store-level "Discard all pending drafts"). A
1851
+ normal windowShouldClose_ close still fires on_complete (leftover cards are
1852
+ just undecided); this path skips both callbacks entirely so the bulk
1853
+ discard's own bookkeeping is the only thing that runs. Returns True if a
1854
+ panel was actually open."""
1855
+ global _active
1856
+ c = _active
1857
+ if c is None or c._panel is None:
1858
+ return False
1859
+ try:
1860
+ c._close_stats_popover()
1861
+ except Exception:
1862
+ pass
1863
+ try:
1864
+ c._panel.setDelegate_(None)
1865
+ c._panel.close()
1866
+ except Exception:
1867
+ pass
1868
+ c._panel = None
1869
+ c._on_complete = None
1870
+ c._on_decision = None
1871
+ _active = None
1872
+ _log(f"closed: dismissed (bulk discard, {len(c._decisions)} decided of {len(c._drafts)})")
1873
+ _write_review_state(last_event="dismissed")
1874
+ return True
1875
+
1876
+
1847
1877
  def heal_active():
1848
1878
  """Self-heal an unattended card: move it to the top-right of the screen the
1849
1879
  pointer is on and raise it, WITHOUT stealing keyboard focus (the user is
@@ -2502,6 +2502,11 @@ class S4LMenuBar(rumps.App):
2502
2502
  if ob
2503
2503
  else 0
2504
2504
  )
2505
+ # Pending draft-card count, for the bulk-discard menu item (visibility +
2506
+ # label). Cheap local JSON reads, same source _maybe_start_review uses.
2507
+ _, pending_drafts = self._pending_review()
2508
+ pending_count = len(pending_drafts)
2509
+
2505
2510
  # _update_available / _latest_version are in the signature so a freshly
2506
2511
  # detected update rebuilds the menu (adding "Update now & restart Claude Desktop") even mid-run.
2507
2512
  sig = (
@@ -2523,10 +2528,14 @@ class S4LMenuBar(rumps.App):
2523
2528
  schedule_state,
2524
2529
  self._stall_reason_info,
2525
2530
  os.path.exists(PAUSE_FLAG),
2531
+ pending_count,
2526
2532
  )
2527
2533
  if sig != self._sig:
2528
2534
  self._sig = sig
2529
- self._build_menu(runtime_ready, setup_complete, ob, blocker, snap, attention, schedule_state)
2535
+ self._build_menu(
2536
+ runtime_ready, setup_complete, ob, blocker, snap, attention, schedule_state,
2537
+ pending_count=pending_count,
2538
+ )
2530
2539
 
2531
2540
  # Draft-review pop-ups: if a draft cycle left a review request, present the
2532
2541
  # cards. Don't start a review mid-run (the spinner means a tool is active).
@@ -2578,6 +2587,21 @@ class S4LMenuBar(rumps.App):
2578
2587
  self._posting_batch_total = 0
2579
2588
  self._posting_batch_done = 0
2580
2589
 
2590
+ def _pending_review(self):
2591
+ """(batch_id, undecided draft cards) from the durable review store —
2592
+ the same source _maybe_start_review presents from. Cheap (small local
2593
+ JSON reads); drives the menu's bulk-discard item, both its visibility
2594
+ and what it acts on."""
2595
+ try:
2596
+ req = st.read_review_request()
2597
+ batch = (req or {}).get("batch_id")
2598
+ if not batch:
2599
+ return None, []
2600
+ plan = st.read_plan(req.get("plan_path") or "")
2601
+ return batch, st.review_drafts(plan)
2602
+ except Exception:
2603
+ return None, []
2604
+
2581
2605
  def _maybe_start_review(self):
2582
2606
  req = st.read_review_request()
2583
2607
  if not req:
@@ -2874,6 +2898,61 @@ class S4LMenuBar(rumps.App):
2874
2898
  if not any(d.get("approved") for d in decisions):
2875
2899
  self._notify("S4L", "No drafts approved — nothing posted.")
2876
2900
 
2901
+ def _discard_all_pending(self, _=None):
2902
+ """Bulk-discard every pending draft card: rejected with NO reason,
2903
+ instantly, and — deliberately — without shipping a review event for any
2904
+ of them. A normal per-card reject always ships one (feeding the
2905
+ feedback-digest -> learned_preferences rail, see _ship_review_event);
2906
+ this bulk "clear the backlog" action carries no per-card judgment
2907
+ signal, so it must never reach that rail (user-specified 2026-07-08)."""
2908
+ batch, drafts = self._pending_review()
2909
+ if not batch or not drafts:
2910
+ return
2911
+ n = len(drafts)
2912
+ choice = _show_alert(
2913
+ title="Discard all pending drafts?",
2914
+ message=(
2915
+ f"Discards all {n} pending draft(s) right now, with no reason "
2916
+ "given. None of them will post or be shown for review again. "
2917
+ "This does not feed the AI feedback loop (learned_preferences) "
2918
+ "the way an individual reject does."
2919
+ ),
2920
+ ok="Discard All", cancel="Cancel",
2921
+ )
2922
+ if choice != 1:
2923
+ return
2924
+ try:
2925
+ st.discard_all_pending(drafts)
2926
+ except Exception as e:
2927
+ sys.stderr.write(f"[s4l-menubar] discard all pending failed: {e}\n")
2928
+ sys.stderr.flush()
2929
+ _capture(e, phase="discard_all_pending")
2930
+ self._alert("Discard failed", str(e)[:200])
2931
+ return
2932
+ ns = [d.get("n") for d in drafts if d.get("n") is not None]
2933
+
2934
+ def _persist_discard():
2935
+ try:
2936
+ st.post_drafts(batch, reject=ns, timeout=60)
2937
+ except Exception:
2938
+ pass
2939
+
2940
+ threading.Thread(target=_persist_discard, daemon=True).start()
2941
+ try:
2942
+ import s4l_card
2943
+
2944
+ s4l_card.dismiss_active()
2945
+ except Exception:
2946
+ pass
2947
+ with self._review_lock:
2948
+ self._panel_open = False
2949
+ if self._posts_outstanding <= 0:
2950
+ self._review_active = False
2951
+ self._reset_posting_progress_locked()
2952
+ self._last_review_sig = None
2953
+ st.clear_review_request()
2954
+ self._notify("S4L", f"Discarded {n} pending draft(s).")
2955
+
2877
2956
  def _ensure_post_worker(self):
2878
2957
  # One persistent daemon worker drains the approved-card queue. It never
2879
2958
  # exits (avoids an enqueue-vs-exit race) — an idle parked thread is cheap.
@@ -2979,7 +3058,7 @@ class S4LMenuBar(rumps.App):
2979
3058
  self.title = "S4L"
2980
3059
 
2981
3060
  # ---- menu construction ------------------------------------------------
2982
- def _build_menu(self, runtime_ready, setup_complete, ob, blocker, snap, attention=False, schedule_state="ok"):
3061
+ def _build_menu(self, runtime_ready, setup_complete, ob, blocker, snap, attention=False, schedule_state="ok", pending_count=0):
2983
3062
  self.menu.clear()
2984
3063
  items = []
2985
3064
 
@@ -3094,7 +3173,7 @@ class S4LMenuBar(rumps.App):
3094
3173
  elif not setup_complete:
3095
3174
  items += self._state_b(ob, blocker)
3096
3175
  else:
3097
- items += self._state_c(snap)
3176
+ items += self._state_c(snap, pending_count)
3098
3177
 
3099
3178
  # Engagement lanes — ALWAYS visible (every state), not just post-setup, so
3100
3179
  # the user can see + flip either lane any time. Two INDEPENDENT checkmarks
@@ -3242,8 +3321,15 @@ class S4LMenuBar(rumps.App):
3242
3321
  # The engagement-mode toggles live in _build_menu (shown in EVERY state), and
3243
3322
  # there is deliberately no "Run draft cycle" / "Post approved drafts" item
3244
3323
  # (the autopilot drafts on its own; approving a review card already posts it).
3245
- def _state_c(self, snap):
3246
- return []
3324
+ def _state_c(self, snap, pending_count=0):
3325
+ if pending_count <= 0:
3326
+ return []
3327
+ return [
3328
+ rumps.MenuItem(
3329
+ f"Discard {pending_count} pending draft{'s' if pending_count != 1 else ''}…",
3330
+ callback=self._discard_all_pending,
3331
+ )
3332
+ ]
3247
3333
 
3248
3334
 
3249
3335
  if __name__ == "__main__":
@@ -770,6 +770,39 @@ def store_stamp_decision(batch, decision):
770
770
  return bool(_store_update(mutate))
771
771
 
772
772
 
773
+ def discard_all_pending(drafts):
774
+ """Bulk-reject an entire pending set (the menu bar's "Discard all pending
775
+ drafts"), durably and atomically in ONE lock acquisition. Each candidate is
776
+ stamped terminal with NO reason (reject_category=None), same as a card's
777
+ "Reject, no reason" button. Deliberately distinct from store_stamp_decision:
778
+ this never ships a review event, by design, so a bulk "clear the backlog"
779
+ click never reaches the review-events/feedback-digest rail and can't
780
+ pollute learned_preferences with a non-judgment. Returns how many were
781
+ stamped."""
782
+
783
+ def mutate(data):
784
+ done = 0
785
+ for d in drafts:
786
+ c = _match_candidate(data, d.get("n"), d.get("candidate_id"))
787
+ if c is None or c.get("posted") is True or c.get("terminal") is True:
788
+ continue
789
+ c["terminal"] = True
790
+ c["terminal_reason"] = "human_discarded_all"
791
+ c["decision"] = {
792
+ "approved": False,
793
+ "text": c.get("reply_text") or "",
794
+ "edited": False,
795
+ "drop_link": False,
796
+ "loved": False,
797
+ "reject_category": None,
798
+ "decided_at": time_iso(),
799
+ }
800
+ done += 1
801
+ return done
802
+
803
+ return _store_update(mutate) or 0
804
+
805
+
773
806
  def store_mark_post_failed(batch, n, candidate_id=None, error=None):
774
807
  """A decided post that FAILED surfaces via notification/dashboard, not by
775
808
  re-presenting the card and not by endless resume retries."""
package/mcp/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/s4l-mcp",
3
- "version": "1.7.2-rc.5",
3
+ "version": "1.7.2-rc.7",
4
4
  "private": true,
5
5
  "description": "Desktop MCP client for social-autoposter (X/Twitter rail): manual draft/review/approve loop, autopilot control, and stats. Thin wrapper over the existing pipeline scripts.",
6
6
  "license": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/s4l",
3
- "version": "1.7.2-rc.5",
3
+ "version": "1.7.2-rc.7",
4
4
  "description": "Automated social posting pipeline for Reddit, X/Twitter, LinkedIn, and Moltbook. Install as a Claude Code agent skill.",
5
5
  "bin": {
6
6
  "social-autoposter": "bin/cli.js",
@@ -18,10 +18,14 @@ Safe by construction:
18
18
  - Best-effort: any single failure is logged and skipped; never raises.
19
19
 
20
20
  Degradation vs a normal cycle: salvaged candidates skip the cycle's post-provider
21
- top-N selection (so MORE cards, which is fine) and lack the tail-link / experiments
22
- arm stamp that run-twitter-cycle.sh's plan writer adds after the provider returns.
23
- The reply text itself is complete. A salvaged card is strictly better than a lost
24
- draft.
21
+ top-N selection (so MORE cards, which is fine), lack the tail-link / experiments
22
+ arm stamp that run-twitter-cycle.sh's plan writer adds after the provider returns,
23
+ and (two-draft schema only) lack assigned_style/assigned_mode, which live in the
24
+ cycle's shell variables, not the model output. The reply text itself IS complete
25
+ end-to-end (_mirror_two_draft_fields backfills reply_text/drafts from
26
+ draft_a_text/draft_b_text for the post-2026-07-07/08 two-draft schema, since the
27
+ model output alone has no reply_text field to check for completeness). A salvaged
28
+ card is strictly better than a lost draft.
25
29
 
26
30
  Usage:
27
31
  python3 scripts/salvage_orphaned_prep_results.py # automated (safe age gate)
@@ -59,6 +63,52 @@ except Exception: # standalone fallbacks
59
63
  pass
60
64
 
61
65
 
66
+ def _mirror_two_draft_fields(candidates):
67
+ """Backfill reply_text/drafts for two-draft-schema candidates (2026-07-07/08
68
+ redesign) that reach salvage. The normal cycle path (run-twitter-cycle.sh)
69
+ mirrors draft_a_text onto reply_text/engagement_style/drafts right after the
70
+ model returns, but salvage bypasses that shell-side step entirely, so an
71
+ orphaned post-redesign result reached review cards with NEITHER field set.
72
+ The menubar card (s4l_card.py) reads d.get("drafts") first, then falls back
73
+ to d.get("reply_text") or "", so those cards rendered the thread with a
74
+ completely empty editable reply box despite draft_a_text/draft_b_text
75
+ holding real, already-drafted content (root-caused 2026-07-09 via
76
+ candidate 374925 and 4 siblings, all missing 'experiments' too, confirming
77
+ they came through this salvage path rather than a normal cycle write).
78
+
79
+ assigned_style/assigned_mode are deliberately left OUT (not set to None,
80
+ just absent): the picker's per-cycle style assignment lives only in
81
+ run-twitter-cycle.sh's shell variables, not in the model's JSON output, so
82
+ it can't be recovered here. twitter_post_plan.py already has a documented
83
+ fallback for that ("assigned_mode key absent" -> use the plan-level
84
+ assignment, itself None for a salvaged plan), so leaving the keys out is
85
+ the safe, already-supported degradation, same class as the existing
86
+ no-experiments-stamp degradation.
87
+ """
88
+ for c in candidates:
89
+ if not isinstance(c, dict) or "draft_a_text" not in c or "reply_text" in c:
90
+ continue
91
+ c["reply_text"] = c.get("draft_a_text") or ""
92
+ c["engagement_style"] = c.get("draft_a_style") or ""
93
+ c["new_style"] = c.get("draft_a_new_style")
94
+ if c.get("draft_a_text_en"):
95
+ c["reply_text_en"] = c["draft_a_text_en"]
96
+ draft_b_text = c.get("draft_b_text")
97
+ if not c.get("is_reused_draft") and draft_b_text:
98
+ c["drafts"] = [
99
+ {
100
+ "variant": "a", "text": c.get("draft_a_text") or "",
101
+ "style": c.get("draft_a_style") or "",
102
+ "text_en": c.get("draft_a_text_en"),
103
+ },
104
+ {
105
+ "variant": "b", "text": draft_b_text,
106
+ "style": c.get("draft_b_style") or "",
107
+ "text_en": c.get("draft_b_text_en"),
108
+ },
109
+ ]
110
+
111
+
62
112
  def _is_prep_result(obj):
63
113
  """True iff obj looks like a twitter-prep result (drafted candidates).
64
114
 
@@ -142,6 +192,7 @@ def main():
142
192
  pass
143
193
  continue
144
194
 
195
+ _mirror_two_draft_fields(obj["candidates"])
145
196
  n = len(obj["candidates"])
146
197
  age_min = (now - st.st_mtime) / 60.0
147
198
  _plog(f"[salvage] ORPHAN prep result job {job_id}: producer never consumed it "