README.md

keijigakari #

A local-first personal CRM layer, written in Kukicha. The name keijigakari (係り) is the tea-room role of the person who keeps track of each guest — who they are, what they need, and when to follow up.

It is not a new database. It is a thin scheduling-and-digest layer over tools that already exist:

                  ┌─────────────────────────────────────────┐
                  │              OS scheduler                │
                  │   systemd timer (Linux) / launchd (mac)  │
                  └──────────────────┬──────────────────────┘
                                     │ runs daily, on wake
                                     v
  keijigakari digest ── queries ──> mizuya (people, notes, edges)
        │                            bd-kukicha (follow-ups)
        │
        ├── terminal digest (stdout, --json)
        └── (optional) POST to foamy SSE endpoint
Layer Tool Role
People + memory mizuya entities (type: person), observations, relate edges
Follow-ups bd-kukicha bd create issues for promises, "ask about X"
Dates + recurrence keijigakari itself dates table in .keiji/keiji.db, plain SQL window queries
Clock systemd / launchd daily digest, catch-up on wake — the OS already solved sleep
UI terminal (now), foamy (later) digest is text/JSON; foamy integration is a follow-up

What it does #

  1. keiji init — create .keiji/keiji.db (a dates table: entity id, kind, month/day, note) plus the OS timer files (printed to stdout or written with --install).
  2. keiji date add --id sam --kind birthday --month 3 --day 5 — record an important date for a mizuya entity.
  3. keiji digest — one idempotent command: everything due now.
    • dates landing in the next N days (--horizon, default 14)
    • open bd follow-ups (bd list --status open --json)
    • stale people (no observation in --stale-days, default 90; people with no observations at all are always stale)
    • --json is snake_case throughout, e.g. dates, followups, stale, plus a warnings array: absence of a sibling skips its section silently, a sibling that is present but broken (corrupt file, schema drift, bd failing) is reported there instead of disappearing. keiji digest never fails on sibling trouble, only on its own database.
  4. keiji okf — ecosystem watch: scan sibling repos' AGENTS.md frontmatter for stale/missing/unparseable stale_after; opt-in --file-issues files one bd issue per problem, deduped by title.
  5. keiji date list / rm — manage dates.

Monica-parity mapping: dates → important dates; bd issues → reminders and commitments; mizuya → people, notes, relationships. The deliberately-missing pieces (web UI, contact fields) are foamy's job, not this repo's.

Why no scheduler library #

Every in-process scheduler (gocron, robfig/cron) re-implements what systemd and launchd already do, worse for a laptop that sleeps:

  • Persistent=true (systemd) runs a missed job on boot.
  • launchd coalesces missed StartCalendarInterval jobs to one run on wake.

So the clock is delegated to the OS (see os/), and keiji digest is safe to run twice, thrice, or at 3am after a week closed — it only reads. Recurring dates are pure queries (month/day BETWEEN today AND today+N), not schedules to fire.

Install #

Requires the Kukicha compiler on PATH.

git clone <this repo>
cd keijigakari
kukicha build .            # produces ./keijigakari — put it on PATH as `keiji`

Usage #

keiji init                          # creates .keiji/keiji.db
keiji date add --id sam --kind birthday --month 3 --day 5
keiji date add --id sam --kind anniversary --month 6 --day 14 --note "moved to Kyoto"

keiji digest                        # human-readable
keiji digest --json                 # structured output for agents/foamy
keiji digest --horizon 7 --stale-days 30

# Point at sibling databases (defaults assume ../mizuya, ../.beads)
keiji digest --mizuya-db ~/.mizuya/mizuya.db --bd-db ~/work/.beads/beads.db

Daily schedule #

See os/README.md for the systemd timer (Linux) and launchd agent (macOS) templates — including keiji init --install wiring, which writes them to the right locations and prints the enable commands.

Architecture #

main.kuki          — CLI entry: init, digest, date add/list/rm, check
models.kuki        — DateRow, DigestEntry types
schema.kuki        — DDL + initDB for .keiji/keiji.db (dates table only)
store.kuki         — date CRUD + due-window query
digest.kuki        — the digest assembly: dates + bd follow-ups + stale people
mizuya_read.kuki   — read-only queries against a mizuya database
bd_read.kuki       — read-only queries against a beads database
format.kuki        — terminal output

Each read layer opens its sibling database read-only and tolerates its absence — mizuya missing means no stale-people section, bd missing means no follow-up section, a missing dates row for an entity is a warning not an error. keiji digest never writes to either sibling.

5. The OKF watch (keiji okf) #

keiji okf extends the watch to the ecosystem's agent contracts: it scans every directory under the sibling repos root (auto-detected from the keiji database path, overridable with --repos), reads each AGENTS.md, and surfaces contract problems — stale_after expired, missing, or unparseable, a malformed frontmatter block, or a contract that exists but cannot be read (unreadable). Hidden directories (.git and friends) are not repos and are skipped entirely; one bad contract never aborts the scan. With --file-issues, one bd issue is filed per problem, deduped by title, and the created issue ids appear in the --json output under filed.

  • A blank verified: is never an issue — that field is the human sign-off tier and is empty by design for agent-authored docs.
  • Missing AGENTS.md is absence, not error — the repo is skipped.
  • Filing (--file-issues) is the one write surface, and it goes through the bd create CLI — the same contract a human uses — into the repo's own .beads/beads.db, or ~/.beads/beads.db when the repo has none. Dedupe is by title pre-check (beads rejects identical content but would happily accept same-title/different-body as a second issue), so titles carry no day counts and no machine-specific repos root — they are stable across runs and clones; closing an issue while the contract is still stale refiles it on the next scan.

Status #

v0 skeleton — schema, date CRUD, and the digest pipeline work end-to -end; OS templates and the init flow are included but --install is planned. Foamy SSE push is a follow-up.