social-autoposter 1.6.44 → 1.6.45
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 +40 -7
- package/package.json +1 -1
package/mcp/dist/index.js
CHANGED
|
@@ -180,7 +180,8 @@ function cycleProgressMessage(line) {
|
|
|
180
180
|
let m;
|
|
181
181
|
if (/=== Twitter Cycle \(batch=/.test(l))
|
|
182
182
|
return "Starting draft cycle…";
|
|
183
|
-
|
|
183
|
+
// NB: lines carry a `[HH:MM:SS] ` timestamp prefix, so don't anchor on ^.
|
|
184
|
+
if ((m = /Selected projects?:\s*(.+)$/.exec(l)))
|
|
184
185
|
return `Selected project: ${m[1]}`;
|
|
185
186
|
if (/phase=phase1\b/.test(l) || /Phase 1: drafting queries/.test(l))
|
|
186
187
|
return "Searching X for fresh threads…";
|
|
@@ -210,24 +211,56 @@ async function produceDrafts(project, onProgress) {
|
|
|
210
211
|
if (project)
|
|
211
212
|
env.SAPS_FORCE_PROJECT = project;
|
|
212
213
|
let step = 0;
|
|
214
|
+
let lastMsg = "";
|
|
215
|
+
// ONE predictable, host-independent place to watch a draft_cycle run, so any
|
|
216
|
+
// agent (or human) debugging "the cycle looks stuck" has an obvious path:
|
|
217
|
+
// ~/social-autoposter/skill/logs/draft_cycle-mcp.log
|
|
218
|
+
// It lives right next to the cycle's own twitter-cycle-*.log. We append the
|
|
219
|
+
// full live cycle output here (not just milestones) plus a clear run banner.
|
|
220
|
+
// Best-effort: a logging failure must never break the cycle.
|
|
221
|
+
const mcpLog = path.join(REPO_DIR, "skill", "logs", "draft_cycle-mcp.log");
|
|
222
|
+
const appendLog = (s) => {
|
|
223
|
+
try {
|
|
224
|
+
fs.appendFileSync(mcpLog, s);
|
|
225
|
+
}
|
|
226
|
+
catch {
|
|
227
|
+
/* ignore — never fail the cycle over a log write */
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
try {
|
|
231
|
+
fs.mkdirSync(path.dirname(mcpLog), { recursive: true });
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
/* ignore */
|
|
235
|
+
}
|
|
236
|
+
appendLog(`\n===== draft_cycle start ${new Date().toISOString()} ` +
|
|
237
|
+
`project=${project ?? "(default)"} =====\n`);
|
|
213
238
|
const res = await run("bash", ["skill/run-twitter-cycle.sh"], {
|
|
214
239
|
env,
|
|
215
240
|
timeoutMs: 900_000, // scan+draft can take several minutes
|
|
216
|
-
//
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
241
|
+
// Fan every cycle line out to THREE sinks so progress is never a black box:
|
|
242
|
+
// 1. draft_cycle-mcp.log — the stable, documented, host-independent file.
|
|
243
|
+
// 2. this server's stderr — lands in the host's MCP server log
|
|
244
|
+
// (mcp-server-social-autoposter.log on Desktop), which used to show
|
|
245
|
+
// only the JSON-RPC handshake.
|
|
246
|
+
// 3. the live progress sink — milestone messages under the chat spinner.
|
|
220
247
|
onLine: (line) => {
|
|
221
248
|
const t = line.replace(/\s+$/, "");
|
|
222
|
-
if (t.trim())
|
|
249
|
+
if (t.trim()) {
|
|
250
|
+
appendLog(`${t}\n`);
|
|
223
251
|
console.error(`[draft_cycle] ${t}`);
|
|
252
|
+
}
|
|
224
253
|
if (!onProgress)
|
|
225
254
|
return;
|
|
226
255
|
const msg = cycleProgressMessage(t);
|
|
227
|
-
|
|
256
|
+
// Skip consecutive duplicates (a phase can log a couple matching lines).
|
|
257
|
+
if (msg && msg !== lastMsg) {
|
|
258
|
+
lastMsg = msg;
|
|
228
259
|
onProgress(msg, ++step);
|
|
260
|
+
}
|
|
229
261
|
},
|
|
230
262
|
});
|
|
263
|
+
appendLog(`===== draft_cycle end ${new Date().toISOString()} exit=${res.code} =====\n`);
|
|
231
264
|
// Prefer the explicit marker; fall back to the newest plan file on disk.
|
|
232
265
|
const marker = /DRAFT_ONLY_PLAN=\/tmp\/twitter_cycle_plan_(.+)\.json/.exec(res.stdout + "\n" + res.stderr);
|
|
233
266
|
if (marker && marker[1])
|
package/package.json
CHANGED