docgov-cli 0.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/.claude-plugin/marketplace.json +29 -0
  2. package/.claude-plugin/plugin.json +41 -0
  3. package/LICENSE +21 -0
  4. package/README.md +136 -0
  5. package/agents/architect.md +65 -0
  6. package/agents/classifier.md +44 -0
  7. package/agents/drift-reviewer.md +59 -0
  8. package/agents/quality-reviewer.md +59 -0
  9. package/bin/docgov +1160 -0
  10. package/bin/docgov.cmd +2 -0
  11. package/core/check.js +298 -0
  12. package/core/classify.js +233 -0
  13. package/core/config.js +162 -0
  14. package/core/context.js +144 -0
  15. package/core/document.js +132 -0
  16. package/core/drift.js +225 -0
  17. package/core/find.js +61 -0
  18. package/core/frontmatter.js +65 -0
  19. package/core/git.js +113 -0
  20. package/core/graph.js +182 -0
  21. package/core/health.js +101 -0
  22. package/core/impact.js +146 -0
  23. package/core/invariants.js +126 -0
  24. package/core/inventory.js +167 -0
  25. package/core/links.js +80 -0
  26. package/core/migrate.js +158 -0
  27. package/core/onboard.js +271 -0
  28. package/core/paths.js +53 -0
  29. package/core/publish.js +92 -0
  30. package/core/registry.js +71 -0
  31. package/core/similarity.js +89 -0
  32. package/core/size.js +87 -0
  33. package/core/suppressions.js +58 -0
  34. package/core/taxonomy.js +477 -0
  35. package/core/templates.js +159 -0
  36. package/core/util.js +124 -0
  37. package/core/yaml.js +250 -0
  38. package/hooks/hooks.json +65 -0
  39. package/lenses/agent.md +38 -0
  40. package/lenses/architecture.md +30 -0
  41. package/lenses/developer.md +26 -0
  42. package/lenses/operations.md +32 -0
  43. package/lenses/readme.md +32 -0
  44. package/lenses/security.md +33 -0
  45. package/lenses/user.md +30 -0
  46. package/package.json +39 -0
  47. package/policy/documentation.md +82 -0
  48. package/schemas/config.json +239 -0
  49. package/schemas/frontmatter.json +299 -0
  50. package/skills/affected/SKILL.md +41 -0
  51. package/skills/brief/SKILL.md +38 -0
  52. package/skills/create/SKILL.md +53 -0
  53. package/skills/find/SKILL.md +32 -0
  54. package/skills/health/SKILL.md +36 -0
  55. package/skills/inspect/SKILL.md +58 -0
  56. package/skills/publish/SKILL.md +45 -0
  57. package/skills/review/SKILL.md +65 -0
  58. package/skills/setup/SKILL.md +52 -0
  59. package/skills/stale/SKILL.md +55 -0
  60. package/skills/tag/SKILL.md +59 -0
  61. package/templates/architecture.adr.md +42 -0
  62. package/templates/architecture.domain.md +44 -0
  63. package/templates/architecture.trd.md +72 -0
  64. package/templates/constitution.invariants.md +40 -0
  65. package/templates/operations.runbook.md +47 -0
  66. package/templates/product.prd.md +60 -0
  67. package/templates/security.threat-model.md +51 -0
  68. package/templates/user.readme.md +43 -0
