shit_admin: 2026-08-13 12:41:21
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Steph Ango (@kepano)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,107 @@
|
||||
---
|
||||
name: obsidian-bases
|
||||
description: Create and edit Obsidian Bases (.base files) with valid YAML schemas, filters, formulas, properties, summaries, and views. Use for database-like Obsidian views or when the user mentions Bases, .base files, table/card/list views, filters, formulas, or summaries.
|
||||
license: MIT
|
||||
metadata:
|
||||
copilot-enabled-agents: claude, codex, opencode
|
||||
copilot-builtin-version: "1"
|
||||
copilot-upstream-revision: "a1dc48e68138490d522c04cbf5822214c6eb1202"
|
||||
---
|
||||
|
||||
# Obsidian Bases
|
||||
|
||||
## Workflow
|
||||
|
||||
1. Read the existing <code>.base</code> file before editing it.
|
||||
2. Define global scope with <code>filters</code>.
|
||||
3. Add computed values under <code>formulas</code> only when needed.
|
||||
4. Configure property display names and one or more views.
|
||||
5. Validate YAML, formula references, quoting, and date/duration operations.
|
||||
6. Open or query the Base in Obsidian when the CLI is available.
|
||||
|
||||
## Schema
|
||||
|
||||
~~~yaml
|
||||
filters:
|
||||
and:
|
||||
- 'file.ext == "md"'
|
||||
- 'status != "archived"'
|
||||
|
||||
formulas:
|
||||
days_until_due: 'if(due, (date(due) - today()).days, "")'
|
||||
|
||||
properties:
|
||||
status:
|
||||
displayName: Status
|
||||
formula.days_until_due:
|
||||
displayName: "Days Until Due"
|
||||
|
||||
summaries:
|
||||
mean_rounded: 'values.mean().round(2)'
|
||||
|
||||
views:
|
||||
- type: table
|
||||
name: Active
|
||||
limit: 50
|
||||
filters:
|
||||
and:
|
||||
- 'status != "done"'
|
||||
order:
|
||||
- file.name
|
||||
- status
|
||||
- formula.days_until_due
|
||||
groupBy:
|
||||
property: status
|
||||
direction: ASC
|
||||
summaries:
|
||||
formula.days_until_due: Average
|
||||
~~~
|
||||
|
||||
Views may be <code>table</code>, <code>cards</code>, or <code>list</code>.
|
||||
A <code>map</code> view depends on compatible map support.
|
||||
|
||||
## Filters and properties
|
||||
|
||||
Filters may be a single expression or recursively nested <code>and</code>,
|
||||
<code>or</code>, and <code>not</code> objects. Property namespaces are:
|
||||
|
||||
- note properties: <code>status</code> or <code>note.status</code>
|
||||
- file metadata: <code>file.name</code>, <code>file.path</code>,
|
||||
<code>file.folder</code>, <code>file.ctime</code>, <code>file.mtime</code>,
|
||||
<code>file.tags</code>, <code>file.links</code>, and
|
||||
<code>file.backlinks</code>
|
||||
- formulas: <code>formula.days_until_due</code>
|
||||
|
||||
Use <code>file.hasTag()</code>, <code>file.hasLink()</code>,
|
||||
<code>file.hasProperty()</code>, and <code>file.inFolder()</code> for indexed
|
||||
file relationships. The <code>this</code> value refers to the Base itself, the
|
||||
embedding note, or the active file depending on where the Base is rendered.
|
||||
|
||||
## Formula rules
|
||||
|
||||
- Guard optional properties with <code>if()</code>.
|
||||
- Date subtraction returns a Duration, not a number. Access
|
||||
<code>.days</code>, <code>.hours</code>, or another numeric field before
|
||||
calling number methods such as <code>.round()</code>.
|
||||
- Every <code>formula.X</code> used by a view or property configuration must
|
||||
have a matching <code>X</code> entry under <code>formulas</code>.
|
||||
- Wrap formulas containing double quotes in YAML single quotes.
|
||||
- Quote YAML strings containing special characters, especially colons and
|
||||
leading punctuation.
|
||||
|
||||
Read [Functions reference](references/FUNCTIONS_REFERENCE.md) for function and
|
||||
type-specific operations, and [Examples](references/EXAMPLES.md) for complete
|
||||
task-tracker and daily-notes Bases.
|
||||
|
||||
## Validation checklist
|
||||
|
||||
- The document parses as YAML and has a <code>views</code> list.
|
||||
- View <code>order</code>, <code>groupBy</code>, and summaries reference defined
|
||||
note, file, or formula properties.
|
||||
- Formula quoting is balanced and duration math accesses a numeric field.
|
||||
- Embedded view names match exactly: <code>![[My Base.base#View Name]]</code>.
|
||||
|
||||
## Attribution
|
||||
|
||||
Adapted from <code>kepano/obsidian-skills</code> at revision
|
||||
<code>a1dc48e68138490d522c04cbf5822214c6eb1202</code>. See <code>LICENSE</code>.
|
||||
@@ -0,0 +1,56 @@
|
||||
# Bases examples
|
||||
|
||||
## Task tracker
|
||||
|
||||
~~~yaml
|
||||
filters:
|
||||
and:
|
||||
- file.hasTag("task")
|
||||
- 'file.ext == "md"'
|
||||
|
||||
formulas:
|
||||
days_until_due: 'if(due, (date(due) - today()).days, "")'
|
||||
is_overdue: 'if(due, date(due) < today() && status != "done", false)'
|
||||
|
||||
properties:
|
||||
formula.days_until_due:
|
||||
displayName: "Days Until Due"
|
||||
|
||||
views:
|
||||
- type: table
|
||||
name: Active
|
||||
filters:
|
||||
and:
|
||||
- 'status != "done"'
|
||||
order:
|
||||
- file.name
|
||||
- status
|
||||
- due
|
||||
- formula.days_until_due
|
||||
groupBy:
|
||||
property: status
|
||||
direction: ASC
|
||||
~~~
|
||||
|
||||
## Daily notes index
|
||||
|
||||
~~~yaml
|
||||
filters:
|
||||
and:
|
||||
- file.inFolder("Daily Notes")
|
||||
- '/^\d{4}-\d{2}-\d{2}$/.matches(file.basename)'
|
||||
|
||||
formulas:
|
||||
day_of_week: 'date(file.basename).format("dddd")'
|
||||
word_estimate: '(file.size / 5).round(0)'
|
||||
|
||||
views:
|
||||
- type: table
|
||||
name: Recent notes
|
||||
limit: 30
|
||||
order:
|
||||
- file.name
|
||||
- formula.day_of_week
|
||||
- formula.word_estimate
|
||||
- file.mtime
|
||||
~~~
|
||||
@@ -0,0 +1,41 @@
|
||||
# Bases functions reference
|
||||
|
||||
## Global functions
|
||||
|
||||
| Function | Purpose |
|
||||
| --- | --- |
|
||||
| <code>date(value)</code> | Parse a date string |
|
||||
| <code>duration(value)</code> | Parse a duration string |
|
||||
| <code>now()</code> / <code>today()</code> | Current date-time / date |
|
||||
| <code>if(condition, yes, no?)</code> | Conditional value |
|
||||
| <code>number(value)</code> | Convert to number |
|
||||
| <code>link(path, display?)</code> | Create a link |
|
||||
| <code>file(path)</code> | Resolve a file object |
|
||||
| <code>list(value)</code> | Normalize a value to a list |
|
||||
| <code>image(path)</code> / <code>icon(name)</code> | Create renderable values |
|
||||
|
||||
## Common methods
|
||||
|
||||
- String: <code>contains</code>, <code>startsWith</code>, <code>endsWith</code>,
|
||||
<code>lower</code>, <code>trim</code>, <code>replace</code>,
|
||||
<code>split</code>, <code>isEmpty</code>.
|
||||
- Number: <code>abs</code>, <code>ceil</code>, <code>floor</code>,
|
||||
<code>round</code>, <code>toFixed</code>.
|
||||
- List: <code>contains</code>, <code>containsAll</code>,
|
||||
<code>containsAny</code>, <code>filter</code>, <code>map</code>,
|
||||
<code>reduce</code>, <code>flat</code>, <code>join</code>,
|
||||
<code>sort</code>, <code>unique</code>.
|
||||
- File: <code>asLink</code>, <code>hasLink</code>, <code>hasTag</code>,
|
||||
<code>hasProperty</code>, <code>inFolder</code>.
|
||||
- Link: <code>asFile</code>, <code>linksTo</code>.
|
||||
- Object: <code>keys</code>, <code>values</code>, <code>isEmpty</code>.
|
||||
- Regular expression: <code>matches</code>.
|
||||
|
||||
Date fields include <code>year</code>, <code>month</code>, <code>day</code>,
|
||||
<code>hour</code>, <code>minute</code>, and <code>second</code>. Date methods
|
||||
include <code>date()</code>, <code>format()</code>, <code>time()</code>, and
|
||||
<code>relative()</code>.
|
||||
|
||||
Duration fields are <code>days</code>, <code>hours</code>,
|
||||
<code>minutes</code>, <code>seconds</code>, and <code>milliseconds</code>.
|
||||
Duration does not directly support number rounding methods.
|
||||
Reference in New Issue
Block a user