跳到正文
Skillpedia
API 与服务器(后端)7.6k · #13203

slot-engine

它能做什么

这项技能描述计算哪些会议时段开放的函数,以及它始终遵循的规则。适合需要基于它进行开发,或需要找出某个时间缺失原因的开发者。

适用场景

  • ✓当预约页面上缺少某个会议时间,你需要找出原因的时候。
  • ✓当你修改可用时间的计算方式的时候。
  • ✓当你需要知道计算所保证的内容,例如不会出现过去时段的时候。

技能链接

https://github.com/BuilderIO/agent-native/blob/main/packages/scheduling/docs/skills/slot-engine/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/BuilderIO/agent-native/blob/main/packages/scheduling/docs/skills/slot-engine/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“为什么我的预约页面上周二下午 2 点没有显示为可预约?请帮我查明原因。”

每周 5 个新技能,1 分钟读完。

工作原理

该函数接收会议规则、日程、忙碌时段和现有预约数量,并返回一个时段列表。排查时需要检查该日的每周工作时间、日期变更和忙碌时段。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Slot engine

import { computeAvailableSlots } from "@agent-native/scheduling/core"

Inputs

  • Event type config (duration, buffers, minimum notice, period, limits, slot interval)
  • Schedule (timezone + weekly availability + date overrides)
  • Busy intervals (UTC, aggregated from external calendars + existing bookings)
  • Booking counts by bucket (day/week/month/year) for limit enforcement
  • Time range to compute over
  • Optional seats-per-slot + seats-taken map
  • Viewer timezone (for limit bucketing, if it differs from the schedule)

Output

  • Array of Slot { start: ISO, end: ISO, available: boolean, seatsRemaining?, hostEmail? }

Invariants

The function guarantees, in order:

  1. No slot falls in the past (now + minimumBookingNotice is the floor).
  2. No slot overlaps a busy interval (with buffers applied).
  3. No slot falls outside the schedule's available intervals for that day.
  4. No slot exceeds a booking limit.
  5. No slot falls outside the event's period (rolling/range).
  6. DST-safe: we convert to UTC using the schedule's timezone before doing any interval arithmetic.

Debugging

If a slot is unexpectedly missing:

  1. Check the schedule's weekly availability for that day-of-week in the schedule's timezone (not UTC — weekends can shift across the date line).
  2. Check date overrides for that local date (empty intervals = fully blocked).
  3. Check merged busy intervals for overlap, including the before/after buffer expansion.
  4. Check booking limits: a single existing booking can close a day.
  5. Check period caps: rolling periods restrict how far in the future slots appear.

If a slot is unexpectedly present:

  1. Check that now is being passed correctly (defaults to new Date()).
  2. Check that busy intervals from providers are in UTC.
  3. Confirm slot interval matches what you expect (default = duration).
常见问题

函数会返回过去的时段吗?

不会。早于最短提前通知期限的时间绝不会提供。

夏令时如何处理?

在进行任何计算之前,时间会先按日程的时区进行转换。

时段缺失时我应先检查什么?

该日在日程自身时区中的每周工作时间。

详情

作者的原始描述

The pure `computeAvailableSlots` function — inputs, outputs, invariants, and debugging guide.

repo: BuilderIO/agent-native

热度

GitHub 星标
7.6k
排名
#13203
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能