Skip to content

Commit fc6e49b

Browse files
committed
chore: add AGENTS.md, commit hooks, coverage thresholds, deadcode detection, spec templates
1 parent 5c4b625 commit fc6e49b

5 files changed

Lines changed: 131 additions & 1 deletion

File tree

.githooks/prepare-commit-msg

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
# Auto-strip Co-authored-by trailers and enforce conventional commits
3+
COMMIT_MSG_FILE=$1
4+
COMMIT_SOURCE=$2
5+
6+
# Skip merge commits, amend, etc.
7+
if [ "$COMMIT_SOURCE" = "merge" ] || [ "$COMMIT_SOURCE" = "squash" ]; then
8+
exit 0
9+
fi
10+
11+
# Strip Co-authored-by lines
12+
sed -i.bak "/^Co-authored-by:/d" "$COMMIT_MSG_FILE" 2>/dev/null || \
13+
sed -i "/^Co-authored-by:/d" "$COMMIT_MSG_FILE"
14+
15+
# Remove trailing blank lines
16+
sed -i.bak -e :a -e "/^
17+
*$/{$d;N;ba" -e "}" "$COMMIT_MSG_FILE" 2>/dev/null || \
18+
sed -i -e :a -e "/^
19+
*$/{$d;N;ba" -e "}" "$COMMIT_MSG_FILE"
20+
21+
# Clean up backup files
22+
rm -f "${COMMIT_MSG_FILE}.bak"
23+

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
python -m pip install --upgrade pip
3636
pip install -e ".[dev]"
3737
- name: pytest
38-
run: pytest --strict-markers --tb=short
38+
run: pytest --strict-markers --tb=short --cov=hawk --cov-report=term-missing --cov-fail-under=30
3939

4040
lint:
4141
name: lint (ruff)

AGENTS.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# AGENTS.md — hawk-sdk-python
2+
3+
Python SDK for the Hawk daemon API. Provides an idiomatic Python client for chat, streaming, sessions, and stats.
4+
5+
## Design Principles
6+
7+
- **Thin wrapper** — maps directly to the hawk daemon HTTP API
8+
- **Type-hinted** — full type annotations for IDE support
9+
- **Zero dependencies** — only `requests` and `typing_extensions`
10+
11+
## Build & Test
12+
13+
```bash
14+
pip install -e ".[dev]" # Install with dev deps
15+
pytest # Run tests
16+
pytest --cov=hawk --cov-report=term-missing # Coverage
17+
ruff check . # Lint
18+
ruff format . # Format
19+
mypy . # Type check
20+
```
21+
22+
## Architecture
23+
24+
- `hawk/client.py` — Main `HawkClient` class
25+
- `hawk/models.py` — Pydantic models for API responses
26+
- `hawk/errors.py` — Typed error classes (`HawkAPIError`, etc.)
27+
- `hawk/discovery.py` — Auto-discover running hawk daemon
28+
- `hawk/memory_tools.py` — Memory graph operations
29+
- `tests/` — Test suite with mocked HTTP responses
30+
31+
## Conventions
32+
33+
- Python 3.10+
34+
- `ruff` for linting and formatting (enforced in CI)
35+
- Type annotations required on all public APIs
36+
- Conventional Commits: `feat:`, `fix:`, `docs:`, `refactor:`, `test:`
37+
- No `Co-authored-by:` trailers
38+
- `pytest` for testing, `httpretty` for HTTP mocking
39+
40+
## Common Pitfalls
41+
42+
- `HawkClient` uses context manager (`with` statement) for cleanup
43+
- Discovery scans localhost ports — tests must mock this
44+
- `Retry-After: 0` is valid — respect it, don't retry immediately

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,7 @@ clean: ## Remove build artefacts and caches.
9595

9696
help: ## Show this help.
9797
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
98+
99+
.PHONY: hooks
100+
hooks:
101+
git config core.hooksPath .githooks

plans/SPEC-TEMPLATE.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Feature Specification: [Feature Name]
2+
3+
**Status:** Draft | In Review | Approved | Implemented
4+
**Author:** [Your Name]
5+
**Date:** [YYYY-MM-DD]
6+
**Repos affected:** [list repos]
7+
8+
## Problem Statement
9+
10+
[What problem does this solve?]
11+
12+
## Proposed Solution
13+
14+
[High-level approach]
15+
16+
## Design Details
17+
18+
### API Changes
19+
20+
[New endpoints, types, interfaces]
21+
22+
### Data Model Changes
23+
24+
[Schema changes, migrations]
25+
26+
### UI Changes
27+
28+
[Screens, components, flows]
29+
30+
## Alternatives Considered
31+
32+
[What else was considered and why rejected]
33+
34+
## Implementation Plan
35+
36+
### Phase 1: [Name]
37+
- [ ] Task 1
38+
- [ ] Task 2
39+
40+
### Phase 2: [Name]
41+
- [ ] Task 1
42+
- [ ] Task 2
43+
44+
## Testing Strategy
45+
46+
- Unit tests: [what to test]
47+
- Integration tests: [what to test]
48+
- E2E tests: [what to test]
49+
50+
## Risks & Mitigations
51+
52+
| Risk | Impact | Mitigation |
53+
|------|--------|------------|
54+
| [risk] | [high/med/low] | [mitigation] |
55+
56+
## References
57+
58+
- [Link to related docs, issues, PRs]
59+

0 commit comments

Comments
 (0)