mirror of
https://github.com/Ar9av/obsidian-wiki.git
synced 2026-09-14 20:36:34 +08:00
77d74e0261
* feat(config): resolve global config from an XDG-style location (#172) The global config lived at ~/.obsidian-wiki, which isn't XDG-compliant. It now resolves to $XDG_CONFIG_HOME/obsidian-wiki (default ~/.config/obsidian-wiki). Existing installs are unaffected: if ~/.obsidian-wiki is present and the XDG path is not, the legacy directory is used as-is. No migration is required, and nothing moves on upgrade. Once the XDG path exists it wins, so `mv ~/.obsidian-wiki ~/.config/obsidian-wiki` is all a migration takes. Resolution is implemented identically in Python (cli.py), bash (setup.sh, scripts/daily-update.sh, scripts/wiki-notify.sh), and the Config Resolution Protocol that every skill defers to, so vault-scoped state and named `config.<name>` profiles stay in one place. * fix(config): stop setup from wiping user-added config keys `write_config` rewrote the global config with only the three setup-managed keys, so every `obsidian-wiki setup` — including the one a pip upgrade prompts for — silently destroyed anything else in the file: OBSIDIAN_LINK_FORMAT, QMD_WIKI_COLLECTION, WIKI_SKIP_PROJECTS, sync settings, and comments. Setup now owns only OBSIDIAN_VAULT_PATH, OBSIDIAN_WIKI_REPO and OBSIDIAN_WIKI_VERSION, updating those in place and carrying every other line over untouched. Duplicate definitions of a managed key collapse to one. Predates the XDG change (same behavior on main) but is fixed here because this branch already touches config writing, and the XDG work makes re-running setup more likely. Also pins PYTHONPATH in both new test files so they exercise this checkout rather than whatever obsidian_wiki happens to be installed.
50 lines
1.9 KiB
Bash
50 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
# Source this from your shell rc file to get wiki freshness reminders on terminal open.
|
|
#
|
|
# Setup (shell-specific):
|
|
# zsh/bash: source /path/to/obsidian-wiki/scripts/wiki-notify.sh
|
|
# fish: bass source /path/to/obsidian-wiki/scripts/wiki-notify.sh
|
|
# (or copy _wiki_notify logic natively using fish syntax)
|
|
#
|
|
# State is vault-scoped under <global-config-dir>/state/<vault-id>/ — the
|
|
# global config dir is XDG-style (~/.config/obsidian-wiki by default), with
|
|
# the legacy ~/.obsidian-wiki honored if it already exists (see
|
|
# llm-wiki/SKILL.md Config Resolution Protocol).
|
|
# Multiple vaults are supported — all stale vaults are shown.
|
|
|
|
_wiki_notify() {
|
|
local xdg_dir="${XDG_CONFIG_HOME:-$HOME/.config}/obsidian-wiki"
|
|
local legacy_dir="$HOME/.obsidian-wiki"
|
|
local config_dir="$xdg_dir"
|
|
[[ -d "$legacy_dir" && ! -e "$xdg_dir" ]] && config_dir="$legacy_dir"
|
|
local state_base="$config_dir/state"
|
|
[[ -d "$state_base" ]] || return
|
|
|
|
local now age_s age_h stale last vault_path shown=0
|
|
|
|
now=$(date +%s)
|
|
|
|
# Iterate over all vault state dirs
|
|
for state_dir in "$state_base"/*/; do
|
|
[[ -f "$state_dir/.last_update" ]] || continue
|
|
|
|
last=$(cat "$state_dir/.last_update" 2>/dev/null || echo 0)
|
|
age_s=$(( now - last ))
|
|
|
|
# Only show if >20 hours stale
|
|
(( age_s > 72000 )) || continue
|
|
|
|
age_h=$(( age_s / 3600 ))
|
|
stale=$(cat "$state_dir/.pending_delta" 2>/dev/null || echo 0)
|
|
vault_path=$(cat "$state_dir/.vault_path" 2>/dev/null || echo "unknown vault")
|
|
|
|
echo "┌─ wiki: last synced ${age_h}h ago · ${vault_path##*/}$([ "$stale" -gt 0 ] && echo " · ${stale} source(s) have new content" || echo "")"
|
|
echo "│ /wiki-history-ingest claude sync Claude sessions"
|
|
echo "│ /wiki-status see full delta"
|
|
echo "└─ /memory-bridge diff compare tool memories"
|
|
shown=$(( shown + 1 ))
|
|
done
|
|
}
|
|
|
|
_wiki_notify
|