docguard-cli 0.28.0 → 0.29.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 (65) hide show
  1. package/README.es.md +102 -0
  2. package/README.md +64 -31
  3. package/README.pt-BR.md +101 -0
  4. package/STANDARD.md +20 -10
  5. package/cli/commands/agents.mjs +149 -0
  6. package/cli/commands/diff.mjs +6 -15
  7. package/cli/commands/generate.mjs +14 -1001
  8. package/cli/commands/guard.mjs +136 -8
  9. package/cli/commands/llms.mjs +67 -5
  10. package/cli/commands/mcp.mjs +263 -0
  11. package/cli/commands/memory.mjs +115 -0
  12. package/cli/commands/score.mjs +76 -12
  13. package/cli/docguard.mjs +31 -2
  14. package/cli/findings.mjs +499 -0
  15. package/cli/scanners/agent-readability.mjs +202 -0
  16. package/cli/scanners/semantic-claims.mjs +7 -1
  17. package/cli/scanners/speckit.mjs +98 -28
  18. package/cli/shared-ignore.mjs +148 -16
  19. package/cli/shared.mjs +45 -1
  20. package/cli/validators/api-surface.mjs +113 -26
  21. package/cli/validators/architecture.mjs +66 -43
  22. package/cli/validators/canonical-sync.mjs +59 -28
  23. package/cli/validators/changelog.mjs +41 -17
  24. package/cli/validators/cross-reference.mjs +28 -11
  25. package/cli/validators/doc-quality.mjs +78 -44
  26. package/cli/validators/docs-coverage.mjs +90 -63
  27. package/cli/validators/docs-diff.mjs +63 -64
  28. package/cli/validators/docs-sync.mjs +48 -33
  29. package/cli/validators/drift.mjs +40 -34
  30. package/cli/validators/environment.mjs +67 -27
  31. package/cli/validators/freshness.mjs +12 -5
  32. package/cli/validators/generated-staleness.mjs +26 -10
  33. package/cli/validators/metadata-sync.mjs +28 -25
  34. package/cli/validators/metrics-consistency.mjs +89 -47
  35. package/cli/validators/schema-sync.mjs +37 -32
  36. package/cli/validators/security.mjs +7 -20
  37. package/cli/validators/spec-kit.mjs +3 -0
  38. package/cli/validators/structure.mjs +58 -23
  39. package/cli/validators/surface-sync.mjs +34 -15
  40. package/cli/validators/test-spec.mjs +87 -29
  41. package/cli/validators/todo-tracking.mjs +83 -74
  42. package/cli/validators/traceability.mjs +67 -39
  43. package/cli/writers/doc-generators.mjs +853 -0
  44. package/cli/writers/generate-io.mjs +142 -0
  45. package/cli/writers/sarif.mjs +129 -0
  46. package/commands/docguard.fix.md +56 -53
  47. package/commands/docguard.guard.md +53 -47
  48. package/commands/docguard.review.md +49 -31
  49. package/docs/ai-integration.md +133 -134
  50. package/docs/commands.md +49 -3
  51. package/docs/configuration.md +38 -0
  52. package/docs/faq.md +15 -0
  53. package/extensions/spec-kit-docguard/extension.yml +1 -1
  54. package/extensions/spec-kit-docguard/skills/docguard-fix/SKILL.md +2 -2
  55. package/extensions/spec-kit-docguard/skills/docguard-guard/SKILL.md +2 -2
  56. package/extensions/spec-kit-docguard/skills/docguard-review/SKILL.md +2 -2
  57. package/extensions/spec-kit-docguard/skills/docguard-score/SKILL.md +2 -2
  58. package/extensions/spec-kit-docguard/skills/docguard-sync/SKILL.md +2 -2
  59. package/package.json +1 -1
  60. package/schemas/docguard-config.schema.json +17 -0
  61. package/templates/commands/docguard.fix.md +33 -10
  62. package/templates/commands/docguard.guard.md +40 -26
  63. package/templates/commands/docguard.init.md +23 -11
  64. package/templates/commands/docguard.review.md +25 -8
  65. package/templates/commands/docguard.update.md +14 -4
@@ -1,179 +1,178 @@
1
1
  # AI Integration Guide
2
2
 
3
- DocGuard is **AI-native**. It generates prompts that AI agents execute — the human reviews, not writes.
3
+ DocGuard is **AI-native by design**: a deterministic, zero-LLM core that finds
4
+ documentation-code drift, paired with surfaces that let any AI consumer act on
5
+ what it finds. The division of labour never changes:
4
6
 
