CLI usability: pip-installable + default to current directory#3
CLI usability: pip-installable + default to current directory#3anschmieg wants to merge 4 commits into
Conversation
- Add pyproject.toml defining package metadata and console script entry point - Convert client-cli/ into an installable package by adding init.py - Adjust import in python_cli.py to work both as script and installed module (try/except) - Ignore generated *.egg-info/ directories in .gitignore
When neither --directory nor --files is provided, the CLI now defaults to os.getcwd() so running `momoa "prompt"` operates on the current working directory instead of doing nothing. 💘 Generated with Crush Assisted-by: GLM 5.1 via Crush <crush@charm.land>
There was a problem hiding this comment.
Pull request overview
Adds Python packaging and a small CLI UX improvement so momoa-cli can be installed via pip and behaves more naturally when no input paths are provided.
Changes:
- Add
pyproject.tomldefining amomoaconsole script and packaging metadata formomoa-cli. - Update
python_cli.pyto support both direct execution and package-relative imports, and default file collection to the current working directory when-d/-fare omitted. - Ignore Python
*.egg-info/artifacts in.gitignore(and add__init__.pyto ensure the CLI directory is a package).
Reviewed changes
Copilot reviewed 2 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
pyproject.toml |
Introduces setuptools-based packaging + momoa entrypoint. |
client-cli/python_cli.py |
Adds dual-mode import for agentignore_rules and defaults to CWD for directory scanning. |
client-cli/__init__.py |
Makes the CLI directory importable as a Python package for console-script installs. |
.gitignore |
Prevents committing generated *.egg-info/ metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # If no directory or files specified, default to current directory | ||
| if args.directory is None and not args.files: | ||
| args.directory = os.getcwd() |
There was a problem hiding this comment.
Defaulting to uploading the entire current working directory can unintentionally exfiltrate sensitive or very large content (e.g., .env, .git/, node_modules/, virtualenvs), because evaluate_path defaults to include everything when no .agentignore is present and the CLI reads all file contents into memory before chunking. Please add a safety mitigation (e.g., built-in default excludes for common sensitive/huge paths, require confirmation when defaulting to CWD, and/or cap total files/bytes) to reduce accidental leakage and OOM/slow runs.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
more specific ModuleNotFoundError instead of ImportError Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
This PR adds two small quality-of-life improvements for
momoa-cli:pip installsupport — adds apyproject.tomlso the CLI can be installed as a global console script (momoa) viapip install -e .. Also tweaks theagentignore_rulesimport to work both as a standalone script and as an installed package.momoa "your query"without passing-dor-f, it now automatically operates on the current working directory, saving some keystrokes for frequent use.Test run
pip install -e .installs and registers themomoacommandmomoa "prompt"without-d/-fpicks up files from CWD-dand-fstill work as beforepython client-cli/python_cli.pydirectly still works