mcpField
O
obsidian-bases

obsidian-bases

github.com/oldwinter生産性1038 回インストール1 週間前に更新
リポジトリ

obsidian-bases について

Obsidian Bases Skill は、スキル対応エージェントが Obsidian の保管庫内のノートを動的に表示する YAML 形式の `.base` ファイルを作成・編集できるようにします。フィルター、数式、プロパティ、集計、テーブル・カード・リスト・マップ表示を扱います。

主な機能

  1. 01`.base` ファイルの作成と編集
  2. 02全体およびビュー別フィルターの定義
  3. 03数式プロパティの計算
  4. 04テーブル、カード、リスト、マップ表示の設定
  5. 05組み込み関数と集計の利用

活用シーン

  1. 01保管庫のノートを使った絞り込み式タスク管理
  2. 02計算フィールド付き読書リストの作成
  3. 03日付や数値プロパティによるノート集計

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/oldwinter/skills --skill obsidian-bases

インストール後、Claude Code で/obsidian-basesを入力して読み込まれたか確認します。

詳細

Obsidian Bases スキル

このスキルを使うと、スキル互換のエージェントが、ビュー、フィルター、数式、および関連するすべての設定を含む、有効な Obsidian Bases(.base)ファイルを作成および編集できます。

概要

Obsidian Bases は、Obsidian の保管庫内のノートを動的に表示するための、YAML ベースのファイルです。Base ファイルには、複数のビュー、グローバルフィルター、数式、プロパティ設定、カスタム集計を含めることができます。

ファイル形式

Base ファイルは .base 拡張子を使用し、有効な YAML を含みます。また、Markdown のコードブロックに埋め込むこともできます。

完全なスキーマ

# Global filters apply to ALL views in the base
filters:
  # Can be a single filter string
  # OR a recursive filter object with and/or/not
  and: []
  or: []
  not: []

# Define formula properties that can be used across all views
formulas:
  formula_name: 'expression'

# Configure display names and settings for properties
properties:
  property_name:
    displayName: "Display Name"
  formula.formula_name:
    displayName: "Formula Display Name"
  file.ext:
    displayName: "Extension"

# Define custom summary formulas
summaries:
  custom_summary_name: 'values.mean().round(3)'

# Define one or more views
views:
  - type: table | cards | list | map
    name: "View Name"
    limit: 10                    # Optional: limit results
    groupBy:                     # Optional: group results
      property: property_name
      direction: ASC | DESC
    filters:                     # View-specific filters
      and: []
    order:                       # Properties to display in order
      - file.name
      - property_name
      - formula.formula_name
    summaries:                   # Map properties to summary formulas
      property_name: Average

フィルター構文

フィルターを使って結果を絞り込みます。グローバルまたはビューごとに適用できます。

フィルター構造
# Single filter
filters: 'status == "done"'

# AND - all conditions must be true
filters:
  and:
    - 'status == "done"'
    - 'priority > 3'

# OR - any condition can be true
filters:
  or:
    - 'file.hasTag("book")'
    - 'file.hasTag("article")'

# NOT - exclude matching items
filters:
  not:
    - 'file.hasTag("archived")'

# Nested filters
filters:
  or:
    - file.hasTag("tag")
    - and:
        - file.hasTag("book")
        - file.hasLink("Textbook")
    - not:
        - file.hasTag("book")
        - file.inFolder("Required Reading")
フィルター演算子
演算子説明
==等しい
!=等しくない
>より大きい
<より小さい
>=以上
<=以下
&&論理積
||論理和
!論理否定

プロパティ

プロパティの3つの種類
  1. ノートプロパティ - フロントマターから取得します:note.author または単に author
  2. ファイルプロパティ - ファイルのメタデータです:file.name、file.mtime など
  3. 数式プロパティ - 計算値です:formula.my_formula