5
- ## How It Works
7
+ > **Deterministic discovery, LLM judgment.** DocGuard extracts the facts
8
+ > (routes, schemas, env vars, documented claims, finding codes); the agent
9
+ > reads, verifies, and writes prose. DocGuard never calls an LLM itself.
6
10
 
7
- ```
8
- docguard diagnose → AI reads output → AI writes docs → docguard guard → ✅
9
- ```
10
-
11
- DocGuard is designed to be used **by** AI agents, not just **for** humans.
12
-
13
- ## Supported AI Agents
11
+ ## Pick your integration surface
14
12
 
15
- DocGuard works with any AI coding agent that can read CLI output:
13
+ | You are… | Use | One-liner |
14
+ |----------|-----|-----------|
15
+ | An MCP-capable agent (Claude Code, Cursor, …) | **MCP server** | `claude mcp add docguard -- npx docguard-cli mcp` |
16
+ | An agent that can run CLI commands | **JSON contract** | `npx docguard-cli guard --format json` |
17
+ | A slash-command workflow | **Installed commands** | `docguard init` installs `/docguard.*` into `.agent/commands/` |
18
+ | GitHub Code Scanning / SARIF dashboards | **SARIF output** | `npx docguard-cli guard --format sarif` |
19
+ | A PR reviewer (human or bot) | **GitHub Action** | inline annotations + sticky doc-impact comment, default on |
20
+ | An LLM reading the repo cold | **llms.txt / llms-full.txt / context pack** | `docguard llms`, `llms --full`, `memory --pack` |
16
21
 
17
- | Agent | Integration |
18
- |-------|------------|
19
- | **Claude Code** | Reads `diagnose` output, writes docs, runs `guard` |
20
- | **GitHub Copilot** | Slash commands in `.github/commands/` |
21
- | **Cursor** | Slash commands in `.cursor/rules/` |
22
- | **Google Antigravity** | Workflows in `.agents/workflows/` |
23
- | **Google Gemini** | Commands in `.gemini/commands/` |
24
- | **Any CLI-capable LLM** | Reads JSON output from `--format json` |
22
+ ## MCP server (native tools, no shelling out)
25
23
 
26
- ## Slash Commands
24
+ ```bash
25
+ # Claude Code
26
+ claude mcp add docguard -- npx docguard-cli mcp
27
+ # any MCP client: stdio transport, JSON-RPC 2.0
28
+ npx docguard-cli mcp
29
+ ```
27
30
 
28
- `docguard init` auto-installs slash commands for detected AI agents:
31
+ Five tools, each accepting an optional `projectDir`:
29
32
 
30
- ```
31
- .github/commands/diagnose.md # GitHub Copilot
32
- .cursor/rules/diagnose.md # Cursor
33
- .gemini/commands/diagnose.md # Google Gemini
34
- .agents/workflows/diagnose.md # Antigravity
35
- ```
33
+ | Tool | Returns |
34
+ |------|---------|
35
+ | `docguard_guard` | The full guard JSON contract — status, findings (stable codes), coverage, unverified-claim count |
36
+ | `docguard_score` | `{score, grade, categories}` |
37
+ | `docguard_explain` | A finding code's contract: title, help, suppression pragma, owning validator |
38
+ | `docguard_verify_claims` | Documented numbers/limits/enums as verification tasks — **the caller checks each against the code** |
39
+ | `docguard_diagnose` | Failing/warning validators with per-finding suggestions, shaped for action |
36
40
 
37
- ## The AI Workflow
41
+ The server is read-only (never scaffolds), keeps stdout as a pure JSON-RPC
42
+ transport, and turns in-tool failures (e.g. a malformed `.docguard.json`) into
43
+ `isError` results instead of dying.
38
44
 
39
- ### Step 1: Diagnose
45
+ ## The JSON contract (CLI automation)
40
46
 