@@ -0,0 +1,26 @@
1
+ # Developer lens
2
+
3
+ **The question:** can a competent engineer who does not know this system reproduce what the
4
+ document describes, and predict what happens when it goes wrong?
5
+
6
+ ## Evaluates
7
+
8
+ - **Technical precision.** Exact names, exact paths, exact versions. "Configure the service"
9
+ is not an instruction.
10
+ - **Reproducibility.** Every command runnable as written. Prerequisites stated, not assumed.
11
+ - **Examples.** At least one complete one. Fragments that assume surrounding context fail.
12
+ - **Assumptions stated.** What must already be true. This is the most common omission and
13
+ the most expensive.
14
+ - **Failure modes.** What breaks, how it surfaces, what to do. A document that only
15
+ describes the happy path is half a document.
16
+ - **Dependencies.** What this needs, and what degrades when each is unavailable.
17
+ - **Links to architecture.** Why, not just how — otherwise the reader cannot tell which
18
+ parts are safe to change.
19
+
20
+ ## Fails the lens
21
+
22
+ - Passive voice hiding the actor: "the token is validated" — by what, when, and what happens
23
+ if it is not?
24
+ - Version-less instructions that were true once.
25
+ - "Simply", "just", "obviously". Each one marks a step the author skipped.
26
+ - Copy-pasted schema or config instead of a link to the authoritative source.
@@ -0,0 +1,32 @@
1
+ # Operations lens
2
+
3
+ **The question:** can an on-call engineer, woken at 3am, who did not build this, execute
4
+ this correctly on the first attempt?
5
+
6
+ ## Evaluates
7
+
8
+ - **Trigger.** The exact signal that starts this. An alert name, a symptom, a threshold.
9
+ - **Preconditions.** Access required, approvals needed, what must be true first.
10
+ - **Diagnostics before action.** Commands that establish what is actually happening.
11
+ Procedures that act before confirming cause make outages worse.
12
+ - **Numbered steps, one action each.** Each with its expected result.
13
+ - **Copy-pasteable commands.** No placeholders that need thought to fill.
14
+ - **Validation.** How you know it worked, measured not assumed.
15
+ - **Rollback.** How to undo, and the point past which you cannot.
16
+ - **Escalation.** Who to wake, at what threshold, by what route.
17
+ - **Time expectations.** If a step takes eleven minutes, say so, or it will be declared
18
+ hung and interrupted.
19
+
20
+ ## Fails the lens
21
+
22
+ - Prose. Under pressure, prose is unreadable. Numbered steps.
23
+ - "Investigate the issue" as a step.
24
+ - "Contact the team" with no name, rotation or channel.
25
+ - A step whose outcome is not observable.
26
+ - Commands requiring access the preconditions did not mention.
27
+ - Last reviewed two years ago with no verification that the commands still exist.
28
+
29
+ ## The test
30
+
31
+ Could someone who has never seen this system execute it without asking a question? If not,
32
+ the missing answer is the finding. A runbook is tested by being executed, not by being read.
@@ -0,0 +1,32 @@
1
+ # README lens
2
+
3
+ **The question:** can a developer who has never seen this project understand what it is and
4
+ get it running in five minutes?
5
+
6
+ ## Must answer, in roughly this order
7
+
8
+ 1. What is this? (one or two sentences, no marketing)
9
+ 2. Why would I use it instead of the obvious alternative?
10
+ 3. What does it look like? (one example, or one image)
11
+ 4. How do I install it?
12
+ 5. How do I do the first useful thing?
13
+ 6. What else can it do? (a list, with links)
14
+ 7. Where is the deeper documentation?
15
+ 8. How do I contribute?
16
+ 9. Where do I get help?
17
+
18
+ ## Fails the lens
19
+
20
+ - Architecture explained rather than summarized. Three lines and a link, not 200 lines.
21
+ - Installation buried below the feature tour.
22
+ - An example that does not run as written.
23
+ - Internal implementation detail, team names, ticket references.
24
+ - API reference inline. That is a reference document.
25
+ - A changelog inline. That is `CHANGELOG.md`.
26
+ - Badges occupying more vertical space than the description.
27
+ - Over 300 lines. Past 500 it has stopped being a README.
28
+
29
+ ## The test
30
+
31
+ Delete every section a first-time reader does not need in their first five minutes. If the
32
+ README is now much shorter, the deleted sections were other documents wearing a README.
@@ -0,0 +1,33 @@
1
+ # Security lens
2
+
3
+ **The question:** does this document let a reader reason correctly about what is protected,
4
+ from whom, and what is not protected at all?
5
+
6
+ ## Evaluates
7
+
8
+ - **Trust boundaries.** Where trust changes, and what crosses each boundary.
9
+ - **Threat actors.** Who, with what capability and what motive. "Hackers" is not an actor.
10
+ - **Assets.** What is worth protecting, and why, in order.
11
+ - **Authorization.** Subjects, resources, actions, and the rule that joins them. Checked
12
+ where — at the edge, in the service, in the database?
13
+ - **Secret handling.** Where secrets live, how they rotate, who can read them.
14
+ - **Abuse cases.** Not just "can an attacker get in" but "what can a legitimate user do that
15
+ they should not".
16
+ - **Assumptions.** What must be true for the model to hold. When an assumption breaks, this
17
+ is the list that tells you what else just broke.
18
+ - **Residual risk.** What remains after the controls, and who accepted it.
19
+
20
+ ## Fails the lens
21
+
22
+ - Controls with no threats. A control list is not a threat model.
23
+ - Threats with no controls and no residual-risk entry — silently accepted risk.
24
+ - "We use encryption." Which data, at rest or in transit, which algorithm, whose keys?
25
+ - Compliance framework names standing in for a security argument.
26
+ - **Visibility error:** a threat model that names unmitigated vulnerabilities must be
27
+ `internal`. If it is in a public path, that is a critical finding, not a style note.
28
+
29
+ ## The internal/external pair
30
+
31
+ A threat model (`internal`) and a public security model (`public`) are two documents, not
32
+ one document with redactions. The public one says what you protect and how to report a
33
+ vulnerability. The internal one says what you have not fixed yet.
package/lenses/user.md ADDED
@@ -0,0 +1,30 @@
1
+ # User lens
2
+
3
+ **The question:** can the intended reader — who does not know how the system is built and
4
+ should not have to — complete the task they came for?
5
+
6
+ ## Evaluates
7
+
8
+ - **Task orientation.** Organized around what the reader wants to do, not around how the
9
+ system is structured. Readers arrive with goals, not with a mental model of your modules.
10
+ - **Jargon.** Every internal term either removed or defined on first use.
11
+ - **No internal leakage.** No service names, team names, ticket ids, or hostnames.
12
+ - **Prerequisites.** Stated before step one, not discovered at step four.
13
+ - **Examples.** Runnable exactly as written, with realistic values.
14
+ - **Expected results.** Each step says what the reader should see. Without that they cannot
15
+ tell success from silent failure.
16
+ - **Failure recovery.** What to do when a step does not work, or where to go.
17
+
18
+ ## Fails the lens
19
+
20
+ - Architecture explained to justify an instruction.
21
+ - "See the API reference" where a concrete example belongs.
22
+ - Screenshots of a UI that has since changed, with no version note.
23
+ - Steps written from the author's environment: absolute paths, personal directories.
24
+ - Diátaxis confusion: a tutorial that is really a reference, a how-to that is really an
25
+ explanation. Each of the four forms answers a different need; mixing them serves none.
26
+
27
+ ## The test
28
+
29
+ Hand it to someone who has never used the system. If they ask a question the document could
30
+ have answered, that question is the finding.
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "docgov-cli",
3
+ "version": "0.2.0",
4
+ "description": "Your AI writes docs faster than anyone can check them. DocGov checks them.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "docgov": "bin/docgov"
9
+ },
10
+ "engines": {
11
+ "node": ">=20"
12
+ },
13
+ "scripts": {
14
+ "test": "node --test test/*.test.js",
15
+ "docgov": "node ./bin/docgov"
16
+ },
17
+ "files": [
18
+ "bin",
19
+ "core",
20
+ "templates",
21
+ "lenses",
22
+ "schemas",
23
+ "policy",
24
+ "skills",
25
+ "agents",
26
+ "hooks",
27
+ ".claude-plugin"
28
+ ],
29
+ "dependencies": {},
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/ZeeshanSultan/DocGov.git"
33
+ },
34
+ "bugs": {
35
+ "url": "https://github.com/ZeeshanSultan/DocGov/issues"
36
+ },
37
+ "homepage": "https://github.com/ZeeshanSultan/DocGov#readme",
38
+ "author": "Zeeshan Sultan"
39
+ }
@@ -0,0 +1,82 @@
1
+ # Documentation rules
2
+
3
+ DocGov governs documentation in this repository. Mode: `{{MODE}}`. Layout: `{{LAYOUT}}`.
4
+
5
+ These rules apply to every agent and every human. They exist because a repository
6
+ with many authors — most of them now agents — degrades its documentation faster
7
+ than any review process can repair it.
8
+
9
+ ## Before creating any documentation
10
+
11
+ 1. **Check whether it already exists.** `docgov find "<topic>"` returns results in
12
+ authority order. If an authoritative document already covers the topic, update
13
+ that document. Do not create a second one.
14
+ 2. **Find out what you are writing.** `docgov whatis --path <intended-file>` names
15
+ the document class, its canonical location, its required sections and its limits.
16
+ 3. **Create it through DocGov.** `docgov create <type> "<name>" [--domain <d>]` puts
17
+ it in the right place, applies the template, and wires it into the graph. A
18
+ document not in the graph is invisible to impact analysis, which means nobody
19
+ will be told when it goes stale.
20
+
21
+ Never invent a new top-level Markdown file. Never invent a new documentation
22
+ directory. The taxonomy has 57 document classes; run `docgov types` before
23
+ concluding that yours is not one of them.
24
+
25
+ ## Before editing code in a governed area
26
+
27
+ Run `docgov brief <domain>` and read it. It is the minimum authoritative context
28
+ for that area: the constitution, the canonical specification, the rules in
29
+ force, the relevant ADRs and the machine contracts — and nothing else.
30
+
31
+ If a rule blocks what you were about to do, the rule wins. Changing it
32
+ means changing its source document in the same change, with a reason.
33
+
34
+ ## Authority
35
+
36
+ Authority is ordered and it is not negotiable:
37
+
38
+ ```
39
+ constitution > canonical > requirements / decision > machine contract
40
+ > implementation > generated > audience > historical
41
+ ```
42
+
43
+ A lower-authority document may not contradict a higher one. If you find a
44
+ contradiction, do not fix it by editing the lower document into agreement — work
45
+ out which one is actually right, fix that one, and record the decision.
46
+
47
+ Machine contracts (OpenAPI, JSON Schema, protobuf, GraphQL, migrations) are
48
+ authoritative over any prose that describes them. Reference them; do not restate
49
+ their contents.
50
+
51
+ ## Writing
52
+
53
+ - Apply the template for the class. Required sections are a deterministic gate, not
54
+ a style preference — a TRD with no failure analysis is not a TRD.
55
+ - Respect the audience. A README answers "what is this and how do I start" in under
56
+ 300 lines and links everything deeper. An architecture document does not explain
57
+ how to install anything.
58
+ - Keep one document to one concept. If a document holds several independently
59
+ addressable concepts, it should be a directory with an index.
60
+ - Never edit a generated document. Change its source and regenerate.
61
+ - Never edit the archive. It is a historical record.
62
+ - No TBD, TODO or FIXME in a document another agent will read as fact. Either state
63
+ what is true, or say explicitly that it is unknown and who owns finding out.
64
+
65
+ ## After changing anything material
66
+
67
+ 1. `docgov affected` — which documents this change affects, and which of them are
68
+ required rather than optional.
69
+ 2. Update the required ones in the same change. "I will document it later" is how
70
+ drift starts.
71
+ 3. `docgov check` — deterministic violations. Blocking checks in this mode:
72
+ `{{BLOCKING}}`.
73
+ 4. If a check is genuinely wrong for your case, `docgov ignore <ID> --reason "..."`.
74
+ A suppression needs a reason, stays visible in every report, and can expire. What
75
+ it never does is disappear.
76
+
77
+ ## What DocGov will not do for you
78
+
79
+ It will not decide whether two documents contradict each other, whether a document
80
+ should be split, or whether prose is clear. Those are judgement calls: they are
81
+ reported for review, never enforced automatically. Everything DocGov blocks is
82
+ something software can decide without guessing.
@@ -0,0 +1,239 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/ZeeshanSultan/DocGov/main/schemas/config.json",
4
+ "title": "DocGov configuration",
5
+ "description": ".docgov/config.yaml \u2014 every governance decision is configurable here. A policy pack may set any of these; local config always wins.",
6
+ "type": "object",
7
+ "required": [
8
+ "version",
9
+ "project"
10
+ ],
11
+ "properties": {
12
+ "version": {
13
+ "const": 1
14
+ },
15
+ "project": {
16
+ "type": "object",
17
+ "required": [
18
+ "mode"
19
+ ],
20
+ "properties": {
21
+ "name": {
22
+ "type": [
23
+ "string",
24
+ "null"
25
+ ]
26
+ },
27
+ "mode": {
28
+ "enum": [
29
+ "solo",
30
+ "team",
31
+ "enterprise",
32
+ "open-source"
33
+ ],
34
+ "description": "Decides how much blocks. solo blocks 3 rules; enterprise blocks 12. Over-enforcement is the main reason governance tooling gets uninstalled."
35
+ },
36
+ "visibility": {
37
+ "enum": [
38
+ "internal",
39
+ "public",
40
+ "mixed"
41
+ ]
42
+ },
43
+ "layout": {
44
+ "enum": [
45
+ "compact",
46
+ "full"
47
+ ],
48
+ "description": "compact suits most repositories. full is the numbered 00-canonical\u202699-archive tree; it earns its overhead at roughly 25+ documents."
49
+ }
50
+ }
51
+ },
52
+ "documentation": {
53
+ "type": "object",
54
+ "properties": {
55
+ "root": {
56
+ "type": "string"
57
+ },
58
+ "include": {
59
+ "type": "array",
60
+ "items": {
61
+ "type": "string"
62
+ }
63
+ },
64
+ "exclude": {
65
+ "type": "array",
66
+ "items": {
67
+ "type": "string"
68
+ },
69
+ "description": "Agent infrastructure is excluded by default: governing the files that configure DocGov is not useful."
70
+ },
71
+ "registrations": {
72
+ "type": "object",
73
+ "description": "Documents governed from config instead of from a `docgov:` block in the file. GitHub renders YAML frontmatter in Markdown as a table, so the files it surfaces on a project's front page \u2014 README, CONTRIBUTING, SECURITY, CHANGELOG \u2014 should be registered here and carry no frontmatter. Keys are repository-relative paths; values take the same fields as a `docgov:` block.",
74
+ "additionalProperties": {
75
+ "$ref": "frontmatter.json#/properties/docgov"
76
+ }
77
+ }
78
+ }
79
+ },
80
+ "governance": {
81
+ "type": "object",
82
+ "properties": {
83
+ "canonical_changes_require_review": {
84
+ "type": "boolean"
85
+ },
86
+ "prevent_duplicate_domains": {
87
+ "type": "boolean"
88
+ },
89
+ "enforce": {
90
+ "type": [
91
+ "array",
92
+ "null"
93
+ ],
94
+ "items": {
95
+ "type": "string"
96
+ },
97
+ "description": "Rule ids that block. null derives the list from the project mode."
98
+ },
99
+ "warn_only": {
100
+ "type": "boolean",
101
+ "description": "Nothing blocks. Useful while adopting DocGov on an existing repository."
102
+ },
103
+ "max_new_root_docs": {
104
+ "type": "integer",
105
+ "minimum": 0
106
+ }
107
+ }
108
+ },
109
+ "limits": {
110
+ "type": "object",
111
+ "description": "Per document type. Line counts gate whether a semantic review is worth spending; they never trigger an automatic split.",
112
+ "additionalProperties": {
113
+ "type": "object",
114
+ "properties": {
115
+ "soft_lines": {
116
+ "type": "integer"
117
+ },
118
+ "hard_lines": {
119
+ "type": "integer"
120
+ }
121
+ }
122
+ }
123
+ },
124
+ "quality": {
125
+ "type": "object",
126
+ "description": "Advisory thresholds per type. Never used as a hard gate: a subjective judgement that fails a build is one nobody can appeal.",
127
+ "additionalProperties": {
128
+ "type": "integer",
129
+ "minimum": 0,
130
+ "maximum": 100
131
+ }
132
+ },
133
+ "visibility_paths": {
134
+ "type": "array",
135
+ "items": {
136
+ "type": "object",
137
+ "required": [
138
+ "glob",
139
+ "require"
140
+ ],
141
+ "properties": {
142
+ "glob": {
143
+ "type": "string"
144
+ },
145
+ "require": {
146
+ "type": "array",
147
+ "items": {
148
+ "type": "string"
149
+ }
150
+ }
151
+ }
152
+ }
153
+ },
154
+ "generated_paths": {
155
+ "type": "array",
156
+ "items": {
157
+ "type": "string"
158
+ }
159
+ },
160
+ "drift": {
161
+ "type": "object",
162
+ "properties": {
163
+ "enabled": {
164
+ "type": "boolean"
165
+ },
166
+ "stale_threshold": {
167
+ "type": "integer",
168
+ "minimum": 0,
169
+ "maximum": 100
170
+ },
171
+ "lookback": {
172
+ "type": "string"
173
+ },
174
+ "fail_on": {
175
+ "type": "array",
176
+ "items": {
177
+ "enum": [
178
+ "critical",
179
+ "high",
180
+ "medium",
181
+ "low"
182
+ ]
183
+ }
184
+ }
185
+ }
186
+ },
187
+ "generated": {
188
+ "type": "object",
189
+ "properties": {
190
+ "allow_manual_edit": {
191
+ "type": "boolean"
192
+ }
193
+ }
194
+ },
195
+ "contracts": {
196
+ "type": "object",
197
+ "additionalProperties": {
198
+ "type": "array",
199
+ "items": {
200
+ "type": "string"
201
+ }
202
+ }
203
+ },
204
+ "domains": {
205
+ "type": "object",
206
+ "description": "The highest-leverage section. Mapping a domain to code paths is what switches on context packs, invariant injection and drift detection.",
207
+ "additionalProperties": {
208
+ "type": "object",
209
+ "properties": {
210
+ "paths": {
211
+ "type": "array",
212
+ "items": {
213
+ "type": "string"
214
+ }
215
+ },
216
+ "docs": {
217
+ "type": "array",
218
+ "items": {
219
+ "type": "string"
220
+ }
221
+ },
222
+ "owner": {
223
+ "type": "string"
224
+ }
225
+ }
226
+ }
227
+ },
228
+ "policy_packs": {
229
+ "type": "array",
230
+ "items": {
231
+ "type": "string"
232
+ },
233
+ "description": "V3 organizational governance: paths to policy packs whose taxonomy, limits, quality thresholds and invariants layer under this config. The repository always keeps the last word."
234
+ },
235
+ "suppressions_file": {
236
+ "type": "string"
237
+ }
238
+ }
239
+ }