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/bases_ops.py

View on GitHub
"""
bases_ops.py (CLI)
=====================================

Purpose:
    Read and manipulate Obsidian Bases (.base) files.
    These YAML-based files define database-like views (tables, cards, grids) over vault notes.
    This module handles row appending, cell updates, and view config preservation.

Layer: Core Operations

Usage Examples:
    pythonbases_ops.py read --file example.base
    pythonbases_ops.py append-row --file example.base --data key1=value1 key2=value2
    pythonbases_ops.py update-cell --file example.base --row-index 0 --column Title --value "New Title"

Supported Object Types:
    - .base (YAML layouts)

CLI Arguments:
    Subcommands: read, append-row, update-cell. Run with --help for details.

Input Files:
    - .base files.

Output:
    - JSON results or modified .base files.

Key Functions:
    read_base(): Read and parse a .base file.
    append_row(): Append a new row to a .base file.
    update_cell(): Update a specific cell in a .base file.

Script Dependencies:
    sys, json, argparse, pathlib, ruamel.yaml

Consumed by:
    - obsidian-bases-manager skill
"""
import sys
import json
import argparse
from pathlib import Path
from typing import Dict, Any, List, Optional

try:
    from ruamel.yaml import YAML
    _yaml = YAML()
    _yaml.preserve_quotes = True
    _yaml.default_flow_style = False
    HAS_RUAMEL = True
except ImportError:
    HAS_RUAMEL = False
    print("WARNING: ruamel.yaml required. Install: pip install ruamel.yaml", file=sys.stderr)


class BasesError(Exception):
    """Non-fatal error for bases operations. Reports cleanly instead of crashing."""
    pass


def read_base(filepath: Path) -> Dict[str, Any]:
    """Read and parse a .base file. Returns the parsed YAML structure."""
    if not HAS_RUAMEL:
        return {"error": "ruamel.yaml not installed"}

    if not filepath.exists():
        return {"error": f"File not found: {filepath}"}

    if not str(filepath).endswith('.base'):
        return {"error": f"Not a .base file: {filepath}"}

    try:
        from io import StringIO
        content = filepath.read_text(encoding='utf-8')
        data = _yaml.load(StringIO(content))

        if data is None:
            return {"error": "Empty or invalid .base file", "file": str(filepath)}

        result = {
            "file": str(filepath),
            "data": dict(data) if data else {},
        }

        # Extract row count if data has a recognizable structure
        if isinstance(data, dict):
            for key in ['rows', 'data', 'entries', 'items']:
                if key in data and isinstance(data[key], list):
                    result["row_count"] = len(data[key])
                    break

        return result

    except Exception as e:
        return {"error": f"YAML_PARSE_ERROR: {str(e)}", "file": str(filepath)}


def append_row(filepath: Path, row_data: Dict[str, Any]) -> Dict[str, Any]:
    """Append a new row to a .base file's data array."""
    if not HAS_RUAMEL:
        return {"error": "ruamel.yaml not installed"}

    if not filepath.exists():
        return {"error": f"File not found: {filepath}"}

    try:
        from io import StringIO
        content = filepath.read_text(encoding='utf-8')
        data = _yaml.load(StringIO(content))

        if data is None:
            return {"error": "Empty or invalid .base file"}

        # Find the data array (try common keys)
        data_key = None
        for key in ['rows', 'data', 'entries', 'items']:
            if key in data and isinstance(data[key], list):
                data_key = key
                break

        if data_key is None:
            # Create a 'rows' array if none exists
            data['rows'] = []
            data_key = 'rows'

        data[data_key].append(row_data)

        # Write back atomically
        stream = StringIO()
        _yaml.dump(data, stream)
        new_content = stream.getvalue()

        # Use atomic write from vault_ops
        tmp_path = filepath.parent / f"{filepath.name}.agent-tmp"
        import os
        tmp_path.write_text(new_content, encoding='utf-8')
        os.rename(str(tmp_path), str(filepath))

        return {"status": "row_appended", "file": str(filepath), "row_count": len(data[data_key])}

    except Exception as e:
        return {"error": f"APPEND_ERROR: {str(e)}", "file": str(filepath)}


def _find_data_array_key(data: Dict[str, Any]) -> Optional[str]:
    """Return the first present list-valued key among rows/data/entries/items, or None."""
    for key in ['rows', 'data', 'entries', 'items']:
        if key in data and isinstance(data[key], list):
            return key
    return None


def _write_base_atomic(filepath: Path, data: Dict[str, Any]) -> None:
    """Dump data as YAML and atomically replace filepath's contents."""
    from io import StringIO
    import os
    stream = StringIO()
    _yaml.dump(data, stream)
    tmp_path = filepath.parent / f"{filepath.name}.agent-tmp"
    tmp_path.write_text(stream.getvalue(), encoding='utf-8')
    os.rename(str(tmp_path), str(filepath))


def update_cell(filepath: Path, row_index: int, column: str, value: Any) -> Dict[str, Any]:
    """Update a specific cell in a .base file."""
    if not HAS_RUAMEL:
        return {"error": "ruamel.yaml not installed"}

    if not filepath.exists():
        return {"error": f"File not found: {filepath}"}

    try:
        from io import StringIO
        content = filepath.read_text(encoding='utf-8')
        data = _yaml.load(StringIO(content))

        if data is None:
            return {"error": "Empty or invalid .base file"}

        data_key = _find_data_array_key(data)
        if data_key is None:
            return {"error": "No data array found in .base file"}

        rows = data[data_key]
        if row_index < 0 or row_index >= len(rows):
            return {"error": f"Row index {row_index} out of range (0-{len(rows)-1})"}

        if not isinstance(rows[row_index], dict):
            return {"error": f"Row {row_index} is not a dict, cannot update cell"}

        old_value = rows[row_index].get(column, "<not set>")
        rows[row_index][column] = value

        _write_base_atomic(filepath, data)

        return {
            "status": "cell_updated",
            "file": str(filepath),
            "row": row_index,
            "column": column,
            "old_value": str(old_value),
            "new_value": str(value)
        }

    except Exception as e:
        return {"error": f"UPDATE_ERROR: {str(e)}", "file": str(filepath)}


def main() -> None:
    """Parse CLI subcommand args and dispatch to read_base/append_row/update_cell."""
    parser = argparse.ArgumentParser(description="Obsidian Bases Manager")
    subparsers = parser.add_subparsers(dest='command', help='Commands')

    read_p = subparsers.add_parser('read', help='Read a .base file')
    read_p.add_argument('--file', required=True)

    append_p = subparsers.add_parser('append-row', help='Append a row')
    append_p.add_argument('--file', required=True)
    append_p.add_argument('--data', nargs='+', required=True, help='key=value pairs')

    update_p = subparsers.add_parser('update-cell', help='Update a cell')
    update_p.add_argument('--file', required=True)
    update_p.add_argument('--row-index', type=int, required=True)
    update_p.add_argument('--column', required=True)
    update_p.add_argument('--value', required=True)

    args = parser.parse_args()

    if args.command == 'read':
        print(json.dumps(read_base(Path(args.file)), indent=2, default=str))
    elif args.command == 'append-row':
        row = {}
        for kv in args.data:
            k, v = kv.split('=', 1)
            row[k] = v
        print(json.dumps(append_row(Path(args.file), row), indent=2))
    elif args.command == 'update-cell':
        print(json.dumps(update_cell(Path(args.file), args.row_index, args.column, args.value), indent=2))
    else:
        parser.print_help()


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