ファイルプロパティのリファレンス
プロパティ型説明
file.nameStringファイル名
file.basenameString拡張子を除いたファイル名
file.pathStringファイルへのフルパス
file.folderString親フォルダーのパス
file.extStringファイル拡張子
file.sizeNumberファイルサイズ(バイト)
file.ctimeDate作成日時
file.mtimeDate更新日時
file.tagsListファイル内のすべてのタグ
file.linksListファイル内の内部リンク
file.backlinksListこのファイルにリンクしているファイル
file.embedsListノート内の埋め込み
file.propertiesObjectすべてのフロントマタープロパティ
this キーワード
  • メインコンテンツ領域では、Base ファイル自体を指します
  • 埋め込まれている場合は、埋め込み元のファイルを指します
  • サイドバーでは、メインコンテンツ内のアクティブなファイルを指します

数式の構文

数式はプロパティから値を計算します。formulas セクションで定義します。

formulas:
  # Simple arithmetic
  total: "price * quantity"
  
  # Conditional logic
  status_icon: 'if(done, "✅", "⏳")'
  
  # String formatting
  formatted_price: 'if(price, price.toFixed(2) + " dollars")'
  
  # Date formatting
  created: 'file.ctime.format("YYYY-MM-DD")'
  
  # Complex expressions
  days_old: '((now() - file.ctime) / 86400000).round(0)'

関数のリファレンス

グローバル関数
関数シグネチャ説明
date()date(string): date文字列を日付に変換します。形式:YYYY-MM-DD HH:mm:ss
duration()duration(string): duration期間の文字列を解析します
now()now(): date現在の日時
today()today(): date今日の日付(時刻は 00:00:00)
if()if(condition, trueResult, falseResult?)条件分岐
min()min(n1, n2, ...): number最小の数値
max()max(n1, n2, ...): number最大の数値
number()number(any): number数値に変換します
link()link(path, display?): Linkリンクを作成します
list()list(element): Listまだリストでない場合、リストに変換します
file()file(path): fileファイルオブジェクトを取得します
image()image(path): imageレンダリング用の画像を作成します
icon()icon(name): icon名前で Lucide アイコンを指定します
html()html(string): htmlHTML としてレンダリングします
escapeHTML()escapeHTML(string): stringHTML 文字をエスケープします
任意の型に使える関数
関数シグネチャ説明
isTruthy()any.isTruthy(): booleanブール値に変換します
isType()any.isType(type): boolean型を確認します
toString()any.toString(): string文字列に変換します
日付関数とフィールド

フィールド: date.year, date.month, date.day, date.hour, date.minute, date.second, date.millisecond

関数シグネチャ説明
date()date.date(): date時刻部分を削除
format()date.format(string): stringMoment.js のパターンで書式設定
time()date.time(): string時刻を文字列として取得
relative()date.relative(): string人が読みやすい相対時間
isEmpty()date.isEmpty(): boolean日付では常に false
日付の演算
# Duration units: y/year/years, M/month/months, d/day/days, 
#                 w/week/weeks, h/hour/hours, m/minute/minutes, s/second/seconds

# Add/subtract durations
"date + \"1M\""           # Add 1 month
"date - \"2h\""           # Subtract 2 hours
"now() + \"1 day\""       # Tomorrow
"today() + \"7d\""        # A week from today

# Subtract dates for millisecond difference
"now() - file.ctime"

# Complex duration arithmetic
"now() + (duration('1d') * 2)"
文字列関数

フィールド: string.length

