diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..8b4929f --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,12 @@ +{ + "permissions": { + "allow": [ + "Bash(python scripts/verify.py)" + ], + "deny": [ + "Read(./.env)", + "Read(./.env.*)", + "Edit(./LICENSE)" + ] + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..14c0568 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.claude/settings.local.json +CLAUDE.local.md +__pycache__/ diff --git a/AGENTS.md b/AGENTS.md index 098fce6..d7b868d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,7 +1,7 @@ # Rules for AI agents -Verify: none. This repo holds only Markdown, YAML and 1 image; check YAML forms parse -(`python -c "import yaml,glob;[yaml.safe_load(open(f)) for f in glob.glob('ISSUE_TEMPLATE/*.yml')]"`). +Verify: `python scripts/verify.py` (offline, needs PyYAML; expect `verify: ok`). It parses the issue forms, starter +workflows and their `.properties.json`, and checks relative Markdown links. External links are checked only by CI. The Solarity-AI organisation's default community files. Every repository without its own copy uses them, so a change here changes every such repository at once. @@ -19,6 +19,7 @@ here changes every such repository at once. - `workflow-templates/`: org starter workflows offered on every repo's "New workflow" page (`node-ci.yml` calls the shared Node test job in `ci-platform` at `@v1`; each template needs a matching `.properties.json`). - `.github/workflows/links.yml`: checks the links in every Markdown file on pull requests (hosted runner, public repo). +- `scripts/verify.py`: the offline check above. - `profile/README.md`: the public organisation profile page; it is public, so no private repo names, people or numbers. ## Rules diff --git a/scripts/verify.py b/scripts/verify.py new file mode 100644 index 0000000..0e34fc0 --- /dev/null +++ b/scripts/verify.py @@ -0,0 +1,33 @@ +"""Offline check for the org default files: YAML and JSON parse, each starter workflow has its properties file, +and every relative Markdown link points at a file that exists. Needs PyYAML. Exit 1 on any problem.""" +import glob, json, os, re, sys + +import yaml + +bad = [] +for f in glob.glob("ISSUE_TEMPLATE/*.yml") + glob.glob("workflow-templates/*.yml") + glob.glob(".github/workflows/*.yml"): + try: + yaml.safe_load(open(f, encoding="utf-8")) + except Exception as e: + bad.append(f"{f}: invalid YAML ({e})") +for f in glob.glob("workflow-templates/*.properties.json"): + try: + json.load(open(f, encoding="utf-8")) + except Exception as e: + bad.append(f"{f}: invalid JSON ({e})") +for f in glob.glob("workflow-templates/*.yml"): + p = f[:-4] + ".properties.json" + if not os.path.exists(p): + bad.append(f"{f}: missing {p}") +for f in glob.glob("*.md") + glob.glob("profile/*.md"): + text = open(f, encoding="utf-8").read() + for m in re.findall(r'\]\(([^)\s]+)\)|src="([^"]+)"', text): + url = m[0] or m[1] + if url.startswith(("#", "mailto:", "http://", "https://")): + continue + if not os.path.exists(os.path.join(os.path.dirname(f), url.split("#")[0])): + bad.append(f"{f}: {url} -> missing file") +for b in bad: + print("FAIL", b) +print("verify: " + ("FAILED" if bad else "ok")) +sys.exit(1 if bad else 0)