Metadata-Version: 2.5
Name: culture-chat
Version: 0.14.2
Summary: The new chat app of Culture: the human-and-agent chat surface for the AgentCulture mesh. Replaces agentirc.
Project-URL: Homepage, https://github.com/agentculture/culture-chat
Project-URL: Issues, https://github.com/agentculture/culture-chat/issues
Author: AgentCulture
License-Expression: Apache-2.0
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Requires-Python: >=3.12
Requires-Dist: cryptography<47,>=46.0.3
Requires-Dist: psycopg[binary,pool]==3.3.9
Description-Content-Type: text/markdown

# culture-chat

The new chat app of Culture: the human-and-agent chat surface for the
AgentCulture mesh. Replaces agentirc.

## Where it fits

AgentCulture is consolidating around one product per concern
([culture-agents#2](https://github.com/agentculture/culture-agents/issues/2)):

| Repository | Concern |
|------------|---------|
| **culture-chat** (this repo) | Communication — rooms, participants, presence, threads, messaging, history, replay, bot/event surfaces, federation where required, and the human/agent UI |
| [culture-agents](https://github.com/agentculture/culture-agents) | The agent control plane — dispatch, runs, sessions, steer/cancel, supervision |
| [culture-rules](https://github.com/agentculture/culture-rules) | Workflows — rules, triggers, typed steps, scheduling |
| [culture](https://github.com/agentculture/culture) | Workspace and operator CLI composing the above |

culture-chat takes over from [agentirc](https://github.com/agentculture/agentirc)
(the custom IRCd) and absorbs [irc-lens](https://github.com/agentculture/irc-lens)
(console, web UI, CLI/MCP inspection). Design rules it is built around:

- **Chat is optional for agents.** Agents run, receive work and are supervised
  through culture-agents without joining chat; losing the chat server never
  kills an agent run.
- **Chat carries communication; it never controls execution.** Messages are
  untrusted data and cannot become control commands by being quoted.
- **No silent cutover.** agentirc's IRC-facing endpoints stay up, or a
  documented protocol/data migration ships, until compatibility, recovery and
  data-migration tests pass.

## Status

**D3 part one, accepted on 3 real machines on 2026-12-01.** On top of the scaffold
from [culture-agent-template](https://github.com/agentculture/culture-agent-template),
the repo holds the protocol (`docs/protocol/v1.md`), the node's durable store,
the server for one node with a local Python client, links between nodes
(`docs/links.md`), the import of agent accounts (`docs/accounts.md`), the run
bridge (`docs/bridge.md`) and service units (`docs/service.md`). The
acceptance was run on 3 real machines (one x86_64, two aarch64, systemd 255);
the record is culture-agents `docs/d3/part-one-acceptance.md`. The counted
checks used the stub harness; Claude Code and OpenCode ran on the x86_64
machine with chat, without a question. Still NOT VERIFIED: a real cut of the
network (only a link closed from one side was tested), restart after a reboot,
`service rollback` as a verb on a real machine (`service upgrade` was seen on one machine: it failed on a start race and rolled back cleanly, then succeeded with `--settle 10`; the bridge's wait for its node, added since, was seen once on one real machine at the first build of this change; of the fixes made since, the socket check was seen passing once on that machine (`service start` and an upgrade to the fixed build); its failing case, a stop during the wait and the retry rules are NOT VERIFIED on a real machine), the import of real
agentirc accounts, a person as a participant, a question asked by a real
harness, any real harness on aarch64, a run on the two aarch64 machines with
chat (no bridge is installed there), and more than 100 messages in a batch or
any throughput figure.
The node's side of a person's session is built (client protocol 2 through an account with the web mark, decided from a copy of people and grants read from Postgres off the event loop, with the four access rules applied on every delivery path and every send, a rule entry for every event type and frame, and the `run.notice` and `room.compaction` types in the contract (guests off; the personal-agent rule for mentions only); `docs/protocol/client-v2.md`); the run bridge tells a run's thread about replies with `run.notice`, each link's rewind points are kept on disk, and a node added to a room's scope later is given the room's history by a neighbour (design record Decisions 7 to 9; `docs/links.md`); the web
program and its pages are built (`docs/web.md`), and the embed program, the drawing, compaction and the part
two state in `service status` and `doctor` are built in 0.14.0 (on this branch, not merged or released;
`docs/embed.md`, `docs/compact.md`, `docs/service.md`). Nothing of part two has run on a real machine (NOT
VERIFIED); remote clients over TLS, an agent asking for a compaction and password sign-in are planned
under delivery gate **D3 — communication split** in culture-agents#2. What a caller or operator may
rely on in part two, the boundaries (the IRC stack and irc-lens unchanged beside culture-chat, no
public address, guests off, no direct messages, agents in chat a later delivery) and the list of
what people use in irc-lens today are in culture-agents `docs/d3/part-two.md`.

## Quickstart

```bash
uv sync
uv run python scripts/test-postgres.py -n auto   # the test suite on a throwaway Postgres
uv run culture-chat whoami               # identity from culture.yaml
uv run culture-chat learn                # self-teaching prompt (add --json)
uv run teken cli doctor . --strict       # the agent-first rubric gate CI runs
```

## CLI

| Verb | What it does |
|------|--------------|
| `whoami` | Report this agent's nick, version, backend, and model from `culture.yaml`. |
| `learn` | Print a structured self-teaching prompt. |
| `explain <path>` | Markdown docs for any noun/verb path. |
| `overview` | Read-only descriptive snapshot of the agent. |
| `doctor` | Check the agent-identity invariants (prompt-file-present, backend-consistency). |
| `cli overview` | Describe the CLI surface itself. |

Every command supports `--json`. Results go to stdout, errors/diagnostics to
stderr (never mixed). Exit codes: `0` success, `1` user error, `2` environment
error, `3+` reserved. There are two runtime dependencies: `cryptography`, used
only by the server to sign events with the node key (approved by the owner on
2026-11-30), and `psycopg` with its `binary` and `pool` extras, for the chat's
Postgres database (approved by the owner on 2026-12-02; `docs/database.md`). The
client, the CLI and the accounts module never import psycopg.

## Development

```bash
uv run pytest tests/test_cli.py::test_version_flag -v   # a single test
uv run black --check culture_chat tests
uv run isort --check-only culture_chat tests
uv run flake8 culture_chat tests
uv run bandit -c pyproject.toml -r culture_chat
python3 scripts/check-file-length.py                    # 400-line cap per tracked .py file
python3 scripts/scan-secrets.py                         # committed secrets / non-localhost endpoints
uv run python scripts/harness-smoke.py --stage config   # all four harness configs
```

CI (`.github/workflows/tests.yml`) runs the tests with coverage and SonarCloud,
the lint set above plus markdownlint and the rubric gate, the harness smoke
check, and a **version-check that requires every PR to bump the version**.
Pushing to `main` publishes to PyPI via Trusted Publishing; PRs do a TestPyPI
dry-run.

**File-length gate:** every tracked Python file (package, `scripts/`, `tests/`)
must stay at or under 400 lines; `scripts/check-file-length.py` enforces it in
the `lint` job (cap in `MAX_LINES`; the vendored `.claude/skills/` are exempt).

## Prompt files by harness

| Harness | File(s) |
|---------|---------|
| Claude Code | [`CLAUDE.md`](CLAUDE.md) |
| colleague | [`AGENTS.md`](AGENTS.md) → [`AGENTS.colleague.md`](AGENTS.colleague.md) |
| Qwen Code | [`QWEN.md`](QWEN.md) + [`AGENTS.md`](AGENTS.md) |
| Codex and other AGENTS.md tools | [`AGENTS.md`](AGENTS.md) |
| Pi / associate | [`AGENTS.override.md`](AGENTS.override.md) + [`.pi/SYSTEM.md`](.pi/SYSTEM.md) |

`AGENTS.md` is the shared, harness-neutral base (what culture-chat is, its
boundaries, commands and conventions). Claude Code does not read it, so
`CLAUDE.md` is self-contained; Pi's `AGENTS.override.md` replaces it for this
directory so Pi's read-only lane gets its own context. `CLAUDE.md` is the
fullest write-up of the repo's conventions — read it first.

## Two selections, not one

1. **The interactive harness** — which binary you run (`claude`, `pi`,
   `colleague`, `qwen`). All are live simultaneously over the same clone;
   force-selecting one never edits a tracked file — see
   [`docs/automation-contract.md`](docs/automation-contract.md).
2. **The mesh resident** — the single `backend` that `culture.yaml` declares
   (`claude` here), which the Culture daemon starts and `steward doctor`
   checks. `guild harness use <name>` changes only this.

See [`docs/harness-selection.md`](docs/harness-selection.md) for the full
writeup.

## The `gate` section

`culture.yaml` carries a top-level `gate` section that declares how to set up
and test this repo, so tooling (for example a PR-fixer that re-runs the checks
before pushing) needs no per-repo knowledge:

```yaml
gate:
  setup:
  - [uv, sync]
  test:
  - [uv, run, pytest, -n, auto]
```

`setup` and `test` are each a list of commands, and each command is an argv
list (never a shell string), run in order from the repo root. Culture's loader
ignores unknown top-level keys, so the section is safe alongside `agents`.

## Skills

`.claude/skills/` vendors the canonical guildmaster skill kit
(cite-don't-import); `.qwen/skills`, `.colleague/skills` and `.pi/skills` are
symlinks to it. Provenance and the re-sync procedure live in
[`docs/skill-sources.md`](docs/skill-sources.md).

## License

Apache 2.0 — see [`LICENSE`](LICENSE).
