social-autoposter 1.6.78 → 1.6.80

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/mcp/dist/index.js CHANGED
@@ -183,17 +183,21 @@ const server = new McpServer({
183
183
  "autopilot by calling the HOST tool `create_scheduled_task` with: taskId " +
184
184
  "'social-autoposter-autopilot'; cronExpression '* * * * *' (continuous, like the pipeline; the " +
185
185
  "host runs one at a time and skips overlapping fires, so cycles run back-to-back); and a " +
186
- "self-contained prompt telling the run to call scan_candidates (which long-pollsif it " +
187
- "returns a `Scan in progress` status, call scan_candidates again with the same args and keep " +
188
- "re-calling until it returns candidates; never sleep or use background waits between calls), " +
189
- "then (if it needs the project's brand voice to draft on-brand) call project_config to read it, " +
190
- "draft ONE on-brand reply (<=250 chars, same language as the thread, adds real value) for each " +
191
- "candidate worth engaging, then call submit_drafts with those drafts, and NOT post (drafts pile " +
192
- "up in the menu-bar approval cards for the user to approve). The prompt MUST name EVERY tool the " +
193
- "run can use (scan_candidates, project_config, submit_drafts) so none is a surprise mid-run. " +
194
- "Then run ONE FULL cycle yourself now that exercises ALL of them " +
195
- "(scan_candidates -> project_config -> draft -> submit_drafts) to seed the cards AND pre-approve " +
196
- "every tool, so unattended fires never stall waiting on a per-tool permission prompt. If the host " +
186
+ "self-contained prompt telling the run to use ONLY two toolsscan_candidates and submit_drafts " +
187
+ " and to IMPROVISE NOTHING ELSE. Specifically the prompt must say: (1) call scan_candidates " +
188
+ "(which long-polls if it returns a `Scan in progress` status, call scan_candidates again with " +
189
+ "the same args and keep re-calling until it returns candidates; never sleep or use background " +
190
+ "waits between calls); (2) the brand voice + guardrails come back INLINE in the result's " +
191
+ "`project_voices[<matched_project>]` field draft from THAT and NEVER read config files, call " +
192
+ "project_config, or run Bash/Read to find the voice; (3) draft ONE on-brand reply (<=250 chars, " +
193
+ "same language as the thread, adds real value) for each candidate worth engaging; (4) call " +
194
+ "submit_drafts with those drafts, and do NOT post (drafts pile up in the menu-bar approval cards). " +
195
+ "Add a HARD GUARD: if scan_candidates is NOT available (ToolSearch returns no matching tool — can " +
196
+ "happen when a run spawns before the extension's MCP server reconnects), STOP immediately and " +
197
+ "report 'S4L tools unavailable, skipping this cycle' — do NOT search the connector registry, do " +
198
+ "NOT call list_connectors, do NOT improvise any other tool. Then run ONE cycle yourself now " +
199
+ "(scan_candidates -> draft -> submit_drafts) to seed the cards AND pre-approve those two tools, " +
200
+ "so unattended fires never stall waiting on a per-tool permission prompt. If the host " +
197
201
  "exposes no create_scheduled_task tool, tell the user " +
198
202
  "the autopilot could not be scheduled here and to run a draft cycle manually instead.\n\n" +
199
203
  "BE PROACTIVE ABOUT MARKETING MOMENTS. Whenever the user ships, finishes, merges, or releases " +
@@ -1838,18 +1842,61 @@ function startScanJob(project) {
1838
1842
  });
1839
1843
  return job;
1840
1844
  }
