viepilot 1.0.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 (84) hide show
  1. package/CHANGELOG.md +230 -0
  2. package/LICENSE +23 -0
  3. package/README.md +550 -0
  4. package/bin/viepilot.cjs +222 -0
  5. package/bin/vp-tools.cjs +912 -0
  6. package/dev-install.sh +109 -0
  7. package/docs/README.md +125 -0
  8. package/docs/advanced-usage.md +366 -0
  9. package/docs/api/README.md +12 -0
  10. package/docs/api/graphql-schema.md +5 -0
  11. package/docs/api/kafka-events.md +5 -0
  12. package/docs/api/rest-api.md +19 -0
  13. package/docs/api/websocket-api.md +5 -0
  14. package/docs/dev/architecture.md +226 -0
  15. package/docs/dev/cli-reference.md +324 -0
  16. package/docs/dev/contributing.md +195 -0
  17. package/docs/dev/deployment.md +204 -0
  18. package/docs/dev/getting-started.md +16 -0
  19. package/docs/dev/testing.md +171 -0
  20. package/docs/dev/ui-components-library.md +36 -0
  21. package/docs/getting-started.md +163 -0
  22. package/docs/skills-reference.md +399 -0
  23. package/docs/troubleshooting.md +297 -0
  24. package/docs/user/faq.md +117 -0
  25. package/docs/user/features/autonomous-mode.md +111 -0
  26. package/docs/user/features/checkpoint-recovery.md +76 -0
  27. package/docs/user/features/debug-mode.md +77 -0
  28. package/docs/user/features/ui-direction.md +29 -0
  29. package/docs/user/quick-start.md +157 -0
  30. package/docs/videos/01-installation.md +113 -0
  31. package/docs/videos/02-first-project.md +132 -0
  32. package/docs/videos/03-autonomous-mode.md +147 -0
  33. package/install.sh +144 -0
  34. package/lib/cli-shared.cjs +108 -0
  35. package/package.json +78 -0
  36. package/skills/vp-audit/SKILL.md +140 -0
  37. package/skills/vp-auto/SKILL.md +204 -0
  38. package/skills/vp-brainstorm/SKILL.md +75 -0
  39. package/skills/vp-crystallize/SKILL.md +175 -0
  40. package/skills/vp-debug/SKILL.md +96 -0
  41. package/skills/vp-docs/SKILL.md +258 -0
  42. package/skills/vp-evolve/SKILL.md +165 -0
  43. package/skills/vp-pause/SKILL.md +150 -0
  44. package/skills/vp-request/SKILL.md +250 -0
  45. package/skills/vp-resume/SKILL.md +141 -0
  46. package/skills/vp-rollback/SKILL.md +116 -0
  47. package/skills/vp-status/SKILL.md +137 -0
  48. package/skills/vp-task/SKILL.md +139 -0
  49. package/skills/vp-ui-components/SKILL.md +64 -0
  50. package/templates/phase/PHASE-STATE.md +35 -0
  51. package/templates/phase/SPEC.md +40 -0
  52. package/templates/phase/SUMMARY.md +67 -0
  53. package/templates/phase/TASK.md +101 -0
  54. package/templates/phase/VERIFICATION.md +49 -0
  55. package/templates/project/AI-GUIDE.md +114 -0
  56. package/templates/project/ARCHITECTURE.md +70 -0
  57. package/templates/project/CHANGELOG.md +36 -0
  58. package/templates/project/CONTRIBUTING.md +154 -0
  59. package/templates/project/CONTRIBUTORS.md +41 -0
  60. package/templates/project/PROJECT-CONTEXT.md +74 -0
  61. package/templates/project/PROJECT-META.md +133 -0
  62. package/templates/project/README.md +197 -0
  63. package/templates/project/ROADMAP.md +56 -0
  64. package/templates/project/SYSTEM-RULES.md +368 -0
  65. package/templates/project/TRACKER.md +50 -0
  66. package/ui-components/INDEX.md +9 -0
  67. package/ui-components/base/button/README.md +8 -0
  68. package/ui-components/base/button/metadata.json +8 -0
  69. package/ui-components/base/card/README.md +8 -0
  70. package/ui-components/base/card/metadata.json +8 -0
  71. package/ui-components/base/input/README.md +8 -0
  72. package/ui-components/base/input/metadata.json +8 -0
  73. package/workflows/audit.md +549 -0
  74. package/workflows/autonomous.md +425 -0
  75. package/workflows/brainstorm.md +257 -0
  76. package/workflows/crystallize.md +418 -0
  77. package/workflows/debug.md +241 -0
  78. package/workflows/documentation.md +587 -0
  79. package/workflows/evolve.md +258 -0
  80. package/workflows/pause-work.md +255 -0
  81. package/workflows/request.md +534 -0
  82. package/workflows/resume-work.md +226 -0
  83. package/workflows/rollback.md +202 -0
  84. package/workflows/ui-components.md +109 -0
