@bompus/house-rules 0.0.0-stage → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CODE_OF_CONDUCT.md +83 -0
- package/CONTRIBUTING.md +54 -0
- package/LICENSE +21 -0
- package/README.md +378 -2
- package/THIRD_PARTY_NOTICES.md +188 -0
- package/compose.mjs +125 -0
- package/composition.mjs +361 -0
- package/config-view.mjs +209 -0
- package/config.mjs +381 -0
- package/docs/assets/banner-dark.png +0 -0
- package/docs/assets/banner-light.png +0 -0
- package/docs/assets/overview.png +0 -0
- package/docs/configuration.md +269 -0
- package/docs/skill-names.md +50 -0
- package/examples/person/house-rules.json +15 -0
- package/examples/person/rules/10-tooling.md +8 -0
- package/examples/person/rules/20-reporting.md +9 -0
- package/examples/project/AGENTS.md +18 -0
- package/package.json +42 -4
- package/rule-references.mjs +91 -0
- package/rules/core.md +340 -0
- package/rules/modifiers/backlog-outline.md +25 -0
- package/rules/modifiers/backlog-visual.md +16 -0
- package/rules/modifiers/coded-offers.md +70 -0
- package/rules/modifiers/cross-session-relay.md +23 -0
- package/rules/modifiers/effort-estimates.md +41 -0
- package/rules/modifiers/land-when-done.md +12 -0
- package/rules/modifiers/low-quota-handoff.md +20 -0
- package/rules/modifiers/model-default-questions.md +33 -0
- package/rules/modifiers/multi-agent.md +38 -0
- package/rules/modifiers/no-attribution.md +16 -0
- package/rules/modifiers/periodic-updates.md +25 -0
- package/rules/modifiers/plan-files.md +82 -0
- package/rules/modifiers/question-cards.md +48 -0
- package/rules/modifiers/release-batching.md +15 -0
- package/rules/modifiers/scratch-on-disk.md +15 -0
- package/rules/modifiers/shared-host-load.md +19 -0
- package/rules/modifiers/solo-operator.md +13 -0
- package/rules/modifiers/squash-landing.md +22 -0
- package/rules/modifiers/upstream-contributions.md +45 -0
- package/rules/modifiers/web-image-formats.md +35 -0
- package/rules/references/backlog-view.md +154 -0
- package/rules/references/github-actions.md +45 -0
- package/rules/references/landing.md +39 -0
- package/rules/references/multi-agent.md +51 -0
- package/rules/references/release-batching.md +66 -0
- package/rules/references/squash-landing.md +50 -0
- package/rules/references/thread-visuals.md +45 -0
- package/setup.mjs +445 -0
- package/skills/hr-agent-guidance-audit/LICENSE +21 -0
- package/skills/hr-agent-guidance-audit/SKILL.md +91 -0
- package/skills/hr-agent-guidance-audit/agents/openai.yaml +2 -0
- package/skills/hr-agent-guidance-audit/references/prune-workflow.md +72 -0
- package/skills/hr-agent-guidance-audit/references/records-and-lessons.md +60 -0
- package/skills/hr-agent-guidance-audit/references/retirement-verdicts.md +49 -0
- package/skills/hr-agent-guidance-refresh/LICENSE +21 -0
- package/skills/hr-agent-guidance-refresh/SKILL.md +36 -0
- package/skills/hr-agent-guidance-refresh/agents/openai.yaml +2 -0
- package/skills/hr-agent-guidance-refresh/references/verification.md +47 -0
- package/skills/hr-api-exposure-check/SKILL.md +159 -0
- package/skills/hr-api-exposure-check/agents/openai.yaml +3 -0
- package/skills/hr-audit-choices/SKILL.md +67 -0
- package/skills/hr-audit-choices/agents/openai.yaml +2 -0
- package/skills/hr-benchmarking/NOTICE.md +36 -0
- package/skills/hr-benchmarking/SKILL.md +279 -0
- package/skills/hr-benchmarking/agents/openai.yaml +2 -0
- package/skills/hr-benchmarking/references/javascript.md +130 -0
- package/skills/hr-benchmarking/references/tools.md +165 -0
- package/skills/hr-benchmarking/scripts/process-attribution.ps1 +20 -0
- package/skills/hr-benchmarking/scripts/process-attribution.py +107 -0
- package/skills/hr-better-accessibility/LICENSE +22 -0
- package/skills/hr-better-accessibility/NOTICE.md +46 -0
- package/skills/hr-better-accessibility/SKILL.md +119 -0
- package/skills/hr-better-accessibility/agents/openai.yaml +3 -0
- package/skills/hr-better-accessibility/focus-and-keyboard.md +130 -0
- package/skills/hr-better-accessibility/forms.md +82 -0
- package/skills/hr-better-accessibility/hit-areas.md +98 -0
- package/skills/hr-better-accessibility/motion-and-zoom.md +81 -0
- package/skills/hr-better-accessibility/screen-readers.md +102 -0
- package/skills/hr-better-accessibility/semantics-and-aria.md +84 -0
- package/skills/hr-better-colors/LICENSE +21 -0
- package/skills/hr-better-colors/NOTICE.md +37 -0
- package/skills/hr-better-colors/SKILL.md +114 -0
- package/skills/hr-better-colors/agents/openai.yaml +3 -0
- package/skills/hr-better-colors/color-formats.md +90 -0
- package/skills/hr-better-colors/color-usage.md +140 -0
- package/skills/hr-better-colors/contrast.md +80 -0
- package/skills/hr-better-colors/palette-generation.md +104 -0
- package/skills/hr-better-colors/palette-structure.md +76 -0
- package/skills/hr-better-colors/token-naming.md +97 -0
- package/skills/hr-better-layout/LICENSE +22 -0
- package/skills/hr-better-layout/NOTICE.md +48 -0
- package/skills/hr-better-layout/SKILL.md +92 -0
- package/skills/hr-better-layout/agents/openai.yaml +3 -0
- package/skills/hr-better-layout/grouping-and-alignment.md +144 -0
- package/skills/hr-better-layout/spacing-and-adaptivity.md +215 -0
- package/skills/hr-better-typography/LICENSE +22 -0
- package/skills/hr-better-typography/NOTICE.md +46 -0
- package/skills/hr-better-typography/SKILL.md +172 -0
- package/skills/hr-better-typography/agents/openai.yaml +3 -0
- package/skills/hr-better-typography/choosing-fonts.md +69 -0
- package/skills/hr-better-typography/css-cheat-sheet.md +65 -0
- package/skills/hr-better-typography/details-and-accessibility.md +119 -0
- package/skills/hr-better-typography/spacing-and-sizing.md +131 -0
- package/skills/hr-better-typography/variable-fonts-and-opentype.md +105 -0
- package/skills/hr-better-typography/wrapping-and-punctuation.md +57 -0
- package/skills/hr-better-writing/LICENSE +22 -0
- package/skills/hr-better-writing/NOTICE.md +46 -0
- package/skills/hr-better-writing/SKILL.md +122 -0
- package/skills/hr-better-writing/agents/openai.yaml +3 -0
- package/skills/hr-code-review/LICENSE +21 -0
- package/skills/hr-code-review/NOTICE.md +26 -0
- package/skills/hr-code-review/SKILL.md +163 -0
- package/skills/hr-code-review/agents/openai.yaml +3 -0
- package/skills/hr-code-review/references/acp-client.md +43 -0
- package/skills/hr-code-review/references/evidence.md +57 -0
- package/skills/hr-code-review/references/impact.md +103 -0
- package/skills/hr-code-review/references/panel-adjudication.md +58 -0
- package/skills/hr-code-review/references/panel-plan.md +61 -0
- package/skills/hr-code-review/references/panel-recommendations.json +105 -0
- package/skills/hr-code-review/references/panel-recommendations.md +46 -0
- package/skills/hr-code-review/references/panel-setup.md +54 -0
- package/skills/hr-code-review/references/reviewer-role.md +31 -0
- package/skills/hr-code-review/scripts/acp-panel-client.mjs +299 -0
- package/skills/hr-code-review/scripts/check-receipts.mjs +263 -0
- package/skills/hr-code-review/scripts/panel-plan.mjs +69 -0
- package/skills/hr-code-review/scripts/panel-preferences.mjs +220 -0
- package/skills/hr-design-exploration/SKILL.md +105 -0
- package/skills/hr-design-exploration/agents/openai.yaml +4 -0
- package/skills/hr-diagnosing-bugs/NOTICE.md +45 -0
- package/skills/hr-diagnosing-bugs/SKILL.md +108 -0
- package/skills/hr-diagnosing-bugs/agents/openai.yaml +3 -0
- package/skills/hr-diagnosing-bugs/references/reporting.md +97 -0
- package/skills/hr-diagnosing-bugs/scripts/check-pr-offer.mjs +47 -0
- package/skills/hr-explain-code/NOTICE.md +37 -0
- package/skills/hr-explain-code/SKILL.md +110 -0
- package/skills/hr-explain-code/agents/openai.yaml +5 -0
- package/skills/hr-explain-code/references/helper-brief.md +39 -0
- package/skills/hr-extract-shared-steps/SKILL.md +134 -0
- package/skills/hr-extract-shared-steps/agents/openai.yaml +3 -0
- package/skills/hr-forgotten-work-audit/SKILL.md +130 -0
- package/skills/hr-forgotten-work-audit/references/brief-template.md +56 -0
- package/skills/hr-forgotten-work-audit/references/result-format.md +46 -0
- package/skills/hr-handoff/LICENSE +21 -0
- package/skills/hr-handoff/NOTICE.md +29 -0
- package/skills/hr-handoff/SKILL.md +114 -0
- package/skills/hr-handoff/agents/openai.yaml +5 -0
- package/skills/hr-handoff/assets/ledger.example.json +10 -0
- package/skills/hr-handoff/assets/receipt.example.json +76 -0
- package/skills/hr-handoff/assets/source.example.json +20 -0
- package/skills/hr-handoff/references/reconciliation.md +124 -0
- package/skills/hr-handoff/references/successor-thread.md +76 -0
- package/skills/hr-handoff/scripts/check-reconciliation.mjs +324 -0
- package/skills/hr-house-rules-setup/SKILL.md +114 -0
- package/skills/hr-house-rules-setup/agents/openai.yaml +5 -0
- package/skills/hr-issue-tracker-setup/SKILL.md +49 -0
- package/skills/hr-issue-tracker-setup/agents/openai.yaml +5 -0
- package/skills/hr-lean-plan/SKILL.md +146 -0
- package/skills/hr-lean-plan/agents/openai.yaml +5 -0
- package/skills/hr-maintainability-review/SKILL.md +186 -0
- package/skills/hr-maintainability-review/agents/openai.yaml +5 -0
- package/skills/hr-manual-qa/NOTICE.md +36 -0
- package/skills/hr-manual-qa/SKILL.md +37 -0
- package/skills/hr-manual-qa/agents/openai.yaml +3 -0
- package/skills/hr-navigation-retro/LICENSE +21 -0
- package/skills/hr-navigation-retro/NOTICE.md +5 -0
- package/skills/hr-navigation-retro/SKILL.md +86 -0
- package/skills/hr-navigation-retro/agents/openai.yaml +4 -0
- package/skills/hr-navigation-retro/references/inputs.md +67 -0
- package/skills/hr-navigation-retro/scripts/retro.py +552 -0
- package/skills/hr-navigation-retro/scripts/transcripts.py +205 -0
- package/skills/hr-ordering-tests/SKILL.md +51 -0
- package/skills/hr-ordering-tests/agents/openai.yaml +2 -0
- package/skills/hr-plain-prose/SKILL.md +264 -0
- package/skills/hr-plain-prose/agents/openai.yaml +3 -0
- package/skills/hr-plain-prose/scripts/check.mjs +331 -0
- package/skills/hr-pr-followup/LICENSE +21 -0
- package/skills/hr-pr-followup/NOTICE.md +9 -0
- package/skills/hr-pr-followup/SKILL.md +74 -0
- package/skills/hr-pr-followup/agents/openai.yaml +2 -0
- package/skills/hr-pr-followup/references/review-helpers.md +111 -0
- package/skills/hr-pr-followup/scripts/check-landing.py +204 -0
- package/skills/hr-pr-followup/scripts/check-pr-review.ts +510 -0
- package/skills/hr-pr-followup/scripts/merge-pr.sh +100 -0
- package/skills/hr-pr-followup/scripts/resolve-pr-thread.ts +219 -0
- package/skills/hr-pr-followup/scripts/verify-landed.sh +184 -0
- package/skills/hr-progress-report/SKILL.md +49 -0
- package/skills/hr-progress-report/agents/openai.yaml +5 -0
- package/skills/hr-read-reddit/SKILL.md +44 -0
- package/skills/hr-read-reddit/agents/openai.yaml +2 -0
- package/skills/hr-read-reddit/scripts/reddit.ts +252 -0
- package/skills/hr-read-x-links/SKILL.md +42 -0
- package/skills/hr-read-x-links/agents/openai.yaml +2 -0
- package/skills/hr-read-x-links/scripts/x-post.ts +264 -0
- package/skills/hr-research-shared-links/SKILL.md +103 -0
- package/skills/hr-split-to-prs/LICENSE +21 -0
- package/skills/hr-split-to-prs/NOTICE.md +9 -0
- package/skills/hr-split-to-prs/SKILL.md +61 -0
- package/skills/hr-split-to-prs/agents/openai.yaml +2 -0
- package/skills/hr-sqlite/SKILL.md +174 -0
- package/skills/hr-sqlite/agents/openai.yaml +2 -0
- package/skills/hr-sqlite/references/evidence.md +94 -0
- package/skills/hr-sqlite/references/tool-decisions.md +39 -0
- package/skills/hr-sqlite/scripts/inspect-sqlite.py +245 -0
- package/skills/hr-stock-ui-audit/SKILL.md +132 -0
- package/skills/hr-stock-ui-audit/agents/openai.yaml +3 -0
- package/skills/hr-stock-ui-audit/scripts/scan.mjs +619 -0
- package/skills/hr-tdd/LICENSE +21 -0
- package/skills/hr-tdd/NOTICE.md +10 -0
- package/skills/hr-tdd/SKILL.md +40 -0
- package/skills/hr-tdd/agents/openai.yaml +3 -0
- package/skills/hr-tdd/mocking.md +39 -0
- package/skills/hr-tdd/tests.md +77 -0
- package/skills/hr-test-audit/LICENSE +21 -0
- package/skills/hr-test-audit/NOTICE.md +67 -0
- package/skills/hr-test-audit/SKILL.md +146 -0
- package/skills/hr-test-audit/agents/openai.yaml +3 -0
- package/skills/hr-test-audit/scripts/floor-guard.ts +137 -0
- package/skills/hr-usage-report/SKILL.md +90 -0
- package/skills/hr-usage-report/agents/openai.yaml +2 -0
- package/skills/hr-usage-report/assets/example-report.json +125 -0
- package/skills/hr-usage-report/assets/report-template.html +377 -0
- package/skills/hr-usage-report/scripts/render-report.ts +86 -0
- package/skills/hr-usage-report/scripts/usage-by-model.ts +499 -0
- package/skills/hr-what-next/SKILL.md +151 -0
- package/skills/hr-what-next/agents/openai.yaml +4 -0
- package/skills/hr-what-next/references/reporting.md +59 -0
- package/skills/hr-what-next/scripts/check-open-work.mjs +711 -0
- package/skills/hr-writing-for-agents/NOTICE.md +46 -0
- package/skills/hr-writing-for-agents/SKILL-MECHANICS.md +83 -0
- package/skills/hr-writing-for-agents/SKILL.md +108 -0
- package/skills/hr-writing-for-agents/agents/openai.yaml +3 -0
- package/skills/hr-writing-pr/NOTICE.md +48 -0
- package/skills/hr-writing-pr/SKILL.md +119 -0
- package/skills/hr-writing-pr/agents/openai.yaml +2 -0
- package/skills/hr-writing-pr/scripts/benefit-chart.py +200 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
Some files in this repository copy or adapt work published under the MIT
|
|
4
|
+
License. Each source's copyright notice and the licence text follow.
|
|
5
|
+
`CODE_OF_CONDUCT.md` is the Contributor Covenant, under CC BY 4.0, noted at
|
|
6
|
+
the end.
|
|
7
|
+
|
|
8
|
+
## Cursor workflow ideas
|
|
9
|
+
|
|
10
|
+
Source: https://cursor.com/docs/skills
|
|
11
|
+
|
|
12
|
+
- `skills/hr-split-to-prs/`: independently written workflow informed by the
|
|
13
|
+
purpose of Cursor's built-in `split-to-prs` skill.
|
|
14
|
+
- `skills/hr-pr-followup/`: independently written workflow informed by the
|
|
15
|
+
purpose of Cursor's built-in `autopilot` skill.
|
|
16
|
+
|
|
17
|
+
These bundles distribute no Cursor instruction text. Their MIT licence applies
|
|
18
|
+
to newly written house-rules material, not to the Cursor skills.
|
|
19
|
+
|
|
20
|
+
## mattpocock/skills
|
|
21
|
+
|
|
22
|
+
Source: https://github.com/mattpocock/skills (compared at revision `d81f3a1`)
|
|
23
|
+
|
|
24
|
+
- `skills/hr-writing-for-agents/`: adapted from `skills/productivity/writing-for-agents/`.
|
|
25
|
+
- `skills/hr-code-review/`: adapted from `skills/engineering/code-review/`.
|
|
26
|
+
- `skills/hr-handoff/`: adapted from `skills/productivity/handoff/`.
|
|
27
|
+
- `skills/hr-diagnosing-bugs/`: written for this repository after
|
|
28
|
+
`skills/engineering/diagnosing-bugs/`, which it shares a purpose with.
|
|
29
|
+
|
|
30
|
+
- `skills/hr-tdd/`: adapted from `skills/engineering/tdd/` at revision
|
|
31
|
+
`f3fc5632f401156837ee3872f14fe33ccf1024ea`. The bundle carries its MIT notice.
|
|
32
|
+
|
|
33
|
+
Copyright (c) 2026 Matt Pocock
|
|
34
|
+
|
|
35
|
+
## obra/superpowers
|
|
36
|
+
|
|
37
|
+
Source: https://github.com/obra/superpowers (compared at revision `8ca22db`)
|
|
38
|
+
|
|
39
|
+
- `skills/hr-writing-for-agents/SKILL.md`: the instruction-form table is adapted
|
|
40
|
+
from `writing-skills`. Its wording tests found that a recipe beat a prohibition
|
|
41
|
+
for shape failures.
|
|
42
|
+
- `skills/hr-test-audit/SKILL.md`: cites `writing-good-tests.md`.
|
|
43
|
+
|
|
44
|
+
Copyright (c) 2025 Jesse Vincent
|
|
45
|
+
|
|
46
|
+
## addyosmani/agent-skills
|
|
47
|
+
|
|
48
|
+
Source: https://github.com/addyosmani/agent-skills (compared at revision `9d0c60d`)
|
|
49
|
+
|
|
50
|
+
- `skills/hr-test-audit/scripts/floor-guard.ts`: adapted from
|
|
51
|
+
constraint-driven-development.
|
|
52
|
+
|
|
53
|
+
Copyright (c) 2025 Addy Osmani
|
|
54
|
+
|
|
55
|
+
## openclaw/openclaw
|
|
56
|
+
|
|
57
|
+
Source: https://github.com/openclaw/openclaw (linked at revision `65f1e4d`, compared at `1fda703`)
|
|
58
|
+
|
|
59
|
+
- `skills/hr-test-audit/SKILL.md`: the authoring gate, junk patterns, retention
|
|
60
|
+
bar and evidence fields are adapted from `.agents/skills/test-audit/`.
|
|
61
|
+
|
|
62
|
+
Copyright (c) 2026 OpenClaw Foundation
|
|
63
|
+
|
|
64
|
+
## no-human-ai/no_human
|
|
65
|
+
|
|
66
|
+
Source: https://github.com/no-human-ai/no_human (compared at revision `9b50bf6`)
|
|
67
|
+
|
|
68
|
+
- `skills/hr-test-audit/SKILL.md`: the rule that weakening a test counts as
|
|
69
|
+
removing it is adapted from its tamper guard.
|
|
70
|
+
- `skills/hr-code-review/references/evidence.md`: test-weakening assessment and
|
|
71
|
+
refuting completion claims are informed by its verification approach.
|
|
72
|
+
|
|
73
|
+
Copyright (c) 2026 Eyal Golan
|
|
74
|
+
|
|
75
|
+
## omkamal/pypict-claude-skill
|
|
76
|
+
|
|
77
|
+
Source: https://github.com/omkamal/pypict-claude-skill (compared at revision `fbda212`)
|
|
78
|
+
|
|
79
|
+
- `skills/hr-test-audit/SKILL.md`: the pairwise-coverage guidance is adapted from
|
|
80
|
+
this skill.
|
|
81
|
+
|
|
82
|
+
Copyright (c) 2025 pypict-claude-skill contributors
|
|
83
|
+
|
|
84
|
+
## sickn33/antigravity-awesome-skills
|
|
85
|
+
|
|
86
|
+
Source: https://github.com/sickn33/antigravity-awesome-skills (compared at revision `7bb0ab4`)
|
|
87
|
+
|
|
88
|
+
- `skills/hr-writing-pr/SKILL.md`: selected ideas from
|
|
89
|
+
`skills/git-pr-workflows-pr-enhance/`. Selected ideas also come from
|
|
90
|
+
[Luke Parker's writing-pr post](https://x.com/LukeParkerDev/status/2096769160021979571).
|
|
91
|
+
|
|
92
|
+
Copyright (c) 2026 Antigravity User
|
|
93
|
+
|
|
94
|
+
## cursor/plugins (pstack)
|
|
95
|
+
|
|
96
|
+
Source: https://github.com/cursor/plugins (compared at revision `e43c7ee`)
|
|
97
|
+
|
|
98
|
+
- `rules/core.md`: the § Implementation economy bullet on scripting changes
|
|
99
|
+
that span more than three places is adapted from
|
|
100
|
+
`pstack/skills/principle-build-the-lever/`.
|
|
101
|
+
- `skills/hr-diagnosing-bugs/SKILL.md`: § Question the premise is adapted from
|
|
102
|
+
`pstack/skills/principle-attack-the-premise/`.
|
|
103
|
+
- `skills/hr-benchmarking/SKILL.md`: the validity checks are adapted from
|
|
104
|
+
`pstack/skills/benchmark-checklist/`.
|
|
105
|
+
|
|
106
|
+
Copyright (c) 2026 Lauren Tan
|
|
107
|
+
|
|
108
|
+
## jakubkrehel/skills
|
|
109
|
+
|
|
110
|
+
Source: https://github.com/jakubkrehel/skills (compared at revision `267330e1adfc66a718fb65fa6918c1f06d0a689e`)
|
|
111
|
+
|
|
112
|
+
- `skills/hr-better-accessibility/`, `skills/hr-better-colors/`, `skills/hr-better-layout/`,
|
|
113
|
+
`skills/hr-better-typography/` and `skills/hr-better-writing/`: adapted skill bundles,
|
|
114
|
+
including their supporting references and discovery metadata.
|
|
115
|
+
|
|
116
|
+
Copyright (c) 2026 Jakub Krehel
|
|
117
|
+
|
|
118
|
+
## emilkowalski/skills
|
|
119
|
+
|
|
120
|
+
Source: https://github.com/emilkowalski/skills (compared at revision `e8a175de22ae1e49370fc144c1f3bb9aeedf988d`)
|
|
121
|
+
|
|
122
|
+
- `skills/hr-better-accessibility/` and `skills/hr-better-layout/`: mobile behavior and
|
|
123
|
+
viewport guidance adapted from `skills/mobile-native/SKILL.md`.
|
|
124
|
+
- `skills/hr-better-layout/`, `skills/hr-better-typography/` and `skills/hr-better-writing/`:
|
|
125
|
+
clipping, truncation and plural-form guidance adapted from `skills/break-ui/SKILL.md`.
|
|
126
|
+
|
|
127
|
+
Copyright (c) 2026 Emil Kowalski
|
|
128
|
+
|
|
129
|
+
## humanlayer/skills
|
|
130
|
+
|
|
131
|
+
Source: https://github.com/humanlayer/skills (compared at revision `bba9d13ab34f0a87f1cc33df4dd196372393ddfc`)
|
|
132
|
+
|
|
133
|
+
- `skills/hr-explain-code/SKILL.md` and `skills/hr-writing-pr/SKILL.md`: compact
|
|
134
|
+
visual explanation and focused structural-diff guidance adapted from
|
|
135
|
+
`plugins/show-me/skills/show-me/SKILL.md`.
|
|
136
|
+
|
|
137
|
+
Copyright (c) 2026 HumanLayer
|
|
138
|
+
|
|
139
|
+
## Jeanno/jeanno-skills (ideas)
|
|
140
|
+
|
|
141
|
+
Source: https://github.com/Jeanno/jeanno-skills (compared at revision `db4e8fd66197ece38d622ca8b527dbe821843df2`)
|
|
142
|
+
|
|
143
|
+
- `skills/hr-manual-qa/SKILL.md`: independently written instructions informed by
|
|
144
|
+
the reproducible-checklist idea in `skills/qa-checklist/SKILL.md`.
|
|
145
|
+
- `rules/core.md`: independently written correction handling informed by the
|
|
146
|
+
dependent-work sweep in `skills/realign/SKILL.md`.
|
|
147
|
+
|
|
148
|
+
No source text from this repository is copied here.
|
|
149
|
+
|
|
150
|
+
## ayghri/i-have-adhd (ideas)
|
|
151
|
+
|
|
152
|
+
Source: https://github.com/ayghri/i-have-adhd (compared at revision `723af7d9afaf43eb871dbcce6129e2bf80de90d5`)
|
|
153
|
+
|
|
154
|
+
- `rules/core.md`: independently written guidance informed by the small visible
|
|
155
|
+
list idea in `skills/i-have-adhd/SKILL.md`.
|
|
156
|
+
- `skills/hr-plain-prose/SKILL.md`: independently written reply check informed
|
|
157
|
+
by the first-and-last-line check in that skill.
|
|
158
|
+
|
|
159
|
+
No source text from this repository is copied here.
|
|
160
|
+
|
|
161
|
+
## MIT License text
|
|
162
|
+
|
|
163
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
164
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
165
|
+
in the Software without restriction, including without limitation the rights
|
|
166
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
167
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
168
|
+
furnished to do so, subject to the following conditions:
|
|
169
|
+
|
|
170
|
+
The above copyright notice and this permission notice shall be included in all
|
|
171
|
+
copies or substantial portions of the Software.
|
|
172
|
+
|
|
173
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
174
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
175
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
176
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
177
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
178
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
179
|
+
SOFTWARE.
|
|
180
|
+
|
|
181
|
+
## Contributor Covenant
|
|
182
|
+
|
|
183
|
+
Source: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
184
|
+
|
|
185
|
+
- `CODE_OF_CONDUCT.md`: version 2.1, with this repository's reporting method
|
|
186
|
+
filled in. Licensed under
|
|
187
|
+
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); its own
|
|
188
|
+
Attribution section credits the source.
|
package/compose.mjs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Composes rules and skills into explicit output paths; config commands manage selections.
|
|
3
|
+
// node compose.mjs --config <path> [--out <file>] [--skills-out <dir>]
|
|
4
|
+
// node compose.mjs config help
|
|
5
|
+
import {
|
|
6
|
+
cpSync,
|
|
7
|
+
existsSync,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
readdirSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
realpathSync,
|
|
12
|
+
writeFileSync,
|
|
13
|
+
} from "node:fs";
|
|
14
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { parseArgs } from "node:util";
|
|
17
|
+
import { composeConfiguration, configurationPath, modifierList } from "./composition.mjs";
|
|
18
|
+
import { configCommand } from "./config.mjs";
|
|
19
|
+
import { setupCommand } from "./setup.mjs";
|
|
20
|
+
import { checkOutputPath, planReferenceOutput, writeReferenceOutput } from "./rule-references.mjs";
|
|
21
|
+
export {
|
|
22
|
+
compose,
|
|
23
|
+
composeConfiguration,
|
|
24
|
+
configurationPath,
|
|
25
|
+
loadFragments,
|
|
26
|
+
modifierList,
|
|
27
|
+
parseFragment,
|
|
28
|
+
skillSources,
|
|
29
|
+
splitSections,
|
|
30
|
+
} from "./composition.mjs";
|
|
31
|
+
const BASE = dirname(fileURLToPath(import.meta.url));
|
|
32
|
+
const NOTICES = ["LICENSE", "THIRD_PARTY_NOTICES.md"];
|
|
33
|
+
|
|
34
|
+
function main(argv) {
|
|
35
|
+
if (argv[0] === "setup") return setupCommand(argv.slice(1));
|
|
36
|
+
if (argv[0] === "config") {
|
|
37
|
+
return configCommand(argv.slice(1));
|
|
38
|
+
}
|
|
39
|
+
const { values } = parseArgs({
|
|
40
|
+
args: argv,
|
|
41
|
+
options: {
|
|
42
|
+
config: { type: "string" },
|
|
43
|
+
out: { type: "string" },
|
|
44
|
+
"skills-out": { type: "string" },
|
|
45
|
+
"references-out": { type: "string" },
|
|
46
|
+
list: { type: "boolean" },
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (values.list) {
|
|
50
|
+
for (const m of modifierList()) console.log(`${m.name}: ${m.description ?? ""}`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const configPath = configurationPath(values.config);
|
|
54
|
+
let config;
|
|
55
|
+
try {
|
|
56
|
+
config = JSON.parse(readFileSync(configPath, "utf8").replace(/^\uFEFF/, ""));
|
|
57
|
+
} catch (error) {
|
|
58
|
+
if (!(error instanceof SyntaxError)) throw error;
|
|
59
|
+
throw new Error(`${configPath} is not valid JSON (${error.message}); fix it or move it aside`);
|
|
60
|
+
}
|
|
61
|
+
const { out, "skills-out": skillsOut, "references-out": explicitReferences } = values;
|
|
62
|
+
if (explicitReferences && !out) throw new Error("--references-out requires --out");
|
|
63
|
+
const referencesOut = out
|
|
64
|
+
? resolve(explicitReferences ?? join(dirname(resolve(out)), "house-rules-references"))
|
|
65
|
+
: null;
|
|
66
|
+
const { fragments, rules, skills, warnings, references } = composeConfiguration(
|
|
67
|
+
config,
|
|
68
|
+
dirname(configPath),
|
|
69
|
+
referencesOut
|
|
70
|
+
? { referencesDirectory: relative(dirname(resolve(out)), referencesOut) || "." }
|
|
71
|
+
: {},
|
|
72
|
+
);
|
|
73
|
+
for (const warning of warnings) console.error(`warning: ${warning}`);
|
|
74
|
+
const paths = [
|
|
75
|
+
out && { path: resolve(out), directory: false },
|
|
76
|
+
skillsOut && { path: resolve(skillsOut), directory: true },
|
|
77
|
+
referencesOut && { path: referencesOut, directory: true },
|
|
78
|
+
].filter(Boolean);
|
|
79
|
+
for (const { path, directory } of paths) checkOutputPath(path, directory);
|
|
80
|
+
for (const a of paths)
|
|
81
|
+
for (const b of paths) {
|
|
82
|
+
if (a === b) continue;
|
|
83
|
+
const rel = relative(a.path, b.path);
|
|
84
|
+
if (
|
|
85
|
+
!rel ||
|
|
86
|
+
(rel !== ".." &&
|
|
87
|
+
!rel.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) &&
|
|
88
|
+
!isAbsolute(rel))
|
|
89
|
+
)
|
|
90
|
+
throw new Error("Output paths must not overlap");
|
|
91
|
+
}
|
|
92
|
+
// Composition errors and a non-empty --skills-out stop the run before anything is written.
|
|
93
|
+
if (skillsOut && existsSync(skillsOut) && readdirSync(skillsOut).length)
|
|
94
|
+
throw new Error(`--skills-out ${skillsOut} must be empty or absent`);
|
|
95
|
+
const referenceWrites = references.size ? planReferenceOutput(referencesOut, references) : [];
|
|
96
|
+
writeReferenceOutput(referenceWrites);
|
|
97
|
+
if (out) {
|
|
98
|
+
mkdirSync(dirname(resolve(out)), { recursive: true });
|
|
99
|
+
writeFileSync(out, rules);
|
|
100
|
+
} else process.stdout.write(rules);
|
|
101
|
+
if (skillsOut) {
|
|
102
|
+
// Skill tests stay in the source checkout; hosts get only what the skill uses.
|
|
103
|
+
for (const [name, from] of skills)
|
|
104
|
+
cpSync(from, join(skillsOut, name), {
|
|
105
|
+
recursive: true,
|
|
106
|
+
filter: (src) => src !== join(from, "test"),
|
|
107
|
+
});
|
|
108
|
+
for (const f of NOTICES) cpSync(join(BASE, f), join(skillsOut, f));
|
|
109
|
+
}
|
|
110
|
+
console.error(
|
|
111
|
+
`composed ${rules.split("\n").length} lines of rules from ${fragments.length} optional or personal rule file(s)${skillsOut ? ` and ${skills.size} skill(s)` : ""}`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (
|
|
116
|
+
process.argv[1] &&
|
|
117
|
+
realpathSync(resolve(process.argv[1])) === realpathSync(fileURLToPath(import.meta.url))
|
|
118
|
+
) {
|
|
119
|
+
try {
|
|
120
|
+
await main(process.argv.slice(2));
|
|
121
|
+
} catch (e) {
|
|
122
|
+
console.error(`house-rules: ${e.message}`);
|
|
123
|
+
process.exit(e.exitCode ?? 1);
|
|
124
|
+
}
|
|
125
|
+
}
|
package/composition.mjs
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
// Composition and source discovery shared by output generation and configuration management.
|
|
2
|
+
import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const BASE = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
const PROTECTED = "End of every reply";
|
|
9
|
+
// The protected section points at § Offers, so Offers may be replaced but not removed.
|
|
10
|
+
const REQUIRED = [PROTECTED, "Offers"];
|
|
11
|
+
const OPS = ["replaces", "after", "before", "removes"];
|
|
12
|
+
const KEYS = [...OPS, "description", "requires", "reference"];
|
|
13
|
+
|
|
14
|
+
// Windows line endings and a byte-order mark would otherwise hide frontmatter and headings.
|
|
15
|
+
const normalize = (text) => text.replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n");
|
|
16
|
+
|
|
17
|
+
// A YAML value may be wrapped in one pair of matching quotes; the text inside is the value.
|
|
18
|
+
const unquote = (value) =>
|
|
19
|
+
value.length > 1 && /^(["']).*\1$/.test(value) ? value.slice(1, -1) : value;
|
|
20
|
+
|
|
21
|
+
// Minimal frontmatter: `key: value` lines between `---` fences.
|
|
22
|
+
export function parseFragment(rawText, source) {
|
|
23
|
+
const text = normalize(rawText);
|
|
24
|
+
const m = /^---\n([\s\S]*?)\n---\n?/.exec(text);
|
|
25
|
+
const meta = {};
|
|
26
|
+
if (m) {
|
|
27
|
+
for (const line of m[1].split("\n")) {
|
|
28
|
+
const i = line.indexOf(":");
|
|
29
|
+
if (i > 0) meta[line.slice(0, i).trim()] = unquote(line.slice(i + 1).trim());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return { meta, body: (m ? text.slice(m[0].length) : text).trim(), source };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Splits on level-2 headings outside fenced code blocks; level-3 and deeper stay inside their section.
|
|
36
|
+
export function splitSections(rawText) {
|
|
37
|
+
const parts = [[]];
|
|
38
|
+
let fence = null;
|
|
39
|
+
for (const line of normalize(rawText).split("\n")) {
|
|
40
|
+
const f = /^(`{3,}|~{3,})/.exec(line);
|
|
41
|
+
if (f && (!fence || f[1][0] === fence[0])) fence = fence ? null : f[1];
|
|
42
|
+
if (!fence && line.startsWith("## ")) parts.push([]);
|
|
43
|
+
parts.at(-1).push(line);
|
|
44
|
+
}
|
|
45
|
+
const preamble = parts.shift().join("\n").trim();
|
|
46
|
+
const sections = parts.map((lines) => ({
|
|
47
|
+
heading: lines[0].slice(3).trim(),
|
|
48
|
+
text: lines.join("\n").trim(),
|
|
49
|
+
}));
|
|
50
|
+
return { preamble, sections };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function composeParts(coreText, fragments, referencesDirectory, candidates) {
|
|
54
|
+
const core = parseFragment(coreText, "core");
|
|
55
|
+
if ("reference" in core.meta && "references" in core.meta)
|
|
56
|
+
throw new Error("core: use reference or references, not both");
|
|
57
|
+
const paths =
|
|
58
|
+
"references" in core.meta
|
|
59
|
+
? core.meta.references.split(",").map((path) => path.trim())
|
|
60
|
+
: "reference" in core.meta
|
|
61
|
+
? [core.meta.reference]
|
|
62
|
+
: [];
|
|
63
|
+
if (paths.some((path) => !path) || new Set(paths).size !== paths.length)
|
|
64
|
+
throw new Error("core: references must contain distinct non-empty paths");
|
|
65
|
+
const outputs = new Map();
|
|
66
|
+
if (paths.length) {
|
|
67
|
+
core.path = join(BASE, "rules/core.md");
|
|
68
|
+
core.root = BASE;
|
|
69
|
+
for (const path of paths) {
|
|
70
|
+
const output = renderReference(core, referencesDirectory, true, path);
|
|
71
|
+
if (outputs.has(output.heading))
|
|
72
|
+
throw new Error(`core: duplicate reference section "${output.heading}"`);
|
|
73
|
+
outputs.set(output.heading, output);
|
|
74
|
+
}
|
|
75
|
+
coreText = core.body;
|
|
76
|
+
}
|
|
77
|
+
const { preamble, sections } = splitSections(coreText);
|
|
78
|
+
if (referencesDirectory !== undefined)
|
|
79
|
+
for (const section of sections) section.referenceOutput = outputs.get(section.heading);
|
|
80
|
+
const find = (heading, f) => {
|
|
81
|
+
const i = sections.findIndex((s) => s.heading === heading);
|
|
82
|
+
if (i < 0) throw new Error(`${f.source}: no section "${heading}" to target`);
|
|
83
|
+
return i;
|
|
84
|
+
};
|
|
85
|
+
for (const f of fragments) {
|
|
86
|
+
const unknown = Object.keys(f.meta).filter((k) => !KEYS.includes(k));
|
|
87
|
+
if (unknown.length)
|
|
88
|
+
throw new Error(
|
|
89
|
+
`${f.source}: unknown frontmatter key "${unknown[0]}" (use ${KEYS.join(", ")})`,
|
|
90
|
+
);
|
|
91
|
+
const ops = OPS.filter((k) => k in f.meta);
|
|
92
|
+
if (ops.length > 1) throw new Error(`${f.source}: use one of ${OPS.join(", ")}`);
|
|
93
|
+
const op = ops[0];
|
|
94
|
+
const target = op && f.meta[op];
|
|
95
|
+
if (op && !target) throw new Error(`${f.source}: ${op}: needs a section heading`);
|
|
96
|
+
if (target === PROTECTED && op !== "after")
|
|
97
|
+
throw new Error(
|
|
98
|
+
`${f.source}: "${PROTECTED}" stays first and can only be added to with after:`,
|
|
99
|
+
);
|
|
100
|
+
if (op === "removes") {
|
|
101
|
+
if (REQUIRED.includes(target))
|
|
102
|
+
throw new Error(`${f.source}: "${target}" can be replaced, not removed`);
|
|
103
|
+
if (f.body) throw new Error(`${f.source}: a removes: fragment has no body`);
|
|
104
|
+
sections.splice(find(target, f), 1);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const { preamble: stray, sections: added } = splitSections(f.body);
|
|
108
|
+
for (const section of added) section.referenceOutput = f.referenceOutput;
|
|
109
|
+
if (!added.length || stray)
|
|
110
|
+
throw new Error(`${f.source}: body must start with a "## " heading`);
|
|
111
|
+
if (op === "replaces") {
|
|
112
|
+
// A replacement keeps the `after:` tag of the section it replaces, so later `after:` fragments still queue behind it.
|
|
113
|
+
const i = find(target, f);
|
|
114
|
+
sections.splice(i, 1, ...added.map((s) => ({ ...s, after: sections[i].after })));
|
|
115
|
+
} else if (op === "before") sections.splice(find(target, f), 0, ...added);
|
|
116
|
+
else if (op === "after") {
|
|
117
|
+
// Earlier `after:` fragments for the same target stay first, in configured order.
|
|
118
|
+
let i = find(target, f) + 1;
|
|
119
|
+
while (sections[i]?.after === target) i++;
|
|
120
|
+
sections.splice(i, 0, ...added.map((s) => ({ ...s, after: target })));
|
|
121
|
+
} else sections.push(...added);
|
|
122
|
+
}
|
|
123
|
+
const seen = new Set();
|
|
124
|
+
for (const s of sections) {
|
|
125
|
+
if (seen.has(s.heading))
|
|
126
|
+
throw new Error(`duplicate section "${s.heading}"; use replaces: to override it`);
|
|
127
|
+
seen.add(s.heading);
|
|
128
|
+
if (s.referenceOutput) {
|
|
129
|
+
const resource = s.referenceOutput;
|
|
130
|
+
const previous = candidates.get(resource.name);
|
|
131
|
+
if (previous && previous.text !== resource.text)
|
|
132
|
+
throw new Error(`conflicting reference "${resource.name}"`);
|
|
133
|
+
candidates.set(resource.name, resource);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (sections[0]?.heading !== PROTECTED)
|
|
137
|
+
throw new Error(`"${PROTECTED}" must stay the first section`);
|
|
138
|
+
for (const h of REQUIRED)
|
|
139
|
+
if (!seen.has(h))
|
|
140
|
+
throw new Error(`a "${h}" section is required; a replacement must keep that heading`);
|
|
141
|
+
return [preamble, ...sections.map((s) => s.text)].filter(Boolean).join("\n\n") + "\n";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function compose(coreText, fragments) {
|
|
145
|
+
const inline = fragments.map((fragment) => {
|
|
146
|
+
if (!("reference" in fragment.meta) || !fragment.body.includes(`](${fragment.meta.reference})`))
|
|
147
|
+
return fragment;
|
|
148
|
+
const f = { ...fragment };
|
|
149
|
+
if (!f.path) {
|
|
150
|
+
const name =
|
|
151
|
+
typeof f.source === "string" ? f.source.replace(/^modifier /, "").replace(/\.md$/, "") : "";
|
|
152
|
+
const path = join(BASE, "rules/modifiers", `${name}.md`);
|
|
153
|
+
if (
|
|
154
|
+
!/^[a-z0-9-]+$/.test(name) ||
|
|
155
|
+
!existsSync(path) ||
|
|
156
|
+
parseFragment(readFileSync(path, "utf8"), name).body !== f.body
|
|
157
|
+
)
|
|
158
|
+
throw new Error(`${f.source}: use loadFragments to establish the reference source layer`);
|
|
159
|
+
f.path = path;
|
|
160
|
+
f.root = BASE;
|
|
161
|
+
}
|
|
162
|
+
renderReference(f, undefined);
|
|
163
|
+
return f;
|
|
164
|
+
});
|
|
165
|
+
return composeParts(coreText, inline, undefined, new Map());
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const mdFiles = (dir) =>
|
|
169
|
+
existsSync(dir)
|
|
170
|
+
? readdirSync(dir)
|
|
171
|
+
.filter((f) => f.endsWith(".md"))
|
|
172
|
+
.sort()
|
|
173
|
+
: [];
|
|
174
|
+
|
|
175
|
+
export function modifierList() {
|
|
176
|
+
const dir = join(BASE, "rules/modifiers");
|
|
177
|
+
return mdFiles(dir).map((f) => ({
|
|
178
|
+
name: f.slice(0, -3),
|
|
179
|
+
...parseFragment(readFileSync(join(dir, f), "utf8"), f).meta,
|
|
180
|
+
}));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// The directory holding house-rules.json is the user's layer unless the config lists others.
|
|
184
|
+
const layersOf = (config) => config.layers ?? ["."];
|
|
185
|
+
|
|
186
|
+
function loadRawFragments(config, configDir) {
|
|
187
|
+
const fragments = (config.modifiers ?? []).map((name) => {
|
|
188
|
+
const path = join(BASE, "rules/modifiers", `${name}.md`);
|
|
189
|
+
if (!existsSync(path))
|
|
190
|
+
throw new Error(
|
|
191
|
+
`unknown modifier "${name}"; remove it from "modifiers" in the configuration file ("node compose.mjs --list" in the checkout, or "house-rules --list", shows the available names)`,
|
|
192
|
+
);
|
|
193
|
+
return { ...parseFragment(readFileSync(path, "utf8"), `modifier ${name}`), path, root: BASE };
|
|
194
|
+
});
|
|
195
|
+
for (const layer of layersOf(config)) {
|
|
196
|
+
const dir = join(resolve(configDir, layer), "rules");
|
|
197
|
+
for (const f of mdFiles(dir))
|
|
198
|
+
fragments.push({
|
|
199
|
+
...parseFragment(readFileSync(join(dir, f), "utf8"), join(dir, f)),
|
|
200
|
+
path: join(dir, f),
|
|
201
|
+
root: resolve(configDir, layer),
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return fragments;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Later layers' skills shadow base skills of the same name.
|
|
208
|
+
export function skillSources(config, configDir) {
|
|
209
|
+
const base = join(BASE, "skills");
|
|
210
|
+
const shipped = new Set(
|
|
211
|
+
readdirSync(base).filter((name) => existsSync(join(base, name, "SKILL.md"))),
|
|
212
|
+
);
|
|
213
|
+
const legacyNames = new Map(
|
|
214
|
+
[...shipped].filter((name) => name.startsWith("hr-")).map((name) => [name.slice(3), name]),
|
|
215
|
+
);
|
|
216
|
+
const exclude = new Set(config.skills?.exclude ?? []);
|
|
217
|
+
const independent = new Set(config.skills?.independent ?? []);
|
|
218
|
+
const included = config.skills?.include;
|
|
219
|
+
if (included !== undefined) {
|
|
220
|
+
if (
|
|
221
|
+
!Array.isArray(included) ||
|
|
222
|
+
included.some((name) => typeof name !== "string" || !name.trim())
|
|
223
|
+
)
|
|
224
|
+
throw new Error("skills.include must be an array of non-empty strings");
|
|
225
|
+
if (new Set(included).size !== included.length)
|
|
226
|
+
throw new Error("skills.include contains duplicates");
|
|
227
|
+
for (const name of included) {
|
|
228
|
+
if (!shipped.has(name))
|
|
229
|
+
throw new Error(`unknown shipped skill "${name}" in skills.include (see config catalog)`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
for (const name of exclude) {
|
|
233
|
+
if (legacyNames.has(name) && !independent.has(name))
|
|
234
|
+
throw new Error(
|
|
235
|
+
`legacy skill name "${name}" in skills.exclude; replace it with "${legacyNames.get(name)}"`,
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
const sources = new Map();
|
|
239
|
+
for (const root of [
|
|
240
|
+
base,
|
|
241
|
+
...layersOf(config).map((l) => join(resolve(configDir, l), "skills")),
|
|
242
|
+
]) {
|
|
243
|
+
if (!existsSync(root)) continue;
|
|
244
|
+
for (const name of readdirSync(root)) {
|
|
245
|
+
if (!existsSync(join(root, name, "SKILL.md"))) continue;
|
|
246
|
+
if (legacyNames.has(name) && !independent.has(name))
|
|
247
|
+
throw new Error(
|
|
248
|
+
`legacy skill name "${name}" in a personal layer; rename its directory and frontmatter name to "${legacyNames.get(name)}", or list "${name}" in skills.independent to keep it as an independent skill`,
|
|
249
|
+
);
|
|
250
|
+
if (root !== base && legacyNames.get(name.slice(3)) === name) {
|
|
251
|
+
const declaredName = parseFragment(readFileSync(join(root, name, "SKILL.md"), "utf8"), name)
|
|
252
|
+
.meta.name?.replace(/\s+#.*$/, "")
|
|
253
|
+
.replace(/^(['"])(.*)\1$/, "$2");
|
|
254
|
+
if (legacyNames.has(declaredName))
|
|
255
|
+
throw new Error(
|
|
256
|
+
`legacy skill name "${declaredName}" in frontmatter; set name to "${name}" to match its renamed override directory`,
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
if (
|
|
260
|
+
!exclude.has(name) &&
|
|
261
|
+
(root !== base || included === undefined || included.includes(name))
|
|
262
|
+
)
|
|
263
|
+
sources.set(name, join(root, name));
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return sources;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function configurationPath(path) {
|
|
270
|
+
return resolve(
|
|
271
|
+
path ??
|
|
272
|
+
join(
|
|
273
|
+
process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"),
|
|
274
|
+
"house-rules/house-rules.json",
|
|
275
|
+
),
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function renderReference(f, referencesDirectory, core = false, reference = f.meta.reference) {
|
|
280
|
+
const invalidReference = `${f.source}: reference must be a regular file within its source layer`;
|
|
281
|
+
const path = resolve(dirname(f.path), reference);
|
|
282
|
+
if (!reference || !existsSync(path) || !lstatSync(path).isFile())
|
|
283
|
+
throw new Error(invalidReference);
|
|
284
|
+
const inside = relative(realpathSync(f.root), realpathSync(path));
|
|
285
|
+
if (inside.startsWith("..") || isAbsolute(inside)) throw new Error(invalidReference);
|
|
286
|
+
const name = basename(path);
|
|
287
|
+
if (!/^[a-z0-9][a-z0-9-]*\.md$/.test(name))
|
|
288
|
+
throw new Error(`${f.source}: invalid reference filename`);
|
|
289
|
+
const text = readFileSync(path, "utf8");
|
|
290
|
+
const original = splitSections(text);
|
|
291
|
+
const parts = splitSections(f.body);
|
|
292
|
+
const section = core
|
|
293
|
+
? parts.sections.find((s) => s.heading === original.sections[0]?.heading)
|
|
294
|
+
: null;
|
|
295
|
+
const short = core ? splitSections(section?.text ?? "") : parts;
|
|
296
|
+
if (
|
|
297
|
+
original.preamble ||
|
|
298
|
+
short.preamble ||
|
|
299
|
+
original.sections.length !== 1 ||
|
|
300
|
+
short.sections.length !== 1 ||
|
|
301
|
+
original.sections[0].heading !== short.sections[0].heading
|
|
302
|
+
)
|
|
303
|
+
throw new Error(`${f.source}: reference must contain the same single section heading`);
|
|
304
|
+
const sourceLink = `](${reference})`;
|
|
305
|
+
if (!(core ? section.text : f.body).includes(sourceLink))
|
|
306
|
+
throw new Error(`${f.source}: reference link missing from body`);
|
|
307
|
+
if (referencesDirectory === undefined) {
|
|
308
|
+
f.body = core ? f.body.replace(section.text, text.trim()) : text.trim();
|
|
309
|
+
} else {
|
|
310
|
+
const href = encodeURI(
|
|
311
|
+
`${referencesDirectory.replace(/\\/g, "/").replace(/\/$/, "")}/${name}`,
|
|
312
|
+
).replace(/[()#?]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
313
|
+
f.body = f.body.replaceAll(sourceLink, `](${href})`);
|
|
314
|
+
if (!core) f.referenceOutput = { name, text, heading: original.sections[0].heading };
|
|
315
|
+
}
|
|
316
|
+
return { name, text, heading: original.sections[0].heading };
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function referenceFragments(config, configDir, referencesDirectory) {
|
|
320
|
+
if (
|
|
321
|
+
referencesDirectory !== undefined &&
|
|
322
|
+
(typeof referencesDirectory !== "string" || !referencesDirectory.trim())
|
|
323
|
+
)
|
|
324
|
+
throw new Error("referencesDirectory must be a non-empty string");
|
|
325
|
+
const fragments = loadRawFragments(config, configDir);
|
|
326
|
+
const candidates = new Map();
|
|
327
|
+
for (const f of fragments) {
|
|
328
|
+
if (!("reference" in f.meta)) continue;
|
|
329
|
+
renderReference(f, referencesDirectory);
|
|
330
|
+
}
|
|
331
|
+
return { fragments, candidates };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Existing low-level callers receive complete inline procedure bodies too.
|
|
335
|
+
export function loadFragments(config, configDir) {
|
|
336
|
+
return referenceFragments(config, configDir).fragments;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
export function composeConfiguration(config, configDir, { referencesDirectory } = {}) {
|
|
340
|
+
const { fragments, candidates } = referenceFragments(config, configDir, referencesDirectory);
|
|
341
|
+
const rules = composeParts(
|
|
342
|
+
readFileSync(join(BASE, "rules/core.md"), "utf8"),
|
|
343
|
+
fragments,
|
|
344
|
+
referencesDirectory,
|
|
345
|
+
candidates,
|
|
346
|
+
);
|
|
347
|
+
const references = new Map([...candidates].map(([name, value]) => [name, value.text]));
|
|
348
|
+
const skills = skillSources(config, configDir);
|
|
349
|
+
const warnings = [];
|
|
350
|
+
const core = parseFragment(readFileSync(join(BASE, "rules/core.md"), "utf8"), "rules/core.md");
|
|
351
|
+
for (const f of [core, ...fragments]) {
|
|
352
|
+
for (const need of (f.meta.requires ?? "")
|
|
353
|
+
.split(",")
|
|
354
|
+
.map((s) => s.trim())
|
|
355
|
+
.filter(Boolean)) {
|
|
356
|
+
if (!skills.has(need))
|
|
357
|
+
warnings.push(`${f.source} expects the "${need}" skill, which is not in the composed set`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return { fragments, rules, skills, warnings, references };
|
|
361
|
+
}
|