docguard-cli 0.35.0 → 0.36.1

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 (55) hide show
  1. package/README.md +8 -15
  2. package/cli/commands/agent.mjs +27 -6
  3. package/cli/commands/ci.mjs +3 -0
  4. package/cli/commands/diagnose.mjs +8 -2
  5. package/cli/commands/feedback.mjs +83 -89
  6. package/cli/commands/fix.mjs +4 -0
  7. package/cli/commands/generate.mjs +3 -0
  8. package/cli/commands/guard.mjs +37 -20
  9. package/cli/commands/hooks.mjs +61 -40
  10. package/cli/commands/init.mjs +51 -5
  11. package/cli/commands/memory.mjs +29 -15
  12. package/cli/commands/report.mjs +12 -7
  13. package/cli/commands/score.mjs +39 -19
  14. package/cli/commands/sync.mjs +2 -0
  15. package/cli/commands/watch.mjs +113 -70
  16. package/cli/config.mjs +6 -3
  17. package/cli/docguard.mjs +12 -4
  18. package/cli/findings.mjs +13 -13
  19. package/cli/scanners/memory-plan.mjs +279 -134
  20. package/cli/scanners/project-type.mjs +6 -1
  21. package/cli/scanners/semantic-claims.mjs +176 -26
  22. package/cli/shared-diff.mjs +22 -1
  23. package/cli/shared-doc-roles.mjs +59 -0
  24. package/cli/shared-ignore.mjs +15 -2
  25. package/cli/shared-source.mjs +223 -1
  26. package/cli/validator-coverage.mjs +20 -0
  27. package/cli/validators/api-surface.mjs +94 -70
  28. package/cli/validators/architecture.mjs +19 -5
  29. package/cli/validators/diff-suspicion.mjs +45 -9
  30. package/cli/validators/docs-coverage.mjs +6 -5
  31. package/cli/validators/docs-diff.mjs +51 -7
  32. package/cli/validators/environment.mjs +3 -2
  33. package/cli/validators/freshness.mjs +140 -83
  34. package/cli/validators/schema-sync.mjs +3 -2
  35. package/cli/validators/security.mjs +58 -23
  36. package/cli/validators/structure.mjs +3 -1
  37. package/cli/validators/test-spec.mjs +3 -2
  38. package/cli/validators/todo-tracking.mjs +61 -28
  39. package/cli/validators/traceability.mjs +152 -38
  40. package/docs/configuration.md +41 -0
  41. package/extensions/spec-kit-docguard/README.md +6 -6
  42. package/extensions/spec-kit-docguard/commands/sync.md +1 -1
  43. package/extensions/spec-kit-docguard/extension.yml +3 -4
  44. package/extensions/spec-kit-docguard/scripts/bash/common.sh +9 -17
  45. package/extensions/spec-kit-docguard/scripts/bash/docguard-check-docs.sh +18 -11
  46. package/extensions/spec-kit-docguard/skills/docguard-fix/SKILL.md +3 -3
  47. package/extensions/spec-kit-docguard/skills/docguard-guard/SKILL.md +2 -2
  48. package/extensions/spec-kit-docguard/skills/docguard-review/SKILL.md +2 -2
  49. package/extensions/spec-kit-docguard/skills/docguard-score/SKILL.md +2 -2
  50. package/extensions/spec-kit-docguard/skills/docguard-sync/SKILL.md +2 -2
  51. package/extensions/spec-kit-docguard/templates/extensions.yml +1 -2
  52. package/extensions/spec-kit-docguard/templates/github-workflows/docguard-guard.yml +74 -29
  53. package/package.json +1 -1
  54. package/schemas/docguard-config.schema.json +43 -1
  55. package/templates/ci/github-actions.yml +51 -11
@@ -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.35.0
9
+ version: 0.36.1
10
10
  source: extensions/spec-kit-docguard/skills/docguard-fix
11
11
  ---
12
- <!-- docguard:version: 0.35.0 -->
12
+ <!-- docguard:version: 0.36.1 -->
13
13
 
14
14
  # DocGuard Fix Skill
15
15
 
@@ -25,7 +25,7 @@ If no arguments, fix ALL issues found by `docguard diagnose`.
25
25
 
26
26
  ## Goal
27
27
 
28
- Research the actual codebase to generate or repair canonical documentation that passes DocGuard's 19-validator guard suite. This skill replaces generic templates with real, project-specific content and iterates until quality checks pass.
28
+ Research the actual codebase to generate or repair canonical documentation that passes DocGuard's configurable guard suite. This skill replaces generic templates with real, project-specific content and iterates until quality checks pass.
29
29
 
