diff --git a/AGENTS.md b/AGENTS.md index acba858..db04240 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,42 +1,52 @@ # Repository Guidelines -## Project Structure & Module Organization -- `src/cmdforge/` contains the core Python package (CLI entry point, tool model, runner, providers, UI backends). -- `tests/` holds pytest suites. -- `docs/` includes installation, provider setup, examples, and design notes. -- `examples/` provides sample tools and an installer script. -- `wiki/` contains additional reference material. +> **Note**: See CLAUDE.md for comprehensive project documentation. This file provides a quick reference for common patterns. -## Architecture Overview -- `cli/` directory routes subcommands like `list`, `create`, `run`, `test`, and `refresh`. -- `tool.py` defines tool/step models and handles YAML config loading and wrapper generation. -- `runner.py` executes steps and performs `{input}`/argument variable substitution. -- `providers.py` shells out to configured AI provider CLIs (or the `mock` provider). -- `gui/` provides the PySide6 desktop GUI with pages for tools, registry, and providers. +## Project Structure -## Build, Test, and Development Commands -- `pip install -e ".[dev]"` installs CmdForge in editable mode with dev dependencies. -- `pytest` runs the full test suite. -- `pytest tests/test.py::test_name` runs a focused test. -- `python -m cmdforge.cli` runs the CLI module directly. -- `cmdforge` launches the desktop GUI (requires PySide6). -- `docker-compose build` builds the dev container image. -- `docker-compose run --rm test` runs tests inside Docker. +- `src/cmdforge/` - Core Python package (CLI, tool model, runner, providers, GUI) +- `tests/` - Pytest test suites +- `docs/` - Infrastructure and deployment documentation -## Coding Style & Naming Conventions -- Python code uses 4-space indentation and module/variable names in `snake_case`. -- Keep CLI command names and tool IDs lowercase with hyphens (e.g., `fix-grammar`, `json-extract`). -- Prefer small, composable functions that mirror the Unix pipe flow described in `README.md`. +## Development Commands -## Testing Guidelines -- Framework: `pytest` (configured in `pyproject.toml`). -- Place new tests under `tests/` and name files `test_*.py`. -- For provider-dependent logic, prefer the built-in `mock` provider to avoid network calls. +```bash +pip install -e ".[dev]" # Install in dev mode +pytest tests/ -m "not integration" # Run unit tests +cmdforge # Launch GUI +cf # Interactive tool picker +``` -## Commit & Pull Request Guidelines -- Commit messages follow short, imperative, sentence-case subjects (e.g., "Improve provider error messages"). -- PRs should include a clear summary, test results (or rationale if tests are skipped), and screenshots when UI behavior changes. +## Architecture Quick Reference -## Security & Configuration Tips -- Provider credentials live in `~/.cmdforge/providers.yaml`; avoid committing secrets. -- User tool configs live in `~/.cmdforge//config.yaml` and should not be added to the repo. +- `cli/` - Routes all subcommands (list, create, run, test, providers, registry, collections, deps, install, etc.) +- `tool.py` - Tool/step dataclasses, YAML loading, wrapper generation +- `runner.py` - Step execution, variable substitution (`{input}`, `{varname}`) +- `providers.py` - AI provider abstraction (calls CLI tools via subprocess) +- `gui/` - PySide6 desktop GUI with page-based navigation +- `web/` - Flask web UI and forum +- `registry/` - Flask registry API (search, publish, moderation) + +## Coding Style + +- Python: 4-space indentation, `snake_case` for modules/variables +- CLI tools: lowercase with hyphens (e.g., `fix-grammar`, `json-extract`) +- Follow Unix pipe philosophy: composable tools with stdin/stdout + +## Testing + +- Framework: `pytest` (see `pyproject.toml`) +- Test files: `tests/test_*.py` +- Use `mock` provider or `--dry-run` to avoid network calls +- Integration tests require `@pytest.mark.integration` decorator + +## Commit Guidelines + +- Short, imperative, sentence-case subjects (e.g., "Add provider validation") +- Include test results or rationale if skipped +- Add screenshots for UI changes + +## Security + +- Provider configs: `~/.cmdforge/providers.yaml` (never commit) +- Tool configs: `~/.cmdforge//config.yaml` (user data, never commit) diff --git a/CLAUDE.md b/CLAUDE.md index 468d609..a45959d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -39,7 +39,7 @@ python -m cmdforge.cli # Alternative CLI invocation ### Core Modules (`src/cmdforge/`) -- **cli/**: CLI commands entry points (`cmdforge` command). Routes subcommands: list, create, edit, delete, test, run, refresh, collections, registry, settings, system-deps +- **cli/**: CLI commands entry points (`cmdforge` command). Routes subcommands: list, create, edit, delete, test, run, ui, docs, check, refresh, providers, registry, collections, deps, install, lock, verify, add, remove, init, config, settings, system-deps - **tool.py**: Tool definition dataclasses (`Tool`, `ToolArgument`, `PromptStep`, `CodeStep`, `ToolStep`), YAML config loading/saving, wrapper script generation - **runner.py**: Execution engine. Runs tool steps sequentially, handles variable substitution (`{input}`, `{varname}`), executes Python code steps via `exec()`, handles nested tool calls with depth limit (MAX_TOOL_DEPTH=10) - **resolver.py**: Tool resolution. `resolve_tool()` searches: project manifest → local tools → owner/name → registry. Returns `ResolvedTool` with path info @@ -49,10 +49,15 @@ python -m cmdforge.cli # Alternative CLI invocation - **manifest.py**: Project manifest (`cmdforge.yaml`) for declaring tool dependencies with version constraints - **lockfile.py**: Lock file support for reproducible installs (`cmdforge.lock`) - **registry_client.py**: Client for registry API (search, publish, download, authentication) +- **config.py**: Global configuration management (registry URL, auth tokens) +- **system_deps.py**: System package dependency management (apt/dnf/pacman detection and installation) +- **dependency_graph.py**: Dependency graph resolution for meta-tools +- **hash_utils.py**: Hash verification utilities for tool integrity - **gui/**: PySide6 desktop GUI - **main_window.py**: Main application window with sidebar navigation - - **pages/**: Tools page, Tool Builder, Registry browser, Collections page, Providers management, Profiles - - **dialogs/**: Step editors, Argument editor, Provider dialog, Connect/Publish dialogs + - **pages/**: Welcome page, Tools page, Tool Builder, Registry browser, Collections page, Providers management, Profiles + - **dialogs/**: Step editors (prompt/code/tool), Argument editor, Provider dialog, Connect/Publish dialogs, Test Step dialog, Settings dialog, System Dep dialog, Help dialogs, Review/Issue dialogs + - **widgets/**: Flow graph visualization (`flow_graph.py`), Icon utilities (`icons.py`) ### Key Paths @@ -113,11 +118,15 @@ CmdForge includes a web interface and tool registry: - **app.py**: Flask app factory, registers blueprints - **routes.py**: Main web routes (docs, tutorials, tools, etc.) +- **auth.py**: Authentication middleware and decorators +- **sessions.py**: Session management +- **email.py**: Email utilities (password reset, notifications) +- **seo.py**: SEO utilities (sitemap, meta tags) +- **filters.py**: Jinja2 filters (timeago, markdown, etc.) +- **docs_content.py**: Documentation and tutorial content - **forum/**: Community forum blueprint - **models.py**: Forum database schema (categories, topics, replies) - **routes.py**: Forum routes (/forum, /forum/c/, /forum/t/) -- **filters.py**: Jinja2 filters (timeago, markdown, etc.) -- **docs_content.py**: Documentation and tutorial content ### Registry Modules (`src/cmdforge/registry/`) @@ -125,6 +134,12 @@ CmdForge includes a web interface and tool registry: - **db.py**: SQLite schema and queries (`connect_db()`, `query_one()`, `query_all()`) - **embeddings.py**: Semantic search with vector embeddings for tool discovery - **sync.py**: Git-based tool sync from Gitea repository +- **categorize.py**: Auto-categorization of tools based on content +- **rate_limit.py**: Rate limiting for API endpoints +- **scrutiny.py**: Tool vetting (honesty, transparency, scope, efficiency checks) +- **similarity.py**: Duplicate detection via embedding similarity +- **stats.py**: Registry statistics and metrics +- **settings.py**: Server-side settings management ### Key URLs