-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhk.pkl
More file actions
150 lines (131 loc) · 5.03 KB
/
hk.pkl
File metadata and controls
150 lines (131 loc) · 5.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
amends "package://github.com/jdx/hk/releases/download/v1.28.0/hk@1.28.0#/Config.pkl"
import "package://github.com/jdx/hk/releases/download/v1.28.0/hk@1.28.0#/Builtins.pkl"
// =============================================================================
// hk Configuration for ExFig
// =============================================================================
// Migrated from pre-commit
// All hooks run in parallel for maximum performance
// =============================================================================
// Excludes for generated/binary files
local generated_excludes = List(".build/**", "docs/**", "CHANGELOG.md")
// Excludes for template files (trailing whitespace/newlines are semantically significant)
local template_excludes = List("**/*.jinja", "**/*.jinja.include")
// SourceKit toolchain path for SwiftLint (required for GUI apps: Fork, Xcode, Tower)
local sourcekit_env = new Mapping<String, String> {
["TOOLCHAIN_DIR"] = read("env:HOME") + "/.local/share/mise/installs/swift/6.2.3"
}
// =============================================================================
// Swift Linters (parallel, check_first optimization)
// =============================================================================
local swift_linters = new Mapping<String, Step> {
["swiftformat"] {
glob = List("*.swift")
check = "swiftformat --lint {{files}}"
fix = "swiftformat {{files}}"
batch = true
stage = List("*.swift")
check_first = true
hide = true
}
["swiftlint"] {
glob = List("*.swift")
fix = "swiftlint --fix {{files}}"
batch = true
stage = List("*.swift")
hide = true
env = sourcekit_env
}
// Strict check after fix to catch unfixable errors
["swiftlint-strict"] {
glob = List("*.swift")
check = "swiftlint lint --strict --quiet {{files}}"
batch = true
depends = "swiftlint"
hide = true
env = sourcekit_env
}
}
// =============================================================================
// dprint Formatter (Markdown) - Rust-based, fast
// =============================================================================
local dprint_checks = new Mapping<String, Step> {
["dprint"] = (Builtins.dprint) {
exclude = List("CHANGELOG.md", "Sources/**/*.docc/**", ".claude/**", ".github/ISSUE_TEMPLATE/**")
stage = List("*.md")
check_first = true
hide = true
}
}
// =============================================================================
// Builtin Checks (fast, parallel)
// =============================================================================
local builtin_checks = new Mapping<String, Step> {
["trailing-whitespace"] = (Builtins.trailing_whitespace) {
exclude = generated_excludes + template_excludes
hide = true
}
["check-merge-conflict"] = (Builtins.check_merge_conflict) {
hide = true
}
["newlines"] = (Builtins.newlines) {
exclude = generated_excludes + template_excludes
depends = "llms-check"
hide = true
}
["actionlint"] {
glob = List(".github/workflows/*.yml", ".github/workflows/*.yaml")
check = "actionlint {{files}}"
batch = true
hide = true
}
}
// =============================================================================
// Generated File Checks
// =============================================================================
local generated_checks = new Mapping<String, Step> {
// Regenerate llms.txt / llms-full.txt when documentation sources change.
// check generates to a temp dir (parallel-safe), fix writes to repo.
["llms-check"] {
glob = List("README.md", "Sources/ExFigCLI/ExFig.docc/**/*.md", "CONFIG.md", "docs/*.md")
check = "bash Scripts/check-llms-freshness.sh"
fix = "bash Scripts/generate-llms.sh"
stage = List("llms.txt", "llms-full.txt")
hide = true
}
}
// =============================================================================
// Combined Linters
// =============================================================================
local all_linters = new Mapping<String, Step> {
...swift_linters
...dprint_checks
...builtin_checks
...generated_checks
}
// =============================================================================
// Hooks Configuration
// =============================================================================
hooks {
// Pre-commit: runs all linters with auto-fix
// Using patch-file stash mode to properly handle untracked files
["pre-commit"] {
fix = true
stash = "none"
steps = all_linters
}
// Commit-msg: validate conventional commits format
["commit-msg"] {
steps {
["conventional-commit"] = Builtins.check_conventional_commit
}
}
// Helper: run all linters with fix
["fix"] {
fix = true
steps = all_linters
}
// Helper: run all linters without fix
["check"] {
steps = all_linters
}
}