Skip to content

Conversation

@khnumdev
Copy link
Owner

Add initial README.md and CONTRIBUTORS.md documentation for the avendehut CLI tool.


Open in Cursor Open in Web

@cursor
Copy link

cursor bot commented Aug 25, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

.env.example Outdated
@@ -0,0 +1,10 @@
# OneDrive / Microsoft Graph configuration
ONEDRIVE_CLIENT_ID=
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent add a todo as placeholders

Copy link

@cursor cursor bot Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I significantly enhanced the application by implementing full OneDrive integration, allowing it to list and process files directly from Microsoft Graph. This involved adding new dependencies and updating configuration examples, alongside minor CLI improvements.

  • I replaced the OneDrive stub in avendehut/utils/onedrive.py with a functional implementation using msgraph-sdk and azure-identity. This includes methods for authenticating via DeviceCodeCredential, handling paginated results from the Graph API, and recursively listing files from a specified OneDrive path.
  • I added azure-identity and msgraph-sdk to pyproject.toml to support the new OneDrive integration.
  • I updated .env.example to include ONEDRIVE_TENANT_ID and added TODO comments for clearer setup instructions.
  • I standardized the help options across all click commands in avendehut/cli.py and avendehut/commands/*.py by adding "-help" to context_settings.
  • I updated the repository URL in README.md to reflect the correct GitHub path.

Open in Cursor Open in Web

Learn more about Cursor Agents

README.md Outdated

1. Clone the repository.
```bash
git clone https://github.com/yourusername/avendehut.git
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent Put the right path

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web



@click.command()
@click.option("--src", type=click.Path(exists=True, file_okay=False, path_type=Path), required=True, help="Source folder (local or onedrive:/path)")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent for all the commands, add a -help parameter to describe the options available

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web



def list_onedrive_files(prefix_path: str) -> Iterable[Path]: # pragma: no cover - stub
raise NotImplementedError("OneDrive listing not implemented. Use local paths for now.")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent implement this. Use official sdk to iterate pages and returning resu,to of files in each folder

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web


def _get_graph_client() -> GraphServiceClient:
client_id = os.environ["ONEDRIVE_CLIENT_ID"]
tenant_id = os.environ.get("ONEDRIVE_TENANT_ID", "consumers")
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent we are using clientid/clientsecret,not interactive

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web

try:
token = credential.get_token("Files.Read.All")
except Exception:
cred = DeviceCodeCredential(client_id=os.environ["ONEDRIVE_CLIENT_ID"], tenant_id=os.environ.get("ONEDRIVE_TENANT_ID", "consumers"))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent don't repeat code. Do a clean and better iteration for this

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web

pyproject.toml Outdated
name = "avendehut"
version = "0.1.0"
description = "CLI to scan books, extract metadata, and generate a searchable HTML catalog."
authors = ["Your Name <[email protected]>"]
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent populatewith my data. You know the repo you are

Copy link

@cursor cursor bot Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I significantly refactored the OneDrive integration to use app-only authentication via ClientSecretCredential, enhancing automation capabilities by removing interactive user prompts. I also improved the README.md with practical usage examples for the CLI commands.

  • I updated avendehut/utils/onedrive.py to switch from DeviceCodeCredential (interactive) to ClientSecretCredential for OneDrive authentication, enabling app-only access. This now requires ONEDRIVE_CLIENT_SECRET and ONEDRIVE_TENANT_ID environment variables.
  • I refactored the OneDrive file listing logic in _iterate_children within avendehut/utils/onedrive.py to leverage the Microsoft Graph SDK's built-in pagination, removing the need for manual requests calls to follow @odata.nextLink.
  • I added a new "Usage" section to README.md with bash examples for avendehut build, open, search, and export commands to provide clear guidance.
  • I updated the authors, homepage, and repository fields in pyproject.toml to reflect the khnumdev profile.

4 tasks completed

  • Refactor OneDrive to client secret and clean pagination
  • Add basic Usage section to README
  • Update pyproject authors and repo to khnumdev
  • Run test suite after changes
Open in Cursor Open in Web

Learn more about Cursor Agents

- `OUT_FOLDER` (local output path)
- Register an app and configure permissions by following Microsoft's official docs: [Register an application](https://learn.microsoft.com/en-us/graph/auth-register-app-v2).

### CLI Commands
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent add a basic "usage" section

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent add basic usage section, to process from local and for one drive

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web


### Installation

1. Clone the repository.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent This should be for development.

Ideally, I'd like to have this as a package published.

  1. Prepare CI with an action to publish package in some python repository
  2. Add here instructions to install that package

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent still pending

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to increase your spend limit or enable usage-based billing to run background agents. Go to Cursor

reader = PdfReader(str(path))
info = reader.metadata or {}
title = (getattr(info, "title", None) or path.stem)
author = getattr(info, "author", None)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent use any attributes apart from these, like Subject: A brief description or the central idea of the document.
Keywords/Tags: Terms that help categorize and search for the document's content.
Creation Date: The date and time the document was first created.
Modification Date: The date and time the document was last changed.
Creator/Application: The software that created the original document (e.g., Microsoft Word).
Producer: The software that converted the document into its PDF format.
File Name: The name of the file itself.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web

title: str
authors: List[str]
year: Optional[int]
language: Optional[str]
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent it may happen that same book is prsent in different formats, like EPUB of PDF. Normally file name is the same for both, but with differnt extensions.
Probably the model should be updated to a "book" and it should have different formats with the links of the files

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web

- `OUT_FOLDER` (local output path)
- Register an app and configure permissions by following Microsoft's official docs: [Register an application](https://learn.microsoft.com/en-us/graph/auth-register-app-v2).

### CLI Commands
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent add basic usage section, to process from local and for one drive



def iter_source_files(src: Path) -> Iterable[Path]:
for root, _dirs, files in os.walk(src):
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cursoragent is this using onedrive or local? It should the one based on the path provided

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it! I'll start making changes in this branch.

Open in Cursor Open in Web

@khnumdev khnumdev marked this pull request as ready for review August 25, 2025 12:16
cursor bot pushed a commit that referenced this pull request Oct 17, 2025
…Drive opt-in.

- Support -h/-help/--help across commands; document help usage.
- Fix README repo path and clarify OneDrive env and setup.
- Add .env.example placeholders and tidy variables.
- Make OneDrive deps optional via lazy imports; clarify build src type.
- Minor robustness in build: validate src, error on onedrive path until sync.
- Ensure EPUB parsing lazy-imports ebooklib to speed tests.
@khnumdev khnumdev assigned khnumdev and Copilot and unassigned khnumdev Nov 4, 2025
@khnumdev
Copy link
Owner Author

khnumdev commented Nov 4, 2025

@copilot apply pending feedback and finish the PR. Ensure this is working,run any test required.

Copy link

Copilot AI commented Nov 4, 2025

@khnumdev I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you.

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.

3 participants