Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

fix: address notebooklm review feedback

liuche0a4d8237c561
diff --git a/notebooklm/agent-harness/cli_anything/notebooklm/README.md b/notebooklm/agent-harness/cli_anything/notebooklm/README.md
index 2751f83d8..88fff930f 100644
--- a/notebooklm/agent-harness/cli_anything/notebooklm/README.md
+++ b/notebooklm/agent-harness/cli_anything/notebooklm/README.md
@@ -38,7 +38,7 @@ python3 -m playwright install chromium
# Show help
cli-anything-notebooklm --help
-# Check auth state
+# Check auth state (wraps `notebooklm auth check`)
cli-anything-notebooklm auth status
# List notebooks
@@ -57,7 +57,7 @@ python3 -m cli_anything.notebooklm.notebooklm_cli --help
| Group | Purpose |
| --- | --- |
-| `auth` | login, auth status, and lightweight auth checks |
+| `auth` | login helpers and authentication checks |
| `notebook` | list, create, and summarize notebooks |
| `source` | inspect sources and add URL sources |
| `chat` | ask questions and inspect history |
@@ -78,7 +78,7 @@ cli-anything-notebooklm artifact generate-report --notebook nb_123
## For AI Agents
- Prefer explicit notebook IDs with `--notebook` instead of relying on ambient state.
-- Use `--json` whenever the command supports machine-readable output.
+- Use `--json` only on commands whose upstream `notebooklm` subcommand supports machine-readable output.
- Treat NotebookLM auth state as sensitive local data and never print cookie or storage files.
- Treat this harness as a thin wrapper around `notebooklm`, not a reimplementation of NotebookLM.
diff --git a/notebooklm/agent-harness/cli_anything/notebooklm/notebooklm_cli.py b/notebooklm/agent-harness/cli_anything/notebooklm/notebooklm_cli.py
index 53640752b..5da8612e6 100644
--- a/notebooklm/agent-harness/cli_anything/notebooklm/notebooklm_cli.py
+++ b/notebooklm/agent-harness/cli_anything/notebooklm/notebooklm_cli.py
@@ -84,7 +84,7 @@ def auth():
@handle_error
def auth_status():
"""Check authentication status."""
- emit(run_notebooklm(["status"], json_output=_json_output))
+ emit(run_notebooklm(["auth", "check"], json_output=_json_output))
@auth.command("login")
diff --git a/notebooklm/agent-harness/cli_anything/notebooklm/skills/SKILL.md b/notebooklm/agent-harness/cli_anything/notebooklm/skills/SKILL.md
index 9a8c6b514..12940c3a7 100644
--- a/notebooklm/agent-harness/cli_anything/notebooklm/skills/SKILL.md
+++ b/notebooklm/agent-harness/cli_anything/notebooklm/skills/SKILL.md
@@ -47,7 +47,7 @@ cli-anything-notebooklm --json notebook list
| Group | Purpose |
| --- | --- |
-| `auth` | login and auth status |
+| `auth` | login and auth validation |
| `notebook` | notebook list, create, summary |
| `source` | source listing and URL add |
| `chat` | ask questions and inspect history |
@@ -60,12 +60,12 @@ cli-anything-notebooklm --json notebook list
1. Check auth with `cli-anything-notebooklm auth status`
2. Discover notebook IDs with `cli-anything-notebooklm --json notebook list`
3. Use explicit `--notebook` for follow-up commands
-4. Prefer `--json` for list and inspection commands
+4. Prefer `--json` only where the upstream `notebooklm` command supports it
## Agent Guidance
- Prefer explicit notebook IDs with `--notebook`.
-- Use `--json` for machine-readable output.
+- Use `--json` for machine-readable output only on commands that support it upstream.
- Treat this harness as experimental and unofficial.
- Do not expose auth files or cookies in logs.
- NotebookLM is a Google product; this harness is unofficial and not affiliated with Google.
diff --git a/notebooklm/agent-harness/cli_anything/notebooklm/tests/TEST.md b/notebooklm/agent-harness/cli_anything/notebooklm/tests/TEST.md
index 26a3afe23..24b37f86a 100644
--- a/notebooklm/agent-harness/cli_anything/notebooklm/tests/TEST.md
+++ b/notebooklm/agent-harness/cli_anything/notebooklm/tests/TEST.md
@@ -62,3 +62,28 @@ python3 -m cli_anything.notebooklm.notebooklm_cli --help
- Added doc-level assertions so the package README and skill file now explicitly cover installation, tests, safety boundaries, and unofficial Google attribution.
- Added `_resolve_cli`-style subprocess smoke coverage so the CLI can be exercised through a resolved command path, not only through Click's in-process test runner.
+
+## Review Fix Verification
+
+Verified on 2026-03-17 after addressing PR review feedback about JSON passthrough and auth command semantics.
+
+### Commands Run
+
+```bash
+python3 -m pytest cli_anything/notebooklm/tests/test_core.py -q
+python3 -m pytest cli_anything/notebooklm/tests/test_cli_smoke.py -q
+python3 -m pytest cli_anything/notebooklm/tests -q
+python3 -m cli_anything.notebooklm.notebooklm_cli --json auth login
+```
+
+### Results
+
+- targeted backend tests: pass
+- targeted CLI routing tests: pass
+- full NotebookLM harness suite: pass
+- `--json auth login`: fails fast with a structured JSON error instead of passing an invalid `--json` flag through to upstream login
+
+### Notes
+
+- `auth status` now wraps upstream `notebooklm auth check`, which matches authentication semantics.
+- JSON passthrough is now limited to wrapper commands whose upstream `notebooklm` command has verified `--json` support.
diff --git a/notebooklm/agent-harness/cli_anything/notebooklm/tests/test_cli_smoke.py b/notebooklm/agent-harness/cli_anything/notebooklm/tests/test_cli_smoke.py
index e9c440f64..d803d5758 100644
--- a/notebooklm/agent-harness/cli_anything/notebooklm/tests/test_cli_smoke.py
+++ b/notebooklm/agent-harness/cli_anything/notebooklm/tests/test_cli_smoke.py
@@ -56,6 +56,25 @@ class TestSubcommandHelp:
assert "List notebooks" in result.output
+class TestCommandRouting:
+ def test_auth_status_routes_to_auth_check(self, monkeypatch):
+ calls = []
+
+ def fake_run(args, **kwargs):
+ calls.append((args, kwargs))
+ return {"ok": True}
+
+ monkeypatch.setattr(
+ "cli_anything.notebooklm.notebooklm_cli.run_notebooklm",
+ fake_run,
+ )
+
+ result = CliRunner().invoke(cli, ["auth", "status"])
+
+ assert result.exit_code == 0
+ assert calls == [(["auth", "check"], {"json_output": False})]
+
+
class TestModuleExecution:
def test_python_m_module_help_emits_output(self):
result = subprocess.run(
diff --git a/notebooklm/agent-harness/cli_anything/notebooklm/tests/test_core.py b/notebooklm/agent-harness/cli_anything/notebooklm/tests/test_core.py
index 7ef1a4889..bc9d2f770 100644
--- a/notebooklm/agent-harness/cli_anything/notebooklm/tests/test_core.py
+++ b/notebooklm/agent-harness/cli_anything/notebooklm/tests/test_core.py
@@ -9,7 +9,9 @@ import pytest
from cli_anything.notebooklm.core.session import Session
from cli_anything.notebooklm.utils.notebooklm_backend import (
build_command,
+ command_supports_json,
require_notebooklm,
+ run_notebooklm,
sanitize_error,
)
@@ -45,6 +47,20 @@ class TestCommandBuilder:
command = build_command(["list"])
assert command == ["notebooklm", "list"]
+ def test_command_supports_json_for_verified_command(self):
+ assert command_supports_json(["download", "report"]) is True
+
+ def test_command_supports_json_rejects_unsupported_command(self):
+ assert command_supports_json(["login"]) is False
+
+
+class TestRunNotebooklm:
+ def test_run_notebooklm_rejects_json_for_unsupported_command(self):
+ with patch("cli_anything.notebooklm.utils.notebooklm_backend.subprocess.run") as run_mock:
+ with pytest.raises(RuntimeError, match="JSON output is not supported for command: login"):
+ run_notebooklm(["login"], json_output=True)
+ run_mock.assert_not_called()
+
class TestErrorSanitization:
def test_sanitize_error_redacts_storage_state_path(self):
diff --git a/notebooklm/agent-harness/cli_anything/notebooklm/utils/notebooklm_backend.py b/notebooklm/agent-harness/cli_anything/notebooklm/utils/notebooklm_backend.py
index 4ff424097..6603d980f 100644
--- a/notebooklm/agent-harness/cli_anything/notebooklm/utils/notebooklm_backend.py
+++ b/notebooklm/agent-harness/cli_anything/notebooklm/utils/notebooklm_backend.py
@@ -21,6 +21,23 @@ import shutil
import subprocess
+JSON_SUPPORTED_COMMANDS = {
+ ("auth", "check"),
+ ("status",),
+ ("list",),
+ ("create",),
+ ("source", "list"),
+ ("source", "add"),
+ ("ask",),
+ ("history",),
+ ("artifact", "list"),
+ ("generate", "report"),
+ ("download", "report"),
+ ("share", "status"),
+}
+TWO_PART_COMMAND_GROUPS = {"auth", "source", "artifact", "generate", "download", "share"}
+
+
def require_notebooklm() -> str:
"""Resolve the notebooklm command from PATH."""
path = shutil.which("notebooklm")
@@ -33,6 +50,17 @@ def require_notebooklm() -> str:
)
+def command_supports_json(args: list[str]) -> bool:
+ """Return whether the wrapped notebooklm command supports --json."""
+ if not args:
+ return False
+ if len(args) > 1 and args[0] in TWO_PART_COMMAND_GROUPS:
+ key = tuple(args[:2])
+ else:
+ key = tuple(args[:1])
+ return key in JSON_SUPPORTED_COMMANDS
+
+
def build_command(
args: list[str],
*,
@@ -43,7 +71,7 @@ def build_command(
command = ["notebooklm", *args]
if notebook_id:
command.extend(["-n", notebook_id])
- if json_output:
+ if json_output and command_supports_json(args):
command.append("--json")
return command
@@ -69,6 +97,11 @@ def run_notebooklm(
json_output: bool = False,
) -> dict | str:
"""Run notebooklm and optionally parse JSON output."""
+ if json_output and not command_supports_json(args):
+ raise RuntimeError(
+ f"JSON output is not supported for command: {' '.join(args)}"
+ )
+
command = build_command(
args,
notebook_id=notebook_id,