30
30
  ## Operating Constraints
31
31
 
@@ -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.35.0
10
+ version: 0.36.1
11
11
  source: extensions/spec-kit-docguard/skills/docguard-guard
12
12
  ---
13
- <!-- docguard:version: 0.35.0 -->
13
+ <!-- docguard:version: 0.36.1 -->
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.35.0
9
+ version: 0.36.1
10
10
  source: extensions/spec-kit-docguard/skills/docguard-review
11
11
  ---
12
- <!-- docguard:version: 0.35.0 -->
12
+ <!-- docguard:version: 0.36.1 -->
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.35.0
9
+ version: 0.36.1
10
10
  source: extensions/spec-kit-docguard/skills/docguard-score
11
11
  ---
12
- <!-- docguard:version: 0.35.0 -->
12
+ <!-- docguard:version: 0.36.1 -->
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.35.0
7
+ version: 0.36.1
8
8
  source: extensions/spec-kit-docguard/skills/docguard-sync
9
9
  ---
10
- <!-- docguard:version: 0.35.0 -->
10
+ <!-- docguard:version: 0.36.1 -->
11
11
 
12
12
  # DocGuard Sync Skill
13
13
 
@@ -17,8 +17,7 @@ hooks:
17
17
  command: speckit.docguard.guard
18
18
  description: "Validate documentation passes CDD standards after implementation"
19
19
  enabled: true
20
- optional: true
21
- prompt: "Run DocGuard guard to verify documentation quality after implementation changes?"
20
+ optional: false
22
21
 
23
22
  # Run DocGuard review before /speckit.tasks to catch doc drift early
24
23
  before_tasks:
@@ -1,48 +1,93 @@
1
- # DocGuard Guard runs all validators on every PR and main push.
2
- #
3
- # This is the canonical CI gate. It does NOT modify your repo — it only
4
- # reports. Pair with `docguard-autofix.yml` if you want mechanical fixes
5
- # applied automatically.
6
- #
7
- # Setup:
8
- # 1. Copy this file to .github/workflows/docguard-guard.yml
9
- # 2. (Optional) Set `fail-on-warning: 'true'` to make warnings block the PR.
1
+ # Copy this starter to .github/workflows/. Reports stay in runner temp.
2
+ # The static CLI pin is checked against package.json by ci-reproducibility tests.
3
+ # Warnings are non-blocking; set FAIL_ON_WARNING to true to make them fail.
10
4
  name: DocGuard Guard
11
5
 
12
6
  on:
13
- push:
14
- branches: [main]
15
7
  pull_request:
16
8
  branches: [main]
9
+ push:
10
+ branches: [main]
17
11
 
18
12
  permissions:
19
13
  contents: read
20
- pull-requests: write # only needed for the optional score comment below
21
14
 
22
15
  jobs:
23
16
  guard:
24
17
  runs-on: ubuntu-latest
18
+ env:
19
+ FAIL_ON_WARNING: 'false'
25
20
  steps:
26
- - uses: actions/checkout@v4
21
+ - name: Initialize report paths
22
+ shell: bash
23
+ run: |
24
+ echo "DOCGUARD_REPORT=$RUNNER_TEMP/docguard-report.json" >> "$GITHUB_ENV"
25
+ echo "DOCGUARD_LOG=$RUNNER_TEMP/docguard-stderr.log" >> "$GITHUB_ENV"
26
+ echo "DOCGUARD_SCORE=$RUNNER_TEMP/docguard-score.json" >> "$GITHUB_ENV"
27
+
28
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
27
29
  with:
28
- fetch-depth: 0
30
+ fetch-depth: 0 # Freshness needs the complete commit history.
31
+ persist-credentials: false
29
32
 
30
- - name: Run all validators
31
- uses: raccioly/docguard@v0.25.0
33
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
32
34
  with:
33
- command: guard
34
- # Flip to 'true' once your repo is clean — turns warnings into hard failures.
35
- fail-on-warning: 'false'
35
+ node-version: '20'
36
36
 
