rule-script-generator
Writes deterministic .mjs verification scripts with pass and fail fixtures for each deterministic or heuristic rule that has no enforcer, and registers a script only after it classifies its own fixtures correctly; a failing script goes to a Decision Pause. Use when the user asks to generate or regenerate rule scripts after analyze rules produced a reviewed map.
- License 许可
- MIT
- 所属仓库
- Eliyce/paqad-ai
- 最近更新
- 2026-11-13
- Stars
- ★ 8
- Forks
- 0
01 前言 Front Matter
- name
- rule-script-generator
- metadata
- { "cacheable": "false", "model_tier": "reasoning", "paqad-meta": "skill.meta.yaml", "output_format": "markdown" }
- description
- Writes deterministic .mjs verification scripts with pass and fail fixtures for each deterministic or heuristic rule that has no enforcer, and registers a script only after it classifies its own fixtures correctly; a failing script goes to a Decision Pause. Use when the user asks to generate or regenerate rule scripts after analyze rules produced a reviewed map.
02 资源文件 6
- 参考文档agents/openai.yaml369 B
- 参考文档references/script-authoring.md4.4 KB
- 脚本scripts/prune.mjs497 B
- 脚本scripts/register-script.mjs1.8 KB
- 脚本scripts/validate-script.mjs811 B
- 参考文档skill.meta.yaml366 B
03 SKILL.md 正文
What It Does
For every rule in rule-script-map.yml whose verifiability.kind ∈ {deterministic, heuristic} and whose enforced_by is empty, authors one or more Node ESM scripts under .paqad/scripts/rules/<mirror>/<rule-file>/NNN-name.mjs, each with __fixtures__/pass/ and __fixtures__/fail/. Each script:
- Carries the
@paqad-rule-scriptheader (validated against the header schema). - Reads
{ projectRoot, files }from stdin and writes the findings JSON contract to stdout. - Is validated against its own fixtures before registration. Pass fixtures must yield zero findings; fail fixtures at least one. A script that fails is rejected and surfaced, never registered.
No .sh scripts are ever produced. See references/script-authoring.md for the full contract.
Use This When
- A user prompt matches the priority-225 router rules
generate rule scriptsorregenerate scripts for rule RL-<id>. - After
analyze ruleshas produced a reviewedrule-script-map.yml.
Inputs
docs/instructions/rules/rule-script-map.yml(read for rules + classifications; written only via the bundledregister-script.mjs→src/rule-scripts/apply.ts).- The rule text for each target rule (to author the detection logic).
- Existing in-scope source files, used for the over-flagging dry-run guard.
Procedure
- Load the map. Select target rules:
kind ∈ {deterministic, heuristic}andenforced_by == []. Ifonly_rule_idis set, restrict to it. - For each target rule, author
NNN-name.mjswith the header + stdin/stdout contract (references/script-authoring.md), plus 2–4 synthetic 5–15 line fixtures under__fixtures__/pass/and__fixtures__/fail/. Fixtures are synthetic: never copied from the user's real code. When the script loopsfor (const file of files)and each file's findings depend only on that file's own content (no other file read, no state shared across files), add// per_file: trueto the header so the pre-edit check can reuse its earlier results for files that did not change; leave it out otherwise. - Validate the script against its fixtures:
Exit 0 = accepted. Exit 1 = rejected: surface a Decision Pause packet ("scriptnode scripts/validate-script.mjs <abs-script-path>NNN-name.mjsfailed its own fixtures, regenerate / edit / mark unverifiable?") and do not register. - Over-flag dry-run: run the accepted script across in-scope existing files. If the flag rate exceeds the per-kind threshold (
deterministic: 0.05,heuristic: 0.20), surface a Decision Pause packet before registering. - Register the validated script onto its rule:
node scripts/register-script.mjs <project-root> <script-path-rel> <rule-id> <kind> <scope> - At the end of the cycle, prune orphaned scripts (left by edited / downgraded / removed rules):
Deletes anynode scripts/prune.mjs <project-root>.mjs+__fixtures__/under.paqad/scripts/rules/not referenced by an active map rule. Archived rules' scripts survive one cycle, then this prunes them. - Present the
## Generation Summary: scripts accepted, scripts rejected (with reasons), over-flag warnings, pruned files. Tell the user the next prompt (feature-developmentwill now enforce them).
Output Contract
- Accepted scripts written under
.paqad/scripts/rules/...with their__fixtures__/. rule-script-map.ymlupdated viasrc/rule-scripts/apply.tswith each accepted script entry (path,kind,runtime,scope,last_validated_at,fixtures_passed: true).- A
## Generation Summarymarkdown block listing accepted / rejected / over-flag, each rejection naming the exact regen prompt.
Escalate / Stop Conditions
- Never register a script that fails its fixtures or whose header is invalid: surface a Decision Pause packet instead.
- Never author a
.shscript; Node.mjsonly. - Never copy fixtures from the user's real code: fixtures are synthetic.
- Skip rules with non-empty
enforced_by(already covered) andunverifiablerules. - All map writes go through
register-script.mjs→src/rule-scripts/apply.ts.
Resources
references/script-authoring.md: header + findings + fixtures contract.runtime/base/skills/rule-script-generator/agents/openai.yaml: agent interface metadata.src/rule-scripts/fixture-runner.ts: the fixture gate.src/rule-scripts/guard.ts: the over-flagging guard.src/rule-scripts/prune.ts: orphan-script pruning (end-of-cycle).- the Decision Pause Contract (in the framework bootstrap): packet semantics for rejected scripts.
04 同仓库更多 Skills
sample-skill
Sample bundled skill fixture
processing-invoices
Turns a supplier invoice into one ledger line. Use when a supplier invoice arrives and needs booking.
processing-invoices
Turns a supplier invoice into one ledger line. Use when a supplier invoice arrives and needs booking.
understand-idea
Chat and Claude Code: Step 1 of the discover journey: clarifies the goal, who benefits, success and constraints into the idea block. Use when the journey directs it to step 1, not directly.
size-work
Chat and Claude Code: Suggest a size for a ticket from comparable finished work, as a labelled suggestion the team still owns. Use it when someone asks "how big is this?", "roughly how much work is ABC-12?", or wants a backlog item sized. It finds the team's sizing scale at first use, picks two to five of the closest finished tickets with links, and gives a size or range with the drivers behind it and a confidence of low, medium or high, lowered and explained when the area's documents are template text. Every result is labelled a suggested size, never a date or a commitment. It writes nothing into the size field unless the user says "set it", and it refuses to overwrite an existing size unless the user asks to replace it. Produces the sizing block of the record.
refine-ticket
Chat and Claude Code: Improve one or more existing tracker tickets without losing the author's intent. Use it when someone wants a ticket read, diagnosed and tidied up ("this ticket is vague", "fix up ABC-12", "split this, it's too big"). It reads each ticket in full and snapshots it with its last-updated time, says what is wrong with evidence, and proposes a field-by-field before and after change set limited to summary, description, labels, parent, links and new child tickets on a split. It writes nothing until an explicit "apply it" bound to that exact change set, re-checks the ticket for conflicting edits just before writing, never replaces rich descriptions with plain text, never deletes or closes a ticket, and reads each ticket back after applying. Produces the existing and changes blocks of the record.