Skip to content

teng-lin/notebooklm-py

notebooklm

Verified

Install, authenticate, troubleshoot, and operate Gemini Notebook through the notebooklm-py CLI or typed async Python API. Use for notebook and source management, grounded chat and research, and artifact generation or download when the user mentions Gemini Notebook, notebooklm-py, the notebooklm CLI, or its Python API. Do not use for the generic Gemini API or unrelated content creation.

FileKindSize
SKILL.mdskill md16.0 KB
examples/bulk-import.pyscript3.4 KB
examples/chat.pyscript6.9 KB
examples/notes.pyscript9.8 KB
examples/quickstart.pyscript2.3 KB
examples/refresh_browser_cookies.pyscript2.9 KB
examples/research-to-podcast.pyscript3.2 KB
examples/video.pyscript5.9 KB
scripts/__init__.pyscript73 B
scripts/_ci_e2e_notebooks.pyscript19.0 KB
scripts/_ci_progress.pyscript2.5 KB
scripts/_ci_rpc_progress.pyscript7.5 KB
scripts/_live_auth_scenarios/__init__.pyscript2.6 KB
scripts/_live_auth_scenarios/_contract.pyscript1.9 KB
scripts/_live_auth_scenarios/browser_refresh.pyscript3.1 KB
scripts/_live_auth_scenarios/crash_safe_writer.pyscript1.9 KB
scripts/_live_auth_scenarios/master_token_recovery.pyscript3.3 KB
scripts/_live_auth_scenarios/mcp_recovery.pyscript3.0 KB
scripts/_live_auth_scenarios/rest_recovery.pyscript5.9 KB
scripts/_live_auth_scenarios/sibling_concurrent_reload.pyscript3.9 KB
scripts/_live_auth_scenarios/storage_reload.pyscript2.9 KB
scripts/_onetime_rescrub_cookies.pyscript6.6 KB
scripts/_onetime_retarget_cassette_hosts.pyscript8.5 KB
scripts/_strip_audit_refs.pyscript15.9 KB
scripts/_tracked_files.pyscript872 B
scripts/aggregate_ci_e2e_outcomes.pyscript10.8 KB
scripts/android_grpc_canary.pyscript26.6 KB
scripts/api-compat-allowlist.jsonconfig163 B
scripts/audit_auth_import_graph.pyscript7.5 KB
scripts/audit_auth_patch_sites.pyscript83.6 KB
scripts/audit_auth_shared_mutations.pyscript41.7 KB
scripts/audit_backend_coupling.pyscript32.8 KB
scripts/audit_public_api_compat.pyscript47.4 KB
scripts/audit_test_suite.pyscript10.7 KB
scripts/capture_mobile_grpc.jsscript5.1 KB
scripts/capture_rpc_registry.pyscript44.5 KB
scripts/check_action_pinning.pyscript6.7 KB
scripts/check_auth_behavior_scenario_policy.pyscript37.1 KB
scripts/check_auth_coverage_delta.pyscript23.2 KB
scripts/check_auth_lifecycle_cleanup_policy.pyscript11.7 KB
scripts/check_base_wheel.pyscript6.3 KB
scripts/check_ci_install_parity.pyscript8.8 KB
scripts/check_claude_md_freshness.pyscript8.0 KB
scripts/check_coverage_thresholds.pyscript8.4 KB
scripts/check_deprecation_targets.pyscript33.1 KB
scripts/check_docs_module_refs.pyscript14.4 KB
scripts/check_rpc_health.pyscript112.0 KB
scripts/check_workflow_permissions.pyscript5.3 KB
scripts/check_workflow_secret_gates.pyscript40.4 KB
scripts/decode_mobile_grpc.pyscript7.2 KB
scripts/diagnose_get_notebook.pyscript9.1 KB
scripts/extract_blutter_grpc_signatures.pyscript7.6 KB
scripts/live_auth_matrix.pyscript40.2 KB
scripts/manage_ci_e2e_notebooks.pyscript67.4 KB
scripts/materialize_ci_auth.pyscript8.0 KB
scripts/mcp_live_smoke.pyexecutablescript224 B
scripts/parse_pbenums.pyscript8.6 KB
scripts/parse_pbschema.pyscript11.8 KB
scripts/regen_baselines.pyscript2.7 KB
scripts/regenerate_android_protos.pyscript16.3 KB
scripts/rescrub-cassettes.pyscript13.3 KB
scripts/scrub_rpc_har.pyscript9.4 KB
scripts/select_ci_account.pyscript4.8 KB
scripts/stress_fault_server.pyscript20.6 KB
scripts/test_taxonomy_inventory.pyscript16.1 KB
scripts/verify_ci_artifacts.pyscript35.3 KB

