mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
* chore(test-vault): tag deployed manifest with branch + build timestamp `npm run test:vault` now writes a real `manifest.json` (instead of a symlink to the worktree copy) with the current git branch and a `yyyymmdd-HHMMSS` build timestamp appended to `name` and prepended to `description`. Surfaces the active worktree/build directly in Obsidian's Community plugins list, so "is my latest build actually loaded?" is a glance instead of a guess. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(chain): stop writing chainType back inside setChain (apply-Plus freeze) Applying a Copilot Plus license key froze Obsidian. Root cause: ChainManager ran multiple concurrent `createChainWithNewModel` invocations (one from the constructor's `initialize()`, plus one each from the settings, model-key, and chain-type subscribers firing on `applyPlusSettings`). Each captured `chainType = getChainType()` at its start, awaited `setChatModel(...)`, then resumed with a now-stale local value and wrote it back to `chainTypeAtom` via `setChain` → `setChainType`. The write re-fired the chain-type subscriber in ProjectManager, which scheduled another stale-closure rebuild, and the atom bounced indefinitely between `LLM_CHAIN` and `COPILOT_PLUS_CHAIN`. Inlined `setChain` into `createChainWithNewModel` and removed the redundant chainType write-back. The atom is owned by the UI dropdowns and `applyPlusSettings`; this function only reads from it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(chain): fix outdated comment reference to removed test file Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
91 lines
3 KiB
Bash
Executable file
91 lines
3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
OBSIDIAN_BIN="/Applications/Obsidian.app/Contents/MacOS/obsidian"
|
|
|
|
if [[ -z "${COPILOT_TEST_VAULT_PATH:-}" ]]; then
|
|
cat >&2 <<'EOF'
|
|
error: COPILOT_TEST_VAULT_PATH is not set.
|
|
|
|
Set it once at the user level (e.g. in ~/.zshrc or ~/.config/fish/config.fish)
|
|
to the absolute path of an Obsidian vault you've opened at least once:
|
|
|
|
export COPILOT_TEST_VAULT_PATH="$HOME/Obsidian/CopilotTestVault"
|
|
|
|
Then re-run: npm run test:vault
|
|
EOF
|
|
exit 1
|
|
fi
|
|
|
|
VAULT_PATH="$COPILOT_TEST_VAULT_PATH"
|
|
|
|
if [[ ! -d "$VAULT_PATH" ]]; then
|
|
echo "error: vault directory not found: $VAULT_PATH" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -d "$VAULT_PATH/.obsidian" ]]; then
|
|
echo "error: $VAULT_PATH has no .obsidian/ folder." >&2
|
|
echo "Open the folder as a vault in Obsidian once, then re-run." >&2
|
|
exit 1
|
|
fi
|
|
|
|
WORKTREE_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$WORKTREE_ROOT"
|
|
|
|
echo "==> Installing dependencies"
|
|
npm install --prefer-offline --no-audit --no-fund
|
|
|
|
echo "==> Building plugin"
|
|
npm run build
|
|
|
|
PLUGIN_ID="$(node -p "require('./manifest.json').id")"
|
|
if [[ -z "$PLUGIN_ID" ]]; then
|
|
echo "error: could not read plugin id from manifest.json" >&2
|
|
exit 1
|
|
fi
|
|
|
|
PLUGIN_DIR="$VAULT_PATH/.obsidian/plugins/$PLUGIN_ID"
|
|
mkdir -p "$PLUGIN_DIR"
|
|
|
|
echo "==> Linking artifacts into $PLUGIN_DIR"
|
|
for f in main.js styles.css; do
|
|
if [[ ! -f "$WORKTREE_ROOT/$f" ]]; then
|
|
echo "error: expected build artifact missing: $WORKTREE_ROOT/$f" >&2
|
|
exit 1
|
|
fi
|
|
ln -sfn "$WORKTREE_ROOT/$f" "$PLUGIN_DIR/$f"
|
|
done
|
|
|
|
# Write a branch- and timestamp-tagged manifest.json (real file, not a symlink)
|
|
# so Obsidian's Community plugins list visibly reflects which worktree/branch
|
|
# is loaded and when this build was deployed.
|
|
BRANCH="$(git -C "$WORKTREE_ROOT" rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"
|
|
BUILD_TS="$(date +%Y%m%d-%H%M%S)"
|
|
echo "==> Writing branch-tagged manifest.json (branch: $BRANCH, build: $BUILD_TS)"
|
|
rm -f "$PLUGIN_DIR/manifest.json"
|
|
SRC="$WORKTREE_ROOT/manifest.json" DEST="$PLUGIN_DIR/manifest.json" BRANCH="$BRANCH" BUILD_TS="$BUILD_TS" node -e '
|
|
const fs = require("fs");
|
|
const m = JSON.parse(fs.readFileSync(process.env.SRC, "utf8"));
|
|
m.name = m.name + " [" + process.env.BRANCH + " @ " + process.env.BUILD_TS + "]";
|
|
m.description = "[branch: " + process.env.BRANCH + " | build: " + process.env.BUILD_TS + "] " + m.description;
|
|
fs.writeFileSync(process.env.DEST, JSON.stringify(m, null, 2) + "\n");
|
|
'
|
|
|
|
echo "==> Reloading plugin in Obsidian"
|
|
if [[ ! -x "$OBSIDIAN_BIN" ]]; then
|
|
echo "warning: Obsidian CLI not found at $OBSIDIAN_BIN; skipping reload." >&2
|
|
else
|
|
if ! "$OBSIDIAN_BIN" plugin:enable id="$PLUGIN_ID" >/dev/null 2>&1 \
|
|
|| ! "$OBSIDIAN_BIN" plugin:reload id="$PLUGIN_ID" >/dev/null 2>&1; then
|
|
echo "warning: Obsidian doesn't appear to be running. Start it and the symlinked plugin will load on next open." >&2
|
|
fi
|
|
fi
|
|
|
|
echo
|
|
echo "Done."
|
|
echo " worktree: $WORKTREE_ROOT"
|
|
echo " branch: $BRANCH"
|
|
echo " build: $BUILD_TS"
|
|
echo " vault: $VAULT_PATH"
|
|
echo " plugin: $PLUGIN_ID"
|