v0.3.41 9fa3d04

AGENTS.md RawHistoryFolder

Working Agreement for zot

This file defines how automated coding assistants should work in this repository. Treat it as a practical operating manual, not a substitute for reading the code.

Product intent

zot is a compact Go coding-agent harness. Changes should preserve its defining properties:

  • one portable binary
  • a provider-neutral agent engine
  • a terminal UI without a framework dependency
  • extensions that communicate through subprocess JSON-RPC
  • predictable behavior on macOS, Linux, and Windows
  • a small dependency and operational footprint

Prefer a narrow, explicit implementation over a generalized subsystem. New abstractions must earn their cost through a real boundary or repeated use.

Starting a task

Build context before editing:

  1. Inspect git status --short. Existing modifications may belong to the user or another agent.
  2. Locate and read every AGENTS.md that governs the target path.
  3. Read the owning implementation, nearby tests, and any user-facing documentation for the behavior.
  4. Reproduce reported failures when feasible. Record expected behavior separately from observed behavior.
  5. For GitHub work, inspect the issue or pull request with gh if it is available. Do not change branches merely to review a pull request.

Do not use a search result or one function as a complete model of a feature. Follow calls across package boundaries and inspect persisted or streamed representations when relevant.

Code ownership map

Put behavior in the package that owns the concern:

Area Responsibility
packages/core Agent loop, messages, tool contracts, events, confirmation, sessions, compaction
packages/provider Provider clients, wire formats, streaming, retries, model metadata and discovery
packages/provider/auth Login flows, credential lookup, refresh, and storage
packages/agent CLI configuration, model selection, runtime assembly, RPC, and zotfiles
packages/agent/modes Interactive, print, JSON, dialog, bot, and Telegram interfaces
packages/agent/extensions Extension process lifecycle and host integration
packages/agent/extproto Extension wire protocol
packages/agent/ext Public extension SDK
packages/agent/skills Skill discovery and loading
packages/agent/swarm Background-agent state, supervision, and persistence
packages/agent/tools Built-in tools, permission checks, and jail behavior
packages/tui Terminal input, layout, rendering, markdown, themes, and images
packages/ignore Ignore-pattern matching

Provider quirks must not leak into packages/core. Terminal escape handling and visual layout belong in packages/tui. Avoid making the interactive mode a catch-all when a focused package can own the behavior.

Correctness contracts

Some parts of zot require extra care because small mistakes corrupt state or weaken user protections.

Agent events and sessions

  • Keep streamed events and stored transcripts structurally valid.
  • Preserve tool-call and tool-result pairing, including cancellation and error paths.
  • Maintain compatibility with existing session files unless a migration is explicitly part of the task.
  • Validate replay, resume, fork, import, and export paths when changing shared session structures.

Providers

  • Keep request construction, response parsing, streaming state, and retry classification inside packages/provider.
  • Never assume two OpenAI-compatible services have identical edge behavior.
  • When changing model metadata, verify provider ID, model ID, context size, output limit, reasoning support, routing, and pricing independently.
  • Tests must use local servers or fixtures. Do not make paid or credentialed API calls.

Credentials and private data

  • Treat API keys, OAuth tokens, session text, extension payloads, and local state as sensitive.
  • Never include secrets in logs, fixtures, snapshots, errors, or commits.
  • Credential files must retain restrictive permissions where the platform supports them.
  • Test authentication with synthetic values and isolated temporary directories.

Tools and confinement

  • Permission checks must fail closed.
  • Resolve path and symlink behavior before allowing filesystem access.
  • Jail mode is an accident-prevention guardrail, not a security sandbox. Documentation and errors must not claim stronger isolation.
  • Preserve confirmation semantics across every mode. A convenient fallback must not silently grant access.

Extensions and RPC

  • Existing JSON-RPC and extension clients are compatibility surfaces.
  • Add fields in a backward-compatible way and tolerate peers that do not send newly introduced fields.
  • Keep stdout machine-readable where it carries protocol data. Diagnostics belong on stderr or in the established event channel.
  • Ensure child processes are cleaned up on normal exit, cancellation, and startup failure.

