Skip to content

richfrem/agent-plugins-skills / plugins/agent-memory/.apm/skills/managing-obsidian-vaults

managing-obsidian-vaults

Verified

Interactive vault, wiki and Super-RAG setup in the main conversation. Use for "set up my wiki", "initialize the full knowledge stack" or combined RLM/vector/wiki setup. Manage Obsidian vaults and LLM wikis: initialize vaults, author Markdown and wikilinks, safely edit notes and Bases, create Canvas diagrams, traverse graphs, build concept wikis, distill summary/bullets/deep layers, query and lint knowledge.

FileKindSize
SKILL.mdskill md5.9 KB
assets/templates/config.yaml.templateother556 B
assets/templates/raw-sources.json.exampleother862 B
assets/templates/wiki-node.template.mdmarkdown410 B
evals/README.mdmarkdown569 B
evals/evals.jsonconfig23.4 KB
evals/legacy/obsidian-bases-manager/evals.jsonconfig692 B
evals/legacy/obsidian-bases-manager/results.tsvother301 B
evals/legacy/obsidian-canvas-architect/evals.jsonconfig731 B
evals/legacy/obsidian-canvas-architect/results.tsvother301 B
evals/legacy/obsidian-graph-traversal/evals.jsonconfig706 B
evals/legacy/obsidian-graph-traversal/results.tsvother301 B
evals/legacy/obsidian-init/evals.jsonconfig667 B
evals/legacy/obsidian-init/results.tsvother301 B
evals/legacy/obsidian-markdown-mastery/evals.jsonconfig652 B
evals/legacy/obsidian-markdown-mastery/results.tsvother301 B
evals/legacy/obsidian-query-agent/evals.jsonconfig767 B
evals/legacy/obsidian-rlm-distiller/evals.jsonconfig685 B
evals/legacy/obsidian-vault-crud/evals.jsonconfig638 B
evals/legacy/obsidian-vault-crud/results.tsvother301 B
evals/legacy/obsidian-wiki-builder/evals.jsonconfig732 B
evals/legacy/obsidian-wiki-linter/evals.jsonconfig1.5 KB
evals/results.tsvother73 B
evals/task-success.jsonconfig3.5 KB
references/acceptance-criteria.mdmarkdown2.9 KB
references/architecture-background.mdmarkdown2.8 KB
references/dependencies.mdmarkdown1.7 KB
references/interactive-setup.mdmarkdown7.0 KB
references/interactive-stack-setup.mdmarkdown5.6 KB
references/kepano-analysis-summary.mdmarkdown1.7 KB
references/obsidian-bases-manager-acceptance-criteria.mdmarkdown628 B
references/obsidian-bases-manager-fallback-tree.mdmarkdown787 B
references/obsidian-bases-manager.mdmarkdown2.1 KB
references/obsidian-canvas-architect-acceptance-criteria.mdmarkdown645 B
references/obsidian-canvas-architect-fallback-tree.mdmarkdown836 B
references/obsidian-canvas-architect.mdmarkdown1.9 KB
references/obsidian-graph-traversal-acceptance-criteria.mdmarkdown690 B
references/obsidian-graph-traversal-fallback-tree.mdmarkdown877 B
references/obsidian-graph-traversal.mdmarkdown2.2 KB
references/obsidian-init-acceptance-criteria.mdmarkdown650 B
references/obsidian-init-fallback-tree.mdmarkdown1.1 KB
references/obsidian-init.mdmarkdown2.0 KB
references/obsidian-markdown-mastery-acceptance-criteria.mdmarkdown700 B
references/obsidian-markdown-mastery-fallback-tree.mdmarkdown889 B
references/obsidian-markdown-mastery.mdmarkdown2.2 KB
references/obsidian-query-agent.mdmarkdown1.8 KB
references/obsidian-rlm-distiller.mdmarkdown1.8 KB
references/obsidian-vault-crud-acceptance-criteria.mdmarkdown833 B
references/obsidian-vault-crud-fallback-tree.mdmarkdown1.1 KB
references/obsidian-vault-crud.mdmarkdown2.2 KB
references/obsidian-vault-onboarding-guide.mdmarkdown3.7 KB
references/obsidian-wiki-builder.mdmarkdown1.8 KB
references/obsidian-wiki-linter.mdmarkdown1.7 KB
references/resource-index.mdmarkdown4.3 KB
references/safety-learnings.mdmarkdown2.7 KB
references/wiki-builder-guide.mdmarkdown2.7 KB
references/wiki-distillation-guide.mdmarkdown1.7 KB
references/wiki-linting-guide.mdmarkdown2.1 KB
references/wiki-query-guide.mdmarkdown2.1 KB
requirements.inother32 B
requirements.txtmanifest463 B
scripts/audit.pyscript9.0 KB
scripts/bases_ops.pyscript7.8 KB
scripts/canvas_gen.pyscript7.9 KB
scripts/canvas_ops.pyscript11.5 KB
scripts/concept_extractor.pyscript10.2 KB
scripts/constants.pyscript908 B
scripts/distill_wiki.pyscript12.9 KB
scripts/graph_ops.pyscript11.7 KB
scripts/ingest.pyscript8.3 KB
scripts/init_vault.pyscript5.7 KB
scripts/lint_wiki.pyscript9.3 KB
scripts/obsidian-parser/parser.pyscript6.5 KB
scripts/obsidian-parser/tests/test_parser.pyscript4.1 KB
scripts/query_wiki.pyscript21.3 KB
scripts/raw_manifest.pyscript14.3 KB
scripts/vault_ops.pyscript13.4 KB
scripts/wiki_builder.pyscript14.3 KB

