Skip to content

Commit ef506bc

Browse files
PedramNavidzealoushackerclaude
authored
add zh to memory cookbook (anthropics#325)
* add zh to memory cookbook * docs(authors): add zealoushacker and sort authors alphabetically - Add Alex Notov (zealoushacker) to authors.yaml - Sort all authors alphabetically by name (Anthropic first) - Update skills notebooks attribution from Anthropic to zealoushacker 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]> * add pre-commit hook to validate authors.yaml sorting * feat(authors): add --fix flag to sort authors.yaml automatically * chore(pre-commit): update authors validation hook to auto-sort * chore: add pyyaml dev dependency and fix zip strict parameter Set strict=False in zip() call in validate_authors_sorted.py to maintain Python 3.9 compatibility * feat: add --fix flag to authors validation script Add automatic sorting capability to the authors validation script and integrate it into the Makefile's fix target. The script now provides consistent output messages matching standard formatter conventions (e.g., "1 file reformatted" or "1 file left unchanged"). * refactor: simplify authors.yaml handling and improve type hints - Replace manual YAML formatting with yaml.dump() - Add type hints to load_authors() and show_diff() functions - Update pre-commit hook name to reflect validation functionality --------- Co-authored-by: Alex Notov <[email protected]> Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 25ea077 commit ef506bc

File tree

7 files changed

+158
-32
lines changed

7 files changed

+158
-32
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,11 @@ repos:
1515
entry: uv run python scripts/validate_notebooks.py
1616
language: system
1717
files: '\.ipynb$'
18-
pass_filenames: true
18+
pass_filenames: true
19+
20+
- id: validate-authors-sorted
21+
name: Validate and sort authors.yaml
22+
entry: uv run python scripts/validate_authors_sorted.py --fix
23+
language: system
24+
files: 'authors\.yaml$'
25+
pass_filenames: false

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help format lint check fix test clean install
1+
.PHONY: help format lint check fix test clean install sort-authors
22

33
# Default target
44
help:
@@ -10,6 +10,7 @@ help:
1010
@echo " make test - Run tests"
1111
@echo " make install - Install dependencies"
1212
@echo " make clean - Remove cache files"
13+
@echo " make sort-authors - Sort authors.yaml alphabetically"
1314

1415
# Format code with ruff
1516
format:
@@ -54,3 +55,8 @@ clean:
5455
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
5556
find . -type f -name "*.pyc" -delete 2>/dev/null || true
5657
@echo "Cache cleaned!"
58+
59+
# Sort authors.yaml alphabetically
60+
sort-authors:
61+
@echo "Sorting authors.yaml..."
62+
uv run python scripts/validate_authors_sorted.py --fix

authors.yaml

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
# This file maps author GitHub usernames (used in registry.yaml) to their full details
44
# for display on the website.
55