Terminal behavior

  • Rendering code must account for ANSI sequences, Unicode display width, wrapping, narrow terminals, and partial streamed content.
  • Avoid tests that depend on a developer's terminal capabilities.
  • Changes involving input, resize, clipboard, process control, paths, shells, or signals require inspection of build-tagged counterparts.

Implementation approach

For fixes, locate the earliest broken invariant and test there. A UI symptom may originate in provider parsing, event construction, or session replay. Repair the owning layer rather than masking the symptom downstream.

For features, identify all public surfaces before coding: flags, configuration, slash commands, SDK, RPC, extensions, persisted state, provider behavior, and docs. Implement only the surfaces required for a complete first version.

While editing:

  • Preserve unrelated working-tree changes.
  • Use idiomatic Go and standard-library facilities when they are sufficient.
  • Keep functions and interfaces focused. Do not introduce an interface solely to mock one call unless it improves the production boundary.
  • Return errors with enough context to identify the failed operation, without exposing private data.
  • Thread context.Context through blocking work and honor cancellation.
  • Avoid time-based synchronization in tests. Prefer channels, explicit hooks, or polling with a deadline.
  • Use t.TempDir() and t.Setenv() for isolated tests. Restore package globals in cleanup.
  • Do not perform opportunistic refactors outside the requested change.

If intentional behavior appears removable or requirements conflict materially, ask the user before proceeding.

Validation ladder

Match validation effort to the change, then finish with repository-wide checks when code changed.

  1. Add or update a regression test in the owning package.

  2. During iteration, run the smallest relevant test, for example:

    go test ./packages/provider -run TestName
    
  3. Format every changed Go file with gofmt.

  4. Run the complete suite:

    go test ./...
    

    make test additionally enables the race detector and is preferred for concurrency-sensitive work.

  5. Run go vet ./... for changes involving concurrency, interfaces, formatting calls, unsafe behavior, process lifecycle, or broad runtime wiring.

  6. Before reporting completion, inspect:

    git diff --check
    git status --short
    git diff
    

Do not hide failures, weaken assertions, or claim validation that was not run. If a check cannot run, state the command and the reason.

Documentation-only changes do not require the Go test suite unless they alter generated or executable examples. They still require diff and status review.

Documentation duties

Update documentation in the same change whenever users, integrators, or extension authors would observe different behavior. Relevant locations include README.md, docs/rpc.md, docs/extensions.md, docs/skills.md, docs/themes.md, and docs/zotfiles.md.

Examples must match real flags and schemas. State limitations plainly, especially around sandboxing, provider support, compatibility, and platform differences.

Dependency policy

zot's single-binary design and small footprint are product requirements.

  • Prefer the standard library or existing dependencies.
  • Explain why a new dependency is necessary before adding it.
  • Review transitive dependencies and platform implications.
  • Do not add a TUI framework for behavior the current renderer can support.
  • Keep go.mod and go.sum changes limited to the requested work.

Source-control safety

The working directory may contain changes from other people or agents.

Allowed inspection commands include git status, git diff, git log, git show, and git blame. Avoid destructive or broad commands such as git reset --hard, git clean, git checkout ., and blanket staging.

Do not commit, create or switch branches, rebase, push, tag, or open a pull request unless the user explicitly requests that operation. Permission to edit files is not permission to commit them.

When a commit is requested:

  • include only files changed for the current task
  • stage paths explicitly
  • review the staged diff before committing
  • use a concise imperative subject that describes the behavior
  • never bypass hooks without explicit approval

When a pull request is requested, run the full validation suite first, summarize compatibility and user-visible effects, and mention any failed or skipped checks.

Completion report

A final response should be brief and factual. Include:

  • what changed and where
  • which checks were run and their results
  • any unresolved risk, skipped validation, or follow-up needed

Do not report success while tests are failing. Do not include unrelated cleanup suggestions unless they materially affect the requested work.

