A self-organizing Obsidian vault that gives AI coding agents persistent memory.
TypeScript ai-agentsclaude-codecodex-cligemini-cliknowledge-managementobsidianobsidian-vaultpersistent-memorysecond-braintemplate
ci: auto-generate CHANGELOG on release (#32)
Brenno Ferrarie521f25d0982
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.mdnew file mode 100644index 0000000..0bbb699--- /dev/null+++ b/.github/pull_request_template.md@@ -0,0 +1,25 @@+## Summary+<!-- What does this PR do? One or two sentences. -->++## Type+<!-- Your PR title must start with one of these prefixes. -->+<!-- e.g. "feat: add /om-review command" -->++- [ ] `feat` — new command, agent, hook, or capability+- [ ] `fix` — bug fix+- [ ] `docs` — documentation only+- [ ] `refactor` — code restructuring, no behavior change+- [ ] `test` — adding or updating tests+- [ ] `ci` — CI/CD workflow changes+- [ ] `chore` — maintenance, cleanup+- [ ] `build` — build system or packaging changes+- [ ] `perf` — performance improvements+- [ ] `style` — formatting, no behavior change+- [ ] `revert` — revert a previous change++## Checklist++- [ ] PR title follows `type: description` format+- [ ] Tests pass (`python .claude/scripts/test_hooks.py`)+- [ ] Doc tables updated if adding commands/agents (CLAUDE.md, README, Skills.md, translations)+- [ ] No changes to CHANGELOG.md or vault-manifest.json version (automated by release pipeline)diff --git a/.github/scripts/generate-changelog.py b/.github/scripts/generate-changelog.pynew file mode 100644index 0000000..8ccdb77--- /dev/null+++ b/.github/scripts/generate-changelog.py@@ -0,0 +1,185 @@+#!/usr/bin/env python3+"""Generate a CHANGELOG.md entry from commits since the previous tag.++Usage: generate-changelog.py <version>+ e.g. generate-changelog.py v3.8++Outputs:+ - Prepends new section to CHANGELOG.md (or replaces if version exists)+ - Updates vault-manifest.json version and released date+ - Prints the generated section to stdout (for use as GitHub Release body)+"""++import json+import re+import subprocess+import sys+from datetime import datetime, timezone++PREFIX_MAP = {+ "feat": "Added",+ "fix": "Fixed",+ "docs": "Changed",+ "ci": "Changed",+ "refactor": "Changed",+ "perf": "Changed",+ "test": "Changed",+ "chore": "Changed",+ "build": "Changed",+ "style": "Changed",+ "revert": "Fixed",+}++SKIP_PREFIXES = {"release", "ci", "test"}++SECTION_ORDER = ["Added", "Changed", "Fixed", "Removed"]+++def run_git(*args):+ result = subprocess.run(+ ["git"] + list(args),+ capture_output=True, text=True+ )+ if result.returncode != 0:+ print(f"git {' '.join(args)} failed: {result.stderr.strip()}", file=sys.stderr)+ sys.exit(1)+ return result.stdout.strip()+++def get_previous_tag():+ output = run_git("tag", "--sort=-version:refname")+ tags = [t.strip() for t in output.split("\n") if t.strip()]+ if len(tags) >= 2:+ return tags[1]+ return None+++def get_commits(since_tag):+ if since_tag:+ range_spec = f"{since_tag}..HEAD"+ else:+ range_spec = "HEAD"++ output = run_git("log", range_spec, "--pretty=format:%s", "--first-parent")+ return [line.strip() for line in output.split("\n") if line.strip()]+++def classify_commit(message):+ # Strip PR reference suffix like (#25)+ clean = re.sub(r'\s*\(#\d+\)\s*$', '', message)++ # Try prefix match: "feat: description" or "feat(scope): description"+ match = re.match(r'^(\w+)(?:\([^)]*\))?\s*:\s*(.+)$', clean)+ if match:+ prefix = match.group(1).lower()+ description = match.group(2).strip()+ if prefix in SKIP_PREFIXES:+ return None, None+ category = PREFIX_MAP.get(prefix, "Changed")+ return category, description++ # No prefix — capitalize first letter, put in Changed+ if not clean:+ return "Changed", clean+ return "Changed", clean[0].upper() + clean[1:]+++def generate_section(version, commits):+ today = datetime.now(timezone.utc).strftime("%Y-%m-%d")+ grouped = {}++ for msg in commits:+ category, description = classify_commit(msg)+ if category is None:+ continue+ if category not in grouped:+ grouped[category] = []+ grouped[category].append(description)++ lines = [f"## {version} — {today}", ""]++ for section in SECTION_ORDER:+ if section in grouped:+ lines.append(f"### {section}")+ for item in grouped[section]:+ lines.append(f"- {item}")+ lines.append("")++ return "\n".join(lines)+++def prepend_to_changelog(section, version):+ with open("CHANGELOG.md", "r", encoding="utf-8") as f:+ content = f.read()++ # Check if this version already exists (idempotent on re-runs)+ version_pattern = rf"(?m)^## {re.escape(version)} — .*$"+ # Match everything from this version header up to the next version header (or end of file)+ existing_pattern = rf"(?ms)^## {re.escape(version)} — .*?(?=\n## [^\n]|\Z)"+ if re.search(version_pattern, content):+ new_content = re.sub(existing_pattern, section.rstrip(), content, count=1)+ else:+ # Insert after the "# Changelog" header+ header = "# Changelog"+ idx = content.find(header)+ if idx == -1:+ new_content = f"{header}\n\n{section}\n{content}"+ else:+ insert_at = idx + len(header)+ while insert_at < len(content) and content[insert_at] in ("\n", "\r"):+ insert_at += 1+ new_content = content[:insert_at] + "\n" + section + "\n" + content[insert_at:]++ with open("CHANGELOG.md", "w", encoding="utf-8") as f:+ f.write(new_content)+++def normalize_version(version):+ match = re.fullmatch(r"v?(\d+)\.(\d+)(?:\.(\d+))?", version)+ if not match:+ print(f"Invalid version '{version}'. Expected vX.Y or vX.Y.Z.", file=sys.stderr)+ sys.exit(1)+ major, minor, patch = match.groups()+ return f"{major}.{minor}.{patch or '0'}"+++def update_manifest(version):+ with open("vault-manifest.json", "r", encoding="utf-8") as f:+ manifest = json.load(f)++ manifest["version"] = normalize_version(version)+ manifest["released"] = datetime.now(timezone.utc).strftime("%Y-%m-%d")++ with open("vault-manifest.json", "w", encoding="utf-8") as f:+ json.dump(manifest, f, indent=2, ensure_ascii=False)+ f.write("\n")+++def main():+ if len(sys.argv) < 2:+ print("Usage: generate-changelog.py <version>", file=sys.stderr)+ sys.exit(1)++ version = sys.argv[1]+ prev_tag = get_previous_tag()+ commits = get_commits(prev_tag)++ if not commits:+ print("No commits found since previous tag.", file=sys.stderr)+ sys.exit(1)++ section = generate_section(version, commits)++ if not any(classify_commit(msg)[0] is not None for msg in commits):+ print("All commits were skipped (ci/test/release only). Nothing to changelog.", file=sys.stderr)+ sys.exit(1)++ prepend_to_changelog(section, version)+ update_manifest(version)++ # Print section for GitHub Release body+ print(section)+++if __name__ == "__main__":+ main()diff --git a/.github/workflows/manifest-check.yml b/.github/workflows/manifest-check.ymlnew file mode 100644index 0000000..b323f7b--- /dev/null+++ b/.github/workflows/manifest-check.yml@@ -0,0 +1,63 @@+name: Manifest Check++on:+ pull_request:+ paths:+ - '.claude/commands/**'+ - '.claude/agents/**'+ - '.claude/scripts/**'+ - 'templates/**'+ - 'bases/**'++jobs:+ check:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4++ - name: Check manifest coverage+ run: |+ MISSING=()++ # Read infrastructure globs from manifest+ GLOBS=$(python3 -c "+ import json+ with open('vault-manifest.json') as f:+ m = json.load(f)+ for g in m.get('infrastructure', []):+ print(g)+ ")++ # For each file in watched directories, check if any glob covers it+ for f in .claude/commands/*.md .claude/agents/*.md .claude/scripts/*.py .claude/scripts/*.sh templates/*.md bases/*.base; do+ [ -f "$f" ] || continue+ COVERED=false+ while IFS= read -r glob; do+ # Check exact match+ if [ "$f" = "$glob" ]; then+ COVERED=true+ break+ fi+ # Check glob coverage: ".claude/**" covers ".claude/commands/foo.md"+ # Convert glob to regex: ** → .*, * → [^/]*+ regex=$(echo "$glob" | sed 's|\*\*|__DOUBLESTAR__|g' | sed 's|\*|[^/]*|g' | sed 's|__DOUBLESTAR__|.*|g' | sed 's|\.|\\.|g' | sed 's|\\\.\*|.*|g' | sed 's|\\\[|[|g' | sed 's|\\\]|]|g')+ if echo "$f" | grep -qE "^${regex}$"; then+ COVERED=true+ break+ fi+ done <<< "$GLOBS"++ if [ "$COVERED" = false ]; then+ MISSING+=("$f")+ fi+ done++ if [ ${#MISSING[@]} -gt 0 ]; then+ echo "::warning::The following files are not covered by vault-manifest.json infrastructure globs:"+ for f in "${MISSING[@]}"; do+ echo " - $f"+ done+ echo ""+ echo "If these are template infrastructure files, add them to the 'infrastructure' array in vault-manifest.json."+ echo "Also consider adding a version_fingerprints entry if this is a new version-defining file."+ fidiff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.ymlnew file mode 100644index 0000000..80c7be8--- /dev/null+++ b/.github/workflows/pr-title.yml@@ -0,0 +1,23 @@+name: PR Title++on:+ pull_request:+ types: [opened, edited, synchronize]++jobs:+ check:+ runs-on: ubuntu-latest+ steps:+ - name: Check PR title format+ env:+ TITLE: ${{ github.event.pull_request.title }}+ run: |+ if [[ ! "$TITLE" =~ ^(feat|fix|docs|ci|refactor|perf|test|chore|build|style|revert):\ .+ ]]; then+ echo "::error::PR title must follow conventional format: 'type: description'"+ echo ""+ echo "Valid types: feat, fix, docs, ci, refactor, perf, test, chore, build, style, revert"+ echo "Example: 'feat: add /om-review command'"+ echo ""+ echo "See CONTRIBUTING.md for details."+ exit 1+ fidiff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex c7eeaa1..0add570 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -13,16 +13,35 @@ jobs:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v4+ with:+ ref: main+ fetch-depth: 0++ - uses: actions/setup-python@v5+ with:+ python-version: '3.12'- name: Run testsrun: python3 .claude/scripts/test_hooks.py- - name: Build vault zip+ - name: Generate changelogrun: |VERSION="${GITHUB_REF#refs/tags/}"+ python3 .github/scripts/generate-changelog.py "$VERSION" > /tmp/release_body.md+ echo "VERSION=$VERSION" >> "$GITHUB_ENV"++ - name: Commit changelog and manifest+ run: |+ git config user.name "github-actions[bot]"+ git config user.email "github-actions[bot]@users.noreply.github.com"+ git add CHANGELOG.md vault-manifest.json+ git commit -m "release: update CHANGELOG and manifest for $VERSION"+ git push origin main++ - name: Build vault zip+ run: |ZIP_NAME="obsidian-mind-${VERSION}.zip"- # Create clean zip excluding dev/CI fileszip -r "$ZIP_NAME" . \-x ".git/*" \-x ".github/*" \@@ -31,16 +50,16 @@ jobs:-x "thinking/session-logs/*"echo "ZIP_NAME=$ZIP_NAME" >> "$GITHUB_ENV"- echo "VERSION=$VERSION" >> "$GITHUB_ENV"- name: Create or update releaserun: |if gh release view "$VERSION" &>/dev/null; then+ gh release edit "$VERSION" --notes-file /tmp/release_body.mdgh release upload "$VERSION" "$ZIP_NAME" --clobberelsegh release create "$VERSION" "$ZIP_NAME" \--title "$VERSION" \- --generate-notes+ --notes-file /tmp/release_body.mdfienv:GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}diff --git a/.github/workflows/tag-release.yml b/.github/workflows/tag-release.ymlnew file mode 100644index 0000000..259d1df--- /dev/null+++ b/.github/workflows/tag-release.yml@@ -0,0 +1,38 @@+name: Tag Release++on:+ workflow_dispatch:+ inputs:+ version:+ description: 'Version to release (e.g. v3.8)'+ required: true+ type: string++permissions:+ contents: write++jobs:+ tag:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4++ - name: Validate version format+ env:+ VERSION: ${{ inputs.version }}+ run: |+ if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]; then+ echo "::error::Invalid version format: $VERSION (expected v*.* or v*.*.*)"+ exit 1+ fi+ if git ls-remote --tags origin "refs/tags/$VERSION" | grep -q .; then+ echo "::error::Tag $VERSION already exists"+ exit 1+ fi++ - name: Create and push tag+ env:+ VERSION: ${{ inputs.version }}+ run: |+ git tag "$VERSION"+ git push origin "$VERSION"diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 79e67bc..d6f5aa9 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -1,23 +1,83 @@# Contributing+Thanks for your interest in contributing to obsidian-mind!++## Quick Start++1. Fork the repo and create a branch from `main`+2. Make your changes+3. Open a PR with a title following the [commit format](#pr-title-format)+4. That's it — the maintainer will review and merge++## PR Title Format++**This is the most important convention.** PR titles become commit messages (squash merge) and feed the automated changelog. Use this format:++```+type: short description+```++| Prefix | When to use | Changelog |+|--------|-------------|-----------|+| `feat` | New command, agent, hook, or capability | Added |+| `fix` | Bug fix | Fixed |+| `docs` | Documentation only (README, translations, CLAUDE.md) | Changed |+| `refactor` | Code restructuring without behavior change | Changed |+| `chore` | Maintenance, cleanup | Changed |+| `build` | Build system or packaging changes | Changed |+| `perf` | Performance improvements | Changed |+| `style` | Formatting, no behavior change | Changed |+| `revert` | Reverting a previous change | Fixed |+| `ci` | CI/CD workflow changes | Skipped (internal) |+| `test` | Adding or updating tests | Skipped (internal) |++**Examples:**+- `feat: add /om-review command`+- `fix: classify-message crash on empty input`+- `docs: update Japanese README with new commands`++**Bad examples:**+- `Feat/rename commands om prefix` — wrong format, casing+- `Update Skills.md` — missing type prefix+- `fix bug` — missing colon and description+## Template Development ChecklistWhen adding or modifying commands, agents, hooks, or vault structure, **all of these files must stay in sync**:| File | What to update ||------|---------------|-| `CLAUDE.md` | Command table, agent table, vault structure table, counts (commands/agents), root files rule |-| `README.md` | Command table, agent table, vault structure diagram, counts, relevant sections |-| `brain/Skills.md` | Command tables (by category), subagents table, usage notes, workflows if affected |-| `CHANGELOG.md` | New version entry at top with Added/Changed/Fixed sections |-| `vault-manifest.json` | Version number, infrastructure globs, scaffold paths, frontmatter schemas, version fingerprints |-| `bases/*.base` | If new properties or note types are added, update relevant Base views |--## Before Creating a PR--- Counts match everywhere (commands, agents)-- New command/agent appears in ALL tables (CLAUDE.md + README + Skills.md)-- `vault-manifest.json` version is bumped-- CHANGELOG has the new version entry-- All infrastructure paths in the manifest actually exist (`ls` each non-glob path)-- Examples use generic dates and names, not specific to any company or person+| `CLAUDE.md` | Command table, agent table, vault structure table, counts |+| `README.md` | Command table, agent table, vault structure diagram, counts |+| `README.ja.md`, `README.ko.md`, `README.zh-CN.md` | Same as README, in the respective language |+| `brain/Skills.md` | Command tables (by category), subagents table, workflows |+| `bases/*.base` | If new properties or note types are added |++## What NOT to Update++The release pipeline handles these automatically — **do not include in your PR**:++- `CHANGELOG.md` — auto-generated from commit messages on release+- `vault-manifest.json` version or released date — auto-bumped on release+- Version numbers in any file — the maintainer handles versioning++## Before Submitting++- [ ] PR title follows `type: description` format+- [ ] Counts match everywhere (commands, agents) if you added/removed any+- [ ] New command/agent appears in ALL doc tables (CLAUDE.md + README + Skills.md)+- [ ] Translations flagged if you changed README.md (maintainer can handle these)+- [ ] Tests pass: `python .claude/scripts/test_hooks.py`+- [ ] Examples use generic dates and names, not specific to any company or person++## Running Tests++```bash+python .claude/scripts/test_hooks.py -v+```++Tests run automatically on PRs that touch `.claude/scripts/`.++## Questions?++Open an issue or start a discussion. PRs are welcome without prior assignment — just open it.