scripts/canvas_gen.py

View on GitHub
#!/usr/bin/env python
"""
canvas_gen.py
=====================================

Purpose:
    Auto-generate Obsidian Canvas (.canvas) files from wiki concept clusters.
    Creates one canvas per cluster showing concepts as nodes with edges
    representing wikilink relationships.

Layer: Visualize / Wiki

Usage:
    python ./scripts/canvas_gen.py --wiki-root /path/to/wiki-root
    python ./scripts/canvas_gen.py --wiki-root /path/to/wiki-root --cluster arch-docs
    python ./scripts/canvas_gen.py --wiki-root /path/to/wiki-root --output /path/to/output.canvas

Related:
    - wiki_builder.py  (generates the wiki nodes this script reads)
    - raw_manifest.py  (wiki root resolution)
    - obsidian-canvas-architect skill (manual canvas editing)

Key Input Dependencies:
    - {wiki_root}/wiki/*.md nodes with a 'cluster:' frontmatter field
"""
import sys
import json
import argparse
import re
import math
from pathlib import Path
from typing import Dict, List, Any, Optional, Set

SCRIPT_DIR = Path(__file__).resolve().parent
if str(SCRIPT_DIR) not in sys.path:
    sys.path.insert(0, str(SCRIPT_DIR))

from raw_manifest import WikiSourceConfig

NODE_WIDTH = 250
NODE_HEIGHT = 80
CLUSTER_RADIUS_BASE = 400
WIKILINK_PATTERN = re.compile(r"\[\[([^\]|#]+)")


def _extract_wikilinks(node_content: str) -> Set[str]:
    """
    Extract all [[wikilink]] targets from a wiki node file.

    Args:
        node_content: Raw markdown content of the wiki node.

    Returns:
        Set of linked concept slugs.
    """
    return {m.group(1).strip() for m in WIKILINK_PATTERN.finditer(node_content)}


def _layout_circle(concepts: List[str], center_x: int = 0, center_y: int = 0) -> Dict[str, tuple]:
    """
    Arrange concept nodes in a circle for a cluster canvas.

    Args:
        concepts:  List of concept slugs.
        center_x:  Canvas center X coordinate.
        center_y:  Canvas center Y coordinate.

    Returns:
        Dict mapping concept -> (x, y) position.
    """
    n = len(concepts)
    if n == 0:
        return {}
    radius = max(CLUSTER_RADIUS_BASE, n * 60)
    positions: Dict[str, tuple] = {}
    for i, concept in enumerate(concepts):
        angle = (2 * math.pi * i) / n
        x = int(center_x + radius * math.cos(angle))
        y = int(center_y + radius * math.sin(angle))
        positions[concept] = (x, y)
    return positions


def _build_title_node(cluster_name: str) -> Dict[str, Any]:
    """Build the center title node for a cluster canvas."""
    return {
        "id": f"_title_{cluster_name}",
        "type": "text",
        "text": f"# {cluster_name.replace('-', ' ').title()}",
        "x": -NODE_WIDTH // 2,
        "y": -NODE_HEIGHT // 2,
        "width": NODE_WIDTH,
        "height": NODE_HEIGHT,
        "color": "1",
    }


def _build_concept_node(node_id: str, concept: str, x: int, y: int, node_file: Path, wiki_root: Path) -> Dict[str, Any]:
    """Build a canvas node for one concept: a file-reference node if the wiki file exists, else a text node."""
    base = {"id": node_id, "x": x, "y": y, "width": NODE_WIDTH, "height": NODE_HEIGHT}
    if node_file.exists():
        return {**base, "type": "file", "file": str(node_file.relative_to(wiki_root)).replace("\\", "/")}
    return {**base, "type": "text", "text": concept}