1845
+ // Read the on-brand drafting guidance for the given projects from config.json so
1846
+ // scan_candidates can hand it to the agent INLINE. Without this the autopilot run
1847
+ // has to read the config itself (project_config returns status, not the voice
1848
+ // fields) — and a headless run improvises Bash/Read for that, hitting an
1849
+ // un-approved tool and hanging. Returning the voice here removes the need to read
1850
+ // any file. Best-effort: a missing/unreadable config yields {} and the agent
1851
+ // drafts from thread context, same as before.
1852
+ function readProjectVoices(projectNames) {
1853
+ const out = {};
1854
+ const want = new Set(projectNames.filter(Boolean));
1855
+ if (!want.size)
1856
+ return out;
1857
+ try {
1858
+ const cfg = JSON.parse(fs.readFileSync(path.join(repoDir(), "config.json"), "utf-8"));
1859
+ const projects = Array.isArray(cfg?.projects) ? cfg.projects : [];
1860
+ for (const p of projects) {
1861
+ if (!p?.name || !want.has(p.name))
1862
+ continue;
1863
+ // Only the fields needed to draft on-brand — keep it lean.
1864
+ out[p.name] = {
1865
+ voice: p.voice,
1866
+ voice_relationship: p.voice_relationship,
1867
+ description: p.description,
1868
+ differentiator: p.differentiator,
1869
+ content_guardrails: p.content_guardrails,
1870
+ website: p.website,
1871
+ get_started_link: p.get_started_link,
1872
+ };
1873
+ }
1874
+ }
1875
+ catch {
1876
+ /* best effort — no inline voice, agent falls back to thread context */
1877
+ }
1878
+ return out;
1879
+ }
1841
1880
  function formatScanResult(scan) {
1842
1881
  if (!scan.batchId) {
1843
1882
  return textContent(scan.blocked || "No candidates found.");
1844
1883
  }
1884
+ // The brand voice for every project in this batch, INLINE, so the agent never
1885
+ // has to read a config file (that improvisation is what hangs headless runs).
1886
+ const projects = Array.from(new Set(scan.candidates.map((c) => c.matched_project).filter(Boolean)));
1887
+ const project_voices = readProjectVoices(projects);
1845
1888
  return jsonContent({
1846
1889
  batch_id: scan.batchId,
1847
1890
  count: scan.candidates.length,
1848
1891
  candidates: scan.candidates,
1892
+ project_voices,
1849
1893
  next_step: `Draft an on-brand reply (<=250 chars, match the thread's language) for each candidate you ` +
1850
- `judge genuinely worth engaging; skip the rest. Then call submit_drafts with batch_id ` +
1851
- `"${scan.batchId}" and one entry per drafted reply ({candidate_id, reply_text}). Nothing posts ` +
1852
- `until the user approves.`,
1894
+ `judge genuinely worth engaging; skip the rest. The brand voice + guardrails for each ` +
1895
+ `candidate's project are in project_voices[<matched_project>] (voice, description, ` +
1896
+ `differentiator, content_guardrails) draft from THAT. Do NOT read config files or call any ` +
1897
+ `other tool to find the voice; everything you need is in this result. Then call submit_drafts ` +
1898
+ `with batch_id "${scan.batchId}" and one entry per drafted reply ({candidate_id, reply_text}). ` +
1899
+ `Nothing posts until the user approves.`,
1853
1900
  });
1854
1901
  }
