docs: clarify properties prefix rule and add CLI/Bases prerequisites

obsidian-bases:
- Document the asymmetric prefix rule: in `properties:` config block,
  frontmatter keys must use `note.` prefix or `displayName` is silently
  ignored (column header shows raw field name). In `order`, `filters`,
  `groupBy`, `sort`, the bare form still works.
- Update Schema and Task Tracker / Reading List examples to show the
  `note.` prefix in `properties:` blocks.
- Add a Prerequisite note: Bases is a core plugin and may need to be
  enabled in `core-plugins.json` for vaults that predate v1.9.
- Add a Troubleshooting entry for the displayName-ignored symptom.

obsidian-cli:
- Add Prerequisites section: Obsidian on macOS has two version numbers
  (asar bundle auto-updates, installer does not). The in-app updater
  can report "latest" while installer is too old to ship the CLI
  binary. Document how to check the installer version and reinstall.
- Add health check command and a fallback path for environments where
  the CLI isn't available.

These are documentation-only changes informed by hands-on use that
hit both gotchas (displayName silently ignored, CLI missing despite
"latest version" prompt).
This commit is contained in:
黄松涛
2026-04-25 11:52:46 +08:00
parent fa1e131a01
commit a652d28755
2 changed files with 66 additions and 6 deletions
+30 -6
View File
@@ -5,6 +5,10 @@ description: Create and edit Obsidian Bases (.base files) with views, filters, f
# Obsidian Bases Skill # Obsidian Bases Skill
## Prerequisite
Bases is a **core plugin** introduced in Obsidian v1.9, but it is **not always enabled by default** — particularly in vaults that predate v1.9. If `.base` files don't appear in the file tree or won't render, check that `.obsidian/core-plugins.json` contains `"bases": true`. Enable via Settings → Core plugins → Bases, or edit the JSON and reload the vault.
## Workflow ## Workflow
1. **Create the file**: Create a `.base` file in the vault with valid YAML content 1. **Create the file**: Create a `.base` file in the vault with valid YAML content
@@ -31,13 +35,15 @@ filters:
formulas: formulas:
formula_name: 'expression' formula_name: 'expression'
# Configure display names and settings for properties # Configure display names and settings for properties.
# IMPORTANT: keys in this section must use their fully-qualified form.
# Frontmatter properties need the `note.` prefix or the displayName is silently ignored.
properties: properties:
property_name: note.property_name: # frontmatter property — MUST prefix with `note.`
displayName: "Display Name" displayName: "Display Name"
formula.formula_name: formula.formula_name: # formula reference — already prefixed
displayName: "Formula Display Name" displayName: "Formula Display Name"
file.ext: file.ext: # file property — already prefixed
displayName: "Extension" displayName: "Extension"
# Define custom summary formulas # Define custom summary formulas
@@ -123,6 +129,8 @@ filters:
2. **File properties** - File metadata: `file.name`, `file.mtime`, etc. 2. **File properties** - File metadata: `file.name`, `file.mtime`, etc.
3. **Formula properties** - Computed values: `formula.my_formula` 3. **Formula properties** - Computed values: `formula.my_formula`
**Asymmetric prefix rule**: in `order`, `filters`, `groupBy`, and `sort`, a frontmatter property can be referenced bare (`author`) or prefixed (`note.author`). But in the top-level `properties:` configuration block (where `displayName` is set), frontmatter keys **must** use the `note.` prefix — bare keys are silently ignored and the raw field name will appear as the column header. See Troubleshooting for the symptom.
### File Properties Reference ### File Properties Reference
| Property | Type | Description | | Property | Type | Description |
@@ -302,7 +310,7 @@ formulas:
priority_label: 'if(priority == 1, "🔴 High", if(priority == 2, "🟡 Medium", "🟢 Low"))' priority_label: 'if(priority == 1, "🔴 High", if(priority == 2, "🟡 Medium", "🟢 Low"))'
properties: properties:
status: note.status:
displayName: Status displayName: Status
formula.days_until_due: formula.days_until_due:
displayName: "Days Until Due" displayName: "Days Until Due"
@@ -351,7 +359,7 @@ formulas:
year_read: 'if(finished_date, date(finished_date).year, "")' year_read: 'if(finished_date, date(finished_date).year, "")'
properties: properties:
author: note.author:
displayName: Author displayName: Author
formula.status_icon: formula.status_icon:
displayName: "" displayName: ""
@@ -476,6 +484,22 @@ formulas:
'if(due_date, (date(due_date) - today()).days, "")' 'if(due_date, (date(due_date) - today()).days, "")'
``` ```
**`displayName` ignored / column shows raw field name**: in the `properties:` configuration block, frontmatter keys must be prefixed with `note.`. Bare keys are silently ignored.
```yaml
# WRONG - displayName ignored, column header shows "status"
properties:
status:
displayName: Status
# CORRECT - column header shows "Status"
properties:
note.status:
displayName: Status
```
This asymmetry trips users up because `order`, `filters`, and `groupBy` all accept the bare form. The `properties:` block is the exception.
**Referencing undefined formulas**: Ensure every `formula.X` in `order` or `properties` has a matching entry in `formulas`. **Referencing undefined formulas**: Ensure every `formula.X` in `order` or `properties` has a matching entry in `formulas`.
```yaml ```yaml
+36
View File
@@ -7,6 +7,42 @@ description: Interact with Obsidian vaults using the Obsidian CLI to read, creat
Use the `obsidian` CLI to interact with a running Obsidian instance. Requires Obsidian to be open. Use the `obsidian` CLI to interact with a running Obsidian instance. Requires Obsidian to be open.
## Prerequisites
The `obsidian` binary ships with the **installer**, not with the auto-updated asar bundle. If `which obsidian` returns nothing, the user is most likely missing one of these:
1. **Installer is too old.** Obsidian on macOS has two version numbers: the asar bundle (shown in Settings → About) auto-updates, but the installer at `/Applications/Obsidian.app` does **not**. The in-app "check for updates" only covers the asar — it can report "you are on the latest version" while the installer is multiple versions behind. CLI binary requires installer ≥ 1.10. Check via:
```bash
defaults read /Applications/Obsidian.app/Contents/Info.plist CFBundleShortVersionString
```
If old, download the latest from <https://obsidian.md/download> and reinstall (vault data is unaffected).
2. **CLI not enabled.** Settings → General → Advanced → toggle "Enable command line interface" ON. This installs the shim to `/usr/local/bin/`.
3. **PATH not refreshed.** Open a new terminal after enabling.
### Health check
```bash
which obsidian \
&& obsidian vault \
&& obsidian dev:screenshot path=/tmp/obs.png
```
If all three succeed, the CLI is ready.
### Fallback when CLI is unavailable
When the CLI cannot be installed (older Obsidian, restricted host, etc.), most vault operations are still doable via direct file access:
- Read / edit notes: read or edit the `.md` file directly
- Toggle core plugins: edit `.obsidian/core-plugins.json` and ask the user to reload (`Cmd+P → Reload app without saving`)
- Open a file: `open "obsidian://open?vault=<name>&file=<url-encoded-path>"`
Note: direct file edits won't trigger Obsidian's index refresh until the vault reloads.
## Command reference ## Command reference
Run `obsidian help` to see all available commands. This is always up to date. Full docs: https://help.obsidian.md/cli Run `obsidian help` to see all available commands. This is always up to date. Full docs: https://help.obsidian.md/cli