json-logic-rules
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 "json-logic-rules" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-826e42d9e50cc86e028ba1d54b260182975049282e45f7b62fcaa13fe084ff7d. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/kfa20266358 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
Execute JSON Logic rules in the browser using json-logic-js to evaluate conditions like high-value customers or follow-up reminders; suitable for local automation rules and scenarios without backend condition evaluation.
Introduction source: third_party · user_f1b049da · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: json-logic-rules
slug: kfa20266358
displayName: 本地自动化规则
version: 1.0.0
summary: 用 json-logic-js 本地判定高价值客户与跟进提醒,不请求后端。
license: MIT
description: 用 json-logic-js 在浏览器内执行 JSON Logic 规则,判定高价值客户、跟进提醒等条件。当用户需要本地自动化规则、json-logic、前端规则引擎、无后端条件判定时使用。本地自动化规则(json-logic-js)
灵感:能力工具箱 json-logic(pkg: json-logic-js)。
把「金额 ≥ 阈值且阶段为意向」等业务条件写成 JSON Logic,在前端本地 apply,用于列表高亮、提醒开关、筛选,不发起网络请求。
何时使用
- 高价值客户本地打标 / 列表过滤
- 跟进提醒触发条件(逾期天数、阶段、金额组合)
- 需要可配置、可序列化、可热更新的规则,又不想上后端规则引擎
硬约束
- 依赖
json-logic-js(jsonLogic.apply(rule, data))。 - 规则与数据均为纯 JSON;禁止
eval/new Function。 - 结果应归一为布尔或明确枚举(如
pass/warn),并给出可读中文原因(可自建 reason 映射)。 - 规则变更应可版本化(存 localStorage / 配置文件),默认提供安全示例规则。
- 不请求后端;敏感阈值由调用方注入 data,不写死密钥。
推荐实现要点
import jsonLogic from 'json-logic-js'
/** 高价值:意向/谈判且金额 ≥ 阈值 */
export const highValueRule = {
and: [
{ in: [{ var: 'stage' }, ['intend', 'negotiate']] },
{ '>=': [{ var: 'amount' }, { var: 'threshold' }] },
],
} as const
/** 跟进提醒:距上次跟进天数 ≥ N 或已逾期 */
export const followRemindRule = {
or: [
{ '>=': [{ var: 'daysSinceFollow' }, { var: 'remindAfterDays' }] },
{ '==': [{ var: 'overdue' }, true] },
],
} as const
export function evalRule(rule: object, data: Record<string, unknown>): boolean {
return Boolean(jsonLogic.apply(rule, data))
}
export function labelHighValue(customer: {
stage: string
amount: number
threshold?: number
}) {
const ok = evalRule(highValueRule, {
stage: customer.stage,
amount: customer.amount,
threshold: customer.threshold ?? 100000,
})
return {
highValue: ok,
reason: ok ? '阶段与金额满足高价值规则' : '未达高价值条件',
}
}
Agent 步骤
- 安装/引入
json-logic-js,接入示例规则与业务 data 字段对齐。 - 自测:金额够但阶段为 lead → false;intend + 金额够 → true。
- UI:用结果控制标签/角标,规则 JSON 可展示给运营只读预览。
附加
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供前端本地规则引擎能力,解决高价值客户判定、跟进提醒等实际业务场景
- 无需后端请求,适合可配置、可序列化、可热更新的规则需求
Highlights
- 触发词覆盖合理,明确列出本地自动化规则、JSON Logic、前端规则引擎等适用场景
Highlights
- 文档结构清晰,包含何时使用、硬约束、推荐实现要点、Agent 步骤
- 提供 TypeScript 代码示例,frontmatter 完整
Highlights
- 依赖 json-logic-js 明确,参数使用规范,无 eval 等危险操作
- 有自测用例,敏感数据由调用方注入,安全性良好
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.
-
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 29
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
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.