AGENTS.md
packages/schema/AGENTS.mdAGENTS.md
Quality
65/100
Scores the file, not the repository.Length
882 words
12 headings · 1 code blocksRepository
193k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# Schema Package Guide23`@opencode-ai/schema` owns browser-safe wire and storage contracts shared by protocol, server, core, and generated SDKs. Keep runtime behavior, service layers, side effects, and host-local implementation details in the domain package that owns them.45## Package Boundary67- Preserve the dependency direction: `@opencode-ai/schema <- @opencode-ai/protocol <- @opencode-ai/server`.8- Schema values should be serializable contract definitions, not service implementations or runtime registries.9- A domain may keep a minimal public wire contract here when SDK generation needs it, but do not move the broader runtime model into Schema just because an event is public. `plugin.added` is the current example: Schema may own the minimum browser-safe event payload, while plugin runtime behavior stays outside Schema.10- The root barrel exports canonical current domain contracts. Specialized event modules, manifests, infrastructure modules, and V1 contracts use direct entrypoints instead of becoming first-class root exports.1112## Current Versus V11314- Current contracts are unversioned: use names like `Session`, `Permission`, `Question`, and identifiers like `Permission.Request`.15- Legacy contracts retained for active compatibility, persistence, or migration are explicitly `V1`: use names like `SessionV1`, `PermissionV1`, and identifiers like `PermissionV1.Request`.16- Do not preserve `V2` as the permanent name for the replacement architecture. Remove `V2` from current namespaces, brands, and identifiers as the contracts are normalized.17- Retained V1 contracts should live under a dedicated `src/v1/` subtree once the V1 isolation PR runs. New/current code must not depend on that subtree.18- V1 coexistence is temporary. Keep compatibility entrypoints only where migration requires them, and delete the V1 subtree when the legacy runtime is retired.19- `@opencode-ai/protocol` and `@opencode-ai/sdk-next` are current `/api/...` surfaces.2021## Events2223- Classify event definitions by protocol role before adding them to a public manifest: `current`, `shared transitional`, or `V1-only`.24- Being emitted by V1 is not enough to include an event in Protocol or SDK Next.25- Keep clearly V1-only events, such as `message.updated` and `message.part.*`, out of the current Protocol/SDK Next event surface unless a current-client requirement is documented.26- Keep compatibility events available only to the existing App/TUI/CLI compatibility surface while they are still needed.27- Preserve a single canonical event definition. Do not duplicate definitions for generation convenience.2829## Module Shape3031- Use one canonical exported value for each contract. Avoid bridge aliases such as `PluginID`, `PluginEvent`, `PtyInfo`, `PtyEvent`, and `SessionTodoInfo`.32- Prefer importing the schema module namespace and reading canonical members, for example `Plugin.ID` or `SessionTodo.Info`.33- Core may compose Schema contracts with runtime behavior into a deliberate domain facade, but the facade must re-export the exact canonical Schema value. Do not create a second schema identity.34- Use flat top-level exports plus the package's existing namespace projection pattern, for example `export * as SessionMessage from "./session-message"`.35- Keep standalone ID modules only when they prevent real cycles or heavy dependency edges. Inline one-off IDs into their owning contract module when no cycle exists.3637## Naming3839- Exported schema values and namespace objects use `PascalCase`.40- Schema-building functions and combinators use `camelCase`.41- The package's static-method combinator is `statics(...)`.42- Keep descriptive schema value names such as `PositiveInt`, `NonNegativeInt`, `AbsolutePath`, `RelativePath`, and `DateTimeUtcFromMillis`.4344## Optional Fields And Defaults4546- Use the package `optional(...)` helper for optional object properties, including nested structs and event payloads, so encoded objects omit `undefined` keys.47- Use raw `Schema.optional(...)` only when preserving `undefined` as an explicitly encoded property is intentional and documented.48- External convenience defaults are normally decode-only with `Schema.withDecodingDefault(...)`.49- Add constructor defaults only when the domain value itself requires construction-time normalization.5051## Public Types5253- Public `Schema.Struct` records use same-name interfaces:5455```ts56 export interface Info extends Schema.Schema.Type<typeof Info> {}57 export const Info = Schema.Struct({ ... })58```5960- Use type aliases for unions, scalars, arrays, branded scalar types, and event payload helper types.61- Closed documented string sets use `Schema.Literals(...)`. If arbitrary strings are valid, document the field as arbitrary rather than listing a closed set.6263## Mutability6465- Public Schema contracts are readonly by default.66- Do not use `Schema.mutable(...)` in public contracts for runtime convenience.67- Runtime code that needs mutation should opt in at the boundary with `Types.DeepMutable`, a purpose-built draft type, or another explicit mutable API.6869## Unknown Values7071- Current public contracts avoid `Schema.Any`.72- Use `Schema.Json` for values that must be JSON-serializable.73- Use `Schema.Unknown` for genuinely opaque values that require consumer-side narrowing.74- Keep `Schema.Any` only at an explicitly unsafe compatibility boundary with a documented reason.7576## IDs And Identifiers7778- Current ID constructors expose `create()`.79- Directional constructors such as `ascending()` or `descending()` remain only where ordering semantics are part of the public contract or compatibility requires the old method.80- New generated ID schemas must validate exactly the prefix they emit, including the underscore.81- Do not tighten legacy loose ID validators without an explicit compatibility and migration decision; existing callers and tests may rely on accepted non-canonical IDs.82- Reusable exported public schemas get stable, domain-qualified identifiers such as `Model.Ref` or `Agent.Color`.83- Public schema identifiers and brands must be unique and stable. Private one-use nested schemas may remain anonymous.8485## Tests For Contract Changes8687- Add focused tests when changing contract behavior or generated surface.88- Cover optional properties omitting `undefined`, no accidental current-contract `Schema.Any`, stable and unique public identifiers, exact facade/schema identity, and current Protocol manifests excluding V1-only events.89
Also in anomalyco/opencode
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| anomalyco/opencodeAGENTS.md · 193k | AGENTS.md | testlint-formatstyletypes+3 | 80/100 | 3 days ago | |
| anomalyco/opencodepackages/app/AGENTS.md · 193k | AGENTS.md | style | 56/100 | 3 days ago | |
| anomalyco/opencodepackages/app/e2e/performance/AGENTS.md · 193k | AGENTS.md | no sections | 16/100 | 3 days ago | |
| anomalyco/opencodepackages/codemode/AGENTS.md · 193k | AGENTS.md | api | 43/100 | 3 days ago | |
| anomalyco/opencodepackages/core/src/tool/AGENTS.md · 193k | AGENTS.md | stylesecurity | 58/100 | 3 days ago | |
| anomalyco/opencodepackages/effect-drizzle-sqlite/AGENTS.md · 193k | AGENTS.md | database | 38/100 | 3 days ago | |
| anomalyco/opencodepackages/llm/AGENTS.md · 193k | AGENTS.md | stylearchtesting-strategygit+1 | 57/100 | 3 days ago | |
| anomalyco/opencodepackages/opencode/src/server/routes/instance/httpapi/AGENTS.md · 193k | AGENTS.md | styleapi | 40/100 | 3 days ago | |
| anomalyco/opencodepackages/opencode/src/session/llm/AGENTS.md · 193k | AGENTS.md | arch | 61/100 | 3 days ago | |
| anomalyco/opencodepackages/opencode/test/AGENTS.md · 193k | AGENTS.md | teststylearchtesting-strategy+1 | 81/100 | 3 days ago | |
| anomalyco/opencodepackages/opencode/test/server/AGENTS.md · 193k | AGENTS.md | teststyleapi | 38/100 | 3 days ago | |
| anomalyco/opencodepackages/opencode/AGENTS.md · 193k | AGENTS.md | styledatabaseapido-not | 81/100 | 3 days ago |
Diff against AGENTS.md Diff against packages/app/AGENTS.md Diff against packages/app/e2e/performance/AGENTS.md Diff against packages/codemode/AGENTS.md Diff against packages/core/src/tool/AGENTS.md Diff against packages/effect-drizzle-sqlite/AGENTS.md Diff against packages/llm/AGENTS.md Diff against packages/opencode/src/server/routes/instance/httpapi/AGENTS.md Diff against packages/opencode/src/session/llm/AGENTS.md Diff against packages/opencode/test/AGENTS.md Diff against packages/opencode/test/server/AGENTS.md Diff against packages/opencode/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| elastic/elasticsearchx-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+2 | 100/100 | 3 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| aaif-goose/gooseAGENTS.md · 52k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| elastic/elasticsearchx-pack/plugin/inference/AGENTS.md · 78k | AGENTS.md | buildtestlint-formatstyle+3 | 100/100 | 3 days ago |
