Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@ jobs:
run: python -m pip install -e ".[mcp]"
- name: Run tests
run: python -m unittest discover -s tests -t .
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install (with the optional MCP dependency and the checkers)
run: python -m pip install -e ".[mcp]" ruff coverage
- name: Lint
run: ruff check .
- name: Tests with coverage floor (see pyproject.toml)
run: |
python -m coverage run -m unittest discover -s tests -t .
python -m coverage report
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Thanks for helping. PersonaKit is pre-release; the design is in
- **Respect the module boundaries.** Only `store` touches SQLite, only `llm` talks to a model, only
`ingest` reads session files. If you need to break a boundary, open an issue first.
- **No duplicated logic.** Reuse an existing helper or move it to the right module.
- **Checks must pass locally first.** `ruff check .` and `python -m coverage run -m unittest discover -s tests -t . && python -m coverage report`
(CI fails below the coverage floor in `pyproject.toml`).
- **Small pull requests.** One change, with tests and a doc update if behavior or a privacy claim changes.

## Workflow
Expand Down
2 changes: 1 addition & 1 deletion personakit/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ExtractionResult:
memories: list[Memory] = field(default_factory=list)
rejected: Counter = field(default_factory=Counter)

def merge(self, other: "ExtractionResult") -> None:
def merge(self, other: ExtractionResult) -> None:
self.memories.extend(other.memories)
self.rejected.update(other.rejected)

Expand Down
3 changes: 2 additions & 1 deletion personakit/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
import json
import subprocess
import tempfile
from collections.abc import Callable
from dataclasses import dataclass
from pathlib import Path
from typing import Callable, Protocol
from typing import Protocol

from personakit.ingest.common import SANDBOX_PREFIX

Expand Down
2 changes: 1 addition & 1 deletion personakit/retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from __future__ import annotations

import re
from collections.abc import Iterable
from dataclasses import dataclass
from typing import Iterable

from personakit.model import Memory, State

Expand Down
4 changes: 2 additions & 2 deletions personakit/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from __future__ import annotations

from dataclasses import dataclass, field
from typing import Callable
from collections.abc import Callable
from dataclasses import dataclass

from personakit.model import Decider, Memory, State
from personakit.store import Store
Expand Down
6 changes: 3 additions & 3 deletions personakit/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from __future__ import annotations

import sqlite3
from collections.abc import Callable, Iterable
from datetime import datetime, timezone
from pathlib import Path
from typing import Callable, Iterable

from personakit.model import Decider, Evidence, Memory, State

Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(self, path: str | Path, now: Callable[[], str] = _utc_now):
def close(self) -> None:
self._conn.close()

def __enter__(self) -> "Store":
def __enter__(self) -> Store:
return self

def __exit__(self, *exc: object) -> None:
Expand Down Expand Up @@ -176,7 +176,7 @@ def list(
clauses, params = [], []
if states is not None:
values = [s.value for s in states]
clauses.append("state IN (%s)" % ",".join("?" * len(values)))
clauses.append(f"state IN ({','.join('?' * len(values))})")
params.extend(values)
if scope is not None:
clauses.append("scope = ?")
Expand Down
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,21 @@ personakit = "personakit.cli:main"

[tool.setuptools.packages.find]
include = ["personakit*"]

[tool.ruff]
line-length = 130
target-version = "py310"

[tool.ruff.lint]
select = ["E", "F", "I", "UP", "B"]

[tool.coverage.run]
branch = true
source = ["personakit"]

[tool.coverage.report]
fail_under = 90
show_missing = true

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["E501"]
2 changes: 0 additions & 2 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
from unittest import mock

from personakit import cli, llm
from personakit.model import Evidence, Memory
from personakit.store import Store
from tests.helpers import reply

FIXTURES = Path(__file__).parent / "fixtures" / "claude_code"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_retrieve.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest

from personakit.model import Evidence, Memory, State
from personakit import retrieve
from personakit.model import Evidence, Memory, State
from personakit.retrieve import SERVED, STANDING_CONTEXT, search


Expand Down
Loading