1855
1902
  function scanInProgress(job) {
@@ -1867,7 +1914,10 @@ tool("scan_candidates", {
1867
1914
  "and without spending any `claude -p` budget. You (this session) then draft an on-brand reply " +
1868
1915
  "for each good candidate YOURSELF and submit them with `submit_drafts`. Each candidate includes " +
1869
1916
  "its candidate_id (pass it back), the thread text/author, the matched project, and engagement " +
1870
- "metrics. Optional `project` scopes the scan to one configured project. The scan drives a real " +
1917
+ "metrics. The result ALSO includes `project_voices` the brand voice + guardrails for each " +
1918
+ "project in the batch — so you draft on-brand WITHOUT reading config files or calling other " +
1919
+ "tools (do not improvise a config read). Optional `project` scopes the scan to one configured " +
1920
+ "project. The scan drives a real " +
1871
1921
  "browser and can take 1-3 minutes: this call long-polls and may return a `Scan in progress` " +
1872
1922
  "status instead of candidates — if so, just call scan_candidates again (same args) and keep " +
1873
1923
  "re-calling until it returns candidates. Never sleep or use a background wait to bridge the gap.",
@@ -178,6 +178,7 @@ export function ensurePipelineCurrent() {
178
178
  const rt = readRuntime();
179
179
  if (rt?.pipeline_version === bundled)
180
180
  return; // already current.
181
+ const prevVer = rt?.pipeline_version ?? "unrecorded"; // capture before we mutate rt below.
181
182
  // Stale (or never recorded): extract the new pipeline OVER the materialized
182
183
  // repo. No rmSync, so config.json + logs are preserved.
183
184
  fs.mkdirSync(REPO_MATERIALIZE_DIR, { recursive: true });
@@ -199,7 +200,7 @@ export function ensurePipelineCurrent() {
199
200
  /* best effort — worst case we re-extract next boot */
200
201
  }
201
202
  }
202
- console.error(`[runtime] re-materialized pipeline -> ${bundled} (was ${rt?.pipeline_version ?? "unrecorded"})`);
203
+ console.error(`[runtime] re-materialized pipeline -> ${bundled} (was ${prevVer})`);
203
204
  }
204
205
  catch (e) {
205
206
  console.error(`[runtime] ensurePipelineCurrent error: ${e?.message || e}`);
@@ -773,7 +774,12 @@ export async function ensureMenubar() {
773
774
  if (fs.existsSync(MENUBAR_ENTRY) &&
774
775
  fs.existsSync(MENUBAR_PLIST) &&
775
776
  (await menubarLoaded())) {
776
- return { ok: true, skipped: true, detail: "already installed" };
777
+ // Installed but refresh the stable copy if the bundled menu bar is newer.
778
+ // An .mcpb update ships new menu bar code, yet the running menu bar runs from
779
+ // this stable copy (so it survives extension replacement); without this it
780
+ // would stay the version it first installed at. Cheap: content-compare, and
781
+ // a kickstart only when something actually changed.
782
+ return await refreshMenubarIfStale();
777
783
  }
778
784
  const uv = findUv();
779
785
  if (!uv)
@@ -783,3 +789,35 @@ export async function ensureMenubar() {
783
789
  };
784
790
  return installMenubar(uv, uvEnv, resolvePython());
785
791
  }
792
+ // Re-copy the bundled menu bar python into the stable dir when it differs from
793
+ // what's installed, and kickstart the launchd job so the running menu bar picks
794
+ // up the new code. Content-compare keeps this a no-op on an unchanged boot, so
795
+ // it's cheap to call on every ensureMenubar(). This is what makes menu bar
796
+ // changes (e.g. the "Please update now" button) actually ship on an .mcpb update.
797
+ async function refreshMenubarIfStale() {
798
+ const src = menubarSourceDir();
799
+ if (!src)
800
+ return { ok: true, skipped: true, detail: "no bundle source to refresh from" };
801
+ let changed = false;
802
+ try {
803
+ for (const f of fs.readdirSync(src)) {
804
+ if (!f.endsWith(".py"))
805
+ continue;
806
+ const s = fs.readFileSync(path.join(src, f));
807
+ const dPath = path.join(MENUBAR_DIR, f);
808
+ const d = fs.existsSync(dPath) ? fs.readFileSync(dPath) : Buffer.alloc(0);
809
+ if (!s.equals(d)) {
810
+ fs.writeFileSync(dPath, s);
811
+ changed = true;
812
+ }
813
+ }
814
+ }
815
+ catch (e) {
816
+ return { ok: true, skipped: true, detail: `menu bar refresh check failed: ${e?.message || e}` };
817
+ }
818
+ if (!changed)
819
+ return { ok: true, skipped: true, detail: "menu bar already current" };
820
+ const uid = process.getuid ? process.getuid() : 0;
821
+ await sh("launchctl", ["kickstart", "-k", `gui/${uid}/${MENUBAR_LABEL}`], { timeoutMs: 15_000 });
822
+ return { ok: true, detail: "menu bar refreshed + restarted to bundled version" };
823
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "1.6.78",
3
- "installedAt": "2026-06-22T18:51:40.278Z"
2
+ "version": "1.6.80",
3
+ "installedAt": "2026-06-22T19:14:04.032Z"
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.6.78",
5
+ "version": "1.6.80",
6
6
  "description": "Draft, review, approve, and autopilot X/Twitter posts. Thin desktop client over the S4L pipeline.",
7
7
  "long_description": "A guided assistant that drafts, reviews, and autopilots X/Twitter posts.\nTo get started:\n1. Click **Configure** and set every tool permission to **Always Allow**.\n2. Copy this prompt: **Set me up on S4L end to end**.\n3. Quit fully with CMD+Q, restart Claude, and paste the prompt into a new chat.",
8
8
  "author": {
@@ -17,9 +17,12 @@ rather than rumps.notification (which needs a bundle id).
17
17
  """
18
18
 
19
19
  import json
20
+ import os
20
21
  import subprocess
21
22
  import sys
23
+ import tempfile
22
24
  import threading
25
+ import time
23
26
 
24
27
  import rumps
25
28
 
@@ -111,6 +114,14 @@ class S4LMenuBar(rumps.App):
111
114
  # read per second.
112
115
  self._act_poll = rumps.Timer(self._poll_activity, 1.0)
113
116
  self._act_poll.start()
117
+ # Self-check for a newer published .mcpb, independent of the MCP server's
118
+ # npm check (which has been flaky). Slow timer + cache; drives the title
119
+ # indicator + the "Please update now" menu item.
120
+ self._update_available = False
121
+ self._latest_version = None
122
+ self._upd_timer = rumps.Timer(self._check_update, 1800) # every 30 min
123
+ self._upd_timer.start()
124
+ self._check_update(None)
114
125
  self._tick(None)
115
126
 
116
127
  # ---- side effects -----------------------------------------------------
@@ -172,6 +183,98 @@ class S4LMenuBar(rumps.App):
172
183
  def _update(self, _=None):
173
184
  self._send_to_claude(UPDATE_PROMPT)
174
185
 
186
+ # ---- .mcpb self-update (menu-bar driven) ------------------------------
187
+ EXT_DIR = os.path.expanduser(
188
+ "~/Library/Application Support/Claude/Claude Extensions/"
189
+ "local.mcpb.m13v.social-autoposter"
190
+ )
191
+ MCPB_URL = (
192
+ "https://github.com/m13v/social-autoposter/releases/latest/download/"
193
+ "social-autoposter.mcpb"
194
+ )
195
+ RELEASE_API = (
196
+ "https://api.github.com/repos/m13v/social-autoposter/releases/latest"
197
+ )
198
+
199
+ @staticmethod
200
+ def _vtuple(v):
201
+ try:
202
+ return tuple(int(x) for x in str(v).split("."))
203
+ except Exception:
204
+ return (0,)
205
+
206
+ def _check_update(self, _=None):
207
+ """Is a newer .mcpb published than what's installed? Compare the GitHub
208
+ latest release tag to the installed extension manifest. Offline / API
209
+ errors leave the cached value untouched (never flips to 'no update' on a
210
+ transient failure). A change forces a title + menu repaint."""
211
+ installed = None
212
+ try:
213
+ with open(os.path.join(self.EXT_DIR, "manifest.json")) as f:
214
+ installed = (json.load(f) or {}).get("version")
215
+ except Exception:
216
+ return # not a .mcpb install (or no manifest) -> nothing to offer
217
+ try:
218
+ r = subprocess.run(
219
+ ["curl", "-fsSL", "-m", "15", self.RELEASE_API],
220
+ capture_output=True, text=True, timeout=20,
221
+ )
222
+ if r.returncode != 0:
223
+ return
224
+ latest = ((json.loads(r.stdout) or {}).get("tag_name") or "").lstrip("v")
225
+ except Exception:
226
+ return
227
+ if not latest:
228
+ return
229
+ available = bool(installed) and self._vtuple(latest) > self._vtuple(installed)
230
+ if available != self._update_available or latest != self._latest_version:
231
+ self._update_available = available
232
+ self._latest_version = latest
233
+ self._sig = None # repaint on next tick
234
+
235
+ def _do_mcpb_update(self, _=None):
236
+ """User clicked 'Please update now'. Pull the latest .mcpb, unpack it over
237
+ the Desktop extension dir in place, and restart Claude so the new server
238
+ loads. The menu bar is a launchd process (not a Claude child), so the
239
+ restart is clean. Heavy work runs on a background thread."""
240
+ self._notify("S4L", "Updating… Claude will restart in a moment.")
241
+ threading.Thread(target=self._mcpb_update_work, daemon=True).start()
242
+
243
+ def _mcpb_update_work(self):
244
+ tmpd = tempfile.mkdtemp(prefix="s4l-update-")
245
+ mcpb = os.path.join(tmpd, "social-autoposter.mcpb")
246
+ try:
247
+ r = subprocess.run(["curl", "-fLs", "-m", "300", self.MCPB_URL, "-o", mcpb],
248
+ capture_output=True, timeout=320)
249
+ if r.returncode != 0 or not os.path.exists(mcpb) or os.path.getsize(mcpb) < 100000:
250
+ self._notify("S4L update failed", "Couldn't download the update — check your connection.")
251
+ return
252
+ r = subprocess.run(["unzip", "-oq", mcpb, "-d", self.EXT_DIR],
253
+ capture_output=True, timeout=180)
254
+ if r.returncode != 0:
255
+ self._notify("S4L update failed", "Couldn't unpack the update.")
256
+ return
257
+ # Restart Claude so the refreshed server loads (we're decoupled from it).
258
+ subprocess.run(["osascript", "-e", 'tell application "Claude" to quit'],
259
+ capture_output=True, timeout=20)
260
+ time.sleep(4)
261
+ subprocess.run(["killall", "Claude"], capture_output=True) # if quit was blocked
262
+ time.sleep(2)
263
+ subprocess.run(["killall", "-9", "Claude"], capture_output=True)
264
+ time.sleep(1)
265
+ subprocess.run(["open", "-a", CLAUDE_APP], capture_output=True, timeout=20)
266
+ self._update_available = False
267
+ self._sig = None
268
+ self._notify("S4L updated", "Claude restarted on the latest version.")
269
+ except Exception as e:
270
+ self._notify("S4L update failed", str(e)[:140])
271
+ finally:
272
+ try:
273
+ import shutil
274
+ shutil.rmtree(tmpd, ignore_errors=True)
275
+ except Exception:
276
+ pass
277
+
175
278
  def _open_dashboard(self, _=None):
176
279
  url = st.panel_url()
177
280
  if url:
@@ -350,6 +453,8 @@ class S4LMenuBar(rumps.App):
350
453
  elif not setup_complete and ob and not ob.get("complete"):
351
454
  done = sum(1 for m in ob["milestones"] if m.get("status") == "complete")
352
455
  self.title = f"S4L {done}/{len(ob['milestones'])}"
456
+ elif self._update_available:
457
+ self.title = "S4L ⬆" # update available — open the menu to update
353
458
  else:
354
459
  self.title = "S4L"
355
460
 
@@ -373,12 +478,11 @@ class S4LMenuBar(rumps.App):
373
478
 
374
479
  items.append(rumps.separator)
375
480
  items.append(rumps.MenuItem("Open dashboard", callback=self._open_dashboard))
376
- if snap.get("update_available") and snap.get("latest_version"):
481
+ if self._update_available and self._latest_version:
482
+ items.append(rumps.separator)
483
+ items.append(self._label(f"⬆ Update available · v{self._latest_version}"))
377
484
  items.append(
378
- rumps.MenuItem(
379
- f"Update to v{snap['latest_version']} in Claude",
380
- callback=self._update,
381
- )
485
+ rumps.MenuItem("Please update now", callback=self._do_mcpb_update)
382
486
  )
383
487
  items.append(rumps.MenuItem("Quit", callback=rumps.quit_application))
384
488
 
package/mcp/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/social-autoposter-mcp",
3
- "version": "1.6.78",
3
+ "version": "1.6.80",
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": "social-autoposter",
3
- "version": "1.6.78",
3
+ "version": "1.6.80",
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"