agent-doc-system 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +269 -0
  2. package/README.md +97 -112
  3. package/adapters/ansible.mjs +306 -0
  4. package/adapters/cache.mjs +8 -2
  5. package/adapters/contract-consumers.mjs +1 -1
  6. package/adapters/database.mjs +18 -4
  7. package/adapters/events.mjs +1 -1
  8. package/adapters/github-actions.mjs +244 -85
  9. package/adapters/go.mjs +1 -1
  10. package/adapters/index.mjs +5 -2
  11. package/adapters/object-store.mjs +2 -2
  12. package/adapters/python.mjs +1142 -0
  13. package/adapters/resource-client.mjs +1 -1
  14. package/adapters/rust.mjs +987 -0
  15. package/adapters/typescript.mjs +1 -1
  16. package/bin/agentdoc.mjs +60 -44
  17. package/bin/commands.mjs +169 -0
  18. package/bin/usage.txt +5 -3
  19. package/core/audit.mjs +55 -4
  20. package/core/authority/engine.mjs +27 -4
  21. package/core/codes.mjs +11 -0
  22. package/core/compile.mjs +263 -13
  23. package/core/dependents.mjs +42 -0
  24. package/core/descriptors.mjs +5 -2
  25. package/core/discover.mjs +60 -9
  26. package/core/fsx.mjs +27 -4
  27. package/core/graph.mjs +1 -1
  28. package/core/impact.mjs +55 -44
  29. package/core/normative.mjs +171 -0
  30. package/core/query.mjs +18 -8
  31. package/core/scaffold.mjs +87 -22
  32. package/core/sourcescan.mjs +11 -2
  33. package/core/toml.mjs +463 -140
  34. package/core/yaml.mjs +5 -3
  35. package/docs/ADAPTERS.md +232 -7
  36. package/docs/AUTHORITY.md +10 -1
  37. package/docs/BENCHMARK.md +68 -0
  38. package/docs/CI.md +3 -1
  39. package/docs/EVALS.md +33 -2
  40. package/docs/MIGRATION.md +76 -6
  41. package/docs/QUERY.md +53 -4
  42. package/docs/SPEC.md +22 -0
  43. package/docs/assets/readme/agentdoc-hero.webp +0 -0
  44. package/docs/assets/readme/agentdoc-in-action.webp +0 -0
  45. package/docs/assets/readme/how-agentdoc-works.webp +0 -0
  46. package/docs/assets/readme/why-agentdoc.webp +0 -0
  47. package/docs/ci/github-actions.yml +1 -1
  48. package/evals/harness.mjs +32 -6
  49. package/evals/scenarios/fixture-b-03-change-shared-lib.json +8 -1
  50. package/evals/scenarios/fixture-c-03-shared-vocabulary.json +7 -1
  51. package/evals/scenarios/fixture-e-01-change-shared-lib.json +14 -0
  52. package/evals/scenarios/fixture-e-02-change-manifest.json +9 -0
  53. package/evals/scenarios/fixture-e-03-local-module.json +9 -0
  54. package/evals/scenarios/fixture-e-04-ambiguous-crate.json +14 -0
  55. package/evals/scenarios/fixture-f-01-change-shared-lib.json +9 -0
  56. package/evals/scenarios/fixture-f-02-change-manifest.json +9 -0
  57. package/evals/scenarios/fixture-f-03-shadowed-import.json +9 -0
  58. package/evals/scenarios/fixture-f-04-nested-workspace.json +9 -0
  59. package/evals/scenarios/fixture-f-05-alembic-database.json +9 -0
  60. package/evals/scenarios/fixture-f-06-unittest-job.json +9 -0
  61. package/package.json +2 -1
  62. package/schemas/common.schema.json +40 -0
  63. package/schemas/component.schema.json +5 -1
  64. package/schemas/config.schema.json +117 -1
  65. package/skills/agent-doc-system/SKILL.md +5 -1
  66. package/skills/agent-doc-system/references/cli.md +12 -4
  67. package/skills/agent-doc-system/references/create-migrate.md +28 -6
  68. package/templates/ci.yml +1 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,269 @@
