agent-doc-system 0.0.0-stage → 1.1.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 (124) hide show
  1. package/INSTALL_FOR_AGENTS.md +60 -0
  2. package/LICENSE +21 -0
  3. package/README.md +98 -2
  4. package/adapters/ansible.mjs +306 -0
  5. package/adapters/cache.mjs +27 -0
  6. package/adapters/contract-consumers.mjs +56 -0
  7. package/adapters/database.mjs +116 -0
  8. package/adapters/deploy-config.mjs +34 -0
  9. package/adapters/dockerfile.mjs +26 -0
  10. package/adapters/events.mjs +145 -0
  11. package/adapters/generic.mjs +86 -0
  12. package/adapters/github-actions.mjs +106 -0
  13. package/adapters/go.mjs +91 -0
  14. package/adapters/graphql.mjs +28 -0
  15. package/adapters/index.mjs +56 -0
  16. package/adapters/node.mjs +118 -0
  17. package/adapters/object-store.mjs +64 -0
  18. package/adapters/oidc.mjs +56 -0
  19. package/adapters/openapi.mjs +50 -0
  20. package/adapters/pnpm.mjs +42 -0
  21. package/adapters/protobuf.mjs +35 -0
  22. package/adapters/registry.mjs +27 -0
  23. package/adapters/resource-client.mjs +61 -0
  24. package/adapters/turborepo.mjs +135 -0
  25. package/adapters/typescript.mjs +85 -0
  26. package/adapters/wrangler.mjs +206 -0
  27. package/bin/agentdoc.mjs +494 -0
  28. package/bin/commands.mjs +169 -0
  29. package/bin/usage.txt +28 -0
  30. package/core/acceptances.mjs +69 -0
  31. package/core/audit.mjs +456 -0
  32. package/core/authority/classes.mjs +39 -0
  33. package/core/authority/engine.mjs +266 -0
  34. package/core/authority/facts.mjs +41 -0
  35. package/core/codes.mjs +126 -0
  36. package/core/compile.mjs +1018 -0
  37. package/core/contracts.mjs +121 -0
  38. package/core/derive.mjs +102 -0
  39. package/core/descriptors.mjs +489 -0
  40. package/core/determinism.mjs +95 -0
  41. package/core/discover.mjs +147 -0
  42. package/core/facts.mjs +53 -0
  43. package/core/fsx.mjs +348 -0
  44. package/core/graph.mjs +260 -0
  45. package/core/impact.mjs +175 -0
  46. package/core/indexes.mjs +165 -0
  47. package/core/jsonschema.mjs +298 -0
  48. package/core/normative.mjs +171 -0
  49. package/core/observations.mjs +129 -0
  50. package/core/provenance.mjs +83 -0
  51. package/core/query.mjs +384 -0
  52. package/core/relations.mjs +286 -0
  53. package/core/scaffold.mjs +322 -0
  54. package/core/secrets.mjs +92 -0
  55. package/core/sourcescan.mjs +88 -0
  56. package/core/toml.mjs +163 -0
  57. package/core/yaml.mjs +477 -0
  58. package/docs/ADAPTERS.md +207 -0
  59. package/docs/AUTHORITY.md +269 -0
  60. package/docs/CI.md +138 -0
  61. package/docs/COMPARISON-KODA.md +164 -0
  62. package/docs/EVALS.md +166 -0
  63. package/docs/MIGRATION.md +261 -0
  64. package/docs/PROVENANCE.md +133 -0
  65. package/docs/QUERY.md +180 -0
  66. package/docs/SPEC.md +339 -0
  67. package/docs/VERIFICATION.md +28 -0
  68. package/docs/assets/readme/agentdoc-hero.webp +0 -0
  69. package/docs/assets/readme/agentdoc-in-action.webp +0 -0
  70. package/docs/assets/readme/how-agentdoc-works.webp +0 -0
  71. package/docs/assets/readme/why-agentdoc.webp +0 -0
  72. package/docs/ci/generic-ci.sh +28 -0
  73. package/docs/ci/github-actions.yml +35 -0
  74. package/evals/harness.mjs +426 -0
  75. package/evals/scenarios/fixture-a-01-change-api.json +9 -0
  76. package/evals/scenarios/fixture-a-02-change-db.json +9 -0
  77. package/evals/scenarios/fixture-a-03-enforce-constraint.json +9 -0
  78. package/evals/scenarios/fixture-b-01-change-proto.json +9 -0
  79. package/evals/scenarios/fixture-b-02-change-write-path.json +9 -0
  80. package/evals/scenarios/fixture-b-03-change-shared-lib.json +9 -0
  81. package/evals/scenarios/fixture-b-04-journey.json +9 -0
  82. package/evals/scenarios/fixture-c-01-mixed-runtime-edge.json +19 -0
  83. package/evals/scenarios/fixture-c-02-stale-doc-contradiction.json +9 -0
  84. package/evals/scenarios/fixture-c-03-shared-vocabulary.json +9 -0
  85. package/evals/scenarios/fixture-c-04-contract-change.json +9 -0
  86. package/evals/scenarios/koda-01-modify-api-consumer.json +26 -0
  87. package/evals/scenarios/koda-02-change-db-schema.json +20 -0
  88. package/evals/scenarios/koda-03-change-auth.json +21 -0
  89. package/evals/scenarios/koda-04-add-event-producer.json +19 -0
  90. package/evals/scenarios/koda-05-modify-worker-binding.json +25 -0
  91. package/evals/scenarios/koda-06-change-cross-component-endpoint.json +22 -0
  92. package/evals/scenarios/koda-07-change-shared-package.json +16 -0
  93. package/evals/scenarios/koda-08-change-runtime-cron.json +23 -0
  94. package/evals/scenarios/koda-09-debug-production-mismatch.json +26 -0
  95. package/evals/thresholds.json +11 -0
  96. package/package.json +46 -4
  97. package/schemas/api.schema.json +84 -0
  98. package/schemas/common.schema.json +147 -0
  99. package/schemas/component.schema.json +44 -0
  100. package/schemas/config.schema.json +801 -0
  101. package/schemas/domain.schema.json +14 -0
  102. package/schemas/graph.schema.json +1084 -0
  103. package/schemas/journeys.schema.json +47 -0
  104. package/schemas/observation.schema.json +143 -0
  105. package/schemas/resource.schema.json +28 -0
  106. package/schemas/system.schema.json +26 -0
  107. package/skills/agent-doc-system/SKILL.md +117 -0
  108. package/skills/agent-doc-system/references/authority-and-conflicts.md +70 -0
  109. package/skills/agent-doc-system/references/cli.md +97 -0
  110. package/skills/agent-doc-system/references/create-migrate.md +113 -0
  111. package/skills/agent-doc-system/references/maintenance.md +52 -0
  112. package/templates/ADR.md +26 -0
  113. package/templates/ARCHITECTURE.md +19 -0
  114. package/templates/CONSTRAINTS.md +17 -0
  115. package/templates/PRODUCT.md +17 -0
  116. package/templates/api.yaml +10 -0
  117. package/templates/ci.yml +31 -0
  118. package/templates/component.yaml +14 -0
  119. package/templates/domain.yaml +6 -0
  120. package/templates/journey.yaml +7 -0
  121. package/templates/observation.yaml +19 -0
  122. package/templates/resource.yaml +8 -0
  123. package/templates/system.yaml +10 -0
  124. package/templates/warning-acceptance.yaml +14 -0
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "agentdoc.dev/schema/journeys.schema.json",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "schemaVersion",
8
+ "journeys"
9
+ ],
10
+ "properties": {
11
+ "schemaVersion": {
12
+ "const": "agentdoc.dev/journeys/v1"
13
+ },
14
+ "journeys": {
15
+ "type": "array",
16
+ "minItems": 0,
17
+ "items": {
18
+ "type": "object",
19
+ "additionalProperties": false,
20
+ "required": [
21
+ "id",
22
+ "description",
23
+ "components"
24
+ ],
25
+ "properties": {
26
+ "id": {
27
+ "$ref": "common.json#/$defs/name"
28
+ },
29
+ "description": {
30
+ "$ref": "common.json#/$defs/description"
31
+ },
32
+ "components": {
33
+ "type": "array",
34
+ "minItems": 2,
35
+ "uniqueItems": true,
36
+ "items": {
37
+ "$ref": "common.json#/$defs/componentRef"
38
+ }
39
+ },
40
+ "notes": {
41
+ "$ref": "common.json#/$defs/rationale"
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,143 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "agentdoc.dev/schema/observation.schema.json",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "apiVersion",
8
+ "kind",
9
+ "metadata",
10
+ "spec"
11
+ ],
12
+ "properties": {
13
+ "apiVersion": {
14
+ "const": "agentdoc.dev/observation/v1"
15
+ },
16
+ "kind": {
17
+ "const": "ObservationSet"
18
+ },
19
+ "metadata": {
20
+ "type": "object",
21
+ "additionalProperties": false,
22
+ "required": [
23
+ "name",
24
+ "description",
25
+ "environment",
26
+ "capturedAt",
27
+ "sourceSystem",
28
+ "collector",
29
+ "evidenceBundle"
30
+ ],
31
+ "properties": {
32
+ "name": {
33
+ "$ref": "common.json#/$defs/name"
34
+ },
35
+ "description": {
36
+ "$ref": "common.json#/$defs/description"
37
+ },
38
+ "environment": {
39
+ "description": "Which environment the observation describes. Never a secret-bearing identifier.",
40
+ "type": "string",
41
+ "minLength": 1,
42
+ "maxLength": 60,
43
+ "pattern": "^[a-z0-9][a-z0-9._-]*$"
44
+ },
45
+ "capturedAt": {
46
+ "type": "string",
47
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$"
48
+ },
49
+ "maxAgeDays": {
50
+ "type": "integer",
51
+ "minimum": 1,
52
+ "maximum": 3650
53
+ },
54
+ "sourceSystem": {
55
+ "description": "The authoritative external system the facts came from.",
56
+ "type": "string",
57
+ "minLength": 1,
58
+ "maxLength": 80,
59
+ "pattern": "^[a-z0-9][a-z0-9._-]*$"
60
+ },
61
+ "collector": {
62
+ "description": "Retrieval method identity: the command or API used to read the source system.",
63
+ "type": "string",
64
+ "minLength": 1,
65
+ "maxLength": 120,
66
+ "pattern": "^[^\\n\\r]+$"
67
+ },
68
+ "evidenceBundle": {
69
+ "description": "Durable, secret-free, repository-relative reference to the raw observation. Never a temp path, host path or console URL with credentials.",
70
+ "$ref": "common.json#/$defs/repoPath"
71
+ },
72
+ "supersedes": {
73
+ "$ref": "common.json#/$defs/name"
74
+ },
75
+ "provenance": {
76
+ "type": "string",
77
+ "maxLength": 280
78
+ }
79
+ }
80
+ },
81
+ "spec": {
82
+ "type": "object",
83
+ "additionalProperties": false,
84
+ "required": [
85
+ "facts"
86
+ ],
87
+ "properties": {
88
+ "facts": {
89
+ "type": "array",
90
+ "minItems": 1,
91
+ "items": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "required": [
95
+ "id",
96
+ "subject",
97
+ "key",
98
+ "value",
99
+ "semantics"
100
+ ],
101
+ "properties": {
102
+ "id": {
103
+ "$ref": "common.json#/$defs/name"
104
+ },
105
+ "subject": {
106
+ "$ref": "common.json#/$defs/entityRef"
107
+ },
108
+ "key": {
109
+ "description": "Dotted claim key, e.g. schedule.cron, binding.kv, contract.supports-annotations.",
110
+ "type": "string",
111
+ "minLength": 1,
112
+ "maxLength": 80,
113
+ "pattern": "^[a-z0-9]+(?:[.-][a-z0-9]+)*$"
114
+ },
115
+ "value": {
116
+ "description": "Observed value. A JSON scalar, array of scalars, or null when the fact is known to be absent."
117
+ },
118
+ "semantics": {
119
+ "description": "What the observed value actually means, in one sentence.",
120
+ "$ref": "common.json#/$defs/rationale"
121
+ },
122
+ "observedRefs": {
123
+ "type": "array",
124
+ "maxItems": 16,
125
+ "uniqueItems": true,
126
+ "items": {
127
+ "$ref": "common.json#/$defs/entityRef"
128
+ }
129
+ },
130
+ "detail": {
131
+ "type": "string",
132
+ "maxLength": 600
133
+ }
134
+ }
135
+ }
136
+ }
137
+ }
138
+ },
139
+ "extensions": {
140
+ "$ref": "common.json#/$defs/extensions"
141
+ }
142
+ }
143
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "agentdoc.dev/schema/resource.schema.json",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["apiVersion", "kind", "metadata", "spec"],
7
+ "properties": {
8
+ "apiVersion": { "const": "agentdoc.dev/v1" },
9
+ "kind": { "const": "Resource" },
10
+ "metadata": { "$ref": "common.json#/$defs/metadata" },
11
+ "spec": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "required": ["type"],
15
+ "properties": {
16
+ "type": { "enum": ["logical-database", "logical-dataset", "event-bus", "queue", "cache", "object-store", "search-index", "secret-store", "other"] },
17
+ "placementRationale": { "$ref": "common.json#/$defs/rationale" },
18
+ "system": { "$ref": "common.json#/$defs/name" },
19
+ "context": { "$ref": "common.json#/$defs/context" }
20
+ },
21
+ "oneOf": [
22
+ { "required": ["system"] },
23
+ { "required": ["placementRationale"] }
24
+ ]
25
+ },
26
+ "extensions": { "$ref": "common.json#/$defs/extensions" }
27
+ }
28
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "agentdoc.dev/schema/system.schema.json",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["apiVersion", "kind", "metadata", "spec"],
7
+ "properties": {
8
+ "apiVersion": { "const": "agentdoc.dev/v1" },
9
+ "kind": { "const": "System" },
10
+ "metadata": { "$ref": "common.json#/$defs/metadata" },
11
+ "spec": {
12
+ "type": "object",
13
+ "additionalProperties": false,
14
+ "properties": {
15
+ "domain": { "$ref": "common.json#/$defs/name" },
16
+ "placementRationale": { "$ref": "common.json#/$defs/rationale" },
17
+ "context": { "$ref": "common.json#/$defs/context" }
18
+ },
19
+ "oneOf": [
20
+ { "required": ["domain"], "not": { "required": ["placementRationale"] } },
21
+ { "required": ["placementRationale"], "not": { "required": ["domain"] } }
22
+ ]
23
+ },
24
+ "extensions": { "$ref": "common.json#/$defs/extensions" }
25
+ }
26
+ }
@@ -0,0 +1,117 @@
1
+ ---
2
+ name: agent-doc-system
3
+ description: Use AgentDoc to create, migrate, query, validate, and maintain an agent-oriented software catalog and documentation system for a codebase. Use when architectural context, dependency impact, documentation drift, provenance, authority conflicts, or repository documentation migration matters.
4
+ ---
5
+
6
+ # AgentDoc
7
+
8
+ AgentDoc is a machine-installed CLI (`agentdoc`) that compiles a repository into
9
+ one deterministic graph and routes a path or entity to the minimum context
10
+ needed to change it safely. This skill teaches you how to operate it.
11
+
12
+ ## Prerequisite
13
+
14
+ The CLI must already be installed on this machine:
15
+
16
+ ```bash
17
+ agentdoc --version
18
+ ```
19
+
20
+ If that fails, AgentDoc is not installed. Stop, report the missing prerequisite,
21
+ and point the user at `INSTALL_FOR_AGENTS.md` in the agent-doc-system
22
+ repository. Do not clone the source repository into the user's project — the
23
+ CLI is installed on the machine, never vendored into a project.
24
+
25
+ ## When to use it
26
+
27
+ - The repository contains `agentdoc/agentdoc.config.yaml` — a catalog exists
28
+ and you are using it.
29
+ - You are about to change files and need to know what else must stay
30
+ consistent.
31
+ - You were asked to document a repository, audit its docs, find what depends
32
+ on X, or explain why production disagrees with the manifest.
33
+
34
+ Do not use it to write prose. The system routes facts; prose lives in the files
35
+ it points at.
36
+
37
+ ## The mental model
38
+
39
+ Three kinds of claim get conflated in most repositories, and the confusion is
40
+ the main way an agent goes wrong:
41
+
42
+ | kind | who makes it | how it fails |
43
+ |---|---|---|
44
+ | what the repository **claims** | authored docs, config, manifests | drifts; states intent, not fact |
45
+ | what is **derived** from code | imports, manifests, contracts | incomplete; cannot know intent |
46
+ | what was **observed** running | schedulers, bindings, live APIs | goes stale; disagrees with intent |
47
+
48
+ A fact carries an evidence class, a confidence, and a pointer to its evidence.
49
+ When classes disagree, the disagreement is **surfaced as a conflict**, not
50
+ reconciled. There is no global precedence order: authority depends on the fact.
51
+
52
+ **Your obligation:** never present a claim from one class as if it came from
53
+ another. If the graph reports a conflict or an unresolved fact, say so.
54
+
55
+ ## Pick the workflow
56
+
57
+ | workflow | when | entry point |
58
+ |---|---|---|
59
+ | CREATE | no `agentdoc/` config exists | `agentdoc init`, then `scaffold --write` |
60
+ | MIGRATE | established repo, scattered or stale docs | `agentdoc audit`, then work the report |
61
+ | VALIDATE | before committing, in CI | `agentdoc validate` → `compile` → `check` |
62
+ | QUERY | before and during a change | `agentdoc query <path-or-ref>` |
63
+ | MAINTAIN | after a change | `agentdoc impact <paths>` |
64
+
65
+ CREATE versus MIGRATE is not about size: a repository whose existing docs make
66
+ *claims* is a migration, because those claims must be verified. Details:
67
+ [references/create-migrate.md](references/create-migrate.md).
68
+
69
+ ## The normal loop
70
+
71
+ ```bash
72
+ agentdoc impact <files I will change> # what this reaches
73
+ agentdoc query <path> # minimum context, compact
74
+ agentdoc query <path> --json # full payload
75
+ # ... make the change ...
76
+ agentdoc impact <files I changed> # what must stay consistent
77
+ agentdoc validate && agentdoc check # prove it
78
+ ```
79
+
80
+ If `check` fails, the committed graph no longer describes the repository. Do
81
+ not work around it: run `agentdoc compile`, review the diff, commit the graph.
82
+
83
+ ## Rules that are never optional
84
+
85
+ - **Never vendor the CLI.** A project gets `agentdoc/` project data (config,
86
+ descriptors, observations), `docs/` skeletons, `.agentdoc/graph.json` and a
87
+ CI workflow — never a copy of the agentdoc source tree (`core/`, `bin/`,
88
+ `adapters/`, `schemas/`, `templates/`, `evals/`, `tests/`).
89
+ - **Never promote uncertainty.** Heuristic guesses do not become authored
90
+ facts; they become `reviewedOverrides` with evidence, or they stay out.
91
+ - **Never reconcile a conflict by editing one side.** Add an authority rule for
92
+ the key, or report both values to a human. Details:
93
+ [references/authority-and-conflicts.md](references/authority-and-conflicts.md).
94
+ - **Never write a secret** into a descriptor, observation, evidence bundle or
95
+ commit message. Validation fails on secret-shaped input *and* output.
96
+ - **Never hand-edit `.agentdoc/graph.json`.** The gate rejects it, and it would
97
+ be wrong anyway.
98
+ - **Do not trust existing documentation.** In MIGRATE it is evidence of what
99
+ someone once believed. The audit flags only a narrow set of contradictions
100
+ automatically (negated components, port claims); it does not read prose for
101
+ meaning. Obligations in specifications are checked only once declared:
102
+ configure `docs.normative`, turn every section into a component requirement
103
+ or a reviewed attestation, and finish with `agentdoc check --strict`.
104
+
105
+ ## Deeper references
106
+
107
+ | file | covers |
108
+ |---|---|
109
+ | [references/cli.md](references/cli.md) | every command, flag and exit code |
110
+ | [references/create-migrate.md](references/create-migrate.md) | the two onboarding workflows and the audit report |
111
+ | [references/authority-and-conflicts.md](references/authority-and-conflicts.md) | evidence classes, elections, secrets, descriptors |
112
+ | [references/maintenance.md](references/maintenance.md) | keeping the catalog true: gates, freshness, evidence handover |
113
+
114
+ The normative specification (`docs/SPEC.md`, `docs/AUTHORITY.md`,
115
+ `docs/PROVENANCE.md`, `docs/QUERY.md`, `docs/MIGRATION.md`, `docs/CI.md`) lives
116
+ in the agent-doc-system repository — read it when a rule here needs the full
117
+ contract behind it.
@@ -0,0 +1,70 @@
1
+ # Evidence, authority and conflicts
2
+
3
+ ## The three evidence classes
4
+
5
+ | class | source | may be authored? |
6
+ |---|---|---|
7
+ | `AUTHORED` | a file in the repository you can point at | yes |
8
+ | `DERIVED` | a deterministic extractor produces it | yes, once reviewed |
9
+ | `OBSERVED_RUNTIME` | an `agentdoc/observations/*.yaml` ObservationSet, written after actually reading the external system | **no** — it belongs in an ObservationSet |
10
+ | `REVIEWED_OVERRIDE` | a reviewed human interpretation, citing pinned evidence | yes, with `reviewWhen` and evidence digests |
11
+
12
+ There is no global precedence order. The committed manifest is authoritative
13
+ for *intent*; a live scheduler is authoritative for *what fires*; the canonical
14
+ contract is authoritative for the *desired wire surface* while a live probe is
15
+ authoritative for *what is deployed today*. Which class wins is decided per
16
+ fact key, by an explicit authority rule.
17
+
18
+ ## When you cannot establish a fact
19
+
20
+ - **Heuristic guess** — do not write it. Add a `reviewedOverrides` entry with a
21
+ `reason`, a `reviewWhen`, and file-level `evidence` (path + sha256, via
22
+ `agentdoc pin-evidence`), or leave it out.
23
+ - **Two sources disagree** — do not pick one. Either add an authority rule that
24
+ says which class is authoritative *for that key*, or report the contradiction
25
+ to a human. Fail-closed is the default: a disagreeing fact with no governing
26
+ rule is an error, and no gate passes while it stands.
27
+ - **Product or ownership decision** — ask. Do not infer ownership from folder
28
+ names.
29
+
30
+ ## Handling a reported conflict
31
+
32
+ `agentdoc query <ref> --json` returns `authority.conflicts`. For each one:
33
+
34
+ 1. Read `election.basis` and `election.ruleId`. `basis: none` means no rule
35
+ governs this fact and the system refused to choose.
36
+ 2. Both values stay in the graph. Report both to the human, with their evidence
37
+ pointers, and say which one the system elected and why.
38
+ 3. If the right answer is "the runtime wins for this key", add an authority
39
+ rule with `elect: [OBSERVED_RUNTIME]`, a `rationale`, and a `reviewWhen`.
40
+ Do not edit the observation to match the manifest, and do not edit the
41
+ manifest to match the observation.
42
+
43
+ ## Secrets
44
+
45
+ Never write a credential, token, key or credentialed URL into a descriptor, an
46
+ observation, an evidence bundle, or a commit message. `agentdoc validate`
47
+ fails on secret-shaped input, and the output scanner fails on secret-shaped
48
+ output too. Observations cite a committed, secret-free evidence bundle by
49
+ repository-relative path — a temp path, a console URL with a session token, or
50
+ a screenshot filename is not evidence.
51
+
52
+ ## Writing descriptors
53
+
54
+ The templates ship with the CLI (`templates/` in the package). The rules that
55
+ matter:
56
+
57
+ - A Component descriptor lives at the root of the unit it describes, named by
58
+ `discovery.componentDescriptorName` (conventionally `agentdoc.yaml`).
59
+ - `metadata.description` is **one sentence, present tense**, ending in `.`,
60
+ `!` or `?`. It says what the component is *for*.
61
+ - Placement is exactly one of `system`, `domain`, or `placementRationale`.
62
+ - Every durable cross-component boundary has exactly one canonical
63
+ machine-readable contract, and exactly one API descriptor pointing at it.
64
+ Default to OpenAPI 3.1 for JSON HTTP; a protocol's native schema is equally
65
+ valid.
66
+ - You never author a relation. Placement and API provider edges come from the
67
+ descriptor; everything else is derived or reviewed.
68
+
69
+ The full model is `docs/AUTHORITY.md` and `docs/PROVENANCE.md` in the agentdoc
70
+ repository.
@@ -0,0 +1,97 @@
1
+ # agentdoc CLI reference
2
+
3
+ The binary is `agentdoc`, installed once per machine. Every command that
4
+ operates on a catalog can be run from any subdirectory of the repository: the
5
+ configuration is found by walking up to `agentdoc/agentdoc.config.yaml`. No
6
+ command ever needs the agentdoc source tree or a path to it.
7
+
8
+ Exit codes: `0` ok, `1` failure, `2` usage. Flags are declared per command:
9
+ an unknown or misspelled flag is a usage error (`2`), with a suggestion when
10
+ one is close — it is never silently ignored, so `check --strcit` cannot pass
11
+ for `check --strict`. `agentdoc <command> --help` lists exactly what a command
12
+ accepts.
13
+
14
+ ## Meta
15
+
16
+ ```bash
17
+ agentdoc --version # installed version
18
+ agentdoc --help # command list
19
+ agentdoc <command> --help # every flag of one command (also: agentdoc help <command>)
20
+ agentdoc doctor # machine check: is this CLI install healthy
21
+ agentdoc doctor --project # the same, plus the current project's catalog health
22
+ ```
23
+
24
+ `doctor` answers "is the CLI itself healthy": supported Node, schema bundle,
25
+ compiler version. It never fails because a project is not configured yet.
26
+ `doctor --project` additionally checks `agentdoc/agentdoc.config.yaml` exists,
27
+ parses, and that the repository root is writable — run it inside a project.
28
+
29
+ ## Onboarding
30
+
31
+ ```bash
32
+ agentdoc init [--force] # write agentdoc/agentdoc.config.yaml + doc skeleton
33
+ agentdoc audit # inventory the repo, classify every fact (JSON)
34
+ agentdoc scaffold [--write] # generate descriptors for what can be proven
35
+ ```
36
+
37
+ `init` never overwrites an existing file without `--force`, and run inside a
38
+ subdirectory of a cataloged repository it writes at the catalog root, not the
39
+ current directory. `scaffold` is a dry run without `--write`; with `--write` it
40
+ is a superset of `init` — it also installs anything missing from the config,
41
+ doc skeleton and CI workflow, not only component descriptors. `audit` works
42
+ even when the repository cannot compile yet; it reports the compilation
43
+ failures as part of its output.
44
+
45
+ ## Validation
46
+
47
+ ```bash
48
+ agentdoc validate # sources + schemas + semantic checks
49
+ agentdoc compile [--require-clean] # deterministic graph build, atomic write
50
+ agentdoc check [--strict] [--require-clean] [--allow-stale-observations]
51
+ ```
52
+
53
+ `compile` writes `.agentdoc/graph.json` (or the path in `output.graph`).
54
+ `check` is the gate: it fails on a stale or hand-edited graph, a compiler or
55
+ schema version mismatch, an observation past its declared `maxAgeDays`, and —
56
+ with `--require-clean` — catalog inputs that differ from `HEAD`. With
57
+ `--strict` it also fails on every warning not accepted in `warningAcceptances`
58
+ — the gate that ends a MIGRATE (unreviewed normative sections, unproven
59
+ requirements, orphan documents).
60
+
61
+ ## Query and impact
62
+
63
+ ```bash
64
+ agentdoc query <path|entity-ref> # compact markdown context
65
+ agentdoc query <path|entity-ref> --json # full payload
66
+ agentdoc query <path> --budget relations=10,verification=4
67
+ agentdoc impact <paths...> # what a change forces consistent
68
+ agentdoc impact --diff <git-ref> # the same, for a commit range
69
+ ```
70
+
71
+ `query` refuses a stale graph — it never falls back to one. `impact` answers a
72
+ question about the working tree, so it compiles in memory instead: run it
73
+ *before* rebuilding.
74
+
75
+ Entity refs look like `component:<namespace>/<name>` — `query --json` returns
76
+ `entity.ref` values you can reuse.
77
+
78
+ ## Maintenance
79
+
80
+ ```bash
81
+ agentdoc pin-evidence [--json] # which pinned evidence digests are current
82
+ agentdoc eval routing [--json] # routing evaluation (meaningful on a source
83
+ # checkout; exits SKIP on other repositories)
84
+ ```
85
+
86
+ Reviewed overrides pin their evidence by content hash, re-verified on every
87
+ compile. `pin-evidence` reports `CURRENT` / `STALE` / `MISSING` per entry so a
88
+ digest can be updated without computing SHA-256 by hand. It exits `1` when any
89
+ entry is not current.
90
+
91
+ ## Error output
92
+
93
+ Diagnostics are lines of the form `ERROR <CODE>: <message>` on stderr, with a
94
+ JSON stats object. `WARN` lines are non-fatal; `WARN ACCEPTED` lines carry the
95
+ acceptance classification and reason. The full code registry is
96
+ `core/codes.mjs` in the agentdoc source; the operator-facing table is in
97
+ `docs/CI.md` of the repository.
@@ -0,0 +1,113 @@
1
+ # CREATE and MIGRATE
2
+
3
+ Two onboarding workflows. CREATE for a repository with no catalog; MIGRATE for
4
+ an established one. Both start with the same audit; MIGRATE adds a
5
+ source-of-truth mapping and a reviewed-ambiguity list a human must work
6
+ through.
7
+
8
+ ## Choosing
9
+
10
+ | situation | mode |
11
+ |---|---|
12
+ | no `agentdoc/` directory, small or new repository | CREATE |
13
+ | no `agentdoc/`, large or established repository | MIGRATE |
14
+ | an existing catalog, documentation that has drifted | MIGRATE |
15
+
16
+ The test is not size. It is whether the repository has documentation that
17
+ *claims* things. Claims need verifying — that is migration work regardless of
18
+ how few components there are.
19
+
20
+ ## CREATE
21
+
22
+ ```bash
23
+ cd <repository root>
24
+ agentdoc doctor --project # expect configurationFound: false for now
25
+ agentdoc init # config skeleton + documentation hierarchy
26
+ $EDITOR agentdoc/agentdoc.config.yaml
27
+ agentdoc audit # what is provable, what is not
28
+ agentdoc scaffold # dry run: what it would write
29
+ agentdoc scaffold --write # write descriptors for provable units
30
+ $EDITOR '**/agentdoc.yaml' # review every generated description
31
+ agentdoc validate && agentdoc compile && agentdoc check
32
+ ```
33
+
34
+ `init` writes `agentdoc/agentdoc.config.yaml`, the central descriptor files
35
+ (`domains.yaml`, `systems.yaml`, `apis.yaml`, `resources.yaml`),
36
+ `agentdoc/journeys.yaml`, the documentation hierarchy under `docs/`, the
37
+ observations README, and a CI workflow. It writes **project data only** — it
38
+ never copies the agentdoc implementation into the repository.
39
+
40
+ In `agentdoc.config.yaml`:
41
+
42
+ - Set `namespace`, fix `discovery.componentDescriptors` to match the real
43
+ layout, and enable the adapters for the technologies present. `adapters: []`
44
+ is a valid but useless starting point: with no adapter, a component
45
+ descriptor is an unsupported claim and compilation fails on purpose.
46
+ - Three example authority rules are written **commented out**. Uncomment only
47
+ the ones you can justify, with the rationale in your own words. An authority
48
+ rule is a governance decision; the scaffolder does not make it for you.
49
+
50
+ A generated description is a statement about artifact evidence, not a product
51
+ claim. Read every one and fix the ones that are wrong. The scaffolder never
52
+ chooses a `system` or `domain`: placement is an ownership decision, so the
53
+ generated descriptor carries a commented `placementRationale` prompt instead.
54
+
55
+ ## The audit report
56
+
57
+ `agentdoc audit` runs even when the repository cannot compile, and inventories
58
+ four truth sources independently: derivable facts, machine-readable contracts,
59
+ authored documentation, and ObservationSets. Key fields:
60
+
61
+ | field | meaning |
62
+ |---|---|
63
+ | `facts` | every major fact classified `CONFIRMED` / `DERIVED` / `OBSERVED` / `CONFLICT` / `UNRESOLVED` |
64
+ | `contradictions`, `documentationContradictions` | where sources disagree |
65
+ | `reviewedAmbiguity` | the list a human must decide |
66
+ | `documentation.orphanDocs` | documents nothing will ever route to |
67
+ | `documentation.undocumentedComponents` | components an agent will get wrong |
68
+ | `contracts.unclaimed` | contract files no API descriptor owns |
69
+ | `scaffold` | what the scaffolder proposes to write |
70
+
71
+ `OBSERVED` facts cannot be authored — they belong in an ObservationSet under
72
+ `agentdoc/observations/`. `CONFLICT` and `UNRESOLVED` need a human.
73
+
74
+ ## MIGRATE
75
+
76
+ ```bash
77
+ agentdoc init
78
+ # set componentDescriptors to the real layout; enable the right adapters
79
+ agentdoc audit > migration-report.json
80
+ ```
81
+
82
+ Then, in order:
83
+
84
+ 1. **Source-of-truth mapping.** Set `docs.normative` to the specifications and
85
+ profiles, then empty `normative.uncovered`: each section becomes a
86
+ `spec.requirements` entry on the component that must fulfil it, or a
87
+ `normativeCoverage` attestation that it obliges nothing. Prove each
88
+ requirement (adapter evidence or a `requirement-satisfaction` override);
89
+ an unproven one stays `REQUIREMENT_UNVERIFIED`. For other major claims,
90
+ record which inventory supports them; anything supported by none goes to
91
+ `reviewedAmbiguity`.
92
+ 2. **Contradictions.** Work `contradictions` and `documentationContradictions`.
93
+ Each needs a human decision: fix the docs, fix the code, or add an authority
94
+ rule saying which class wins for that key.
95
+ 3. **Orphan docs.** Link each to a component via `context.docs`, or delete it.
96
+ 4. **Missing docs.** Work `undocumentedComponents` / `unverifiedComponents`.
97
+ 5. **Stale contracts.** Point the API descriptor at the current contract file.
98
+ 6. **Ownership.** Placement from code where unambiguous, from a human elsewhere.
99
+ 7. **Catalog.** `scaffold --write`, review every generated file.
100
+ 8. **Gate.** `validate` → `compile` → `check --strict`, then install CI. Strict
101
+ fails on any unaccepted warning: an unreviewed section or an unproven
102
+ requirement cannot ship in a "complete" migration.
103
+
104
+ **The audit does not read prose for meaning.** It checks only negated
105
+ components and port claims automatically; every other documented obligation is
106
+ caught only if it is declared as a requirement.
107
+
108
+ **Do not trust existing documentation.** The single most common migration
109
+ failure is copying existing prose into descriptions. If you cannot write a
110
+ one-sentence present-tense statement of a component's current purpose, the
111
+ purpose is not understood yet — that discovery is the point.
112
+
113
+ The full workflow contract is `docs/MIGRATION.md` in the agentdoc repository.