def _build_concept_edges(
    concept: str, node_id: str, node_file: Path, concept_set: Set[str], edge_set: Set[tuple]
) -> List[Dict[str, Any]]:
    """Extract wikilinks from node_file and build edge specs for links within concept_set, deduped via edge_set."""
    edges: List[Dict[str, Any]] = []
    if not node_file.exists():
        return edges
    try:
        content = node_file.read_text(encoding="utf-8")
    except Exception:
        return edges
    for link_target in _extract_wikilinks(content):
        if link_target in concept_set and link_target != concept:
            edge_key = tuple(sorted([concept, link_target]))
            if edge_key not in edge_set:
                edge_set.add(edge_key)
                edges.append({
                    "id": f"edge_{concept}_{link_target}",
                    "fromNode": node_id,
                    "fromSide": "right",
                    "toNode": f"node_{link_target}",
                    "toSide": "left",
                })
    return edges


def build_cluster_canvas(
    cluster_name: str,
    concepts: List[str],
    wiki_root: Path,
) -> Dict[str, Any]:
    """
    Build a JSON Canvas spec for one cluster of wiki concepts.

    Nodes represent concept wiki files. Edges represent wikilink relationships
    found in the wiki node content.

    Args:
        cluster_name: Name of the cluster (used as canvas title node).
        concepts:     List of concept slugs in this cluster.
        wiki_root:    Root of the wiki output directory.

    Returns:
        JSON Canvas spec dict (JSON Canvas Spec 1.0).
    """
    positions = _layout_circle(concepts)
    nodes: List[Dict[str, Any]] = [_build_title_node(cluster_name)]
    edges: List[Dict[str, Any]] = []
    concept_set = set(concepts)
    edge_set: Set[tuple] = set()

    for concept, (x, y) in positions.items():
        node_id = f"node_{concept}"
        node_file = wiki_root / "wiki" / f"{concept}.md"
        nodes.append(_build_concept_node(node_id, concept, x, y, node_file, wiki_root))
        edges.extend(_build_concept_edges(concept, node_id, node_file, concept_set, edge_set))

    return {"nodes": nodes, "edges": edges}


def _build_arg_parser() -> argparse.ArgumentParser:
    """Build the CLI argument parser for canvas_gen.py."""
    parser = argparse.ArgumentParser(
        description="Generate Obsidian Canvas files from wiki concept clusters"
    )
    parser.add_argument("--wiki-root", required=True, help="Path to the wiki root directory")
    parser.add_argument("--cluster", default=None, help="Generate canvas for one cluster only")
    parser.add_argument("--output", default=None,
                        help="Output path for canvas file (default: {wiki-root}/wiki/_{cluster}.canvas)")
    return parser


def _discover_clusters(wiki_dir: Path) -> Dict[str, List[str]]:
    """Scan wiki node frontmatter and group concept slugs by cluster name."""
    clusters: Dict[str, List[str]] = {}
    cluster_pattern = re.compile(r"^cluster:\s*(.+)$", re.MULTILINE)

    for node_file in sorted(wiki_dir.glob("*.md")):
        if node_file.name.startswith("_"):
            continue
        try:
            content = node_file.read_text(encoding="utf-8")
        except Exception:
            continue
        match = cluster_pattern.search(content)
        cluster_name = match.group(1).strip() if match else "unclustered"
        clusters.setdefault(cluster_name, []).append(node_file.stem)
    return clusters


def main() -> None:
    """Parse CLI arguments and generate canvas files for wiki clusters."""
    args = _build_arg_parser().parse_args()

    wiki_root = Path(args.wiki_root).resolve()
    wiki_dir = wiki_root / "wiki"

    if not wiki_dir.exists():
        print(f"[ERROR] Wiki directory not found: {wiki_dir}")
        print("        Run /wiki-ingest first.")
        sys.exit(1)

    clusters = _discover_clusters(wiki_dir)

    if not clusters:
        print("[WARN] No wiki nodes found. Run /wiki-ingest first.")
        return

    target_clusters = [args.cluster] if args.cluster else list(clusters.keys())

    for cluster_name in target_clusters:
        if cluster_name not in clusters:
            print(f"[WARN] Cluster '{cluster_name}' not found.")
            continue

        concepts = clusters[cluster_name]
        canvas_spec = build_cluster_canvas(cluster_name, concepts, wiki_root)

        if args.output and args.cluster:
            out_path = Path(args.output)
        else:
            out_path = wiki_dir / f"_{cluster_name}.canvas"

        out_path.parent.mkdir(parents=True, exist_ok=True)
        out_path.write_text(json.dumps(canvas_spec, indent=2), encoding="utf-8")
        print(f"[OK] Canvas written: {out_path} ({len(concepts)} nodes, {len(canvas_spec['edges'])} edges)")


if __name__ == "__main__":
    main()
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 194kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 194kUpdated Claude CodeCodexVerifiedInstall