関数シグネチャ説明
contains()string.contains(value): boolean部分文字列を確認
containsAll()string.containsAll(...values): booleanすべての部分文字列が含まれる
containsAny()string.containsAny(...values): booleanいずれかの部分文字列が含まれる
startsWith()string.startsWith(query): booleanクエリで始まる
endsWith()string.endsWith(query): booleanクエリで終わる
isEmpty()string.isEmpty(): boolean空または存在しない
lower()string.lower(): string小文字に変換
title()string.title(): stringタイトルケースに変換
trim()string.trim(): string空白を削除
replace()string.replace(pattern, replacement): stringパターンを置換
repeat()string.repeat(count): string文字列を繰り返す
reverse()string.reverse(): string文字列を反転
slice()string.slice(start, end?): string部分文字列
split()string.split(separator, n?): listリストに分割
数値関数
関数シグネチャ説明
abs()number.abs(): number絶対値
ceil()number.ceil(): number切り上げ
floor()number.floor(): number切り捨て
round()number.round(digits?): number指定桁数に丸める
toFixed()number.toFixed(precision): string固定小数点表記
isEmpty()number.isEmpty(): boolean存在しない
リスト関数

フィールド: list.length

関数シグネチャ説明
contains()list.contains(value): boolean要素が存在する
containsAll()list.containsAll(...values): booleanすべての要素が存在する
containsAny()list.containsAny(...values): booleanいずれかの要素が存在する
filter()list.filter(expression): list条件でフィルタリング(value、index を使用)
map()list.map(expression): list要素を変換(value、index を使用)
reduce()list.reduce(expression, initial): any単一の値に集約(value、index、acc を使用)
flat()list.flat(): listネストされたリストを平坦化
join()list.join(separator): string文字列に結合
reverse()list.reverse(): list順序を反転
slice()list.slice(start, end?): listサブリスト
sort()list.sort(): list昇順に並べ替え
unique()list.unique(): list重複を削除
isEmpty()list.isEmpty(): boolean要素がない
ファイル関数
関数シグネチャ説明
asLink()file.asLink(display?): Linkリンクに変換
hasLink()file.hasLink(otherFile): booleanファイルへのリンクがある
hasTag()file.hasTag(...tags): booleanいずれかのタグを持つ
hasProperty()file.hasProperty(name): booleanプロパティを持つ
inFolder()file.inFolder(folder): booleanフォルダまたはサブフォルダ内にある
リンク関数
関数シグネチャ説明
asFile()link.asFile(): fileファイルオブジェクトを取得
linksTo()link.linksTo(file): booleanファイルへのリンクがある
オブジェクト関数
関数シグネチャ説明
isEmpty()object.isEmpty(): booleanプロパティがありません
keys()object.keys(): listキーの一覧
values()object.values(): list値の一覧
正規表現関数
関数シグネチャ説明
matches()regexp.matches(string): boolean一致するかどうかをテストします

ビューの種類

テーブルビュー
views:
  - type: table
    name: "My Table"
    order:
      - file.name
      - status
      - due_date
    summaries:
      price: Sum
      count: Average
カードビュー
views:
  - type: cards
    name: "Gallery"
    order:
      - file.name
      - cover_image
      - description
リストビュー
views:
  - type: list
    name: "Simple List"
    order:
      - file.name
      - status
マップビュー

緯度・経度のプロパティと Maps コミュニティプラグインが必要です。

views:
  - type: map
    name: "Locations"
    # Map-specific settings for lat/lng properties

デフォルトの集計数式

名前入力タイプ説明
Average数値算術平均
Min数値最小値
Max数値最大値
Sum数値すべての数値の合計
Range数値最大値 - 最小値
Median数値数学的な中央値
Stddev数値標準偏差
Earliest日付最も古い日付
Latest日付最も新しい日付
Range日付最新の日付 - 最も古い日付
Checkedブール値true の値の数
Uncheckedブール値false の値の数
Empty任意空の値の数
Filled任意空でない値の数
Unique任意一意な値の数

完全な例

タスクトラッカーのベース
filters:
  and:
    - file.hasTag("task")
    - 'file.ext == "md"'

formulas:
  days_until_due: 'if(due, ((date(due) - today()) / 86400000).round(0), "")'
  is_overdue: 'if(due, date(due) < today() && status != "done", false)'
  priority_label: 'if(priority == 1, "🔴 High", if(priority == 2, "🟡 Medium", "🟢 Low"))'

