corrkit 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- corrkit-0.5.0/.claude/settings.local.json +49 -0
- corrkit-0.5.0/.claude/skills/email/SKILL.md +47 -0
- corrkit-0.5.0/.claude/skills/email/find_unanswered.py +66 -0
- corrkit-0.5.0/.env.example +9 -0
- corrkit-0.5.0/.github/workflows/ci.yml +27 -0
- corrkit-0.5.0/.gitignore +12 -0
- corrkit-0.5.0/.make/common.mk +18 -0
- corrkit-0.5.0/.mise.toml +9 -0
- corrkit-0.5.0/.python-version +1 -0
- corrkit-0.5.0/AGENTS.md +231 -0
- corrkit-0.5.0/CLAUDE.md +1 -0
- corrkit-0.5.0/LICENSE +190 -0
- corrkit-0.5.0/Makefile +1 -0
- corrkit-0.5.0/PKG-INFO +410 -0
- corrkit-0.5.0/README.md +389 -0
- corrkit-0.5.0/VERSIONS.md +79 -0
- corrkit-0.5.0/accounts.toml.example +33 -0
- corrkit-0.5.0/collaborators.toml +0 -0
- corrkit-0.5.0/contacts.toml.example +13 -0
- corrkit-0.5.0/pyproject.toml +74 -0
- corrkit-0.5.0/services/com.corrkit.watch.plist +32 -0
- corrkit-0.5.0/services/corrkit-watch.service +19 -0
- corrkit-0.5.0/src/accounts.py +317 -0
- corrkit-0.5.0/src/audit_docs.py +251 -0
- corrkit-0.5.0/src/cloudflare/__init__.py +0 -0
- corrkit-0.5.0/src/collab/__init__.py +81 -0
- corrkit-0.5.0/src/collab/add.py +373 -0
- corrkit-0.5.0/src/collab/find_unanswered.py +86 -0
- corrkit-0.5.0/src/collab/remove.py +78 -0
- corrkit-0.5.0/src/collab/rename.py +101 -0
- corrkit-0.5.0/src/collab/reset.py +168 -0
- corrkit-0.5.0/src/collab/sync.py +172 -0
- corrkit-0.5.0/src/collab/templates/notify.yml +18 -0
- corrkit-0.5.0/src/collab/validate_draft.py +111 -0
- corrkit-0.5.0/src/contact/__init__.py +47 -0
- corrkit-0.5.0/src/contact/add.py +117 -0
- corrkit-0.5.0/src/corrkit.py +108 -0
- corrkit-0.5.0/src/draft/__init__.py +0 -0
- corrkit-0.5.0/src/draft/push.py +234 -0
- corrkit-0.5.0/src/help.py +71 -0
- corrkit-0.5.0/src/sync/__init__.py +0 -0
- corrkit-0.5.0/src/sync/auth.py +49 -0
- corrkit-0.5.0/src/sync/folders.py +63 -0
- corrkit-0.5.0/src/sync/imap.py +641 -0
- corrkit-0.5.0/src/sync/types.py +43 -0
- corrkit-0.5.0/src/watch.py +182 -0
- corrkit-0.5.0/tests/conftest.py +22 -0
- corrkit-0.5.0/tests/test_accounts.py +222 -0
- corrkit-0.5.0/tests/test_add_label.py +144 -0
- corrkit-0.5.0/tests/test_collab_add.py +280 -0
- corrkit-0.5.0/tests/test_collab_config.py +108 -0
- corrkit-0.5.0/tests/test_collab_remove.py +170 -0
- corrkit-0.5.0/tests/test_collab_rename.py +159 -0
- corrkit-0.5.0/tests/test_collab_sync.py +220 -0
- corrkit-0.5.0/tests/test_collab_workflow.py +343 -0
- corrkit-0.5.0/tests/test_contact_add.py +205 -0
- corrkit-0.5.0/tests/test_contact_config.py +98 -0
- corrkit-0.5.0/tests/test_corrkit.py +116 -0
- corrkit-0.5.0/tests/test_draft_push.py +126 -0
- corrkit-0.5.0/tests/test_imap_sync.py +458 -0
- corrkit-0.5.0/tests/test_list_folders.py +100 -0
- corrkit-0.5.0/tests/test_sync_state_migration.py +93 -0
- corrkit-0.5.0/tests/test_watch.py +305 -0
- corrkit-0.5.0/uv.lock +565 -0
- corrkit-0.5.0/voice.md +19 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"WebFetch(domain:harper.blog)",
|
|
5
|
+
"WebFetch(domain:jlongster.com)",
|
|
6
|
+
"Bash(uv sync:*)",
|
|
7
|
+
"Bash(uv run:*)",
|
|
8
|
+
"Bash(python3:*)",
|
|
9
|
+
"Bash(uv add:*)",
|
|
10
|
+
"Bash(git -C /home/brian/work/btakita/correspondence-kit log --oneline -10)",
|
|
11
|
+
"Bash(git -C /home/brian/work/btakita/correspondence-kit status)",
|
|
12
|
+
"Bash(git -C /home/brian/work/btakita/correspondence-kit check-ignore .env CLAUDE.local.md conversations/ drafts/)",
|
|
13
|
+
"Bash(git -C /home/brian/work/btakita/correspondence-kit log --oneline --all)",
|
|
14
|
+
"WebSearch",
|
|
15
|
+
"WebFetch(domain:pypi.org)",
|
|
16
|
+
"Bash(curl:*)",
|
|
17
|
+
"Bash(git -C /home/brian/work/btakita/correspondence-kit diff)",
|
|
18
|
+
"Bash(git -C /home/brian/work/btakita/correspondence-kit log --oneline -3)",
|
|
19
|
+
"Bash(git -C /home/brian/work/btakita/correspondence status)",
|
|
20
|
+
"Bash(git -C /home/brian/work/btakita/correspondence diff .sync-state.json)",
|
|
21
|
+
"Bash(git -C /home/brian/work/btakita/correspondence log --oneline -3)",
|
|
22
|
+
"Bash(git -C /home/brian/work/btakita/correspondence add .sync-state.json conversations/personal/ conversations/proton-dev/)",
|
|
23
|
+
"Bash(git -C:*)",
|
|
24
|
+
"Bash(gh repo view:*)",
|
|
25
|
+
"Bash(git submodule add:*)",
|
|
26
|
+
"Bash(ln:*)",
|
|
27
|
+
"Bash(git submodule:*)",
|
|
28
|
+
"Bash(git reset:*)",
|
|
29
|
+
"Bash(git rm:*)",
|
|
30
|
+
"Bash(git add:*)",
|
|
31
|
+
"Bash(cat:*)",
|
|
32
|
+
"Bash(pip index:*)",
|
|
33
|
+
"Bash(ls:*)",
|
|
34
|
+
"Bash(uv pip install:*)",
|
|
35
|
+
"Bash(git commit:*)",
|
|
36
|
+
"Bash(git push:*)",
|
|
37
|
+
"WebFetch(domain:github.com)",
|
|
38
|
+
"WebFetch(domain:pakstech.com)",
|
|
39
|
+
"WebFetch(domain:andypi.co.uk)",
|
|
40
|
+
"WebFetch(domain:www.launchd.info)",
|
|
41
|
+
"Bash(grep:*)",
|
|
42
|
+
"Bash(GIT_SEQUENCE_EDITOR=: git rebase:*)",
|
|
43
|
+
"Bash(GIT_SEQUENCE_EDITOR=\"sed -i ''1s/pick/edit/''\" git rebase -i 2bbac86)",
|
|
44
|
+
"Bash(git rebase:*)",
|
|
45
|
+
"Bash(git checkout:*)",
|
|
46
|
+
"Bash(uv build:*)"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Email Skill
|
|
2
|
+
|
|
3
|
+
Manage and draft correspondence using locally synced email threads.
|
|
4
|
+
|
|
5
|
+
## Core Principles
|
|
6
|
+
|
|
7
|
+
- **Draft only** — never send email directly; always save as a draft for human review
|
|
8
|
+
- **Match voice** — follow the Writing Voice guidelines in CLAUDE.md exactly
|
|
9
|
+
- **Use context** — always read the relevant thread in `conversations/` before drafting a reply
|
|
10
|
+
- **Be concise** — prefer shorter responses; ask before writing anything long
|
|
11
|
+
|
|
12
|
+
## Available Tools
|
|
13
|
+
|
|
14
|
+
- `correspondence/conversations/` — synced email threads as Markdown (flat, one file per thread)
|
|
15
|
+
- `correspondence/contacts/{name}/AGENTS.md` — per-contact context for drafting
|
|
16
|
+
- `correspondence/manifest.toml` — thread index by labels, accounts, contacts
|
|
17
|
+
- `correspondence/drafts/` — outgoing email drafts being worked on
|
|
18
|
+
- `corrkit by find-unanswered` — list threads awaiting a reply
|
|
19
|
+
- `corrkit sync` — re-sync threads from all accounts
|
|
20
|
+
- `corrkit list-folders ACCOUNT` — list IMAP folders for an account
|
|
21
|
+
|
|
22
|
+
## Workflows
|
|
23
|
+
|
|
24
|
+
### Review inbox
|
|
25
|
+
1. Run `corrkit by find-unanswered` to identify threads needing a reply
|
|
26
|
+
2. Read each thread and assess priority
|
|
27
|
+
3. Present a prioritized list with a one-line summary per thread
|
|
28
|
+
4. Wait for instruction before drafting anything
|
|
29
|
+
|
|
30
|
+
### Draft a reply
|
|
31
|
+
1. Read the full thread from `correspondence/conversations/`
|
|
32
|
+
2. Identify the key ask or context requiring a response
|
|
33
|
+
3. Draft a reply in `correspondence/drafts/[YYYY-MM-DD]-[slug].md` matching the voice guidelines
|
|
34
|
+
4. Present the draft and ask for feedback before finalizing
|
|
35
|
+
5. Iterate until approved — then offer to save as a draft
|
|
36
|
+
|
|
37
|
+
### Draft a new email
|
|
38
|
+
1. Ask for: recipient, topic, any relevant context or linked threads
|
|
39
|
+
2. Draft in `correspondence/drafts/[YYYY-MM-DD]-[slug].md`
|
|
40
|
+
3. Iterate until approved
|
|
41
|
+
|
|
42
|
+
## Success Criteria
|
|
43
|
+
|
|
44
|
+
- Drafts sound like the user wrote them, not like an AI
|
|
45
|
+
- No email is ever sent without explicit approval
|
|
46
|
+
- Threads are read in full before drafting — no assumptions from subject alone
|
|
47
|
+
- Priority assessment reflects the user's relationships and context, not just recency
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""
|
|
2
|
+
List synced threads where the last message is not from you —
|
|
3
|
+
i.e. threads awaiting your reply.
|
|
4
|
+
|
|
5
|
+
Usage: uv run .claude/skills/email/find_unanswered.py
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
import re
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
from dotenv import load_dotenv
|
|
14
|
+
|
|
15
|
+
load_dotenv()
|
|
16
|
+
|
|
17
|
+
USER_EMAIL = os.getenv("GMAIL_USER_EMAIL", "").lower()
|
|
18
|
+
if not USER_EMAIL:
|
|
19
|
+
print("GMAIL_USER_EMAIL not set in .env", file=sys.stderr)
|
|
20
|
+
sys.exit(1)
|
|
21
|
+
|
|
22
|
+
CONVERSATIONS = Path("correspondence/conversations")
|
|
23
|
+
if not CONVERSATIONS.exists():
|
|
24
|
+
print(
|
|
25
|
+
"No correspondence/conversations/ directory found. Run sync first.",
|
|
26
|
+
file=sys.stderr,
|
|
27
|
+
)
|
|
28
|
+
sys.exit(1)
|
|
29
|
+
|
|
30
|
+
# Match "## Sender Name <email@example.com> — Date" or "## Name — Date"
|
|
31
|
+
SENDER_RE = re.compile(r"^## (.+?) \u2014", re.MULTILINE)
|
|
32
|
+
|
|
33
|
+
# Labels from **Labels**: or legacy **Label**: line
|
|
34
|
+
LABELS_RE = re.compile(r"\*\*Labels?\*\*:\s*(.+)")
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def last_sender(text: str) -> str:
|
|
38
|
+
matches = SENDER_RE.findall(text)
|
|
39
|
+
return matches[-1].strip() if matches else ""
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def thread_labels(text: str) -> str:
|
|
43
|
+
m = LABELS_RE.search(text)
|
|
44
|
+
return m.group(1).strip() if m else ""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
unanswered: list[tuple[str, str, str]] = [] # (labels, filename, last_sender)
|
|
48
|
+
|
|
49
|
+
thread_files = sorted(CONVERSATIONS.rglob("*.md"), key=lambda p: p.name, reverse=True)
|
|
50
|
+
for thread_file in thread_files:
|
|
51
|
+
text = thread_file.read_text(encoding="utf-8")
|
|
52
|
+
sender = last_sender(text)
|
|
53
|
+
# Consider it unanswered if the last sender doesn't contain the user's email
|
|
54
|
+
if USER_EMAIL not in sender.lower():
|
|
55
|
+
labels = thread_labels(text) or thread_file.parent.name
|
|
56
|
+
unanswered.append((labels, thread_file.name, sender))
|
|
57
|
+
|
|
58
|
+
if not unanswered:
|
|
59
|
+
print("No unanswered threads found.")
|
|
60
|
+
sys.exit(0)
|
|
61
|
+
|
|
62
|
+
print(f"Unanswered threads ({len(unanswered)}):\n")
|
|
63
|
+
for labels, filename, sender in unanswered:
|
|
64
|
+
print(f" [{labels}] {filename}")
|
|
65
|
+
print(f" Last from: {sender}")
|
|
66
|
+
print()
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
GMAIL_USER_EMAIL=
|
|
2
|
+
GMAIL_APP_PASSWORD= # myaccount.google.com/apppasswords
|
|
3
|
+
GMAIL_SYNC_LABELS=correspondence
|
|
4
|
+
GMAIL_SYNC_DAYS=3650
|
|
5
|
+
|
|
6
|
+
# Cloudflare (optional — for routing intelligence)
|
|
7
|
+
CLOUDFLARE_ACCOUNT_ID=
|
|
8
|
+
CLOUDFLARE_API_TOKEN=
|
|
9
|
+
CLOUDFLARE_D1_DATABASE_ID=
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
check:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
|
|
15
|
+
- uses: astral-sh/setup-uv@v5
|
|
16
|
+
|
|
17
|
+
- name: Install dependencies
|
|
18
|
+
run: uv sync
|
|
19
|
+
|
|
20
|
+
- name: Type check
|
|
21
|
+
run: uv run ty check --error-on-warning
|
|
22
|
+
|
|
23
|
+
- name: Lint
|
|
24
|
+
run: uv run ruff check
|
|
25
|
+
|
|
26
|
+
- name: Test
|
|
27
|
+
run: uv run pytest
|
corrkit-0.5.0/.gitignore
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
init: PY_VERSION = $(shell [ -f .python-version ] && \
|
|
2
|
+
cat .python-version || \
|
|
3
|
+
uv run python -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')" \
|
|
4
|
+
)
|
|
5
|
+
init:
|
|
6
|
+
@echo "Using Python version: $(PY_VERSION)"
|
|
7
|
+
|
|
8
|
+
@if command -v mise >/dev/null 2>&1; then \
|
|
9
|
+
mise install; \
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
uv venv .venv --python "$(PY_VERSION)" --no-project --clear --seed $(VENV_ARGS)
|
|
13
|
+
|
|
14
|
+
@if [ -n "$(ALL)" ]; then \
|
|
15
|
+
uv sync --python "$(PY_VERSION)" --all-groups --all-extras $(SYNC_ARGS); \
|
|
16
|
+
else \
|
|
17
|
+
uv sync --python "$(PY_VERSION)" $(SYNC_ARGS); \
|
|
18
|
+
fi
|
corrkit-0.5.0/.mise.toml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
corrkit-0.5.0/AGENTS.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Correspondence Kit
|
|
2
|
+
|
|
3
|
+
## Tech Stack
|
|
4
|
+
|
|
5
|
+
- **Runtime**: Python 3.12+ via `uv`
|
|
6
|
+
- **Linter/formatter**: `ruff`
|
|
7
|
+
- **Type checker**: `ty`
|
|
8
|
+
- **Types/serialization**: `msgspec` (Struct instead of dataclasses)
|
|
9
|
+
- **Storage**: Markdown files (one flat directory, one file per conversation thread)
|
|
10
|
+
- **Sources**: Any IMAP provider (Gmail, Protonmail Bridge, generic IMAP); Slack and social media planned
|
|
11
|
+
- **Cloudflare** (routing layer): TypeScript Workers reading from D1/KV populated by Python
|
|
12
|
+
|
|
13
|
+
## Two Repos
|
|
14
|
+
|
|
15
|
+
**corrkit** is the tool — Python source, tests, config templates. It is a public repo.
|
|
16
|
+
|
|
17
|
+
**correspondence** is the data — synced threads, drafts, contacts, collaborator submodules.
|
|
18
|
+
It is a separate, private repo. corrkit accesses it via a `correspondence/` path in the
|
|
19
|
+
working directory, which can be either:
|
|
20
|
+
|
|
21
|
+
- A **symlink** to an external clone (e.g. `correspondence -> ~/data/correspondence`)
|
|
22
|
+
- A **subdirectory** or nested clone inside the corrkit checkout
|
|
23
|
+
|
|
24
|
+
All corrkit commands assume `correspondence/` exists at the working directory root.
|
|
25
|
+
The `correspondence` entry in `.gitignore` keeps the data repo out of corrkit's git history
|
|
26
|
+
regardless of how it is linked.
|
|
27
|
+
|
|
28
|
+
## Project Structure
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
./ # Tool repo (this repo)
|
|
32
|
+
AGENTS.md # Project instructions (CLAUDE.md symlinks here)
|
|
33
|
+
pyproject.toml
|
|
34
|
+
voice.md # Writing voice guidelines (committed)
|
|
35
|
+
accounts.toml # Multi-account IMAP config (gitignored)
|
|
36
|
+
accounts.toml.example # Template with provider presets (committed)
|
|
37
|
+
contacts.toml # Contact metadata (gitignored)
|
|
38
|
+
contacts.toml.example # Template (committed)
|
|
39
|
+
collaborators.toml # Collaborator config (committed)
|
|
40
|
+
.env # Legacy credentials fallback (gitignored)
|
|
41
|
+
.claude/
|
|
42
|
+
skills/
|
|
43
|
+
email/
|
|
44
|
+
SKILL.md # Email drafting & management skill
|
|
45
|
+
find_unanswered.py # Find threads needing a reply
|
|
46
|
+
src/
|
|
47
|
+
accounts.py # Account config parser (accounts.toml)
|
|
48
|
+
sync/
|
|
49
|
+
imap.py # Multi-account IMAP sync logic
|
|
50
|
+
types.py # msgspec Structs
|
|
51
|
+
auth.py # One-time Gmail OAuth flow
|
|
52
|
+
draft/
|
|
53
|
+
push.py # Push draft to email (draft or send)
|
|
54
|
+
collab/
|
|
55
|
+
__init__.py # Collaborator config parser
|
|
56
|
+
add.py # for add command
|
|
57
|
+
sync.py # for sync / for status commands
|
|
58
|
+
remove.py # for remove command
|
|
59
|
+
rename.py # for rename command
|
|
60
|
+
reset.py # for reset command
|
|
61
|
+
find_unanswered.py # by find-unanswered command
|
|
62
|
+
validate_draft.py # by validate-draft command
|
|
63
|
+
contact/
|
|
64
|
+
__init__.py # Contact config parser
|
|
65
|
+
add.py # contact-add command
|
|
66
|
+
cloudflare/
|
|
67
|
+
__init__.py # Push intelligence to Cloudflare (planned)
|
|
68
|
+
watch.py # IMAP polling daemon (corrkit watch)
|
|
69
|
+
services/
|
|
70
|
+
corrkit-watch.service # systemd user unit template
|
|
71
|
+
com.corrkit.watch.plist # launchd agent template
|
|
72
|
+
tests/
|
|
73
|
+
|
|
74
|
+
correspondence/ # Data repo (separate, gitignored)
|
|
75
|
+
conversations/ # Synced threads (flat, one file per thread)
|
|
76
|
+
[subject-slug].md # Immutable filename, mtime = last message date
|
|
77
|
+
contacts/ # Per-contact context docs
|
|
78
|
+
[name]/
|
|
79
|
+
AGENTS.md # Relationship, tone, topics, notes
|
|
80
|
+
CLAUDE.md # Symlink → AGENTS.md
|
|
81
|
+
drafts/ # Outgoing email drafts
|
|
82
|
+
[YYYY-MM-DD]-[subject].md
|
|
83
|
+
for/ # Collaborator submodules (outgoing)
|
|
84
|
+
[gh-user]/ # submodule → {owner}/to-{collab-gh}
|
|
85
|
+
conversations/*.md
|
|
86
|
+
drafts/*.md
|
|
87
|
+
AGENTS.md
|
|
88
|
+
voice.md
|
|
89
|
+
by/ # Collaborator submodules (incoming, planned)
|
|
90
|
+
manifest.toml # Thread index (generated by sync)
|
|
91
|
+
.sync-state.json # IMAP sync state
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Writing Voice
|
|
95
|
+
|
|
96
|
+
See `voice.md` (committed) for tone, style, and formatting guidelines.
|
|
97
|
+
|
|
98
|
+
## Safety Rules
|
|
99
|
+
|
|
100
|
+
- **Never send email directly.** Always save as a Gmail draft for review first.
|
|
101
|
+
- **Never guess at intent.** If the right response is unclear, ask rather than assume.
|
|
102
|
+
- **Never share conversation content** outside this local environment (no third-party APIs) unless explicitly instructed.
|
|
103
|
+
|
|
104
|
+
## Environment Setup
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
cp accounts.toml.example accounts.toml # configure your email accounts
|
|
108
|
+
uv sync
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
See README.md for full config reference (accounts.toml, contacts.toml, Gmail OAuth).
|
|
112
|
+
|
|
113
|
+
## Sync Behavior
|
|
114
|
+
|
|
115
|
+
- **Immutable filenames**: Slug derived from subject on first write, never changes.
|
|
116
|
+
Thread identity tracked by `**Thread ID**` metadata inside the file.
|
|
117
|
+
- **File mtime**: Set to last message date via `os.utime()`.
|
|
118
|
+
- **Multi-label accumulation**: Thread fetched from multiple labels/accounts accumulates all in metadata.
|
|
119
|
+
- **Incremental by default**: Tracks IMAP UIDs per-account in `.sync-state.json`. `--full` re-fetches everything.
|
|
120
|
+
- **Streaming writes**: Each message merged immediately. If sync crashes, state is not saved; next run re-fetches.
|
|
121
|
+
- **Shared label routing**: Labels in `collaborators.toml` route to `correspondence/for/{gh-user}/conversations/`.
|
|
122
|
+
Supports `account:label` syntax for per-label account binding.
|
|
123
|
+
- **Dedup**: Messages deduplicated by `(sender, date)` tuple when merging into existing files.
|
|
124
|
+
- **Slug collisions**: Different threads with same slug get `-2`, `-3` suffix.
|
|
125
|
+
- **Orphan cleanup**: On `--full`, files not touched during sync are deleted.
|
|
126
|
+
|
|
127
|
+
## Conversation Markdown Format
|
|
128
|
+
|
|
129
|
+
```markdown
|
|
130
|
+
# [Subject]
|
|
131
|
+
|
|
132
|
+
**Labels**: [label1, label2]
|
|
133
|
+
**Accounts**: [account1, account2]
|
|
134
|
+
**Thread ID**: [thread key]
|
|
135
|
+
**Last updated**: [RFC 2822 date]
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## [Sender Name] — [Date]
|
|
140
|
+
|
|
141
|
+
[Body text]
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## [Reply sender] — [Date]
|
|
146
|
+
|
|
147
|
+
[Body text]
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Draft Format
|
|
151
|
+
|
|
152
|
+
Drafts live in `correspondence/drafts/` (private) or `correspondence/for/{gh-user}/drafts/` (collaborator).
|
|
153
|
+
Filename convention: `[YYYY-MM-DD]-[slug].md`.
|
|
154
|
+
|
|
155
|
+
```markdown
|
|
156
|
+
# [Subject]
|
|
157
|
+
|
|
158
|
+
**To**: [recipient]
|
|
159
|
+
**CC**: (optional)
|
|
160
|
+
**Status**: draft
|
|
161
|
+
**Author**: brian
|
|
162
|
+
**Account**: (optional — account name from accounts.toml, e.g. "personal")
|
|
163
|
+
**From**: (optional — email address, used to resolve account if Account not set)
|
|
164
|
+
**In-Reply-To**: (optional — message ID)
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
[Draft body]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Status values: `draft` -> `review` -> `approved` -> `sent`
|
|
172
|
+
|
|
173
|
+
## Collaborators Config
|
|
174
|
+
|
|
175
|
+
The TOML section key is the collaborator's GitHub username. `repo` is auto-derived as
|
|
176
|
+
`{owner_gh}/to-{collab_gh}` if omitted.
|
|
177
|
+
|
|
178
|
+
```toml
|
|
179
|
+
[alex-gh]
|
|
180
|
+
labels = ["for-alex"]
|
|
181
|
+
name = "Alex"
|
|
182
|
+
account = "personal" # optional — bind ALL plain labels to one account
|
|
183
|
+
|
|
184
|
+
[bot-agent]
|
|
185
|
+
labels = ["for-bot", "proton-dev:INBOX"] # account:label scopes to one account
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Label scoping**: `account:label` syntax binds a label to one account.
|
|
189
|
+
Plain labels use the collaborator-level `account` field, or match all accounts if unset.
|
|
190
|
+
|
|
191
|
+
## Package-Level Instruction Files
|
|
192
|
+
|
|
193
|
+
Each subpackage can contain its own `AGENTS.md` with package-specific conventions.
|
|
194
|
+
Keep the root `AGENTS.md` focused on cross-cutting concerns.
|
|
195
|
+
|
|
196
|
+
**Dual-name convention:** `AGENTS.md` is canonical (committed). `CLAUDE.md` is a symlink.
|
|
197
|
+
Personal overrides: `CLAUDE.local.md` / `AGENTS.local.md` (gitignored).
|
|
198
|
+
|
|
199
|
+
**Actionable over informational.** Instruction files contain the minimum needed to generate
|
|
200
|
+
correct code. Reference material belongs in `README.md`.
|
|
201
|
+
|
|
202
|
+
**Update with the code.** When a change affects patterns, conventions, or module boundaries,
|
|
203
|
+
update instruction files as part of the same change.
|
|
204
|
+
|
|
205
|
+
**Stay concise.** Combined root + package files should stay well under 1000 lines.
|
|
206
|
+
|
|
207
|
+
## Conventions
|
|
208
|
+
|
|
209
|
+
- Use `uv run` for script execution, never bare `python`
|
|
210
|
+
- Use `msgspec.Struct` for all data types — not dataclasses or TypedDict
|
|
211
|
+
- Use `ruff` for linting and formatting
|
|
212
|
+
- Use `ty` for type checking
|
|
213
|
+
- Keep sync, draft, and cloudflare logic in separate subpackages
|
|
214
|
+
- Do not commit `.env`, `accounts.toml`, `contacts.toml`, `CLAUDE.local.md` / `AGENTS.local.md`, or `correspondence`
|
|
215
|
+
- Scripts must be runnable directly: `uv run src/sync/imap.py`
|
|
216
|
+
- Commits that include a version change should include the version number in the commit message
|
|
217
|
+
- Use `BREAKING CHANGE:` prefix in VERSIONS.md entries for incompatible changes
|
|
218
|
+
|
|
219
|
+
## .gitignore
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
.env
|
|
223
|
+
accounts.toml
|
|
224
|
+
contacts.toml
|
|
225
|
+
CLAUDE.local.md
|
|
226
|
+
AGENTS.local.md
|
|
227
|
+
correspondence
|
|
228
|
+
*.credentials.json
|
|
229
|
+
.venv/
|
|
230
|
+
__pycache__/
|
|
231
|
+
```
|
corrkit-0.5.0/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENTS.md
|
corrkit-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Brian Takita
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
corrkit-0.5.0/Makefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include ./.make/common.mk
|