6+
Adriaan-ANT:
7+
name: Adriaan Engelbrecht
8+
avatar: https://avatars.githubusercontent.com/u/222316629?v=4
9+
alexalbertt:
10+
name: Alex Albert
11+
website: https://github.com/alexalbertt
12+
avatar: https://avatars.githubusercontent.com/u/34638987?v=4
613
Anthropic:
714
name: Anthropic
815
website: https://www.anthropic.com
@@ -11,26 +18,25 @@ Briiick:
1118
name: Alexander Bricken
1219
website: https://bricken.co
1320
avatar: https://avatars.githubusercontent.com/u/44481408?v=4
14-
GarvanD:
15-
name: Garvan Doyle
16-
website: https://garvandoyle.com
17-
avatar: https://avatars.githubusercontent.com/u/22383376?v=4
18-
JiriDeJonghe:
19-
name: Jiri De Jonghe
20-
website: https://github.com/JiriDeJonghe
21-
avatar: https://avatars.githubusercontent.com/u/33628402?v=4
22-
alexalbertt:
23-
name: Alex Albert
24-
website: https://github.com/alexalbertt
25-
avatar: https://avatars.githubusercontent.com/u/34638987?v=4
2621
davidhershey:
2722
name: David Hershey
2823
website: https://github.com/davidhershey
2924
avatar: https://avatars.githubusercontent.com/u/11651858?v=4
25+
GarvanD:
26+
name: Garvan Doyle
27+
website: https://garvandoyle.com
28+
avatar: https://avatars.githubusercontent.com/u/22383376?v=4
29+
henrykeetay:
30+
name: Henry Keetay
31+
avatar: https://avatars.githubusercontent.com/u/227475578?v=4
3032
james-briggs:
3133
name: james-briggs
3234
website: https://github.com/James-Briggs
3335
avatar: https://avatars.githubusercontent.com/u/64431405?v=4
36+
JiriDeJonghe:
37+
name: Jiri De Jonghe
38+
website: https://github.com/JiriDeJonghe
39+
avatar: https://avatars.githubusercontent.com/u/33628402?v=4
3440
jpvajda:
3541
name: john-vajda
3642
website: https://github.com/jpvajda
@@ -39,6 +45,13 @@ maheshmurag:
3945
name: Mahesh Murag
4046
website: https://github.com/maheshmurag
4147
avatar: https://avatars.githubusercontent.com/u/5667029?v=4
48+
nadine-anthropic:
49+
name: Nadine Yasser
50+
avatar: https://avatars.githubusercontent.com/u/238355370?v=4
51+
PedramNavid:
52+
name: Pedram Navid
53+
website: http://x.com/pdrmnvd
54+
avatar: https://avatars.githubusercontent.com/u/1045990
4255
ravi03071991:
4356
name: Ravi Theja
4457
website: https://sites.google.com/view/ravi-theja
@@ -51,16 +64,7 @@ RichmondAlake:
5164
name: Richmond Alake
5265
website: https://github.com/RichmondAlake
5366
avatar: https://github.com/RichmondAlake.png
54-
PedramNavid:
55-
name: Pedram Navid
56-
website: http://x.com/pdrmnvd
57-
avatar: https://avatars.githubusercontent.com/u/1045990
58-
nadine-anthropic:
59-
name: Nadine Yasser
60-
avatar: https://avatars.githubusercontent.com/u/238355370?v=4
61-
henrykeetay:
62-
name: Henry Keetay
63-
avatar: https://avatars.githubusercontent.com/u/227475578?v=4
64-
Adriaan-ANT:
65-
name: Adriaan Engelbrecht
66-
avatar: https://avatars.githubusercontent.com/u/222316629?v=4
67+
zealoushacker:
68+
name: Alex Notov
69+
website: https://github.com/zealoushacker
70+
avatar: https://avatars.githubusercontent.com/u/346275?v=4

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ dev = [
2424
"pytest>=8.3.3",
2525
"nbval>=0.11.0",
2626
"pre-commit>=3.8.0",
27-
"nbconvert>=7.16.0",
27+
"nbconvert>=7.16.0",
28+
"pyyaml>=6.0.3",
2829
]
2930

3031
[tool.hatch.build.targets.wheel]

registry.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@
355355
PowerPoint, PDF skills.
356356
path: skills/notebooks/01_skills_introduction.ipynb
357357
authors:
358-
- Anthropic
358+
- zealoushacker
359359
date: '2025-10-14'
360360
categories:
361361
- Skills
@@ -364,7 +364,7 @@
364364
PowerPoint, PDF skills.
365365
path: skills/notebooks/02_skills_financial_applications.ipynb
366366
authors:
367-
- Anthropic
367+
- zealoushacker
368368
date: '2025-10-15'
369369
categories:
370370
- Skills
@@ -373,7 +373,7 @@
373373
organizational workflows.
374374
path: skills/notebooks/03_skills_custom_development.ipynb
375375
authors:
376-
- Anthropic
376+
- zealoushacker
377377
date: '2025-10-15'
378378
categories:
379379
- Skills
@@ -528,7 +528,7 @@
528528
context editing.
529529
path: tool_use/memory_cookbook.ipynb
530530
authors:
531-
- Anthropic
531+
- zealoushacker
532532
date: '2025-05-22'
533533
categories:
534534
- Tools