properties:
  status:
    displayName: Status
  formula.days_until_due:
    displayName: "Days Until Due"
  formula.priority_label:
    displayName: Priority

views:
  - type: table
    name: "Active Tasks"
    filters:
      and:
        - 'status != "done"'
    order:
      - file.name
      - status
      - formula.priority_label
      - due
      - formula.days_until_due
    groupBy:
      property: status
      direction: ASC
    summaries:
      formula.days_until_due: Average

  - type: table
    name: "Completed"
    filters:
      and:
        - 'status == "done"'
    order:
      - file.name
      - completed_date
読書リストのベース
filters:
  or:
    - file.hasTag("book")
    - file.hasTag("article")

formulas:
  reading_time: 'if(pages, (pages * 2).toString() + " min", "")'
  status_icon: 'if(status == "reading", "📖", if(status == "done", "✅", "📚"))'
  year_read: 'if(finished_date, date(finished_date).year, "")'

properties:
  author:
    displayName: Author
  formula.status_icon:
    displayName: ""
  formula.reading_time:
    displayName: "Est. Time"

views:
  - type: cards
    name: "Library"
    order:
      - cover
      - file.name
      - author
      - formula.status_icon
    filters:
      not:
        - 'status == "dropped"'

  - type: table
    name: "Reading List"
    filters:
      and:
        - 'status == "to-read"'
    order:
      - file.name
      - author
      - pages
      - formula.reading_time
プロジェクトノートのベース
filters:
  and:
    - file.inFolder("Projects")
    - 'file.ext == "md"'

formulas:
  last_updated: 'file.mtime.relative()'
  link_count: 'file.links.length'
  
summaries:
  avgLinks: 'values.filter(value.isType("number")).mean().round(1)'

properties:
  formula.last_updated:
    displayName: "Updated"
  formula.link_count:
    displayName: "Links"

views:
  - type: table
    name: "All Projects"
    order:
      - file.name
      - status
      - formula.last_updated
      - formula.link_count
    summaries:
      formula.link_count: avgLinks
    groupBy:
      property: status
      direction: ASC

  - type: list
    name: "Quick List"
    order:
      - file.name
      - status
デイリーノートのインデックス
filters:
  and:
    - file.inFolder("Daily Notes")
    - '/^\d{4}-\d{2}-\d{2}$/.matches(file.basename)'

formulas:
  word_estimate: '(file.size / 5).round(0)'
  day_of_week: 'date(file.basename).format("dddd")'

properties:
  formula.day_of_week:
    displayName: "Day"
  formula.word_estimate:
    displayName: "~Words"

views:
  - type: table
    name: "Recent Notes"
    limit: 30
    order:
      - file.name
      - formula.day_of_week
      - formula.word_estimate
      - file.mtime

ベースの埋め込み

Markdown ファイルに埋め込みます。

![[MyBase.base]]


![[MyBase.base#View Name]]

YAML の引用符のルール

  • 二重引用符を含む数式には一重引用符を使用します:'if(done, "Yes", "No")'
  • 単純な文字列には二重引用符を使用します:"My View Name"
  • 複雑な式では、入れ子になった引用符を適切にエスケープします

よく使われるパターン

タグで絞り込む
filters:
  and:
    - file.hasTag("project")
フォルダーで絞り込む
filters:
  and:
    - file.inFolder("Notes")
日付範囲で絞り込む
filters:
  and:
    - 'file.mtime > now() - "7d"'
プロパティ値で絞り込む
filters:
  and:
    - 'status == "active"'
    - 'priority >= 3'
複数の条件を組み合わせる
filters:
  or:
    - and:
        - file.hasTag("important")
        - 'status != "done"'
    - and:
        - 'priority == 1'
        - 'due != ""'

参考資料

コメント