forkfeed-mcp 1.3.0 → 1.3.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 (2) hide show
  1. package/dist/index.js +31 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -160,11 +160,11 @@ function truncateDiff(diff, maxLinesPerFile = 200) {
160
160
  }
161
161
  async function getCommitDetail(cwd, sha) {
162
162
  const [meta, stats, diff] = await Promise.all([
163
- gitExec(['show', sha, '--format=%H|%h|%s|%an|%aI', '--no-patch'], cwd),
163
+ gitExec(['show', sha, `--format=%H${SEP}%h${SEP}%s${SEP}%an${SEP}%aI`, '--no-patch'], cwd),
164
164
  gitExec(['diff', `${sha}^..${sha}`, '--stat'], cwd),
165
165
  gitExec(['diff', `${sha}^..${sha}`, '-U3'], cwd),
166
166
  ]);
167
- const [fullSha, shortSha, message, author, date] = meta.trim().split('|');
167
+ const [fullSha, shortSha, message, author, date] = meta.trim().split(SEP);
168
168
  return {
169
169
  sha: fullSha,
170
170
  shortSha,
@@ -224,10 +224,30 @@ const BG_PREFS = [
224
224
  ['bg25', 'bg30'], // 6: Alternatives
225
225
  ['bg18', 'bg5'], // 7: Quiz
226
226
  ];
227
- function assignBackgrounds(_tags) {
227
+ // Map language tags to preferred Learning card (index 5) backgrounds
228
+ const LANG_BG = {
229
+ javascript: 'bg12', typescript: 'bg12',
230
+ python: 'bg13',
231
+ rust: 'bg14',
232
+ deploy: 'bg15',
233
+ // bg17 = Frontend (fallback for language tag without specific match)
234
+ };
235
+ function assignBackgrounds(tags) {
228
236
  const used = new Set();
229
- return BG_PREFS.map((prefs) => {
230
- const pick = prefs.find((bg) => !used.has(bg)) || prefs[0];
237
+ // For card 5 (Learning), reorder prefs based on detected language tags
238
+ const learningPrefs = [...BG_PREFS[5]];
239
+ for (const tag of tags) {
240
+ const preferred = LANG_BG[tag];
241
+ if (preferred && learningPrefs.includes(preferred)) {
242
+ // Move matched bg to front
243
+ learningPrefs.splice(learningPrefs.indexOf(preferred), 1);
244
+ learningPrefs.unshift(preferred);
245
+ break;
246
+ }
247
+ }
248
+ return BG_PREFS.map((prefs, i) => {
249
+ const candidates = i === 5 ? learningPrefs : prefs;
250
+ const pick = candidates.find((bg) => !used.has(bg)) || candidates[0];
231
251
  used.add(pick);
232
252
  return pick;
233
253
  });
@@ -301,9 +321,10 @@ function inferBlock(block) {
301
321
  };
302
322
  }
303
323
  if ('img' in block) {
324
+ const img = block.img;
304
325
  return {
305
326
  type: 'CONTENT_IMAGE',
306
- imageSrc: resolveImageId(block.img),
327
+ imageSrc: img.startsWith('http') ? img : resolveImageId(img),
307
328
  sizing: (block.sizing || 'wide'),
308
329
  };
309
330
  }
@@ -556,7 +577,7 @@ server.tool('forkfeed_commits', 'Read git commits from the current repo. Without
556
577
  lines.push(`| ${i + 1} | ${c.shortSha} | ${c.message.slice(0, 60)} | ${c.author} | ${c.date} | ${pub} |`);
557
578
  }
558
579
  if (existingFeedIds.length > 0) {
559
- lines.push('', `Existing feed IDs (include ALL in fork.feedIds): ${existingFeedIds.join(', ')}`);
580
+ lines.push('', `Published feeds: ${existingFeedIds.length} (builder auto-includes them)`);
560
581
  }
561
582
  if (statusWarning)
562
583
  lines.push(statusWarning);
@@ -571,8 +592,7 @@ server.tool('forkfeed_commits', 'Read git commits from the current repo. Without
571
592
  return { content: [{ type: 'text', text: `Failed to read commit ${sha}: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
572
593
  }
573
594
  // Extract file paths from stats for tag detection
574
- const filePathMatches = detail.stats.match(/^\s*(.+?)\s+\|/gm) || [];
575
- const filePaths = filePathMatches.map((m) => m.trim().replace(/\s+\|$/, ''));
595
+ const filePaths = parseFilePathsFromStats(detail.stats);
576
596
  const tags = detectTags(detail.message, filePaths);
577
597
  const images = filterImagesByTags(tags);
578
598
  const lines = [
@@ -587,13 +607,10 @@ server.tool('forkfeed_commits', 'Read git commits from the current repo. Without
587
607
  '## Diff',
588
608
  detail.diff,
589
609
  '',
590
- `## Suggested Images (tags: ${tags.join(', ')})`,
610
+ `## Suggested Scene Images (tags: ${tags.join(', ')})`,
611
+ 'Use short IDs (e.g. img47) in card blocks. Backgrounds are auto-assigned by the builder.',
591
612
  '',
592
- 'Scene images (for covers + inline):',
593
613
  ...images.scenes,
594
- '',
595
- 'Background images (for card backgrounds):',
596
- ...images.backgrounds,
597
614
  ].filter(Boolean);
598
615
  return { content: [{ type: 'text', text: lines.join('\n') }] };
599
616
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forkfeed-mcp",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "MCP server for pushing GitHub commits to forkfeed",
5
5
  "type": "module",
6
6
  "bin": {