scripts/validate_authors_sorted.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env python3
2+
"""Validate and optionally fix authors.yaml sorting (case-insensitive alphabetical)."""
3+
4+
import argparse
5+
import sys
6+
from pathlib import Path
7+
from typing import Any
8+
9+
import yaml
10+
11+
# Ensure UTF-8 output on Windows
12+
if sys.platform == "win32":
13+
sys.stdout.reconfigure(encoding="utf-8")
14+
sys.stderr.reconfigure(encoding="utf-8")
15+
16+
AUTHORS_FILE = Path(__file__).parent.parent / "authors.yaml"
17+
18+
HEADER = """\
19+
# yaml-language-server: $schema=./.github/authors_schema.json
20+
# Authors mapping: GitHub username -> Author details
21+
# This file maps author GitHub usernames (used in registry.yaml) to their full details
22+
# for display on the website.
23+
24+
"""
25+
26+
27+
def load_authors() -> dict[str, Any] | None:
28+
"""Load authors.yaml and return the data."""
29+
with open(AUTHORS_FILE, encoding="utf-8") as f:
30+
return yaml.safe_load(f)
31+
32+
33+
def is_sorted(data: dict) -> bool:
34+
"""Check if the keys are sorted alphabetically (case-insensitive)."""
35+
keys = list(data.keys())
36+
return keys == sorted(keys, key=str.lower)
37+
38+
39+
def sort_authors(data: dict, check_only: bool = False) -> bool:
40+
"""Sort and write authors.yaml. Returns True if file was/would be changed."""
41+
sorted_data = dict(sorted(data.items(), key=lambda x: x[0].lower()))
42+
43+
if check_only:
44+
return list(data.keys()) != list(sorted_data.keys())
45+
46+
with open(AUTHORS_FILE, "w", encoding="utf-8") as f:
47+
f.write(HEADER)
48+
yaml.dump(sorted_data, f, default_flow_style=False, allow_unicode=True, sort_keys=False)
49+
50+
return True
51+
52+
53+
def show_diff(keys: list, sorted_keys: list) -> None:
54+
"""Show the difference between current and expected order."""
55+
print("authors.yaml is not sorted alphabetically (case-insensitive).")
56+
print("\nCurrent order:")
57+
for k in keys:
58+
print(f" {k}")
59+
60+
print("\nExpected order:")
61+
for k in sorted_keys:
62+
print(f" {k}")
63+
64+
print("\nOut of place entries:")
65+
for i, (current, expected) in enumerate(zip(keys, sorted_keys, strict=False)):
66+
if current != expected:
67+
print(f" Position {i}: got '{current}', expected '{expected}'")
68+
69+
70+
def main():
71+
parser = argparse.ArgumentParser(description="Validate or fix authors.yaml sorting")
72+
parser.add_argument(
73+
"--fix", action="store_true", help="Sort the file instead of just validating"
74+
)
75+
args = parser.parse_args()
76+
77+
data = load_authors()
78+
79+
if not data:
80+
print("authors.yaml is empty")
81+
sys.exit(0)
82+
83+
already_sorted = is_sorted(data)
84+
85+
if args.fix:
86+
if already_sorted:
87+
print("1 file left unchanged")
88+
else:
89+
sort_authors(data)
90+
print("1 file reformatted")
91+
sys.exit(0)
92+
93+
# Validation mode
94+
if already_sorted:
95+
print("1 file left unchanged")
96+
sys.exit(0)
97+
98+
keys = list(data.keys())
99+
sorted_keys = sorted(keys, key=str.lower)
100+
show_diff(keys, sorted_keys)
101+
print("\nRun with --fix to sort automatically")
102+
sys.exit(1)
103+
104+
105+
if __name__ == "__main__":
106+
main()

uv.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)