@@ -0,0 +1,8 @@
1
+ # base-input-text
2
+
3
+ Standard text input with label and helper text pattern.
4
+
5
+ ## Usage
6
+ - Authentication and profile forms
7
+ - Search bars
8
+ - Filter controls
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "base-input-text",
3
+ "category": "base",
4
+ "source": "viepilot-stock",
5
+ "tags": ["input", "form", "base"],
6
+ "stack_notes": "Always pair with label and validation message region.",
7
+ "status": "approved"
8
+ }
@@ -0,0 +1,549 @@
1
+ <purpose>
2
+ Audit ViePilot project state và documentation để phát hiện drift.
3
+ Hoạt động trên bất kỳ project nào đang dùng ViePilot.
4
+ Auto-detect nếu đang chạy trong viepilot framework repo để thêm framework-specific checks.
5
+ </purpose>
6
+
7
+ <process>
8
+
9
+ <step name="detect_project_type">
10
+ ## 0. Detect Project Type
11
+
12
+ ```bash
13
+ # Detect if this is the viepilot framework repo itself
14
+ IS_VIEPILOT_FRAMEWORK=false
15
+ if [ -d "skills" ] && ls skills/vp-*/SKILL.md 2>/dev/null | head -1 > /dev/null; then
16
+ IS_VIEPILOT_FRAMEWORK=true
17
+ echo "→ Detected: ViePilot framework repository"
18
+ echo " Will run Tier 1–4 (includes Tier 4 framework integrity when enabled)"
19
+ else
20
+ echo "→ Detected: User project using ViePilot"
21
+ echo " Will run Tier 1–3; Tier 4 framework tier is skipped unless --framework"
22
+ fi
23
+
24
+ # Override with flags if provided
25
+ # --framework : force framework checks even if not detected
26
+ # --project : force project-only checks (skip framework tier)
27
+ ```
28
+
29
+ Display audit plan:
30
+ ```
31
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
32
+ VIEPILOT ► AUDIT
33
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
34
+
35
+ Tier 1: ViePilot State Consistency [ALWAYS]
36
+ Tier 2: Project Documentation Drift [ALWAYS]
37
+ Tier 3: Stack Best Practices + Code Quality [ALWAYS]
38
+ Tier 4: Framework Integrity [{FRAMEWORK_STATUS}]
39
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
40
+ ```
41
+ </step>
42
+
43
+ <step name="tier1_state">
44
+ ## 1. Tier 1: ViePilot State Consistency (always runs)
45
+
46
+ Check that ViePilot's own tracking files are internally consistent.
47
+ This is meaningful for **any project** using ViePilot.
48
+
49
+ ### 1a. TRACKER.md vs PHASE-STATE.md
50
+ ```bash
51
+ # Read current phase from TRACKER.md
52
+ TRACKER_PHASE=$(grep "Current Phase" .viepilot/TRACKER.md 2>/dev/null | sed 's/.*: //' | tr -d '*')
53
+ TRACKER_TASK=$(grep "Current Task" .viepilot/TRACKER.md 2>/dev/null | sed 's/.*: //' | tr -d '*')
54
+
55
+ # Check each phase directory for status
56
+ for phase_dir in .viepilot/phases/*/; do
57
+ if [ -f "$phase_dir/PHASE-STATE.md" ]; then
58
+ PHASE_STATUS=$(grep "^\- \*\*Status\*\*:" "$phase_dir/PHASE-STATE.md" 2>/dev/null | sed 's/.*: //')
59
+ PHASE_NUM=$(basename "$phase_dir" | grep -o '^[0-9]*')
60
+ # Compare with TRACKER.md current state
61
+ fi
62
+ done
63
+ ```
64
+
65
+ ### 1b. ROADMAP.md phase status vs PHASE-STATE.md
66
+ ```bash
67
+ # For each completed PHASE-STATE.md, verify ROADMAP.md shows ✅
68
+ for phase_dir in .viepilot/phases/*/; do
69
+ if [ -f "$phase_dir/PHASE-STATE.md" ]; then
70
+ PHASE_STATUS=$(grep "^\- \*\*Status\*\*:" "$phase_dir/PHASE-STATE.md" 2>/dev/null | sed 's/.*: //')
71
+ if echo "$PHASE_STATUS" | grep -qi "complete"; then
72
+ PHASE_NUM=$(basename "$phase_dir" | grep -o '^[0-9]*' | sed 's/^0*//')
73
+ # Check ROADMAP.md has ✅ for this phase
74
+ ROADMAP_STATUS=$(grep -i "Phase $PHASE_NUM" .viepilot/ROADMAP.md 2>/dev/null | head -1)
75
+ if ! echo "$ROADMAP_STATUS" | grep -q "✅"; then
76
+ echo "⚠️ Phase $PHASE_NUM: PHASE-STATE says complete but ROADMAP.md not marked ✅"
77
+ fi
78
+ fi
79
+ fi
80
+ done
81
+ ```
82
+
83
+ ### 1c. HANDOFF.json vs TRACKER.md
84
+ ```bash
85
+ if [ -f ".viepilot/HANDOFF.json" ]; then
86
+ HANDOFF_PHASE=$(node -e "try{const h=require('./.viepilot/HANDOFF.json');console.log(h.current_phase||'')}catch(e){}" 2>/dev/null)
87
+ HANDOFF_TASK=$(node -e "try{const h=require('./.viepilot/HANDOFF.json');console.log(h.current_task||'')}catch(e){}" 2>/dev/null)
88
+ # Compare with TRACKER.md values
89
+ fi
90
+ ```
91
+
92
+ ### 1d. Git tags vs completed phases
93
+ ```bash
94
+ # List completed phases (PHASE-STATE.md with status: complete)
95
+ # List git tags matching vp-p{N}-complete
96
+ COMPLETE_TAGS=$(git tag 2>/dev/null | grep -E '^vp-p[0-9]+-complete$' | sort)
97
+ # Report any phase marked complete in PHASE-STATE.md without a git tag
98
+ ```
99
+
100
+ ### 1e. Detect delayed/batch-only state updates (anti-pattern)
101
+ ```bash
102
+ # Heuristic signals for poor traceability:
103
+ # - PHASE-STATE has all tasks done but missing in_progress transitions
104
+ # - HANDOFF/TRACKER timestamps only move at phase end
105
+ # - no per-task done tags for multi-task phases
106
+ #
107
+ # Report as:
108
+ # ⚠️ Phase N may use batch-only state updates (missing incremental trace)
109
+ ```
110
+
111
+ ### 1f. Execute-first / docs-later ordering risk (heuristic; BUG-001)
112
+
113
+ > **Heuristic only** — can produce false positives. Confirm manually before accusing a run of violating doc-first policy.
114
+
115
+ Signals that implementation may have started **before** task documentation / state gates:
116
+
117
+ 1. **Git vs task file** — Commit introduces substantive changes under paths implied by a task, but the task `.md` still has only template placeholders in **Paths** / **File-Level Plan** at that commit (use `git log --follow` + blame on task file).
118
+ 2. **Git vs PHASE-STATE** — First implementation commit for a task predates the first edit that marks the task `in_progress` in `PHASE-STATE.md` for that task row.
119
+ 3. **Empty plan** — Task file lacks **Pre-execution documentation gate** checklist (template after Phase 15) yet commits exist on tracked deliverable files assigned to that task ID in tracker/notes.
120
+
121
+ Report example:
122
+ ```
123
+ ⚠️ Task X.Y: possible execute-first pattern — verify doc-first gate in workflows/autonomous.md was satisfied
124
+ ```
125
+
126
+ ### 1g. Report Tier 1 results
127
+ ```
128
+ TIER 1: ViePilot State Consistency
129
+ ─────────────────────────────────────────────────
130
+ TRACKER.md ↔ PHASE-STATE.md {✅ Consistent | ⚠️ Mismatch}
131
+ ROADMAP.md ↔ PHASE-STATE.md {✅ Consistent | ⚠️ N phase(s) out of sync}
132
+ HANDOFF.json ↔ TRACKER.md {✅ Consistent | ⚠️ Mismatch | ℹ️ No HANDOFF.json}
133
+ Git tags ↔ completed phases {✅ All tagged | ⚠️ N phase(s) missing tags}
134
+ Incremental state traceability {✅ Per-task updates found | ⚠️ Batch-only update pattern suspected}
135
+ Execute-first / docs-later risk {✅ None suspected | ⚠️ N heuristic flag(s) — manual confirm}
136
+ ```
137
+ </step>
138
+
139
+ <step name="tier2_docs">
140
+ ## 2. Tier 2: Project Documentation Drift (always runs)
141
+
142
+ Check that project documentation reflects the current state of the codebase.
143
+ Works for **any project type** (Java, Node, Python, etc.).
144
+
145
+ ### 2a. Detect project version
146
+ ```bash
147
+ # Generic version detection
148
+ if [ -f "package.json" ]; then
149
+ PROJECT_VERSION=$(node -p "require('./package.json').version" 2>/dev/null)
150
+ VERSION_SOURCE="package.json"
151
+ elif [ -f "pom.xml" ]; then
152
+ PROJECT_VERSION=$(grep -m1 "<version>" pom.xml 2>/dev/null | sed 's/.*<version>//;s/<.*//' | tr -d ' ')
153
+ VERSION_SOURCE="pom.xml"
154
+ elif [ -f "pyproject.toml" ]; then
155
+ PROJECT_VERSION=$(grep '^version' pyproject.toml 2>/dev/null | head -1 | cut -d'"' -f2)
156
+ VERSION_SOURCE="pyproject.toml"
157
+ else
158
+ PROJECT_VERSION=""
159
+ VERSION_SOURCE="not found"
160
+ fi
161
+ ```
162
+
163
+ ### 2b. README.md version drift
164
+ ```bash
165
+ if [ -n "$PROJECT_VERSION" ] && [ -f "README.md" ]; then
166
+ # Check if README.md mentions the current version
167
+ if ! grep -q "$PROJECT_VERSION" README.md 2>/dev/null; then
168
+ echo "⚠️ README.md does not mention current version $PROJECT_VERSION (from $VERSION_SOURCE)"
169
+ fi
170
+ fi
171
+ ```
172
+
173
+ ### 2c. CHANGELOG.md vs recent commits
174
+ ```bash
175
+ if [ -f "CHANGELOG.md" ]; then
176
+ # Get last version tag
177
+ LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
178
+ if [ -n "$LAST_TAG" ]; then
179
+ COMMITS_SINCE=$(git log --oneline "$LAST_TAG"..HEAD 2>/dev/null | wc -l | tr -d ' ')
180
+ CHANGELOG_UNRELEASED=$(grep -c "^\-" <(sed -n '/## \[Unreleased\]/,/## \[/p' CHANGELOG.md 2>/dev/null) 2>/dev/null || echo "0")
181
+ if [ "$COMMITS_SINCE" -gt 0 ] && [ "$CHANGELOG_UNRELEASED" -eq 0 ]; then
182
+ echo "⚠️ $COMMITS_SINCE commits since $LAST_TAG but CHANGELOG.md [Unreleased] is empty"
183
+ fi
184
+ fi
185
+ fi
186
+ ```
187
+
188
+ ### 2d. Placeholder URLs in docs/
189
+ ```bash
190
+ if [ -d "docs" ]; then
191
+ PLACEHOLDER_FILES=$(grep -rl "your-org\|YOUR_USERNAME\|YOUR_ORG\|your-username\|example\.com" docs/ --include="*.md" 2>/dev/null)
192
+ if [ -n "$PLACEHOLDER_FILES" ]; then
193
+ echo "⚠️ Placeholder URLs found in:"
194
+ echo "$PLACEHOLDER_FILES"
195
+ fi
196
+ fi
197
+ ```
198
+
199
+ ### 2e. New features without docs (phases added recently)
200
+ ```bash
201
+ # Check if recent phases added features without corresponding docs updates
202
+ RECENT_PHASES=$(ls -t .viepilot/phases/*/PHASE-STATE.md 2>/dev/null | head -3)
203
+ for phase_state in $RECENT_PHASES; do
204
+ PHASE_STATUS=$(grep "^\- \*\*Status\*\*:" "$phase_state" 2>/dev/null | sed 's/.*: //')
205
+ if echo "$PHASE_STATUS" | grep -qi "complete"; then
206
+ PHASE_DIR=$(dirname "$phase_state")
207
+ # Check if docs/ was updated in commits for this phase
208
+ PHASE_NUM=$(basename "$PHASE_DIR" | grep -o '^[0-9]*' | sed 's/^0*//')
209
+ PHASE_TAG="vp-p${PHASE_NUM}-complete"
210
+ PREV_TAG=$(git tag --sort=-version:refname 2>/dev/null | grep "vp-p.*-complete" | grep -A1 "^$PHASE_TAG$" | tail -1)
211
+ if [ -n "$PREV_TAG" ]; then
212
+ DOCS_CHANGED=$(git diff "$PREV_TAG"..HEAD --name-only 2>/dev/null | grep "^docs/" | wc -l | tr -d ' ')
213
+ if [ "$DOCS_CHANGED" -eq 0 ]; then
214
+ echo "ℹ️ Phase $PHASE_NUM complete but no docs/ changes detected"
215
+ fi
216
+ fi
217
+ fi
218
+ done
219
+ ```
220
+
221
+ ### 2f. Report Tier 2 results
222
+ ```
223
+ TIER 2: Project Documentation Drift
224
+ ─────────────────────────────────────────────────
225
+ README.md version {✅ v{version} mentioned | ⚠️ v{version} not found}
226
+ CHANGELOG.md freshness {✅ Up to date | ⚠️ N commits not documented}
227
+ Placeholder URLs in docs/ {✅ None | ⚠️ Found in N files}
228
+ New features without docs {✅ All documented | ℹ️ Phase N may need docs}
229
+ ```
230
+ </step>
231
+
232
+ <step name="tier3_stack_practices">
233
+ ## 3. Tier 3: Stack Best Practices + Code Quality (always runs)
234
+
235
+ Evaluate project code and architecture decisions against stack-specific guidance.
236
+ This tier runs for any project, but only checks detected stacks.
237
+
238
+ ### 3a. Detect relevant stacks
239
+ ```bash
240
+ # Source 1: .viepilot/STACKS.md (if present)
241
+ # Source 2: project manifests (package.json, pom.xml, pyproject.toml, requirements.txt)
242
+ # Source 3: common file patterns (e.g., mybatis xml, spring boot, next.config, fastapi imports)
243
+ #
244
+ # Build normalized stack list, e.g.:
245
+ # java, spring-boot, mybatis, nodejs, express, react, python, fastapi
246
+ ```
247
+
248
+ ### 3b. Load stack cache summary first (token-efficient)
249
+ ```bash
250
+ for stack in $DETECTED_STACKS; do
251
+ SUMMARY="$HOME/.viepilot/stacks/$stack/SUMMARY.md"
252
+ if [ -f "$SUMMARY" ]; then
253
+ echo "✅ Cache found for $stack (summary)"
254
+ else
255
+ echo "⚠️ No stack summary cache for $stack"
256
+ fi
257
+ done
258
+ ```
259
+
260
+ ### 3c. Research fallback when cache missing or weak
261
+ Fallback trigger conditions:
262
+ - `SUMMARY.md` missing for detected stack
263
+ - cache appears stale (missing update metadata)
264
+ - summary too shallow for audit scope (no Do/Don't or checklist)
265
+
266
+ Fallback action:
267
+ - Use `WebSearch` to locate official docs first.
268
+ - Use `WebFetch` to extract key guidance from official docs/reference pages.
269
+ - Synthesize concise findings into:
270
+ - Do / Don't
271
+ - Common pitfalls
272
+ - Recommended structure
273
+ - Implementation checklist
274
+ - Code quality heuristics
275
+
276
+ Source priority:
277
+ 1. Official documentation/specification
278
+ 2. Official maintainer org/reference repositories
279
+ 3. Reputable community references (only as supplemental)
280
+
281
+ ### 3d. Audit compliance by stack
282
+ For each detected stack:
283
+ - Compare code patterns with Do/Don't guidance.
284
+ - Flag anti-patterns and structural violations.
285
+ - Record findings with severity (`critical`, `high`, `medium`, `low`).
286
+ - Tie each finding to path/module when possible.
287
+
288
+ ### 3e. Emit vp-auto-compatible guardrails
289
+ Generate a reusable "guardrails contract" block:
290
+ ```yaml
291
+ stack: {stack}
292
+ summary_used: {cache|research}
293
+ must_follow:
294
+ - ...
295
+ avoid:
296
+ - ...
297
+ preflight_checklist:
298
+ - ...
299
+ needs_detail_lookup: {true|false}
300
+ ```
301
+
302
+ This contract is intended for `/vp-auto` preflight so implementation uses the same stack policy as audit.
303
+
304
+ ### 3f. Cache update guidance
305
+ When fallback research is used, suggest/update:
306
+ - `~/.viepilot/stacks/{stack}/SUMMARY.md`
307
+ - `~/.viepilot/stacks/{stack}/BEST-PRACTICES.md`
308
+ - `~/.viepilot/stacks/{stack}/ANTI-PATTERNS.md`
309
+ - `~/.viepilot/stacks/{stack}/SOURCES.md`
310
+
311
+ Include source links and last-updated timestamp.
312
+
313
+ ### 3g. Report Tier 3 results
314
+ ```
315
+ TIER 3: Stack Best Practices + Code Quality
316
+ ─────────────────────────────────────────────────
317
+ Stack detection {✅ N detected | ⚠️ none detected}
318
+ Cache coverage {✅ all cached | ⚠️ N stacks missing cache}
319
+ Research fallback {✅ not needed | ℹ️ applied to N stacks}
320
+ Compliance findings {✅ no issues | ⚠️ N findings by severity}
321
+ vp-auto guardrails contract {✅ generated | ⚠️ partial}
322
+ ```
323
+ </step>
324
+
325
+ <step name="tier3_framework">
326
+ ## 4. Tier 4: Framework Integrity (viepilot framework only)
327
+
328
+ > **Guard**: Only runs when `IS_VIEPILOT_FRAMEWORK=true` (or `--framework` flag).
329
+ > Skip entirely for user projects.
330
+
331
+ ```bash
332
+ if [ "$IS_VIEPILOT_FRAMEWORK" != "true" ]; then
333
+ echo "→ Tier 4 skipped (not a viepilot framework repo)"
334
+ # Jump to step 5 (report)
335
+ fi
336
+ ```
337
+
338
+ ### 4a. Collect actual framework state
339
+ ```bash
340
+ SKILL_COUNT=$(ls -d skills/vp-*/ 2>/dev/null | wc -l | tr -d ' ')
341
+ SKILL_LIST=$(ls -d skills/vp-*/ 2>/dev/null | xargs -I{} basename {} | sort)
342
+ WORKFLOW_COUNT=$(ls workflows/*.md 2>/dev/null | wc -l | tr -d ' ')
343
+ WORKFLOW_LIST=$(ls workflows/*.md 2>/dev/null | xargs -I{} basename {} .md | sort)
344
+ CLI_OUTPUT=$(node bin/vp-tools.cjs help 2>/dev/null)
345
+ CLI_COUNT=$(echo "$CLI_OUTPUT" | grep -E "^\s+[a-z]" | wc -l | tr -d ' ')
346
+ ```
347
+
348
+ ### 4b. Parse ARCHITECTURE.md
349
+ Read `.viepilot/ARCHITECTURE.md` and extract documented counts:
350
+ ```
351
+ /SKILLS LAYER \((\d+)\)/
352
+ /WORKFLOWS LAYER \((\d+)\)/
353
+ /vp-tools\.cjs \((\d+) commands\)/
354
+ ```
355
+
356
+ ### 4c. Compare and identify gaps
357
+ ```javascript
358
+ const gaps = [];
359
+ if (actual.skills !== documented.skills) {
360
+ gaps.push({ type: 'skills', actual: actual.skills, documented: documented.skills,
361
+ missing: actual.skillList.filter(s => !documented.skillList.includes(s)),
362
+ extra: documented.skillList.filter(s => !actual.skillList.includes(s)) });
363
+ }
364
+ // Similar for workflows and CLI
365
+ ```
366
+
367
+ ### 4d. Check README.md viepilot-specific badges
368
+ ```bash
369
+ ACTUAL_SKILLS=$(ls skills/*/SKILL.md 2>/dev/null | wc -l | tr -d ' ')
370
+ ACTUAL_WORKFLOWS=$(ls workflows/*.md 2>/dev/null | wc -l | tr -d ' ')
371
+ README_VERSION=$(grep -o 'version-[0-9]\+\.[0-9]\+\.[0-9]\+' README.md 2>/dev/null | head -1 | sed 's/version-//')
372
+ README_SKILLS=$(grep -o 'skills-[0-9]\+' README.md 2>/dev/null | head -1 | sed 's/skills-//')
373
+ README_WORKFLOWS=$(grep -o 'workflows-[0-9]\+' README.md 2>/dev/null | head -1 | sed 's/workflows-//')
374
+ ```
375
+
376
+ ### 4e. Check docs/skills-reference.md vs skills/
377
+ ```bash
378
+ ACTUAL_SKILLS_LIST=$(ls skills/*/SKILL.md 2>/dev/null | sed 's|skills/||; s|/SKILL\.md||' | sort)
379
+ DOCUMENTED_SKILLS=$(grep "^## /vp-" docs/skills-reference.md 2>/dev/null | sed 's|## /||' | sort)
380
+ MISSING_IN_SKILLSREF=$(comm -23 <(echo "$ACTUAL_SKILLS_LIST") <(echo "$DOCUMENTED_SKILLS"))
381
+ ```
382
+
383
+ ### 4f. Report Tier 4 results
384
+ ```
385
+ TIER 4: Framework Integrity
386
+ ─────────────────────────────────────────────────
387
+ Skills count (ARCHITECTURE.md) {✅ N in sync | ⚠️ N actual vs M documented}
388
+ Workflows count {✅ N in sync | ⚠️ N actual vs M documented}
389
+ CLI commands count {✅ N in sync | ⚠️ N actual vs M documented}
390
+ README.md badges {✅ In sync | ⚠️ version/skills/workflows drift}
391
+ docs/skills-reference.md {✅ Complete | ⚠️ N skills missing}
392
+ ```
393
+ </step>
394
+
395
+ <step name="report">
396
+ ## 5. Generate Full Report
397
+
398
+ ### All Clear
399
+ ```
400
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
401
+ VIEPILOT ► AUDIT PASSED ✅
402
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
403
+
404
+ Tier 1: ViePilot State ✅ All consistent
405
+ Tier 2: Project Docs ✅ No drift detected
406
+ Tier 3: Stack Practices {✅ In sync | ⚠️ N issues}
407
+ Tier 4: Framework {✅ In sync | ℹ️ Skipped}
408
+
409
+ Everything looks good!
410
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
411
+ ```
412
+
413
+ ### Issues Found
414
+ ```
415
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
416
+ VIEPILOT ► AUDIT REPORT
417
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
418
+
419
+ Tier 1: ViePilot State {✅ | ⚠️ N issues}
420
+ Tier 2: Project Docs {✅ | ⚠️ N issues}
421
+ Tier 3: Stack Practices {✅ | ⚠️ N issues}
422
+ Tier 4: Framework {✅ | ⚠️ N issues | ℹ️ Skipped}
423
+
424
+ ISSUES DETAIL:
425
+ {list each issue with context}
426
+
427
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
428
+ OPTIONS
429
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
430
+ 1. Auto-fix all issues
431
+ 2. Report only → save to .viepilot/audit-report.md
432
+ 3. Fix specific items
433
+ 4. Skip
434
+ ```
435
+ </step>
436
+
437
+ <step name="fix">
438
+ ## 6. Auto-Fix (if requested)
439
+
440
+ ### Tier 1 fixes
441
+ - Update ROADMAP.md phase statuses from PHASE-STATE.md files
442
+ - Sync TRACKER.md current state with PHASE-STATE.md
443
+ - Create missing git tags for completed phases
444
+ - Add missing per-task trace entries/checkpoints when feasible
445
+
446
+ ### Tier 2 fixes
447
+ - Replace placeholder URLs in docs/ with actual git remote URL
448
+ - Add version mention to README.md if missing
449
+ - Add CHANGELOG.md [Unreleased] section if commits exist
450
+
451
+ ### Tier 3 fixes (stack guidance)
452
+ - Write/update stack cache guidance files when fallback research was used
453
+ - Add/update "guardrails contract" section in generated audit report
454
+ - Mark source confidence (official/reference/community)
455
+
456
+ ### Tier 4 fixes (framework only)
457
+ - Update ARCHITECTURE.md counts (skills, workflows, CLI)
458
+ - Add missing skills to ARCHITECTURE.md diagrams
459
+ - Append missing skill sections to docs/skills-reference.md
460
+ - Update README.md viepilot-specific badges
461
+
462
+ ### Commit
463
+ ```bash
464
+ git add .viepilot/ARCHITECTURE.md .viepilot/ROADMAP.md .viepilot/TRACKER.md docs/ README.md CHANGELOG.md
465
+ git commit -m "docs: sync project documentation (audit auto-fix)
466
+
467
+ Auto-fixed by /vp-audit"
468
+ git push
469
+ ```
470
+ </step>
471
+
472
+ <step name="save_report">
473
+ ## 7. Save Report (if --report)
474
+
475
+ Create `.viepilot/audit-report.md`:
476
+ ```markdown
477
+ # Audit Report - {timestamp}
478
+
479
+ ## Summary
480
+ - **Status**: {PASS|ISSUES_FOUND}
481
+ - **Project Type**: {viepilot-framework|user-project}
482
+ - **Issues**: {count}
483
+ - **Generated**: {timestamp}
484
+
485
+ ## Tier 1: ViePilot State
486
+ {results}
487
+
488
+ ## Tier 2: Project Documentation
489
+ {results}
490
+
491
+ ## Tier 3: Stack Best Practices + Code Quality
492
+ {results}
493
+
494
+ ## Tier 4: Framework Integrity
495
+ {results or "Skipped — not a viepilot framework repo"}
496
+
497
+ ## Recommendations
498
+ {what to fix}
499
+ ```
500
+ </step>
501
+
502
+ </process>
503
+
504
+ <integration>
505
+ ## Auto-Hook Integration
506
+
507
+ Add to `workflows/autonomous.md` after phase complete:
508
+
509
+ ```xml
510
+ <step name="post_phase_audit">
511
+ ## Post-Phase Documentation Audit
512
+
513
+ After marking phase complete:
514
+
515
+ 1. Run silent audit (Tier 1 + Tier 2 only)
516
+ ```bash
517
+ # Conceptually:
518
+ /vp-audit --silent
519
+ ```
520
+
521
+ 2. If issues found:
522
+ ```
523
+ ⚠️ Documentation may be out of sync.
524
+
525
+ Run /vp-audit to check and fix.
526
+
527
+ Continue anyway? (y/n)
528
+ ```
529
+
530
+ 3. Recommend running before version bump
531
+ </step>
532
+ ```
533
+ </integration>
534
+
535
+ <success_criteria>
536
+ - [ ] Tier 1 state consistency checks work for any project using ViePilot
537
+ - [ ] Tier 1 can flag delayed/batch-only state-update anti-patterns
538
+ - [ ] Tier 1 includes heuristic guidance for execute-first / docs-later ordering risk (BUG-001)
539
+ - [ ] Tier 2 documentation drift checks work for Java/Node/Python/any project
540
+ - [ ] Tier 3 stack best-practice checks run for detected stacks
541
+ - [ ] Tier 3 supports web research fallback when stack cache is missing/weak
542
+ - [ ] Tier 3 output includes severity + file/module mapping
543
+ - [ ] Tier 3 output emits vp-auto-compatible guardrails contract
544
+ - [ ] Tier 4 framework checks only run when viepilot framework repo detected
545
+ - [ ] `--framework` flag forces Tier 4 checks
546
+ - [ ] `--project` flag skips Tier 4 checks
547
+ - [ ] Report clearly shows which tier found issues
548
+ - [ ] Auto-fix applies correct fixes per tier
549
+ </success_criteria>