37
- # Optional: post the CDD score on every PR as a tracked metric.
38
- score:
39
- runs-on: ubuntu-latest
40
- if: github.event_name == 'pull_request'
41
- steps:
42
- - uses: actions/checkout@v4
37
+ - name: Install DocGuard
38
+ run: npm install --global --ignore-scripts docguard-cli@0.36.1
39
+
40
+ - name: Run DocGuard
41
+ shell: bash
42
+ run: |
43
+ status=0
44
+ docguard guard --format json > "$DOCGUARD_REPORT" 2> "$DOCGUARD_LOG" || status=$?
45
+ cat "$DOCGUARD_LOG" >&2
46
+ # Validate machine output and normalize the verdict from the actual
47
+ # exit code (including CI threshold failures in older releases).
48
+ DOCGUARD_STATUS="$status" node --input-type=module -e '
49
+ import fs from "node:fs";
50
+ const file = process.env.DOCGUARD_REPORT;
51
+ const report = JSON.parse(fs.readFileSync(file, "utf8"));
52
+ if (!report || typeof report !== "object" || Array.isArray(report)) throw new Error("Invalid DocGuard report");
53
+ const status = Number(process.env.DOCGUARD_STATUS);
54
+ report.status = status === 0 ? "PASS" : status === 2 ? "WARN" : "FAIL";
55
+ fs.writeFileSync(file, JSON.stringify(report, null, 2) + "\n");
56
+ '
57
+ if [ "$status" -eq 2 ] && [ "$FAIL_ON_WARNING" != 'true' ]; then
58
+ echo "::warning::DocGuard found warnings; see the report artifact"
59
+ exit 0
60
+ fi
61
+ exit "$status"
62
+
63
+ # Optional PR score stays read-only and travels with the findings artifact.
64
+ - name: Capture PR score
65
+ if: always() && github.event_name == 'pull_request'
66
+ run: docguard score --format json > "$DOCGUARD_SCORE"
67
+
68
+ - name: Display Results
69
+ if: always()
70
+ shell: bash
71
+ run: |
72
+ echo "## DocGuard Report" >> "$GITHUB_STEP_SUMMARY"
73
+ if [ -s "$DOCGUARD_REPORT" ]; then
74
+ echo '<details><summary>JSON findings</summary>' >> "$GITHUB_STEP_SUMMARY"
75
+ echo '' >> "$GITHUB_STEP_SUMMARY"
76
+ echo '````json' >> "$GITHUB_STEP_SUMMARY"
77
+ cat "$DOCGUARD_REPORT" >> "$GITHUB_STEP_SUMMARY"
78
+ echo '````' >> "$GITHUB_STEP_SUMMARY"
79
+ echo '</details>' >> "$GITHUB_STEP_SUMMARY"
80
+ else
81
+ echo 'No report produced; inspect the install/run logs.' >> "$GITHUB_STEP_SUMMARY"
82
+ fi
43
83
 
44
- - name: Score & comment
45
- uses: raccioly/docguard@v0.25.0
84
+ - name: Upload Report
85
+ if: always()
86
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
46
87
  with:
47
- command: score
48
- format: json
88
+ name: docguard-report
89
+ path: |
90
+ ${{ env.DOCGUARD_REPORT }}
91
+ ${{ env.DOCGUARD_LOG }}
92
+ ${{ env.DOCGUARD_SCORE }}
93
+ if-no-files-found: warn
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docguard-cli",
3
- "version": "0.35.0",
3
+ "version": "0.36.1",
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": {
@@ -185,10 +185,52 @@
185
185
  "type": "object",
186
186
  "description": "Documentation discovery (field report #6 follow-up).",
187
187
  "properties": {
188
+ "roles": {
189
+ "type": "object",
190
+ "description": "Explicit canonical document roles in an existing layout. Each mapping is required and remains subject to content checks; maps do not certify prose or change historical intent.",
191
+ "properties": {
192
+ "architecture": {
193
+ "type": "string",
194
+ "minLength": 1,
195
+ "pattern": "\\.[mM][dD]$"
196
+ },
197
+ "dataModel": {
198
+ "type": "string",
199
+ "minLength": 1,
200
+ "pattern": "\\.[mM][dD]$"
201
+ },
202
+ "security": {
203
+ "type": "string",
204
+ "minLength": 1,
205
+ "pattern": "\\.[mM][dD]$"
206
+ },
207
+ "testSpec": {
208
+ "type": "string",
209
+ "minLength": 1,
210
+ "pattern": "\\.[mM][dD]$"
211
+ },
212
+ "environment": {
213
+ "type": "string",
214
+ "minLength": 1,
215
+ "pattern": "\\.[mM][dD]$"
216
+ },
217
+ "apiReference": {
218
+ "type": "string",
219
+ "minLength": 1,
220
+ "pattern": "\\.[mM][dD]$"
221
+ },
222
+ "requirements": {
223
+ "type": "string",
224
+ "minLength": 1,
225
+ "pattern": "\\.[mM][dD]$"
226
+ }
227
+ },
228
+ "additionalProperties": false
229
+ },
188
230
  "dirs": {
189
231
  "type": "array",
190
232
  "items": { "type": "string" },
191
- "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."
233
+ "description": "Additional documentation inventory directories, extending conventional homes. Explicit directories also participate in freshness review. Inventory membership does not imply every detector scans every document; semantic extraction has its own declared scope. Use docs.roles to map existing Markdown documents to canonical roles, and .docguardignore to exclude paths."
192
234
  }
193
235
  },