41
47
  ```bash
42
- npx docguard-cli diagnose
43
- ```
44
-
45
- Output:
48
+ npx docguard-cli guard --format json
46
49
  ```
47
- 🔍 DocGuard Diagnose — my-project
48
- Profile: standard | Score: 75/100 (B)
49
- Guard: 35/41 passed | Status: WARN
50
50
 
51
- Warnings (3):
52
- ⚠ [Freshness] docs-canonical/ARCHITECTURE.md — 15 commits since last update
53
- Fix: docguard fix --doc architecture
51
+ | Field | Meaning |
52
+ |-------|---------|
53
+ | `status` | `PASS` / `WARN` / `FAIL` — severity-aware, matches the exit code (0/2/1) |
54
+ | `findings[]` | `{code, severity, confidence, message, location, suggestion}` — codes are stable API (`STR001`, `ENV003`, `XRF002`, …) |
55
+ | `nextStep` | The single suggested follow-up command (`null` on PASS) |
56
+ | `reportable[]` | Low-confidence findings (possible false positives) — verify before acting |
57
+ | `coverage` | Markdown tier map: canonical / tracked / ignored / `unclassified[]` |
58
+ | `semanticClaims.count` | Documented counts/limits/enums **not yet verified against code** |
59
+ | `validators[]` | Per-validator results — `na` means "nothing to validate", which is not a pass |
54
60
 
55
- 📋 Remediation Plan:
56
- 1. docguard fix --doc architecture
57
- 2. docguard guard ← verify fixes
61
+ Working with findings:
58
62
 
59
- 🤖 AI-Ready Prompt:
60
- TASK: Fix 3 documentation issue(s) in project "my-project"
61
- ...
63
+ ```bash
64
+ npx docguard-cli explain XRF002 # any code contract, cause, fix, suppression
65
+ npx docguard-cli fix --write # apply deterministic fixes (provenance-checked)
66
+ npx docguard-cli feedback # report a false positive (local-first + prefilled issue)
62
67
  ```
63
68
 
64
- ### Step 2: AI Fixes
69
+ Suppress a confirmed false positive **at the finding site**, never by disabling
70
+ a validator: `// docguard:ignore SEC001` on (or above) the flagged line, or
71
+ `<!-- docguard:validator <key> n/a — reason -->` in a doc.
65
72
 
66
- The AI reads the remediation plan and executes `docguard fix --doc <name>` for each issue. Each fix command outputs research instructions:
73
+ ## SARIF (GitHub Code Scanning)
67
74
 
68
75
  ```bash
69
- npx docguard-cli fix --doc architecture
76
+ npx docguard-cli guard --format sarif > docguard.sarif
70
77
  ```
71
78
 
72
- Output:
73
- ```
74
- TASK: Write ARCHITECTURE.md for "my-project"
75
-
76
- RESEARCH STEPS:
77
- 1. Read package.json for dependencies and project structure
78
- 2. List top-level directories (src/, lib/, cli/)
79
- 3. Read 2-3 representative files per directory
80
- 4. Map the import graph
81
- 5. Identify external dependencies
82
-
83
- WRITE THE DOCUMENT:
84
- - System Overview (2-3 sentences)
85
- - Component Map (table of modules)
86
- - Layer Boundaries (import rules)
87
- - Data Flow (request lifecycle)
88
- ```
79
+ Findings map 1:1 onto SARIF 2.1.0 — codes become rules (with the registry's
80
+ title/help), locations become regions, low-confidence findings carry a property
81
+ bag. Upload with `github/codeql-action/upload-sarif` and DocGuard findings
82
+ appear inline on PR diffs and in the Security tab. Exit codes are unchanged
83
+ (0/2/1), so the same run can gate and report.
89
84
 
90
- ### Step 3: Verify
85
+ ## GitHub Action (PR feedback)
91
86
 
92
- ```bash
93
- npx docguard-cli guard
87
+ ```yaml
88
+ permissions: { pull-requests: write }
89
+ steps:
90
+ - uses: actions/checkout@v4
91
+ with: { fetch-depth: 0 }
92
+ - uses: raccioly/docguard@v0.12.0
93
+ with:
94
+ command: guard
95
+ # both default to 'true':
96
+ # annotations: inline ::error/::warning per finding (capped at 50)
97
+ # pr-comment: sticky comment — verdict, top findings, impacted canonical docs
94
98
  ```
95
99
 
96
- If all checks pass done. If issues remain repeat from Step 1.
100
+ The feedback steps run **even when guard fails** that is when they matter —
101
+ and degrade gracefully on fork tokens and shallow clones.
97
102
 
98
- ## JSON Output for Automation
103
+ ## Context surfaces (for LLMs reading the repo)
99
104
 
100
- For programmatic integration:
105
+ | Artifact | Command | What it is |
106
+ |----------|---------|------------|
107
+ | `llms.txt` | `docguard llms` | Link index of the canonical docs ([llms.txt standard](https://llmstxt.org)) |
108
+ | `llms-full.txt` | `docguard llms --full` | Full doc bodies inlined — one fetch, per-doc 400-line cap |
109
+ | `.docguard/context-pack.md` | `docguard memory --pack` | Compact session-start context: guard status, scanner-derived surface counts, doc index with review dates, your AGENTS.md rules verbatim, known drift. Everything derived from code — regenerable, hallucination-free |
101
110
 
102
- ```bash
103
- npx docguard-cli diagnose --format json
104
- ```
111
+ Load the context pack at agent session start; regenerate any time — it is
112
+ never hand-edited.
105
113
 
106
- ```json
107
- {
108
- "project": "my-project",
109
- "profile": "standard",
110
- "status": "WARN",
111
- "score": 75,
112
- "grade": "B",
113
- "issues": [
114
- {
115
- "severity": "warning",
116
- "validator": "Freshness",
117
- "message": "ARCHITECTURE.md — 15 commits since last update",
118
- "command": "docguard fix --doc architecture",
119
- "docTarget": "architecture"
120
- }
121
- ],
122
- "fixCommands": ["docguard fix --doc architecture"]
123
- }
124
- ```
114
+ ## One source of truth for agent files
115
+
116
+ Teams hand-duplicate AGENTS.md into `CLAUDE.md`, `.cursor/rules/`,
117
+ `.github/copilot-instructions.md`, `GEMINI.md` — and the copies drift. Instead:
125
118
 
126
119
  ```bash
