traffic-light-calc
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "traffic-light-calc" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-41272a2b42f6397889b64dddc80d791ac05668011014587ec228f8f80bde7639. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/qgi20260031 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Calculates remaining seconds until the next signal change based on the durations of red, yellow, and green phases and the current state. Useful for questions like “how long until the light changes,” “what is the signal cycle length,” or “how much time remains on the pedestrian countdown.” Do not run red lights; follow traffic rules to ensure safety.
Introduction source: third_party · user_f1b049da · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Audience
- Not specified in the source documentation.
- Inputs and outputs
- Not specified in the source documentation.
- Software, accounts and paid services
- Not specified in the source documentation.
- Limits and differences
- Not specified in the source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: traffic-light-calc
slug: qgi20260031
displayName: 红绿灯计算器
version: 1.0.0
summary: 按红黄绿相位时长与当前状态,计算剩余秒数与下一变化时刻。
license: MIT
description: 按红黄绿相位时长与当前状态,计算剩余秒数与下一变化时刻。当用户问红绿灯还要等多久、信号灯周期、过街倒计时时使用。不鼓励闯红灯。红绿灯计算器
原创本地试算:输入路口信号灯各相位秒数与「当前灯色 + 已亮秒数」(或倒计时读数),计算:
- 本相位还剩多久
- 距下次绿灯 / 红灯还有多久
- 一个完整周期多长
- (可选)步行过街是否赶得及
仅供估算;实地以灯态与交警设施为准。禁止输出怂恿超速或闯灯的建议。
何时使用
- 「红灯还要等多久」
- 「绿闪还有几秒变黄」
- 「过街 20 米能不能这波过」
硬约束
- 相位时长均
> 0;支持自定义顺序,默认循环:绿 → 黄 → 红(可配置行人专用相等价相位)。 - 当前状态:
phase+elapsedSec(已显示秒)或remainSec(倒计时);二者只取一种,优先remainSec。 - 输出整数秒(四舍五入)+ 下一变灯的相对时间;可选绝对时刻(需用户提供现在时钟)。
- 过街估算:
crossingSec = distanceM / walkSpeed(默认 1.2 m/s),与绿灯剩余比较,给「建议等待 / 可谨慎通过」——黄灯一律建议停。 - 文案免责:不同路口有箭头灯、感应配时,本模型为固定周期近似。
推荐模型
export type Phase = 'green' | 'yellow' | 'red'
export type LightConfig = {
green: number
yellow: number
red: number
/** 相位顺序,默认绿黄红 */
order?: Phase[]
}
const roundSec = (n: number) => Math.max(0, Math.round(n))
export function cycleLength(c: LightConfig) {
return c.green + c.yellow + c.red
}
export function remainInPhase(input: {
config: LightConfig
phase: Phase
elapsedSec?: number
remainSec?: number
}) {
const dur = input.config[input.phase]
if (input.remainSec != null) return roundSec(Math.min(dur, Math.max(0, input.remainSec)))
const elapsed = input.elapsedSec ?? 0
return roundSec(Math.max(0, dur - elapsed))
}
/** 从当前相位剩余,累加直到目标相位再次开始 */
export function secondsUntilPhase(
config: LightConfig,
current: Phase,
remain: number,
target: Phase,
) {
const order = config.order ?? (['green', 'yellow', 'red'] as Phase[])
let i = order.indexOf(current)
let wait = remain
// 先走完当前剩余;若目标就是当前且 remain>0,则 wait=remain(「还要亮多久」)
if (current === target) return roundSec(remain)
for (let step = 0; step < order.length; step++) {
i = (i + 1) % order.length
const p = order[i]
if (p === target) return roundSec(wait)
wait += config[p]
}
return roundSec(wait)
}
export function canCrossOnGreen(opts: {
greenRemainSec: number
distanceM: number
walkMps?: number
bufferSec?: number
}) {
const need = opts.distanceM / (opts.walkMps ?? 1.2) + (opts.bufferSec ?? 2)
const ok = opts.greenRemainSec >= need
return { needSec: roundSec(need), ok, advice: ok ? '绿灯剩余较充足,仍须左右观察' : '建议等下一轮绿灯' }
}
Agent 执行步骤
- 收集:绿/黄/红秒数;当前灯色;剩余或已过秒数。
- 输出:周期、本相剩余、距绿灯、距红灯;需要时做步行过街判断。
- 黄灯/红灯场景明确「停车等待」,不给抢黄灯话术。
附加
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供红绿灯倒计时、步行过街时间估算等实用功能,解决日常出行中的具体痛点
- 明确安全约束,禁止输出闯灯建议,符合交通规则
Highlights
- 触发词覆盖典型场景(红绿灯等待、信号周期、过街倒计时),边界清晰
- description 位置正确,内容完整无截断
Areas to improve
-
缺少端到端完整示例 Reported severity: Minor
文档提供了函数模型和步骤,但缺少一个完整的端到端使用示例(如输入具体数值后的完整输出)
Recommendation: 补充一个完整的端到端示例,展示从输入到输出的完整流程,提升用户理解
Highlights
- Phase/步骤划分清晰,有明确的硬约束和执行步骤
- frontmatter 完整,单文件长度适中
Highlights
- 工具逻辑完整,参数校验合理(remainSec 优先、四舍五入、边界处理)
- 覆盖主要异常场景,黄灯/红灯明确建议停车,安全提示到位
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Not specified in the source documentation.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.