diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 601ddd7..0000000 --- a/.coveragerc +++ /dev/null @@ -1,19 +0,0 @@ -[run] -source = src -omit = - src/tests/* - */tests/* - */test_*.py - src/mdoctor/fmlint.py - src/python_ruff/pycustomlint.py - src/llm-wiki/__init__.py - -[report] -exclude_lines = - pragma: no cover - def __repr__ - raise AssertionError - raise NotImplementedError - if __name__ == .__main__.: - if TYPE_CHECKING: - @abstractmethod diff --git a/.gitignore b/.gitignore index 1506685..1d3084a 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ dist/ # Coverage .coverage +coverage.xml htmlcov/ # Jupyter Notebook checkpoints diff --git a/AGENTS.md b/AGENTS.md index 6d5786a..d6fb6e1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,6 +1,6 @@ --- name: Fiona-Assistant Agent Rules -version: 1.4.1 +version: 1.5.0 title: LLM Agent Rules type: summary created: 2025-09-23 @@ -57,7 +57,7 @@ Fiona-Assistant repository. Refer to rules in this file as `project agent rule N.M` (e.g. `project agent rule 1.1`) to differentiate them from rules in other -AGENTS.md files (e.g. the llm-wiki template's `src/llm-wiki/AGENTS.md`). +AGENTS.md files (e.g. the llm-wiki template's `src/fiona/data/llm_wiki/AGENTS.md`). --- @@ -82,7 +82,7 @@ Before step 2, load the environment (project agent rule 3.1). (project agent rule 6.1). Leave production code unchanged in this step. 3. **Implement, TDD style.** Load the - [python-tdd skill](./src/llm-wiki/utils/skills/python-tdd/SKILL.md) + [python-tdd skill](./src/fiona/data/llm_wiki/utils/skills/python-tdd/SKILL.md) (project agent rule 4.1). - Red: run the new tests and confirm they fail. - Green: write the smallest change that makes them pass. @@ -94,8 +94,8 @@ Before step 2, load the environment (project agent rule 3.1). task. Move status along `Planned` -> `Partially Implemented` -> `Implemented`, or set `Won't Do` when the requirement is rejected. - - Run `python src/run_tests.py`, then - `python src/run_sanity.py --non-interactive`. Both pass + - Run `python scripts/run_tests.py`, then + `python scripts/run_sanity.py --non-interactive`. Both pass (project agent rule 2.2). 5. **Bump versions.** On each markdown file this task edited, bump frontmatter `version` and set `updated` to the edit date @@ -111,10 +111,10 @@ bumps versions (step 5). It skips the test and implementation steps. ### 2.2 Testing -- For testing scripts always run `python src/run_tests.py` and make sure +- For testing scripts always run `python scripts/run_tests.py` and make sure everything is passing on every loop - After modifying the repo, make sure - `python src/run_sanity.py --non-interactive` passes before finalizing. + `python scripts/run_sanity.py --non-interactive` passes before finalizing. ### 2.3 Documentation @@ -178,12 +178,12 @@ dependency conflicts, incorrect Python versions, or missing packages. ### 4.1 Load Python TDD Skill for Python Tasks > When modifying or creating Python scripts, the -> [python-tdd skill](./src/llm-wiki/utils/skills/python-tdd/SKILL.md) +> [python-tdd skill](./src/fiona/data/llm_wiki/utils/skills/python-tdd/SKILL.md) > MUST be loaded ```text SKILL: python-tdd -PATH: src/llm-wiki/utils/skills/python-tdd/SKILL.md +PATH: src/fiona/data/llm_wiki/utils/skills/python-tdd/SKILL.md ``` - Project Rules: @@ -222,22 +222,25 @@ The repository has the following structure with specific permissions: ```text fiona-assistant/ -├── src/ # Source code -│ ├── llm-wiki/ # Packaged llm-wiki template (data only) -│ │ # Structure source of truth: -│ │ # `src/llm-wiki/wiki/schema.md` -│ ├── fiona/ # Main CLI package +├── src/fiona/ # The only installable package +│ ├── __main__.py # CLI entry point │ ├── librarian/ # Wiki content management │ ├── mdoctor/ # Markdown diagnosis -│ ├── python_ruff/ # Python code linting -│ ├── wiki/ # Wiki lifecycle modules (init, update) -│ ├── tests/ # Unit tests -│ ├── run_tests.py # Test runner -│ ├── run_sanity.py # Sanity runner (tests + linters) +│ ├── customlinter/ # Frontmatter, markdown, Python, JSON linters +│ ├── python_ruff/ # Ruff wrapper +│ ├── gittool/ # Git operations +│ ├── sanity_runner/ # Shared sanity engine +│ ├── wiki/ # Wiki lifecycle (init, update, sanity, graph) +│ ├── data/llm_wiki/ # Packaged template (data only) +│ ├── run_tests.py # Test runner module +│ └── run_sanity.py # Sanity runner module +├── tests/ # Unit tests (not installed) +├── scripts/ # Repo tooling, not package source +│ ├── run_tests.py # Launcher for fiona.run_tests +│ ├── run_sanity.py # Launcher for fiona.run_sanity │ ├── settings_dev.json # Development settings │ ├── utils.sh # Shell utilities │ └── install_packages.sh # Dependency installer -│ ├── pyproject.toml # Project configuration ├── bootstrap # Environment setup (bash; source it) ├── bootstrap.ps1 # Environment setup (PowerShell; dot-source it) @@ -245,7 +248,7 @@ fiona-assistant/ ``` The llm-wiki directory structure is not duplicated here: -`src/llm-wiki/wiki/schema.md` is the final source of truth for the +`src/fiona/data/llm_wiki/wiki/schema.md` is the final source of truth for the llm-wiki directory structure. **General Rules:** @@ -254,8 +257,8 @@ llm-wiki directory structure. - `/raw/` directories are **READ-ONLY** - Never edit archived source materials - `/wiki/concepts/` is **READ-WRITE** - Place synthesized content here - `/ingest/` is for **input processing** - Parse files dropped here -- **Always update** `src/llm-wiki/wiki/index.md` when adding new concepts -- **Always append** to `src/llm-wiki/wiki/log.md` for every action +- **Always update** `src/fiona/data/llm_wiki/wiki/index.md` when adding new concepts +- **Always append** to `src/fiona/data/llm_wiki/wiki/log.md` for every action --- @@ -274,7 +277,7 @@ Steps 2 and 3 of project agent rule 2.1. ```bash # Run all tests -python src/run_tests.py +python scripts/run_tests.py # Run with pytest directly python -m pytest @@ -283,7 +286,7 @@ python -m pytest python -m pytest --cov=src # Run specific test file -python -m pytest src/tests/test_md_frontmatter.py -v +python -m pytest tests/test_md_frontmatter.py -v ``` **Test File Structure:** @@ -367,10 +370,10 @@ Before step 2 of that lifecycle: 1. Set up the environment (project agent rule 3.1). 2. Load the skill when the task needs one (project agent rule 4.1). Python tasks load the - [python-tdd skill](./src/llm-wiki/utils/skills/python-tdd/SKILL.md). + [python-tdd skill](./src/fiona/data/llm_wiki/utils/skills/python-tdd/SKILL.md). Wiki tasks load the - [Fiona skill](./src/llm-wiki/utils/skills/fiona/SKILL.md) - unless `src/llm-wiki/AGENTS.md` already loaded it. + [Fiona skill](./src/fiona/data/llm_wiki/utils/skills/fiona/SKILL.md) + unless `src/fiona/data/llm_wiki/AGENTS.md` already loaded it. --- @@ -486,14 +489,14 @@ These rules **CAN** be overridden by: | Task | Required Action | | ---- | -------------- | | Development | project agent rule 2.1, in order | -| Any Python work | Load the [python-tdd skill](./src/llm-wiki/utils/skills/python-tdd/SKILL.md) | +| Any Python work | Load the [python-tdd skill](./src/fiona/data/llm_wiki/utils/skills/python-tdd/SKILL.md) | | Before testing | `source bootstrap` (Windows: `. .\bootstrap.ps1`) | | Step 1 | Write or check [SPEC](./SPEC.md) | | Step 2 and 3 | Failing tests, then the smallest change | | Step 4 | Re-read the spec; tests and sanity pass | | Step 5 | Bump `version` and `updated` on edited markdown | | Before commit | Run tests + linters | -| Wiki changes | Load the [Fiona skill](./src/llm-wiki/utils/skills/fiona/SKILL.md); update index.md + log.md | +| Wiki changes | Load the [Fiona skill](./src/fiona/data/llm_wiki/utils/skills/fiona/SKILL.md); update index.md + log.md | | Frontmatter | Include name, version, title, dates | | Errors | Raise exceptions, don't fail silently | diff --git a/README.md b/README.md index 9a305e2..6bdd71b 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ consistent, parseable structures that LLMs can easily read and process. ### Wiki Structure Support -Fiona-Assistant understands and maintains the [LLM Wiki directory structure](./llm-wiki/AGENTS.md): +Fiona-Assistant understands and maintains the [LLM Wiki directory structure](./src/fiona/data/llm_wiki/AGENTS.md): ```text llm-wiki/ @@ -258,39 +258,26 @@ Definitions: ```text fiona-assistant/ -├── llm-wiki/ # Wiki content and structure definition -│ ├── AGENTS.md # Agent rules and directory permissions -│ ├── ingest/ # Input zone for new content -│ ├── raw/ # Archived source materials -│ ├── wiki/ # Processed concept notes -│ └── utils/ # Utility scripts -│ -├── src/ -│ ├── fiona/ # Main CLI entry point -│ │ └── __main__.py # Unified command dispatcher -│ │ +├── src/fiona/ # Installable package +│ ├── __main__.py # Unified command dispatcher │ ├── librarian/ # Wiki content management -│ │ ├── __init__.py -│ │ ├── librarian.py # File scanning and listing -│ │ └── toc_generator.py # Table of contents generator -│ │ │ ├── mdoctor/ # Markdown diagnosis -│ │ ├── __init__.py -│ │ └── mdoctor.py # PyMarkdown lint wrapper -│ │ │ ├── python_ruff/ # Python code linting -│ │ ├── __init__.py -│ │ └── python_ruff.py # Ruff lint wrapper -│ │ -│ ├── tests/ # Unit tests -│ │ ├── test_fiona_main.py -│ │ ├── test_librarian.py -│ │ ├── test_mdoctor.py -│ │ └── test_python_ruff.py -│ │ -│ ├── run_tests.py # Test runner -│ └── README.md # Development documentation -│ +│ ├── customlinter/ # Custom linters +│ ├── gittool/ # Git operations +│ ├── sanity_runner/ # Shared sanity engine +│ ├── wiki/ # Wiki lifecycle +│ └── data/llm_wiki/ # Packaged wiki template +│ ├── AGENTS.md # Agent rules and directory permissions +│ ├── ingest/ # Input zone for new content +│ ├── raw/ # Archived source materials +│ ├── wiki/ # Processed concept notes +│ └── utils/ # Utility scripts +├── tests/ # Unit tests (not installed) +├── scripts/ # Repo tooling (not installed) +│ ├── run_tests.py +│ ├── run_sanity.py +│ └── settings_dev.json ├── pyproject.toml # Project configuration ├── bootstrap # Environment setup script (bash) ├── bootstrap.ps1 # Environment setup script (PowerShell) @@ -306,13 +293,13 @@ fiona-assistant/ ```bash # Run all tests -python src/run_tests.py +python scripts/run_tests.py # Or use pytest directly python -m pytest # Run with coverage -python -m pytest --cov=src +python -m pytest --cov=src/fiona ``` --- @@ -341,7 +328,7 @@ GPL-3.0-only ## Related Documentation -- [LLM Wiki Agent Rules](./llm-wiki/AGENTS.md) - Directory permissions and workflow rules +- [LLM Wiki Agent Rules](./src/fiona/data/llm_wiki/AGENTS.md) - Directory permissions and workflow rules - [Development Setup](./src/README.md) - Detailed development information - [Project Specification](./SPEC.md) - Feature spec sheet with requirements and acceptance criteria - [Project TODO](./todo.md) - Roadmap and planned features @@ -358,7 +345,7 @@ GPL-3.0-only | Check Python lint | `fiona-assistant python-ruff chklint /path/to/dir` | | Generate TOC | `generate-toc /path/to/dir --recursive-toc` | | Generate file TOC | `fiona-assistant librarian toc file /path/to/file.md --sectionized` | -| Run tests | `python src/run_tests.py` | +| Run tests | `python scripts/run_tests.py` | | Install | `pip install fiona-assistant` | | Dev install | `pip install -e .` | diff --git a/SPEC.md b/SPEC.md index 3830855..455c43a 100644 --- a/SPEC.md +++ b/SPEC.md @@ -1,6 +1,6 @@ --- name: Fiona-Assistant Specification -version: 0.40.5 +version: 0.41.0 title: Project Spec Sheet created: 2026-09-23 updated: 2026-09-29 @@ -80,7 +80,8 @@ Implemented`, `Planned`, and `Won't Do`. Revision 0.40.0 reorganizes the sheet into contracts. Revision 0.40.1 numbers nested requirements such as `7.16.1.1`. Revision 0.40.4 adds -the PYC001 exception in *6.4.2.*. +the PYC001 exception in *6.4.2.*. Revision 0.41.0 installs one +`fiona` package and keeps tests and repo scripts outside it. Each feature section starts with a `Status` line. Requirements use `- *N.M.K.*`. Each `*acceptance*` sits under the requirement it tests. @@ -134,8 +135,8 @@ These apply to every feature. - *acceptance*: `wiki update` leaves every file under `personal/` and `raw/` byte-for-byte unchanged. - *1.2.4.* Code changes follow test-first development. - `python src/run_tests.py` is green, then - `python src/run_sanity.py` is green, before a change is finished. + `python scripts/run_tests.py` is green, then + `python scripts/run_sanity.py` is green, before a change is finished. - *acceptance*: A sanity run below the coverage gate in section 5.2 fails even when every test passes. - *1.2.5.* Python passes Ruff. Markdown passes PyMarkdown with the @@ -149,8 +150,9 @@ These apply to every feature. > Status: Implemented -Python `>= 3.8`. Install with `pip install -e .` from the repository -root. Runtime dependencies: +Python `>= 3.11` (also 3.12 and 3.13). Install with `pip install -e .` +from the repository root. The build requires setuptools 61 or newer. +Runtime dependencies: | Package | Minimum | | --- | --- | @@ -158,31 +160,34 @@ root. Runtime dependencies: | ruff | 0.16.8 | | pyyaml | 6.0.3 | | GitPython | 3.1.0 | -| pylint | (unpinned; present, unused by the CLI) | -| html5validator | 0.4.0 (present for the planned HTML linter) | -Development extras: `pytest>=7.0`, `pytest-cov>=4.0`, `pytest-mock`. +Development extras: `pytest>=7.0`, `pytest-cov>=4.0`, `pytest-mock`, +`pylint`. `html5validator` is not a dependency until section 7.17 +is implemented. -Importable packages live under `src/`: `fiona`, `librarian`, -`mdoctor`, `python_ruff`, `customlinter`, `sanity_runner`, `wiki`, -`gittool`. `src/llm-wiki/` is package data (the wiki template), not -an importable module. Tests live in `src/tests/`. +One importable package, `fiona`, lives under `src/fiona/`. Its +subpackages are `librarian`, `mdoctor`, `customlinter`, +`python_ruff`, `gittool`, `sanity_runner`, and `wiki`. The wiki +template is package data at `src/fiona/data/llm_wiki/` and is loaded +with `importlib.resources`. It is not an importable module. Tests +live in repo-root `tests/` and are not installed. `scripts/` holds +`settings_dev.json`, shell helpers, and the launchers +`scripts/run_tests.py` and `scripts/run_sanity.py`. Console scripts: | Script | Entry | | --- | --- | | `fiona-assistant` | `fiona.__main__:main` | -| `librarian` | `librarian.librarian:main` | -| `mdoctor` | `mdoctor.mdoctor:main` | +| `librarian` | `fiona.librarian.librarian:main` | +| `mdoctor` | `fiona.mdoctor.mdoctor:main` | `python-ruff`, `fmlint`, `json-lint`, and `git` are reached only -through `fiona-assistant`. `pyproject.toml` still declares an -`html-js-lint` script whose package is absent. Remove that entry -until section 7.17 is implemented. +through `fiona-assistant`. `html-js-lint` is not installed until +section 7.17 is implemented. -Coverage measures `src/`, omitting tests. The gate percentage is -section 5.2. +Coverage measures `src/fiona`, omitting tests. The config lives in +`pyproject.toml`. The gate percentage is section 5.2. Logging: every CLI entry calls `setup_logging()` before work. Level order is `LOG_LEVEL` environment variable, then `fiona.log_level` in @@ -223,7 +228,6 @@ AGENTS.md README.md fiona-settings.json table_of_contents.md -__init__.py ingest/README.md personal/README.md raw/README.md @@ -606,10 +610,10 @@ Defaults: output `wiki_graph.html` in the current directory, format ### 4.13. Repository runners -`python src/run_tests.py` runs pytest with `--color=no` and a +`python scripts/run_tests.py` runs pytest with `--color=no` and a temporary JUnit XML report (`junit_family=xunit1`). -`python src/run_sanity.py [--non-interactive]` runs, in order: +`python scripts/run_sanity.py [--non-interactive]` runs, in order: `pytests`, `markdownlint`, `ruff`, `frontmatter_lint`, `pycustomlint`, `jsonlint`. Same progress display, result table, and verdict shape as wiki sanity, with label `Running Sanity` and an @@ -620,7 +624,7 @@ extra untimed `coverage:` row under pytests. Details are section 7.16. ## 5. Settings Schema Two files. `fiona-settings.json` ships in the template and marks a -wiki root. `src/settings_dev.json` is repository tooling only and is +wiki root. `scripts/settings_dev.json` is repository tooling only and is not copied into a wiki. ### 5.1. fiona-settings.json @@ -1478,10 +1482,9 @@ Implements section 4.5. The sanity check name is `ruff` in > Status: Planned -Remove the `html-js-lint` console script and the `html_js_lint` -package entry until this section is built. The intended tool -validates HTML with `html5validator` (Java 8+) and JavaScript with -`eslint` on PATH. +The `html-js-lint` console script is not installed until this +section is built. The intended tool validates HTML with +`html5validator` (Java 8+) and JavaScript with `eslint` on PATH. - *7.17.1.* `NOT_IMPLEMENTED` HTML files (default `.html` and `.htm`) are checked. Findings include path, line, and column. @@ -1580,7 +1583,7 @@ file sink. > Status: Partially Implemented `README.md` links to this spec. `src/README.md`, -`src/librarian/README.md`, and `src/mdoctor/README.md` exist and +`src/fiona/librarian/README.md`, and `src/fiona/mdoctor/README.md` exist and are behind the current CLIs. - *7.21.1.* `NOT_IMPLEMENTED` `librarian/README.md` documents `list` @@ -1588,9 +1591,9 @@ are behind the current CLIs. `fix`. - *acceptance*: A new reader can install and run each command from those files alone. -- *7.21.2.* `NOT_IMPLEMENTED` `src/README.md` lists `wiki/`, - `python_ruff/`, `run_tests.py`, `run_sanity.py`, and - `settings_dev.json`. +- *7.21.2.* `src/README.md` describes `src/fiona/` (including + `wiki/`, `python_ruff/`, and `data/llm_wiki/`), repo-root `tests/`, + and `scripts/` (`run_tests.py`, `run_sanity.py`, `settings_dev.json`). - *acceptance*: Those names appear in the structure section. - *7.21.3.* Documentation markdown passes `mdoctor chklint`. - *acceptance*: `README.md` contains a markdown link to `SPEC.md` @@ -1704,18 +1707,20 @@ These notes are not requirements. They point at the current tree. | --- | --- | | CLI dispatch | `src/fiona/__main__.py` | | Logging | `src/fiona/logging_config.py` | -| librarian list | `src/librarian/librarian.py` | -| TOC | `src/librarian/toc_generator.py` | -| mdoctor | `src/mdoctor/mdoctor.py` | -| fmlint, mdlinter, pycustomlint, json-lint | `src/customlinter/` | -| ruff wrapper | `src/python_ruff/python_ruff.py` | -| wiki init | `src/wiki/wiki.py` | -| wiki update | `src/wiki/update_manager.py` | -| wiki sanity | `src/wiki/sanity_manager.py` | -| wiki graph | `src/wiki/graph_generator.py`, `src/wiki/templates/graph_template.html` | -| git | `src/gittool/git_tool.py` | -| sanity engine | `src/sanity_runner/sanity_runner.py` | -| runners | `src/run_tests.py`, `src/run_sanity.py` | +| template path | `src/fiona/paths.py` | +| librarian list | `src/fiona/librarian/librarian.py` | +| TOC | `src/fiona/librarian/toc_generator.py` | +| mdoctor | `src/fiona/mdoctor/mdoctor.py` | +| fmlint, mdlinter, pycustomlint, json-lint | `src/fiona/customlinter/` | +| ruff wrapper | `src/fiona/python_ruff/python_ruff.py` | +| wiki init | `src/fiona/wiki/wiki.py` | +| wiki update | `src/fiona/wiki/update_manager.py` | +| wiki sanity | `src/fiona/wiki/sanity_manager.py` | +| wiki graph | `src/fiona/wiki/graph_generator.py`, `src/fiona/wiki/templates/graph_template.html` | +| git | `src/fiona/gittool/git_tool.py` | +| sanity engine | `src/fiona/sanity_runner/sanity_runner.py` | +| runners | `src/fiona/run_tests.py`, `src/fiona/run_sanity.py` | +| launchers | `scripts/run_tests.py`, `scripts/run_sanity.py` | Known defects to avoid copying blindly: diff --git a/bootstrap b/bootstrap index eab1c39..bdb9ddf 100755 --- a/bootstrap +++ b/bootstrap @@ -32,7 +32,7 @@ CLEAN_ENVIRONMENT=false # Flag to delete and recreate environment SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # scripts root directory # Source utilities (needed for echo_error, echo_status, etc.) -source "$SCRIPT_DIR/src/utils.sh" +source "$SCRIPT_DIR/scripts/utils.sh" # Parse command line arguments while [[ $# -gt 0 ]]; do @@ -387,18 +387,18 @@ upgrade_pip() { install_dev_packages() { echo_status "Installing local Python packages in development mode..." - local install_script="$SCRIPT_DIR/src/install_packages.sh" + local install_script="$SCRIPT_DIR/scripts/install_packages.sh" if [ -f "$install_script" ]; then # Use source to run in current shell context, preserving environment variables - (cd "$SCRIPT_DIR/src" && . "$install_script") || { + (cd "$SCRIPT_DIR" && . "$install_script") || { echo_error "Dev packages not installed!" return 1 } else echo_status "Install script not found at $install_script, attempting direct install..." - # Fallback: install in editable mode from src directory - (cd "$SCRIPT_DIR/src" && pip install -e . --break-system-packages) || { + # Fallback: install in editable mode from the repository root + (cd "$SCRIPT_DIR" && pip install -e . --break-system-packages) || { echo_error "Failed to install package in development mode" return 1 } diff --git a/bootstrap.ps1 b/bootstrap.ps1 index 5cba1b5..6a881e3 100644 --- a/bootstrap.ps1 +++ b/bootstrap.ps1 @@ -274,7 +274,7 @@ Write-FionaStatus "Python: $pythonVersionText ($pythonWhere)" Write-FionaStatus "Pip: $pipVersionText" Write-FionaStatus "" Write-FionaStatus "To verify installation, try:" -Write-FionaStatus " python src/run_tests.py" +Write-FionaStatus " python scripts/run_tests.py" Write-FionaStatus " fiona-assistant --help" Write-FionaStatus "" Write-FionaStatus "Happy coding!" diff --git a/coverage.xml b/coverage.xml deleted file mode 100644 index b5d4dbe..0000000 --- a/coverage.xml +++ /dev/null @@ -1,612 +0,0 @@ - - - - - - /home/user/repositories/fiona-assistant/src/customlinter - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pyproject.toml b/pyproject.toml index 0d6083c..2df129d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,29 @@ [build-system] -requires = ["setuptools>=42"] +requires = ["setuptools>=61"] build-backend = "setuptools.build_meta" [project] name = "fiona-assistant" -version = "0.40.5" +version = "0.41.0" description = "Tools for managing the LLM wiki." authors = [{name = "nvaldeziii"}] readme = "README.md" license = "GPL-3.0-only" -requires-python = ">=3.8" +requires-python = ">=3.11" classifiers = [ "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Operating System :: OS Independent", ] # Core dependencies (required for runtime) -# Note: html5validator requires Java 8+ to be installed on the system dependencies = [ "pymarkdownlnt>=0.9.0", "ruff>=0.16.8", "pyyaml>=6.0.3", - "pylint", "GitPython>=3.1.0", - "html5validator>=0.4.0", ] # Optional dependencies groups @@ -32,6 +32,7 @@ dev = [ "pytest>=7.0.0", "pytest-cov>=4.0.0", "pytest-mock", + "pylint", "build", "twine", ] @@ -41,23 +42,21 @@ include-package-data = true [tool.setuptools.packages.find] where = ["src"] -# llm-wiki is a hyphenated, non-importable data-only "package" that ships -# template files (wiki/, ingest/, AGENTS.md, etc.) as package data. -# The hyphen makes it unimportable as a Python module (import llm-wiki -# is a SyntaxError), but setuptools allows it as a distribution package name. -# The __init__.py exists only to satisfy setuptools' package detection. -include = ["fiona", "librarian", "mdoctor", "python_ruff", "customlinter", "sanity_runner", "llm-wiki", "wiki", "gittool", "html_js_lint"] +include = ["fiona*"] [tool.setuptools.package-data] -# Include all files under llm-wiki/ as package data (not Python code) -"llm-wiki" = ["*", "**/*"] +fiona = [ + "data/llm_wiki/**/*", + "wiki/templates/*", +] [tool.pytest.ini_options] -testpaths = ["src/tests"] +testpaths = ["tests"] +pythonpath = ["src"] [tool.coverage.run] -source = ["src"] -omit = ["src/tests/*", "*/tests/*", "*/test_*.py"] +source = ["src/fiona"] +omit = ["*/tests/*", "*/test_*.py"] [tool.coverage.report] exclude_lines = [ @@ -73,6 +72,10 @@ exclude_lines = [ # Define console scripts entry points [project.scripts] fiona-assistant = "fiona.__main__:main" -librarian = "librarian.librarian:main" -mdoctor = "mdoctor.mdoctor:main" -html-js-lint = "html_js_lint.html_js_lint:main" +librarian = "fiona.librarian.librarian:main" +mdoctor = "fiona.mdoctor.mdoctor:main" + +[tool.ruff] +target-version = "py311" +line-length = 100 +src = ["src"] diff --git a/src/install_packages.sh b/scripts/install_packages.sh similarity index 100% rename from src/install_packages.sh rename to scripts/install_packages.sh diff --git a/scripts/run_sanity.py b/scripts/run_sanity.py new file mode 100644 index 0000000..18be85a --- /dev/null +++ b/scripts/run_sanity.py @@ -0,0 +1,17 @@ +"""Repo-root launcher for the sanity runner. + +Generated by AI/LLM: 2026-09-29 - implementation lives in fiona.run_sanity. +""" + +import pathlib +import sys + +_SRC = pathlib.Path(__file__).resolve().parent.parent / "src" +if str(_SRC) not in sys.path: + sys.path.insert(0, str(_SRC)) + +import fiona.run_sanity as runner # noqa: E402 + + +if __name__ == "__main__": + sys.exit(runner.main()) diff --git a/scripts/run_tests.py b/scripts/run_tests.py new file mode 100644 index 0000000..4d64391 --- /dev/null +++ b/scripts/run_tests.py @@ -0,0 +1,17 @@ +"""Repo-root launcher for the test runner. + +Generated by AI/LLM: 2026-09-29 - implementation lives in fiona.run_tests. +""" + +import pathlib +import sys + +_SRC = pathlib.Path(__file__).resolve().parent.parent / "src" +if str(_SRC) not in sys.path: + sys.path.insert(0, str(_SRC)) + +import fiona.run_tests as runner # noqa: E402 + + +if __name__ == "__main__": + sys.exit(runner.main()) diff --git a/src/settings_dev.json b/scripts/settings_dev.json similarity index 100% rename from src/settings_dev.json rename to scripts/settings_dev.json diff --git a/src/utils.sh b/scripts/utils.sh similarity index 100% rename from src/utils.sh rename to scripts/utils.sh diff --git a/src/README.md b/src/README.md index 587e615..6bdc1a8 100644 --- a/src/README.md +++ b/src/README.md @@ -7,7 +7,7 @@ A collection of tools for managing the LLM wiki and related operations. The Fiona Assistant project provides command-line tools for: - **Librarian**: Managing LLM wiki content and operations -- **MDoctor**: [Description to be added] +- **MDoctor**: Markdown diagnosis (lint, list, and fix) ## Installation @@ -57,7 +57,7 @@ pip install -e ".[dev]" ### Librarian -See [librarian/README.md](./librarian/README.md) for detailed usage. +See [librarian/README.md](./fiona/librarian/README.md) for detailed usage. ```bash librarian --help @@ -65,7 +65,7 @@ librarian --help ### MDoctor -See [mdoctor/README.md](./mdoctor/README.md) for detailed usage. +See [mdoctor/README.md](./fiona/mdoctor/README.md) for detailed usage. ```bash mdoctor --help @@ -74,22 +74,38 @@ mdoctor --help ## Project Structure ```text -src/ -├── fiona/ # Main package -├── librarian/ # Wiki content management tool -├── mdoctor/ # [Tool description] -├── tests/ # Unit tests -└── README.md # This file +src/fiona/ +├── __main__.py # CLI entry point +├── librarian/ # Wiki content management +├── mdoctor/ # Markdown diagnosis +├── customlinter/ # Frontmatter, markdown, Python, and JSON linters +├── python_ruff/ # Ruff wrapper +├── gittool/ # Git operations +├── sanity_runner/ # Shared sanity engine +├── wiki/ # Wiki init, update, sanity, and graph +├── data/llm_wiki/ # Packaged wiki template +├── run_tests.py # Test runner +└── run_sanity.py # Sanity runner +tests/ # Unit tests (repository root, not installed) +scripts/ +├── run_tests.py +├── run_sanity.py +├── settings_dev.json +├── utils.sh +└── install_packages.sh ``` ## Running Tests ```bash # Run all tests -pytest +python scripts/run_tests.py + +# Or use pytest directly +python -m pytest # Run with coverage -pytest --cov=src +python -m pytest --cov=src/fiona ``` ## Development Tools @@ -98,9 +114,10 @@ The project includes several development utilities: - `bootstrap`: Set up the Python development environment (bash) - `bootstrap.ps1`: Set up the Python development environment (PowerShell) -- `src/utils.sh`: Shell utility functions -- `src/install_packages.sh`: Install local Python packages -- `src/run_tests.sh`: Run the test suite +- `scripts/utils.sh`: Shell utility functions +- `scripts/install_packages.sh`: Install local Python packages +- `scripts/run_tests.py`: Run the test suite +- `scripts/run_sanity.py`: Run tests and linters ## License @@ -108,4 +125,6 @@ GPL-3.0-only ## Contributing -[Contribution guidelines to be added] +Follow [AGENTS.md](../AGENTS.md): update [SPEC.md](../SPEC.md) first, +add a failing test, then implement. Run `python scripts/run_tests.py` +and `python scripts/run_sanity.py --non-interactive` before finishing. diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index bcebbcd..0000000 --- a/src/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# Fiona tools package diff --git a/src/fiona/__main__.py b/src/fiona/__main__.py index 41dc823..bb75254 100644 --- a/src/fiona/__main__.py +++ b/src/fiona/__main__.py @@ -8,18 +8,18 @@ import argparse import logging import sys -from customlinter.fmlint import main as fmlint_main -from customlinter.jsonlint import main as jsonlint_main +from fiona.customlinter.fmlint import main as fmlint_main +from fiona.customlinter.jsonlint import main as jsonlint_main +from fiona.gittool.git_tool import main as git_tool_main +from fiona.librarian.librarian import main as librarian_main +from fiona.librarian.toc_generator import main as toc_generator_main from fiona.logging_config import setup_logging -from gittool.git_tool import main as git_tool_main -from librarian.librarian import main as librarian_main -from librarian.toc_generator import main as toc_generator_main -from mdoctor.mdoctor import main as mdoctor_main -from python_ruff.python_ruff import main as python_ruff_main -from wiki.graph_generator import wiki_graph_main -from wiki.sanity_manager import sanity_main -from wiki.update_manager import check_update_main, update_main -from wiki.wiki import wiki_init +from fiona.mdoctor.mdoctor import main as mdoctor_main +from fiona.python_ruff.python_ruff import main as python_ruff_main +from fiona.wiki.graph_generator import wiki_graph_main +from fiona.wiki.sanity_manager import sanity_main +from fiona.wiki.update_manager import check_update_main, update_main +from fiona.wiki.wiki import wiki_init def main(): diff --git a/src/customlinter/__init__.py b/src/fiona/customlinter/__init__.py similarity index 84% rename from src/customlinter/__init__.py rename to src/fiona/customlinter/__init__.py index ebc1aee..c0ccbca 100644 --- a/src/customlinter/__init__.py +++ b/src/fiona/customlinter/__init__.py @@ -16,7 +16,7 @@ various code and content rules. It includes: All linters share a common interface and output format for consistency. """ -from customlinter.base import ( +from fiona.customlinter.base import ( DEFAULT_SETTINGS_FILE, READONLY_ZONES, BaseLinter, @@ -25,9 +25,9 @@ from customlinter.base import ( LinterError, LintViolation, ) -from customlinter.fmlint import FrontmatterLinter -from customlinter.mdlinter import MarkdownLinter -from customlinter.pycustomlint import PythonCustomLinter +from fiona.customlinter.fmlint import FrontmatterLinter +from fiona.customlinter.mdlinter import MarkdownLinter +from fiona.customlinter.pycustomlint import PythonCustomLinter __all__ = [ "DEFAULT_SETTINGS_FILE", diff --git a/src/customlinter/base.py b/src/fiona/customlinter/base.py similarity index 99% rename from src/customlinter/base.py rename to src/fiona/customlinter/base.py index 563caf7..831f398 100644 --- a/src/customlinter/base.py +++ b/src/fiona/customlinter/base.py @@ -15,6 +15,8 @@ import pathlib from abc import ABC, abstractmethod from typing import Any, ClassVar +from fiona.paths import llm_wiki_template + logger = logging.getLogger(__name__) @@ -40,9 +42,7 @@ def report_path(path: pathlib.Path | str) -> str: READONLY_ZONES = ["personal", "raw"] # Default settings file path -DEFAULT_SETTINGS_FILE = ( - pathlib.Path(__file__).resolve().parent.parent / "llm-wiki" / "fiona-settings.json" -) +DEFAULT_SETTINGS_FILE = llm_wiki_template() / "fiona-settings.json" # Re-export constants for backward compatibility __all__ = [ diff --git a/src/customlinter/fmlint.py b/src/fiona/customlinter/fmlint.py similarity index 99% rename from src/customlinter/fmlint.py rename to src/fiona/customlinter/fmlint.py index bfd1841..b101150 100644 --- a/src/customlinter/fmlint.py +++ b/src/fiona/customlinter/fmlint.py @@ -26,14 +26,14 @@ import pathlib import re import sys -from customlinter.base import ( +from fiona.customlinter.base import ( BaseLinter, FrontmatterLintError, LintViolation, report_path, ) +from fiona.librarian.md_frontmatter import FrontmatterError, parse_frontmatter from fiona.logging_config import setup_logging -from librarian.md_frontmatter import FrontmatterError, parse_frontmatter logger = logging.getLogger(__name__) diff --git a/src/customlinter/jsonlint.py b/src/fiona/customlinter/jsonlint.py similarity index 99% rename from src/customlinter/jsonlint.py rename to src/fiona/customlinter/jsonlint.py index 8bf65e7..f9b4143 100644 --- a/src/customlinter/jsonlint.py +++ b/src/fiona/customlinter/jsonlint.py @@ -9,7 +9,7 @@ Includes support for: - Key ordering (optional) - Auto-fixing certain violations -Follows the BaseLinter pattern from customlinter.base. +Follows the BaseLinter pattern from fiona.customlinter.base. """ from __future__ import annotations @@ -21,7 +21,7 @@ import re import sys from typing import Any, ClassVar -from customlinter.base import BaseLinter, LinterError, LintViolation +from fiona.customlinter.base import BaseLinter, LinterError, LintViolation from fiona.logging_config import setup_logging logger = logging.getLogger(__name__) diff --git a/src/customlinter/mdlinter.py b/src/fiona/customlinter/mdlinter.py similarity index 98% rename from src/customlinter/mdlinter.py rename to src/fiona/customlinter/mdlinter.py index 0859abc..57fe263 100644 --- a/src/customlinter/mdlinter.py +++ b/src/fiona/customlinter/mdlinter.py @@ -27,7 +27,7 @@ import pathlib import re from typing import Any, ClassVar -from customlinter.base import BaseLinter, LinterError, LintViolation +from fiona.customlinter.base import BaseLinter, LinterError, LintViolation logger = logging.getLogger(__name__) @@ -238,7 +238,7 @@ class MarkdownLinter(BaseLinter): # ============================================================================= -# Module-level Dead Link Helper (moved from wiki.sanity_manager) +# Module-level Dead Link Helper (moved from fiona.wiki.sanity_manager) # ============================================================================= def find_dead_links(wiki_root: pathlib.Path) -> list[LintViolation]: diff --git a/src/customlinter/pycustomlint.py b/src/fiona/customlinter/pycustomlint.py similarity index 99% rename from src/customlinter/pycustomlint.py rename to src/fiona/customlinter/pycustomlint.py index e4d8108..99a8241 100644 --- a/src/customlinter/pycustomlint.py +++ b/src/fiona/customlinter/pycustomlint.py @@ -25,7 +25,7 @@ import pathlib import sys from typing import ClassVar -from customlinter.base import ( +from fiona.customlinter.base import ( BaseLinter, CustomLintError, LintViolation, diff --git a/src/llm-wiki/AGENTS.md b/src/fiona/data/llm_wiki/AGENTS.md similarity index 100% rename from src/llm-wiki/AGENTS.md rename to src/fiona/data/llm_wiki/AGENTS.md diff --git a/src/llm-wiki/README.md b/src/fiona/data/llm_wiki/README.md similarity index 100% rename from src/llm-wiki/README.md rename to src/fiona/data/llm_wiki/README.md diff --git a/src/llm-wiki/fiona-settings.json b/src/fiona/data/llm_wiki/fiona-settings.json similarity index 100% rename from src/llm-wiki/fiona-settings.json rename to src/fiona/data/llm_wiki/fiona-settings.json diff --git a/src/llm-wiki/ingest/README.md b/src/fiona/data/llm_wiki/ingest/README.md similarity index 100% rename from src/llm-wiki/ingest/README.md rename to src/fiona/data/llm_wiki/ingest/README.md diff --git a/src/llm-wiki/personal/README.md b/src/fiona/data/llm_wiki/personal/README.md similarity index 100% rename from src/llm-wiki/personal/README.md rename to src/fiona/data/llm_wiki/personal/README.md diff --git a/src/llm-wiki/raw/README.md b/src/fiona/data/llm_wiki/raw/README.md similarity index 100% rename from src/llm-wiki/raw/README.md rename to src/fiona/data/llm_wiki/raw/README.md diff --git a/src/llm-wiki/raw/articles/.gitkeep b/src/fiona/data/llm_wiki/raw/articles/.gitkeep similarity index 100% rename from src/llm-wiki/raw/articles/.gitkeep rename to src/fiona/data/llm_wiki/raw/articles/.gitkeep diff --git a/src/llm-wiki/raw/assets/.gitkeep b/src/fiona/data/llm_wiki/raw/assets/.gitkeep similarity index 100% rename from src/llm-wiki/raw/assets/.gitkeep rename to src/fiona/data/llm_wiki/raw/assets/.gitkeep diff --git a/src/llm-wiki/raw/papers/.gitkeep b/src/fiona/data/llm_wiki/raw/papers/.gitkeep similarity index 100% rename from src/llm-wiki/raw/papers/.gitkeep rename to src/fiona/data/llm_wiki/raw/papers/.gitkeep diff --git a/src/llm-wiki/raw/transcripts/.gitkeep b/src/fiona/data/llm_wiki/raw/transcripts/.gitkeep similarity index 100% rename from src/llm-wiki/raw/transcripts/.gitkeep rename to src/fiona/data/llm_wiki/raw/transcripts/.gitkeep diff --git a/src/llm-wiki/table_of_contents.md b/src/fiona/data/llm_wiki/table_of_contents.md similarity index 100% rename from src/llm-wiki/table_of_contents.md rename to src/fiona/data/llm_wiki/table_of_contents.md diff --git a/src/llm-wiki/utils/README.md b/src/fiona/data/llm_wiki/utils/README.md similarity index 100% rename from src/llm-wiki/utils/README.md rename to src/fiona/data/llm_wiki/utils/README.md diff --git a/src/llm-wiki/utils/personas/default/SOUL.md b/src/fiona/data/llm_wiki/utils/personas/default/SOUL.md similarity index 100% rename from src/llm-wiki/utils/personas/default/SOUL.md rename to src/fiona/data/llm_wiki/utils/personas/default/SOUL.md diff --git a/src/llm-wiki/utils/personas/template/SOUL.md b/src/fiona/data/llm_wiki/utils/personas/template/SOUL.md similarity index 100% rename from src/llm-wiki/utils/personas/template/SOUL.md rename to src/fiona/data/llm_wiki/utils/personas/template/SOUL.md diff --git a/src/llm-wiki/utils/scripts/example.py b/src/fiona/data/llm_wiki/utils/scripts/example.py similarity index 100% rename from src/llm-wiki/utils/scripts/example.py rename to src/fiona/data/llm_wiki/utils/scripts/example.py diff --git a/src/llm-wiki/utils/scripts/map.md b/src/fiona/data/llm_wiki/utils/scripts/map.md similarity index 100% rename from src/llm-wiki/utils/scripts/map.md rename to src/fiona/data/llm_wiki/utils/scripts/map.md diff --git a/src/llm-wiki/utils/skills/README.md b/src/fiona/data/llm_wiki/utils/skills/README.md similarity index 100% rename from src/llm-wiki/utils/skills/README.md rename to src/fiona/data/llm_wiki/utils/skills/README.md diff --git a/src/llm-wiki/utils/skills/fiona/SKILL.md b/src/fiona/data/llm_wiki/utils/skills/fiona/SKILL.md similarity index 99% rename from src/llm-wiki/utils/skills/fiona/SKILL.md rename to src/fiona/data/llm_wiki/utils/skills/fiona/SKILL.md index 1a7342f..860fe33 100644 --- a/src/llm-wiki/utils/skills/fiona/SKILL.md +++ b/src/fiona/data/llm_wiki/utils/skills/fiona/SKILL.md @@ -4,7 +4,7 @@ category: productivity description: Operate an llm-wiki with the fiona-assistant CLI. author: nvaldez license: MIT -version: 1.2.0 +version: 1.2.1 updated: 2026-09-29 --- @@ -472,6 +472,6 @@ These are not implemented. Do not invent flags for them. - `fiona-assistant python-ruff fix` On a checkout of the fiona-assistant product repository, tests and -the product gate are `python src/run_tests.py` and -`python src/run_sanity.py --non-interactive`. Those are not wiki +the product gate are `python scripts/run_tests.py` and +`python scripts/run_sanity.py --non-interactive`. Those are not wiki commands. A wiki uses `fiona-assistant wiki sanity`. diff --git a/src/llm-wiki/utils/skills/fiona/llm-wiki-mod.md b/src/fiona/data/llm_wiki/utils/skills/fiona/llm-wiki-mod.md similarity index 100% rename from src/llm-wiki/utils/skills/fiona/llm-wiki-mod.md rename to src/fiona/data/llm_wiki/utils/skills/fiona/llm-wiki-mod.md diff --git a/src/llm-wiki/utils/skills/fiona/markdown_rules.md b/src/fiona/data/llm_wiki/utils/skills/fiona/markdown_rules.md similarity index 100% rename from src/llm-wiki/utils/skills/fiona/markdown_rules.md rename to src/fiona/data/llm_wiki/utils/skills/fiona/markdown_rules.md diff --git a/src/llm-wiki/utils/skills/obsidian/SKILL.md b/src/fiona/data/llm_wiki/utils/skills/obsidian/SKILL.md similarity index 100% rename from src/llm-wiki/utils/skills/obsidian/SKILL.md rename to src/fiona/data/llm_wiki/utils/skills/obsidian/SKILL.md diff --git a/src/llm-wiki/utils/skills/python-tdd/SKILL.md b/src/fiona/data/llm_wiki/utils/skills/python-tdd/SKILL.md similarity index 100% rename from src/llm-wiki/utils/skills/python-tdd/SKILL.md rename to src/fiona/data/llm_wiki/utils/skills/python-tdd/SKILL.md diff --git a/src/llm-wiki/utils/skills_local/README.md b/src/fiona/data/llm_wiki/utils/skills_local/README.md similarity index 100% rename from src/llm-wiki/utils/skills_local/README.md rename to src/fiona/data/llm_wiki/utils/skills_local/README.md diff --git a/src/llm-wiki/wiki/comparisons/.gitkeep b/src/fiona/data/llm_wiki/wiki/comparisons/.gitkeep similarity index 100% rename from src/llm-wiki/wiki/comparisons/.gitkeep rename to src/fiona/data/llm_wiki/wiki/comparisons/.gitkeep diff --git a/src/llm-wiki/wiki/concepts/.gitkeep b/src/fiona/data/llm_wiki/wiki/concepts/.gitkeep similarity index 100% rename from src/llm-wiki/wiki/concepts/.gitkeep rename to src/fiona/data/llm_wiki/wiki/concepts/.gitkeep diff --git a/src/llm-wiki/wiki/entities/.gitkeep b/src/fiona/data/llm_wiki/wiki/entities/.gitkeep similarity index 100% rename from src/llm-wiki/wiki/entities/.gitkeep rename to src/fiona/data/llm_wiki/wiki/entities/.gitkeep diff --git a/src/llm-wiki/wiki/index.md b/src/fiona/data/llm_wiki/wiki/index.md similarity index 100% rename from src/llm-wiki/wiki/index.md rename to src/fiona/data/llm_wiki/wiki/index.md diff --git a/src/llm-wiki/wiki/log.md b/src/fiona/data/llm_wiki/wiki/log.md similarity index 96% rename from src/llm-wiki/wiki/log.md rename to src/fiona/data/llm_wiki/wiki/log.md index 694bd1d..052122e 100644 --- a/src/llm-wiki/wiki/log.md +++ b/src/fiona/data/llm_wiki/wiki/log.md @@ -1,7 +1,7 @@ --- name: log title: Wiki Log -version: 1.2.7 +version: 1.2.8 type: summary created: 2025-09-23 updated: 2026-09-29 @@ -57,6 +57,8 @@ Chronological tracking of all actions performed on the wiki. `progress` section with `interval` and `expected-seconds` keys. - 2026-09-29 - Retargeted spec citations in this log, `todo.md`, and the code to the current section numbers. +- 2026-09-29 - Moved the template to `src/fiona/data/llm_wiki/` as + package data (no importable `llm-wiki` package). Fiona skill v1.2.1. - 2026-09-29 - Restored the development lifecycle as project agent rule 2.1 (AGENTS.md v1.4.1) and linked the python-tdd skill. - 2026-09-29 - PYC001 allows a module-level if/else import before diff --git a/src/llm-wiki/wiki/logs/.gitkeep b/src/fiona/data/llm_wiki/wiki/logs/.gitkeep similarity index 100% rename from src/llm-wiki/wiki/logs/.gitkeep rename to src/fiona/data/llm_wiki/wiki/logs/.gitkeep diff --git a/src/llm-wiki/wiki/queries/.gitkeep b/src/fiona/data/llm_wiki/wiki/queries/.gitkeep similarity index 100% rename from src/llm-wiki/wiki/queries/.gitkeep rename to src/fiona/data/llm_wiki/wiki/queries/.gitkeep diff --git a/src/llm-wiki/wiki/schema.md b/src/fiona/data/llm_wiki/wiki/schema.md similarity index 100% rename from src/llm-wiki/wiki/schema.md rename to src/fiona/data/llm_wiki/wiki/schema.md diff --git a/src/llm-wiki/wiki/sources/.gitkeep b/src/fiona/data/llm_wiki/wiki/sources/.gitkeep similarity index 100% rename from src/llm-wiki/wiki/sources/.gitkeep rename to src/fiona/data/llm_wiki/wiki/sources/.gitkeep diff --git a/src/gittool/__init__.py b/src/fiona/gittool/__init__.py similarity index 100% rename from src/gittool/__init__.py rename to src/fiona/gittool/__init__.py diff --git a/src/gittool/git_tool.py b/src/fiona/gittool/git_tool.py similarity index 98% rename from src/gittool/git_tool.py rename to src/fiona/gittool/git_tool.py index 8122e39..89cf32f 100644 --- a/src/gittool/git_tool.py +++ b/src/fiona/gittool/git_tool.py @@ -7,7 +7,7 @@ from __future__ import annotations import argparse import pathlib -from datetime import datetime, timezone +from datetime import UTC, datetime import git from git.repo.base import Repo @@ -50,7 +50,7 @@ class GitTool: Returns: str: Formatted timestamp string. """ - return datetime.now(tz=timezone.utc).strftime("%Y-%m-%d %H:%M:%S") + return datetime.now(tz=UTC).strftime("%Y-%m-%d %H:%M:%S") @staticmethod def _get_tag_timestamp() -> str: @@ -62,7 +62,7 @@ class GitTool: Returns: str: Formatted timestamp string safe for git tags. """ - return datetime.now(tz=timezone.utc).strftime("%Y-%m-%d_%H-%M-%S") + return datetime.now(tz=UTC).strftime("%Y-%m-%d_%H-%M-%S") def _is_working_tree_clean(self) -> bool: """Check if the working tree is clean. diff --git a/src/librarian/README.md b/src/fiona/librarian/README.md similarity index 100% rename from src/librarian/README.md rename to src/fiona/librarian/README.md diff --git a/src/librarian/__init__.py b/src/fiona/librarian/__init__.py similarity index 100% rename from src/librarian/__init__.py rename to src/fiona/librarian/__init__.py diff --git a/src/librarian/librarian.py b/src/fiona/librarian/librarian.py similarity index 100% rename from src/librarian/librarian.py rename to src/fiona/librarian/librarian.py diff --git a/src/librarian/md_frontmatter.py b/src/fiona/librarian/md_frontmatter.py similarity index 100% rename from src/librarian/md_frontmatter.py rename to src/fiona/librarian/md_frontmatter.py diff --git a/src/librarian/toc_generator.py b/src/fiona/librarian/toc_generator.py similarity index 99% rename from src/librarian/toc_generator.py rename to src/fiona/librarian/toc_generator.py index 464d04e..6d3506a 100644 --- a/src/librarian/toc_generator.py +++ b/src/fiona/librarian/toc_generator.py @@ -16,8 +16,9 @@ import re import sys import typing +from fiona.librarian.md_frontmatter import FrontmatterError, get_file_version from fiona.logging_config import load_settings, setup_logging -from librarian.md_frontmatter import FrontmatterError, get_file_version +from fiona.paths import llm_wiki_template logger = logging.getLogger(__name__) @@ -40,9 +41,7 @@ SETTINGS_NAME = "fiona-settings.json" ARTIFACT_DIR_NAMES = frozenset({"build", "dist", "__pycache__"}) FILE_TOC_KEYS = frozenset({"min_heading", "max_heading", "sectionize", "ignore_files"}) -DEFAULT_SETTINGS_FILE = ( - pathlib.Path(__file__).resolve().parent.parent / "llm-wiki" / "fiona-settings.json" -) +DEFAULT_SETTINGS_FILE = llm_wiki_template() / "fiona-settings.json" def load_toc_settings(settings_file: str | pathlib.Path | None = None) -> dict: @@ -170,7 +169,7 @@ def build_toc( (3 = h1 through h3). None or 0 mean unlimited. """ # Add YAML frontmatter - today = datetime.datetime.now(datetime.timezone.utc).date().isoformat() + today = datetime.datetime.now(datetime.UTC).date().isoformat() frontmatter = f"""--- title: Table of Contents created: {today} diff --git a/src/fiona/logging_config.py b/src/fiona/logging_config.py index d286230..6da2adc 100644 --- a/src/fiona/logging_config.py +++ b/src/fiona/logging_config.py @@ -20,18 +20,18 @@ import os import pathlib import sys +from fiona.paths import llm_wiki_template + # AI/LLM: Windows-only; module-level so PYC001 allows it (SPEC 6.4.2). if os.name == "nt": import msvcrt DEFAULT_LOG_LEVEL = "WARNING" -DEFAULT_SETTINGS_FILE = ( - pathlib.Path(__file__).resolve().parent.parent / "llm-wiki" / "fiona-settings.json" -) +DEFAULT_SETTINGS_FILE = llm_wiki_template() / "fiona-settings.json" # Tool package loggers that carry the level explicitly: pymarkdown # resets the root logger to WARNING mid-run, which would otherwise # silence tool diagnostics (same pattern as run_sanity, see SPEC 7.20). -TOOL_LOGGER_NAMES = ("fiona", "librarian", "mdoctor", "python_ruff", "wiki") +TOOL_LOGGER_NAMES = ("fiona",) LOG_FORMAT = "%(levelname)s %(name)s: %(message)s" FILE_LOG_FORMAT = "%(asctime)s %(levelname)s %(name)s: %(message)s" diff --git a/src/mdoctor/README.md b/src/fiona/mdoctor/README.md similarity index 100% rename from src/mdoctor/README.md rename to src/fiona/mdoctor/README.md diff --git a/src/mdoctor/__init__.py b/src/fiona/mdoctor/__init__.py similarity index 100% rename from src/mdoctor/__init__.py rename to src/fiona/mdoctor/__init__.py diff --git a/src/mdoctor/mdoctor.py b/src/fiona/mdoctor/mdoctor.py similarity index 98% rename from src/mdoctor/mdoctor.py rename to src/fiona/mdoctor/mdoctor.py index 525238d..7644256 100644 --- a/src/mdoctor/mdoctor.py +++ b/src/fiona/mdoctor/mdoctor.py @@ -15,13 +15,12 @@ from typing import Any, ClassVar from pymarkdown.api import PyMarkdownApi, PyMarkdownApiException -from customlinter.base import BaseLinter, LintViolation +from fiona.customlinter.base import BaseLinter, LintViolation +from fiona.librarian.librarian import Librarian from fiona.logging_config import setup_logging -from librarian.librarian import Librarian +from fiona.paths import llm_wiki_template -DEFAULT_SETTINGS_FILE = ( - pathlib.Path(__file__).resolve().parent.parent / "llm-wiki" / "fiona-settings.json" -) +DEFAULT_SETTINGS_FILE = llm_wiki_template() / "fiona-settings.json" # AI/LLM: MD013 defaults used when fiona-settings.json omits the keys. MD013_DEFAULTS: dict[str, int | bool] = { "line_length": 100, diff --git a/src/fiona/paths.py b/src/fiona/paths.py new file mode 100644 index 0000000..830af15 --- /dev/null +++ b/src/fiona/paths.py @@ -0,0 +1,21 @@ +"""Filesystem locations for packaged Fiona data. + +Generated by AI/LLM: 2026-09-29 - one resolver for the llm-wiki template. +""" + +from __future__ import annotations + +import importlib.resources +import pathlib + + +def llm_wiki_template() -> pathlib.Path: + """Return the packaged llm-wiki template directory. + + Generated by AI/LLM: 2026-09-29 - load package data with importlib.resources. + + Returns: + Filesystem path of ``fiona/data/llm_wiki``. + """ + resource = importlib.resources.files("fiona").joinpath("data", "llm_wiki") + return pathlib.Path(str(resource)) diff --git a/src/python_ruff/__init__.py b/src/fiona/python_ruff/__init__.py similarity index 100% rename from src/python_ruff/__init__.py rename to src/fiona/python_ruff/__init__.py diff --git a/src/python_ruff/python_ruff.py b/src/fiona/python_ruff/python_ruff.py similarity index 99% rename from src/python_ruff/python_ruff.py rename to src/fiona/python_ruff/python_ruff.py index 692f9b8..cf35230 100644 --- a/src/python_ruff/python_ruff.py +++ b/src/fiona/python_ruff/python_ruff.py @@ -8,7 +8,7 @@ from typing import Any, ClassVar import ruff -from customlinter.base import BaseLinter, LintViolation +from fiona.customlinter.base import BaseLinter, LintViolation from fiona.logging_config import setup_logging diff --git a/src/run_sanity.py b/src/fiona/run_sanity.py similarity index 95% rename from src/run_sanity.py rename to src/fiona/run_sanity.py index 71ee868..f6f1657 100644 --- a/src/run_sanity.py +++ b/src/fiona/run_sanity.py @@ -17,18 +17,35 @@ import time from collections.abc import Callable, Sequence from pathlib import Path -import sanity_runner -from customlinter.fmlint import FrontmatterLinter -from customlinter.jsonlint import JsonLinter -from customlinter.pycustomlint import PythonCustomLinter -from mdoctor.mdoctor import MDoctor -from python_ruff.python_ruff import PythonRuff -from run_tests import TestRunner +from fiona import sanity_runner +from fiona.customlinter.fmlint import FrontmatterLinter +from fiona.customlinter.jsonlint import JsonLinter +from fiona.customlinter.pycustomlint import PythonCustomLinter +from fiona.mdoctor.mdoctor import MDoctor +from fiona.python_ruff.python_ruff import PythonRuff +from fiona.run_tests import TestRunner # Configure logging logger = logging.getLogger(__name__) -SETTINGS_FILE = Path(__file__).resolve().parent / "settings_dev.json" + +def dev_settings_file() -> Path: + """Return scripts/settings_dev.json from the checkout that contains this file. + + Generated by AI/LLM: 2026-09-29 - development settings live outside the package. + + Returns: + The settings file when this module sits in a checkout, otherwise a + path relative to the current working directory. + """ + for parent in Path(__file__).resolve().parents: + candidate = parent / "scripts" / "settings_dev.json" + if candidate.is_file(): + return candidate + return Path("scripts") / "settings_dev.json" + + +SETTINGS_FILE = dev_settings_file() # Progress display defaults (overridable via the "progress" settings # section, see load_progress_settings) @@ -57,7 +74,7 @@ def configure_logging() -> None: # pymarkdown resets the root logger to WARNING during lint scans, # which would silence the runner's debug output mid-run; the module # loggers therefore also carry the level explicitly - for logger_name in (__name__, "run_sanity", "run_tests"): + for logger_name in (__name__, "fiona.run_tests"): logging.getLogger(logger_name).setLevel(level) @@ -92,8 +109,11 @@ def load_progress_settings(settings_file: str | Path = SETTINGS_FILE) -> dict: Each falls back to its default when the "progress" section or the individual key is absent. """ - with open(settings_file, encoding="utf-8") as f: - settings = json.load(f) + try: + with open(settings_file, encoding="utf-8") as f: + settings = json.load(f) + except FileNotFoundError: + settings = {} progress = settings.get("progress", {}) return { "interval_seconds": float( @@ -261,7 +281,7 @@ def run_pytests(): (or the raw message when no traceback details exist) """ runner = TestRunner() - result = runner.run_pytest("src/tests", verbose=True, capture_output=True, with_coverage=True) + result = runner.run_pytest("tests", verbose=True, capture_output=True, with_coverage=True) required_coverage = load_required_coverage() coverage_percent = result.get("coverage_percent") @@ -293,7 +313,7 @@ def run_pytests(): unreported_failures, ) - lines = ["Pytest Results", "TARGET: src/tests", ""] + lines = ["Pytest Results", "TARGET: tests", ""] lines.append(f"Tests: {result['passed_count']}/{result['total_count']} passed") for file_name in sorted(file_results): counts = file_results[file_name] @@ -429,7 +449,7 @@ def run_frontmatter_lint(): linter = FrontmatterLinter() # Lint markdown files in llm-wiki directory only (per project agent rule 10.1) - llm_wiki_path = "./src/llm-wiki" + llm_wiki_path = "./src/fiona/data/llm_wiki" violations_dict = linter.lint_directory(llm_wiki_path) # Get violation count from meta diff --git a/src/run_tests.py b/src/fiona/run_tests.py similarity index 99% rename from src/run_tests.py rename to src/fiona/run_tests.py index 7beeee7..8d1feee 100644 --- a/src/run_tests.py +++ b/src/fiona/run_tests.py @@ -22,6 +22,8 @@ logger = logging.getLogger(__name__) class TestRunner: """A test runner for Fiona tools that can be used both manually and in CI.""" + __test__ = False + def __init__(self, base_dir: str | None = None): """ Initialize the test runner. @@ -464,7 +466,7 @@ class TestRunner: if verbose: cmd.append("-v") if with_coverage: - cmd.extend(["--cov=src", "--cov-config=.coveragerc", "--cov-report=term"]) + cmd.extend(["--cov=src/fiona", "--cov-report=term"]) if ignore: cmd.extend(["--ignore-glob", f"*{ignore}*"]) @@ -477,9 +479,9 @@ class TestRunner: # environment variables (PY_COLORS, FORCE_COLOR) would break them cmd.append("--color=no") - # Set PYTHONPATH to include src directory for customlinter imports + # Set PYTHONPATH to include src so the fiona package resolves env = os.environ.copy() - src_dir = os.path.abspath(os.path.dirname(__file__)) + src_dir = str(pathlib.Path(__file__).resolve().parent.parent) if os.path.exists(src_dir): current_pythonpath = env.get("PYTHONPATH", "") if current_pythonpath: @@ -572,7 +574,7 @@ class TestRunner: True if all tests passed, False otherwise """ test_paths = [ - "src/tests" + "tests" ] all_passed = True diff --git a/src/sanity_runner/__init__.py b/src/fiona/sanity_runner/__init__.py similarity index 90% rename from src/sanity_runner/__init__.py rename to src/fiona/sanity_runner/__init__.py index d9dafa4..aae872d 100644 --- a/src/sanity_runner/__init__.py +++ b/src/fiona/sanity_runner/__init__.py @@ -6,7 +6,7 @@ repository sanity runner (run_sanity) and the wiki sanity command timings and the common AI-friendly report format (SPEC 6.1/7.16.1). """ -from sanity_runner.sanity_runner import ( +from fiona.sanity_runner.sanity_runner import ( SanityRunner, format_duration, format_violation_count, diff --git a/src/sanity_runner/sanity_runner.py b/src/fiona/sanity_runner/sanity_runner.py similarity index 99% rename from src/sanity_runner/sanity_runner.py rename to src/fiona/sanity_runner/sanity_runner.py index 9e1ebc4..f897b43 100644 --- a/src/sanity_runner/sanity_runner.py +++ b/src/fiona/sanity_runner/sanity_runner.py @@ -3,7 +3,7 @@ This module provides `SanityRunner`, the generalized class behind both sanity runners in the project: -- the repository sanity runner (`src/run_sanity.py`, SPEC 7.16) +- the repository sanity runner (`fiona.run_sanity`, SPEC 7.16) - the wiki sanity command (`src/wiki/sanity_manager.py`, SPEC 7.3) The class owns the common machinery: concurrent check execution with diff --git a/src/wiki/__init__.py b/src/fiona/wiki/__init__.py similarity index 80% rename from src/wiki/__init__.py rename to src/fiona/wiki/__init__.py index 8cc790a..119ba76 100644 --- a/src/wiki/__init__.py +++ b/src/fiona/wiki/__init__.py @@ -3,6 +3,6 @@ This module provides functionality for initializing and managing llm-wiki directories. """ -from wiki.wiki import wiki_init +from fiona.wiki.wiki import wiki_init __all__ = ["wiki_init"] diff --git a/src/wiki/graph_generator.py b/src/fiona/wiki/graph_generator.py similarity index 99% rename from src/wiki/graph_generator.py rename to src/fiona/wiki/graph_generator.py index 166f8b4..a02586c 100644 --- a/src/wiki/graph_generator.py +++ b/src/fiona/wiki/graph_generator.py @@ -570,7 +570,7 @@ class HTMLGraphRenderer: "wiki_root": wiki_root, "file_count": len(self.graph.nodes), "link_count": sum(self.graph.edges.values()), - "generated_at": datetime.datetime.now(datetime.timezone.utc).isoformat() + "generated_at": datetime.datetime.now(datetime.UTC).isoformat() }, "nodes": self._generate_node_data(), "edges": self._generate_edge_data(), diff --git a/src/wiki/sanity_manager.py b/src/fiona/wiki/sanity_manager.py similarity index 97% rename from src/wiki/sanity_manager.py rename to src/fiona/wiki/sanity_manager.py index e17d229..160fe9e 100644 --- a/src/wiki/sanity_manager.py +++ b/src/fiona/wiki/sanity_manager.py @@ -23,14 +23,13 @@ import time from collections.abc import Callable from pathlib import Path -import run_sanity -import sanity_runner -from customlinter.base import LintViolation -from customlinter.fmlint import FrontmatterLinter -from customlinter.jsonlint import JsonLinter -from customlinter.mdlinter import MarkdownLinter -from mdoctor.mdoctor import MDoctor -from python_ruff.python_ruff import PythonRuff +from fiona import run_sanity, sanity_runner +from fiona.customlinter.base import LintViolation +from fiona.customlinter.fmlint import FrontmatterLinter +from fiona.customlinter.jsonlint import JsonLinter +from fiona.customlinter.mdlinter import MarkdownLinter +from fiona.mdoctor.mdoctor import MDoctor +from fiona.python_ruff.python_ruff import PythonRuff SETTINGS_FILE = "fiona-settings.json" diff --git a/src/wiki/templates/graph_template.html b/src/fiona/wiki/templates/graph_template.html similarity index 100% rename from src/wiki/templates/graph_template.html rename to src/fiona/wiki/templates/graph_template.html diff --git a/src/wiki/update_manager.py b/src/fiona/wiki/update_manager.py similarity index 97% rename from src/wiki/update_manager.py rename to src/fiona/wiki/update_manager.py index 359c874..8daca1c 100644 --- a/src/wiki/update_manager.py +++ b/src/fiona/wiki/update_manager.py @@ -19,10 +19,11 @@ import sys from dataclasses import dataclass, field from pathlib import Path +from fiona.librarian.md_frontmatter import get_file_version +from fiona.librarian.toc_generator import path_matches from fiona.logging_config import setup_logging -from librarian.md_frontmatter import get_file_version -from librarian.toc_generator import path_matches -from wiki.wiki import _copy_file, get_ignore_patterns, replace_date_placeholders +from fiona.paths import llm_wiki_template +from fiona.wiki.wiki import _copy_file, get_ignore_patterns, replace_date_placeholders # ============================================================================= # Data Classes @@ -108,39 +109,30 @@ READ_ONLY_ZONES = ["personal/", "raw/"] def get_llm_wiki_source_path() -> Path: """Get the path to the llm-wiki source directory in the package. - + + Generated by AI/LLM: 2026-09-29 - template ships as package data. + Returns: Path: The path to the llm-wiki source directory. """ - # The llm-wiki directory is in the same parent as this wiki module - # src/wiki/ -> src/llm-wiki/ - wiki_dir = Path(__file__).parent - llm_wiki_dir = wiki_dir.parent / "llm-wiki" - - if not llm_wiki_dir.exists(): - # Fallback: check if we're in a development environment - # Go up to src directory and look for llm-wiki - src_dir = wiki_dir.parent - llm_wiki_dir = src_dir / "llm-wiki" - - return llm_wiki_dir + return llm_wiki_template() def calculate_sha256(file_path: Path) -> str: """Calculate SHA256 hash of a file. - + Args: file_path: Path to the file. - + Returns: str: The SHA256 hash as a hexadecimal string. - + Raises: FileNotFoundError: If the file does not exist. """ if not file_path.exists(): raise FileNotFoundError(f"File not found: {file_path}") - + sha256_hash = hashlib.sha256() with open(file_path, "rb") as f: for byte_block in iter(lambda: f.read(4096), b""): @@ -150,32 +142,32 @@ def calculate_sha256(file_path: Path) -> str: def is_core_file(file_path: Path, wiki_root: Path) -> bool: """Check if a file is a core file (part of the package). - + Args: file_path: Path to the file to check. wiki_root: Root path of the wiki. - + Returns: bool: True if the file is a core file, False otherwise (user-created). """ - # Get relative path from wiki root + # Get relative path from fiona.wiki root try: relative_path = file_path.relative_to(wiki_root) except ValueError: return False - + relative_str = relative_path.as_posix() file_name = file_path.name - + # Check if it's a core file by name if file_name in CORE_FILES: return True - + # Check if it's in a core directory for core_dir in CORE_DIRECTORIES: if relative_str.startswith(f"{core_dir}/"): return True - + return False @@ -419,16 +411,16 @@ def find_missing_directories(wiki_root: Path, template_dir: Path) -> list[Path]: def check_wiki_updates(directory: str | Path = ".") -> UpdateSummary: """Check if there are updates available for the wiki. - + This function compares all core files in the wiki against the packaged template and returns a summary of files that need to be updated or added. - + Args: directory: The wiki directory to check. Defaults to current directory. - + Returns: UpdateSummary: Summary of all files that need updates. - + Raises: FileNotFoundError: If the wiki directory does not exist. NotADirectoryError: If the directory is not an llm-wiki directory. @@ -547,10 +539,10 @@ def update_core_files(directory: str | Path = ".", force: bool = False, yes: boo yes: If True, perform update without prompting. verbose: If True, print the update plan and skipped files. Set to False for machine-readable (JSON) CLI output. - + Returns: UpdateSummary: Summary of files that were updated. - + Raises: FileNotFoundError: If the wiki directory does not exist. NotADirectoryError: If the directory is not an llm-wiki directory. @@ -727,7 +719,7 @@ def update_main( dry_run: bool = False ) -> int: """Main function for the 'wiki update' CLI command. - + Args: directory: Wiki directory to update (default: current directory). force: If True, perform update without prompting (alias for yes). @@ -782,7 +774,7 @@ def update_main( ) return 0 - + except (FileNotFoundError, NotADirectoryError) as e: print(f"Error: {e}", file=sys.stderr) return 1 diff --git a/src/wiki/wiki.py b/src/fiona/wiki/wiki.py similarity index 90% rename from src/wiki/wiki.py rename to src/fiona/wiki/wiki.py index 9242b3c..fce86e9 100644 --- a/src/wiki/wiki.py +++ b/src/fiona/wiki/wiki.py @@ -8,34 +8,26 @@ from __future__ import annotations import shutil from collections.abc import Sequence -from datetime import datetime, timezone +from datetime import UTC, datetime from pathlib import Path import git +from fiona.gittool.git_tool import GitTool +from fiona.librarian.toc_generator import path_matches from fiona.logging_config import load_settings -from gittool.git_tool import GitTool -from librarian.toc_generator import path_matches +from fiona.paths import llm_wiki_template def get_llm_wiki_source_path() -> Path: """Get the path to the llm-wiki source directory. + Generated by AI/LLM: 2026-09-29 - template ships as package data. + Returns: Path: The path to the llm-wiki source directory. """ - # The llm-wiki directory is in the same parent as this wiki module - # src/wiki/ -> src/llm-wiki/ - wiki_dir = Path(__file__).parent - llm_wiki_dir = wiki_dir.parent / "llm-wiki" - - if not llm_wiki_dir.exists(): - # Fallback: check if we're in a development environment - # Go up to src directory and look for llm-wiki - src_dir = wiki_dir.parent - llm_wiki_dir = src_dir / "llm-wiki" - - return llm_wiki_dir + return llm_wiki_template() def get_ignore_patterns(source: Path) -> list[str]: @@ -69,7 +61,7 @@ def replace_date_placeholders(content: str) -> str: Returns: str: The content with placeholders replaced. """ - date_stamp = datetime.now(tz=timezone.utc).strftime("%Y-%m-%d") + date_stamp = datetime.now(tz=UTC).strftime("%Y-%m-%d") return content.replace("DATE_PLACEHOLDER", date_stamp) @@ -149,7 +141,7 @@ def wiki_init(directory: str = ".") -> str: """Initialize a directory as an llm-wiki directory. This function copies the complete llm-wiki template structure and files - from the package's src/llm-wiki directory to the target directory. + from the packaged llm-wiki template to the target directory. This ensures a 1:1 copy of the template. It also initializes a git repository and makes the initial commit with diff --git a/src/llm-wiki/__init__.py b/src/llm-wiki/__init__.py deleted file mode 100644 index 714b061..0000000 --- a/src/llm-wiki/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# llm-wiki package -# This package contains templates and utilities for managing the LLM wiki. - -__version__ = "0.1.0" diff --git a/src/tests/__init__.py b/src/tests/__init__.py deleted file mode 100644 index 46816dd..0000000 --- a/src/tests/__init__.py +++ /dev/null @@ -1 +0,0 @@ -"""Tests package.""" diff --git a/src/tests/conftest.py b/tests/conftest.py similarity index 93% rename from src/tests/conftest.py rename to tests/conftest.py index 496f7c0..451a91c 100644 --- a/src/tests/conftest.py +++ b/tests/conftest.py @@ -2,19 +2,15 @@ import os import shutil -import sys import tempfile -# Add the src directory to the Python path so the tool packages resolve -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - import pytest -from librarian.librarian import Librarian -from mdoctor.mdoctor import MDoctor -from python_ruff.python_ruff import PythonRuff -from wiki.sanity_manager import run_wiki_checks -from wiki.wiki import get_llm_wiki_source_path, wiki_init +from fiona.librarian.librarian import Librarian +from fiona.mdoctor.mdoctor import MDoctor +from fiona.python_ruff.python_ruff import PythonRuff +from fiona.wiki.sanity_manager import run_wiki_checks +from fiona.wiki.wiki import get_llm_wiki_source_path, wiki_init @pytest.fixture diff --git a/src/tests/test_customlinter_base.py b/tests/test_customlinter_base.py similarity index 99% rename from src/tests/test_customlinter_base.py rename to tests/test_customlinter_base.py index a2104f3..c41a0ce 100644 --- a/src/tests/test_customlinter_base.py +++ b/tests/test_customlinter_base.py @@ -12,7 +12,7 @@ from typing import ClassVar import pytest -from customlinter.base import ( +from fiona.customlinter.base import ( DEFAULT_SETTINGS_FILE, READONLY_ZONES, BaseLinter, diff --git a/src/tests/test_fiona_main.py b/tests/test_fiona_main.py similarity index 99% rename from src/tests/test_fiona_main.py rename to tests/test_fiona_main.py index 8ecf582..ad567d0 100644 --- a/src/tests/test_fiona_main.py +++ b/tests/test_fiona_main.py @@ -11,7 +11,7 @@ import pytest from fiona import logging_config from fiona.__main__ import main -from librarian import toc_generator +from fiona.librarian import toc_generator @pytest.fixture diff --git a/src/tests/test_fmlint.py b/tests/test_fmlint.py similarity index 99% rename from src/tests/test_fmlint.py rename to tests/test_fmlint.py index 5ab2aea..3e7057f 100644 --- a/src/tests/test_fmlint.py +++ b/tests/test_fmlint.py @@ -15,13 +15,13 @@ import tempfile import pytest -from customlinter.base import FrontmatterLintError, LintViolation -from customlinter.fmlint import ( +from fiona.customlinter.base import FrontmatterLintError, LintViolation +from fiona.customlinter.fmlint import ( FrontmatterLinter, main, validate_file_frontmatter, ) -from librarian.md_frontmatter import FrontmatterError +from fiona.librarian.md_frontmatter import FrontmatterError # ============================================================================= # Fixtures @@ -1222,7 +1222,7 @@ class TestLintFileDirect: # Mock parse_frontmatter to raise error; patch the binding that # lint_file actually uses (module-level, see python-tdd rule 0) mocker.patch( - "customlinter.fmlint.parse_frontmatter", + "fiona.customlinter.fmlint.parse_frontmatter", side_effect=FrontmatterError("Invalid frontmatter") ) diff --git a/src/tests/test_gittool.py b/tests/test_gittool.py similarity index 99% rename from src/tests/test_gittool.py rename to tests/test_gittool.py index 2ecf0ef..a84f0e1 100644 --- a/src/tests/test_gittool.py +++ b/tests/test_gittool.py @@ -5,7 +5,7 @@ from __future__ import annotations import git import pytest -from gittool.git_tool import GitTool +from fiona.gittool.git_tool import GitTool @pytest.fixture diff --git a/src/tests/test_graph_generator.py b/tests/test_graph_generator.py similarity index 99% rename from src/tests/test_graph_generator.py rename to tests/test_graph_generator.py index b1f82d2..49b3de1 100644 --- a/src/tests/test_graph_generator.py +++ b/tests/test_graph_generator.py @@ -6,7 +6,7 @@ Test cases for MarkdownLinkParser, WikiGraph, and HTMLGraphRenderer classes. import json import os -from wiki.graph_generator import ( +from fiona.wiki.graph_generator import ( HTMLGraphRenderer, MarkdownLinkParser, WikiGraph, @@ -726,7 +726,7 @@ class TestWikiGraphMain: return False return real_access(path, mode) - monkeypatch.setattr("wiki.graph_generator.os.access", deny_directory_write) + monkeypatch.setattr("fiona.wiki.graph_generator.os.access", deny_directory_write) output_file = tmp_path / "graph.html" result = wiki_graph_main( diff --git a/src/tests/test_json_lint.py b/tests/test_json_lint.py similarity index 98% rename from src/tests/test_json_lint.py rename to tests/test_json_lint.py index acfff58..91ceafb 100644 --- a/src/tests/test_json_lint.py +++ b/tests/test_json_lint.py @@ -13,11 +13,11 @@ from io import StringIO import pytest -from customlinter.base import BaseLinter, LinterError, LintViolation -from customlinter.jsonlint import JsonLinter, main +from fiona.customlinter.base import BaseLinter, LinterError, LintViolation +from fiona.customlinter.jsonlint import JsonLinter, main # AI/LLM: the suite is not tied to a Linux checkout path. -REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] +REPO_ROOT = pathlib.Path(__file__).resolve().parents[1] def _run_jsonlint_cli(argv: list[str]) -> subprocess.CompletedProcess[str]: @@ -33,7 +33,7 @@ def _run_jsonlint_cli(argv: list[str]) -> subprocess.CompletedProcess[str]: The completed subprocess. """ script = ( - "from customlinter.jsonlint import main; import sys; " + "from fiona.customlinter.jsonlint import main; import sys; " f"sys.argv = {argv!r}; main()" ) return subprocess.run( @@ -1294,7 +1294,7 @@ def test_cli_default_subcommand(): # Run without subcommand (should default to chklint) result = subprocess.run( [sys.executable, '-c', - 'from customlinter.jsonlint import main; import sys; sys.argv = ["jsonlint"]; main()'], + 'from fiona.customlinter.jsonlint import main; import sys; sys.argv = ["jsonlint"]; main()'], capture_output=True, text=True, check=False, @@ -1309,7 +1309,7 @@ def test_cli_chklint_with_nonexistent(): """Test CLI chklint with nonexistent directory.""" result = subprocess.run( [sys.executable, '-c', - 'from customlinter.jsonlint import main; import sys; sys.argv = ["jsonlint", "chklint", "/nonexistent/path"]; main()'], + 'from fiona.customlinter.jsonlint import main; import sys; sys.argv = ["jsonlint", "chklint", "/nonexistent/path"]; main()'], capture_output=True, text=True, check=False @@ -1323,7 +1323,7 @@ def test_cli_fix_with_nonexistent(): """Test CLI fix with nonexistent directory.""" result = subprocess.run( [sys.executable, '-c', - 'from customlinter.jsonlint import main; import sys; sys.argv = ["jsonlint", "fix", "/nonexistent/path"]; main()'], + 'from fiona.customlinter.jsonlint import main; import sys; sys.argv = ["jsonlint", "fix", "/nonexistent/path"]; main()'], capture_output=True, text=True, check=False diff --git a/src/tests/test_librarian.py b/tests/test_librarian.py similarity index 98% rename from src/tests/test_librarian.py rename to tests/test_librarian.py index ae9eaaf..6db0a64 100644 --- a/src/tests/test_librarian.py +++ b/tests/test_librarian.py @@ -8,7 +8,7 @@ from unittest.mock import patch import pytest from fiona import logging_config -from librarian.librarian import main +from fiona.librarian.librarian import main def test_list_all_files(librarian, temp_dir_with_files): diff --git a/src/tests/test_logging_config.py b/tests/test_logging_config.py similarity index 95% rename from src/tests/test_logging_config.py rename to tests/test_logging_config.py index 6ab2175..0915c16 100644 --- a/src/tests/test_logging_config.py +++ b/tests/test_logging_config.py @@ -145,7 +145,7 @@ class TestFileLogging: "file_log_location": str(location), } }) - logging.getLogger("librarian").info("hello file") + logging.getLogger("fiona.librarian").info("hello file") content = location.read_text(encoding="utf-8") assert "hello file" in content assert "INFO" in content @@ -159,7 +159,7 @@ class TestFileLogging: "file_log_location": str(location), } }) - logging.getLogger("librarian").info("stamped") + logging.getLogger("fiona.librarian").info("stamped") line = location.read_text(encoding="utf-8").strip() assert re.match(r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}", line) @@ -173,8 +173,8 @@ class TestFileLogging: "file_log_location": str(location), } }) - logging.getLogger("librarian").info("info record") - logging.getLogger("librarian").error("error record") + logging.getLogger("fiona.librarian").info("info record") + logging.getLogger("fiona.librarian").error("error record") content = location.read_text(encoding="utf-8") assert "error record" in content assert "info record" not in content @@ -188,7 +188,7 @@ class TestFileLogging: "file_log_location": str(location), } }) - logging.getLogger("librarian").debug("debug record") + logging.getLogger("fiona.librarian").debug("debug record") assert "debug record" in location.read_text(encoding="utf-8") def test_no_location_adds_no_file_handler(self): @@ -209,7 +209,7 @@ class TestFileLogging: second = tmp_path / "second.log" setup_logging({"fiona": {"log_level": "INFO", "file_log_location": str(first)}}) setup_logging({"fiona": {"log_level": "INFO", "file_log_location": str(second)}}) - logging.getLogger("librarian").info("moved record") + logging.getLogger("fiona.librarian").info("moved record") assert "moved record" in second.read_text(encoding="utf-8") assert not first.exists() or "moved record" not in first.read_text(encoding="utf-8") @@ -232,7 +232,7 @@ class TestFileLogging: } }) assert "VERBOSE" in caplog.text - logging.getLogger("librarian").info("fallback record") + logging.getLogger("fiona.librarian").info("fallback record") assert "fallback record" in location.read_text(encoding="utf-8") def test_unwritable_location_warns_and_continues(self, tmp_path, caplog): diff --git a/src/tests/test_md_frontmatter.py b/tests/test_md_frontmatter.py similarity index 99% rename from src/tests/test_md_frontmatter.py rename to tests/test_md_frontmatter.py index 5906a8e..5174685 100644 --- a/src/tests/test_md_frontmatter.py +++ b/tests/test_md_frontmatter.py @@ -10,7 +10,7 @@ import tempfile import pytest -from librarian.md_frontmatter import ( +from fiona.librarian.md_frontmatter import ( FrontmatterError, FrontmatterParser, RequiredFieldError, diff --git a/src/tests/test_mdlinter.py b/tests/test_mdlinter.py similarity index 95% rename from src/tests/test_mdlinter.py rename to tests/test_mdlinter.py index 2bf3654..6d6e974 100644 --- a/src/tests/test_mdlinter.py +++ b/tests/test_mdlinter.py @@ -1,7 +1,7 @@ """Tests for the MarkdownLinter (mdlinter) module. Covers the custom markdown linter in the customlinter framework: the -dead-link check (MDL001/MDL002, moved from wiki.sanity_manager), the +dead-link check (MDL001/MDL002, moved from fiona.wiki.sanity_manager), the per-file check registry, and the shared linter report format (SPEC 6.1). """ @@ -13,9 +13,9 @@ from pathlib import Path import pytest -from customlinter.base import LinterError -from customlinter.mdlinter import MarkdownLinter, find_dead_links -from wiki.wiki import get_llm_wiki_source_path +from fiona.customlinter.base import LinterError +from fiona.customlinter.mdlinter import MarkdownLinter, find_dead_links +from fiona.wiki.wiki import get_llm_wiki_source_path def _write_md(path: Path, name: str, body: str, version: str = "1.0.0"): @@ -46,7 +46,7 @@ def linter(wiki): # ============================================================================= -# Dead Link Check Tests (moved from wiki.sanity_manager) +# Dead Link Check Tests (moved from fiona.wiki.sanity_manager) # ============================================================================= class TestDeadLinkCheck: @@ -211,7 +211,7 @@ class TestLintFile: # ============================================================================= -# Module-level find_dead_links (moved from wiki.sanity_manager) +# Module-level find_dead_links (moved from fiona.wiki.sanity_manager) # ============================================================================= class TestFindDeadLinks: diff --git a/src/tests/test_mdoctor.py b/tests/test_mdoctor.py similarity index 99% rename from src/tests/test_mdoctor.py rename to tests/test_mdoctor.py index 35d18f5..7f7e7db 100644 --- a/src/tests/test_mdoctor.py +++ b/tests/test_mdoctor.py @@ -10,7 +10,7 @@ from unittest.mock import patch import pytest from pymarkdown.api import PyMarkdownApiException -from mdoctor.mdoctor import MDoctor, ProgrammaticLintViolation, main +from fiona.mdoctor.mdoctor import MDoctor, ProgrammaticLintViolation, main class TestMDoctor: @@ -353,7 +353,7 @@ class TestMDoctorFix: """Test main() reports pymarkdown API failures instead of crashing.""" with tempfile.TemporaryDirectory() as temp_dir, \ patch('sys.argv', ['mdoctor', 'fix', temp_dir]), \ - patch('mdoctor.mdoctor.MDoctor.fix_file_programmatically', + patch('fiona.mdoctor.mdoctor.MDoctor.fix_file_programmatically', side_effect=PyMarkdownApiException("api failure")): with pytest.raises(SystemExit) as exc_info: main() diff --git a/src/tests/test_pycustomlint.py b/tests/test_pycustomlint.py similarity index 99% rename from src/tests/test_pycustomlint.py rename to tests/test_pycustomlint.py index 40dc4f4..51a17d8 100644 --- a/src/tests/test_pycustomlint.py +++ b/tests/test_pycustomlint.py @@ -8,8 +8,8 @@ import tempfile import pytest -from customlinter.base import CustomLintError -from customlinter.pycustomlint import ( +from fiona.customlinter.base import CustomLintError +from fiona.customlinter.pycustomlint import ( READONLY_ZONES, VIOLATION_CODES, InlineImportVisitor, diff --git a/src/tests/test_python_ruff.py b/tests/test_python_ruff.py similarity index 97% rename from src/tests/test_python_ruff.py rename to tests/test_python_ruff.py index 774031c..dc4692c 100644 --- a/src/tests/test_python_ruff.py +++ b/tests/test_python_ruff.py @@ -8,7 +8,7 @@ from unittest.mock import MagicMock, patch import pytest -from python_ruff.python_ruff import PythonRuff, main +from fiona.python_ruff.python_ruff import PythonRuff, main class TestPythonRuff: @@ -194,14 +194,14 @@ class TestPythonRuffEdgeCases: def test_lint_with_fix_passes_flag(self, pyruff): """Test lint(fix=True) passes --fix to the ruff binary.""" - with patch('python_ruff.python_ruff.subprocess.run') as mock_run: + with patch('fiona.python_ruff.python_ruff.subprocess.run') as mock_run: mock_run.return_value = MagicMock(returncode=0, stdout="[]", stderr="") pyruff.lint("src", fix=True) assert "--fix" in mock_run.call_args[0][0] def test_lint_non_list_json_returns_empty(self, pyruff): """Test lint returns [] when ruff emits a non-list JSON payload.""" - with patch('python_ruff.python_ruff.subprocess.run') as mock_run: + with patch('fiona.python_ruff.python_ruff.subprocess.run') as mock_run: mock_run.return_value = MagicMock( returncode=0, stdout='{"violations": []}', stderr="" ) diff --git a/src/tests/test_run_sanity.py b/tests/test_run_sanity.py similarity index 93% rename from src/tests/test_run_sanity.py rename to tests/test_run_sanity.py index fac845f..a65e32f 100644 --- a/src/tests/test_run_sanity.py +++ b/tests/test_run_sanity.py @@ -9,12 +9,12 @@ from unittest.mock import patch import pytest -import run_sanity -from customlinter.base import LintViolation -from customlinter.pycustomlint import PythonCustomLinter -from mdoctor.mdoctor import MDoctor -from python_ruff.python_ruff import PythonRuff -from run_tests import TestRunner +import fiona.run_sanity as run_sanity +from fiona.customlinter.base import LintViolation +from fiona.customlinter.pycustomlint import PythonCustomLinter +from fiona.mdoctor.mdoctor import MDoctor +from fiona.python_ruff.python_ruff import PythonRuff +from fiona.run_tests import TestRunner def _make_pytest_result(passed_count=1, failed_count=0, coverage_percent=95.0, @@ -59,7 +59,7 @@ def required_coverage_95(monkeypatch): @pytest.fixture def mock_test_runner(): """Patch TestRunner inside run_sanity to avoid running real tests.""" - with patch("run_sanity.TestRunner") as runner_class: + with patch("fiona.run_sanity.TestRunner") as runner_class: yield runner_class @@ -198,7 +198,7 @@ class TestRunPytests: }, ], ) - with caplog.at_level(logging.DEBUG, logger="run_sanity"): + with caplog.at_level(logging.DEBUG, logger="fiona.run_sanity"): run_sanity.run_pytests() assert "src/tests/test_a.py::TestX::test_one" in caplog.text @@ -218,7 +218,7 @@ class TestRunPytests: }, failed_tests=[], ) - with caplog.at_level(logging.WARNING, logger="run_sanity"): + with caplog.at_level(logging.WARNING, logger="fiona.run_sanity"): run_sanity.run_pytests() assert "no failure details" in caplog.text @@ -243,7 +243,7 @@ class TestRunPytests: }, failed_tests=[duplicate, dict(duplicate)], ) - with caplog.at_level(logging.WARNING, logger="run_sanity"): + with caplog.at_level(logging.WARNING, logger="fiona.run_sanity"): run_sanity.run_pytests() assert "no failure details" not in caplog.text @@ -293,17 +293,17 @@ class TestConfigureLogging: monkeypatch.setenv("LOG_LEVEL", "DEBUG") run_sanity.configure_logging() assert root.level == logging.DEBUG - assert logging.getLogger("run_sanity").level == logging.DEBUG - assert logging.getLogger("run_tests").level == logging.DEBUG + assert logging.getLogger("fiona.run_sanity").level == logging.DEBUG + assert logging.getLogger("fiona.run_tests").level == logging.DEBUG monkeypatch.setenv("LOG_LEVEL", "INFO") run_sanity.configure_logging() assert root.level == logging.INFO - assert logging.getLogger("run_sanity").level == logging.INFO - assert logging.getLogger("run_tests").level == logging.INFO + assert logging.getLogger("fiona.run_sanity").level == logging.INFO + assert logging.getLogger("fiona.run_tests").level == logging.INFO finally: root.setLevel(old_level) - for name in ("run_sanity", "run_tests"): + for name in ("fiona.run_sanity", "fiona.run_tests"): logging.getLogger(name).setLevel(logging.NOTSET) def test_default_level_is_warning(self, monkeypatch): @@ -338,7 +338,7 @@ def _make_md_violation(scan_file=".", line=3, column=1, def mock_mdoctor(): """Patch MDoctor inside run_sanity, keeping the real violation formatting.""" real_mdoctor = MDoctor() - with patch("run_sanity.MDoctor") as doctor_class: + with patch("fiona.run_sanity.MDoctor") as doctor_class: instance = doctor_class.return_value instance.compress_violations.side_effect = real_mdoctor.compress_violations instance.format_violations.side_effect = real_mdoctor.format_violations @@ -361,7 +361,7 @@ def _make_ruff_violation(filename, row=13, column=8, def mock_python_ruff(): """Patch PythonRuff inside run_sanity, keeping the real formatting.""" real_ruff = PythonRuff() - with patch("run_sanity.PythonRuff") as ruff_class: + with patch("fiona.run_sanity.PythonRuff") as ruff_class: instance = ruff_class.return_value instance.compress_violations.side_effect = real_ruff.compress_violations instance.format_violations.side_effect = real_ruff.format_violations @@ -373,14 +373,14 @@ class TestRunRuff: def test_stdout_lists_file_and_line(self, mock_python_ruff): """Test stdout names the violating file and the line:column position.""" - filename = str(run_sanity.SETTINGS_FILE.parent / "run_sanity.py") + filename = str(run_sanity.SETTINGS_FILE.parent / "fiona.run_sanity.py") mock_python_ruff.return_value.lint.return_value = [ _make_ruff_violation(filename, row=13, column=8, code="F401"), ] result = run_sanity.run_ruff() assert result["result"] == 1 assert result["violation_count"] == 1 - assert "run_sanity.py" in result["stdout"] + assert "fiona.run_sanity.py" in result["stdout"] assert "13:8 F401" in result["stdout"] def test_no_violations_pass(self, mock_python_ruff): @@ -409,7 +409,7 @@ def _make_pyc_violation(filename, line=205, column=4, code="PYC001", def mock_python_custom_linter(): """Patch PythonCustomLinter inside run_sanity, keeping the real formatting.""" real_linter = PythonCustomLinter() - with patch("run_sanity.PythonCustomLinter") as linter_class: + with patch("fiona.run_sanity.PythonCustomLinter") as linter_class: instance = linter_class.return_value instance.compress_violations.side_effect = real_linter.compress_violations instance.format_compressed_violations.side_effect = ( @@ -428,7 +428,9 @@ class TestRunPycustomlint: pycustomlint report carries the Violations header, TARGET, DEFINITIONS, FILE, and SUMMARY sections. """ - filename = str(run_sanity.SETTINGS_FILE.parent / "customlinter" / "pycustomlint.py") + filename = str( + pathlib.Path("src/fiona/customlinter/pycustomlint.py").resolve() + ) mock_python_custom_linter.return_value.lint_directory.return_value = [ _make_pyc_violation(filename, line=205, column=4, code="PYC001", message="PYC001 Inline import: import argparse"), @@ -446,7 +448,7 @@ class TestRunPycustomlint: " first function or class is allowed" ) in stdout # File path is relative to target (src) - assert "- FILE: customlinter/pycustomlint.py" in stdout + assert "- FILE: fiona/customlinter/pycustomlint.py" in stdout assert " - PYC001 Inline import: import argparse" in stdout assert "- SUMMARY:" in stdout # file count first, matching the fmlint and markdownlint reports @@ -511,7 +513,7 @@ class TestMain: }, "ruff": {"result": 0, "violation_count": 0}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert out.index("AI-FORMATTED-VIOLATIONS") < out.index("Results:") @@ -527,7 +529,7 @@ class TestMain: "stdout": "AI-RUFF-REPORT", }, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert out.index("AI-RUFF-REPORT") < out.index("Results:") @@ -542,7 +544,7 @@ class TestMain: "stdout": "AI-PYCUSTOMLINT-REPORT", }, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert out.index("AI-PYCUSTOMLINT-REPORT") < out.index("Results:") @@ -562,7 +564,7 @@ class TestMain: "stdout": "AI-PYTESTS-REPORT", }, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert out.index("AI-PYTESTS-REPORT") < out.index("Results:") @@ -582,7 +584,7 @@ class TestMain: "stdout": "AI-PYTESTS-REPORT", }, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert "AI-PYTESTS-REPORT" in out @@ -598,7 +600,7 @@ class TestMain: }, "ruff": {"result": 0, "violation_count": 0}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert "SUMMARY" not in out @@ -727,7 +729,7 @@ class TestFormatCheckSummary: }, "ruff": {"result": 0, "violation_count": 0}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert " markdownlint: FAIL - 2 violations" in out @@ -742,16 +744,16 @@ class TestRunAllFunction: def test_run_all_runs_all_checks(self, capsys): """Test run_all executes all six checks and returns their results.""" - with patch("run_sanity.run_pytests", return_value={"result": 0}) as mock_p, \ - patch("run_sanity.run_markdownlint", + with patch("fiona.run_sanity.run_pytests", return_value={"result": 0}) as mock_p, \ + patch("fiona.run_sanity.run_markdownlint", return_value={"result": 0, "violation_count": 0}) as mock_m, \ - patch("run_sanity.run_ruff", + patch("fiona.run_sanity.run_ruff", return_value={"result": 0, "violation_count": 0}) as mock_r, \ - patch("run_sanity.run_frontmatter_lint", + patch("fiona.run_sanity.run_frontmatter_lint", return_value={"result": 0, "violation_count": 0}) as mock_f, \ - patch("run_sanity.run_pycustomlint", + patch("fiona.run_sanity.run_pycustomlint", return_value={"result": 0, "violation_count": 0}) as mock_c, \ - patch("run_sanity.run_jsonlint", + patch("fiona.run_sanity.run_jsonlint", return_value={"result": 0, "violation_count": 0}) as mock_j: results = run_sanity.run_all() @@ -768,14 +770,14 @@ class TestRunAllFunction: def test_run_all_records_durations(self, capsys): """Test run_all attaches a duration to every check result.""" - with patch("run_sanity.run_pytests", return_value={"result": 0}), \ - patch("run_sanity.run_markdownlint", + with patch("fiona.run_sanity.run_pytests", return_value={"result": 0}), \ + patch("fiona.run_sanity.run_markdownlint", return_value={"result": 0, "violation_count": 0}), \ - patch("run_sanity.run_ruff", + patch("fiona.run_sanity.run_ruff", return_value={"result": 0, "violation_count": 0}), \ - patch("run_sanity.run_frontmatter_lint", + patch("fiona.run_sanity.run_frontmatter_lint", return_value={"result": 0, "violation_count": 0}), \ - patch("run_sanity.run_pycustomlint", + patch("fiona.run_sanity.run_pycustomlint", return_value={"result": 0, "violation_count": 0}): results = run_sanity.run_all() @@ -793,7 +795,7 @@ class TestVerdict: "markdownlint": {"result": 0, "violation_count": 0}, "ruff": {"result": 0, "violation_count": 0}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert "SANITY PASSED" in out @@ -807,7 +809,7 @@ class TestVerdict: "markdownlint": {"result": 0, "violation_count": 0}, "ruff": {"result": 0, "violation_count": 0}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert re.search(r"SANITY PASSED \(\d{2}:\d{2}\)", out) @@ -830,7 +832,7 @@ class TestVerdict: "duration_seconds": 7, }, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert " pytests: PASS - 0 tests failed (00:42)" in out @@ -851,7 +853,7 @@ class TestVerdict: }, "ruff": {"result": 0, "violation_count": 0}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert "Sanity Failed - 1 check needs attention:" in out @@ -865,7 +867,7 @@ class TestVerdict: "markdownlint": {"result": 1, "violation_count": 12}, "ruff": {"result": 1, "violation_count": 3}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert "Sanity Failed - 2 checks need attention:" in out @@ -885,7 +887,7 @@ class TestVerdict: }, "ruff": {"result": 0, "violation_count": 0}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert " - pytests: 0 tests failed" in out @@ -904,7 +906,7 @@ class TestVerdict: }, "markdownlint": {"result": 1, "violation_count": 2}, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert " - pytests: 1 test failed" in out @@ -983,7 +985,7 @@ class TestVerdict: ], }, } - with patch("run_sanity.run_all", return_value=results): + with patch("fiona.run_sanity.run_all", return_value=results): run_sanity.main([]) out = capsys.readouterr().out assert " - pytests: 1 test failed" in out @@ -1017,7 +1019,7 @@ class TestFailedTestReportIntegration: self.target, verbose, capture_output, with_coverage=False ) - return patch("run_sanity.TestRunner", lambda: TargetedRunner(test_file)) + return patch("fiona.run_sanity.TestRunner", lambda: TargetedRunner(test_file)) def test_real_failure_shows_function_and_assert(self, tmp_path): """Test a real pytest failure nests its name and assert under the file. @@ -1316,7 +1318,7 @@ class TestNonInteractiveMode: def test_main_wires_progress_callbacks(self, capsys): """Test main() passes the display callbacks to run_all.""" - with patch("run_sanity.run_all", return_value={}) as mock_run_all: + with patch("fiona.run_sanity.run_all", return_value={}) as mock_run_all: run_sanity.main([]) assert mock_run_all.call_args.kwargs["progress"] is not None diff --git a/src/tests/test_run_tests.py b/tests/test_run_tests.py similarity index 95% rename from src/tests/test_run_tests.py rename to tests/test_run_tests.py index daf0870..f438681 100644 --- a/src/tests/test_run_tests.py +++ b/tests/test_run_tests.py @@ -6,7 +6,7 @@ from unittest.mock import MagicMock, patch import pytest -import run_tests +import fiona.run_tests as run_tests @pytest.fixture @@ -339,7 +339,7 @@ class TestRunPytest: ), stderr="", ) - mocker.patch("run_tests.subprocess.run", side_effect=fake_run) + mocker.patch("fiona.run_tests.subprocess.run", side_effect=fake_run) result = test_runner.run_pytest("src/tests", verbose=True, with_coverage=False, capture_output=True) @@ -366,7 +366,7 @@ class TestRunPytest: stdout="========================= 1 error in 0.10s =========================\n", stderr="", ) - mocker.patch("run_tests.subprocess.run", side_effect=fake_run) + mocker.patch("fiona.run_tests.subprocess.run", side_effect=fake_run) result = test_runner.run_pytest("src/tests", verbose=True, with_coverage=False, capture_output=True) @@ -385,7 +385,7 @@ class TestRunPytest: would break the output parsers; the command pins --color=no. """ subprocess_mock = mocker.patch( - "run_tests.subprocess.run", + "fiona.run_tests.subprocess.run", return_value=MagicMock(returncode=0, stdout="1 passed in 0.10s", stderr=""), ) test_runner.run_pytest("src/tests", with_coverage=False, capture_output=True) @@ -411,9 +411,9 @@ class TestRunPytest: ), stderr="", ) - mocker.patch("run_tests.subprocess.run", side_effect=fake_run) + mocker.patch("fiona.run_tests.subprocess.run", side_effect=fake_run) - with caplog.at_level(logging.WARNING, logger="run_tests"): + with caplog.at_level(logging.WARNING, logger="fiona.run_tests"): result = test_runner.run_pytest("src/tests", verbose=True, with_coverage=False, capture_output=True) @@ -433,7 +433,7 @@ class TestRunPytest: ), stderr="", ) - mocker.patch("run_tests.subprocess.run", side_effect=fake_run) + mocker.patch("fiona.run_tests.subprocess.run", side_effect=fake_run) result = test_runner.run_pytest("src/tests", verbose=True, with_coverage=False, capture_output=True) @@ -475,7 +475,7 @@ class TestRunPytest: ), stderr="", ) - mocker.patch("run_tests.subprocess.run", side_effect=fake_run) + mocker.patch("fiona.run_tests.subprocess.run", side_effect=fake_run) result = test_runner.run_pytest("src/tests", verbose=True, with_coverage=False, capture_output=True) @@ -502,7 +502,7 @@ class TestRunPytest: ), stderr="", ) - mocker.patch("run_tests.subprocess.run", side_effect=fake_run) + mocker.patch("fiona.run_tests.subprocess.run", side_effect=fake_run) result = test_runner.run_pytest("src/tests", verbose=True, with_coverage=False, capture_output=True) @@ -523,12 +523,12 @@ class TestRunPytest: written["path"] = junit_path return MagicMock(returncode=0, stdout="1 passed in 0.10s", stderr="") - mocker.patch("run_tests.subprocess.run", side_effect=fake_run) + mocker.patch("fiona.run_tests.subprocess.run", side_effect=fake_run) test_runner.run_pytest("src/tests", with_coverage=False, capture_output=True) assert not pathlib.Path(written["path"]).exists() - @patch('run_tests.subprocess.run') + @patch('fiona.run_tests.subprocess.run') def test_run_pytest_includes_failed_tests(self, mock_run, test_runner): """Test run_pytest returns the failed test details.""" mock_run.return_value = MagicMock( @@ -544,7 +544,7 @@ class TestRunPytest: assert result["failed_tests"][0]["id"] == "src/tests/test_a.py::TestX::test_one" assert "assert 1 == 2" in result["failed_tests"][0]["message"] - @patch('run_tests.subprocess.run') + @patch('fiona.run_tests.subprocess.run') def test_run_pytest_warns_when_failure_details_missing(self, mock_run, test_runner, caplog): """Test a warning is logged when failures count but no details parse.""" @@ -555,13 +555,13 @@ class TestRunPytest: ), stderr="" ) - with caplog.at_level(logging.WARNING, logger="run_tests"): + with caplog.at_level(logging.WARNING, logger="fiona.run_tests"): result = test_runner.run_pytest("src/tests", capture_output=True) assert result["failed_count"] == 1 assert result["failed_tests"] == [] assert "no failure details" in caplog.text - @patch('run_tests.subprocess.run') + @patch('fiona.run_tests.subprocess.run') def test_run_pytest_includes_file_results(self, mock_run, test_runner): """Test run_pytest returns per-file results from verbose output.""" mock_run.return_value = MagicMock( @@ -578,7 +578,7 @@ class TestRunPytest: assert result["file_results"]["test_a.py"]["passed"] == 2 assert result["file_results"]["test_b.py"]["passed"] == 1 - @patch('run_tests.subprocess.run') + @patch('fiona.run_tests.subprocess.run') def test_run_pytest_includes_coverage_files(self, mock_run, test_runner): """Test run_pytest returns per-file coverage from the report.""" mock_run.return_value = MagicMock( @@ -594,7 +594,7 @@ class TestRunPytest: result = test_runner.run_pytest("src/tests", capture_output=True) assert result["coverage_files"]["src/wiki/wiki.py"] == 96.0 - @patch('run_tests.subprocess.run') + @patch('fiona.run_tests.subprocess.run') def test_run_pytest_records_spawn_errors(self, mock_run, test_runner): """Test subprocess spawn failures are recorded, not raised.""" mock_run.side_effect = OSError("spawn failed") @@ -606,7 +606,7 @@ class TestRunPytest: assert result["exc"] is not None assert test_runner.total_collected == 0 - @patch('run_tests.subprocess.run') + @patch('fiona.run_tests.subprocess.run') def test_run_pytest_does_not_swallow_unexpected_errors(self, mock_run, test_runner): """Test unexpected exceptions propagate instead of being swallowed.""" mock_run.side_effect = RuntimeError("unexpected") @@ -614,7 +614,7 @@ class TestRunPytest: with pytest.raises(RuntimeError): test_runner.run_pytest("src/tests", capture_output=True) - # @patch('run_tests.subprocess.run') + # @patch('fiona.run_tests.subprocess.run') # def test_run_pytest_success(self, mock_run, test_runner): # """Test running pytest successfully.""" # mock_run.return_value = MagicMock( @@ -634,7 +634,7 @@ class TestRunPytest: # assert test_runner.total_passed == 3 # assert test_runner.total_failed == 0 - # @patch('run_tests.subprocess.run') + # @patch('fiona.run_tests.subprocess.run') # def test_run_pytest_failure(self, mock_run, test_runner): # """Test running pytest with failures.""" # mock_run.return_value = MagicMock( @@ -654,7 +654,7 @@ class TestRunPytest: # assert test_runner.total_passed == 2 # assert test_runner.total_failed == 1 - # @patch('run_tests.subprocess.run') + # @patch('fiona.run_tests.subprocess.run') # def test_run_pytest_exception(self, mock_run, test_runner): # """Test handling of exceptions in pytest execution.""" # mock_run.side_effect = Exception("Test error") @@ -668,7 +668,7 @@ class TestRunPytest: # assert test_runner.total_passed == 0 # assert test_runner.total_failed == 0 - # @patch('run_tests.subprocess.run') + # @patch('fiona.run_tests.subprocess.run') # def test_run_pytest_verbose(self, mock_run, test_runner): # """Test running pytest in verbose mode.""" # mock_run.return_value = MagicMock( @@ -684,7 +684,7 @@ class TestRunPytest: # call_args = mock_run.call_args[0][0] # assert "-v" in call_args - # @patch('run_tests.subprocess.run') + # @patch('fiona.run_tests.subprocess.run') # def test_run_pytest_capture_output(self, mock_run, test_runner): # """Test running pytest with output capture.""" # mock_run.return_value = MagicMock( @@ -701,7 +701,7 @@ class TestRunPytest: def test_called_with_verbose_flag(self, mocker, test_runner): """Test that the pytest subprocess command includes the verbose flag.""" subprocess_mock = mocker.patch( - "run_tests.subprocess.run", + "fiona.run_tests.subprocess.run", return_value=MagicMock(returncode=0, stdout="1 passed in 0.10s", stderr=""), ) result = test_runner.run_pytest("src/tests", verbose=True, with_coverage=False) @@ -713,7 +713,7 @@ class TestRunPytest: def test_prints_output_when_not_captured(self, mocker, test_runner, capsys): """Test that subprocess output is printed when capture is disabled.""" mocker.patch( - "run_tests.subprocess.run", + "fiona.run_tests.subprocess.run", return_value=MagicMock(returncode=0, stdout="test output", stderr=""), ) test_runner.run_pytest("src/tests", with_coverage=False, capture_output=False) @@ -722,7 +722,7 @@ class TestRunPytest: def test_suppresses_output_when_captured(self, mocker, test_runner, capsys): """Test that subprocess output is suppressed when capture is enabled.""" mocker.patch( - "run_tests.subprocess.run", + "fiona.run_tests.subprocess.run", return_value=MagicMock(returncode=0, stdout="test output", stderr=""), ) test_runner.run_pytest("src/tests", with_coverage=False, capture_output=True) @@ -732,7 +732,7 @@ class TestRunPytest: """Test that a covered run records the coverage percentage from output.""" stdout = "TOTAL 729 98 87%\n3 passed in 0.10s" mocker.patch( - "run_tests.subprocess.run", + "fiona.run_tests.subprocess.run", return_value=MagicMock(returncode=0, stdout=stdout, stderr=""), ) result = test_runner.run_pytest("src/tests", with_coverage=True) @@ -742,7 +742,7 @@ class TestRunPytest: def test_coverage_percent_none_without_coverage(self, mocker, test_runner): """Test that coverage percentage stays None when coverage is disabled.""" mocker.patch( - "run_tests.subprocess.run", + "fiona.run_tests.subprocess.run", return_value=MagicMock(returncode=0, stdout="1 passed in 0.10s", stderr=""), ) result = test_runner.run_pytest("src/tests", with_coverage=False) @@ -752,7 +752,7 @@ class TestRunPytest: """Test that test counts are parsed from the subprocess output.""" stdout = "2 failed, 3 passed, 1 skipped in 0.10s" mocker.patch( - "run_tests.subprocess.run", + "fiona.run_tests.subprocess.run", return_value=MagicMock(returncode=1, stdout=stdout, stderr=""), ) result = test_runner.run_pytest("src/tests", with_coverage=False) @@ -780,7 +780,7 @@ class TestRunAllTests: all_passed = test_runner.run_all_tests(verbose=False, capture_output=False, with_coverage=True) assert all_passed is True - mock_run_pytest.assert_called_once_with("src/tests", False, False, True) + mock_run_pytest.assert_called_once_with("tests", False, False, True) @patch.object(run_tests.TestRunner, 'run_pytest') def test_run_all_tests_failure(self, mock_run_pytest, test_runner): @@ -864,8 +864,8 @@ class TestParseCoverageOutput: class TestRunTestsMain: """Tests for run_tests.run_tests.main() function.""" - @patch('run_tests.TestRunner') - @patch('run_tests.argparse') + @patch('fiona.run_tests.TestRunner') + @patch('fiona.run_tests.argparse') def test_main_all_tests_pass(self, mock_argparse, mock_runner_class): """Test run_tests.main() when all tests pass.""" mock_runner = MagicMock() @@ -896,8 +896,8 @@ class TestRunTestsMain: False, False, True ) - @patch('run_tests.TestRunner') - @patch('run_tests.argparse') + @patch('fiona.run_tests.TestRunner') + @patch('fiona.run_tests.argparse') def test_main_verbose_mode(self, mock_argparse, mock_runner_class): """Test run_tests.main() in verbose mode.""" mock_runner = MagicMock() @@ -928,8 +928,8 @@ class TestRunTestsMain: True, False, True ) - @patch('run_tests.TestRunner') - @patch('run_tests.argparse') + @patch('fiona.run_tests.TestRunner') + @patch('fiona.run_tests.argparse') def test_main_ci_mode(self, mock_argparse, mock_runner_class): """Test run_tests.main() in CI mode.""" mock_runner = MagicMock() @@ -960,8 +960,8 @@ class TestRunTestsMain: False, True, True ) - @patch('run_tests.TestRunner') - @patch('run_tests.argparse') + @patch('fiona.run_tests.TestRunner') + @patch('fiona.run_tests.argparse') def test_main_skip_coverage(self, mock_argparse, mock_runner_class): """Test run_tests.main() with --skip-cov flag.""" mock_runner = MagicMock() @@ -992,9 +992,9 @@ class TestRunTestsMain: False, False, False ) - @patch('run_tests.TestRunner') - @patch('run_tests.argparse') - @patch('run_tests.sys') + @patch('fiona.run_tests.TestRunner') + @patch('fiona.run_tests.argparse') + @patch('fiona.run_tests.sys') def test_main_specific_test(self, mock_sys, mock_argparse, mock_runner_class): """Test run_tests.main() with a specific test path.""" mock_runner = MagicMock() @@ -1034,8 +1034,8 @@ class TestRunTestsMain: 'src/tests/test_librarian.py', False, False, True ) - @patch('run_tests.TestRunner') - @patch('run_tests.argparse') + @patch('fiona.run_tests.TestRunner') + @patch('fiona.run_tests.argparse') def test_main_tests_fail(self, mock_argparse, mock_runner_class): """Test run_tests.main() when tests fail.""" mock_runner = MagicMock() diff --git a/src/tests/test_sanity_manager.py b/tests/test_sanity_manager.py similarity index 99% rename from src/tests/test_sanity_manager.py rename to tests/test_sanity_manager.py index 7dfa809..9ebf545 100644 --- a/src/tests/test_sanity_manager.py +++ b/tests/test_sanity_manager.py @@ -12,9 +12,9 @@ import re import pytest -import run_sanity -from wiki import sanity_manager -from wiki.sanity_manager import ( +import fiona.run_sanity as run_sanity +from fiona.wiki import sanity_manager +from fiona.wiki.sanity_manager import ( SANITY_CHECKS, format_sanity_report, run_wiki_checks, diff --git a/src/tests/test_sanity_runner.py b/tests/test_sanity_runner.py similarity index 98% rename from src/tests/test_sanity_runner.py rename to tests/test_sanity_runner.py index e58dae7..2f80557 100644 --- a/src/tests/test_sanity_runner.py +++ b/tests/test_sanity_runner.py @@ -11,7 +11,7 @@ from __future__ import annotations import logging import time -from sanity_runner import SanityRunner, format_duration +from fiona.sanity_runner import SanityRunner, format_duration # ============================================================================= # Execution Tests @@ -117,7 +117,7 @@ class TestRunAllCallbacks: def test_lifecycle_logged_at_info(self, caplog): runner = SanityRunner(checks=[("a", lambda: {"result": 0})]) - with caplog.at_level(logging.INFO, logger="sanity_runner.sanity_runner"): + with caplog.at_level(logging.INFO, logger="fiona.sanity_runner.sanity_runner"): runner.run_all() messages = [record.message for record in caplog.records] diff --git a/src/tests/test_toc_generator.py b/tests/test_toc_generator.py similarity index 99% rename from src/tests/test_toc_generator.py rename to tests/test_toc_generator.py index 4da5ba1..02f1883 100644 --- a/src/tests/test_toc_generator.py +++ b/tests/test_toc_generator.py @@ -13,8 +13,8 @@ import tempfile import pytest -from librarian import toc_generator -from librarian.toc_generator import ( +from fiona.librarian import toc_generator +from fiona.librarian.toc_generator import ( FILE_TOC_END, FILE_TOC_START, TOC_NAME, @@ -1434,7 +1434,7 @@ class TestFolderTocValidation: original_argv = sys.argv try: monkeypatch.setenv("LOG_LEVEL", "DEBUG") - with caplog.at_level(logging.DEBUG, logger="librarian"): + with caplog.at_level(logging.DEBUG, logger="fiona.librarian"): sys.argv = ["toc_generator", str(tmp_path)] main() finally: @@ -1454,7 +1454,7 @@ class TestFileTocLogging: original_argv = sys.argv try: monkeypatch.setenv("LOG_LEVEL", "DEBUG") - with caplog.at_level(logging.DEBUG, logger="librarian"): + with caplog.at_level(logging.DEBUG, logger="fiona.librarian"): sys.argv = ["toc_generator", "file", str(doc)] main() finally: diff --git a/src/tests/test_update_manager.py b/tests/test_update_manager.py similarity index 99% rename from src/tests/test_update_manager.py rename to tests/test_update_manager.py index c7e6b1e..2cb0a54 100644 --- a/src/tests/test_update_manager.py +++ b/tests/test_update_manager.py @@ -21,7 +21,7 @@ from unittest.mock import patch import pytest -from wiki.update_manager import ( +from fiona.wiki.update_manager import ( CORE_DIRECTORIES, CORE_FILES, READ_ONLY_ZONES, @@ -298,7 +298,9 @@ class TestGetLlmWikiSourcePath: """Test that the path exists or the fallback exists.""" result = get_llm_wiki_source_path() # Either the direct path or the fallback should exist - assert result.exists() or (result.parent.parent / "llm-wiki").exists() + assert result.is_dir() + assert result.name == "llm_wiki" + assert (result / "AGENTS.md").is_file() # ============================================================================= @@ -438,7 +440,7 @@ class TestCheckWikiUpdates: with pytest.raises(NotADirectoryError): check_wiki_updates(str(non_wiki_dir)) - @patch("wiki.update_manager.get_llm_wiki_source_path") + @patch("fiona.wiki.update_manager.get_llm_wiki_source_path") def test_check_template_not_found(self, mock_get_source, tmp_path): """Test checking when template directory is not found.""" # Create a valid wiki directory @@ -586,7 +588,7 @@ class TestUpdateMain: temp_wiki_dir / "fiona-settings.json", template / "fiona-settings.json" ) monkeypatch.setattr( - "wiki.update_manager.get_llm_wiki_source_path", lambda: template + "fiona.wiki.update_manager.get_llm_wiki_source_path", lambda: template ) result = update_main(directory=str(temp_wiki_dir)) @@ -631,7 +633,7 @@ class TestUpdateMain: assert result == 1 - @patch("wiki.update_manager.update_core_files") + @patch("fiona.wiki.update_manager.update_core_files") def test_update_main_runtime_error(self, mock_update, tmp_path): """Test update main when RuntimeError is raised.""" # Create a valid wiki directory @@ -723,7 +725,7 @@ def template_wiki_pair(tmp_path, monkeypatch): template = _build_template(tmp_path / "template") wiki = _build_wiki_from_template(template, tmp_path / "wiki") monkeypatch.setattr( - "wiki.update_manager.get_llm_wiki_source_path", lambda: template + "fiona.wiki.update_manager.get_llm_wiki_source_path", lambda: template ) return template, wiki diff --git a/src/tests/test_wiki.py b/tests/test_wiki.py similarity index 97% rename from src/tests/test_wiki.py rename to tests/test_wiki.py index 9cc39ea..6e4efa4 100644 --- a/src/tests/test_wiki.py +++ b/tests/test_wiki.py @@ -9,7 +9,7 @@ from pathlib import Path import git import pytest -from wiki.wiki import ( +from fiona.wiki.wiki import ( copy_directory_tree, get_ignore_patterns, get_llm_wiki_source_path, @@ -134,7 +134,7 @@ def test_wiki_init_skips_ignored_files(tmp_path, monkeypatch): "fiona": {"llm-wiki": {"ignore_files": ["utils/example.py"]}} }), encoding="utf-8") monkeypatch.setattr( - "wiki.wiki.get_llm_wiki_source_path", lambda: template + "fiona.wiki.wiki.get_llm_wiki_source_path", lambda: template ) wiki_init(str(tmp_path / "wiki")) @@ -247,7 +247,7 @@ def test_wiki_init_rerun_does_not_clobber_user_content(tmp_path): def test_wiki_init_missing_template_raises(tmp_path, monkeypatch): """Test wiki_init reports a missing template directory.""" monkeypatch.setattr( - "wiki.wiki.get_llm_wiki_source_path", lambda: tmp_path / "no-template" + "fiona.wiki.wiki.get_llm_wiki_source_path", lambda: tmp_path / "no-template" ) with pytest.raises(FileNotFoundError): wiki_init(str(tmp_path)) diff --git a/todo.md b/todo.md index 473a772..da0a95e 100644 --- a/todo.md +++ b/todo.md @@ -2,6 +2,7 @@ - [Done](#done) - [P0 — Packaging and Structure Fixes](#p0--packaging-and-structure-fixes) +- [Code defects — 2026-09-29 audit](#code-defects--2026-09-29-audit) - [P1 — Wiki Lifecycle and Version Control](#p1--wiki-lifecycle-and-version-control) - [P2 — Quality Tooling](#p2--quality-tooling) - [P3 — Metadata, Backup, and Documentation](#p3--metadata-backup-and-documentation) @@ -78,7 +79,7 @@ the docs contradict the code. - [x] pytests should show which test are failing, - [x] markdownlint should show which files are in violation , what line - [x] same thing for ruff -- [ ] Remove the phantom `html_js_lint` package and `html-js-lint` console +- [x] Remove the phantom `html_js_lint` package and `html-js-lint` console script from `pyproject.toml` until SPEC 7.17 is implemented. The directory `src/html_js_lint/` does not exist. Detail is item 2 in the 2026-09-29 audit below @@ -110,146 +111,243 @@ as extra entry points that call into those submodules. Do this as one change set: import paths, tests, entry points, and docs move together. Half-moving a package leaves both layouts on `sys.path`. -- [ ] Collapse the nine top-level packages into `fiona` subpackages - - [ ] Current install names, from `packages.find` `include` and from +- [x] Collapse the nine top-level packages into `fiona` subpackages. + Imports, `pyproject.toml`, tests, and docs moved with the directories. + - [x] Current install names, from `packages.find` `include` and from `src/fiona_assistant.egg-info/top_level.txt`: `customlinter`, `fiona`, `gittool`, `librarian`, `llm-wiki`, `mdoctor`, `python_ruff`, `sanity_runner`, `wiki` - - [ ] `fiona/__main__.py` imports them as top-level modules + - [x] `fiona/__main__.py` imports them as top-level modules (`from librarian.librarian import main`, `from wiki.wiki import wiki_init`, and the same for `customlinter`, `gittool`, `mdoctor`, `python_ruff`) - - [ ] Same-name module pattern to preserve while moving: + - [x] Same-name module pattern to preserve while moving: `librarian/librarian.py`, `mdoctor/mdoctor.py`, `python_ruff/python_ruff.py`, `sanity_runner/sanity_runner.py`. `gittool` is the odd one: the module is `git_tool.py` - - [ ] `wiki` is a generic top-level name and will collide with any + - [x] `wiki` is a generic top-level name and will collide with any other installed project that also ships a `wiki` package - - [ ] After the move, `packages.find` `include` should list `fiona` + - [x] After the move, `packages.find` `include` should list `fiona` only. An allow-list is how `python_ruff` was shipped late and how `html_js_lint` stayed declared after the directory vanished -- [ ] Remove the phantom `html_js_lint` declaration (same checkbox as +- [x] Remove the phantom `html_js_lint` declaration (same checkbox as the item above this section) - - [ ] `[project.scripts]` maps `html-js-lint` to + - [x] `[project.scripts]` maps `html-js-lint` to `html_js_lint.html_js_lint:main` - - [ ] `packages.find` `include` lists `html_js_lint` - - [ ] `src/fiona_assistant.egg-info/entry_points.txt` still has that + - [x] `packages.find` `include` lists `html_js_lint` + - [x] `src/fiona_assistant.egg-info/entry_points.txt` still has that script from the last editable install - - [ ] `src/html_js_lint/` does not exist. Invoking `html-js-lint` + - [x] `src/html_js_lint/` does not exist. Invoking `html-js-lint` fails at import. SPEC 7.17 is the future feature; the entry point should not ship until that directory exists - - [ ] `html5validator` is in runtime `dependencies` and is not + - [x] `html5validator` is in runtime `dependencies` and is not imported anywhere under `src/`. Drop it with the phantom script, or keep it only when SPEC 7.17 lands -- [ ] Delete `src/__init__.py` - - [ ] The file's only content is the comment `# Fiona tools package` - - [ ] An `__init__.py` in `src/` makes `src` itself a package whenever +- [x] Delete `src/__init__.py` + - [x] The file's only content is the comment `# Fiona tools package` + - [x] An `__init__.py` in `src/` makes `src` itself a package whenever the repo root is on `sys.path`. The src layout exists so packages are importable only after install - - [ ] That is why bytecode for `run_sanity.py` and `run_tests.py` + - [x] That is why bytecode for `run_sanity.py` and `run_tests.py` lands in `src/__pycache__/` (`run_sanity.cpython-313.pyc`, `run_tests.cpython-313.pyc`, `__init__.cpython-313.pyc`) -- [ ] Stop tests from editing `sys.path` - - [ ] `src/tests/conftest.py` does +- [x] Stop tests from editing `sys.path` + - [x] `src/tests/conftest.py` does `sys.path.insert(0, os.path.dirname(os.path.dirname(...)))`, which puts `src/` on the path, then imports `librarian`, `mdoctor`, `python_ruff`, and `wiki` as top-level names - - [ ] `src/tests/__init__.py` exists, so `tests` is a package sitting + - [x] `src/tests/__init__.py` exists, so `tests` is a package sitting inside the source root. Standard layout is a repo-root `tests/` directory that is not installed - - [ ] `[tool.pytest.ini_options]` sets `testpaths = ["src/tests"]` and + - [x] `[tool.pytest.ini_options]` sets `testpaths = ["src/tests"]` and has no `pythonpath`. Coverage `source = ["src"]` treats the mixed script-and-package directory as the measured tree - - [ ] Replacement: `pip install -e .` in the dev env, or + - [x] Replacement: `pip install -e .` in the dev env, or `pythonpath = ["src"]` once there is a single `fiona` package. The path edit hides "package not installed" failures - - [ ] The 2026-09-27 conftest consolidation (outer `src/conftest.py` + - [x] The 2026-09-27 conftest consolidation (outer `src/conftest.py` removed) stays valid. This item replaces the remaining `sys.path` bootstrap, it does not undo that merge -- [ ] Decide where the loose `src/` files live - - [ ] `src/run_sanity.py` and `src/run_tests.py` are modules, not +- [x] Decide where the loose `src/` files live + - [x] `src/run_sanity.py` and `src/run_tests.py` are modules, not packages. They are absent from `packages.find`, so a wheel does not install them. They are how this repo runs its own sanity and tests (`python src/run_sanity.py`) - - [ ] `src/install_packages.sh`, `src/utils.sh`, and + - [x] `src/install_packages.sh`, `src/utils.sh`, and `src/settings_dev.json` sit in the same directory. Dev config and shell helpers are not package source - - [ ] Either give `run_sanity` / `run_tests` real entry points under + - [x] Either give `run_sanity` / `run_tests` real entry points under `fiona`, or move them to a repo-root `scripts/` (or `tools/`) directory that is not on the package path -- [ ] Replace the hyphenated `llm-wiki` package with package data - - [ ] `import llm-wiki` is a `SyntaxError`. `src/llm-wiki/__init__.py` +- [x] Replace the hyphenated `llm-wiki` package with package data + - [x] `import llm-wiki` is a `SyntaxError`. `src/llm-wiki/__init__.py` exists only so setuptools detects the directory. The `pyproject.toml` comment already documents that hack - - [ ] `[tool.setuptools.package-data]` maps `"llm-wiki" = ["*", "**/*"]` - - [ ] `src/llm-wiki/__init__.py` sets `__version__ = "0.1.0"` while + - [x] `[tool.setuptools.package-data]` maps `"llm-wiki" = ["*", "**/*"]` + - [x] `src/llm-wiki/__init__.py` sets `__version__ = "0.1.0"` while `[project]` `version` is `0.36.0`. Two versions for one distribution - - [ ] Move the template tree to something importable, for example + - [x] Move the template tree to something importable, for example `src/fiona/data/llm_wiki/`, and load files with `importlib.resources`. Update `wiki init` / `wiki update` path helpers (`get_llm_wiki_source_path`) in the same change - - [ ] Root `README.md` links `./llm-wiki/AGENTS.md`. The file is + - [x] Root `README.md` links `./llm-wiki/AGENTS.md`. The file is `src/llm-wiki/AGENTS.md` -- [ ] Get setuptools metadata out of `src/` - - [ ] `src/fiona_assistant.egg-info/` holds `PKG-INFO`, +- [x] Get setuptools metadata out of `src/` + - [x] `src/fiona_assistant.egg-info/` holds `PKG-INFO`, `entry_points.txt`, `requires.txt`, `SOURCES.txt`, `top_level.txt`. That is install metadata. It belongs at the repo root (or nowhere, if it is only a local editable-install artifact) - - [ ] `.gitignore` already ignores `*.egg-info/`, so this directory + - [x] `.gitignore` already ignores `*.egg-info/`, so this directory should not be committed, but `where = ["src"]` can still see it during package discovery - - [ ] The egg name `fiona_assistant` is the setuptools normalization + - [x] The egg name `fiona_assistant` is the setuptools normalization of project name `fiona-assistant`. Leave the normalization alone; only the directory location is wrong -- [ ] Keep a single coverage config, and point it at the code that exists - - [ ] Both `.coveragerc` and `[tool.coverage]` in `pyproject.toml` +- [x] Keep a single coverage config, and point it at the code that exists + - [x] Both `.coveragerc` and `[tool.coverage]` in `pyproject.toml` exist. Coverage reads `.coveragerc` first, so the pyproject block is unused - - [ ] `.coveragerc` still omits `src/mdoctor/fmlint.py` and + - [x] `.coveragerc` still omits `src/mdoctor/fmlint.py` and `src/python_ruff/pycustomlint.py`. Those modules live under `src/customlinter/` (`fmlint.py`, `pycustomlint.py`) - - [ ] Both files share the same `exclude_lines` list. After deleting + - [x] Both files share the same `exclude_lines` list. After deleting `.coveragerc`, confirm `pytest --cov` still honors the pyproject `source`, `omit`, and `exclude_lines` - - [ ] `coverage.xml` at the repo root is a generated report. It is + - [x] `coverage.xml` at the repo root is a generated report. It is not matched by `.gitignore` (`*.log` and `.coverage` are; `coverage.xml` is not) -- [ ] Raise the setuptools build pin so `[project]` is valid - - [ ] `[build-system]` `requires` is `setuptools>=42` - - [ ] The `[project]` table (PEP 621) needs setuptools 61 or newer. +- [x] Raise the setuptools build pin so `[project]` is valid + - [x] `[build-system]` `requires` is `setuptools>=42` + - [x] The `[project]` table (PEP 621) needs setuptools 61 or newer. An older setuptools that satisfies `>=42` can fail the build - - [ ] Set `requires = ["setuptools>=61"]` (or a current floor) and + - [x] Set `requires = ["setuptools>=61"]` (or a current floor) and rebuild the wheel -- [ ] Sort runtime dependencies from repo-only tools - - [ ] `ruff` is imported by `src/python_ruff/python_ruff.py`, so it +- [x] Sort runtime dependencies from repo-only tools + - [x] `ruff` is imported by `src/python_ruff/python_ruff.py`, so it stays in `dependencies` - - [ ] `pylint` is in `dependencies` with no version pin, and nothing + - [x] `pylint` is in `dependencies` with no version pin, and nothing under `src/` imports it. Move it to the `dev` extra or drop it - - [ ] There is no `[tool.ruff]` table and no `ruff.toml`. If this + - [x] There is no `[tool.ruff]` table and no `ruff.toml`. If this repo is linted with Ruff, the rule set belongs in `pyproject.toml` - - [ ] `requires-python` is `>=3.8`. Local bytecode in + - [x] `requires-python` is `>=3.8`. Local bytecode in `src/__pycache__/` is CPython 3.13. Classifiers only say `Programming Language :: Python :: 3`. The bootstrap examples use 3.11. Record the versions this repo actually runs, and confirm syntax such as `str | None` is either covered by `from __future__ import annotations` or by a higher `requires-python` -- [ ] Make the structure docs match the tree (also listed under P3) - - [ ] `src/README.md` "Project Structure" lists only `fiona/`, +- [x] Make the structure docs match the tree (also listed under P3) + - [x] `src/README.md` "Project Structure" lists only `fiona/`, `librarian/`, `mdoctor/`, `tests/`, and `README.md`. Missing from that diagram: `customlinter/`, `python_ruff/`, `gittool/`, `sanity_runner/`, `wiki/`, `llm-wiki/`, `run_sanity.py`, `run_tests.py`, `settings_dev.json`, `utils.sh`, `install_packages.sh` - - [ ] MDoctor's description in that file is still + - [x] MDoctor's description in that file is still `[Description to be added]`, and Contributing is still `[Contribution guidelines to be added]` - - [ ] Refresh this diagram again after the package collapse, so the + - [x] Refresh this diagram again after the package collapse, so the docs describe `src/fiona/` rather than today's sibling packages +## Code defects — 2026-09-29 audit + +Source review after the package directories moved under `src/fiona/`. +`src/` on disk is `fiona/` plus `README.md`. Tests live in `tests/`. +The template lives in `src/fiona/data/llm_wiki/`. The package-move +items below are done. The command defects after them are still open. + +### Finish the package move + +- [x] Point every import at `fiona.` + - [x] `src/fiona/__main__.py` still imports top-level `librarian`, + `mdoctor`, `customlinter`, `python_ruff`, `gittool`, and + `wiki`. Those packages are `src/fiona//`. + - [x] `tests/test_fiona_main.py` still does + `from librarian import toc_generator`. + - [x] `TOOL_LOGGER_NAMES` in `src/fiona/logging_config.py` still + lists `librarian`, `mdoctor`, `python_ruff`, and `wiki`. + Loggers are now `fiona.*` via `getLogger(__name__)`. The + parent name `fiona` already covers them; drop the stale names. +- [x] Point template and settings paths at `fiona/data/llm_wiki` + - [x] `get_llm_wiki_source_path` in `src/fiona/wiki/wiki.py` and + `src/fiona/wiki/update_manager.py` looks for a sibling + `llm-wiki` (`src/fiona/llm-wiki`). The template is + `src/fiona/data/llm_wiki/`. `wiki init` and `wiki update` + miss it. Load it with `importlib.resources` (same end state + as the P0 llm-wiki package-data item). + - [x] The default settings path in `logging_config.py`, + `customlinter/base.py`, `mdoctor/mdoctor.py`, and + `librarian/toc_generator.py` is + `parent.parent / "llm-wiki" / "fiona-settings.json"`, which + is `src/llm-wiki/...`. The file is + `src/fiona/data/llm_wiki/fiona-settings.json`. + - [x] `src/fiona/run_sanity.py` still lints `./src/llm-wiki` for + frontmatter. Point it at `src/fiona/data/llm_wiki`. +- [x] Match packaging and the test runner to the new tree + - [x] `pyproject.toml` `packages.find` `include` and + `[project.scripts]` still name `librarian`, `mdoctor`, + `python_ruff`, `customlinter`, `sanity_runner`, `llm-wiki`, + `wiki`, `gittool`, and `html_js_lint`. `librarian` and + `mdoctor` console scripts import modules that are no longer + top-level. + - [x] `include = ["fiona"]` does not match subpackages. Use + `fiona*` so `fiona.wiki` and the rest are installed. + - [x] `[tool.pytest.ini_options]` `testpaths` is still + `src/tests`. The suite is `tests/`. + - [x] `tests/conftest.py` walks two directories up and inserts the + repo root. That math used to reach `src/` when the file lived + at `src/tests/conftest.py`. Insert `src/` so + `import fiona` works without an editable install. + - [x] `src/__init__.py` is already gone. Leave it gone. + - [x] `run_tests.py` and `run_sanity.py` already sit in + `src/fiona/`. Give them entry points or document + `python -m fiona.run_tests` / `python -m fiona.run_sanity` + in place of `python src/run_tests.py` (SPEC 4.13). + +### Fixes in commands the spec already calls Implemented + +- [ ] `json-lint fix` walks the file list twice (SPEC appendix, + SPEC 4.6). The second `fix_file` pass finds the files already + clean, so the path lines never print. Walk once: one count and + one path line per fixed file. +- [ ] `json-lint chklint --fix` is parsed and ignored + (`src/fiona/customlinter/jsonlint.py`). SPEC 4.6 says + `chklint --fix` rewrites the same way `fix` does. +- [ ] `json-lint fix` treats any path part named `personal` or `raw` + as a read-only zone, including a folder outside the wiki. + Skip with the wiki-relative check in `BaseLinter` + (`src/fiona/customlinter/base.py`), the same rule as `chklint`. +- [ ] `git` failures print `Error:` on stdout and catch `Exception` + (`src/fiona/gittool/git_tool.py`). SPEC 4.7 and section 2: the + message goes to stderr. Catch the errors `GitTool` raises. + This is the concrete case of the P2 logging item. +- [ ] `wiki graph` prints `Error: Directory not found` on stdout + (`src/fiona/wiki/graph_generator.py`). The other graph errors + use stderr. SPEC section 4: an invalid directory is stderr + and exit 1. +- [ ] `wiki graph` replaces `--wikilinks` / `--no-wikilinks` and + `--external-links` with `fiona.wiki.graph` settings after the + CLI has set them (`load_graph_settings` in + `wiki_graph_main`). An explicit flag wins. Settings fill the + defaults only (SPEC 4.12). +- [ ] `wiki graph` drops files above `max_files` with a log line + only. Print the kept count and the limit on stderr. +- [ ] `mdoctor fix` rewrites `personal/` and `raw/` (SPEC 4.3, + appendix). Constraint 1.2.3 says those zones are read-only for + every automated tool. Skip them in `fix_file_programmatically`, + then change SPEC 4.3 to say the command skips those zones. +- [ ] `graph_generator.py` logs with f-strings. Use lazy `%` + formatting, the same style as `logging_config.py`. +- [ ] `fiona-assistant python-ruff` has an empty help string and a + `#TODO` in `src/fiona/__main__.py`. Use a one-line help like + the other linters. +- [ ] `fiona.__main__` rewrites `sys.argv` and calls each tool + `main()`, which parses the arguments a second time. Call the + library functions directly so each command is parsed once. + ## P1 — Wiki Lifecycle and Version Control - [x] `wiki init` hardening (SPEC 7.1) @@ -327,6 +425,15 @@ Half-moving a package leaves both layouts on `sys.path`. - [ ] Error and warning diagnostics go to stderr through logging. CLI reports stay stdout prints. `git_tool`, `graph_generator`, and several CLIs still `print` errors +- [ ] Enable every Ruff rule (`select = ["ALL"]` in `pyproject.toml`) + - [ ] The table under `[tool.ruff]` currently leaves Ruff on its + built-in default. That skips style, docstrings, line length, + pyupgrade, and other families + - [ ] Turn on `ALL`, then clear the findings on `src/` or add an + explicit `ignore` only where a rule fights the spec (CLI + `print` on stdout is one) + - [ ] Keep `test_lint_detects_unused_import` green. It must find + unused-import `F401` even when another rule is reported first - [x] Clear existing lint violations (SPEC 1 constraint: Ruff and PyMarkdown must pass) - [x] Ruff: 0 violations — removed unused imports and unnecessary