127
- npx docguard-cli guard --format json
120
+ docguard agents --sync # regenerate the family from AGENTS.md (hash-marked)
121
+ docguard agents --check # CI gate: exit 2 if any generated variant is stale
128
122
  ```
129
123
 
130
- ```json
131
- {
132
- "project": "my-project",
133
- "profile": "standard",
134
- "status": "PASS",
135
- "passed": 41,
136
- "total": 41,
137
- "validators": [
138
- { "name": "Structure", "status": "pass", "passed": 8, "total": 8 }
139
- ]
140
- }
141
- ```
124
+ Generated variants carry a source-hash marker. Files you wrote by hand (no
125
+ marker) are never touched without `--force`.
142
126
 
143
- ## CI/CD Integration
127
+ ## Slash commands
144
128
 
145
- ### GitHub Actions
129
+ `docguard init` installs `/docguard.*` commands into `.agent/commands/` (the
130
+ spec-kit convention; agents like Claude Code, Copilot, and Cursor pick them
131
+ up). They encode the full workflows below — `templates/commands/` in this repo
132
+ is the canonical source.
146
133
 
147
- DocGuard ships a ready-to-use workflow:
134
+ ## The agent workflow
148
135
 
149
- ```yaml
150
- # .github/workflows/docguard.yml
151
- name: DocGuard CDD Check
152
- on: [pull_request]
153
- jobs:
154
- docguard:
155
- runs-on: ubuntu-latest
156
- steps:
157
- - uses: actions/checkout@v4
158
- - uses: actions/setup-node@v4
159
- with: { node-version: '20' }
160
- - run: npx docguard-cli ci --format json --threshold 70
161
136
  ```
162
-
163
- Or copy `templates/ci/github-actions.yml` from this repo.
164
-
165
- ### Pre-commit Hook
166
-
167
- ```bash
168
- npx docguard-cli hooks
137
+ diagnose → fix (research + write) → guard → verify --semantic → done
169
138
  ```
170
139
 
171
- Automatically runs `guard` before every commit.
140
+ 1. **`docguard diagnose`** one command that identifies everything, with
141
+ AI-ready fix prompts (add `--format json` for structure).
142
+ 2. **`docguard fix --doc <name>`** — emits research steps + expected structure
143
+ for one doc. Execute the research, write real content, no placeholders.
144
+ 3. **`docguard guard`** — verify. Loop until PASS.
145
+ 4. **`docguard verify --semantic`** — extract every checkable documented claim
146
+ (counts, limits, enums) with the nearest cited code path. **You** compare
147
+ each value against the code: a green guard asserts structure, not the truth
148
+ of documented numbers. This is the highest-value step an agent can run.
149
+
150
+ Before editing docs after code changes, prefer the mechanical layers:
151
+ `docguard sync --write` (regenerates `source=code` marked sections) and
152
+ `docguard fix --write` (counts, versions, anchors) — never hand-edit what the
153
+ tool can fix deterministically.
172
154
 
173
- ## Best Practices for AI Agents
155
+ ## Is your repo readable by agents?
174
156
 
175
- 1. **Always run `diagnose` first** — it's the one command that identifies everything
176
- 2. **Use `--format json`** for structured, parseable output
177
- 3. **Run `guard` after fixes** to verify — loop until all checks pass
178
- 4. **Use `fix --doc <name>`** for targeted prompts when you know which doc needs work
179
- 5. **Check `score --tax`** periodically to ensure documentation isn't becoming a burden
157
+ ```bash
158
+ docguard score
159
+ ```
160
+
161
+ The **Agent Readability** block (display-only) measures how well AI consumers
162
+ can read the repo: agent entry file, entry-file token budget, section
163
+ addressability, structured-content density, machine markers, llms.txt, link
164
+ integrity. Each failing metric names its fix.
165
+
166
+ ## Best practices for AI agents
167
+
168
+ 1. **MCP first** — native tools beat parsing CLI output.
169
+ 2. **Trust the codes** — every finding has a stable code; `explain` it before
170
+ acting, suppress at the site with it, report false positives via `feedback`.
171
+ 3. **Run `guard` after every fix batch** — loop until PASS.
172
+ 4. **Never treat `na` as a pass** — "nothing to validate" is a coverage gap.
173
+ 5. **Check `semanticClaims.count` on green runs** — offer `verify --semantic`.
174
+ 6. **Respect the drift protocol** — deviating from canonical docs requires
175
+ `// DRIFT: reason` + a DRIFT-LOG.md entry, not a silent doc rewrite; the
176
+ docs may be right and the code wrong.
177
+ 7. **`score --tax`** periodically — documentation should stay an asset, not a
178
+ burden.
package/docs/commands.md CHANGED
@@ -36,8 +36,10 @@ npx docguard-cli diagnose --format prompt # Raw AI prompt (all issues combined)
36
36
 
37
37
  ```bash
38
38
  npx docguard-cli guard # Text output
39
- npx docguard-cli guard --format json # Structured JSON
39
+ npx docguard-cli guard --format json # Structured JSON (the stable agent contract)
40
+ npx docguard-cli guard --format sarif # SARIF 2.1.0 for GitHub Code Scanning
40
41
  npx docguard-cli guard --verbose # Show all check details
42
+ npx docguard-cli guard --changed-only # Pre-commit lite mode (fast subset)
41
43
  ```
42
44
 
43
45
  **Exit codes:** `0` (pass), `1` (errors), `2` (warnings)
@@ -52,12 +54,21 @@ When issues are found, guard outputs: `Run docguard diagnose to get AI fix promp
52
54
  "status": "WARN",
53
55
  "passed": 37,
54
56
  "total": 40,
57
+ "findings": [
58
+ { "code": "ENV003", "severity": "warn", "message": "…", "location": "docs-canonical/ENVIRONMENT.md", "suggestion": { "kind": "fix", "text": "…" } }
59
+ ],
60
+ "nextStep": "docguard diagnose",
61
+ "coverage": { "canonical": 5, "tracked": 40, "ignored": 10, "unclassified": [] },
62
+ "semanticClaims": { "count": 12 },
55
63
  "validators": [
56
64
  { "name": "Structure", "status": "pass", "passed": 8, "total": 8, "errors": [], "warnings": [] }
57
65
  ]
58
66
  }
59
67
  ```
60
68
 
69
+ Every finding carries a stable code — `docguard explain <CODE>` for its
70
+ contract, `// docguard:ignore <CODE>` to suppress a false positive at the site.
71
+
61
72
  ### `docguard score`
62
73
 
63
74
  **CDD maturity score** (0-100) with category breakdown.
@@ -157,8 +168,43 @@ npx docguard-cli fix --doc environment
157
168
  **Generate agent-specific config files** from AGENTS.md.
158
169
 
159
170
  ```bash
160
- npx docguard-cli agents
161
- npx docguard-cli agents --list
171
+ npx docguard-cli agents # one-shot scaffold (skips existing files)
172
+ npx docguard-cli agents --sync # AGENTS.md → CLAUDE.md/Copilot/Cursor/… (hash-marked, repeatable)
173
+ npx docguard-cli agents --check # CI gate: exit 2 if any synced variant is stale
174
+ ```
175
+
176
+ `--sync` treats AGENTS.md as the canonical source: generated variants carry a
177
+ source-hash marker and are regenerated on change; files you wrote by hand are
178
+ never touched without `--force`.
179
+
180
+ ### `docguard mcp`
181
+
182
+ **MCP server over stdio** — DocGuard's read-only core as native agent tools
183
+ (`docguard_guard`, `docguard_score`, `docguard_explain`,
184
+ `docguard_verify_claims`, `docguard_diagnose`).
185
+
186
+ ```bash
187
+ claude mcp add docguard -- npx docguard-cli mcp
188
+ ```
189
+
190
+ ### `docguard verify --semantic`
191
+
192
+ **Extract documented claims** (counts, limits, enums) as a verification task
193
+ list with cited code paths — the agent checks each value against the code.
194
+
195
+ ### `docguard explain <CODE>`
196
+
197
+ **Explain any finding code** (`STR001`, `ENV003`, …): what it means, how to fix
198
+ it, how to suppress a false positive at the finding site.
199
+
200
+ ### `docguard llms` / `docguard memory --pack`
201
+
202
+ **Context surfaces for LLMs reading the repo:**
203
+
204
+ ```bash
205
+ npx docguard-cli llms # llms.txt (link index)
206
+ npx docguard-cli llms --full # llms-full.txt (full doc bodies inlined)
207
+ npx docguard-cli memory --pack # .docguard/context-pack.md (session-start context)
162
208
  ```
