Skip to content

Conversation

@Anderson-RC
Copy link

Feature: Read Note Commands

Summary

This PR adds commands to read note content from NotebookLM notebooks. It depends on PR #1 (GetNotes parsing fix) which adds the Content field to the Source struct.

Features

1. nlm read-note <notebook-id> <note-id>

Display the content of a specific note. First list notes to get the ID, then read the note:

# Step 1: List notes to get IDs
$ nlm notes <notebook-id>
ID                                   TITLE                    LAST MODIFIED
abc12345-6789-abcd-ef01-234567890abc Research Notes           2025-12-01T10:00:00Z
def67890-abcd-1234-5678-90abcdef1234 Literature Review        2025-12-02T14:30:00Z

# Step 2: Read a specific note using its ID
$ nlm read-note <notebook-id> abc12345-6789-abcd-ef01-234567890abc
Title: Research Notes
ID: abc12345-6789-abcd-ef01-234567890abc
-------------------
[Full note content displayed here]

2. nlm notes <notebook-id> --full

Dump all notes with their full content. Useful for piping to files or other tools for processing:

$ nlm notes <notebook-id> --full
Title: Research Notes
ID: abc12345-6789-abcd-ef01-234567890abc
Last Modified: 2025-12-01T10:00:00Z
-------------------
[Full content of first note - could be 50+ lines]
================================================================================
Title: Literature Review
ID: def67890-abcd-1234-5678-90abcdef1234
Last Modified: 2025-12-02T14:30:00Z
-------------------
[Full content of second note]
================================================================================

Example use case: A notebook with 7 notes, each ~50 lines, would output ~400 lines of content that can be piped to a file or processed by other tools:

$ nlm notes <notebook-id> --full > all_notes.md
$ nlm notes <notebook-id> --full | grep -i "keyword"

Changes

cmd/nlm/main.go

Change Description
read-note command New command to display specific note content
--full flag Global flag for bulk content dump
readNote() function Fetches notes and displays matching note content
listNotes() updated Now accepts showFull parameter
Help text Updated to document new commands

Testing

1. Unit Tests (gen/service/notes_parser_test.go)

Added unit tests for the parsing logic to ensure stability against malformed API data:

  • Nil/Type Guards: nil input, non-array inputs, empty arrays
  • Missing Fields: Entries without content or titles handled gracefully
  • Malformed Data: Invalid timestamps or metadata ignored safely
  • Edge Cases: Non-string IDs still allow content extraction

Run with locally:

go test ./gen/service/... -v

2. CLI Command Tests (cmd/nlm/main_test.go)

Updated cmd/nlm/testdata/note_commands.txt to cover new commands:

  • nlm note <id> --full argument validation
  • nlm read-note usage and auth validation

Run locally:

go test ./cmd/nlm/... -v

3. Manual Verification

Verified against live API(my Google Pro acct to my notebook):

# List notes
$ nlm notes <notebook-id>
#  Shows notes with titles

# Read specific note
$ nlm read-note <notebook-id> <note-id>
#  Shows full note content

# Dump all notes
$ nlm notes <notebook-id> --full
# Returns all content separated with ======= --> I used this to pipe to file

Usage Flow

  1. List notes to get IDs: nlm notes <notebook-id>
  2. Read a specific note: nlm read-note <notebook-id> <note-id>
  3. Or bulk extract: nlm notes <notebook-id> --full > all_notes.md

Dependencies

This PR depends on #17 (GetNotes parsing fix) which:

  • Adds Content field to Source struct
  • Extracts note content from API response position 1

…cks to improve `listNotes` command robustness.
- Add nlm read-note <notebook-id> <note-id> command to read specific notes
- Add --full flag to nlm notes to dump all notes with content
- Add Content field to Source struct in protobuf
- Update GetNotes parser to extract note content from API response
- Update help documentation
- Create notes_response.pb.go documenting expected API message types
- Extract parseNoteEntry helper function for cleaner code
- Add Content field to Source struct for note body text
- Add detailed API structure comments in GetNotes client
- Keep fallback to beprotojson for API format changes
- Update FIX_GETNOTES_PARSING.md with implementation details
- Add nlm read-note <notebook-id> <note-id> command
- Add --full flag to nlm notes for bulk content dump
- Update help documentation
- Update tests for new command structure
- Add READ_NOTE_COMMANDS.md documentation
- Update FIX_GETNOTES_PARSING.md with generic examples

Depends on: GetNotes parsing fix (schema-refactor branch)
- Test nil input handling
- Test malformed/incomplete API response structures
- Test missing fields (content, title, metadata)
- Test non-string source IDs
- Verify no panics on any malformed input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant