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/audit_auth_import_graph.py

View on GitHub
#!/usr/bin/env python3
"""Audit direct-module imports within ``notebooklm._auth`` without importing it."""

from __future__ import annotations

import argparse
import ast
import json
import sys
from collections import defaultdict
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parent.parent
DEFAULT_AUTH_DIR = REPO_ROOT / "src" / "notebooklm" / "_auth"
DEFAULT_PACKAGE_PREFIX = "notebooklm._auth"


class _ImportCollector(ast.NodeVisitor):
    def __init__(
        self,
        source: str,
        nodes: set[str],
        *,
        package_prefix: str = DEFAULT_PACKAGE_PREFIX,
        include_external: bool = False,
    ) -> None:
        self.source = source
        self.nodes = nodes
        self.package_prefix = package_prefix
        self.include_external = include_external
        self.function_depth = 0
        self.edges: set[tuple[str, str, str]] = set()

    @property
    def scope(self) -> str:
        return "function" if self.function_depth else "module"

    def _add(self, target: str) -> None:
        is_local = target in self.nodes
        if (is_local or self.include_external) and target != self.source:
            self.edges.add((self.source, target, self.scope))

    def visit_FunctionDef(self, node: ast.FunctionDef) -> None:
        self.function_depth += 1
        self.generic_visit(node)
        self.function_depth -= 1

    visit_AsyncFunctionDef = visit_FunctionDef

    def visit_Import(self, node: ast.Import) -> None:
        for item in node.names:
            prefix = f"{self.package_prefix}."
            if item.name.startswith(prefix):
                self._add(item.name[len(prefix) :].split(".", 1)[0])
            elif self.include_external and item.name.startswith("notebooklm."):
                self._add(item.name.removeprefix("notebooklm."))

    def visit_ImportFrom(self, node: ast.ImportFrom) -> None:
        module = node.module or ""
        if node.level == 1:
            if module:
                self._add(module.split(".", 1)[0])
            else:
                for item in node.names:
                    self._add(item.name.split(".", 1)[0])
            return
        if node.level == 2 and self.include_external:
            if module == "_auth":
                for item in node.names:
                    self._add(f"_auth.{item.name.split('.', 1)[0]}")
            elif module:
                self._add(module)
            else:
                for item in node.names:
                    self._add(item.name.split(".", 1)[0])
            return
        if node.level:
            return
        if module == self.package_prefix:
            for item in node.names:
                self._add(item.name.split(".", 1)[0])
        elif module.startswith(f"{self.package_prefix}."):
            self._add(module.removeprefix(f"{self.package_prefix}.").split(".", 1)[0])
        elif self.include_external:
            if module == "notebooklm":
                for item in node.names:
                    self._add(item.name.split(".", 1)[0])
            elif module.startswith("notebooklm."):
                self._add(module.removeprefix("notebooklm."))


def _strong_components(nodes: set[str], edges: set[tuple[str, str]]) -> list[list[str]]:
    adjacency: dict[str, set[str]] = defaultdict(set)
    for source, target in edges:
        adjacency[source].add(target)
    index = 0
    indices: dict[str, int] = {}
    lowlinks: dict[str, int] = {}
    stack: list[str] = []
    on_stack: set[str] = set()
    result: list[list[str]] = []

    def visit(node: str) -> None:
        nonlocal index
        indices[node] = lowlinks[node] = index
        index += 1
        stack.append(node)
        on_stack.add(node)
        for target in sorted(adjacency[node]):
            if target not in indices:
                visit(target)
                lowlinks[node] = min(lowlinks[node], lowlinks[target])
            elif target in on_stack:
                lowlinks[node] = min(lowlinks[node], indices[target])
        if lowlinks[node] == indices[node]:
            component: list[str] = []
            while True:
                member = stack.pop()
                on_stack.remove(member)
                component.append(member)
                if member == node:
                    break
            if len(component) > 1:
                result.append(sorted(component))

    for node in sorted(nodes):
        if node not in indices:
            visit(node)
    return sorted(result)


def build_projection(
    auth_dir: Path = DEFAULT_AUTH_DIR,
    *,
    repo_root: Path = REPO_ROOT,
    package_prefix: str = DEFAULT_PACKAGE_PREFIX,
    include_external: bool = False,
) -> dict[str, object]:
    """Build the deterministic module/edge/SCC projection for a direct package directory."""
    paths = sorted(auth_dir.glob("*.py"))
    nodes = {path.stem for path in paths}
    modules: list[dict[str, object]] = []
    all_edges: set[tuple[str, str, str]] = set()
    for path in paths:
        text = path.read_text(encoding="utf-8")
        try:
            relative = path.relative_to(repo_root).as_posix()
        except ValueError:
            relative = path.as_posix()
        modules.append({"name": path.stem, "path": relative, "lines": len(text.splitlines())})
        collector = _ImportCollector(
            path.stem,
            nodes,
            package_prefix=package_prefix,
            include_external=include_external,
        )
        collector.visit(ast.parse(text, filename=str(path)))
        all_edges.update(collector.edges)
    edges = [
        {"source": source, "target": target, "scope": scope}
        for source, target, scope in sorted(all_edges)
    ]
    module_pairs = {
        (s, t) for s, t, scope in all_edges if scope == "module" and s in nodes and t in nodes
    }
    all_pairs = {(s, t) for s, t, _scope in all_edges if s in nodes and t in nodes}
    return {
        "version": 1,
        "modules": modules,
        "edges": edges,
        "summary": {
            "modules": len(modules),
            "total_lines": sum(int(module["lines"]) for module in modules),
            "unique_edges": len(all_edges),
            "module_edges": sum(scope == "module" for _s, _t, scope in all_edges),
            "function_local_edges": sum(scope == "function" for _s, _t, scope in all_edges),
        },
        "sccs": {
            "module_level": _strong_components(nodes, module_pairs),
            "all_scopes": _strong_components(nodes, all_pairs),
        },
    }


def main(argv: list[str] | None = None) -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--auth-dir", type=Path, default=DEFAULT_AUTH_DIR)
    parser.add_argument("--package-prefix", default=DEFAULT_PACKAGE_PREFIX)
    parser.add_argument("--include-external", action="store_true")
    parser.add_argument("--json", action="store_true")
    args = parser.parse_args(argv)
    if not args.auth_dir.is_dir():
        parser.error(f"not a directory: {args.auth_dir}")
    projection = build_projection(
        args.auth_dir,
        package_prefix=args.package_prefix,
        include_external=args.include_external,
    )
    if args.json:
        json.dump(projection, sys.stdout, indent=2, sort_keys=True)
        sys.stdout.write("\n")
    else:
        summary = projection["summary"]
        print(
            f"{summary['modules']} modules, {summary['total_lines']} lines, "
            f"{summary['unique_edges']} edges "
            f"({summary['module_edges']} module, "
            f"{summary['function_local_edges']} function-local)"
        )
    return 0


if __name__ == "__main__":
    raise SystemExit(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