163
209
 
164
210
  ---
@@ -43,6 +43,20 @@ DocGuard is configured via `.docguard.json` in the project root. If no config fi
43
43
  "security": true,
44
44
  "environment": true,
45
45
  "freshness": true
46
+ },
47
+
48
+ "severity": {
49
+ "security": "high",
50
+ "todoTracking": "low"
51
+ },
52
+
53
+ "collections": {
54
+ "extractors": "src/extractors/*.py",
55
+ "commands": "cli/commands/*.mjs"
56
+ },
57
+
58
+ "docs": {
59
+ "dirs": ["reference", "website/docs"]
46
60
  }
47
61
  }
48
62
  ```
@@ -73,6 +87,30 @@ See [Profiles](./profiles.md) for details.
73
87
  | `environment` | `true` | Setup steps, env vars, prerequisites, .env.example |
74
88
  | `freshness` | varies | Docs updated recently relative to code changes (git-based) |
75
89
 
90
+ ## Severity overrides
91
+
92
+ `severity.<validator>` changes a validator's **exit-code weight** without hiding
93
+ anything from display: `"high"` promotes its warnings to blocking (CI fails),
94
+ `"low"` demotes them (shown, but never fail the build). Valid values:
95
+ `high | medium | low`. To silence a validator entirely, use `validators.<key>: false`.
96
+
97
+ ## Collections — verify documented counts against code
98
+
99
+ `collections` binds a documentation noun to a glob whose **file count is the
100
+ source of truth**. With `"extractors": "src/extractors/*.py"`, a doc claiming
101
+ "16 extractors" while the glob matches 19 files becomes a guard warning (and a
102
+ `fix --write`-able correction). Declaring the noun *is* the opt-in — no other
103
+ marker needed. Reserved nouns (`checks`, `validators`, `tests`) keep their
104
+ built-in DocGuard meaning. An unresolvable glob is skipped, never treated as 0.
105
+
106
+ ## Documentation homes — `docs.dirs`
107
+
108
+ Conventional doc folders (`docs/`, `doc/`, `documentation/`, `guides/`,
109
+ `handbook/`, `manual/`, `wiki/`, Docusaurus `website/docs/`, …) are
110
+ **auto-detected** and claim-scanned without enrollment. `docs.dirs` EXTENDS
111
+ that set with non-standard homes — it never replaces auto-detection. To exclude
112
+ a conventional dir, list it in `.docguardignore`.
113
+
76
114
  ## Muting a validator
77
115
 
78
116
  Two ways to turn a validator off, for two different intents:
package/docs/faq.md CHANGED
@@ -153,3 +153,18 @@ Yes. In `.docguard.json`:
153
153
  ```
154
154
 
155
155
  Or use a profile that has them disabled by default (like `starter`).
156
+
157
+ ### Can my AI agent use DocGuard without parsing CLI output?
158
+
159
+ Yes — run the MCP server: `claude mcp add docguard -- npx docguard-cli mcp`
160
+ exposes guard, score, explain, verify-claims, and diagnose as native tools for
161
+ Claude, Cursor, and any MCP client. For CLI-driven agents, `guard --format json`
162
+ is the stable contract (findings with stable codes) and `guard --format sarif`
163
+ feeds GitHub Code Scanning. See [AI Integration](./ai-integration.md).
164
+
165
+ ### Guard flagged something that isn't wrong. What do I do?
166
+
167
+ Suppress it **at the finding site** with its code — `// docguard:ignore SEC001`
168
+ on (or above) the flagged line — and report it with `docguard feedback` (a
169
+ local-first record plus a one-click prefilled GitHub issue). Don't disable the
170
+ whole validator for one false positive.
@@ -3,7 +3,7 @@ schema_version: "1.0"
3
3
  extension:
4
4
  id: "docguard"