scripts/parse_pbenums.py

View on GitHub
#!/usr/bin/env python3
"""Regenerate ``docs/android/enums.txt`` from a blutter dump directory.

Every ``ProtobufEnum`` value in the Dart AOT snapshot is an object holding its integer
(``off_8``) and its name (``off_10``).  The object store (``objs.txt``) is exhaustive and lists
instances grouped by class, so a class name that several Dart libraries define shows up as
several separate runs of objects.  The object pool (``pp.txt``) only inlines the values the
compiled code references directly, but its ``List<Enum>`` ``values`` literals are referenced
from the defining library's disassembly (``asm/<library>/*.dart``), which attributes each run
to a library.  Every run is rendered as its own block, so two enums that merely share a Dart
class name are never merged, and an integer that carries two names inside one enum (an alias)
is rendered twice rather than silently collapsed.
"""

import glob
import os
import re
import sys

OBJECT_RE = re.compile(r"^Obj!(?P<cls>\w+)@(?P<ref>[0-9a-fA-F]+) : \{$")
POOL_OBJECT_RE = re.compile(r"^\[pp\+0x[0-9a-fA-F]+\] Obj!(?P<cls>\w+)@(?P<ref>[0-9a-fA-F]+) : \{")
POOL_LIST_RE = re.compile(
    r"^\[pp\+0x(?P<offset>[0-9a-fA-F]+)\] List<(?P<cls>\w+)>\(\d+\) \[(?P<refs>[^\]]*)\]"
)
LIST_REF_RE = re.compile(r"Obj!\w+@(?P<ref>[0-9a-fA-F]+)")
VALUE_RE = re.compile(r"^\s+off_8: int\((?P<value>-?0x[0-9a-fA-F]+|-?\d+)\),?$")
NAME_RE = re.compile(r"^\s+off_10: \"(?P<name>[^\"]+)\"")
POOL_OFFSET_RE = re.compile(r"pp\+0x(?P<offset>[0-9a-fA-F]+)\b")
ENUM_CLASS_RE = re.compile(r"^class (?P<cls>\w+) extends ProtobufEnum\b", re.MULTILINE)


def parse_enum_runs(objs_path):
    """Return ``[(class, {object ref: (integer, name)}), …]`` — one entry per class run.

    ``objs.txt`` lists the instances of one class contiguously, so a new run of the same
    class name after other objects is a different Dart class that happens to share the name.
    """
    with open(objs_path, errors="replace") as fh:
        lines = fh.read().split("\n")
    runs = []
    previous_cls = None
    for index, line in enumerate(lines):
        match = OBJECT_RE.match(line)
        if not match:
            continue
        cls = match.group("cls")
        is_enum = index + 1 < len(lines) and "Super!ProtobufEnum" in lines[index + 1]
        if not is_enum:
            previous_cls = None
            continue
        value = name = None
        for body in lines[index + 2 : index + 6]:
            if (mv := VALUE_RE.match(body)) is not None:
                value = int(mv.group("value"), 0)
            if (mn := NAME_RE.match(body)) is not None:
                name = mn.group("name")
        if value is None or name is None:
            continue
        if cls != previous_cls:
            runs.append((cls, {}))
            previous_cls = cls
        runs[-1][1][match.group("ref").lower()] = (value, name)
    return runs


def parse_pool(pp_path, enum_classes):
    """Return inlined object refs and ``values`` lists per enum class from ``pp.txt``.

    ``pool_refs`` is ``{class: {ref}}`` for objects the pool inlines directly;
    ``pool_lists`` is ``{class: [(pool offset, {ref}), …]}`` for its ``List<Enum>`` literals.
    """
    pool_refs = {}
    pool_lists = {}
    with open(pp_path, errors="replace") as fh:
        for line in fh:
            if (match := POOL_OBJECT_RE.match(line)) is not None:
                if match.group("cls") in enum_classes:
                    pool_refs.setdefault(match.group("cls"), set()).add(match.group("ref").lower())
            elif (match := POOL_LIST_RE.match(line)) is not None:
                if match.group("cls") in enum_classes:
                    refs = {
                        m.group("ref").lower() for m in LIST_REF_RE.finditer(match.group("refs"))
                    }
                    pool_lists.setdefault(match.group("cls"), []).append(
                        (match.group("offset").lower(), refs)
                    )
    return pool_refs, pool_lists


