Skip to content

Commit 2b7ca2d

Browse files
committed
feat(specs): add lint-specs command, minimal Vale config, pre-commit via git-hooks.nix; add specs/AGENTS.md
- Add `lint-specs` Just task to run markdownlint, link check, spell check, Vale, and Mermaid validation in one shot. - Add minimal `.vale.ini` using built-in `Vale` style (no network). - Integrate `cachix/git-hooks.nix` to run a `pre-commit` hook that executes `just lint-specs`. - Inject the hook via flake devShell shellHook for auto-install during `nix develop`. - Add `specs/AGENTS.md` instructing contributors to run `just lint-specs` before committing. - Ignore generated `.pre-commit-config.yaml`.
1 parent f8bafa6 commit 2b7ca2d

File tree

6 files changed

+57
-0
lines changed

6 files changed

+57
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ test/logs/
88

99
# linter cache
1010
.rubocop-cache/
11+
.pre-commit-config.yaml

.obsidian/workspace.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
},
195195
"active": "01bf72509d2b5652",
196196
"lastOpenFiles": [
197+
"specs/AGENTS.md",
197198
"scripts/md-mermaid-validate.sh",
198199
"specs/Public/Configuration.md",
199200
"specs/Public/CLI.md",

.vale.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Minimal Vale configuration for repository Markdown
2+
MinAlertLevel = warning
3+
4+
[*.md]
5+
BasedOnStyles = Vale

Justfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,26 @@ md-links:
7676
# Spell-check Markdown with cspell (uses default dictionaries unless configured)
7777
md-spell:
7878
cspell "specs/**/*.md"
79+
80+
# Run all spec linting/validation in one go
81+
lint-specs:
82+
#!/usr/bin/env bash
83+
set -euo pipefail
84+
if [ -n "${IN_NIX_SHELL:-}" ]; then
85+
echo "Running lint-specs inside Nix dev shell (no fallbacks)." >&2
86+
fi
87+
just md-lint
88+
just md-links
89+
just md-spell
90+
# Prose/style linting via Vale (requires .vale.ini in repo)
91+
if command -v vale >/dev/null 2>&1; then
92+
vale specs || exit 1
93+
else
94+
if [ -n "${IN_NIX_SHELL:-}" ]; then
95+
echo "vale is missing inside Nix dev shell; add pkgs.vale to flake.nix." >&2
96+
exit 127
97+
fi
98+
echo "vale not found; skipping outside Nix shell." >&2
99+
fi
100+
# Mermaid syntax validation
101+
just md-mermaid-check

flake.nix

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,34 @@
33

44
inputs = {
55
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
git-hooks.url = "github:cachix/git-hooks.nix";
67
};
78

89
outputs = {
910
self,
1011
nixpkgs,
12+
git-hooks,
1113
}: let
1214
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
1315
forAllSystems = nixpkgs.lib.genAttrs systems;
1416
in {
17+
checks = forAllSystems (system: let
18+
pkgs = import nixpkgs { inherit system; };
19+
preCommit = git-hooks.lib.${system}.run {
20+
src = ./.;
21+
hooks = {
22+
lint-specs = {
23+
enable = true;
24+
name = "Lint Markdown specs";
25+
entry = "just lint-specs";
26+
language = "system";
27+
pass_filenames = false;
28+
};
29+
};
30+
};
31+
in {
32+
pre-commit-check = preCommit;
33+
});
1534
packages = forAllSystems (
1635
system: let
1736
pkgs = import nixpkgs {
@@ -106,6 +125,8 @@
106125
];
107126

108127
shellHook = ''
128+
# Install git pre-commit hook invoking our Nix-defined hooks
129+
${self.checks.${system}.pre-commit-check.shellHook}
109130
echo "Agent workflow development environment loaded"
110131
# Provide a convenience function for Docson; no fallbacks in Nix shell
111132
docson () {

specs/AGENTS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Specs Maintenance
2+
3+
- Before committing any change to the `specs/` folder, run `just lint-specs` from the project root. This performs Markdown linting, link checking, spell checking, prose/style linting, and Mermaid diagram validation.
4+
- The Nix dev shell is fully reproducible; if a required tool is missing inside the shell, fix `flake.nix` rather than using ad‑hoc fallbacks.
5+
6+
If the pre-commit hook blocks your commit, run `just lint-specs`, address the reported issues, and commit again.

0 commit comments

Comments
 (0)