5
5
  name: "DocGuard — CDD Enforcement"
6
- version: "0.28.0"
6
+ version: "0.29.0"
7
7
  description: "Canonical-Driven Development enforcement as a true spec-kit extension. LLM-first design with automated validators, 4 AI behavior skills, spec-kit skill chaining, and workflow hooks. One pinned runtime dependency (@babel/parser); pure Node.js otherwise."
8
8
  author: "Ricardo Accioly"
9
9
  repository: "https://github.com/raccioly/docguard"
@@ -6,10 +6,10 @@ description: AI-driven documentation repair with structured research workflow, t
6
6
  compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
7
7
  metadata:
8
8
  author: docguard
9
- version: 0.28.0
9
+ version: 0.29.0
10
10
  source: extensions/spec-kit-docguard/skills/docguard-fix
11
11
  ---
12
- <!-- docguard:version: 0.28.0 -->
12
+ <!-- docguard:version: 0.29.0 -->
13
13
 
14
14
  # DocGuard Fix Skill
15
15
 
@@ -7,10 +7,10 @@ description: Run DocGuard guard validation against Canonical-Driven Development
7
7
  compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
8
8
  metadata:
9
9
  author: docguard
10
- version: 0.28.0
10
+ version: 0.29.0
11
11
  source: extensions/spec-kit-docguard/skills/docguard-guard
12
12
  ---
13
- <!-- docguard:version: 0.28.0 -->
13
+ <!-- docguard:version: 0.29.0 -->
14
14
 
15
15
  # DocGuard Guard Skill
16
16
 
@@ -6,10 +6,10 @@ description: Cross-document consistency analysis and quality assessment. Perform
6
6
  compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
7
7
  metadata:
8
8
  author: docguard
9
- version: 0.28.0
9
+ version: 0.29.0
10
10
  source: extensions/spec-kit-docguard/skills/docguard-review
11
11
  ---
12
- <!-- docguard:version: 0.28.0 -->
12
+ <!-- docguard:version: 0.29.0 -->
13
13
 
14
14
  # DocGuard Review Skill
15
15
 
@@ -6,10 +6,10 @@ description: CDD maturity assessment with category-aware improvement roadmap. Ru
6
6
  compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
7
7
  metadata:
8
8
  author: docguard
9
- version: 0.28.0
9
+ version: 0.29.0
10
10
  source: extensions/spec-kit-docguard/skills/docguard-score
11
11
  ---
12
- <!-- docguard:version: 0.28.0 -->
12
+ <!-- docguard:version: 0.29.0 -->
13
13
 
14
14
  # DocGuard Score Skill
15
15
 
@@ -4,10 +4,10 @@ description: Keep canonical documentation ALWAYS UP TO DATE. Refreshes code-trut
4
4
  compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
5
5
  metadata:
6
6
  author: docguard
7
- version: 0.28.0
7
+ version: 0.29.0
8
8
  source: extensions/spec-kit-docguard/skills/docguard-sync
9
9
  ---
10
- <!-- docguard:version: 0.28.0 -->
10
+ <!-- docguard:version: 0.29.0 -->
11
11
 
12
12
  # DocGuard Sync Skill
13
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docguard-cli",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "The enforcement tool for Canonical-Driven Development (CDD). Audit, generate, and guard your project documentation.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -175,6 +175,23 @@
175
175
  }
176
176
  },
177
177
  "additionalProperties": true
178
+ },
179
+ "docs": {
180
+ "type": "object",
181
+ "description": "Documentation discovery (field report #6 follow-up).",
182
+ "properties": {
183
+ "dirs": {
184
+ "type": "array",
185
+ "items": { "type": "string" },
186
+ "description": "Additional documentation-home directories to claim-scan and count as 'tracked' (relative paths, e.g. [\"reference\", \"website/docs\"]). This EXTENDS the auto-detected conventional homes (docs/, doc/, documentation/, guides/, guide/, handbook/, manual/, wiki/, docs-canonical/, docs-implementation/, extensions/) — it never replaces them, since the goal is to track MORE clearly-documentation folders automatically. Only NAMED dirs are scanned; arbitrary subdirectories are never walked. To EXCLUDE a conventional dir, list it in .docguardignore."
187
+ }
188
+ },
189
+ "additionalProperties": true
190
+ },
191
+ "collections": {
192
+ "type": "object",
193
+ "description": "Project-declared collections (field report #6): maps a documentation noun (e.g. \"extractors\") to a glob whose matching-file count is the source of truth. Metrics-Consistency then flags a documented count that disagrees (\"16 extractors\" in prose vs 19 files on disk), deterministically and with no LLM. A declared collection IS the opt-in binding, so — unlike the built-in checks/validators counts — it does not require the noun's line to mention \"docguard\". An unresolved glob (0 matches) is skipped, never asserting \"0\". Reserved nouns (checks, validators, tests) keep their built-in meaning. Complements surfaceSync (WHICH members drift) with a count check (HOW MANY). Example: { \"extractors\": \"src/extractors/*.py\", \"commands\": \"cli/commands/*.mjs\" }.",
194
+ "additionalProperties": { "type": "string" }
178
195
  }
