@xingwangzhe/stalux 1.13.0 → 1.14.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingwangzhe/stalux",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "A powerful, modern Astro blog theme — use as template or install as plugin",
5
5
  "keywords": [
6
6
  "astro",
@@ -180,10 +180,12 @@ function listPostsTool(): WebMCPTool {
180
180
  description: pick(
181
181
  "分页列出博客的全部已发布文章,返回标题、永久链接(abbrlink)、日期、分类、标签、摘要与文章页 URL。" +
182
182
  "需要浏览全站文章、确认某篇文章的 abbrlink 时使用;不返回正文," +
183
- "只要某篇元信息用 stalux_get_post,读正文请用 stalux_read_post。",
183
+ "只要某篇元信息用 stalux_get_post,读正文请用 stalux_read_post。" +
184
+ "pageSize 建议设 50 一次拿完,减少翻页;页码越界时会自动返回最后一页(clamped 标记)。",
184
185
  "Paginated list of all published posts, returning title, permanent link (abbrlink), date, categories, tags, description and post page URL. " +
185
186
  "Use it to browse the whole blog or find a post's abbrlink; it does not return body content — " +
186
- "use stalux_get_post for one post's metadata, or stalux_read_post for the full body.",
187
+ "use stalux_get_post for one post's metadata, or stalux_read_post for the full body. " +
188
+ "Prefer pageSize 50 to fetch everything in one call; out-of-range pages clamp to the last page (clamped flag).",
187
189
  ),
188
190
  annotations: { readOnlyHint: true, untrustedContentHint: false },
189
191
  inputSchema: {
@@ -222,23 +224,16 @@ function listPostsTool(): WebMCPTool {
222
224
  );
223
225
  const total = list.length;
224
226
  const totalPages = Math.ceil(total / pageSize) || 1;
225
- const start = (page - 1) * pageSize;
226
- if (start >= total) {
227
- return err(
228
- "OUT_OF_RANGE",
229
- pick(
230
- "第 " + page + " 页没有文章(共 " + totalPages + " 页)",
231
- "Page " + page + " has no posts (" + totalPages + " pages total)",
232
- ),
233
- {
234
- page,
235
- totalPages,
236
- total,
237
- },
238
- );
227
+ // 越界时自动回退到最后一页(而非报错),agent 翻过头也能拿到数据
228
+ let clamped = false;
229
+ let resolvedPage = page;
230
+ if (page > totalPages) {
231
+ resolvedPage = totalPages;
232
+ clamped = true;
239
233
  }
234
+ const start = (resolvedPage - 1) * pageSize;
240
235
  const posts = list.slice(start, start + pageSize).map(briefMeta);
241
- return { ok: true, page, pageSize, total, totalPages, posts };
236
+ return { ok: true, page: resolvedPage, pageSize, total, totalPages, clamped, posts };
242
237
  },
243
238
  };
244
239
  }