@codewizard-dt/bootstrap 2.19.0 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/scripts/README.md +27 -18
- package/lib/scripts/bootstrap-prefs.js +18 -0
- package/lib/scripts/install-global.sh +19 -4
- package/lib/scripts/install-obsidian.sh +294 -0
- package/lib/scripts/lib.sh +17 -0
- package/lib/scripts/merge-gitignore.sh +152 -95
- package/lib/scripts/setup-deployment.sh +1 -1
- package/lib/scripts/sync-wiki-scaffold.sh +13 -6
- package/lib/scripts/templates/bootstrap-prefs-schema.json +32 -5
- package/lib/scripts/templates/file-suggestion.sh +13 -5
- package/lib/skills/bootstrap-config/SKILL.md +11 -5
- package/lib/skills/research/SKILL.md +24 -3
- package/lib/skills/task-add/SKILL.md +4 -0
- package/lib/skills/task-audit/SKILL.md +2 -0
- package/package.json +1 -1
- package/raw/guides/dataview-queries.md +66 -0
package/lib/scripts/README.md
CHANGED
|
@@ -25,10 +25,10 @@ All scripts use `set -euo pipefail`. Every script that touches a target project
|
|
|
25
25
|
| `sync-wiki-scaffold.sh` | `setup-project.sh`, `update-project.sh`, `migrate-project.sh` | Scaffolds an **empty** wiki into the target project from `templates/wiki/`: creates `raw/` + all `wiki/` family directories, lifecycle docs, per-family `index.md`, and stub `index.md`/`log.md`. Copy-once for project-owned files; always-refreshes `conventions.md` and `lifecycle.md`. Delivers guides from `raw/guides/` tier-wise into `wiki/guides/`: `command-anti-patterns.md` required (always refreshed); `evals-framework.md` + `type-checking-templates/` optional (`--interactive` prompts on first delivery, sticky refresh once present — legacy `.docs/guides/` presence counts, opt out by deleting); migrates legacy `.docs/guides/` (template-owned files removed or relocated, deprecated `task-spec.md` deleted, empty dirs pruned). Also delivers the `## LLM Wiki` section and `.env` safety policy (copy-once, sentinel-guarded, from `templates/CLAUDE-wiki.md` / `templates/CLAUDE-env-safety.md`) into the target's `CLAUDE.md` — when a `CLAUDE.md` already exists without the schema, prompts whether to modify it or write `CLAUDE.local.md` instead (non-interactive default: `CLAUDE.local.md`). |
|
|
26
26
|
| `build-mcp-guide.sh` | `setup-project.sh`, `update-project.sh`, `migrate-project.sh` | Assembles `wiki/guides/mcp-tools.md` in the target project from the per-server stub files in `templates/guides/stubs/`, including only the sections for MCPs actually installed. |
|
|
27
27
|
| `bootstrap-serena.sh` | `setup-project.sh`, `update-project.sh` | Headlessly triggers `.serena/project.yml` creation via `claude --print` and enables the optional Serena tools needed by this template's workflow. Preflights `claude` and `python3`. |
|
|
28
|
-
| `merge-gitignore.sh` | `setup-project.sh`, `update-project.sh` | Fully interactive `.gitignore` merge — **nothing is ever added without asking**. The packaged template's titled sections are offered one by one (`Add/update .gitignore section '<title>' (N new line(s))? [y/N]`); sections with nothing new are skipped silently. Non-interactive runs (or no tty) change nothing at all. Never touches existing project content. Also offers (git repos only) to keep `.serena/`/`raw/`/`wiki/` out of git via **`.git/info/exclude`** — never `.gitignore`, which would blind Serena on the wiki (see `wiki/knowledge/concepts/git-ignore-tool-visibility.md`); per-machine and idempotent. `info/exclude` *is* honored by ripgrep-class walkers and the `@` file picker, so the
|
|
28
|
+
| `merge-gitignore.sh` | `setup-project.sh`, `update-project.sh` | Fully interactive `.gitignore` merge — **nothing is ever added without asking**. The packaged template's titled sections are offered one by one (`Add/update .gitignore section '<title>' (N new line(s))? [y/N]`); sections with nothing new are skipped silently. Non-interactive runs (or no tty) change nothing at all. Never touches existing project content. Also offers (git repos only) to keep `.serena/`/`raw/`/`wiki/` out of git via **`.git/info/exclude`** — never `.gitignore`, which would blind Serena on the wiki (see `wiki/knowledge/concepts/git-ignore-tool-visibility.md`); per-machine and idempotent. `info/exclude` *is* honored by ripgrep-class walkers and the `@` file picker, so every machine-local exclusion this script manages — the wiki/agent-state dirs AND the `.claude/bootstrap-prefs.*` files, whichever of its prompts get answered and in whichever order — is written under **one shared, generic sentinel** (`# bootstrap machine-local (autocomplete-visible)`) that the `fileSuggestion` picker installed by `install-global.sh` reads back to restore `@`-autocomplete. The sentinel line itself is written proactively on every interactive run against a git repo, even if every exclude-affecting prompt is declined, so the anchor is always there regardless of which preferences got set; a project still carrying the old, separately-named pre-unification header is repaired onto the shared sentinel automatically. |
|
|
29
29
|
| `merge-settings-deny.js` | `install-global.sh` | Zero-dependency Node script that merges the canonical permission deny list (`templates/settings-deny.json` — `Bash(...)` command patterns plus `Edit(...)`/`Read(...)` file-tool patterns) into `~/.claude/settings.json` `permissions.deny`. Entries are opaque strings, so any rule form the permission system accepts merges unchanged. Additive union only: missing entries are appended, user entries are never removed or reordered, all other settings keys pass through untouched. Atomic write, preserves existing indentation, and always exits 0 (warns + skips on unparseable or unexpected file shapes so an install never aborts over a settings merge). `--target`/`--source` flags exist as test seams. A second mode, `--set-key <name> --set-value <json>`, merges a single top-level settings key instead of the deny list (used to register `fileSuggestion`): absent → set; already deep-equal → no-op; present but different → one-line warning and skip, never a clobber. Supplying `--set-key` skips the deny merge entirely; a malformed `--set-value` exits 1, since that is a call-site bug rather than a user's file. |
|
|
30
30
|
| `merge-settings-hooks.js` | `install-global.sh` | Zero-dependency Node sibling of `merge-settings-deny.js` (deliberately not a new mode of it — different, block-and-entry-aware semantics) that merges the canonical hook wiring (`templates/settings-hooks.json`) into the `hooks` key of `~/.claude/settings.json` with a "template owns its blocks" model: repo-owned entries (a `command` under `~/.claude/hooks/` whose basename appears in the template) are created or updated in place; matcher drift on a pure-owned block is adopted (a matcher rename ships without duplicating the block); user/foreign blocks and entries are never modified, reordered, or removed; a repo hook found relocated into a mixed block is warned about but not duplicated; no empty placeholder blocks are ever written. Always exits 0 (warns + skips on unparseable or unexpected file shapes so an install never aborts over a settings merge). `--target`/`--source` flags exist as test seams. |
|
|
31
|
-
| `bootstrap-prefs.js` | `install-global.sh`, `install-mcps.sh`, `sync-wiki-scaffold.sh`, `merge-gitignore.sh`, `update-project.sh` (all through the `prefs_*` / `prompt_*_sticky` wrappers in `lib.sh`), and the `/bootstrap-config` skill | Zero-dependency Node reader/writer for the preference store — the one binary every consumer goes through, so no prompt site keeps its own copy of a key's value list. Five operations: `--get` (a resolving read; always exits 0, so no call site needs `\|\| true`), `--set`, `--unset`, `--list`, and `--section-key <title>` (turns a `.gitignore` banner title into its `gitignore.section.<slug>` key, so the slug rule has exactly one implementation and is Unicode-aware). `--set`/`--unset` require **exactly one** layer selector (`--global` / `--project <dir>` / `--target <path>`) and will not guess — a misdirected write is unrecoverable in a way a misdirected read is not; `--get` resolves across layers by default for the mirror-image reason. Values are validated against the schema's `values` grammar (an illegal value exits 1 — a caller bug must never land in the file and read back as `unset`); writes are atomic and reuse the file's existing indentation; and every successful `--set`/`--unset` regenerates the `bootstrap-prefs.README.md` companion beside the values file. See [Preference helper notes](#preference-helper-notes). |
|
|
31
|
+
| `bootstrap-prefs.js` | `install-global.sh`, `install-mcps.sh`, `sync-wiki-scaffold.sh`, `merge-gitignore.sh`, `update-project.sh` (all through the `prefs_*` / `prompt_*_sticky` wrappers in `lib.sh`), and the `/bootstrap-config` skill | Zero-dependency Node reader/writer for the preference store — the one binary every consumer goes through, so no prompt site keeps its own copy of a key's value list. Five operations: `--get` (a resolving read; always exits 0, so no call site needs `\|\| true`), `--set`, `--unset`, `--list`, and `--section-key <title>` (turns a `.gitignore` banner title into its `gitignore.section.<slug>` key, so the slug rule has exactly one implementation and is Unicode-aware). `--set`/`--unset` require **exactly one** layer selector (`--global` / `--project <dir>` / `--target <path>`) and will not guess — a misdirected write is unrecoverable in a way a misdirected read is not; `--get` resolves across layers by default for the mirror-image reason. Values are validated against the schema's `values` grammar (an illegal value exits 1 — a caller bug must never land in the file and read back as `unset`), and `--set` also refuses to write into a layer the key's `scope` forbids (`--target` stays exempt); writes are atomic and reuse the file's existing indentation; and every successful `--set`/`--unset` regenerates the `bootstrap-prefs.README.md` companion beside the values file. See [Preference helper notes](#preference-helper-notes). |
|
|
32
32
|
|
|
33
33
|
## Standalone infra scripts (not wired to the CLI)
|
|
34
34
|
|
|
@@ -244,16 +244,22 @@ records only whether to install the server. Treat this as a rule when adding a
|
|
|
244
244
|
key: if the answer to a question is a credential, the question does not belong in
|
|
245
245
|
this store.
|
|
246
246
|
|
|
247
|
-
###
|
|
248
|
-
|
|
249
|
-
`--set` validates the *value* against the schema's `values` string,
|
|
250
|
-
|
|
251
|
-
key
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
`scope
|
|
247
|
+
### `--set` enforces a key's grammar AND its scope
|
|
248
|
+
|
|
249
|
+
`--set` validates the *value* against the schema's `values` string, and also
|
|
250
|
+
checks that the chosen layer is one the key's `scope` permits — writing a
|
|
251
|
+
`global`-scope key into a project values file (or vice versa) exits `1` with
|
|
252
|
+
nothing written, naming the actual scope and the layer that would be
|
|
253
|
+
consulted instead. `--target <path>` remains the deliberate, exempt escape
|
|
254
|
+
hatch: it always bypasses the scope check, since it is an explicit
|
|
255
|
+
single-file operation rather than a resolved layer. Fixed as
|
|
256
|
+
[`BUG-0009`](../../wiki/work/bugs/archive/BUG-0009-set-writes-scope-inert-key-silently.md)
|
|
257
|
+
(previously: the write silently succeeded and printed an affirmative line
|
|
258
|
+
while landing in a layer `resolve()` never walks). A scope-inert key can
|
|
259
|
+
still exist — via `--target`, a hand edit, or a values file written by a
|
|
260
|
+
newer bootstrap — and the generated companion's `## Unrecognized keys`
|
|
261
|
+
section still explains it the same way: `scope is ... — this layer never
|
|
262
|
+
consults it, so it has no effect here`.
|
|
257
263
|
|
|
258
264
|
## Preference-schema notes
|
|
259
265
|
|
|
@@ -261,7 +267,7 @@ The shape contract for `templates/bootstrap-prefs-schema.json`. JSON cannot carr
|
|
|
261
267
|
comments, so the file itself must stay bare — no `$comment` header, no explanatory
|
|
262
268
|
keys — and everything a reader or a new consumer needs to know about its shape
|
|
263
269
|
lives here instead. What each individual key *does* is a separate question, and
|
|
264
|
-
it is answered by [The key registry — all
|
|
270
|
+
it is answered by [The key registry — all 21 entries](#the-key-registry--all-21-entries)
|
|
265
271
|
at the end of this section.
|
|
266
272
|
|
|
267
273
|
### Flat key → entry, and eight fields
|
|
@@ -361,7 +367,7 @@ real `lib/scripts/` file or one real `lib/skills/<name>/SKILL.md`, so
|
|
|
361
367
|
`"install-global.sh, /git-commit"` fails the suite by construction. Where a
|
|
362
368
|
run-time prompt exists, it is documented in the key's `detail`.
|
|
363
369
|
|
|
364
|
-
### The key registry — all
|
|
370
|
+
### The key registry — all 22 entries
|
|
365
371
|
|
|
366
372
|
Every key in `templates/bootstrap-prefs-schema.json`, grouped by `consumer` —
|
|
367
373
|
`installer` first, then `skill` — which is the same grouping and the same order
|
|
@@ -370,7 +376,7 @@ schema's `default` field; `unset` in that column means `default: null`, i.e. the
|
|
|
370
376
|
key resolves to `unset` until it is answered. This table is transcribed from the
|
|
371
377
|
JSON; if the two ever disagree, the JSON is right and this table is a bug.
|
|
372
378
|
|
|
373
|
-
#### `consumer: installer` —
|
|
379
|
+
#### `consumer: installer` — 16 entries, read by the setup/update scripts
|
|
374
380
|
|
|
375
381
|
| Key | Scope | Consumer | Values | Default | Asked by | What it does |
|
|
376
382
|
|-----|-------|----------|--------|---------|----------|--------------|
|
|
@@ -379,7 +385,7 @@ JSON; if the two ever disagree, the JSON is right and this table is a bug.
|
|
|
379
385
|
| `mcp.playwrightConflict` | project | installer | `shared \| alongside \| skip` | `unset` | `install-mcps.sh` | How to resolve a committed `.mcp.json` that already registers its own playwright server |
|
|
380
386
|
| `mcp.playwrightReplace` | project | installer | `true \| false` | `unset` | `install-mcps.sh` | Replace an existing machine-local Playwright registration with the bootstrap shared server |
|
|
381
387
|
| `update.legacyDocsAck` | project | installer | `true \| false` | `unset` | `update-project.sh` | Continue `update` even though a legacy `.docs/` directory was detected |
|
|
382
|
-
| `gitignore.infoExclude` | project | installer | `true \| false` | `unset` | `merge-gitignore.sh` |
|
|
388
|
+
| `gitignore.infoExclude` | project | installer | `true \| false` | `unset` | `merge-gitignore.sh` | Add `.serena/`, `raw/`, and `wiki/` to git's local ignore list via `.git/info/exclude` |
|
|
383
389
|
| `prefs.gitTracking` | project | installer | `gitignore \| exclude \| neither` | `unset` | `merge-gitignore.sh` | How git should treat `.claude/bootstrap-prefs.json` and `bootstrap-prefs.README.md` |
|
|
384
390
|
| `guides.*` **(pattern)** | project | installer | `true \| false` | `unset` | `sync-wiki-scaffold.sh` | Install a specific optional guide into `wiki/guides/` |
|
|
385
391
|
| `gitignore.section.*` **(pattern)** | project | installer | `false` | `unset` | `merge-gitignore.sh` | Permanently decline one titled `.gitignore` template section |
|
|
@@ -387,6 +393,8 @@ JSON; if the two ever disagree, the JSON is right and this table is a bug.
|
|
|
387
393
|
| `mcp.context7` | global | installer | `true \| false` | `unset` | `install-mcps.sh` | Install the Context7 MCP for library documentation lookups |
|
|
388
394
|
| `mcp.context7Scope` | global | installer | `user \| project` | `unset` | `lib.sh` | Registration scope for the Context7 MCP |
|
|
389
395
|
| `mcp.playwright` | global | installer | `true \| false` | `unset` | `install-mcps.sh` | Install the Playwright MCP for browser automation and UI testing |
|
|
396
|
+
| `obsidian.installApp` | global | installer | `true \| false` | `unset` | `install-obsidian.sh` | Install the Obsidian desktop app via the native package manager |
|
|
397
|
+
| `obsidian.plugins` | project | installer | `true \| false` | `unset` | `install-obsidian.sh` | Install the bundled Obsidian plugin set (Dataview, Graph Link Types, Breadcrumbs) |
|
|
390
398
|
| `skills.pruneOrphans` | global | installer | `true \| false` | `unset` | `install-global.sh` | Delete stale skill folders in `~/.claude/skills/` left by the wiki rename |
|
|
391
399
|
|
|
392
400
|
The two **(pattern)** rows carry `"dynamic": true` and are key *families*, not
|
|
@@ -397,17 +405,18 @@ Unicode-aware slug rule for `gitignore.section.*` are in
|
|
|
397
405
|
above; `gitignore.section.*`'s deliberate one-value grammar is in
|
|
398
406
|
[the section after it](#gitignoresection-has-a-one-value-grammar-on-purpose).
|
|
399
407
|
|
|
400
|
-
#### `consumer: skill` —
|
|
408
|
+
#### `consumer: skill` — 6 entries, read by slash commands at run time
|
|
401
409
|
|
|
402
410
|
| Key | Scope | Consumer | Values | Default | Asked by | What it does |
|
|
403
411
|
|-----|-------|----------|--------|---------|----------|--------------|
|
|
404
412
|
| `gitCommit.versionBump` | either | skill | `auto \| confirm \| never` | `auto` | `install-global.sh` | How `/git-commit` handles the version bump before committing |
|
|
405
413
|
| `gitCommit.autoPush` | either | skill | `true \| false \| ask` | `false` | `install-global.sh` | Whether `/git-commit` pushes after a successful commit |
|
|
406
414
|
| `research.persistToRaw` | either | skill | `true \| false \| ask` | `true` | `install-global.sh` | Whether `/research` writes its report and sources to `raw/research/` |
|
|
415
|
+
| `research.autoIngest` | either | skill | `true \| false \| ask` | `false` | `install-global.sh` | Whether `/research` automatically wiki-ingests its saved report |
|
|
407
416
|
| `uatGenerate.promoteTests` | either | skill | `sibling \| never \| dedicated` | `dedicated` | `install-global.sh` | Where `/uat-generate` writes the unit tests it promotes out of UAT cases |
|
|
408
417
|
| `gitignore.offerSectionUpdates` | either | skill | `true \| false \| ask` | `true` | `install-global.sh` | Master gate for the `.gitignore` template section review pass |
|
|
409
418
|
|
|
410
|
-
These
|
|
419
|
+
These six are the entire `scope: either` population and the entire
|
|
411
420
|
`consumer: skill` population — the two sets coincide, because a key that changes
|
|
412
421
|
what a slash command does is exactly the kind of key a user may want to answer
|
|
413
422
|
once machine-wide and then override in one checkout.
|
|
@@ -693,6 +693,24 @@ if (opts.op === 'set') {
|
|
|
693
693
|
);
|
|
694
694
|
process.exit(1);
|
|
695
695
|
}
|
|
696
|
+
|
|
697
|
+
// BUG-0009: --set validated the value grammar but never the key's scope,
|
|
698
|
+
// so a global-scope key could be written into a project file (or vice
|
|
699
|
+
// versa) — the write succeeded, printed an affirmative line, and landed
|
|
700
|
+
// in a layer resolve() never walks for that scope, so it silently did
|
|
701
|
+
// nothing. --target is exempt (scopePermitsLayer returns true for it
|
|
702
|
+
// unconditionally); --unset is deliberately left permissive elsewhere,
|
|
703
|
+
// since unsetting an inert key is harmless and is the documented
|
|
704
|
+
// workaround for a key already stuck in the wrong layer.
|
|
705
|
+
if (!scopePermitsLayer(entry, targetLayer)) {
|
|
706
|
+
const correctLayer =
|
|
707
|
+
entry.scope === 'global' ? '--global' : entry.scope === 'project' ? '--project <dir>' : '--global or --project <dir>';
|
|
708
|
+
console.error(
|
|
709
|
+
`Error: "${opts.key}" is scope: ${entry.scope} — the ${targetLayer} layer never reads it, so this write ` +
|
|
710
|
+
`would be inert. Use ${correctLayer} instead, or --target <path> to force a specific file.`
|
|
711
|
+
);
|
|
712
|
+
process.exit(1);
|
|
713
|
+
}
|
|
696
714
|
}
|
|
697
715
|
|
|
698
716
|
// 'true'/'false' become JSON booleans; everything else is a JSON string.
|
|
@@ -27,7 +27,9 @@ GLOBAL_HOOKS_DIR="$HOME/.claude/hooks"
|
|
|
27
27
|
if [ -d "$TEMPLATE_DIR/lib/hooks" ]; then
|
|
28
28
|
echo "Installing hooks globally (~/.claude/hooks/)..."
|
|
29
29
|
mkdir -p "$GLOBAL_HOOKS_DIR"
|
|
30
|
-
|
|
30
|
+
# Content-based comparison + minimal per-file report — see sync-wiki-scaffold.sh's
|
|
31
|
+
# RSYNC_FLAGS comment for why plain -av re-lists every file on every run.
|
|
32
|
+
rsync -a --checksum --omit-dir-times --out-format=' + %n' --exclude='.DS_Store' "$TEMPLATE_DIR/lib/hooks/" "$GLOBAL_HOOKS_DIR/"
|
|
31
33
|
echo ""
|
|
32
34
|
else
|
|
33
35
|
echo "Warning: $TEMPLATE_DIR/lib/hooks not found — hook scripts NOT installed" >&2
|
|
@@ -40,7 +42,7 @@ echo "Installing skills globally (~/.claude/skills/)..."
|
|
|
40
42
|
mkdir -p "$GLOBAL_SKILLS_DIR"
|
|
41
43
|
|
|
42
44
|
# Rsync skills from the template to ~/.claude/skills/
|
|
43
|
-
rsync -
|
|
45
|
+
rsync -a --checksum --omit-dir-times --out-format=' + %n' --exclude='.DS_Store' "$TEMPLATE_DIR/lib/skills/" "$GLOBAL_SKILLS_DIR/"
|
|
44
46
|
|
|
45
47
|
# Detect stale skill folders from the wiki rename
|
|
46
48
|
ORPHAN_FOUND=()
|
|
@@ -197,7 +199,7 @@ settle_skill_pref() {
|
|
|
197
199
|
case "$answer" in
|
|
198
200
|
yes) prefs_set "$key" --global true ; echo " $key = true" ;;
|
|
199
201
|
no) prefs_set "$key" --global false ; echo " $key = false" ;;
|
|
200
|
-
ask) prefs_set "$key" --global ask ; echo " $key = ask (
|
|
202
|
+
ask) prefs_set "$key" --global ask ; echo " $key = ask (the skill will prompt you each time it runs; that per-run answer is never stored)" ;;
|
|
201
203
|
*) echo " $key left unanswered — today's behavior is unchanged, and you will be asked again next sync." ;;
|
|
202
204
|
esac
|
|
203
205
|
PREFS_ASKED=$(( PREFS_ASKED + 1 ))
|
|
@@ -232,6 +234,8 @@ else
|
|
|
232
234
|
"Should /git-commit push the current branch after committing? (Default no — this turns a local action into a published one. It never creates a branch either way.)"
|
|
233
235
|
settle_skill_pref research.persistToRaw \
|
|
234
236
|
"Should /research save its report and sources to raw/research/ by default? (Findings always appear in the reply; this governs the file write only, and you can still decline any single report.)"
|
|
237
|
+
settle_skill_pref research.autoIngest \
|
|
238
|
+
"Should /research automatically fold a saved report into wiki/ (/wiki-ingest) instead of just suggesting the command? (Only runs when a report was actually saved.)"
|
|
235
239
|
# uatGenerate.promoteTests is the second key that cannot go through
|
|
236
240
|
# settle_skill_pref: its grammar is sibling|never|dedicated (plus the
|
|
237
241
|
# parameterized dedicated:<path>), not true|false|ask.
|
|
@@ -302,4 +306,15 @@ if [ "$SKIP_MCPS" = false ]; then
|
|
|
302
306
|
echo ""
|
|
303
307
|
fi
|
|
304
308
|
|
|
305
|
-
|
|
309
|
+
# "preferences" stays unconditional regardless of SKIP_MCPS: step 6 always
|
|
310
|
+
# installs the helper on every pass, whether or not anything was actually
|
|
311
|
+
# asked (a non-tty run still installs it, it just settles no answers) — see
|
|
312
|
+
# BUG-0010. "MCPs" is the one token gated on what actually ran, since step 8
|
|
313
|
+
# is skipped entirely under --skip-mcps and claiming it otherwise overstates
|
|
314
|
+
# the summary's own job (evidence of what ran) on the most common invocation
|
|
315
|
+
# path — both setup-project.sh and update-project.sh call this with --skip-mcps.
|
|
316
|
+
if [ "$SKIP_MCPS" = false ]; then
|
|
317
|
+
echo "Global setup complete (hooks + skills + deny list + hooks wiring + file suggestion + preferences + MCPs)."
|
|
318
|
+
else
|
|
319
|
+
echo "Global setup complete (hooks + skills + deny list + hooks wiring + file suggestion + preferences)."
|
|
320
|
+
fi
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# install-obsidian.sh [--interactive] [--project-dir <dir>]
|
|
5
|
+
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
+
. "$SCRIPT_DIR/lib.sh"
|
|
8
|
+
|
|
9
|
+
INTERACTIVE=false
|
|
10
|
+
PROJECT_DIR=""
|
|
11
|
+
|
|
12
|
+
while [[ $# -gt 0 ]]; do
|
|
13
|
+
case "$1" in
|
|
14
|
+
--interactive) INTERACTIVE=true; shift ;;
|
|
15
|
+
--project-dir) PROJECT_DIR="$2"; shift 2 ;;
|
|
16
|
+
*) shift ;;
|
|
17
|
+
esac
|
|
18
|
+
done
|
|
19
|
+
|
|
20
|
+
# Plugin repo slugs, pinned as named constants (never fetched or derived at
|
|
21
|
+
# runtime) so every releases/latest lookup below is driven by one audited
|
|
22
|
+
# value per plugin.
|
|
23
|
+
PLUGIN_DATAVIEW="blacksmithgu/obsidian-dataview"
|
|
24
|
+
PLUGIN_GRAPH_LINK_TYPES="natefrisch01/Graph-Link-Types"
|
|
25
|
+
# NOTE: prior research flagged an in-progress maintainer transition for
|
|
26
|
+
# Breadcrumbs — verify SkepticMystic/breadcrumbs is still the maintained fork
|
|
27
|
+
# at install time (vs. a community fork) before relying on this constant.
|
|
28
|
+
PLUGIN_BREADCRUMBS="SkepticMystic/breadcrumbs"
|
|
29
|
+
|
|
30
|
+
_install_obsidian_app() {
|
|
31
|
+
local os
|
|
32
|
+
os="$(uname -s)"
|
|
33
|
+
|
|
34
|
+
case "$os" in
|
|
35
|
+
Darwin)
|
|
36
|
+
if [ -d /Applications/Obsidian.app ]; then
|
|
37
|
+
echo " Obsidian.app already installed — skipping."
|
|
38
|
+
return 0
|
|
39
|
+
fi
|
|
40
|
+
brew install --cask obsidian \
|
|
41
|
+
|| echo " WARNING: 'brew install --cask obsidian' failed — install Obsidian manually from https://obsidian.md/download"
|
|
42
|
+
;;
|
|
43
|
+
Linux)
|
|
44
|
+
if flatpak list 2>/dev/null | grep -q md.obsidian.Obsidian; then
|
|
45
|
+
echo " Obsidian (flatpak) already installed — skipping."
|
|
46
|
+
return 0
|
|
47
|
+
fi
|
|
48
|
+
if ! command -v flatpak >/dev/null 2>&1; then
|
|
49
|
+
echo " WARNING: flatpak not found — install Obsidian manually from https://obsidian.md/download"
|
|
50
|
+
return 0
|
|
51
|
+
fi
|
|
52
|
+
flatpak install -y flathub md.obsidian.Obsidian \
|
|
53
|
+
|| echo " WARNING: 'flatpak install -y flathub md.obsidian.Obsidian' failed — install Obsidian manually from https://obsidian.md/download"
|
|
54
|
+
;;
|
|
55
|
+
*)
|
|
56
|
+
echo " Obsidian: no automated installer for '$os' — install manually from https://obsidian.md/download"
|
|
57
|
+
;;
|
|
58
|
+
esac
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
# _gh_release_asset_url <release_json_file> <asset_name>
|
|
62
|
+
# Prints the browser_download_url of a named asset from a GitHub
|
|
63
|
+
# releases/latest JSON payload already saved to disk; prints nothing if the
|
|
64
|
+
# asset is absent OR the file isn't parseable JSON in the expected shape —
|
|
65
|
+
# callers treat "empty" as the single signal to warn and skip, so a bare
|
|
66
|
+
# `node -e` failure can never trip `set -e` here. Mirrors the
|
|
67
|
+
# JSON.parse + readFileSync + try/catch style used by install-mcps.sh's
|
|
68
|
+
# _disable_project_playwright_locally.
|
|
69
|
+
_gh_release_asset_url() {
|
|
70
|
+
node -e '
|
|
71
|
+
const fs = require("fs");
|
|
72
|
+
try {
|
|
73
|
+
const data = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
|
|
74
|
+
const asset = (data.assets || []).find((a) => a.name === process.argv[2]);
|
|
75
|
+
if (asset && asset.browser_download_url) console.log(asset.browser_download_url);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
// Malformed JSON or unexpected shape — print nothing; the caller warns
|
|
78
|
+
// on the resulting empty string rather than on a node exit code.
|
|
79
|
+
}
|
|
80
|
+
' "$1" "$2"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# _install_obsidian_plugin <vault_dir> <owner_repo>
|
|
84
|
+
# Installs one community plugin from its GitHub releases/latest into
|
|
85
|
+
# <vault_dir>/.obsidian/plugins/<id>/, where <id> comes from the release's
|
|
86
|
+
# manifest.json — the authoritative plugin directory name, NOT the GitHub
|
|
87
|
+
# repo name. manifest.json is downloaded and parsed FIRST, before anything
|
|
88
|
+
# else. Every risky step (curl, JSON parsing, mkdir) warns to stderr and
|
|
89
|
+
# returns rather than aborting the script, so one bad/renamed plugin repo
|
|
90
|
+
# never blocks the other two or the rest of the install.
|
|
91
|
+
#
|
|
92
|
+
# Prints the resolved plugin id to stdout as its ONLY stdout output — bash
|
|
93
|
+
# functions can't return strings, so the caller captures it via:
|
|
94
|
+
# plugin_id="$(_install_obsidian_plugin "$vault_dir" "$owner_repo")"
|
|
95
|
+
# All diagnostics go to stderr (`>&2`) specifically so they never end up
|
|
96
|
+
# inside that captured value.
|
|
97
|
+
_install_obsidian_plugin() {
|
|
98
|
+
local vault_dir="$1" owner_repo="$2"
|
|
99
|
+
local release_tmp manifest_tmp manifest_url main_js_url styles_css_url
|
|
100
|
+
local plugin_id plugin_dir
|
|
101
|
+
|
|
102
|
+
release_tmp="$(mktemp)"
|
|
103
|
+
if ! curl -fsSL "https://api.github.com/repos/${owner_repo}/releases/latest" -o "$release_tmp"; then
|
|
104
|
+
echo " WARNING: ${owner_repo}: failed to fetch latest release — skipping plugin." >&2
|
|
105
|
+
rm -f "$release_tmp"
|
|
106
|
+
return
|
|
107
|
+
fi
|
|
108
|
+
if [ ! -s "$release_tmp" ]; then
|
|
109
|
+
echo " WARNING: ${owner_repo}: empty release response — skipping plugin." >&2
|
|
110
|
+
rm -f "$release_tmp"
|
|
111
|
+
return
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
manifest_url="$(_gh_release_asset_url "$release_tmp" manifest.json)"
|
|
115
|
+
if [ -z "$manifest_url" ]; then
|
|
116
|
+
echo " WARNING: ${owner_repo}: latest release has no manifest.json asset (or the release JSON was malformed) — skipping plugin." >&2
|
|
117
|
+
rm -f "$release_tmp"
|
|
118
|
+
return
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
manifest_tmp="$(mktemp)"
|
|
122
|
+
if ! curl -fsSL "$manifest_url" -o "$manifest_tmp"; then
|
|
123
|
+
echo " WARNING: ${owner_repo}: failed to download manifest.json — skipping plugin." >&2
|
|
124
|
+
rm -f "$release_tmp" "$manifest_tmp"
|
|
125
|
+
return
|
|
126
|
+
fi
|
|
127
|
+
|
|
128
|
+
plugin_id="$(node -e '
|
|
129
|
+
const fs = require("fs");
|
|
130
|
+
try {
|
|
131
|
+
const data = JSON.parse(fs.readFileSync(process.argv[1], "utf8"));
|
|
132
|
+
if (data && typeof data.id === "string" && data.id) console.log(data.id);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
// Malformed manifest.json — print nothing; caller warns on the empty
|
|
135
|
+
// result below.
|
|
136
|
+
}
|
|
137
|
+
' "$manifest_tmp")"
|
|
138
|
+
if [ -z "$plugin_id" ]; then
|
|
139
|
+
echo " WARNING: ${owner_repo}: manifest.json is missing/malformed its 'id' field — skipping plugin." >&2
|
|
140
|
+
rm -f "$release_tmp" "$manifest_tmp"
|
|
141
|
+
return
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
plugin_dir="$vault_dir/.obsidian/plugins/$plugin_id"
|
|
145
|
+
if ! mkdir -p "$plugin_dir"; then
|
|
146
|
+
echo " WARNING: ${owner_repo}: failed to create $plugin_dir — skipping plugin." >&2
|
|
147
|
+
rm -f "$release_tmp" "$manifest_tmp"
|
|
148
|
+
return
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
# Obsidian requires manifest.json inside the plugin's own directory to
|
|
152
|
+
# recognize and load it — copy the file we already fetched (and already
|
|
153
|
+
# parsed plugin_id from) rather than re-downloading it. See BUG-0011: an
|
|
154
|
+
# earlier version parsed plugin_id from manifest_tmp and then discarded it
|
|
155
|
+
# without ever writing it into plugin_dir, so every plugin ended up enabled
|
|
156
|
+
# in community-plugins.json but missing the manifest Obsidian needs to load it.
|
|
157
|
+
if ! cp "$manifest_tmp" "$plugin_dir/manifest.json"; then
|
|
158
|
+
echo " WARNING: ${owner_repo}: failed to write manifest.json into $plugin_dir — skipping plugin." >&2
|
|
159
|
+
rm -f "$release_tmp" "$manifest_tmp"
|
|
160
|
+
return
|
|
161
|
+
fi
|
|
162
|
+
|
|
163
|
+
main_js_url="$(_gh_release_asset_url "$release_tmp" main.js)"
|
|
164
|
+
if [ -z "$main_js_url" ]; then
|
|
165
|
+
echo " WARNING: ${owner_repo}: latest release has no main.js asset — skipping plugin." >&2
|
|
166
|
+
rm -f "$release_tmp" "$manifest_tmp"
|
|
167
|
+
return
|
|
168
|
+
fi
|
|
169
|
+
if ! curl -fsSL "$main_js_url" -o "$plugin_dir/main.js"; then
|
|
170
|
+
echo " WARNING: ${owner_repo}: failed to download main.js — skipping plugin." >&2
|
|
171
|
+
rm -f "$release_tmp" "$manifest_tmp"
|
|
172
|
+
return
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
# styles.css is optional — silently skip when the release doesn't ship one.
|
|
176
|
+
styles_css_url="$(_gh_release_asset_url "$release_tmp" styles.css)"
|
|
177
|
+
if [ -n "$styles_css_url" ]; then
|
|
178
|
+
curl -fsSL "$styles_css_url" -o "$plugin_dir/styles.css" \
|
|
179
|
+
|| echo " WARNING: ${owner_repo}: failed to download styles.css — continuing without it." >&2
|
|
180
|
+
fi
|
|
181
|
+
|
|
182
|
+
rm -f "$release_tmp" "$manifest_tmp"
|
|
183
|
+
echo "$plugin_id"
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
# _enable_obsidian_plugin <vault_dir> <id>
|
|
187
|
+
# Idempotently adds <id> to <vault_dir>/.obsidian/community-plugins.json —
|
|
188
|
+
# creates the file as ["<id>"] if absent (mkdir -p'ing .obsidian first), else
|
|
189
|
+
# appends <id> only if not already present. Mirrors install-mcps.sh's
|
|
190
|
+
# _disable_project_playwright_locally: warns and skips (never crashes or
|
|
191
|
+
# overwrites) on unparseable JSON or an unexpected (non-array) shape, and
|
|
192
|
+
# never aborts the calling script on any failure.
|
|
193
|
+
_enable_obsidian_plugin() {
|
|
194
|
+
local vault_dir="$1" id="$2"
|
|
195
|
+
node -e '
|
|
196
|
+
const fs = require("fs"), path = require("path");
|
|
197
|
+
const vaultDir = process.argv[1], id = process.argv[2];
|
|
198
|
+
const dir = path.join(vaultDir, ".obsidian");
|
|
199
|
+
const file = path.join(dir, "community-plugins.json");
|
|
200
|
+
let list;
|
|
201
|
+
if (fs.existsSync(file)) {
|
|
202
|
+
let raw;
|
|
203
|
+
try {
|
|
204
|
+
raw = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
205
|
+
} catch (e) {
|
|
206
|
+
console.error(" WARNING: could not parse " + file + " — skipping enable for " + id + ".");
|
|
207
|
+
process.exit(0);
|
|
208
|
+
}
|
|
209
|
+
if (!Array.isArray(raw)) {
|
|
210
|
+
console.error(" WARNING: " + file + " is not a JSON array — skipping enable for " + id + ".");
|
|
211
|
+
process.exit(0);
|
|
212
|
+
}
|
|
213
|
+
list = raw;
|
|
214
|
+
} else {
|
|
215
|
+
list = [];
|
|
216
|
+
}
|
|
217
|
+
if (list.includes(id)) {
|
|
218
|
+
console.log(" " + id + ": already enabled in " + file + ".");
|
|
219
|
+
process.exit(0);
|
|
220
|
+
}
|
|
221
|
+
list.push(id);
|
|
222
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
223
|
+
const tmp = file + ".tmp-" + process.pid;
|
|
224
|
+
fs.writeFileSync(tmp, JSON.stringify(list, null, 2) + "\n");
|
|
225
|
+
fs.renameSync(tmp, file);
|
|
226
|
+
console.log(" " + id + ": enabled in " + file + ".");
|
|
227
|
+
' "$vault_dir" "$id" || true
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
# ---------------------------------------------------------------------------
|
|
231
|
+
# App install gate
|
|
232
|
+
#
|
|
233
|
+
# Interactive: prompt_yn_sticky handles the ask-once/remember dance itself.
|
|
234
|
+
# Non-interactive: mirror register_optional_mcp's non-interactive branch
|
|
235
|
+
# (install-mcps.sh) exactly — read the stored preference directly via
|
|
236
|
+
# prefs_get, never through a prompt helper (prompt_yn_sticky auto-answers
|
|
237
|
+
# "no" with no tty, which is the wrong default here), and only an explicit
|
|
238
|
+
# stored `false` diverts. `true`, `ask`, and `unset` all proceed with the
|
|
239
|
+
# install, same as register_optional_mcp.
|
|
240
|
+
# ---------------------------------------------------------------------------
|
|
241
|
+
if [ "$INTERACTIVE" = true ]; then
|
|
242
|
+
if prompt_yn_sticky obsidian.installApp --global "Install the Obsidian app (recommended local viewer for wiki/ — https://obsidian.md)? [Y/n]: "; then
|
|
243
|
+
_install_obsidian_app || echo " WARNING: Obsidian app install failed — continuing."
|
|
244
|
+
else
|
|
245
|
+
echo " Skipping Obsidian app install."
|
|
246
|
+
fi
|
|
247
|
+
else
|
|
248
|
+
if [ "$(prefs_get obsidian.installApp --global)" = "false" ]; then
|
|
249
|
+
echo " obsidian.installApp: skipped (remembered decline — change with /bootstrap-config)"
|
|
250
|
+
else
|
|
251
|
+
_install_obsidian_app || echo " WARNING: Obsidian app install failed — continuing."
|
|
252
|
+
fi
|
|
253
|
+
fi
|
|
254
|
+
|
|
255
|
+
# ---------------------------------------------------------------------------
|
|
256
|
+
# Plugin install gate
|
|
257
|
+
#
|
|
258
|
+
# obsidian.plugins is a project-scoped key — the vault root is $PROJECT_DIR,
|
|
259
|
+
# so its prompt_yn_sticky/prefs_get selector is "$PROJECT_DIR" itself (never
|
|
260
|
+
# --global), per the selector-consistency rule documented on prompt_yn_sticky
|
|
261
|
+
# in lib.sh. No $PROJECT_DIR means no vault to install into, so skip outright
|
|
262
|
+
# rather than guessing a location.
|
|
263
|
+
# ---------------------------------------------------------------------------
|
|
264
|
+
if [ -z "$PROJECT_DIR" ]; then
|
|
265
|
+
echo " WARNING: no --project-dir given — skipping Obsidian plugin install."
|
|
266
|
+
else
|
|
267
|
+
install_plugins=false
|
|
268
|
+
if [ "$INTERACTIVE" = true ]; then
|
|
269
|
+
if prompt_yn_sticky obsidian.plugins "$PROJECT_DIR" "Install recommended Obsidian plugins (Dataview, Graph Link Types, Breadcrumbs) into this project's vault config? [Y/n]: "; then
|
|
270
|
+
install_plugins=true
|
|
271
|
+
fi
|
|
272
|
+
else
|
|
273
|
+
# Same non-interactive mirroring as the app-install gate above, applied
|
|
274
|
+
# to the project-scoped key: only a stored `false` skips.
|
|
275
|
+
if [ "$(prefs_get obsidian.plugins "$PROJECT_DIR")" = "false" ]; then
|
|
276
|
+
echo " obsidian.plugins: skipped (remembered decline — change with /bootstrap-config)"
|
|
277
|
+
else
|
|
278
|
+
install_plugins=true
|
|
279
|
+
fi
|
|
280
|
+
fi
|
|
281
|
+
|
|
282
|
+
if [ "$install_plugins" = true ]; then
|
|
283
|
+
for plugin_repo in "$PLUGIN_DATAVIEW" "$PLUGIN_GRAPH_LINK_TYPES" "$PLUGIN_BREADCRUMBS"; do
|
|
284
|
+
plugin_id="$(_install_obsidian_plugin "$PROJECT_DIR" "$plugin_repo")" || plugin_id=""
|
|
285
|
+
if [ -n "$plugin_id" ]; then
|
|
286
|
+
_enable_obsidian_plugin "$PROJECT_DIR" "$plugin_id" || true
|
|
287
|
+
fi
|
|
288
|
+
# Empty $plugin_id means _install_obsidian_plugin already warned
|
|
289
|
+
# internally — just move on to the next plugin.
|
|
290
|
+
done
|
|
291
|
+
else
|
|
292
|
+
echo " Skipping Obsidian plugin install."
|
|
293
|
+
fi
|
|
294
|
+
fi
|
package/lib/scripts/lib.sh
CHANGED
|
@@ -167,6 +167,12 @@ run_project_sync() {
|
|
|
167
167
|
"$script_dir/merge-gitignore.sh" --interactive "$project_dir"
|
|
168
168
|
echo ""
|
|
169
169
|
|
|
170
|
+
echo "Checking Obsidian setup..."
|
|
171
|
+
if ! "$script_dir/install-obsidian.sh" --interactive --project-dir "$project_dir"; then
|
|
172
|
+
echo "Warning: Obsidian install failed — continuing; re-run update to retry." >&2
|
|
173
|
+
fi
|
|
174
|
+
echo ""
|
|
175
|
+
|
|
170
176
|
echo "Building MCP tools guide..."
|
|
171
177
|
installed_mcps="$(detect_installed_mcps "$project_dir")"
|
|
172
178
|
# Unquoted on purpose: word-split the space-separated names into arguments.
|
|
@@ -210,6 +216,17 @@ prompt_yn() {
|
|
|
210
216
|
fi
|
|
211
217
|
case "$reply" in
|
|
212
218
|
[yY]*) return 0 ;;
|
|
219
|
+
"")
|
|
220
|
+
# A bare Enter press honors whichever default the prompt text itself
|
|
221
|
+
# displays. Every prompt in this codebase already signals its default
|
|
222
|
+
# via bracket capitalization ("[Y/n]" vs "[y/N]") — this just makes an
|
|
223
|
+
# empty reply match what the user was shown, instead of every empty
|
|
224
|
+
# reply silently meaning "no" regardless of what the brackets promised.
|
|
225
|
+
case "$prompt" in
|
|
226
|
+
*"[Y/n]"*) return 0 ;;
|
|
227
|
+
*) return 1 ;;
|
|
228
|
+
esac
|
|
229
|
+
;;
|
|
213
230
|
*) return 1 ;;
|
|
214
231
|
esac
|
|
215
232
|
}
|