194
236
  "additionalProperties": true
@@ -1,3 +1,5 @@
1
+ # Copy this starter to .github/workflows/. Reports stay in runner temp.
2
+ # The static CLI pin is checked against package.json by ci-reproducibility tests.
1
3
  name: DocGuard CDD Check
2
4
 
3
5
  on:
@@ -11,29 +13,67 @@ permissions:
11
13
 
12
14
  jobs:
13
15
  docguard:
14
- name: CDD Compliance
15
16
  runs-on: ubuntu-latest
16
17
  steps:
17
- - uses: actions/checkout@v4
18
+ - name: Initialize report paths
19
+ shell: bash
20
+ run: |
21
+ echo "DOCGUARD_REPORT=$RUNNER_TEMP/docguard-report.json" >> "$GITHUB_ENV"
22
+ echo "DOCGUARD_LOG=$RUNNER_TEMP/docguard-stderr.log" >> "$GITHUB_ENV"
23
+
24
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
25
+ with:
26
+ fetch-depth: 0 # Freshness needs the complete commit history.
27
+ persist-credentials: false
18
28
 
19
- - uses: actions/setup-node@v4
29
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
20
30
  with:
21
31
  node-version: '20'
22
32
 
23
- - name: Run DocGuard CI
24
- run: npx docguard-cli ci --format json --threshold 70 > docguard-report.json
33
+ - name: Install DocGuard
34
+ run: npm install --global --ignore-scripts docguard-cli@0.36.1
35
+
36
+ - name: Run DocGuard
37
+ shell: bash
38
+ run: |
39
+ status=0
40
+ docguard ci --format json --threshold 70 --no-history > "$DOCGUARD_REPORT" 2> "$DOCGUARD_LOG" || status=$?
41
+ cat "$DOCGUARD_LOG" >&2
42
+ # Validate machine output and normalize the verdict from the actual
43
+ # exit code (including CI threshold failures in older releases).
44
+ DOCGUARD_STATUS="$status" node --input-type=module -e '
45
+ import fs from "node:fs";
46
+ const file = process.env.DOCGUARD_REPORT;
47
+ const report = JSON.parse(fs.readFileSync(file, "utf8"));
48
+ if (!report || typeof report !== "object" || Array.isArray(report)) throw new Error("Invalid DocGuard report");
49
+ const status = Number(process.env.DOCGUARD_STATUS);
50
+ report.status = status === 0 ? "PASS" : status === 2 ? "WARN" : "FAIL";
51
+ fs.writeFileSync(file, JSON.stringify(report, null, 2) + "\n");
52
+ '
53
+ exit "$status"
25
54
 
26
55
  - name: Display Results
27
56
  if: always()
57
+ shell: bash
28
58
  run: |
29
- echo "## DocGuard Report" >> $GITHUB_STEP_SUMMARY
30
- echo '```json' >> $GITHUB_STEP_SUMMARY
31
- cat docguard-report.json >> $GITHUB_STEP_SUMMARY
32
- echo '```' >> $GITHUB_STEP_SUMMARY
59
+ echo "## DocGuard Report" >> "$GITHUB_STEP_SUMMARY"
60
+ if [ -s "$DOCGUARD_REPORT" ]; then
61
+ echo '<details><summary>JSON findings</summary>' >> "$GITHUB_STEP_SUMMARY"
62
+ echo '' >> "$GITHUB_STEP_SUMMARY"
63
+ echo '````json' >> "$GITHUB_STEP_SUMMARY"
64
+ cat "$DOCGUARD_REPORT" >> "$GITHUB_STEP_SUMMARY"
65
+ echo '````' >> "$GITHUB_STEP_SUMMARY"
66
+ echo '</details>' >> "$GITHUB_STEP_SUMMARY"
67
+ else
68
+ echo 'No report produced; inspect the install/run logs.' >> "$GITHUB_STEP_SUMMARY"
69
+ fi
33
70
 
34
71
  - name: Upload Report
35
72
  if: always()
36
- uses: actions/upload-artifact@v4
73
+ uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
37
74
  with:
38
75
  name: docguard-report
39
- path: docguard-report.json
76
+ path: |
77
+ ${{ env.DOCGUARD_REPORT }}
78
+ ${{ env.DOCGUARD_LOG }}
79
+ if-no-files-found: warn