179
196
  },
180
197
  "additionalProperties": true
@@ -13,29 +13,47 @@ handoffs:
13
13
 
14
14
  You are an AI agent responsible for maintaining documentation quality using DocGuard.
15
15
 
16
- ## Step 1: Assess Current State
16
+ ## Step 1: Mechanical fixes first (no AI judgment needed)
17
17
 
18
18
  ```bash
19
- npx docguard-cli diagnose
19
+ npx docguard-cli fix --write
20
20
  ```
21
21
 
22
- Parse the output to identify all issues categorized as errors or warnings with AI-ready fix prompts.
22
+ This deterministically applies the safe fix class: broken doc anchors, stale
23
+ counts bound to code collections, stale version references. Each fix is
24
+ provenance-checked and fail-closed — it never rewrites content whose source of
25
+ truth it cannot verify. Doing this first shrinks the issue list you research.
23
26
 
24
- If no issues found, report "All CDD documentation is up to date" and stop.
27
+ ## Step 2: Assess what remains
25
28
 
26
- ## Step 2: Fix Each Issue
29
+ ```bash
30
+ npx docguard-cli diagnose
31
+ ```
27
32
 
28
- For each issue, determine the fix type:
33
+ Parse the output issues are categorized with AI-ready fix prompts. Every
34
+ finding carries a stable code; run `npx docguard-cli explain <CODE>` whenever
35
+ the right remediation isn't obvious from the message.
36
+
37
+ If no issues remain, report "All CDD documentation is up to date" and stop.
38
+
39
+ ## Step 3: Fix each issue
29
40
 
30
41
  | Issue Type | Action |
31
42
  |-----------|--------|
32
43
  | `missing-file` | Run `npx docguard-cli fix --doc <name>` to generate |
33
- | `empty-doc` / `partial-doc` | Proceed to Step 3 for codebase research |
44
+ | `empty-doc` / `partial-doc` | Proceed to Step 4 for codebase research |
34
45
  | `missing-config` | Create `.docguard.json` based on project type |
35
46
  | `stale-doc` | Update `docguard:last-reviewed` date and content |
36
47
  | `quality-issue` | Fix negation language, add missing sections |
48
+ | false positive | Suppress at the site: `// docguard:ignore <CODE>` (with a reason comment), and report it: `npx docguard-cli feedback` |
49
+
50
+ **Doc wrong vs code wrong:** a doc/code mismatch does not automatically mean
51
+ the doc is stale. Canonical docs are the spec — if the code drifted from a
52
+ documented decision, flag the code (or record the deviation with a
53
+ `// DRIFT: reason` comment + DRIFT-LOG.md entry) instead of silently rewriting
54
+ the doc to match the regression.
37
55
 
38
- ## Step 3: Write Real Content
56
+ ## Step 4: Write real content
39
57
 
40
58
  For each document that needs content:
41
59
 
@@ -50,12 +68,17 @@ Read the output carefully — it contains:
50
68
  - **WRITE THE DOCUMENT**: Expected structure and content for each section
51
69
 
52
70
  Execute the research steps, then write with REAL project content. No placeholders.
71
+ Never edit inside `<!-- docguard:section ... source=code -->` markers by hand —
72
+ those bodies are regenerated from code by `docguard sync --write`; pin them
73
+ (`pinned="reason"`) if a hand-maintained exception is genuinely needed.
53
74
 
54
- ## Step 4: Verify (Iterate up to 3 times)
75
+ ## Step 5: Verify (iterate up to 3 times)
55
76
 
56
77
  ```bash
57
78
  npx docguard-cli guard
58
79
  npx docguard-cli score
59
80
  ```
60
81
 
61
- All checks should pass. If any fail, read the output and fix remaining issues. Report the final CDD score.
82
+ All checks should pass. If any fail, read the output and fix remaining issues.
83
+ Report the final CDD score, plus anything you suppressed (with reasons) or
84
+ reported as a false positive.