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.
- package/README.es.md +102 -0
- package/README.md +64 -31
- package/README.pt-BR.md +101 -0
- package/STANDARD.md +20 -10
- package/cli/commands/agents.mjs +149 -0
- package/cli/commands/diff.mjs +6 -15
- package/cli/commands/generate.mjs +14 -1001
- package/cli/commands/guard.mjs +136 -8
- package/cli/commands/llms.mjs +67 -5
- package/cli/commands/mcp.mjs +263 -0
- package/cli/commands/memory.mjs +115 -0
- package/cli/commands/score.mjs +76 -12
- package/cli/docguard.mjs +31 -2
- package/cli/findings.mjs +499 -0
- package/cli/scanners/agent-readability.mjs +202 -0
- package/cli/scanners/semantic-claims.mjs +7 -1
- package/cli/scanners/speckit.mjs +98 -28
- package/cli/shared-ignore.mjs +148 -16
- package/cli/shared.mjs +45 -1
- package/cli/validators/api-surface.mjs +113 -26
- package/cli/validators/architecture.mjs +66 -43
- package/cli/validators/canonical-sync.mjs +59 -28
- package/cli/validators/changelog.mjs +41 -17
- package/cli/validators/cross-reference.mjs +28 -11
- package/cli/validators/doc-quality.mjs +78 -44
- package/cli/validators/docs-coverage.mjs +90 -63
- package/cli/validators/docs-diff.mjs +63 -64
- package/cli/validators/docs-sync.mjs +48 -33
- package/cli/validators/drift.mjs +40 -34
- package/cli/validators/environment.mjs +67 -27
- package/cli/validators/freshness.mjs +12 -5
- package/cli/validators/generated-staleness.mjs +26 -10
- package/cli/validators/metadata-sync.mjs +28 -25
- package/cli/validators/metrics-consistency.mjs +89 -47
- package/cli/validators/schema-sync.mjs +37 -32
- package/cli/validators/security.mjs +7 -20
- package/cli/validators/spec-kit.mjs +3 -0
- package/cli/validators/structure.mjs +58 -23
- package/cli/validators/surface-sync.mjs +34 -15
- package/cli/validators/test-spec.mjs +87 -29
- package/cli/validators/todo-tracking.mjs +83 -74
- package/cli/validators/traceability.mjs +67 -39
- package/cli/writers/doc-generators.mjs +853 -0
- package/cli/writers/generate-io.mjs +142 -0
- package/cli/writers/sarif.mjs +129 -0
- package/commands/docguard.fix.md +56 -53
- package/commands/docguard.guard.md +53 -47
- package/commands/docguard.review.md +49 -31
- package/docs/ai-integration.md +133 -134
- package/docs/commands.md +49 -3
- package/docs/configuration.md +38 -0
- package/docs/faq.md +15 -0
- package/extensions/spec-kit-docguard/extension.yml +1 -1
- package/extensions/spec-kit-docguard/skills/docguard-fix/SKILL.md +2 -2
- package/extensions/spec-kit-docguard/skills/docguard-guard/SKILL.md +2 -2
- package/extensions/spec-kit-docguard/skills/docguard-review/SKILL.md +2 -2
- package/extensions/spec-kit-docguard/skills/docguard-score/SKILL.md +2 -2
- package/extensions/spec-kit-docguard/skills/docguard-sync/SKILL.md +2 -2
- package/package.json +1 -1
- package/schemas/docguard-config.schema.json +17 -0
- package/templates/commands/docguard.fix.md +33 -10
- package/templates/commands/docguard.guard.md +40 -26
- package/templates/commands/docguard.init.md +23 -11
- package/templates/commands/docguard.review.md +25 -8
- package/templates/commands/docguard.update.md +14 -4
|
@@ -13,41 +13,55 @@ handoffs:
|
|
|
13
13
|
|
|
14
14
|
You are an AI agent enforcing Canonical-Driven Development (CDD) compliance using DocGuard.
|
|
15
15
|
|
|
16
|
-
## Step 1: Run Guard
|
|
16
|
+
## Step 1: Run Guard (machine-readable)
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
npx docguard-cli guard
|
|
19
|
+
npx docguard-cli guard --format json
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Read the
|
|
22
|
+
Read the JSON contract — do not parse prose:
|
|
23
23
|
|
|
24
|
-
|
|
|
25
|
-
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
24
|
+
| Field | Meaning |
|
|
25
|
+
|-------|---------|
|
|
26
|
+
| `status` | `PASS` / `WARN` / `FAIL` (severity-aware; matches the exit code: 0/2/1) |
|
|
27
|
+
| `findings[]` | Structured issues: `{code, severity, confidence, message, location, suggestion}` |
|
|
28
|
+
| `nextStep` | The single suggested follow-up command (`null` on PASS) |
|
|
29
|
+
| `reportable[]` | Low-confidence findings (possible false positives) — verify before acting |
|
|
30
|
+
| `coverage` | Markdown tier map: `canonical / tracked / ignored / unclassified[]` |
|
|
31
|
+
| `semanticClaims.count` | Documented counts/limits/enums NOT yet verified against code |
|
|
32
|
+
| `validators[]` | Per-validator results, including `na` (nothing to validate ≠ pass) |
|
|
30
33
|
|
|
31
|
-
## Step 2:
|
|
34
|
+
## Step 2: Understand each finding before fixing
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
- Every finding carries a stable code (e.g. `STR001`, `ENV003`, `XRF002`). Run
|
|
37
|
+
`npx docguard-cli explain <CODE>` for its contract, cause, and remediation.
|
|
38
|
+
- `confidence: "low"` means the scanner itself is unsure — verify against the
|
|
39
|
+
code before changing anything, and report real false positives with
|
|
40
|
+
`npx docguard-cli feedback`.
|
|
41
|
+
- A finding's `suggestion` may include a ready-to-run `command` or an inline
|
|
42
|
+
`pragma`. Prefer those over inventing your own fix.
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
For each failing check, provide an **exact fix** — specific file, section, and content.
|
|
41
|
-
Then run the fix workflow:
|
|
42
|
-
```bash
|
|
43
|
-
npx docguard-cli fix --doc <name>
|
|
44
|
-
```
|
|
44
|
+
## Step 3: Fix, suppress, or escalate
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
1. **Mechanical issues first**: `npx docguard-cli fix --write` applies safe,
|
|
47
|
+
provenance-checked fixes (broken anchors, stale counts/versions). Never
|
|
48
|
+
hand-edit what the tool can fix deterministically.
|
|
49
|
+
2. **Prose/content issues**: follow the `/docguard.fix` workflow (research →
|
|
50
|
+
write real content).
|
|
51
|
+
3. **Genuine false positives**: suppress at the finding site with the code —
|
|
52
|
+
`// docguard:ignore <CODE>` on (or above) the flagged line — or mark a whole
|
|
53
|
+
validator not-applicable in a doc:
|
|
54
|
+
`<!-- docguard:validator <key> n/a — reason -->`. Always include the reason.
|
|
55
|
+
Never suppress to silence a real issue.
|
|
56
|
+
4. If `semanticClaims.count > 0`, offer to run `npx docguard-cli verify --semantic`
|
|
57
|
+
and check each extracted claim against the code — a green guard asserts
|
|
58
|
+
structure, not the truth of documented numbers.
|
|
47
59
|
|
|
48
|
-
## Step
|
|
60
|
+
## Step 4: Report
|
|
49
61
|
|
|
50
62
|
Show the user:
|
|
51
|
-
1.
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
1. `status` and pass/total, plus anything in `coverage.unclassified` (docs no
|
|
64
|
+
validator watches — suggest enrolling or ignoring them)
|
|
65
|
+
2. Each finding fixed (by code), each suppressed (with reason), each reported
|
|
66
|
+
as a false positive
|
|
67
|
+
3. Final score: `npx docguard-cli score`
|
|
@@ -21,21 +21,33 @@ npx docguard-cli init
|
|
|
21
21
|
|
|
22
22
|
This creates the folder structure and template files. The templates are skeletons — they need real content.
|
|
23
23
|
|
|
24
|
-
## Step 2:
|
|
24
|
+
## Step 2: Pick the Right Profile
|
|
25
|
+
|
|
26
|
+
`init` auto-detects the project type, but verify the profile fits — it sets
|
|
27
|
+
which docs are required (a CLI shouldn't be forced to document an HTTP API):
|
|
28
|
+
|
|
29
|
+
| Signal | Profile in `.docguard.json` |
|
|
30
|
+
|--------|------------------------------|
|
|
31
|
+
| Has `bin` field / CLI tool | `"profile": "cli"` |
|
|
32
|
+
| Publishable package | `"profile": "library"` |
|
|
33
|
+
| Side project / prototype | `"profile": "starter"` |
|
|
34
|
+
| Team web app / API | `"profile": "standard"` (default) |
|
|
35
|
+
| Regulated / strict | `"profile": "enterprise"` |
|
|
36
|
+
|
|
37
|
+
Only schema-valid keys belong in `.docguard.json` — check
|
|
38
|
+
`schemas/docguard-config.schema.json` (shipped in the package) before adding
|
|
39
|
+
anything. If the project has domain collections (extractors, plugins, rules…),
|
|
40
|
+
declare them so documented counts are verified against code:
|
|
41
|
+
`"collections": { "extractors": "src/extractors/*.py" }`.
|
|
42
|
+
|
|
43
|
+
For an EXISTING codebase, prefer reverse-engineering over blank skeletons:
|
|
25
44
|
|
|
26
45
|
```bash
|
|
27
|
-
|
|
46
|
+
npx docguard-cli generate --plan --write
|
|
28
47
|
```
|
|
29
48
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
| Signal | Setting |
|
|
33
|
-
|--------|---------|
|
|
34
|
-
| Has `bin` field | `projectType: "cli"` |
|
|
35
|
-
| Has react/next/vue | `projectType: "webapp"`, `needsE2E: true` |
|
|
36
|
-
| Has express/fastify | `projectType: "api"`, `needsEnvVars: true` |
|
|
37
|
-
| Has database deps | `needsDatabase: true` |
|
|
38
|
-
| Default | `projectType: "library"` |
|
|
49
|
+
This pre-fills code-truth sections (routes, schemas, env vars) and leaves you
|
|
50
|
+
an agent-task list for the prose.
|
|
39
51
|
|
|
40
52
|
## Step 3: Write Real Documentation
|
|
41
53
|
|
|
@@ -22,8 +22,21 @@ npx docguard-cli score
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Read all output. Identify where documentation no longer matches the codebase.
|
|
25
|
+
Findings carry stable codes — `npx docguard-cli explain <CODE>` when unclear.
|
|
25
26
|
|
|
26
|
-
## Step 2:
|
|
27
|
+
## Step 2: Verify Documented Claims Against Code
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx docguard-cli verify --semantic
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This extracts every checkable claim in the canonical docs — counts, limits,
|
|
34
|
+
rate numbers, retention windows, status enums — as a task list with the nearest
|
|
35
|
+
cited code path. **You perform each verification**: read the cited code, compare
|
|
36
|
+
the value, and report every mismatch with both values. This is the highest-value
|
|
37
|
+
review step; deterministic validators cannot judge these.
|
|
38
|
+
|
|
39
|
+
## Step 3: Semantic Analysis (Beyond CLI)
|
|
27
40
|
|
|
28
41
|
For each canonical doc, verify alignment with actual code:
|
|
29
42
|
|
|
@@ -35,16 +48,20 @@ For each canonical doc, verify alignment with actual code:
|
|
|
35
48
|
| Test Coverage | Critical flows in TEST-SPEC.md have actual test files |
|
|
36
49
|
| Terminology | Same concepts named consistently across all docs |
|
|
37
50
|
|
|
38
|
-
## Step
|
|
51
|
+
## Step 4: Update Stale Docs
|
|
39
52
|
|
|
40
53
|
For each stale or drifted document:
|
|
41
|
-
1.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
1. **Decide which side is wrong first.** Canonical docs are the spec — if the
|
|
55
|
+
code regressed from a documented decision, flag the code (or record a
|
|
56
|
+
`// DRIFT: reason` + DRIFT-LOG.md entry); don't rewrite the doc to match a
|
|
57
|
+
regression.
|
|
58
|
+
2. Sections inside `<!-- docguard:section ... source=code -->` markers are
|
|
59
|
+
regenerated — run `npx docguard-cli sync --write` instead of editing by hand.
|
|
60
|
+
3. For hand-maintained sections: read the relevant source, update the specific
|
|
61
|
+
section, refresh `docguard:last-reviewed` to today.
|
|
62
|
+
4. Add entry to CHANGELOG.md under [Unreleased].
|
|
46
63
|
|
|
47
|
-
## Step
|
|
64
|
+
## Step 5: Verify
|
|
48
65
|
|
|
49
66
|
```bash
|
|
50
67
|
npx docguard-cli guard
|
|
@@ -16,11 +16,12 @@ You are an AI agent that updates documentation to reflect recent code changes.
|
|
|
16
16
|
## Step 1: Identify What Changed
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
+
npx docguard-cli diff --since HEAD~5
|
|
19
20
|
git log --oneline -10
|
|
20
|
-
git diff HEAD~5 --stat
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
`diff --since` maps the changed files directly to the canonical docs they
|
|
24
|
+
affect — read its output first; the git log supplies the "why".
|
|
24
25
|
|
|
25
26
|
## Step 2: Check Which Docs Are Affected
|
|
26
27
|
|
|
@@ -38,10 +39,19 @@ For each changed file, determine which canonical doc it affects:
|
|
|
38
39
|
|
|
39
40
|
## Step 3: Update Each Affected Doc
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
Mechanical layers first — they update marked sections and counts without AI
|
|
43
|
+
judgment:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx docguard-cli sync --write
|
|
47
|
+
npx docguard-cli fix --write
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Then, for each remaining affected document:
|
|
42
51
|
1. Read the current document
|
|
43
52
|
2. Read the relevant source code changes
|
|
44
|
-
3. Update the specific section that changed
|
|
53
|
+
3. Update the specific section that changed (never hand-edit inside
|
|
54
|
+
`<!-- docguard:section ... source=code -->` markers — sync owns those)
|
|
45
55
|
4. Update the `docguard:last-reviewed` date to today
|
|
46
56
|
5. Add entry to CHANGELOG.md under [Unreleased]
|
|
47
57
|
|