docs: install DOX framework and initialize the DOX tree

Appends the canonical DOX framework to the root AGENTS.md and creates
child docs for the two durable boundaries: docs/ (ADR numbering,
format and status rules) and tests/ (jiti aliasing to host-package
stubs, what the tests pin, the NOUS_API_KEY fallback gotcha).

tests/stubs/ gets no child doc on purpose: it is a single file whose
only contract is owned by tests/AGENTS.md.
This commit is contained in:
AlexKucera committed 2026-11-25 09:35:17 +01:00
1 parent 690fcdfe22
commit 8bbece7613
3 files changed
+160

No files matched your search

+87
View File
@@ -32,3 +32,90 @@ Live catalog signals, classified in `tierOf`:
- promo: `pricing.original.prompt` greater than the current `pricing.prompt`
`billing_mode: "subscription"` is a separate axis (batch models billed to the plan), not a promo marker.
# DOX framework
- DOX is highly performant AGENTS.md hierarchy installed here
- Agent must follow DOX instructions across any edits
## Core Contract
- AGENTS.md files are binding work contracts for their subtrees
- Work products, source materials, instructions, records, assets, and durable docs must stay understandable from the nearest applicable AGENTS.md plus every parent AGENTS.md above it
## Read Before Editing
1. Read the root AGENTS.md
2. Identify every file or folder you expect to touch
3. Walk from the repository root to each target path
4. Read every AGENTS.md found along each route
5. If a parent AGENTS.md lists a child AGENTS.md whose scope contains the path, read that child and continue from there
6. Use the nearest AGENTS.md as the local contract and parent docs for repo-wide rules
7. If docs conflict, the closer doc controls local work details, but no child doc may weaken DOX
Do not rely on memory. Re-read the applicable DOX chain in the current session before editing.
## Update After Editing
Every meaningful change requires a DOX pass before the task is done.
Update the closest owning AGENTS.md when a change affects:
- purpose, scope, ownership, or responsibilities
- durable structure, contracts, workflows, or operating rules
- required inputs, outputs, permissions, constraints, side effects, or artifacts
- user preferences about behavior, communication, process, organization, or quality
- AGENTS.md creation, deletion, move, rename, or index contents
Update parent docs when parent-level structure, ownership, workflow, or child index changes. Update child docs when parent changes alter local rules. Remove stale or contradictory text immediately. Small edits that do not change behavior or contracts may leave docs unchanged, but the DOX pass still must happen.
## Hierarchy
- Root AGENTS.md is the DOX rail: project-wide instructions, global preferences, durable workflow rules, and the top-level Child DOX Index
- Child AGENTS.md files own domain-specific instructions and their own Child DOX Index
- Each parent explains what its direct children cover and what stays owned by the parent
- The closer a doc is to the work, the more specific and practical it must be
## Child Doc Shape
- Create a child AGENTS.md when a folder becomes a durable boundary with its own purpose, rules, responsibilities, workflow, materials, or quality standards
- Work Guidance must reflect the current standards of the project or user instructions; if there are no specific standards or instructions yet, leave it empty
- Verification must reflect an existing check; if no verification framework exists yet, leave it empty and update it when one exists
Default section order:
- Purpose
- Ownership
- Local Contracts
- Work Guidance
- Verification
- Child DOX Index
## Style
- Keep docs concise, current, and operational
- Document stable contracts, not diary entries
- Put broad rules in parent docs and concrete details in child docs
- Prefer direct bullets with explicit names
- Do not duplicate rules across many files unless each scope needs a local version
- Delete stale notes instead of explaining history
- Trim obvious statements, repeated rules, misplaced detail, and warnings for risks that no longer exist
## Closeout
1. Re-check changed paths against the DOX chain
2. Update nearest owning docs and any affected parents or children
3. Refresh every affected Child DOX Index
4. Remove stale or contradictory text
5. Run existing verification when relevant
6. Report any docs intentionally left unchanged and why
## User Preferences
When the user requests a durable behavior change, record it here or in the relevant child AGENTS.md
## Child DOX Index
| Path | Scope |
|---|---|
| [docs/AGENTS.md](docs/AGENTS.md) | Durable documentation: ADRs and their numbering, format, and status rules |
| [tests/AGENTS.md](tests/AGENTS.md) | Offline test suite: jiti aliasing to host-package stubs, fixtures, and what the tests pin |
+37
View File
@@ -0,0 +1,37 @@
# docs/AGENTS.md
## Purpose
Durable documentation that explains *why* the project is shaped the way it is. Currently: architecture decision records under `docs/adr/`.
## Ownership
- This doc owns the ADR numbering scheme, file format, and status rules.
- The root AGENTS.md owns repo-wide rules and the top-level Child DOX Index.
- Each ADR owns its single decision; nothing outside `docs/` is owned from here.
## Local Contracts
- ADRs live in `docs/adr/` and are numbered sequentially: `0001-slug.md`, `0002-slug.md`, and so on. The next free number is one above the highest existing file.
- Format follows the domain-modeling skill's `ADR-FORMAT.md`: a short title, then one to three sentences giving context, decision, and reason. Optional `Status` frontmatter, `Considered Options`, and `Consequences` sections are added only when they carry real information.
- Existing records:
- `0001-stack.md`: native pi-ai `Provider` over legacy `ProviderConfig`, because the legacy form leads to agent-key minting that Nous retired.
- `0002-license.md`: GPL-3.0-or-later.
- `0003-forge-and-ci.md`: Gitea remote, no CI file yet.
- An ADR records a decision that is hard to reverse, surprising without context, and the result of a real trade-off. Easy-to-reverse choices do not get an ADR.
## Work Guidance
- Add an ADR when a decision meets all three criteria above; do not backfill records for obvious choices.
- When an ADR is superseded, change its status rather than deleting it, and add the replacement under the next number.
- Keep each record to a single decision.
## Verification
- No automated check. Review by reading: every file in `docs/adr/` matches `NNNN-slug.md` and numbering is gap-free and sequential.
## Child DOX Index
| Path | Scope |
|---|---|
| (none) | `adr/` is a flat set of peer records with shared rules that live in this doc |
+36
View File
@@ -0,0 +1,36 @@
# tests/AGENTS.md
## Purpose
Offline unit tests for `index.ts`. They pin the pure logic that has real branching: model mapping, credential construction, and model fetching. No network, no real credentials.
## Ownership
- This doc owns the test suite, its loader setup, and the host-package stub.
- Root AGENTS.md owns `npm run check` (which runs these tests) and repo-wide rules.
- `index.ts` is owned by the root; tests import its exports but never edit it.
## Local Contracts
- `index.test.mjs` loads `index.ts` through jiti, the same TS loader pi uses, because the host packages are not installed in `node_modules`.
- Host imports are aliased to `stubs/pi-ai.mjs`. Alias keys are matched longest-prefix first: `@earendil-works/pi-ai/compat` must be listed before `@earendil-works/pi-ai`, or the bare key swallows the subpath and resolution fails.
- `stubs/pi-ai.mjs` exports only what `index.ts` touches at import time: `envApiKeyAuth`, `createProvider`, `openAICompletionsApi`. It is a type-less stub; correctness of those functions is pi's concern and is verified live, not here.
- Exported functions under test: `toModel`, `toCredential`, `fetchModels`. Anything not exported is not unit-tested.
- Network calls are replaced by assigning `globalThis.fetch` and restored in `finally`.
- `fetchModels` falls back to `process.env.NOUS_API_KEY`, so tests that assert "no network" must delete that variable for the duration and restore it afterwards.
## Work Guidance
- Test behaviour, not implementation. Each test pins one contract from the function under test.
- When adding an export with branching logic to `index.ts`, add a test here in the same change.
- Keep the stub minimal: add an export only when `index.ts` starts importing it at module load.
## Verification
- `npm test` (or `npm run check`) runs `node --test tests/*.test.mjs`. All tests must pass.
## Child DOX Index
| Path | Scope |
|---|---|
| (none) | `stubs/` holds a single file governed by the contracts above |