docguard-cli 0.9.5 → 0.9.6
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.md +281 -203
- package/cli/validators/metrics-consistency.mjs +2 -1
- package/commands/docguard.fix.md +37 -17
- package/commands/docguard.guard.md +45 -12
- package/commands/docguard.review.md +37 -19
- package/commands/docguard.score.md +36 -17
- package/docs/installation.md +37 -19
- package/docs/quickstart.md +21 -6
- package/extensions/spec-kit-docguard/LICENSE +21 -0
- package/extensions/spec-kit-docguard/README.md +105 -0
- package/extensions/spec-kit-docguard/commands/diagnose.md +43 -0
- package/extensions/spec-kit-docguard/commands/generate.md +50 -0
- package/extensions/spec-kit-docguard/commands/guard.md +73 -0
- package/extensions/spec-kit-docguard/commands/init.md +38 -0
- package/extensions/spec-kit-docguard/commands/score.md +53 -0
- package/extensions/spec-kit-docguard/commands/trace.md +56 -0
- package/extensions/spec-kit-docguard/extension.yml +109 -0
- package/extensions/spec-kit-docguard/scripts/bash/common.sh +106 -0
- package/extensions/spec-kit-docguard/scripts/bash/docguard-check-docs.sh +153 -0
- package/extensions/spec-kit-docguard/scripts/bash/docguard-init-doc.sh +153 -0
- package/extensions/spec-kit-docguard/scripts/bash/docguard-suggest-fix.sh +107 -0
- package/extensions/spec-kit-docguard/skills/docguard-fix/SKILL.md +218 -0
- package/extensions/spec-kit-docguard/skills/docguard-guard/SKILL.md +167 -0
- package/extensions/spec-kit-docguard/skills/docguard-review/SKILL.md +182 -0
- package/extensions/spec-kit-docguard/skills/docguard-score/SKILL.md +178 -0
- package/extensions/spec-kit-docguard/templates/extensions.yml +39 -0
- package/package.json +2 -1
- package/templates/commands/docguard.fix.md +35 -39
- package/templates/commands/docguard.guard.md +26 -13
- package/templates/commands/docguard.init.md +35 -28
- package/templates/commands/docguard.review.md +33 -23
- package/templates/commands/docguard.update.md +15 -4
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# DocGuard — Initialize a new canonical document with metadata header
|
|
3
|
+
# Copies template and adds DocGuard metadata scaffolding
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# ./docguard-init-doc.sh <doc-name> [--json] [--version X.X.X]
|
|
7
|
+
#
|
|
8
|
+
# Examples:
|
|
9
|
+
# ./docguard-init-doc.sh architecture
|
|
10
|
+
# ./docguard-init-doc.sh security --json --version 0.5.0
|
|
11
|
+
#
|
|
12
|
+
# JSON output fields:
|
|
13
|
+
# DOC_PATH — absolute path to created document
|
|
14
|
+
# DOC_NAME — canonical document name
|
|
15
|
+
# TEMPLATE — template used (if any)
|
|
16
|
+
# CREATED — whether file was created (true/false)
|
|
17
|
+
|
|
18
|
+
set -e
|
|
19
|
+
|
|
20
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
21
|
+
source "$SCRIPT_DIR/common.sh"
|
|
22
|
+
|
|
23
|
+
JSON_MODE=false
|
|
24
|
+
DOC_VERSION="0.1.0"
|
|
25
|
+
DOC_NAME=""
|
|
26
|
+
|
|
27
|
+
while [ $# -gt 0 ]; do
|
|
28
|
+
case "$1" in
|
|
29
|
+
--json) JSON_MODE=true ;;
|
|
30
|
+
--version)
|
|
31
|
+
shift
|
|
32
|
+
DOC_VERSION="${1:-0.1.0}"
|
|
33
|
+
;;
|
|
34
|
+
--help|-h)
|
|
35
|
+
echo "Usage: $0 <doc-name> [--json] [--version X.X.X]"
|
|
36
|
+
echo ""
|
|
37
|
+
echo "Document names: architecture, data-model, security, test-spec, environment, requirements"
|
|
38
|
+
echo ""
|
|
39
|
+
echo "Options:"
|
|
40
|
+
echo " --json Output in JSON format"
|
|
41
|
+
echo " --version X.X.X Set initial version (default: 0.1.0)"
|
|
42
|
+
echo " --help Show this help"
|
|
43
|
+
exit 0
|
|
44
|
+
;;
|
|
45
|
+
*)
|
|
46
|
+
if [ -z "$DOC_NAME" ]; then
|
|
47
|
+
DOC_NAME="$1"
|
|
48
|
+
else
|
|
49
|
+
echo "Error: Unexpected argument: $1" >&2
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
;;
|
|
53
|
+
esac
|
|
54
|
+
shift
|
|
55
|
+
done
|
|
56
|
+
|
|
57
|
+
if [ -z "$DOC_NAME" ]; then
|
|
58
|
+
echo "Error: Document name required" >&2
|
|
59
|
+
echo "Usage: $0 <doc-name> [--json] [--version X.X.X]" >&2
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Normalize document name
|
|
64
|
+
DOC_NAME_UPPER=$(echo "$DOC_NAME" | tr '[:lower:]' '[:upper:]' | tr '-' '-')
|
|
65
|
+
DOC_FILE="docs-canonical/${DOC_NAME_UPPER}.md"
|
|
66
|
+
|
|
67
|
+
# Find project root
|
|
68
|
+
PROJECT_ROOT=$(find_docguard_root "$(pwd)") || {
|
|
69
|
+
echo "Error: No DocGuard project found." >&2
|
|
70
|
+
exit 1
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
cd "$PROJECT_ROOT"
|
|
74
|
+
|
|
75
|
+
DOC_PATH="$PROJECT_ROOT/$DOC_FILE"
|
|
76
|
+
CREATED=false
|
|
77
|
+
TEMPLATE_USED=""
|
|
78
|
+
|
|
79
|
+
# Check if file already exists
|
|
80
|
+
if [ -f "$DOC_PATH" ]; then
|
|
81
|
+
if $JSON_MODE; then
|
|
82
|
+
echo "{\"docPath\":\"$(json_escape "$DOC_PATH")\",\"docName\":\"$(json_escape "$DOC_NAME_UPPER")\",\"created\":false,\"reason\":\"File already exists\"}"
|
|
83
|
+
else
|
|
84
|
+
echo "⚠ $DOC_FILE already exists. Use docguard fix to update it."
|
|
85
|
+
fi
|
|
86
|
+
exit 0
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
# Ensure docs-canonical directory exists
|
|
90
|
+
ensure_dir "$PROJECT_ROOT/docs-canonical"
|
|
91
|
+
|
|
92
|
+
# Check for template
|
|
93
|
+
TEMPLATE_DIR="$PROJECT_ROOT/templates"
|
|
94
|
+
TEMPLATE_FILE="$TEMPLATE_DIR/${DOC_NAME_UPPER}.md"
|
|
95
|
+
|
|
96
|
+
# Generate metadata header
|
|
97
|
+
TODAY=$(today_iso)
|
|
98
|
+
HEADER="# ${DOC_NAME_UPPER}
|
|
99
|
+
|
|
100
|
+
<!-- docguard:version ${DOC_VERSION} -->
|
|
101
|
+
<!-- docguard:status active -->
|
|
102
|
+
<!-- docguard:last-reviewed ${TODAY} -->
|
|
103
|
+
"
|
|
104
|
+
|
|
105
|
+
if [ -f "$TEMPLATE_FILE" ]; then
|
|
106
|
+
# Use template, but replace/add metadata header
|
|
107
|
+
cp "$TEMPLATE_FILE" "$DOC_PATH"
|
|
108
|
+
TEMPLATE_USED="$TEMPLATE_FILE"
|
|
109
|
+
|
|
110
|
+
# Ensure metadata header exists
|
|
111
|
+
if ! grep -q "docguard:version" "$DOC_PATH"; then
|
|
112
|
+
# Prepend metadata after first heading
|
|
113
|
+
tmp_file=$(mktemp)
|
|
114
|
+
head -1 "$DOC_PATH" > "$tmp_file"
|
|
115
|
+
echo "" >> "$tmp_file"
|
|
116
|
+
echo "<!-- docguard:version ${DOC_VERSION} -->" >> "$tmp_file"
|
|
117
|
+
echo "<!-- docguard:status active -->" >> "$tmp_file"
|
|
118
|
+
echo "<!-- docguard:last-reviewed ${TODAY} -->" >> "$tmp_file"
|
|
119
|
+
tail -n +2 "$DOC_PATH" >> "$tmp_file"
|
|
120
|
+
mv "$tmp_file" "$DOC_PATH"
|
|
121
|
+
fi
|
|
122
|
+
CREATED=true
|
|
123
|
+
else
|
|
124
|
+
# Generate from scratch with skeleton
|
|
125
|
+
cat > "$DOC_PATH" << EOF
|
|
126
|
+
${HEADER}
|
|
127
|
+
<!-- ACTION REQUIRED: This is a skeleton document. Fill each section with
|
|
128
|
+
real project-specific content. Run 'docguard fix --doc ${DOC_NAME}' for
|
|
129
|
+
AI-generated guidance on what to write. -->
|
|
130
|
+
|
|
131
|
+
## Overview
|
|
132
|
+
|
|
133
|
+
[Describe the purpose of this document and what it covers]
|
|
134
|
+
|
|
135
|
+
## Details
|
|
136
|
+
|
|
137
|
+
[Add project-specific content here]
|
|
138
|
+
|
|
139
|
+
## References
|
|
140
|
+
|
|
141
|
+
- [Link to related documents or resources]
|
|
142
|
+
EOF
|
|
143
|
+
CREATED=true
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
if $JSON_MODE; then
|
|
147
|
+
echo "{\"docPath\":\"$(json_escape "$DOC_PATH")\",\"docName\":\"$(json_escape "$DOC_NAME_UPPER")\",\"template\":\"$(json_escape "$TEMPLATE_USED")\",\"created\":$CREATED,\"version\":\"$(json_escape "$DOC_VERSION")\"}"
|
|
148
|
+
else
|
|
149
|
+
echo "✅ Created $DOC_FILE"
|
|
150
|
+
[ -n "$TEMPLATE_USED" ] && echo " Template: $TEMPLATE_USED"
|
|
151
|
+
echo " Version: $DOC_VERSION"
|
|
152
|
+
echo " Next: Run 'docguard fix --doc $DOC_NAME' for content guidance"
|
|
153
|
+
fi
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# DocGuard — Suggest fixes based on guard/diagnose results
|
|
3
|
+
# Runs guard, parses results, outputs prioritized fix suggestions as JSON
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# ./docguard-suggest-fix.sh [--json] [--top N]
|
|
7
|
+
#
|
|
8
|
+
# JSON output fields:
|
|
9
|
+
# GUARD_PASS — number of passing checks
|
|
10
|
+
# GUARD_TOTAL — total checks
|
|
11
|
+
# FINDINGS — array of {validator, severity, message, fix}
|
|
12
|
+
# TOP_FIX — the single highest-impact fix suggestion
|
|
13
|
+
|
|
14
|
+
set -e
|
|
15
|
+
|
|
16
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
17
|
+
source "$SCRIPT_DIR/common.sh"
|
|
18
|
+
|
|
19
|
+
JSON_MODE=false
|
|
20
|
+
TOP_N=5
|
|
21
|
+
|
|
22
|
+
while [ $# -gt 0 ]; do
|
|
23
|
+
case "$1" in
|
|
24
|
+
--json) JSON_MODE=true ;;
|
|
25
|
+
--top)
|
|
26
|
+
shift
|
|
27
|
+
TOP_N="${1:-5}"
|
|
28
|
+
;;
|
|
29
|
+
--help|-h)
|
|
30
|
+
echo "Usage: $0 [--json] [--top N]"
|
|
31
|
+
echo ""
|
|
32
|
+
echo "Options:"
|
|
33
|
+
echo " --json Output in JSON format"
|
|
34
|
+
echo " --top N Show top N fix suggestions (default: 5)"
|
|
35
|
+
echo " --help Show this help"
|
|
36
|
+
exit 0
|
|
37
|
+
;;
|
|
38
|
+
*) echo "Unknown option: $1" >&2; exit 1 ;;
|
|
39
|
+
esac
|
|
40
|
+
shift
|
|
41
|
+
done
|
|
42
|
+
|
|
43
|
+
# Find project
|
|
44
|
+
PROJECT_ROOT=$(find_docguard_root "$(pwd)") || {
|
|
45
|
+
echo "Error: No DocGuard project found." >&2
|
|
46
|
+
exit 1
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
CLI_CMD=$(find_docguard_cli "$PROJECT_ROOT") || {
|
|
50
|
+
echo "Error: DocGuard CLI not found." >&2
|
|
51
|
+
exit 1
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
cd "$PROJECT_ROOT"
|
|
55
|
+
|
|
56
|
+
# Run guard and capture output
|
|
57
|
+
GUARD_OUTPUT=$(eval $CLI_CMD guard 2>&1 || true)
|
|
58
|
+
|
|
59
|
+
# Parse pass/total
|
|
60
|
+
GUARD_SUMMARY=$(echo "$GUARD_OUTPUT" | grep -o '[0-9]*/[0-9]* passed' || echo "0/0 passed")
|
|
61
|
+
GUARD_PASS=$(echo "$GUARD_SUMMARY" | sed 's|/.*||')
|
|
62
|
+
GUARD_TOTAL=$(echo "$GUARD_SUMMARY" | sed 's|.*/||; s| .*||')
|
|
63
|
+
|
|
64
|
+
# Extract warnings and failures
|
|
65
|
+
FINDINGS="[]"
|
|
66
|
+
if echo "$GUARD_OUTPUT" | grep -q "⚠\|❌"; then
|
|
67
|
+
# Extract warning/failure lines with validator context
|
|
68
|
+
FINDING_LINES=$(echo "$GUARD_OUTPUT" | grep -A1 "⚠\|❌" | grep "⚠ \|❌ " || true)
|
|
69
|
+
|
|
70
|
+
if [ -n "$FINDING_LINES" ]; then
|
|
71
|
+
FINDINGS="["
|
|
72
|
+
first=true
|
|
73
|
+
count=0
|
|
74
|
+
while IFS= read -r line; do
|
|
75
|
+
[ $count -ge $TOP_N ] && break
|
|
76
|
+
if [ "$first" = true ]; then first=false; else FINDINGS="$FINDINGS,"; fi
|
|
77
|
+
|
|
78
|
+
# Clean the line
|
|
79
|
+
clean_line=$(echo "$line" | sed 's/^[[:space:]]*//' | sed 's/⚠ //' | sed 's/❌ //')
|
|
80
|
+
|
|
81
|
+
# Determine severity
|
|
82
|
+
severity="MEDIUM"
|
|
83
|
+
echo "$line" | grep -q "❌" && severity="CRITICAL"
|
|
84
|
+
echo "$line" | grep -qi "security\|secret" && severity="CRITICAL"
|
|
85
|
+
echo "$line" | grep -qi "structure\|missing" && severity="HIGH"
|
|
86
|
+
|
|
87
|
+
FINDINGS="$FINDINGS{\"message\":\"$(json_escape "$clean_line")\",\"severity\":\"$severity\"}"
|
|
88
|
+
count=$((count + 1))
|
|
89
|
+
done <<< "$FINDING_LINES"
|
|
90
|
+
FINDINGS="$FINDINGS]"
|
|
91
|
+
fi
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
if $JSON_MODE; then
|
|
95
|
+
echo "{\"guardPass\":$GUARD_PASS,\"guardTotal\":$GUARD_TOTAL,\"findings\":$FINDINGS}"
|
|
96
|
+
else
|
|
97
|
+
echo "Guard: $GUARD_PASS/$GUARD_TOTAL passed"
|
|
98
|
+
echo ""
|
|
99
|
+
if [ "$GUARD_PASS" = "$GUARD_TOTAL" ]; then
|
|
100
|
+
echo "✅ All checks passed! No fixes needed."
|
|
101
|
+
else
|
|
102
|
+
echo "Suggested fixes (top $TOP_N):"
|
|
103
|
+
echo "$GUARD_OUTPUT" | grep "⚠ \|❌ " | head -$TOP_N | while IFS= read -r line; do
|
|
104
|
+
echo " → $(echo "$line" | sed 's/^[[:space:]]*//')"
|
|
105
|
+
done
|
|
106
|
+
fi
|
|
107
|
+
fi
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docguard-fix
|
|
3
|
+
description: AI-driven documentation repair with structured research workflow, template-aware
|
|
4
|
+
generation, and quality validation loops. Generates or fixes canonical documentation
|
|
5
|
+
by researching the actual codebase, not using placeholders. Iterates until guard passes.
|
|
6
|
+
compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
|
|
7
|
+
metadata:
|
|
8
|
+
author: docguard
|
|
9
|
+
version: 0.9.5
|
|
10
|
+
source: extensions/spec-kit-docguard/skills/docguard-fix
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# DocGuard Fix Skill
|
|
14
|
+
|
|
15
|
+
## User Input
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
$ARGUMENTS
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
You **MUST** consider the user input before proceeding (if not empty).
|
|
22
|
+
If user specifies `--doc <name>`, focus on that single document.
|
|
23
|
+
If no arguments, fix ALL issues found by `docguard diagnose`.
|
|
24
|
+
|
|
25
|
+
## Goal
|
|
26
|
+
|
|
27
|
+
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
|
+
|
|
29
|
+
## Operating Constraints
|
|
30
|
+
|
|
31
|
+
- **NEVER use placeholder content** — every section must reference real files, real modules, real dependencies
|
|
32
|
+
- **ALWAYS back up before overwriting** — use `safeWrite()` pattern or create `.bak` files
|
|
33
|
+
- **Maximum 3 validation iterations** — if still failing after 3 rounds, report remaining issues and stop
|
|
34
|
+
- **Research before writing** — understand the codebase first, then generate documentation
|
|
35
|
+
|
|
36
|
+
## Execution Flow
|
|
37
|
+
|
|
38
|
+
### Step 1: Diagnose Current State
|
|
39
|
+
|
|
40
|
+
Run the diagnostic to identify all issues:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx docguard-cli diagnose 2>&1
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Parse the output to build an issue inventory:
|
|
47
|
+
|
|
48
|
+
| Issue ID | Severity | Category | File | Description | Autofix? |
|
|
49
|
+
|----------|----------|----------|------|-------------|----------|
|
|
50
|
+
| I001 | ERROR | Structure | SECURITY.md | Missing file | Yes |
|
|
51
|
+
| I002 | WARN | Freshness | ARCHITECTURE.md | 5 commits behind | Yes |
|
|
52
|
+
| ... | ... | ... | ... | ... | ... |
|
|
53
|
+
|
|
54
|
+
If `$ARGUMENTS` contains `--doc <name>`, filter to only issues affecting that document.
|
|
55
|
+
|
|
56
|
+
### Step 2: Prioritize Fix Order
|
|
57
|
+
|
|
58
|
+
Sort issues by fix dependency and impact:
|
|
59
|
+
|
|
60
|
+
1. **Structure** first (missing files must exist before checking sections)
|
|
61
|
+
2. **Doc Sections** second (sections must exist before checking quality)
|
|
62
|
+
3. **Doc-Quality** third (readability and language improvements)
|
|
63
|
+
4. **Freshness** fourth (update `last-reviewed` dates)
|
|
64
|
+
5. **Metadata-Sync** fifth (ensure headers are consistent)
|
|
65
|
+
6. **Everything else** last
|
|
66
|
+
|
|
67
|
+
### Step 3: Research the Codebase (Per Document)
|
|
68
|
+
|
|
69
|
+
For each document that needs fixing, execute a **targeted research pass**. Research must be thorough — read actual code, not just filenames.
|
|
70
|
+
|
|
71
|
+
#### For ARCHITECTURE.md:
|
|
72
|
+
1. Read `package.json` for project name, description, dependencies, scripts
|
|
73
|
+
2. List top-level directory structure (`ls -la`, focus on `src/`, `lib/`, `cli/`, `app/`)
|
|
74
|
+
3. Identify entry points — check `main`, `bin`, `exports` in package.json
|
|
75
|
+
4. For each major directory, read 2-3 representative files to understand purpose
|
|
76
|
+
5. Map the import graph — which modules import which
|
|
77
|
+
6. Identify external dependencies and their roles
|
|
78
|
+
|
|
79
|
+
#### For SECURITY.md:
|
|
80
|
+
1. Check `.gitignore` for security-related patterns (`.env`, secrets, keys)
|
|
81
|
+
2. Search for auth patterns: `grep -r "auth\|token\|jwt\|session\|password\|secret" src/ lib/ --include="*.js" --include="*.mjs"`
|
|
82
|
+
3. Check `package.json` for auth dependencies (passport, jwt, bcrypt)
|
|
83
|
+
4. Look for middleware, guards, or permission checks
|
|
84
|
+
5. Check for `.env` files (document variable names only, NEVER values)
|
|
85
|
+
6. Look for CORS, rate limiting, input validation
|
|
86
|
+
|
|
87
|
+
#### For TEST-SPEC.md:
|
|
88
|
+
1. Read `package.json` scripts for test commands
|
|
89
|
+
2. Find test files: `find . -name "*.test.*" -o -name "*.spec.*" | head -20`
|
|
90
|
+
3. Read test configuration (jest.config, vitest.config, etc.)
|
|
91
|
+
4. Read 2-3 test files to understand patterns
|
|
92
|
+
5. Check for E2E setup (playwright, cypress)
|
|
93
|
+
6. Look for CI config that runs tests
|
|
94
|
+
|
|
95
|
+
#### For DATA-MODEL.md:
|
|
96
|
+
1. Search for schema definitions: `grep -r "Schema\|model\|Table\|Entity\|interface\|type " src/ lib/`
|
|
97
|
+
2. Check for ORM configs (prisma, sequelize, mongoose, drizzle)
|
|
98
|
+
3. Look for migration files
|
|
99
|
+
4. Check for TypeScript interfaces/types defining data shapes
|
|
100
|
+
5. Look for Zod schemas, JSON schemas, validation files
|
|
101
|
+
6. If no database: document config file formats
|
|
102
|
+
|
|
103
|
+
#### For ENVIRONMENT.md:
|
|
104
|
+
1. Read `package.json` for engines, scripts, dependencies
|
|
105
|
+
2. Check for `.nvmrc`, `.node-version`, `.tool-versions`
|
|
106
|
+
3. Search for `process.env` usage: `grep -r "process.env" src/ lib/ cli/`
|
|
107
|
+
4. Check for `.env.example` or `.env.template`
|
|
108
|
+
5. Check for Docker/docker-compose files
|
|
109
|
+
6. Look for setup scripts
|
|
110
|
+
|
|
111
|
+
### Step 4: Generate or Fix Document Content
|
|
112
|
+
|
|
113
|
+
For each document, follow this strict writing protocol:
|
|
114
|
+
|
|
115
|
+
1. **Load the metadata header template**:
|
|
116
|
+
```markdown
|
|
117
|
+
# [Document Title]
|
|
118
|
+
|
|
119
|
+
<!-- docguard:version X.X.X -->
|
|
120
|
+
<!-- docguard:status active -->
|
|
121
|
+
<!-- docguard:last-reviewed YYYY-MM-DD -->
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
2. **Write each mandatory section** using research findings:
|
|
125
|
+
- Use **actual file paths**, module names, and dependency names
|
|
126
|
+
- Use **markdown tables** for structured data (fields, types, constraints)
|
|
127
|
+
- Use **code blocks** for command examples (with actual working commands)
|
|
128
|
+
- Keep language **positive** (avoid negation — "MUST use" not "MUST NOT avoid")
|
|
129
|
+
- Write at **Flesch-Kincaid grade level 8-10** (clear, professional, not academic)
|
|
130
|
+
|
|
131
|
+
3. **Validate mandatory sections exist**. Each canonical doc requires:
|
|
132
|
+
- **ARCHITECTURE.md**: System Overview, Component Map, Layer Boundaries, Data Flow, Technology Choices
|
|
133
|
+
- **SECURITY.md**: Auth Mechanism, Secrets Inventory, Secrets Storage, Permissions, Security Boundaries
|
|
134
|
+
- **TEST-SPEC.md**: Test Framework, Test Structure, Test Commands, Critical Flows, Coverage
|
|
135
|
+
- **DATA-MODEL.md**: Data Structures/Schemas, Field Types/Constraints, Relationships, Indexes
|
|
136
|
+
- **ENVIRONMENT.md**: Prerequisites, Setup Steps, Environment Variables
|
|
137
|
+
- **REQUIREMENTS.md**: Functional Requirements (FR-IDs), Non-Functional Requirements
|
|
138
|
+
|
|
139
|
+
4. **Apply DocGuard quality rules**:
|
|
140
|
+
- Section count ≥ 3 per document
|
|
141
|
+
- No TODO/placeholder text in final output
|
|
142
|
+
- Positive language (IEEE 830 §4.3 compliance)
|
|
143
|
+
- Each section has substantive content (not just a heading)
|
|
144
|
+
|
|
145
|
+
### Step 5: Format Compliance
|
|
146
|
+
|
|
147
|
+
Ensure every generated document follows CDD format rules:
|
|
148
|
+
|
|
149
|
+
- **Metadata header**: Must include `docguard:version`, `docguard:status`, `docguard:last-reviewed`
|
|
150
|
+
- **Heading hierarchy**: Single `# H1`, then `## H2` sections, then `### H3` subsections
|
|
151
|
+
- **Tables**: Use markdown tables for structured data (pipes aligned, header separators with 3+ dashes)
|
|
152
|
+
- **Code blocks**: Use fenced blocks with language identifier for all commands/code
|
|
153
|
+
- **Line length**: Keep lines under 120 characters for readability
|
|
154
|
+
- **No trailing whitespace**
|
|
155
|
+
|
|
156
|
+
### Step 6: Validation Loop (Max 3 Iterations)
|
|
157
|
+
|
|
158
|
+
After writing/fixing each document:
|
|
159
|
+
|
|
160
|
+
1. **Run guard on the specific validator**:
|
|
161
|
+
```bash
|
|
162
|
+
npx docguard-cli guard 2>&1
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
2. **Parse results** for the affected validators
|
|
166
|
+
3. **If still failing**:
|
|
167
|
+
- Identify exactly which checks are still failing
|
|
168
|
+
- Apply targeted fixes (not a full rewrite)
|
|
169
|
+
- Re-run guard
|
|
170
|
+
4. **If passing after iteration**: Move to next document
|
|
171
|
+
5. **If still failing after 3 iterations**: Report remaining issues with specific error details
|
|
172
|
+
|
|
173
|
+
### Step 7: Completion Report
|
|
174
|
+
|
|
175
|
+
After all fixes are applied, output:
|
|
176
|
+
|
|
177
|
+
```markdown
|
|
178
|
+
## DocGuard Fix Report
|
|
179
|
+
|
|
180
|
+
### Documents Fixed
|
|
181
|
+
| Document | Action | Checks Before | Checks After | Status |
|
|
182
|
+
|----------|--------|:------------:|:------------:|--------|
|
|
183
|
+
| SECURITY.md | Created | 0/2 | 2/2 | ✅ |
|
|
184
|
+
| ARCHITECTURE.md | Updated sections | 6/8 | 8/8 | ✅ |
|
|
185
|
+
|
|
186
|
+
### Guard Score
|
|
187
|
+
- **Before**: [X]/[Y] checks passed
|
|
188
|
+
- **After**: [X]/[Y] checks passed
|
|
189
|
+
- **Improvement**: +[N] checks
|
|
190
|
+
|
|
191
|
+
### Remaining Issues (if any)
|
|
192
|
+
- [Issue description] — [Why it couldn't be auto-fixed]
|
|
193
|
+
|
|
194
|
+
### Suggested Next Steps
|
|
195
|
+
- Run `/docguard.guard` to verify full compliance
|
|
196
|
+
- Review generated content for accuracy
|
|
197
|
+
- Commit with: `docs: fix CDD documentation [list of docs fixed]`
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Behavior Rules
|
|
201
|
+
|
|
202
|
+
- **Research FIRST, write SECOND** — never generate content without reading the codebase
|
|
203
|
+
- **Be specific to THIS project** — don't add generic boilerplate for features the project doesn't have
|
|
204
|
+
- **Back up before overwriting** — if file exists, create `.bak` first or use `safeWrite()`
|
|
205
|
+
- **Respect existing content** — when updating, preserve user-written sections and only add/fix missing parts
|
|
206
|
+
- **Log deviations** — if you deviate from canonical expectations, add `// DRIFT: reason` in DRIFT-LOG.md
|
|
207
|
+
- **Never include secrets** — document variable/secret NAMES only, never actual values
|
|
208
|
+
|
|
209
|
+
## Integration with Spec Kit
|
|
210
|
+
|
|
211
|
+
If `.specify/` directory exists:
|
|
212
|
+
- Check `constitution.md` for project principles before generating docs
|
|
213
|
+
- Align documentation language with constitutional requirements
|
|
214
|
+
- If `specs/*/spec.md` exists, cross-reference requirements with TEST-SPEC.md
|
|
215
|
+
|
|
216
|
+
## Context
|
|
217
|
+
|
|
218
|
+
$ARGUMENTS
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docguard-guard
|
|
3
|
+
description: Run DocGuard guard validation against Canonical-Driven Development standards.
|
|
4
|
+
Parses output, triages severity, suggests targeted fixes, and optionally chains to
|
|
5
|
+
docguard-fix for automated remediation. Use as a quality gate before commits or after
|
|
6
|
+
implementation phases.
|
|
7
|
+
compatibility: Requires DocGuard CLI installed (npm i -g docguard-cli or npx docguard-cli)
|
|
8
|
+
metadata:
|
|
9
|
+
author: docguard
|
|
10
|
+
version: 0.9.5
|
|
11
|
+
source: extensions/spec-kit-docguard/skills/docguard-guard
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# DocGuard Guard Skill
|
|
15
|
+
|
|
16
|
+
## User Input
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
$ARGUMENTS
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
You **MUST** consider the user input before proceeding (if not empty).
|
|
23
|
+
|
|
24
|
+
## Goal
|
|
25
|
+
|
|
26
|
+
Execute DocGuard's 19-validator guard suite against the current project, parse structured results, triage findings by severity and impact, and produce an actionable remediation plan. This skill transforms raw CLI output into an AI-digestible quality assessment.
|
|
27
|
+
|
|
28
|
+
## Pre-Execution Checks
|
|
29
|
+
|
|
30
|
+
1. **Verify DocGuard is available**:
|
|
31
|
+
- Check if `npx docguard-cli --version` succeeds
|
|
32
|
+
- If not available, check if `node cli/docguard.mjs --help` exists (local dev mode)
|
|
33
|
+
- If neither works: ERROR "DocGuard CLI not found. Install with: npm i -g docguard-cli"
|
|
34
|
+
|
|
35
|
+
2. **Detect project root**:
|
|
36
|
+
- Look for `.docguard.json`, `docs-canonical/`, or `CHANGELOG.md` as project markers
|
|
37
|
+
- If none found: ERROR "No CDD project detected. Run `docguard init` first."
|
|
38
|
+
|
|
39
|
+
## Execution Flow
|
|
40
|
+
|
|
41
|
+
### Step 1: Run Guard with Machine-Readable Output
|
|
42
|
+
|
|
43
|
+
Execute the guard command and capture full output:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npx docguard-cli guard 2>&1
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
If in a DocGuard development environment (cli/docguard.mjs exists), use:
|
|
50
|
+
```bash
|
|
51
|
+
node cli/docguard.mjs guard 2>&1
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Step 2: Parse Validator Results
|
|
55
|
+
|
|
56
|
+
Extract from guard output each validator's status. Build an internal results table:
|
|
57
|
+
|
|
58
|
+
| Validator | Priority | Checks Passed | Total Checks | Status |
|
|
59
|
+
|-----------|----------|---------------|--------------|--------|
|
|
60
|
+
| Structure | HIGH | N | M | ✅/⚠️/❌ |
|
|
61
|
+
| Doc Sections | HIGH | N | M | ✅/⚠️/❌ |
|
|
62
|
+
| ... | ... | ... | ... | ... |
|
|
63
|
+
|
|
64
|
+
**Status mapping**:
|
|
65
|
+
- `✅` = All checks passed
|
|
66
|
+
- `⚠️` = Warning (non-blocking, but should fix)
|
|
67
|
+
- `❌` = Failure (blocking — must fix before commit)
|
|
68
|
+
|
|
69
|
+
### Step 3: Severity Triage
|
|
70
|
+
|
|
71
|
+
Classify every non-passing check using this priority matrix:
|
|
72
|
+
|
|
73
|
+
**CRITICAL (fix immediately)**:
|
|
74
|
+
- Structure failures (missing canonical docs)
|
|
75
|
+
- Security failures (hardcoded secrets, missing SECURITY.md)
|
|
76
|
+
- Test-Spec failures (tests don't match spec)
|
|
77
|
+
|
|
78
|
+
**HIGH (fix before commit)**:
|
|
79
|
+
- Doc Sections failures (missing required sections)
|
|
80
|
+
- Drift detection (undocumented code deviations)
|
|
81
|
+
- Changelog gaps
|
|
82
|
+
- Traceability breaks
|
|
83
|
+
|
|
84
|
+
**MEDIUM (fix this sprint)**:
|
|
85
|
+
- Freshness warnings (stale docs)
|
|
86
|
+
- Docs-Coverage gaps (undocumented config files)
|
|
87
|
+
- Doc-Quality issues (readability, negation language)
|
|
88
|
+
- Metrics-Consistency mismatches
|
|
89
|
+
|
|
90
|
+
**LOW (fix when convenient)**:
|
|
91
|
+
- TODO-Tracking items
|
|
92
|
+
- Schema-Sync gaps
|
|
93
|
+
- Metadata-Sync minor mismatches
|
|
94
|
+
- Spec-Kit warnings (spec structure gaps)
|
|
95
|
+
|
|
96
|
+
### Step 4: Generate Triage Report
|
|
97
|
+
|
|
98
|
+
Output a structured markdown report:
|
|
99
|
+
|
|
100
|
+
```markdown
|
|
101
|
+
## DocGuard Guard Report
|
|
102
|
+
|
|
103
|
+
**Score**: [X]/[Y] checks passed ([percentage]%)
|
|
104
|
+
**Overall Status**: ✅ PASS | ⚠️ WARN | ❌ FAIL
|
|
105
|
+
|
|
106
|
+
### Summary by Priority
|
|
107
|
+
|
|
108
|
+
| Priority | Count | Validators Affected |
|
|
109
|
+
|----------|-------|-------------------|
|
|
110
|
+
| CRITICAL | N | [list] |
|
|
111
|
+
| HIGH | N | [list] |
|
|
112
|
+
| MEDIUM | N | [list] |
|
|
113
|
+
| LOW | N | [list] |
|
|
114
|
+
|
|
115
|
+
### Findings
|
|
116
|
+
|
|
117
|
+
#### CRITICAL
|
|
118
|
+
1. [Validator]: [Specific issue] → **Fix**: [Exact action to take]
|
|
119
|
+
|
|
120
|
+
#### HIGH
|
|
121
|
+
1. [Validator]: [Specific issue] → **Fix**: [Exact action to take]
|
|
122
|
+
|
|
123
|
+
[... continue for MEDIUM/LOW only if user requests or total findings < 10]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Step 5: Remediation Recommendations
|
|
127
|
+
|
|
128
|
+
For each finding, provide a **specific, actionable fix** — not "fix the issue" but the exact file, section, and content to change:
|
|
129
|
+
|
|
130
|
+
- **Missing file**: "Create `docs-canonical/SECURITY.md` with metadata header and these sections: [list]"
|
|
131
|
+
- **Missing section**: "Add `## Threat Model` section to `docs-canonical/SECURITY.md` after line N"
|
|
132
|
+
- **Stale doc**: "Update `<!-- docguard:last-reviewed YYYY-MM-DD -->` in [file] to today's date"
|
|
133
|
+
- **Negation language**: "Replace 'Never store secrets in...' with 'Store secrets exclusively in...'"
|
|
134
|
+
- **Undocumented config**: "Add `.venv` documentation to `docs-canonical/ARCHITECTURE.md` under Developer Tools"
|
|
135
|
+
|
|
136
|
+
### Step 6: Offer Next Actions
|
|
137
|
+
|
|
138
|
+
Based on the triage results:
|
|
139
|
+
|
|
140
|
+
- **If all PASS**: "All 19 validators passed. Project is CDD-compliant. Ready to commit."
|
|
141
|
+
- **If only MEDIUM/LOW warnings**: "Non-blocking warnings found. Safe to commit, but consider running `/docguard.fix` for automated remediation."
|
|
142
|
+
- **If HIGH or CRITICAL failures**: "Blocking issues found. Fix these before committing. Suggest running `/docguard.fix --doc [most impactful doc]` next."
|
|
143
|
+
|
|
144
|
+
Present the user with options:
|
|
145
|
+
1. "Fix all automatically" → Suggest: `/docguard.fix`
|
|
146
|
+
2. "Fix specific doc" → Suggest: `/docguard.fix --doc [name]`
|
|
147
|
+
3. "Ignore warnings and proceed" → Warn about CDD compliance gap
|
|
148
|
+
|
|
149
|
+
## Behavior Rules
|
|
150
|
+
|
|
151
|
+
- **ALWAYS run the actual CLI** — never simulate or guess guard results
|
|
152
|
+
- **Parse real output** — don't hallucinate check counts or validator names
|
|
153
|
+
- **Be specific** — every fix recommendation must reference an actual file path
|
|
154
|
+
- **Respect severity** — don't escalate LOW to CRITICAL or vice versa
|
|
155
|
+
- **Track progress** — if user runs guard multiple times, compare before/after
|
|
156
|
+
- If user provides `$ARGUMENTS` like "just structure" or "only security", filter report to those validators
|
|
157
|
+
|
|
158
|
+
## Integration with Spec Kit
|
|
159
|
+
|
|
160
|
+
If this project has `.specify/` directory (spec-kit enabled):
|
|
161
|
+
- Include Spec-Kit validator results in the triage
|
|
162
|
+
- Cross-reference spec quality issues with `specs/*/spec.md` file paths
|
|
163
|
+
- Suggest `/speckit.analyze` if spec-related findings exceed 3
|
|
164
|
+
|
|
165
|
+
## Context
|
|
166
|
+
|
|
167
|
+
$ARGUMENTS
|