notebooklm-create-library
Stand up a content library — backed by a NotebookLM notebook on the cloud side, and a Wiki/Libraries/{slug}.md node on the vault side. The two are 1:1 and stay in sync.
Pre-flight checks
slugis kebab-case (lowercase letters, digits, hyphens; no spaces/underscores).Wiki/Libraries/{slug}.mddoes not already exist.- NotebookLM session is valid (Phase 2+). If
NOTEBOOKLM_SESSION_PATHis unset OR the session file is missing/expired:- Phase 1 (architecture-only): scaffold the wiki node with
notebooklm_id: ""andstatus: pending-installation. Don't fail. - Phase 2+: abort with a clear "run
notebooklm loginfirst" message.
- Phase 1 (architecture-only): scaffold the wiki node with
Procedure
1. Create the NotebookLM notebook (Phase 2+)
- Use
notebooklm-py's create-notebook function withdisplay_name. - Capture the returned
notebooklm_id(and share URL if supported).
2. Scaffold the wiki node
- Copy
Templates/library.template.mdtoWiki/Libraries/{slug}.md. - Fill frontmatter:
slug,display_name,subject_kind,subject_linknotebooklm_id: from step 1 (or empty in Phase 1)createdandlast_syncedandlast_summarized: todaysource_count: 0tags: [library]plussubject_kind-specific tag (person/<slug>if person,brand/<slug>if brand,topic/<slug>if topic).
- Replace
<kebab-case>and<Display Name>placeholders in body.
3. Seed initial sources
If initial_sources non-empty, for each:
- Invoke notebooklm-add-source with
library_slug={slug}, source={url-or-path}.
4. Cross-link the subject
If subject_link is provided (e.g., <a class="wikilink wikilink-broken" href="#">Wiki/People/naval</a>):
- Edit the subject node's frontmatter to add
library: "<a class="wikilink wikilink-broken" href="#">Wiki/Libraries/{slug}</a>". - Append a "Library: Wiki/Libraries/{slug}" line to the subject node's body if not already present.
5. Append Log entry
- input:
slug={slug}, kind={subject_kind}, sources={count} - artifacts:
<a class="wikilink wikilink-broken" href="#">Wiki/Libraries/{slug}</a> - notes: include
notebooklm_id(orpending-installationin Phase 1).
Atomicity
If step 1 succeeds but step 2 fails (or vice versa), roll back the side that succeeded so the vault and NotebookLM stay 1:1. Specifically:
- If notebook created but wiki node write fails: delete the NotebookLM notebook, then re-raise.
- If wiki node written but notebook creation fails: delete the wiki node.
Hard rules
- Never create two libraries with the same slug.
- Never sync sensitive content (
Raw/Health/,Context/MI.md, brand compliance docs) into a library — Google retains content per their TOS. - Always create the wiki node — even in Phase 1 (architecture-only) the node lets agents start using it as a placeholder.
Failure modes
- NotebookLM rate-limited — surface to Adam, suggest retry; don't silently fail.
- Subject link doesn't exist — abort and ask Adam to create the subject node first (e.g., onboard the brand or create the People node).
- Phase 1 placeholder mode — note in the Log that the notebook side wasn't created; Phase 2 install will need a
/library bind {slug}follow-up to attach the wiki node to a freshly-created notebook.