update themes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: Fiona-Assistant Specification
|
||||
version: 0.90.1
|
||||
version: 0.91.1
|
||||
title: Project Spec Sheet
|
||||
created: 2026-09-23
|
||||
updated: 2026-09-30
|
||||
@@ -295,14 +295,28 @@ Read-only zones, including the zone directory itself:
|
||||
- `personal/`
|
||||
- `raw/`
|
||||
|
||||
`wiki/` is copied by `wiki init` and then left to the LLM.
|
||||
`wiki update` does not add, replace, or report any path under
|
||||
`wiki/`.
|
||||
|
||||
`wiki update` adds missing core files and directories. It never
|
||||
deletes user files. It never writes inside a read-only zone, so a
|
||||
missing file under `personal/` or `raw/` is not added back.
|
||||
missing file under `personal/` or `raw/` is not added back. It
|
||||
never writes a path matched by the repository `.gitignore` or by
|
||||
the wiki's own `.gitignore`.
|
||||
|
||||
After the copy, `wiki init` creates a git repository, writes
|
||||
`.gitignore` containing a comment line and `personal/`, stages
|
||||
everything, and commits `Initial llm-wiki commit`. If git init
|
||||
fails, the copy still counts as success and stdout adds
|
||||
After the copy, `wiki init` creates a git repository and writes
|
||||
`.gitignore`. A new file starts with the fiona-assistant repository
|
||||
`.gitignore` (the same patterns, including `__pycache__/`, `*.pyc`,
|
||||
and `*fiona.log`). When this package is not the source checkout,
|
||||
that text is the packaged `default.gitignore`. The file adds
|
||||
`personal/` when that pattern is missing.
|
||||
An existing `.gitignore` keeps every line it already has; missing
|
||||
patterns from that set are appended. Init then stages everything
|
||||
and commits `Initial llm-wiki commit`. Template paths that match
|
||||
the repository `.gitignore` are not copied. `personal/` and `raw/`
|
||||
are still copied. `personal/` stays untracked. If git init fails,
|
||||
the copy still counts as success and stdout adds
|
||||
`Note: Git repository initialization failed: <error>`.
|
||||
|
||||
- *3.2.1.* An empty directory becomes the tree above, with dates
|
||||
@@ -888,7 +902,7 @@ a dark stroke so the pale end still stands off the canvas. Its
|
||||
`dark` object is a gray night on a charcoal field, not black.
|
||||
Sparse nodes stay medium gray. A mid link count is white-yellow.
|
||||
Many incoming links are a light yellow-orange. `dark` is a blue-slate night. Nodes
|
||||
run from slate through silver to white. The page and the canvas
|
||||
run from slate through white-yellow to a light gold. The page and the canvas
|
||||
stay blue-gray, not black. `professional` is a light boardroom
|
||||
palette: pale blue nodes, a soft blue stroke, light blue
|
||||
buttons, and a quiet radius.
|
||||
@@ -1161,14 +1175,22 @@ value does not hide the earlier key.
|
||||
|
||||
Implements sections 3 and 4.8.
|
||||
|
||||
- *7.1.1.* Copy is 1:1 aside from `DATE_PLACEHOLDER` and
|
||||
`ignore_files`.
|
||||
- *7.1.1.* Copy is 1:1 aside from `DATE_PLACEHOLDER`,
|
||||
`ignore_files`, and paths matched by the repository `.gitignore`.
|
||||
- *acceptance*: A pattern in `ignore_files` omits those paths and
|
||||
copies every other template file.
|
||||
- *acceptance*: A template file matched by the repository
|
||||
`.gitignore` is not copied.
|
||||
- *7.1.2.* Copied markdown keeps `version` and receives
|
||||
`created` / `updated` dates where the template used the placeholder.
|
||||
- *acceptance*: After init, those fields match `YYYY-MM-DD` for
|
||||
the UTC day of the run.
|
||||
- *7.1.3.* `wiki init` puts or appends `.gitignore` from the
|
||||
repository `.gitignore`, plus `personal/` when that pattern is
|
||||
missing. Lines already in the file stay.
|
||||
- *acceptance*: After init, `.gitignore` contains `__pycache__/`
|
||||
and `personal/`. A line `keep-me` written before init is still
|
||||
in the file.
|
||||
|
||||
### 7.2. wiki update
|
||||
|
||||
@@ -1190,9 +1212,10 @@ Implements sections 4.9 and 4.10.
|
||||
- *7.2.3.* `fiona-settings.json` uses the hash comparison to decide
|
||||
that an update is needed, then writes the deep merge from
|
||||
section 5.1.
|
||||
- *7.2.4.* Missing template directories are created. User files that
|
||||
are not in the template stay. Read-only zones are never in the
|
||||
update set.
|
||||
- *7.2.4.* Missing template directories outside `wiki/` and outside
|
||||
read-only zones are created when they hold a file that update may
|
||||
add. User files that are not in the template stay. Read-only zones
|
||||
are never in the update set.
|
||||
- *7.2.5.* A pristine init reports `Wiki is up to date.` and
|
||||
`wiki update` writes nothing.
|
||||
- *acceptance*: A second check-update still reports up to date.
|
||||
@@ -1207,6 +1230,23 @@ Implements sections 4.9 and 4.10.
|
||||
non-TTY.
|
||||
- *acceptance*: The command exits 0 on a pipe when `--yes` is set
|
||||
and updates exist.
|
||||
- *7.2.9.* Every path under `wiki/` stays out of the update set.
|
||||
Update does not list it as a change, an addition, a skipped file,
|
||||
or a directory to add, and it does not write it.
|
||||
- *acceptance*: A `wiki/index.md` older than the template is absent
|
||||
from the check-update report, and its bytes are unchanged after
|
||||
`wiki update --yes`.
|
||||
- *7.2.10.* Update skips a path matched by the repository
|
||||
`.gitignore` or by the wiki's `.gitignore`. Comment lines and
|
||||
blank lines are not patterns. A pattern with no slash matches any
|
||||
path segment. A pattern that ends with `/` matches that directory
|
||||
and everything under it.
|
||||
- *acceptance*: A template file
|
||||
`utils/scripts/__pycache__/example.pyc` is absent from the
|
||||
check-update report.
|
||||
- *acceptance*: When the wiki `.gitignore` lists `example.py`, a
|
||||
drifted `utils/scripts/example.py` is left unchanged and is
|
||||
absent from the report.
|
||||
|
||||
### 7.3. wiki sanity
|
||||
|
||||
@@ -1635,9 +1675,10 @@ used.
|
||||
|
||||
> Status: Implemented
|
||||
|
||||
Implements section 4.7. `personal/` is listed in `.gitignore` at
|
||||
`wiki init` and is never staged by these commands except where
|
||||
`git add --all` respects that ignore file.
|
||||
Implements section 4.7. `wiki init` writes the repository
|
||||
`.gitignore` patterns and `personal/` (section 7.1). Those paths
|
||||
are never staged by these commands except where `git add --all`
|
||||
respects that ignore file.
|
||||
|
||||
- *7.5.1.* `save --description note` on a dirty tree creates one
|
||||
commit whose message starts with the UTC timestamp and ends with
|
||||
@@ -2227,6 +2268,7 @@ These notes are not requirements. They point at the current tree.
|
||||
| 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 gitignore | `src/fiona/wiki/ignore.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`, `src/fiona/wiki/templates/graph_physics.js` |
|
||||
|
||||
@@ -47,6 +47,7 @@ include = ["fiona*"]
|
||||
[tool.setuptools.package-data]
|
||||
fiona = [
|
||||
"data/llm_wiki/**/*",
|
||||
"data/default.gitignore",
|
||||
"wiki/templates/*",
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# Virtual environments
|
||||
.venv/
|
||||
.venvs/
|
||||
venv/
|
||||
env/
|
||||
ENV/
|
||||
|
||||
# IDE-specific files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# Local configuration
|
||||
.env
|
||||
*.local
|
||||
|
||||
# Build artifacts
|
||||
build/
|
||||
dist/
|
||||
*.egg-info/
|
||||
|
||||
# Logs and databases
|
||||
*.log
|
||||
*.sqlite
|
||||
*.db
|
||||
|
||||
# pytest
|
||||
.pytest_cache/
|
||||
|
||||
# Coverage
|
||||
.coverage
|
||||
coverage.xml
|
||||
htmlcov/
|
||||
|
||||
# Jupyter Notebook checkpoints
|
||||
.ipynb_checkpoints/
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# Windows
|
||||
Thumbs.db
|
||||
|
||||
# Python
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
|
||||
*fiona.log
|
||||
*wiki_graph.html
|
||||
@@ -223,8 +223,8 @@
|
||||
"text_color": "#e7eef8",
|
||||
"node_colors": {
|
||||
"low": "#7d8da3",
|
||||
"mid": "#b7c6da",
|
||||
"high": "#f7fbff"
|
||||
"mid": "#fff4c4",
|
||||
"high": "#f7d67c"
|
||||
},
|
||||
"node_stroke": "none",
|
||||
"node_radius": {
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
},
|
||||
"wiki": {
|
||||
"graph": {
|
||||
"theme": "night-sky",
|
||||
"theme": "dark",
|
||||
"show_external_links": true,
|
||||
"subtitle": {
|
||||
"enabled": true
|
||||
|
||||
@@ -4,7 +4,7 @@ category: productivity
|
||||
description: Operate an llm-wiki with the fiona-assistant CLI.
|
||||
author: nvaldez
|
||||
license: MIT
|
||||
version: 1.3.0
|
||||
version: 1.4.0
|
||||
updated: 2026-09-30
|
||||
---
|
||||
|
||||
@@ -106,7 +106,10 @@ fiona-assistant wiki init [directory]
|
||||
|
||||
Copies the template, substitutes `DATE_PLACEHOLDER` with today's
|
||||
UTC date, creates a git repo, and commits `Initial llm-wiki commit`.
|
||||
`personal/` is gitignored.
|
||||
`.gitignore` starts from the fiona-assistant repository ignore
|
||||
file and includes `personal/`. An existing `.gitignore` keeps its
|
||||
lines; missing patterns are appended. Paths matched by that
|
||||
repository ignore file are not copied. `personal/` is gitignored.
|
||||
|
||||
Success stdout:
|
||||
|
||||
@@ -148,7 +151,9 @@ fiona-assistant wiki update [directory] [--dry-run] [-y|--yes] [-f|--force] [--j
|
||||
```
|
||||
|
||||
Updates drifted core files and adds missing ones. Never deletes
|
||||
user files. Never writes inside `personal/` or `raw/`.
|
||||
user files. Never writes inside `personal/` or `raw/`. Never
|
||||
writes anything under `wiki/` (seeded at init, then filled by the
|
||||
LLM). Never writes a path matched by `.gitignore`.
|
||||
|
||||
Run `--dry-run` first. It prints the plan, writes nothing, and
|
||||
exits 0. Without `--yes` or `--force` the command prompts. On a
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: log
|
||||
title: Wiki Log
|
||||
version: 1.2.9
|
||||
version: 1.2.10
|
||||
type: summary
|
||||
created: 2025-09-23
|
||||
updated: 2026-09-30
|
||||
@@ -83,3 +83,5 @@ Chronological tracking of all actions performed on the wiki.
|
||||
`contested`, and `contradictions`. Fiona skill v1.3.0 teaches
|
||||
how to set them. fmlint still enforces `name` and `version` only
|
||||
(SPEC 6.2.3, schema v1.3.0).
|
||||
- 2026-09-30 - Clarified that a markdown link is `[text](url)` in the
|
||||
schema conventions (schema v1.3.2).
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: llm-wiki-schema
|
||||
title: LLM Wiki Schema
|
||||
version: 1.3.0
|
||||
version: 1.3.2
|
||||
created: 2025-09-18
|
||||
updated: 2026-09-30
|
||||
type: summary
|
||||
@@ -26,7 +26,7 @@ Personal knowledge base and inventory management.
|
||||
`name`, `version`. Required on pages under `wiki/`: `confidence`,
|
||||
`llm`, `contested`, `contradictions`. Optional: `title`, `created`,
|
||||
`updated`, `type`, `tags`, `sources`.
|
||||
- Use `[[wikilinks]]` to link between pages (minimum 2 outbound links per page).
|
||||
- Use markdown links (`[text](url)`) to link between pages (minimum 2 outbound links per page).
|
||||
- When updating a page, always bump the `updated` date.
|
||||
- Every new page must be added to `index.md` under the correct section.
|
||||
- Every action must be appended to `log.md`.
|
||||
|
||||
@@ -13,6 +13,7 @@ import git
|
||||
from git.repo.base import Repo
|
||||
|
||||
from fiona.logging_config import setup_logging
|
||||
from fiona.wiki.ignore import ensure_wiki_gitignore
|
||||
|
||||
|
||||
class GitTool:
|
||||
@@ -272,9 +273,9 @@ class GitTool:
|
||||
|
||||
@staticmethod
|
||||
def init_wiki_repo(repo_path: str | pathlib.Path, initial_message: str = "Initial llm-wiki commit") -> git.Repo:
|
||||
"""Initialize a git repository for llm-wiki with .gitignore for personal/.
|
||||
"""Initialize a git repository for llm-wiki and seed .gitignore.
|
||||
|
||||
Creates a .gitignore file that excludes the personal/ directory,
|
||||
Puts or appends the repository ignore patterns plus ``personal/``,
|
||||
stages all files, and makes the initial commit.
|
||||
|
||||
Args:
|
||||
@@ -292,12 +293,9 @@ class GitTool:
|
||||
# Initialize the repo
|
||||
repo = GitTool.init_repo(repo_path)
|
||||
|
||||
# Create .gitignore to exclude personal/ directory
|
||||
gitignore_path = repo_path / ".gitignore"
|
||||
with open(gitignore_path, "w", encoding="utf-8") as f:
|
||||
f.write("# Exclude personal directory from git as per SPEC 7.5\n")
|
||||
f.write("personal/\n")
|
||||
|
||||
# CURSOR: 2026-09-30 - seed .gitignore from the repository ignore file.
|
||||
ensure_wiki_gitignore(repo_path)
|
||||
|
||||
# Add all files and make initial commit
|
||||
repo.git.add("--all")
|
||||
repo.index.commit(initial_message)
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
"""Wiki module for Fiona-Assistant.
|
||||
"""Wiki package for Fiona-Assistant.
|
||||
|
||||
This module provides functionality for initializing and managing llm-wiki directories.
|
||||
Submodules are imported directly. This package does not import them
|
||||
here, so git_tool can load wiki.ignore without a circular import.
|
||||
"""
|
||||
|
||||
from fiona.wiki.wiki import wiki_init
|
||||
|
||||
__all__ = ["wiki_init"]
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
"""Gitignore patterns shared by wiki init and wiki update.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - seed wiki ignores from the repository file.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import fnmatch
|
||||
import importlib.resources
|
||||
import pathlib
|
||||
|
||||
_PACKAGE_NAME = "fiona-assistant"
|
||||
_PERSONAL_PATTERN = "personal/"
|
||||
|
||||
|
||||
def gitignore_patterns_from_text(text: str) -> list[str]:
|
||||
"""Return ignore patterns from gitignore text.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - drop blanks and comments.
|
||||
|
||||
Args:
|
||||
text: Contents of a .gitignore file.
|
||||
|
||||
Returns:
|
||||
Patterns in file order, without comments or blank lines.
|
||||
"""
|
||||
patterns: list[str] = []
|
||||
for line in text.splitlines():
|
||||
stripped = line.strip()
|
||||
if stripped and not stripped.startswith("#"):
|
||||
patterns.append(stripped)
|
||||
return patterns
|
||||
|
||||
|
||||
def path_is_ignored(relpath: str, patterns: list[str]) -> bool:
|
||||
"""Return whether a relative posix path matches any gitignore pattern.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - match unanchored names and directory prefixes.
|
||||
|
||||
A pattern with no slash matches any path segment. A trailing slash matches
|
||||
a directory and everything under it. ``*`` does not cross a directory
|
||||
boundary because matching is done per segment.
|
||||
|
||||
Args:
|
||||
relpath: Path relative to the wiki or template root, posix form.
|
||||
patterns: Gitignore patterns.
|
||||
|
||||
Returns:
|
||||
True when one pattern matches.
|
||||
"""
|
||||
return any(_pattern_matches(relpath, pattern) for pattern in patterns)
|
||||
|
||||
|
||||
def _pattern_matches(relpath: str, pattern: str) -> bool:
|
||||
"""Return whether one gitignore pattern matches a relative posix path."""
|
||||
body = pattern.rstrip("/")
|
||||
if not body:
|
||||
return False
|
||||
parts = relpath.split("/")
|
||||
if "/" in body:
|
||||
prefixes = ["/".join(parts[:index]) for index in range(1, len(parts) + 1)]
|
||||
return any(fnmatch.fnmatchcase(prefix, body) for prefix in prefixes)
|
||||
return any(fnmatch.fnmatchcase(part, body) for part in parts)
|
||||
|
||||
|
||||
def repository_gitignore_path() -> pathlib.Path | None:
|
||||
"""Find the fiona-assistant repository .gitignore, if this tree has one.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - prefer the source checkout over package data.
|
||||
|
||||
Returns:
|
||||
Path to the repository .gitignore, or None when this install is not
|
||||
the source checkout.
|
||||
"""
|
||||
here = pathlib.Path(__file__).resolve()
|
||||
for parent in here.parents:
|
||||
project = parent / "pyproject.toml"
|
||||
gitignore = parent / ".gitignore"
|
||||
if not project.is_file() or not gitignore.is_file():
|
||||
continue
|
||||
text = project.read_text(encoding="utf-8")
|
||||
if f'name = "{_PACKAGE_NAME}"' in text:
|
||||
return gitignore
|
||||
return None
|
||||
|
||||
|
||||
def packaged_gitignore_path() -> pathlib.Path | None:
|
||||
"""Return the packaged copy of the repository .gitignore, if present.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - fallback for an installed wheel.
|
||||
|
||||
Returns:
|
||||
Path to ``fiona/data/default.gitignore``, or None when it is absent.
|
||||
"""
|
||||
resource = importlib.resources.files("fiona").joinpath("data", "default.gitignore")
|
||||
path = pathlib.Path(str(resource))
|
||||
if path.is_file():
|
||||
return path
|
||||
return None
|
||||
|
||||
|
||||
def repository_gitignore_text() -> str:
|
||||
"""Load the ignore file that seeds a wiki, as LF text.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - repository file, then packaged copy.
|
||||
|
||||
Returns:
|
||||
Ignore file text ending in a newline.
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: When neither the repository nor the packaged file exists.
|
||||
"""
|
||||
path = repository_gitignore_path() or packaged_gitignore_path()
|
||||
if path is None:
|
||||
raise FileNotFoundError("fiona-assistant repository .gitignore was not found")
|
||||
text = path.read_text(encoding="utf-8").replace("\r\n", "\n").replace("\r", "\n")
|
||||
if text and not text.endswith("\n"):
|
||||
text += "\n"
|
||||
return text
|
||||
|
||||
|
||||
def wiki_gitignore_patterns() -> list[str]:
|
||||
"""Return patterns written into a wiki, repository set plus personal/.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - personal/ stays untracked after init.
|
||||
|
||||
Returns:
|
||||
Ignore patterns in write order.
|
||||
"""
|
||||
patterns = gitignore_patterns_from_text(repository_gitignore_text())
|
||||
if _PERSONAL_PATTERN not in patterns:
|
||||
patterns.append(_PERSONAL_PATTERN)
|
||||
return patterns
|
||||
|
||||
|
||||
def wiki_gitignore_text() -> str:
|
||||
"""Return the full .gitignore body for a wiki that does not have one yet.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - repository text plus personal/ when missing.
|
||||
|
||||
Returns:
|
||||
File body ending in a newline.
|
||||
"""
|
||||
text = repository_gitignore_text()
|
||||
if _PERSONAL_PATTERN not in gitignore_patterns_from_text(text):
|
||||
text += f"{_PERSONAL_PATTERN}\n"
|
||||
return text
|
||||
|
||||
|
||||
def ensure_wiki_gitignore(directory: pathlib.Path) -> None:
|
||||
"""Create .gitignore or append patterns that are not already listed.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - put or append the repository ignores.
|
||||
|
||||
Args:
|
||||
directory: Wiki root that should contain .gitignore.
|
||||
"""
|
||||
target = directory / ".gitignore"
|
||||
desired = wiki_gitignore_patterns()
|
||||
if not target.exists():
|
||||
target.write_text(wiki_gitignore_text(), encoding="utf-8", newline="\n")
|
||||
return
|
||||
existing = target.read_text(encoding="utf-8").replace("\r\n", "\n").replace("\r", "\n")
|
||||
have = set(gitignore_patterns_from_text(existing))
|
||||
missing = [pattern for pattern in desired if pattern not in have]
|
||||
if not missing:
|
||||
return
|
||||
if existing and not existing.endswith("\n"):
|
||||
existing += "\n"
|
||||
existing += "\n".join(missing) + "\n"
|
||||
target.write_text(existing, encoding="utf-8", newline="\n")
|
||||
@@ -23,6 +23,11 @@ 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 fiona.paths import llm_wiki_template
|
||||
from fiona.wiki.ignore import (
|
||||
gitignore_patterns_from_text,
|
||||
path_is_ignored,
|
||||
repository_gitignore_text,
|
||||
)
|
||||
from fiona.wiki.wiki import _copy_file, get_ignore_patterns, replace_date_placeholders
|
||||
|
||||
# =============================================================================
|
||||
@@ -333,8 +338,8 @@ def compare_settings_file(file_path: Path, template_path: Path) -> FileCompariso
|
||||
def get_all_template_files(template_dir: Path) -> list[Path]:
|
||||
"""Get all files from the template directory recursively.
|
||||
|
||||
Honors the template's `fiona.llm-wiki.ignore_files` glob patterns,
|
||||
matching wiki init's copy behavior.
|
||||
Honors the template's `fiona.llm-wiki.ignore_files` glob patterns
|
||||
and the repository `.gitignore`, matching wiki init's copy behavior.
|
||||
|
||||
Args:
|
||||
template_dir: Path to the llm-wiki template directory.
|
||||
@@ -343,20 +348,50 @@ def get_all_template_files(template_dir: Path) -> list[Path]:
|
||||
list[Path]: All template file paths relative to the template root.
|
||||
"""
|
||||
ignore_patterns = get_ignore_patterns(template_dir)
|
||||
git_patterns = gitignore_patterns_from_text(repository_gitignore_text())
|
||||
files = []
|
||||
for item in sorted(template_dir.rglob("*")):
|
||||
if not item.is_file():
|
||||
continue
|
||||
relative = item.relative_to(template_dir)
|
||||
if any(
|
||||
path_matches(pattern, relative.as_posix())
|
||||
for pattern in ignore_patterns
|
||||
):
|
||||
relative_posix = relative.as_posix()
|
||||
if any(path_matches(pattern, relative_posix) for pattern in ignore_patterns):
|
||||
continue
|
||||
# CURSOR: byte-code caches and other repository-ignored paths are not updates.
|
||||
if path_is_ignored(relative_posix, git_patterns):
|
||||
continue
|
||||
files.append(relative)
|
||||
return files
|
||||
|
||||
|
||||
def _patterns_for_update(wiki_root: Path) -> list[str]:
|
||||
"""Return repository and wiki gitignore patterns for an update check.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - honor both ignore files during update.
|
||||
"""
|
||||
patterns = gitignore_patterns_from_text(repository_gitignore_text())
|
||||
gitignore = wiki_root / ".gitignore"
|
||||
if gitignore.is_file():
|
||||
patterns.extend(gitignore_patterns_from_text(gitignore.read_text(encoding="utf-8")))
|
||||
return patterns
|
||||
|
||||
|
||||
def _excluded_from_update(relative: Path, wiki_root: Path, patterns: list[str]) -> bool:
|
||||
"""Return whether update must leave this template-relative path alone.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - wiki/ is LLM-owned; gitignored paths stay.
|
||||
|
||||
Paths under ``wiki/`` are seeded only by wiki init. Read-only zones and
|
||||
gitignore matches are never written or reported.
|
||||
"""
|
||||
rel = relative.as_posix()
|
||||
if rel == "wiki" or rel.startswith("wiki/"):
|
||||
return True
|
||||
if is_read_only_file(wiki_root / relative, wiki_root):
|
||||
return True
|
||||
return path_is_ignored(rel, patterns)
|
||||
|
||||
|
||||
def find_missing_core_files(wiki_root: Path, template_dir: Path) -> list[Path]:
|
||||
"""Find core files that exist in template but are missing from the wiki.
|
||||
|
||||
@@ -371,11 +406,11 @@ def find_missing_core_files(wiki_root: Path, template_dir: Path) -> list[Path]:
|
||||
list[Path]: Paths (relative to the wiki root) for files to add.
|
||||
"""
|
||||
missing = []
|
||||
patterns = _patterns_for_update(wiki_root)
|
||||
for relative in get_all_template_files(template_dir):
|
||||
wiki_file = wiki_root / relative
|
||||
if is_read_only_file(wiki_file, wiki_root):
|
||||
if _excluded_from_update(relative, wiki_root, patterns):
|
||||
continue
|
||||
if not wiki_file.exists():
|
||||
if not (wiki_root / relative).exists():
|
||||
missing.append(relative)
|
||||
return missing
|
||||
|
||||
@@ -395,11 +430,12 @@ def find_missing_directories(wiki_root: Path, template_dir: Path) -> list[Path]:
|
||||
list[Path]: Missing directory paths relative to the wiki root.
|
||||
"""
|
||||
missing: set[Path] = set()
|
||||
patterns = _patterns_for_update(wiki_root)
|
||||
for relative in get_all_template_files(template_dir):
|
||||
for parent in relative.parents:
|
||||
if parent == Path("."):
|
||||
continue
|
||||
if is_read_only_file(wiki_root / parent, wiki_root):
|
||||
if _excluded_from_update(parent, wiki_root, patterns):
|
||||
continue
|
||||
if not (wiki_root / parent).exists():
|
||||
missing.add(parent)
|
||||
@@ -450,10 +486,11 @@ def check_wiki_updates(directory: str | Path = ".") -> UpdateSummary:
|
||||
raise FileNotFoundError(f"Template directory not found: {template_dir}")
|
||||
|
||||
summary = UpdateSummary()
|
||||
patterns = _patterns_for_update(wiki_root)
|
||||
|
||||
for relative in get_all_template_files(template_dir):
|
||||
wiki_file = wiki_root / relative
|
||||
if is_read_only_file(wiki_file, wiki_root):
|
||||
if _excluded_from_update(relative, wiki_root, patterns):
|
||||
continue
|
||||
|
||||
template_file = template_dir / relative
|
||||
|
||||
+14
-3
@@ -17,6 +17,11 @@ from fiona.gittool.git_tool import GitTool
|
||||
from fiona.librarian.toc_generator import path_matches
|
||||
from fiona.logging_config import load_settings
|
||||
from fiona.paths import llm_wiki_template
|
||||
from fiona.wiki.ignore import (
|
||||
gitignore_patterns_from_text,
|
||||
path_is_ignored,
|
||||
repository_gitignore_text,
|
||||
)
|
||||
|
||||
|
||||
def get_llm_wiki_source_path() -> Path:
|
||||
@@ -80,21 +85,27 @@ def copy_directory_tree(source: Path, destination: Path,
|
||||
raise FileNotFoundError(f"Source directory does not exist: {source}")
|
||||
|
||||
destination.mkdir(parents=True, exist_ok=True)
|
||||
_copy_children(source, destination, source, tuple(ignore_patterns))
|
||||
git_patterns = tuple(gitignore_patterns_from_text(repository_gitignore_text()))
|
||||
_copy_children(source, destination, source, tuple(ignore_patterns), git_patterns)
|
||||
|
||||
|
||||
def _copy_children(source: Path, destination: Path, template_root: Path,
|
||||
ignore_patterns: tuple[str, ...]) -> None:
|
||||
ignore_patterns: tuple[str, ...],
|
||||
git_patterns: tuple[str, ...]) -> None:
|
||||
"""Copy every non-ignored child of source into destination."""
|
||||
for item in source.iterdir():
|
||||
relative = item.relative_to(template_root).as_posix()
|
||||
# CURSOR: repository .gitignore matches (byte-code caches and the like)
|
||||
# are not copied into a wiki.
|
||||
if any(path_matches(pattern, relative) for pattern in ignore_patterns):
|
||||
continue
|
||||
if path_is_ignored(relative, list(git_patterns)):
|
||||
continue
|
||||
|
||||
dest_item = destination / item.name
|
||||
if item.is_dir():
|
||||
dest_item.mkdir(parents=True, exist_ok=True)
|
||||
_copy_children(item, dest_item, template_root, ignore_patterns)
|
||||
_copy_children(item, dest_item, template_root, ignore_patterns, git_patterns)
|
||||
else:
|
||||
_copy_file(item, dest_item)
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import json
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from unittest.mock import patch
|
||||
|
||||
@@ -510,3 +512,14 @@ class TestFionaLibrarianTocFile:
|
||||
assert "## 1. Section" in content
|
||||
assert "- [1. Section](#1-section)" in content
|
||||
assert "<!-- toc-start: sectionized, headings 2..6 -->" in content
|
||||
|
||||
|
||||
def test_cli_entry_imports_without_cycle():
|
||||
"""Test a fresh interpreter can import the CLI."""
|
||||
completed = subprocess.run(
|
||||
[sys.executable, "-c", "import fiona.__main__"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
assert completed.returncode == 0, completed.stderr
|
||||
|
||||
@@ -160,6 +160,7 @@ class TestConstellationThemes:
|
||||
|
||||
Generated by AI/LLM: 2026-09-29 - dark theme beside grayscale.
|
||||
Modified by AI/LLM: 2026-09-30 - night slate instead of black.
|
||||
Modified by CURSOR: 2026-09-30 - dark theme mid and high node colors.
|
||||
"""
|
||||
themes = load_constellation_themes()
|
||||
dark = themes["dark"]
|
||||
@@ -167,7 +168,8 @@ class TestConstellationThemes:
|
||||
assert dark["graph_background"] == "#283448"
|
||||
assert dark["text_color"] == "#e7eef8"
|
||||
assert dark["node_colors"]["low"] == "#7d8da3"
|
||||
assert dark["node_colors"]["high"] == "#f7fbff"
|
||||
assert dark["node_colors"]["mid"] == "#fff4c4"
|
||||
assert dark["node_colors"]["high"] == "#f7d67c"
|
||||
assert dark["edge_colors"]["low"] == "#51627a"
|
||||
assert dark["edge_colors"]["high"] == "#d5e2f2"
|
||||
assert dark["node_stroke"] == "none"
|
||||
|
||||
@@ -0,0 +1,188 @@
|
||||
"""Tests for wiki gitignore seeding and matching.
|
||||
|
||||
Generated by CURSOR: 2026-09-30 - cover repository ignore patterns.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
|
||||
import pytest
|
||||
|
||||
from fiona.wiki.ignore import (
|
||||
ensure_wiki_gitignore,
|
||||
gitignore_patterns_from_text,
|
||||
packaged_gitignore_path,
|
||||
path_is_ignored,
|
||||
repository_gitignore_path,
|
||||
repository_gitignore_text,
|
||||
wiki_gitignore_patterns,
|
||||
wiki_gitignore_text,
|
||||
)
|
||||
|
||||
|
||||
def test_patterns_skip_comments_and_blanks():
|
||||
"""Test comment lines and blank lines are not patterns."""
|
||||
text = "# comment\n\n__pycache__/\n *.pyc \n"
|
||||
|
||||
assert gitignore_patterns_from_text(text) == ["__pycache__/", "*.pyc"]
|
||||
|
||||
|
||||
def test_path_matches_segment_and_directory_prefix():
|
||||
"""Test unanchored names and trailing-slash directory patterns."""
|
||||
patterns = ["*.pyc", "__pycache__/", "*fiona.log", "build/"]
|
||||
|
||||
assert path_is_ignored("utils/scripts/__pycache__/example.pyc", patterns)
|
||||
assert path_is_ignored(
|
||||
"utils/scripts/__pycache__/example.cpython-313.pyc", patterns
|
||||
)
|
||||
assert path_is_ignored("example.pyc", patterns)
|
||||
assert path_is_ignored("fiona.log", patterns)
|
||||
assert path_is_ignored("nested/myfiona.log", patterns)
|
||||
assert path_is_ignored("build/lib/out.py", patterns)
|
||||
assert not path_is_ignored("utils/scripts/example.py", patterns)
|
||||
assert not path_is_ignored("fiona.log.bak", patterns)
|
||||
|
||||
|
||||
def test_path_matches_pattern_that_contains_a_slash():
|
||||
"""Test a pattern with a slash matches that relative prefix."""
|
||||
assert path_is_ignored("utils/scripts/example.py", ["utils/scripts/*"])
|
||||
assert path_is_ignored("utils/scripts/example.py", ["utils/scripts/"])
|
||||
assert path_is_ignored("secret/data.md", ["secret/"])
|
||||
assert not path_is_ignored("other/example.py", ["utils/scripts/*"])
|
||||
assert not path_is_ignored("file.py", ["/"])
|
||||
|
||||
|
||||
def test_repository_gitignore_is_the_fiona_repo_file():
|
||||
"""Test the seed file is the fiona-assistant repository .gitignore."""
|
||||
path = repository_gitignore_path()
|
||||
|
||||
assert path is not None
|
||||
assert path.name == ".gitignore"
|
||||
assert "__pycache__/" in path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_packaged_copy_matches_repository_file():
|
||||
"""Test the packaged fallback has the same text as the repository file."""
|
||||
packaged = packaged_gitignore_path()
|
||||
|
||||
assert packaged is not None
|
||||
packaged_text = packaged.read_text(encoding="utf-8").replace("\r\n", "\n").replace("\r", "\n")
|
||||
if packaged_text and not packaged_text.endswith("\n"):
|
||||
packaged_text += "\n"
|
||||
assert packaged_text == repository_gitignore_text()
|
||||
|
||||
|
||||
def test_wiki_gitignore_adds_personal():
|
||||
"""Test the wiki ignore set starts from the repository and adds personal/."""
|
||||
patterns = wiki_gitignore_patterns()
|
||||
|
||||
assert "__pycache__/" in patterns
|
||||
assert "*.pyc" in patterns
|
||||
assert "*fiona.log" in patterns
|
||||
assert "personal/" in patterns
|
||||
assert wiki_gitignore_text().endswith("personal/\n")
|
||||
|
||||
|
||||
def test_ensure_writes_a_new_file(tmp_path: pathlib.Path):
|
||||
"""Test a missing .gitignore is created from the repository set."""
|
||||
ensure_wiki_gitignore(tmp_path)
|
||||
|
||||
text = (tmp_path / ".gitignore").read_text(encoding="utf-8")
|
||||
assert "__pycache__/" in text.splitlines()
|
||||
assert "personal/" in text.splitlines()
|
||||
|
||||
|
||||
def test_ensure_appends_missing_patterns(tmp_path: pathlib.Path):
|
||||
"""Test an existing .gitignore keeps its lines and gains missing patterns."""
|
||||
(tmp_path / ".gitignore").write_text("keep-me\npersonal/\n", encoding="utf-8")
|
||||
|
||||
ensure_wiki_gitignore(tmp_path)
|
||||
|
||||
lines = (tmp_path / ".gitignore").read_text(encoding="utf-8").splitlines()
|
||||
assert lines[0] == "keep-me"
|
||||
assert "personal/" in lines
|
||||
assert lines.count("personal/") == 1
|
||||
assert "__pycache__/" in lines
|
||||
|
||||
|
||||
def test_ensure_leaves_a_complete_file_unchanged(tmp_path: pathlib.Path):
|
||||
"""Test a file that already has every pattern is not rewritten."""
|
||||
target = tmp_path / ".gitignore"
|
||||
target.write_text(wiki_gitignore_text(), encoding="utf-8")
|
||||
before = target.read_bytes()
|
||||
|
||||
ensure_wiki_gitignore(tmp_path)
|
||||
|
||||
assert target.read_bytes() == before
|
||||
|
||||
|
||||
def test_repository_text_normalizes_newlines(tmp_path, monkeypatch):
|
||||
"""Test CR LF is folded to LF and a missing final newline is added."""
|
||||
source = tmp_path / ".gitignore"
|
||||
source.write_bytes(b"__pycache__/\r\n*.pyc")
|
||||
monkeypatch.setattr(
|
||||
"fiona.wiki.ignore.repository_gitignore_path", lambda: source
|
||||
)
|
||||
|
||||
assert repository_gitignore_text() == "__pycache__/\n*.pyc\n"
|
||||
|
||||
|
||||
def test_wiki_text_keeps_personal_when_already_present(monkeypatch):
|
||||
"""Test personal/ is not duplicated when the repository file lists it."""
|
||||
monkeypatch.setattr(
|
||||
"fiona.wiki.ignore.repository_gitignore_text",
|
||||
lambda: "__pycache__/\npersonal/\n",
|
||||
)
|
||||
|
||||
assert wiki_gitignore_text() == "__pycache__/\npersonal/\n"
|
||||
assert wiki_gitignore_patterns() == ["__pycache__/", "personal/"]
|
||||
|
||||
|
||||
def test_packaged_path_missing(monkeypatch):
|
||||
"""Test a missing packaged ignore file returns None."""
|
||||
real_is_file = pathlib.Path.is_file
|
||||
|
||||
def fake_is_file(self):
|
||||
if self.name == "default.gitignore":
|
||||
return False
|
||||
return real_is_file(self)
|
||||
|
||||
monkeypatch.setattr(pathlib.Path, "is_file", fake_is_file)
|
||||
|
||||
assert packaged_gitignore_path() is None
|
||||
|
||||
|
||||
def test_ensure_appends_when_file_has_no_trailing_newline(tmp_path):
|
||||
"""Test a file without a trailing newline still gains missing patterns."""
|
||||
(tmp_path / ".gitignore").write_bytes(b"keep-me")
|
||||
|
||||
ensure_wiki_gitignore(tmp_path)
|
||||
|
||||
text = (tmp_path / ".gitignore").read_text(encoding="utf-8")
|
||||
assert text.startswith("keep-me\n")
|
||||
assert "__pycache__/" in text.splitlines()
|
||||
|
||||
|
||||
def test_repository_text_falls_back_to_package_data(monkeypatch):
|
||||
"""Test a checkout without the repo file uses the packaged copy."""
|
||||
monkeypatch.setattr(
|
||||
"fiona.wiki.ignore.repository_gitignore_path", lambda: None
|
||||
)
|
||||
|
||||
text = repository_gitignore_text()
|
||||
|
||||
assert "__pycache__/" in text.splitlines()
|
||||
|
||||
|
||||
def test_repository_text_raises_when_no_source_exists(monkeypatch):
|
||||
"""Test a missing repository file and packaged copy is an error."""
|
||||
monkeypatch.setattr(
|
||||
"fiona.wiki.ignore.repository_gitignore_path", lambda: None
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"fiona.wiki.ignore.packaged_gitignore_path", lambda: None
|
||||
)
|
||||
|
||||
with pytest.raises(FileNotFoundError, match="repository .gitignore"):
|
||||
repository_gitignore_text()
|
||||
@@ -889,6 +889,16 @@ class TestGetAllTemplateFilesImplemented:
|
||||
assert "wiki/index.md" not in files
|
||||
assert "AGENTS.md" in files
|
||||
|
||||
def test_skips_repository_gitignore(self, temp_template_dir):
|
||||
"""Test byte-code caches are not template update candidates."""
|
||||
cached = temp_template_dir / "utils" / "scripts" / "__pycache__"
|
||||
cached.mkdir(parents=True)
|
||||
(cached / "example.pyc").write_bytes(b"pyc")
|
||||
|
||||
files = {path.as_posix() for path in get_all_template_files(temp_template_dir)}
|
||||
|
||||
assert "utils/scripts/__pycache__/example.pyc" not in files
|
||||
|
||||
|
||||
class TestFindMissingCoreFilesImplemented:
|
||||
"""Tests for finding missing core files."""
|
||||
@@ -900,7 +910,7 @@ class TestFindMissingCoreFilesImplemented:
|
||||
|
||||
assert "AGENTS.md" in missing
|
||||
assert "README.md" in missing
|
||||
assert "wiki/index.md" in missing
|
||||
assert "wiki/index.md" not in missing
|
||||
|
||||
def test_present_file_not_reported(self, temp_wiki_dir, temp_template_dir):
|
||||
shutil.copy2(
|
||||
@@ -944,7 +954,7 @@ class TestFindMissingDirectories:
|
||||
|
||||
missing = {d.as_posix() for d in find_missing_directories(wiki, template)}
|
||||
|
||||
assert missing == {"wiki", "utils", "utils/scripts"}
|
||||
assert missing == {"utils", "utils/scripts"}
|
||||
|
||||
def test_existing_directories_not_reported(self, tmp_path):
|
||||
template = self._template(tmp_path)
|
||||
@@ -1010,9 +1020,13 @@ class TestCheckWikiUpdatesImplemented:
|
||||
|
||||
summary = check_wiki_updates(str(wiki))
|
||||
|
||||
assert "wiki/queries" in [
|
||||
assert "wiki/queries" not in [
|
||||
d.as_posix() for d in summary.directories_to_add
|
||||
]
|
||||
assert not any(
|
||||
path.as_posix() == "wiki" or path.as_posix().startswith("wiki/")
|
||||
for path in summary.files_to_add
|
||||
)
|
||||
|
||||
def test_locally_modified_version_skipped_and_reported(self, template_wiki_pair):
|
||||
_template, wiki = template_wiki_pair
|
||||
@@ -1058,6 +1072,63 @@ class TestCheckWikiUpdatesImplemented:
|
||||
|
||||
assert summary.has_updates is False
|
||||
|
||||
def test_wiki_pages_stay_out_of_the_report(self, template_wiki_pair):
|
||||
"""Test an edited wiki page is not an update, add, or skip."""
|
||||
_template, wiki = template_wiki_pair
|
||||
_write_md(
|
||||
wiki / "wiki" / "index.md", "0.1.0", body="# User index\n", name="index"
|
||||
)
|
||||
|
||||
summary = check_wiki_updates(str(wiki))
|
||||
|
||||
reported = [result.file_path.as_posix() for result in summary.files_to_update]
|
||||
reported += [result.file_path.as_posix() for result in summary.files_skipped]
|
||||
reported += [path.as_posix() for path in summary.files_to_add]
|
||||
reported += [path.as_posix() for path in summary.directories_to_add]
|
||||
assert not any(
|
||||
path == "wiki" or path.startswith("wiki/") or path.endswith("/wiki/index.md")
|
||||
for path in reported
|
||||
)
|
||||
|
||||
def test_repository_gitignore_artifact_is_not_reported(self, template_wiki_pair):
|
||||
"""Test a template byte-code file is not offered as an update."""
|
||||
template, wiki = template_wiki_pair
|
||||
cached = template / "utils" / "scripts" / "__pycache__"
|
||||
cached.mkdir(parents=True)
|
||||
(cached / "example.pyc").write_bytes(b"template")
|
||||
wiki_cached = wiki / "utils" / "scripts" / "__pycache__"
|
||||
wiki_cached.mkdir(parents=True)
|
||||
(wiki_cached / "example.pyc").write_bytes(b"local")
|
||||
|
||||
summary = check_wiki_updates(str(wiki))
|
||||
|
||||
reported = [result.file_path.as_posix() for result in summary.files_to_update]
|
||||
reported += [result.file_path.as_posix() for result in summary.files_skipped]
|
||||
reported += [path.as_posix() for path in summary.files_to_add]
|
||||
assert not any(path.endswith("example.pyc") for path in reported)
|
||||
|
||||
def test_wiki_gitignore_hides_drifted_file(self, template_wiki_pair):
|
||||
"""Test a path listed in the wiki gitignore is absent from the report."""
|
||||
template, wiki = template_wiki_pair
|
||||
(template / "utils" / "scripts").mkdir(parents=True)
|
||||
(template / "utils" / "scripts" / "example.py").write_text(
|
||||
"print('new')\n", encoding="utf-8"
|
||||
)
|
||||
(wiki / "utils" / "scripts").mkdir(parents=True)
|
||||
(wiki / "utils" / "scripts" / "example.py").write_text(
|
||||
"print('old')\n", encoding="utf-8"
|
||||
)
|
||||
(wiki / ".gitignore").write_text("example.py\n", encoding="utf-8")
|
||||
|
||||
summary = check_wiki_updates(str(wiki))
|
||||
|
||||
assert not any(
|
||||
result.file_path.name == "example.py" for result in summary.files_to_update
|
||||
)
|
||||
assert not any(
|
||||
result.file_path.name == "example.py" for result in summary.files_skipped
|
||||
)
|
||||
|
||||
def test_read_only_template_files_ignored(self, template_wiki_pair):
|
||||
_template, wiki = template_wiki_pair
|
||||
(wiki / "personal" / "README.md").unlink()
|
||||
@@ -1083,16 +1154,50 @@ class TestUpdateCoreFilesImplemented:
|
||||
assert len(summary.files_to_update) == 1
|
||||
|
||||
def test_yes_adds_missing_file_and_directory(self, template_wiki_pair):
|
||||
_template, wiki = template_wiki_pair
|
||||
template, wiki = template_wiki_pair
|
||||
(wiki / "README.md").unlink()
|
||||
shutil.rmtree(wiki / "wiki" / "queries")
|
||||
_write_md(template / "utils" / "scripts" / "map.md", "1.0.0", name="map")
|
||||
|
||||
update_core_files(str(wiki), yes=True)
|
||||
|
||||
assert (wiki / "README.md").read_text(encoding="utf-8") == (
|
||||
"---\nname: readme\nversion: 1.0.0\n---\n# Readme\n"
|
||||
)
|
||||
assert (wiki / "wiki" / "queries" / ".gitkeep").exists()
|
||||
assert (wiki / "utils" / "scripts" / "map.md").is_file()
|
||||
assert not (wiki / "wiki" / "queries").exists()
|
||||
|
||||
def test_yes_leaves_wiki_pages_unchanged(self, template_wiki_pair):
|
||||
"""Test update does not rewrite or restore anything under wiki/."""
|
||||
_template, wiki = template_wiki_pair
|
||||
user = "---\nname: index\nversion: 0.1.0\n---\n# User index\n"
|
||||
(wiki / "wiki" / "index.md").write_text(user, encoding="utf-8")
|
||||
shutil.rmtree(wiki / "wiki" / "queries")
|
||||
|
||||
update_core_files(str(wiki), yes=True)
|
||||
|
||||
assert (wiki / "wiki" / "index.md").read_text(encoding="utf-8") == user
|
||||
assert not (wiki / "wiki" / "queries").exists()
|
||||
|
||||
def test_yes_leaves_gitignored_file_unchanged(self, template_wiki_pair):
|
||||
"""Test update does not overwrite a file the wiki gitignore names."""
|
||||
template, wiki = template_wiki_pair
|
||||
(template / "utils" / "scripts").mkdir(parents=True)
|
||||
(template / "utils" / "scripts" / "example.py").write_text(
|
||||
"print('new')\n", encoding="utf-8"
|
||||
)
|
||||
original = "print('old')\n"
|
||||
(wiki / "utils" / "scripts").mkdir(parents=True)
|
||||
(wiki / "utils" / "scripts" / "example.py").write_text(
|
||||
original, encoding="utf-8"
|
||||
)
|
||||
(wiki / ".gitignore").write_text("example.py\n", encoding="utf-8")
|
||||
|
||||
update_core_files(str(wiki), yes=True)
|
||||
|
||||
assert (wiki / "utils" / "scripts" / "example.py").read_text(
|
||||
encoding="utf-8"
|
||||
) == original
|
||||
|
||||
def test_locally_modified_file_left_untouched(self, template_wiki_pair):
|
||||
_template, wiki = template_wiki_pair
|
||||
|
||||
+53
-2
@@ -34,8 +34,13 @@ def test_wiki_init_is_1_to_1_copy_with_source():
|
||||
template_files = _relative_files(get_llm_wiki_source_path())
|
||||
copied_files = _relative_files(Path(tmpdir))
|
||||
|
||||
# All template files should be present
|
||||
assert template_files.issubset(copied_files)
|
||||
# Gitignored template artifacts are not part of the copy.
|
||||
gitignored = {
|
||||
path for path in template_files
|
||||
if "__pycache__" in path.parts or path.suffix in {".pyc", ".pyo", ".pyd"}
|
||||
}
|
||||
assert (template_files - gitignored).issubset(copied_files)
|
||||
assert gitignored.isdisjoint(copied_files)
|
||||
|
||||
# Git-related files should also be present
|
||||
gitignore_path = Path(tmpdir) / ".gitignore"
|
||||
@@ -70,6 +75,52 @@ def test_copy_directory_tree_copies_python_files(tmp_path):
|
||||
)
|
||||
|
||||
|
||||
def test_copy_directory_tree_skips_repository_gitignore(tmp_path):
|
||||
"""Test byte-code caches listed in the repository gitignore are not copied."""
|
||||
source = tmp_path / "source"
|
||||
scripts = source / "utils" / "scripts"
|
||||
(scripts / "__pycache__").mkdir(parents=True)
|
||||
(scripts / "example.py").write_text("print(1)\n", encoding="utf-8")
|
||||
(scripts / "__pycache__" / "example.pyc").write_bytes(b"pyc")
|
||||
|
||||
destination = tmp_path / "dest"
|
||||
copy_directory_tree(source, destination)
|
||||
|
||||
assert (destination / "utils" / "scripts" / "example.py").is_file()
|
||||
assert not (destination / "utils" / "scripts" / "__pycache__").exists()
|
||||
|
||||
|
||||
def test_wiki_init_appends_repository_gitignore(tmp_path):
|
||||
"""Test init keeps existing ignore lines and adds the repository set."""
|
||||
(tmp_path / ".gitignore").write_text("keep-me\n", encoding="utf-8")
|
||||
|
||||
wiki_init(str(tmp_path))
|
||||
|
||||
text = (tmp_path / ".gitignore").read_text(encoding="utf-8")
|
||||
assert "keep-me" in text.splitlines()
|
||||
assert "__pycache__/" in text.splitlines()
|
||||
assert "personal/" in text.splitlines()
|
||||
|
||||
|
||||
def test_wiki_init_skips_gitignored_template_file(tmp_path, monkeypatch):
|
||||
"""Test init does not copy a template file the repository gitignore matches."""
|
||||
source = tmp_path / "template"
|
||||
scripts = source / "utils" / "scripts"
|
||||
(scripts / "__pycache__").mkdir(parents=True)
|
||||
(scripts / "example.py").write_text("print(1)\n", encoding="utf-8")
|
||||
(scripts / "__pycache__" / "example.pyc").write_bytes(b"\x00pyc")
|
||||
(source / "fiona-settings.json").write_text("{}\n", encoding="utf-8")
|
||||
monkeypatch.setattr(
|
||||
"fiona.wiki.wiki.get_llm_wiki_source_path", lambda: source
|
||||
)
|
||||
|
||||
wiki_init(str(tmp_path / "wiki"))
|
||||
|
||||
wiki_root = tmp_path / "wiki"
|
||||
assert (wiki_root / "utils" / "scripts" / "example.py").is_file()
|
||||
assert not (wiki_root / "utils" / "scripts" / "__pycache__").exists()
|
||||
|
||||
|
||||
def test_copy_directory_tree_respects_ignore_patterns(tmp_path):
|
||||
"""Test matching files are skipped, everything else is copied."""
|
||||
source = tmp_path / "source"
|
||||
|
||||
Reference in New Issue
Block a user