1
+ # Changelog
2
+
3
+ All notable changes to AgentDoc are documented here.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and
6
+ the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The
7
+ compiler version is the package version: a graph compiled by one release is
8
+ refused by the next with `AGENTDOC_COMPILER_MISMATCH` until it is recompiled.
9
+
10
+ ## [Unreleased]
11
+
12
+ ## [1.2.0] - 2026-10-27
13
+
14
+ Rust and Python are now supported at the same level as Node and Go. Before
15
+ this release, a Cargo crate or a Python package was invisible to the compiler:
16
+ `agentdoc audit` reported zero units, and a hand-written descriptor produced a
17
+ component with no language, no dependency edges and no verification commands.
18
+
19
+ The release also fixes how a change is routed. `impact` and `query` now follow
20
+ the components that depend on the changed one, not the ones it depends on, and
21
+ recommend those dependents' checks.
22
+
23
+ ### Added
24
+
25
+ - **`rust` adapter** ([#17]). Reads `Cargo.toml` and never runs Cargo or reads
26
+ `Cargo.lock`.
27
+ - A `[package]` is a unit. `[[bin]]`, `src/main.rs` or `src/bin/` make it
28
+ deployable; `[lib]` or `src/lib.rs` make it importable.
29
+ - Workspace members come from every `[workspace]` manifest, including one
30
+ below the repository root (`rust/Cargo.toml` next to other languages).
31
+ - Sibling crates become `buildDependsOn` / `testDependsOn` edges when the
32
+ manifest says so: a `path`, `workspace = true` resolved through the nearest
33
+ `[workspace.dependencies]`, or a `[patch.<registry>]` / `[replace]` path
34
+ redirect inside the repository. `use`, `extern crate` and `<crate>::` paths
35
+ add provenance to those edges but never create one, because Rust cannot
36
+ use a crate the manifest does not declare.
37
+ - Verification commands: `cargo test -p <name>` and `cargo clippy -p <name>`.
38
+ - Resource vocabulary: sqlx, diesel (`diesel.toml`), tokio-postgres,
39
+ deadpool, sea-orm, the `redis` crate and `aws-sdk-s3`.
40
+ - **`python` adapter** ([#18]). Reads `pyproject.toml` (PEP 621 and Poetry),
41
+ `setup.cfg`, `setup.py` and `requirements*.txt`. It never runs Python,
42
+ resolves a lockfile or inspects a virtualenv.
43
+ - Shape comes from evidence. An entrypoint (`[project.scripts]`,
44
+ `__main__.py`, `manage.py`, an ASGI/WSGI app object) makes a unit
45
+ deployable; a build backend plus a package makes it importable.
46
+ - uv workspace members come from the repository root and from workspaces
47
+ below it. A member with no build backend is still a unit.
48
+ - Sibling packages become edges from `[project] dependencies`,
49
+ `[tool.uv.sources]`, Poetry `path` dependencies, `-e <dir>` requirements,
50
+ and `import` / `from` statements. Dev groups and dev/test extras give
51
+ `testDependsOn`. An import that the importing unit provides itself, such
52
+ as a local `utils.py`, is not read as a sibling.
53
+ - Verification commands are derived only from evidence: `pytest`,
54
+ `python -m unittest discover` for unittest-only suites, `ruff check` and
55
+ `mypy`. `uv run` / `poetry run` is prefixed only when the lockfile names
56
+ the tool.
57
+ - Also derived: `requiresPython` when declared, and Alembic migrations as
58
+ database evidence.
59
+ - Resource vocabulary: SQLAlchemy, asyncpg, psycopg, Django `DATABASES`,
60
+ `redis.Redis` and boto3.
61
+ - `agentdoc init` enables `rust` and `python` when it finds their manifests.
62
+ `agentdoc scaffold` names crates and distributions from their manifests and
63
+ types them from their artifact shape: `service`, `library`, or `other` when
64
+ neither is proven. A virtual Cargo or uv workspace manifest is not scaffolded.
65
+ - A reproducible benchmark, `scripts/bench/run.mjs` ([docs/BENCHMARK.md]).
66
+ It clones four public repositories at pinned commits, runs a fresh
67
+ `init` → `scaffold` → `compile`, counts every hand edit the setup still
68
+ needs (zero for all four), checks that the graph is byte-identical across
69
+ compiles, and measures `query` answers.
70
+ - The routing evaluation reports **check selectivity**: the share of the
71
+ repository's checks that the answer for a change contains ([#43]). The
72
+ baseline's verification recall is now scored with the same rule as the
73
+ catalog's. It is 1.0 by construction, because the baseline runs every check.
74
+ - Rust and Python sample repositories (`fixtures/e-rust-workspace`,
75
+ `fixtures/f-python-workspace`), checked in CI and used to test context
76
+ routing ([#23]).
77
+
78
+ ### Changed
79
+
80
+ - **Change routing follows dependents** ([#30], [#25]).
81
+ - A change to a component reaches the components that depend on it,
82
+ transitively, through reverse `buildDependsOn` / `testDependsOn` edges.
83
+ Before, `impact` also listed the components it depends on as affected,
84
+ and did not follow transitive dependents.
85
+ - Dependencies stay visible as typed relations in `query`. They are no
86
+ longer reported as affected components.
87
+ - `query` and `impact` recommend the dependents' checks after the changed
88
+ component's own: every tier for build dependents, unit checks only for test
89
+ dependents.
90
+ - `impact` adds `recommendedVerificationTotal` and
91
+ `recommendedVerificationTruncated`, so a capped list is never mistaken for
92
+ the whole.
93
+ - **`query` markdown shows an entity's context** ([#28]). Resources and
94
+ Systems now list their `docs`, `CONSTRAINTS` and `runbooks`, as components
95
+ already did. Constraints are never capped by default. Docs and runbooks show
96
+ 12 paths each, and `--budget docs=…,constraints=…,runbooks=…` sets explicit
97
+ caps with a `[truncated: x of y]` marker.
98
+ - **`discovery.notUnitRoots` excludes a whole subtree from inferred units**
99
+ ([#27]). An adapter marker or a scaffold proposal at or below an excluded
100
+ root is no longer a unit. A hand-written descriptor below an excluded root
101
+ is still honoured. A descriptor exactly at an excluded root is refused with
102
+ a message that names the exclusion.
103
+ - **GitHub Actions checks are scoped to the components they run for**
104
+ ([#29]). A step becomes a component check only when its command is a
105
+ recognised test, lint or build invocation, scoped by `working-directory`,
106
+ `cd <dir> &&`, a path argument, a package selector (`--filter`, turbo, nx,
107
+ `make -C`) or a `paths:` filter. Repository scripts whose names say what
108
+ they check (`./scripts/test.sh`, `bash scripts/lint.sh`) are recognised
109
+ with the same scoping ([#40]). Anything else is a repository gate.
110
+ - Before, every step was attached to every component whose path or package
111
+ name appeared anywhere in the workflow, including multi-line ops scripts.
112
+ A shell `test -n` was also recorded as a unit test.
113
+ - `impact` on a workflow file now names the components and gates derived
114
+ from it, plus their dependents' checks.
115
+ - **The TOML reader conforms to TOML 1.0** ([#18], [#31]). It reads
116
+ `Cargo.toml`, `pyproject.toml` and `wrangler.toml`, and passes every case of
117
+ the official [toml-test](https://github.com/toml-lang/toml-test) 1.0.0
118
+ suite: 208 valid and 501 invalid documents. Before, it rejected valid
119
+ documents, such as multi-line strings and lowercase date-time delimiters,
120
+ which lost every fact in the file. It also accepted invalid ones, such as a
121
+ trailing comma in an inline table or a table declared twice. Invalid TOML
122
+ is rejected with `AGENTDOC_YAML_PARSE`.
123
+
124
+ ### Fixed
125
+
126
+ - **A unit nested inside another unit no longer leaks its facts into the
127
+ parent** ([#21]). Every per-unit scan stops at nested units, so each file
128
+ belongs to the deepest unit that contains it. Before, an enclosing unit also
129
+ claimed its nested unit's health routes, ports, capabilities, resource and
130
+ migration evidence, imports, contract consumers, TypeScript routes, Ansible
131
+ playbooks and test markers. This affects any layout with nested units, such
132
+ as a service containing a tool package, a Cargo root package with member
133
+ crates below it, or a uv workspace root with its own `[project]`.
134
+ - An Alembic `alembic/versions` directory was listed as a migration location
135
+ but never recognised. It now counts as migration evidence. The evidence file
136
+ is a qualifying `alembic.ini` or `[tool.alembic]` configuration when one
137
+ exists, and otherwise a revision file.
138
+ - A changed migration, including an Alembic revision, now lists the logical
139
+ database its component uses in `impact`'s `affectedResources` ([#30]).
140
+ Before, the list stayed empty.
141
+ - The audit no longer reports a document as orphaned when it is linked only
142
+ from a Resource's or System's `context` ([#28]).
143
+ - `agentdoc scaffold --write` no longer writes descriptors into directories
144
+ listed in `discovery.notUnitRoots` ([#27]).
145
+ - **A fresh setup compiles without hand edits** ([#37], [#38]).
146
+ - `scaffold` now types every unit from its artifact evidence: `service`,
147
+ `library`, or `other` when neither is proven. Before, a Node app without
148
+ `exports` or `main`, or a Go module, was written as `library` and failed
149
+ `validate` straight away.
150
+ - `init` now discovers descriptors with the `*/**/agentdoc.yaml` glob
151
+ instead of an explicit list, and `scaffold` covers every unit an adapter
152
+ declares, including workspace members under `examples/`.
153
+ - A `setup.py` unit is named after the distribution it declares, and the
154
+ `python` adapter reads `name`, `python_requires` and `install_requires`
155
+ inside a one-line `setup(…)` or `setuptools.setup(…)` call ([#41]).
156
+ - On the four public repositories used for benchmarking (tokio-rs/axum,
157
+ pydantic/pydantic-ai, fastapi/full-stack-fastapi-template and
158
+ t3-oss/create-t3-turbo), `init` + `scaffold --write` + `compile` now pass
159
+ with no edits other than choosing each component's placement.
160
+
161
+ ### Upgrading
162
+
163
+ - The compiler version is now `1.2.0`. A graph committed with 1.1.0 fails
164
+ `agentdoc check` with `AGENTDOC_COMPILER_MISMATCH`. Run `agentdoc compile`
165
+ and commit the graph.
166
+ - An existing catalog keeps its adapter list. To use the new adapters, add
167
+ `rust` and/or `python` to `adapters:` in `agentdoc/agentdoc.config.yaml`,
168
+ then run `agentdoc audit`: units that were invisible appear as
169
+ `AGENTDOC_COVERAGE_ZERO` until they have a descriptor.
170
+ `agentdoc scaffold --write` writes those descriptors.
171
+ - If your repository has nested units, recompiling removes facts that were
172
+ wrongly attributed to an enclosing component. Review the affected facts,
173
+ dependency edges and verification commands, and any descriptor or document
174
+ that relied on them.
175
+ - Tools that read `impact --json` will see fewer `affectedComponents`
176
+ (dependencies are gone) and more `recommendedVerification` entries
177
+ (dependents' checks).
178
+ - A unit inferred below a `notUnitRoots` entry, with no descriptor, is no
179
+ longer reported as `AGENTDOC_COVERAGE_ZERO`. If it should be a component,
180
+ write its descriptor, or remove the directory from `notUnitRoots`.
181
+ - If your workflows run checks for specific components, recompiling changes
182
+ which checks are attached to which component. Review the diff: checks that
183
+ were attached only because a path was mentioned elsewhere in the workflow
184
+ move to repository gates.
185
+ - Recompiling always updates the compiler version, source commit and input
186
+ hash. Review the other derived changes, especially in repositories with
187
+ nested units, Alembic migrations or Wrangler TOML manifests: a manifest the
188
+ old TOML reader could not parse now yields facts.
189
+
190
+ ## [1.1.0] - 2026-10-18
191
+
192
+ ### Added
193
+
194
+ - **MIGRATE gates normative requirements and section coverage** ([#5]).
195
+ Documentation checks now state their real scope, and the strict gate refuses
196
+ unverified requirements.
197
+ - **`ansible` adapter** ([#6]). Reads playbooks without running anything and
198
+ derives installed paths and managed services. A requirement with
199
+ `satisfiedBy: [ansible]` and the new `expects` field
200
+ (`installs: <path>` | `service: <name>`) is checked against them, so a missing
201
+ install ends in a conflict instead of `AGENTDOC_REQUIREMENT_UNVERIFIED`.
202
+ - `agentdoc <command> --help` lists each command's flags and exit codes ([#7]).
203
+
204
+ ### Changed
205
+
206
+ - **The CLI rejects unknown flags** ([#7]) and names the closest valid flag. A
207
+ typo such as `check --strcit` no longer silently runs a non-strict check.
208
+ Scripts that passed flags a command does not accept now exit 2.
209
+
210
+ ### Fixed
211
+
212
+ - A committed graph passes CI ([#11]). `check` no longer fails with
213
+ `AGENTDOC_GRAPH_FRESHNESS` after `compile` on a clean checkout, where the
214
+ graph file itself was counted as a changed input.
215
+ - A nested `.github/workflows` directory no longer fails `validate` ([#12]).
216
+ Only the repository-root directory is read, as GitHub does.
217
+
218
+ ### Upgrading
219
+
220
+ - A graph committed with 1.0.0 fails `agentdoc check` with
221
+ `AGENTDOC_COMPILER_MISMATCH` until it is recompiled.
222
+
223
+ ## [1.0.0] - 2026-09-29
224
+
225
+ First public release.
226
+
227
+ ### Added
228
+
229
+ - The machine-installed `agentdoc` CLI for Node 22, 24 and 26, with zero
230
+ runtime dependencies.
231
+ - A deterministic repository graph: repeated compiles of the same tree are
232
+ byte-identical.
233
+ - Evidence separation between AUTHORED documentation, DERIVED facts extracted
234
+ from code, and OBSERVED runtime evidence.
235
+ - A fail-closed authority model: contradictions surface as conflicts and are
236
+ never silently overwritten.
237
+ - `agentdoc query`, which routes minimal, budgeted context for a task, and
238
+ `agentdoc impact`, which reports what a change forces you to keep consistent.
239
+ - CREATE and MIGRATE workflows through `init`, `audit`, `scaffold`,
240
+ `validate`, `compile` and `check`.
241
+ - `agentdoc doctor` for machine diagnostics, and `agentdoc doctor --project`
242
+ for project health.
243
+ - An Agent Skill under `skills/agent-doc-system/`.
244
+
245
+ [Unreleased]: https://github.com/lbframe/agent-doc-system/compare/v1.2.0...HEAD
246
+ [1.2.0]: https://github.com/lbframe/agent-doc-system/compare/v1.1.0...v1.2.0
247
+ [1.1.0]: https://github.com/lbframe/agent-doc-system/compare/v1.0.0...v1.1.0
248
+ [1.0.0]: https://github.com/lbframe/agent-doc-system/releases/tag/v1.0.0
249
+ [docs/BENCHMARK.md]: docs/BENCHMARK.md
250
+ [#5]: https://github.com/lbframe/agent-doc-system/issues/5
251
+ [#6]: https://github.com/lbframe/agent-doc-system/issues/6
252
+ [#7]: https://github.com/lbframe/agent-doc-system/issues/7
253
+ [#11]: https://github.com/lbframe/agent-doc-system/issues/11
254
+ [#12]: https://github.com/lbframe/agent-doc-system/issues/12
255
+ [#17]: https://github.com/lbframe/agent-doc-system/issues/17
256
+ [#18]: https://github.com/lbframe/agent-doc-system/issues/18
257
+ [#21]: https://github.com/lbframe/agent-doc-system/issues/21
258
+ [#23]: https://github.com/lbframe/agent-doc-system/issues/23
259
+ [#25]: https://github.com/lbframe/agent-doc-system/issues/25
260
+ [#27]: https://github.com/lbframe/agent-doc-system/issues/27
261
+ [#28]: https://github.com/lbframe/agent-doc-system/issues/28
262
+ [#29]: https://github.com/lbframe/agent-doc-system/issues/29
263
+ [#30]: https://github.com/lbframe/agent-doc-system/issues/30
264
+ [#31]: https://github.com/lbframe/agent-doc-system/issues/31
265
+ [#37]: https://github.com/lbframe/agent-doc-system/issues/37
266
+ [#38]: https://github.com/lbframe/agent-doc-system/issues/38
267
+ [#40]: https://github.com/lbframe/agent-doc-system/issues/40
268
+ [#41]: https://github.com/lbframe/agent-doc-system/issues/41
269
+ [#43]: https://github.com/lbframe/agent-doc-system/issues/43
package/README.md CHANGED
@@ -1,152 +1,137 @@
1
- # agentdoc — portable documentation & software-catalog system
1
+ # AgentDoc
2
2
 
3
- Zero runtime dependencies. One Node runtime. AgentDoc compiles a repository
4
- into one deterministic graph and routes a path or an entity to the minimum
5
- context needed to change it safely.
3
+ ![AgentDoc — Give coding agents the context they actually need](docs/assets/readme/agentdoc-hero.webp)
6
4
 
7
- It exists to answer one question cheaply and correctly, for an AI coding agent
8
- or a human reviewer:
5
+ **Give coding agents the context they actually need.**
9
6
 
10
- > I am about to change *this*. What do I need to know, what must I keep
11
- > consistent, and which command proves it?
7
+ AgentDoc turns your codebase, docs, contracts, and runtime evidence into a context layer your coding agent can query before it changes anything.
12
8
 
13
- It does that while keeping three kinds of claim apart — what the repository
14
- *claims*, what can be *derived* from code, and what was *observed* running —
15
- and surfacing their disagreements as conflicts instead of guessing.
9
+ [![npm](https://img.shields.io/npm/v/agent-doc-system.svg)](https://www.npmjs.com/package/agent-doc-system) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![node](https://img.shields.io/badge/node-22%20%7C%2024%20%7C%2026-43853d.svg)](https://nodejs.org/)
16
10
 
17
- ## Install the CLI
11
+ ## Give this to your coding agent
18
12
 
19
- The CLI is installed once per machine. Requires Node 22 or newer (22, 24 and
20
- 26 are the tested baselines).
13
+ Paste this into your agent **from the repository you want to use AgentDoc on**:
21
14
 
22
- ```bash
23
- npm install -g github:lbframe/agent-doc-system
24
-
25
- agentdoc --version
26
- agentdoc doctor # machine self-check
15
+ ```text
16
+ Set up AgentDoc for this repository and use it as the context layer for your work.
17
+
18
+ AgentDoc: https://github.com/lbframe/agent-doc-system
19
+
20
+ 1. Read INSTALL_FOR_AGENTS.md and install or upgrade the AgentDoc CLI.
21
+ 2. Read skills/agent-doc-system/SKILL.md.
22
+ 3. Run agentdoc doctor --project and agentdoc audit.
23
+ 4. Use the appropriate CREATE or MIGRATE workflow for this repository.
24
+ 5. Do not invent ownership, architecture, authority rules, or product intent. Ask me only for decisions AgentDoc cannot safely derive.
25
+ 6. Finish setup with agentdoc validate, agentdoc compile, and agentdoc check.
26
+ 7. From now on, use agentdoc query and agentdoc impact before changes, then agentdoc check after changes.
27
+ 8. Report anything unresolved or conflicting instead of guessing.
27
28
  ```
28
29
 
29
- Unpinned installs track `main`. For reproducible CI, pin a tag or commit:
30
- `github:lbframe/agent-doc-system#v1.0.0`.
30
+ That is the intended onboarding path: **give the prompt to the agent, let AgentDoc build the context layer, and keep using it during development.**
31
31
 
32
- The install footprint is the CLI only — `bin/`, `core/`, `adapters/`,
33
- `schemas/`, `templates/`, `evals/`, docs and the agent skill. Nothing is ever
34
- copied into a project that uses AgentDoc.
32
+ ## Why AgentDoc?
35
33
 
36
- ### Have an AI agent install it for you
34
+ Coding agents can read code. The hard part is knowing **what matters for this change**.
37
35
 
38
- Paste this into a capable coding agent:
36
+ Important context is scattered across code, documentation, API contracts, architectural decisions, CI rules, and production reality. Agents either load too much or miss something important.
39
37
 
40
- ```text
41
- Install AgentDoc on this machine from:
42
- https://github.com/lbframe/agent-doc-system
38
+ AgentDoc gives them a map.
39
+
40
+ - **Query the right context** for a file or component.
41
+ - **See the blast radius** before changing code.
42
+ - **Detect drift** between code and documentation.
43
+ - **Surface conflicts** instead of silently guessing.
44
+ - **Verify constraints in CI** before stale knowledge becomes trusted context.
43
45
 
44
- Read INSTALL_FOR_AGENTS.md from that repository and follow it completely.
46
+ ![AgentDoc in action — query, impact, check](docs/assets/readme/agentdoc-in-action.webp)
45
47
 
46
- Do not initialize, inspect, migrate, or modify any software project as part of
47
- this installation task.
48
+ ## Three commands, one workflow
48
49
 
49
- When finished, verify the AgentDoc CLI and report the installed version.
50
+ ```bash
51
+ agentdoc query src/payments/webhook.ts
52
+ agentdoc impact src/payments/webhook.ts
53
+ agentdoc check
50
54
  ```
51
55
 
52
- [`INSTALL_FOR_AGENTS.md`](INSTALL_FOR_AGENTS.md) contains the procedure.
56
+ `query` tells the agent what it needs to know. `impact` shows what the change can affect. `check` verifies that the repository still agrees with itself.
53
57
 
54
- ## Use it in a project
58
+ ## Why not just AGENTS.md or RAG?
55
59
 
56
- From the repository root:
60
+ ![Why AgentDoc](docs/assets/readme/why-agentdoc.webp)
57
61
 
58
- ```bash
59
- cd my-project
60
- agentdoc doctor --project # is there a catalog here, and is it healthy
61
- agentdoc audit # inventory the repo, classify every fact
62
- ```
62
+ AgentDoc is not another documentation file and it is not just semantic search.
63
63
 
64
- Then follow the workflow the audit implies:
64
+ It combines **authored intent**, **facts derived from code**, and **runtime observations** without pretending they are the same thing. When sources disagree, AgentDoc surfaces the conflict instead of choosing a convenient answer.
65
65
 
66
- | workflow | when | entry point |
67
- |---|---|---|
68
- | CREATE | no catalog exists | `agentdoc init`, then `agentdoc scaffold --write` |
69
- | MIGRATE | established repo, scattered or stale docs | `agentdoc audit`, work the report |
70
- | VALIDATE | before committing, in CI | `agentdoc validate` → `compile` → `check` |
71
- | QUERY | before and during a change | `agentdoc query <path-or-ref>` |
72
- | MAINTAIN | after a change | `agentdoc impact <paths>` |
66
+ ## From repository knowledge to agent-ready context
73
67
 
74
- AgentDoc writes **project data only**: `agentdoc/` (configuration and
75
- descriptors you own), `docs/` skeleton files, `.agentdoc/graph.json` (the
76
- compiled artifact), and a CI workflow. The CLI source is never vendored into
77
- your repository.
68
+ AgentDoc turns scattered repository knowledge into task-specific context your coding agent can query, verify, and act on.
78
69
 
79
- The two directories differ in ownership, not just punctuation:
70
+ ![How AgentDoc works](docs/assets/readme/how-agentdoc-works.webp)
80
71
 
81
- - `agentdoc/` is **authored** — configuration, descriptors and observation
82
- sets. Everything in it is a claim you wrote and a reviewer can diff.
83
- - `.agentdoc/` is **generated** — the compiled graph and other build
84
- artifacts. Never edit it by hand; `compile` rewrites it and `check` rejects
85
- a stale or edited one.
72
+ ## What it understands
86
73
 
87
- ## Use it with an AI agent
74
+ AgentDoc reads manifests, contracts and configuration. It never runs your toolchain.
88
75
 
89
- The agent skill is [`skills/agent-doc-system/`](skills/agent-doc-system/SKILL.md).
90
- Install that directory as a skill in your agent harness. It teaches the agent
91
- when to use the CLI, the evidence-class model, the working loop, and the
92
- integrity rules — with deeper material under `skills/agent-doc-system/references/`.
76
+ Support comes from adapters and from built-in contract validation (AsyncAPI needs no adapter).
77
+ - `agentdoc init` picks `node`, `go`, `rust`, `python`, `dockerfile` and `wrangler` from the files it finds.
78
+ - It always includes `database`, `openapi`, `events` and `github-actions`.
79
+ - Add the others in `agentdoc/agentdoc.config.yaml`.
93
80
 
94
- ## What it is built on
81
+ | area | supported |
82
+ |---|---|
83
+ | languages & packages | Node (npm, pnpm workspaces, Turborepo), TypeScript, Go (modules, `go.work`), Rust (Cargo packages and workspaces), Python (`pyproject.toml` with PEP 621 or Poetry, uv workspaces, `setup.cfg` / `setup.py`, `requirements*.txt`) |
84
+ | contracts | OpenAPI, protobuf, GraphQL, AsyncAPI, OIDC discovery |
85
+ | deployment & CI | Dockerfile / Containerfile, `fly.toml`, `Procfile` and similar deploy configs, Cloudflare Wrangler, Ansible playbooks, GitHub Actions |
86
+ | resources | databases (migrations, ORM config, connection evidence), caches, object stores, event subjects |
95
87
 
96
- Most repositories conflate three different kinds of claim, and the confusion
97
- is the single largest source of wrong agent behaviour:
88
+ For each language, AgentDoc derives:
98
89
 
99
- | what | who says it | how it fails |
100
- |---|---|---|
101
- | what the repository **claims** | authored docs, config, manifests | drifts, is aspirational, is not tested |
102
- | what can be **derived** from code | imports, manifests, contracts | heuristic, incomplete, wrong about intent |
103
- | what was **observed** in a running system | schedulers, bindings, live APIs | goes stale, disagrees with intent |
90
+ - the units;
91
+ - whether each one is deployable or importable;
92
+ - dependency edges between sibling units;
93
+ - verification commands taken from the repository's own evidence (`go test`, `cargo test -p`, `pytest`, `python -m unittest`, npm scripts, …).
104
94
 
105
- A claim carries an evidence class, a confidence, and a pointer to its evidence.
106
- When two classes disagree about the same fact, the disagreement is **surfaced
107
- as a conflict**, not reconciled. There is no global precedence order, because
108
- authority depends on the fact: the committed manifest is authoritative for
109
- *intent*, the live scheduler is authoritative for *what fires*, and the
110
- canonical contract is authoritative for the *desired wire surface* while a
111
- live probe is authoritative for *what is deployed today*.
95
+ What every adapter derives, and what it deliberately cannot see, is in [docs/ADAPTERS.md](docs/ADAPTERS.md).
112
96
 
113
- The default is fail-closed. A fact with no governing authority rule and
114
- disagreeing evidence is an error, and no gate passes while it stands.
97
+ ## By the numbers
115
98
 
116
- ## Documentation
99
+ Measured, reproducible, and with no model in the loop. Method and caveats are in [docs/BENCHMARK.md](docs/BENCHMARK.md).
117
100
 
118
- | file | covers |
119
- |---|---|
120
- | [`skills/agent-doc-system/SKILL.md`](skills/agent-doc-system/SKILL.md) | how an agent uses the system |
121
- | [INSTALL_FOR_AGENTS.md](INSTALL_FOR_AGENTS.md) | machine installation, for an AI agent |
122
- | [docs/SPEC.md](docs/SPEC.md) | the normative specification: entities, graph, determinism |
123
- | [docs/AUTHORITY.md](docs/AUTHORITY.md) | evidence classes, conflict semantics, elections |
124
- | [docs/PROVENANCE.md](docs/PROVENANCE.md) | evidence records, pointers, secret handling |
125
- | [docs/QUERY.md](docs/QUERY.md) | the context router, budgets, freshness refusal |
126
- | [docs/MIGRATION.md](docs/MIGRATION.md) | CREATE and MIGRATE workflows |
127
- | [docs/CI.md](docs/CI.md) | the drift gate and its failure modes |
128
- | [docs/ADAPTERS.md](docs/ADAPTERS.md) | writing an adapter, and what must never live in one |
129
- | [docs/EVALS.md](docs/EVALS.md) | the routing benchmark and pre-registered thresholds |
130
- | [docs/COMPARISON-KODA.md](docs/COMPARISON-KODA.md) | measured comparison against the reference corpus |
131
-
132
- ## Fixtures and the golden corpus
133
-
134
- - `fixtures/a-node-ts-postgres` — single Node/TypeScript service, REST, Postgres, GitHub Actions.
135
- - `fixtures/b-go-multi-service` — multi-service Go repository, protobuf contracts, shared library, resources.
136
- - `fixtures/c-alt-monorepo` — deliberately *not* `apps/`+`packages/`+`workers/`, mixed runtimes, inconsistent pre-existing docs.
137
- - `examples/koda` — the profile that represents a large, mature, TypeScript+Go monorepo, including the runtime-observation conflicts that motivated the authority model.
138
-
139
- ## Development
101
+ - **The right context: 100% vs. 58%.** Across 30 routing scenarios (Node, Go, Rust, Python), `query` + `impact` retrieves every fact the change needs. Reading only the touched component retrieves 58%. Noise stays under 9%, against 40%. Every check the change requires is in the answer, and that answer holds about half of the repository's checks (29% on the largest corpus), not all of them. The thresholds were fixed before the first run and have not moved since.
102
+ - **Seconds to map a real repository.** A fresh `init` → `scaffold` → `compile` takes 1.0–4.6 s on four public repositories, from 141 to 5,142 files (axum, pydantic-ai, full-stack-fastapi-template, create-t3-turbo). No edit was needed beyond choosing each component's placement.
103
+ - **A briefing, not a dump.** A `query` answer is about 100–260 tokens: what the change reaches, what to read, and which checks to run.
104
+ - **The same graph every time.** Compiles are byte-identical, and CI can verify it.
105
+ - **Small and strict.** Zero runtime dependencies, a package of about 285 kB packed, 21 adapters, and 709/709 cases on the official TOML 1.0 conformance suite.
106
+
107
+ ## Install manually
108
+
109
+ Requires Node.js 22+.
110
+
111
+ ```bash
112
+ npm install -g agent-doc-system
113
+ agentdoc doctor
114
+ ```
115
+
116
+ Then, inside a repository:
140
117
 
141
118
  ```bash
142
- node --test tests/*.test.mjs # unit, adversarial and mode tests
143
- node evals/run-all.mjs # aggregate routing evaluation (gate)
144
- npm run selfcheck # agentdoc doctor, from the source checkout
119
+ agentdoc audit
145
120
  ```
146
121
 
147
- ## Licence of the design
122
+ AgentDoc also ships with an Agent Skill at [`skills/agent-doc-system/`](skills/agent-doc-system/SKILL.md).
123
+
124
+ ## Documentation
125
+
126
+ - [Getting started & migration](docs/MIGRATION.md)
127
+ - [Authority & conflicts](docs/AUTHORITY.md)
128
+ - [CI & verification](docs/CI.md)
129
+ - [Specification](docs/SPEC.md)
130
+ - [Adapters](docs/ADAPTERS.md)
131
+ - [Benchmark](docs/BENCHMARK.md)
132
+ - [Agent Skill](skills/agent-doc-system/SKILL.md)
133
+ - [Changelog](CHANGELOG.md)
134
+
135
+ ## License
148
136
 
149
- The architecture, the fail-closed discipline, the provenance model and the
150
- warning-acceptance mechanism are extracted from a production catalog system
151
- that proved them at scale. The namespace, schemas, adapters, CLI and authority
152
- model here are new and neutral.
137
+ [MIT](LICENSE) © 2026 lbframe