source
1# Working Agreement for zot
2
3This file defines how automated coding assistants should work in this repository. Treat it as a practical operating manual, not a substitute for reading the code.
4
5## Product intent
6
7zot is a compact Go coding-agent harness. Changes should preserve its defining properties:
8
9- one portable binary
10- a provider-neutral agent engine
11- a terminal UI without a framework dependency
12- extensions that communicate through subprocess JSON-RPC
13- predictable behavior on macOS, Linux, and Windows
14- a small dependency and operational footprint
15
16Prefer a narrow, explicit implementation over a generalized subsystem. New abstractions must earn their cost through a real boundary or repeated use.
17
18## Starting a task
19
20Build context before editing:
21
221. Inspect `git status --short`. Existing modifications may belong to the user or another agent.
232. Locate and read every `AGENTS.md` that governs the target path.
243. Read the owning implementation, nearby tests, and any user-facing documentation for the behavior.
254. Reproduce reported failures when feasible. Record expected behavior separately from observed behavior.
265. For GitHub work, inspect the issue or pull request with `gh` if it is available. Do not change branches merely to review a pull request.
27
28Do not use a search result or one function as a complete model of a feature. Follow calls across package boundaries and inspect persisted or streamed representations when relevant.
29
30## Code ownership map
31
32Put behavior in the package that owns the concern:
33
34| Area | Responsibility |
35|---|---|
36| `packages/core` | Agent loop, messages, tool contracts, events, confirmation, sessions, compaction |
37| `packages/provider` | Provider clients, wire formats, streaming, retries, model metadata and discovery |
38| `packages/provider/auth` | Login flows, credential lookup, refresh, and storage |
39| `packages/agent` | CLI configuration, model selection, runtime assembly, RPC, and zotfiles |
40| `packages/agent/modes` | Interactive, print, JSON, dialog, bot, and Telegram interfaces |
41| `packages/agent/extensions` | Extension process lifecycle and host integration |
42| `packages/agent/extproto` | Extension wire protocol |
43| `packages/agent/ext` | Public extension SDK |
44| `packages/agent/skills` | Skill discovery and loading |
45| `packages/agent/swarm` | Background-agent state, supervision, and persistence |
46| `packages/agent/tools` | Built-in tools, permission checks, and jail behavior |
47| `packages/tui` | Terminal input, layout, rendering, markdown, themes, and images |
48| `packages/ignore` | Ignore-pattern matching |
49
50Provider quirks must not leak into `packages/core`. Terminal escape handling and visual layout belong in `packages/tui`. Avoid making the interactive mode a catch-all when a focused package can own the behavior.
51
52## Correctness contracts
53
54Some parts of zot require extra care because small mistakes corrupt state or weaken user protections.
55
56### Agent events and sessions
57
58- Keep streamed events and stored transcripts structurally valid.
59- Preserve tool-call and tool-result pairing, including cancellation and error paths.
60- Maintain compatibility with existing session files unless a migration is explicitly part of the task.
61- Validate replay, resume, fork, import, and export paths when changing shared session structures.
62
63### Providers
64
65- Keep request construction, response parsing, streaming state, and retry classification inside `packages/provider`.
66- Never assume two OpenAI-compatible services have identical edge behavior.
67- When changing model metadata, verify provider ID, model ID, context size, output limit, reasoning support, routing, and pricing independently.
68- Tests must use local servers or fixtures. Do not make paid or credentialed API calls.
69
70### Credentials and private data
71
72- Treat API keys, OAuth tokens, session text, extension payloads, and local state as sensitive.
73- Never include secrets in logs, fixtures, snapshots, errors, or commits.
74- Credential files must retain restrictive permissions where the platform supports them.
75- Test authentication with synthetic values and isolated temporary directories.
76
77### Tools and confinement
78
79- Permission checks must fail closed.
80- Resolve path and symlink behavior before allowing filesystem access.
81- Jail mode is an accident-prevention guardrail, not a security sandbox. Documentation and errors must not claim stronger isolation.
82- Preserve confirmation semantics across every mode. A convenient fallback must not silently grant access.
83
84### Extensions and RPC
85
86- Existing JSON-RPC and extension clients are compatibility surfaces.
87- Add fields in a backward-compatible way and tolerate peers that do not send newly introduced fields.
88- Keep stdout machine-readable where it carries protocol data. Diagnostics belong on stderr or in the established event channel.
89- Ensure child processes are cleaned up on normal exit, cancellation, and startup failure.
90
91### Terminal behavior
92
93- Rendering code must account for ANSI sequences, Unicode display width, wrapping, narrow terminals, and partial streamed content.
94- Avoid tests that depend on a developer's terminal capabilities.
95- Changes involving input, resize, clipboard, process control, paths, shells, or signals require inspection of build-tagged counterparts.
96
97## Implementation approach
98
99For fixes, locate the earliest broken invariant and test there. A UI symptom may originate in provider parsing, event construction, or session replay. Repair the owning layer rather than masking the symptom downstream.
100
101For features, identify all public surfaces before coding: flags, configuration, slash commands, SDK, RPC, extensions, persisted state, provider behavior, and docs. Implement only the surfaces required for a complete first version.
102
103While editing:
104
105- Preserve unrelated working-tree changes.
106- Use idiomatic Go and standard-library facilities when they are sufficient.
107- Keep functions and interfaces focused. Do not introduce an interface solely to mock one call unless it improves the production boundary.
108- Return errors with enough context to identify the failed operation, without exposing private data.
109- Thread `context.Context` through blocking work and honor cancellation.
110- Avoid time-based synchronization in tests. Prefer channels, explicit hooks, or polling with a deadline.
111- Use `t.TempDir()` and `t.Setenv()` for isolated tests. Restore package globals in cleanup.
112- Do not perform opportunistic refactors outside the requested change.
113
114If intentional behavior appears removable or requirements conflict materially, ask the user before proceeding.
115
116## Validation ladder
117
118Match validation effort to the change, then finish with repository-wide checks when code changed.
119
1201. Add or update a regression test in the owning package.
1212. During iteration, run the smallest relevant test, for example:
122
123   ```sh
124   go test ./packages/provider -run TestName
125   ```
126
1273. Format every changed Go file with `gofmt`.
1284. Run the complete suite:
129
130   ```sh
131   go test ./...
132   ```
133
134   `make test` additionally enables the race detector and is preferred for concurrency-sensitive work.
135
1365. Run `go vet ./...` for changes involving concurrency, interfaces, formatting calls, unsafe behavior, process lifecycle, or broad runtime wiring.
1376. Before reporting completion, inspect:
138
139   ```sh
140   git diff --check
141   git status --short
142   git diff
143   ```
144
145Do not hide failures, weaken assertions, or claim validation that was not run. If a check cannot run, state the command and the reason.
146
147Documentation-only changes do not require the Go test suite unless they alter generated or executable examples. They still require diff and status review.
148
149## Documentation duties
150
151Update documentation in the same change whenever users, integrators, or extension authors would observe different behavior. Relevant locations include `README.md`, `docs/rpc.md`, `docs/extensions.md`, `docs/skills.md`, `docs/themes.md`, and `docs/zotfiles.md`.
152
153Examples must match real flags and schemas. State limitations plainly, especially around sandboxing, provider support, compatibility, and platform differences.
154
155## Dependency policy
156
157zot's single-binary design and small footprint are product requirements.
158
159- Prefer the standard library or existing dependencies.
160- Explain why a new dependency is necessary before adding it.
161- Review transitive dependencies and platform implications.
162- Do not add a TUI framework for behavior the current renderer can support.
163- Keep `go.mod` and `go.sum` changes limited to the requested work.
164
165## Source-control safety
166
167The working directory may contain changes from other people or agents.
168
169Allowed inspection commands include `git status`, `git diff`, `git log`, `git show`, and `git blame`. Avoid destructive or broad commands such as `git reset --hard`, `git clean`, `git checkout .`, and blanket staging.
170
171Do not commit, create or switch branches, rebase, push, tag, or open a pull request unless the user explicitly requests that operation. Permission to edit files is not permission to commit them.
172
173When a commit is requested:
174
175- include only files changed for the current task
176- stage paths explicitly
177- review the staged diff before committing
178- use a concise imperative subject that describes the behavior
179- never bypass hooks without explicit approval
180
181When a pull request is requested, run the full validation suite first, summarize compatibility and user-visible effects, and mention any failed or skipped checks.
182
183## Completion report
184
185A final response should be brief and factual. Include:
186
187- what changed and where
188- which checks were run and their results
189- any unresolved risk, skipped validation, or follow-up needed
190
191Do not report success while tests are failing. Do not include unrelated cleanup suggestions unless they materially affect the requested work.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close