Commit Graph

2 Commits

Author SHA1 Message Date
ar9av 27bcfea185 feat(extensions): choose which vault the Brain extension answers from
The fill flow always used whatever ~/.obsidian-wiki/config resolved to, so
answering a work questionnaire from the work vault meant re-pointing the
wiki-switch symlink for everything else too. This is the extension's
equivalent of the @name override.

The host gains a `vaults` request that lists the active-config default plus
every ~/.obsidian-wiki/config.<name> profile with its resolved path and an
existence flag, and `fill` accepts a vault name. Named resolution never falls
back to the default: silently answering from the wrong vault is exactly what
picking a vault is meant to prevent.

The popup remembers the choice per browser profile, disables profiles whose
path is gone, and resets to the default (loudly) if the remembered one
disappears. If the host is not installed the picker stays on its single
default option, so fill behaves as before.
2026-08-15 15:27:19 -07:00
ar9av d3e545b012 feat(extensions): fill web forms from the vault; rename to Brain
The brain-capture extension only went one way: browser -> vault. This adds
the return path — read the form on the current page, answer what the vault
supports, and leave the rest blank — and folds both directions into a single
two-tab extension renamed from "Brain Vault Capture" to "Brain".

Retrieval never calls a model. `obsidian-wiki context-pack --json` ranks the
vault deterministically and the model does one narrow job: map retrieved facts
onto fields. One `claude -p` / `codex exec` invocation per fill, billed to the
subscription the user already has. Nothing is ever submitted.

A native messaging host bridges the two, staged into ~/.obsidian-wiki/ rather
than run from the checkout. Chrome's children do not inherit your shell, and
all three consequences bite:

- macOS TCC: ~/Documents is mode 700 with an ACL, and a native host inherits
  Chrome's TCC context, so a checkout there cannot be exec'd at all. Chrome
  reports this as "Native host has exited", identical to a crash.
- PATH: Chrome passes a minimal PATH, hiding claude/codex in ~/.local/bin.
- USER/LOGNAME: Claude Code reads OAuth credentials from the macOS login
  Keychain and needs these to find them, else "Not logged in" despite a valid
  session.

The host bookends every run in its log so those failures stay distinguishable,
re-validates every returned fill against the real form schema (an injected
value cannot reach a field the page never advertised), and forwards the pack's
instruction_policy so vault excerpts stay data rather than instruction.

Form-schema extraction resolves labels via aria-labelledby before aria-label:
Google Forms puts aria-label="Your answer" on every paragraph field while the
real question sits behind aria-labelledby, so checking aria-label first
silently mislabelled exactly the textarea fields. Values are written through
the native setter with input/change dispatched, so React-controlled forms see
a genuine edit.

Docs: docs/browser-extension.md, linked from both READMEs and the docs index.
Also backfills the untranslated tagline from #159 into README_TW.md.
2026-08-14 23:43:19 -07:00