Skip to content

feat(registry): 内容包必须声明适用规则,否则同步时给出 warning - #28

Merged
EOEOY merged 1 commit into
mainfrom
fix/content-pack-ruleset-declaration
Nov 7, 2026
Merged

EOEOY merged 1 commit into
mainfrom
fix/content-pack-ruleset-declaration

Conversation

@EOEOY

@EOEOY EOEOY commented Nov 7, 2026

Copy link
Copy Markdown
Member

背景

客户端「在线内容包」按规则筛选时什么都筛不出来,但「全部规则」能看到全部 10 个包。

原因:应用侧靠 manifest 的 requires.rulesets[].id 生成 ruleset_targets,而线上 14 条索引里 10 个 content-pack 的 requires 全是 null,ruleset_targets 因此是空数组。

应用侧已经改成「未声明 ≠ 不匹配」(diceframe#693)。这个 PR 补索引侧:让新提交的包别再漏声明。

改动

① scripts/registry.cjs

新增 warnUndeclaredRuleset(),在生成 plugin_details.json 时检查:

  • plugin_type === "content-pack"
  • 且没有 system_agnostic: true
  • 且 requires.rulesets 缺失或为空

→ 产出 warning:

demo-pack: content-pack 未声明适用规则(requires.rulesets 或 system_agnostic: true),
在线内容包的规则筛选只能把它归入「规则未标注」

先只发 warning,不 error:存量 10 个包需要作者逐个补,现在就 error 会让同步全线失败。

② templates/content-pack/plugin.json

模板里补上 requires.rulesets 示例。

③ templates/content-pack/README.md

新增「声明适用规则(二选一,必须写)」一节:

  • 依赖某套规则 → "requires": { "rulesets": [{ "id": "core:dnd2024" }] }
  • 与规则无关的通用包 → "system_agnostic": true,删掉 requires
  • 都不写 → 索引 warning,客户端归入「规则未标注」

验证

  • node --test tests/registry.test.cjs → 15 passed(新增 2 条:缺声明给 warning、显式声明/通用包/非内容包不误报)
  • node scripts/validate.cjs → Registry structure is valid.

后续

  1. 10 个存量包补 requires.rulesets(coc-* → core:coc7,dnd-* → core:dnd2024,frieren-journey / hyouka / office-night 需作者确认是否 system_agnostic)
  2. 补完后把 warning 升级为 error
  3. diceframe-content 的插件注册规范文档同步这一节

线上 10 个 content-pack 的 requires 全是 null,客户端按规则筛选因此全是空的。
应用侧已改成「未声明 != 不匹配」,这里补索引侧,别再让新包漏声明。

- registry.cjs 新增 warnUndeclaredRuleset(),generateDetails 时检查 content-pack
  是否声明 requires.rulesets 或 system_agnostic: true,缺失则 warning(暂不 error)
- 模板 plugin.json 补 requires.rulesets 示例,README 增「声明适用规则」一节
- 新增 2 条测试:缺声明给 warning;显式声明/通用包/非内容包不误报

验证:node --test 15 passed;node scripts/validate.cjs 通过。
@EOEOY
EOEOY merged commit 2ea442a into main Nov 7, 2026
1 check passed
@EOEOY
EOEOY deleted the fix/content-pack-ruleset-declaration branch November 7, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant