Metadata-Version: 2.5
Name: dayfile
Version: 0.3.1
Summary: A personal, append-only event log exposed as feed views.
Project-URL: Homepage, https://dayfile.app
Project-URL: Source, https://github.com/dayfile/dayfile
Project-URL: Issues, https://github.com/dayfile/dayfile/issues
Project-URL: Changelog, https://github.com/dayfile/dayfile/blob/master/CHANGELOG.md
Author-email: dayfile <team@dayfile.app>
License-Expression: AGPL-3.0-only
License-File: LICENSE
Keywords: append-only,atom,event-log,json-feed,mcp,self-hosted,sqlite
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.11
Provides-Extra: mcp
Requires-Dist: mcp>=2.3; extra == 'mcp'
Provides-Extra: server
Requires-Dist: cryptography>=50.0.2; extra == 'server'
Requires-Dist: fastapi>=0.162.0; extra == 'server'
Requires-Dist: jsonschema>=4.21; extra == 'server'
Requires-Dist: rfc8785>=0.1.4; extra == 'server'
Requires-Dist: uvicorn>=0.54.0; extra == 'server'
Provides-Extra: web
Requires-Dist: cryptography>=50.0.2; extra == 'web'
Requires-Dist: fastapi>=0.162.0; extra == 'web'
Requires-Dist: jinja2>=3.1.6; extra == 'web'
Requires-Dist: jsonschema>=4.21; extra == 'web'
Requires-Dist: markdown-it-py>=4; extra == 'web'
Requires-Dist: python-multipart>=0.0.33; extra == 'web'
Requires-Dist: rfc8785>=0.1.4; extra == 'web'
Requires-Dist: uvicorn>=0.54.0; extra == 'web'
Description-Content-Type: text/markdown

<p align="center"><img src="https://raw.githubusercontent.com/dayfile/dayfile/master/docs/img/logo.svg" alt="dayfile" height="96"></p>

# dayfile

**[dayfile.app](https://dayfile.app)**: a personal, append-only event log, served as feeds (JSON Feed, Atom,
CloudEvents). Free beta: [see the demo](https://dayfile.app/demo), then sign in with GitHub and get your own log at
`<username>.dayfile.cloud`. Or self-host it: `pip install "dayfile[server]"`, below.

Anything that can send an HTTP request can add events: a script, a webhook, a device, an AI assistant over MCP. The log
is the source of truth; feeds are projections of it, addressed by URL queries such as
`/feed.json?tag=todo&status=open&within=7d`. dayfile keeps the log, enforces who may write and read, and serves the
feeds and the API. Getting events into the right shape from other systems (email, SMS, cron jobs) is the job of whatever
posts them; the repo includes optional adapters for self-hosters.

![Adding events with the dayfile command shows them in the web view; closing a to-do by its six-character id keeps the reason in History](https://raw.githubusercontent.com/dayfile/dayfile/master/docs/img/web-view.gif)

- Append-only SQLite log, enforced by triggers. State changes are new events that point back at the original (close it, replace it, retract it); the status of an event is worked out from that chain.
- Time release (`visible_at`, `expires_at`), idempotent ingest, deny-by-default audiences.
- A JSON API (`GET /events`, long-poll, live SSE stream) next to the feeds, and an MCP server so assistants such as Claude can read and write the log.
- Per-credential feeds: read tokens (Bearer header or `/t/<token>/` path) and write-only tokens.
- Heartbeats: say how often a source should report and dayfile writes an open to-do when it goes quiet.
- A web app (`dayfile[web]`): sign in with GitHub, a log you can read and post to, tokens, feeds (private or public) and settings. It is what runs at [dayfile.app](https://dayfile.app); see below for what runs where.
- Ed25519 signed events and CloudEvents import/export.
- Optional adapters for self-hosters, not part of the hosted service: weather and digest generators, ntfy push.

Design: [docs/SPEC.md](https://github.com/dayfile/dayfile/blob/master/docs/SPEC.md). Milestones and status: [docs/ROADMAP.md](https://github.com/dayfile/dayfile/blob/master/docs/ROADMAP.md).
Contributor rules: [CLAUDE.md](https://github.com/dayfile/dayfile/blob/master/CLAUDE.md).

## How it fits together

![architecture](https://raw.githubusercontent.com/dayfile/dayfile/master/docs/img/architecture.svg)

State changes are new events, never edits:

![lifecycle](https://raw.githubusercontent.com/dayfile/dayfile/master/docs/img/lifecycle.svg)

One URL space, a different view per credential:

![access control](https://raw.githubusercontent.com/dayfile/dayfile/master/docs/img/access.svg)

## Install

Requires Python 3.11 or newer. Pick what the machine is for:

| Install | For | Brings |
|---|---|---|
| `pip install dayfile` | **client**: post to and read a log on a server (yours, or dayfile.app) | nothing else: standard library only |
| `pip install "dayfile[server]"` | **server**: the database, API and feeds, signing | FastAPI, uvicorn, jsonschema, cryptography, rfc8785 |
| `pip install "dayfile[web]"` | **web view** of one log (includes `server`) | the above plus Jinja2, markdown-it-py, python-multipart |
| `pip install "dayfile[mcp]"` | **assistant tools**: `dayfile mcp` and `dayfile suggest` | the `mcp` package |

`uv tool install` and `pipx install` take the same names and keep dayfile out of your system Python.

**Upgrading from 0.2.x:** a server needs `dayfile[server]` now (`dayfile[web]` already includes it).

## Client quick start

Against a log on dayfile.app, or any dayfile server. Make the tokens there; the write token's source must be
`adapter:cli`.

```
pip install dayfile
export DAYFILE_URL=https://USERNAME.dayfile.cloud    # or your own server's address
export DAYFILE_READ_TOKEN=...  DAYFILE_WRITE_TOKEN=...

dayfile add "buy milk" --todo
dayfile list --status open                           # newest first; --tag, --within 7d, --json
dayfile show a1b2c3                                  # the last 6 characters of an id are enough
dayfile close a1b2c3 --note "done" --tag errand
```

`dayfile web` shows that log in a browser, served from your own machine (`pip install "dayfile[web]"`, then paste
your read token at `http://127.0.0.1:8001`).

## Server quick start

```
pip install "dayfile[server]"
export DAYFILE_DB=~/dayfile.db

dayfile add "buy milk" --tag todo --db "$DAYFILE_DB"     # write straight into the local log
dayfile token create --labels self                         # read token: prints the feed URLs once
dayfile token create --labels self --write-source adapter:cli   # write token, for clients
dayfile serve                                              # API and feeds on 127.0.0.1:8000
```

Open the feed URL that `token create` printed (`http://127.0.0.1:8000/t/<read token>/feed.json`, or
`feed.atom`) in a browser or a feed reader. For a server that stays up, use Docker or systemd:
[`deploy/selfhost`](https://github.com/dayfile/dayfile/blob/master/deploy/selfhost).

## Feed URLs

A feed URL answers two questions: **which view** of the log, and **who is asking**.

| Path | Meaning | Example |
|---|---|---|
| `/feed.json`, `/feed.atom`, `/feed.cloudevents` | the default feed: the whole log, filtered by query parameters | `/feed.json?tag=todo&status=open` |
| `/f/<feed>.json`, `.atom`, `.cloudevents` | a **named feed**: a saved filter (tags, status, time window) with a fixed meaning | `/f/todo-open.atom` |
| `/t/<token>/...` | the same feeds, with a **read token in the path**, for feed readers that cannot send headers | `/t/<token>/f/todo-open.atom` |

- `.cloudevents` serves the same page as a CloudEvents 1.0 JSON batch. `POST /events` also accepts CloudEvents (`application/cloudevents+json` or `application/cloudevents-batch+json`). The mapping is in [docs/SPEC.md](docs/SPEC.md).
- Programs should send the token as `Authorization: Bearer <token>` and leave `/t/<token>` out; the path form is a compatibility layer.
- The token decides what you may see (its audience labels), and it can expire or be revoked. Treat a URL that contains one as a secret.
- A named feed is `private` unless you make it `public`. Anyone can read a public feed without a token, but only the events whose audience includes `public`.
- Create and manage named feeds and tokens in the web app (Feeds, Tokens) or with the CLI. The full list of endpoints is on the [docs page](https://dayfile.app/docs) and in [docs/SPEC.md](https://github.com/dayfile/dayfile/blob/master/docs/SPEC.md).

## JSON API

```
curl -H "Authorization: Bearer $READ_TOKEN" 'http://127.0.0.1:8000/events?tag=todo&status=open'
curl -H "Authorization: Bearer $READ_TOKEN" 'http://127.0.0.1:8000/events?since_seq=42&wait=25'   # long-poll
curl -N -H "Authorization: Bearer $READ_TOKEN" http://127.0.0.1:8000/events/stream               # live, SSE
curl -H "Authorization: Bearer $WRITE_TOKEN" -H 'content-type: application/json' \
     -d '{"title": "backup finished", "tags": ["backup"]}' http://127.0.0.1:8000/events   # only title is required
curl -X POST -H "Authorization: Bearer $WRITE_TOKEN" -d '{"body": "why it is done", "tags": ["reviewed"]}' -H 'content-type: application/json' http://127.0.0.1:8000/events/<id>/close      # close a to-do, with an optional note and tags (<id> may be its last 6 characters); /retract for a mistake
```

The stream sends only events that arrive after you connect. To catch up on older ones, read `/events?since_seq=<n>` first (`0` starts from the beginning), then follow the stream.

See the JSON API section of [docs/SPEC.md](https://github.com/dayfile/dayfile/blob/master/docs/SPEC.md).

## Commands

| Command | Purpose |
|---|---|
| `dayfile add` | append an event: with `--db PATH` straight into the database (operator mode), otherwise POST to `--url` using a write token in `$DAYFILE_WRITE_TOKEN` |
| `dayfile list` / `dayfile show ID` | read events from `--url` with `$DAYFILE_READ_TOKEN`, or from `--db PATH` |
| `dayfile close ID` / `dayfile retract ID` | close a to-do or retract a mistake, with `--note` and `--tag` |
| `dayfile serve` | run the API and feeds (`dayfile[server]`) |
| `dayfile web` | run the web view of one log, local or remote, on this machine (`dayfile[web]`) |
| `dayfile token create\|list\|revoke` | manage read and write tokens |
| `dayfile notify` | publish urgent events to ntfy (`$NTFY_URL`) as they become visible |
| `dayfile gen weather\|digest` | generators that write ordinary events back to the log |
| `dayfile key create\|list\|import` | signing keys (`add --sign`) |
| `dayfile mcp` | MCP server on stdio for AI assistants (`pip install dayfile[mcp]`); see below |
| `dayfile suggest` | have any chat model suggest a next step for events tagged `suggest`, or for one event with `dayfile suggest <id>` (`dayfile[mcp]`); see [docs/suggest.md](https://github.com/dayfile/dayfile/blob/master/docs/suggest.md) |
| `dayfile backup DEST` | consistent online copy of the database |
| `dayfile tenant ...` | managed-service operations: create, suspend, limit, usage (see [docs/CLOUD.md](https://github.com/dayfile/dayfile/blob/master/docs/CLOUD.md)) |

## MCP server

Let an assistant such as Claude read and write your log. Both ways use the same seven tools (`dayfile_list_events`, `dayfile_get_event`, `dayfile_new_events`, `dayfile_add_event`, `dayfile_suggest`, `dayfile_close_todo`, `dayfile_retract_event`) and can do only what their tokens allow.

**Hosted (dayfile.cloud).** One address works for everyone: `https://dayfile.cloud/mcp`. You sign in with GitHub, so there is no username to type.

- **Claude:** open Customize, then Connectors, then Add custom connector, paste the address and press Connect. Sign in with GitHub and choose read and write or read only.
- **Claude Code:** `claude mcp add --transport http dayfile https://dayfile.cloud/mcp`, then run `/mcp` to sign in.
- **With tokens, no sign-in:** send `Authorization: Bearer <username>:<read>~<write>`: your username, a colon, then a read token and a write token joined with `~` (read only: the read token alone).

Your log's own address, `https://<username>.dayfile.cloud/mcp`, works the same way, and there the tokens go without the `<username>:` prefix. Disconnect any time under Tokens.

**Local, over stdio.** `dayfile mcp` (`pip install "dayfile[mcp]"`) calls the API at `$DAYFILE_URL` with a read token in `$DAYFILE_READ_TOKEN` and a write token in `$DAYFILE_WRITE_TOKEN`; leave the write token out for a read-only assistant. This is the way to use a self-hosted server without OAuth.

```json
{"mcpServers": {"dayfile": {
  "command": "uvx", "args": ["--from", "dayfile[mcp]", "dayfile", "mcp"],
  "env": {"DAYFILE_URL": "https://myname.dayfile.cloud",
          "DAYFILE_READ_TOKEN": "...", "DAYFILE_WRITE_TOKEN": "..."}}}}
```

Self-hosting the hosted endpoint: set `DAYFILE_MCP=1` (needs `dayfile[mcp]`) and, to offer the sign-in button, `DAYFILE_OAUTH_ISSUER` to the address of a dayfile web app that has accounts.

## Two ways to run it

**Hosted:** [dayfile.app](https://dayfile.app), nothing to run: your log, feeds, tokens and MCP endpoint at `<username>.dayfile.cloud`.
**Self-hosted:** your own server with one log in `$DAYFILE_DB` ([`deploy/selfhost`](https://github.com/dayfile/dayfile/blob/master/deploy/selfhost): `docker compose up` or systemd). The same code serves both. To run a multi-user service of your own, see [docs/CLOUD.md](https://github.com/dayfile/dayfile/blob/master/docs/CLOUD.md).

The web app (`src/dayfile/web`, `pip install "dayfile[web]"`) is a separate process that talks to the API over HTTP. Accounts, GitHub sign-in and the dashboard exist only in the multi-user setup. A self-hosted server runs the API, CLI and feeds, plus an optional web view of your one log (read-only, or able to close to-dos if you give it a write token): set `DAYFILE_SINGLE_LOG=1` and sign in with a read token ([`deploy/selfhost`](https://github.com/dayfile/dayfile/blob/master/deploy/selfhost)). Try it with sample data: `bash deploy/selfhost/try-web-view.sh`. Billing is not built.

## Security notes

- Keep the server on localhost or behind a trusted TLS proxy; tokens in URL paths are a compatibility layer for feed readers.
- Only token hashes are stored; token values are redacted from logs. `.env` is gitignored.

## Contributing

Want to change dayfile itself? Setup, tests and the rules for changes are in [CONTRIBUTING.md](https://github.com/dayfile/dayfile/blob/master/CONTRIBUTING.md).

## License

dayfile is free software under the [GNU Affero General Public License v3](https://github.com/dayfile/dayfile/blob/master/LICENSE) (AGPL-3.0-only).
You may use, modify and self-host it freely. If you run a modified version as a network service,
section 13 requires you to offer its users the corresponding source code.