def parse_libraries(asm_root, enum_classes):
    """Return ``(offset -> {library}, class -> {library})`` from the per-library disassembly.

    A library is the directory name directly under ``asm/``.  ``offset_libraries`` records
    which libraries reference each pool offset; ``class_libraries`` records which libraries
    declare each enum class.
    """
    offset_libraries = {}
    class_libraries = {}
    for path in glob.glob(os.path.join(asm_root, "*", "*.dart")):
        library = os.path.basename(os.path.dirname(path))
        with open(path, errors="replace") as fh:
            text = fh.read()
        for match in ENUM_CLASS_RE.finditer(text):
            if match.group("cls") in enum_classes:
                class_libraries.setdefault(match.group("cls"), set()).add(library)
        for match in POOL_OFFSET_RE.finditer(text):
            offset_libraries.setdefault(match.group("offset").lower(), set()).add(library)
    return offset_libraries, class_libraries


def attribute_runs(runs, pool_lists, offset_libraries, class_libraries):
    """Return ``[(class, library or None, objects)]`` by tying each run to its library.

    A run whose objects appear in a ``values`` list takes the library that references that
    list — but only when every such list points at the same single library; conflicting
    list evidence leaves the run unattributed instead of letting ``pp.txt`` order decide.
    When a class has exactly one declaring library, or exactly one library is left unclaimed
    after the list evidence, the remaining run takes it; otherwise it stays unattributed
    rather than being guessed.
    """
    attributed = []
    by_class = {}
    for index, (cls, _objects) in enumerate(runs):
        by_class.setdefault(cls, []).append(index)
    for cls, indexes in by_class.items():
        libraries = dict.fromkeys(indexes)
        for index in indexes:
            refs = set(runs[index][1])
            candidates = set()
            for offset, list_refs in pool_lists.get(cls, ()):
                if refs & list_refs:
                    candidates |= offset_libraries.get(offset, set())
            if len(candidates) == 1:
                libraries[index] = candidates.pop()
        unclaimed = set(class_libraries.get(cls, ())) - set(filter(None, libraries.values()))
        pending = [index for index, library in libraries.items() if library is None]
        if len(pending) == 1 and len(unclaimed) == 1:
            libraries[pending[0]] = unclaimed.pop()
        for index in indexes:
            attributed.append((cls, libraries[index], runs[index][1]))
    return attributed


def render(attributed, pool_refs):
    """Render one block per (class, library) in the ``enums.txt`` format."""
    blocks = []
    order = sorted(attributed, key=lambda item: (item[0], item[1] or "~"))
    for cls, library, objects in order:
        pairs = sorted(set(objects.values()))
        pool_values = {objects[ref][0] for ref in pool_refs.get(cls, ()) if ref in objects}
        header = f"=== {cls} ({len(pairs)})"
        header += f"  [library {library}]" if library else "  [library unattributed]"
        if not pool_values:
            header += "  [objs-ONLY]"
        elif adds := sorted({value for value, _ in pairs} - pool_values):
            header += f"  [objs adds {adds}]"
        if aliases := sorted({v for v, _ in pairs if sum(1 for x, _ in pairs if x == v) > 1}):
            header += f"  [aliases {aliases}]"
        lines = [header + " ==="] + [f"  {value} = {name}" for value, name in pairs]
        blocks.append("\n".join(lines))
    return "\n" + "\n\n".join(blocks) + "\n"


def main(argv=None):
    """Write the merged, library-attributed enum inventory for a blutter dump to stdout."""
    argv = sys.argv[1:] if argv is None else argv
    if len(argv) != 1:
        print(
            "usage: parse_pbenums.py <blutter out dir containing objs.txt, pp.txt and asm/>",
            file=sys.stderr,
        )
        return 2
    root = argv[0]
    runs = parse_enum_runs(os.path.join(root, "objs.txt"))
    enum_classes = {cls for cls, _ in runs}
    pool_refs, pool_lists = parse_pool(os.path.join(root, "pp.txt"), enum_classes)
    offset_libraries, class_libraries = parse_libraries(os.path.join(root, "asm"), enum_classes)
    attributed = attribute_runs(runs, pool_lists, offset_libraries, class_libraries)
    sys.stdout.write(render(attributed, pool_refs))
    total = sum(len(set(objects.values())) for _, _, objects in attributed)
    unattributed = sum(1 for _, library, _ in attributed if library is None)
    print(
        f"parsed {len(attributed)} enums ({len(enum_classes)} class names, "
        f"{unattributed} unattributed), {total} values",
        file=sys.stderr,
    )
    return 0


if __name__ == "__main__":
    sys.exit(main())
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall