Tools
Project Context
Agent-scoped project context for OpenClaw: capture, checkpoints and lifecycle
README
# OpenClaw Project Context
Private plugin project for a secure, agent-scoped project context workflow inspired by ChatGPT Projects.
## Goal
Let a user create and work inside a project through the OpenClaw agent already in use. The active agent determines the project domain:
| Agent | Domain | Example code |
|---|---|---|
| `main` | A | `A004` |
| `privat` | P | `P008` |
| `beruflich-work` | B | `B005` |
Projects live inside that agent's own workspace. Context is isolated to the selected project and the current conversation.
## Included workflow
- Create a project from natural language or `/project create <name>`; creation selects it for the current conversation.
- Show a visible project status card with `/project status`.
- Capture a proposed summary from the visible conversation. The agent displays a preview; nothing is written until the owner runs `/project capture confirm`. Use `/project capture cancel` to discard it.
- Each confirmed capture is archived under `history/captures/`; `KONTEXT.md` is replaced with a compact working snapshot rather than appended. The first capture also preserves the prior context under `history/legacy/`.
- Newly confirmed decisions are stored separately under `history/decisions/`. Capture history, legacy context, and decisions are excluded from automatic prompt loading; use `/project history`, `/project history legacy`, or `/project decisions` to inspect them on demand.
- Close out a project with a preview and explicit confirmation. The approved closeout is saved, then the current conversation's project selection is cleared.
- Archive and restore projects; move a project to a recoverable trash and restore it later. Context loading is stopped as soon as a project leaves the active state.
- Merge two active projects in the same agent. The source context and reference are appended as quoted data to the target, then the source is archived.
- Move a project between configured agents. The destination receives a newly allocated A/P/B code and copied safe project assets; after the copy is verified, the source is archived with a destination reference.
- Doctor skips a directory only when it carries a private, owner-controlled `.awf-project-fixture.json` marker with schema `awf.project-fixture.v1`, kind `test-fixture`, matching agent and project IDs, and a non-empty reason. Skipped fixture IDs are listed in the result; an invalid marker does not hide the project.
- Run `/project doctor` for read-only checks of project state, references, codes, permissions, context files, and lifecycle logs. Each finding names its project; `/project doctor json` (or the tool's `format: 'json'`) returns the same data machine-readable. Doctor also reports the plugin's own release integrity separately from project findings.
- `/project status` names why no context is active: `no-selection`, `selection-expired`, or `state-generation-changed`.
- Doctor reports archive counts and total history size and flags projects above 2 MiB. Archives are reported, never pruned automatically; `/project history legacy` lists at most 50 records but states the total.
- Doctor shows the loaded plugin version next to the installed manifest and flags `plugin-version-drift` until the Gateway is restarted after an update.
- Every status transition is appended to `history/lifecycle.jsonl` (from/to, generation, timestamp, merge/move detail). Doctor warns when the log is unreadable or behind the project state. A log write failure is reported in the command result; the state change remains authoritative.
- Run `/project repair` for a preview of limited safe repairs. `/project repair confirm` applies only owner-only permission fixes and creation of a minimal missing `KONTEXT.md`; ownership, symlink, reference, and content problems require manual review.
- Run `/project help` for the command list and `/project list` for active projects in the current agent.
- Configure agent-specific code models with `/project config set prefix model AXXX`, `/project config rename prefix AXXX BXXYY`, and `/project config delete prefix AXXX`. X/Y positions are sequential decimal digits. Renamed/deactivated models remain as valid legacy codes for existing projects.
- Configure the future-project location with `/project config set location projects-alt`. Locations must be relative, owner-controlled directories inside that agent's workspace. Existing projects stay where they are and remain listed/selectable.
- Link a project to an exact Codex root with `/project config link P001 /srv/work/example-project`; `/project config unlink P001` removes the link. Selecting that root in Codex loads only the matching active OpenClaw project context for the current agent. The Codex Desktop picker still needs the root registered through its UI.
- On later turns, load only `REFERENZ.md` and optional `KONTEXT.md` from the selected project.
- A failed project creation rolls back the created directory and marks the reserved code `abandoned`; the number is never recycled.
- New working snapshots are limited to 16 KiB. Existing larger context remains readable under the 64 KiB safety ceiling until a confirmed capture compacts it; Doctor flags snapshots above 16 KiB.
- Context files are capped at 64 KiB each; this is the per-file read and write ceiling. For the prompt, reference and context are capped at 24 KiB each and truncated with an explicit marker.
- A failed cross-agent move keeps its partial destination in the workspace `.project-trash/` instead of deleting it.
- Keep allocation append-only and refuse unsafe paths, cross-agent access, invalid files, or stale authority.
- Command and tool results are German. Technical labels (`Release:`, `History:`, `integrity:`, `active`/`archived`/`trash`) and low-level validation errors remain in English.
Capture uses only the conversation visible to the agent and its loaded working snapshot. It does not import chat exports, other conversations, or unrelated workspace files. Captured summaries are quoted as data and cannot change agent instructions. Archives are retained and are not silently pruned.
## Checkpoint compatibility
`/project capture` owns `projects/<id>/KONTEXT.md`. A confirmed capture replaces that file atomically with the compact snapshot headed `# Current project context`; the plugin archives capture history separately and never reads or loads `CHECKPOINTS.md`.
A separate checkpoint helper treats `KONTEXT.md` as read-only. It appends dated events to `projects/<id>/CHECKPOINTS.md` and writes one minimized pointer into the daily memory. Legacy checkpoint blocks inside `KONTEXT.md` remain readable through `--inspect`; the plugin's own archive interface stays `/project history`, `/project history legacy`, and `/project decisions`.
A checkpoint does not refresh the capture snapshot. To include newer work in `KONTEXT.md`, prepare a capture preview and save it only after the owner confirms with `/project capture confirm`.
## Data and security boundaries
- The runtime-supplied active agent and workspace are authoritative.
- A/P/B domains do not cross-read each other's workspaces.
- Project selection is scoped to the active conversation and expires.
- Summary drafts are bound to the agent, conversation, and selected project; they expire after 15 minutes.
- Merge, move, and repair previews are bound to the agent and conversation and expire after 15 minutes. They require `/project transfer confirm` or `/project repair confirm`; transfer previews can be cancelled.
- Code models and project locations are stored per agent in the OpenClaw retained project-config store and are bound to that agent's workspace. Code allocation remains append-only per model; deleted models are disabled rather than erasing historical codes.
- Codex links are stored per OpenClaw project in an owner-only metadata file. The plugin compares only exact canonical paths, and scans links only in the active agent's workspace. It does not read another agent's project files or write to Codex's internal saved-root state.
- Merge is limited to contexts that fit the existing per-file size guard. Move refuses unsafe assets and applies file-count and total-size limits.
- Delete is recoverable trash; this plugin does not permanently erase project data. A failed cross-agent move removes only its own freshly created destination directory.
- Snapshot replacement re-hashes the existing `KONTEXT.md` immediately before the rename, not only when the preview was created.
- `release.json` lists size and SHA-256 for every declared package file. Doctor and `npm run release:verify` report content, version, and manifest/package drift; the manifest is excluded from its own file list.
- Only an authenticated owner command can confirm or cancel a draft.
- Project text is treated as untrusted data.
- No external secret store integration is required.
## Agent portability
The plugin is not limited to the built-in agents (`main`, `privat`, `beruflich-work`).
Any agent id matching `^[a-z0-9][a-z0-9-]{0,63}$` can own projects:
- a configured baseline (`/project config set baseline <prefix> <high-water> <domain>`) always wins;
- otherwise the built-in A/P/B defaults apply;
- for every other agent the prefix is derived from the id (initials, up to four letters,
`highWater` 0, domain = agent id), so the first project becomes e.g. `R001` for `research`;
- the prefix registry still enforces uniqueness. A derived prefix that another agent already
holds fails with a clear message instead of silently renumbering; assign it explicitly;
- `/project doctor` reports an `agent-baseline-derived` warning for such an agent, so an
implicit prefix is visible instead of silent.
## Publishing
The package is publishable metadata-wise (`private: false`, MIT, build metadata,
catalog category). Publishing itself is an explicit owner action and is not part of
any automated flow:
```bash
clawhub login # device flow, once per machine
clawhub package validate . # bund
... (truncated)
tools
Comments
Sign in to leave a comment