cc-devflow 1.0.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.
- package/.claude/CLAUDE.md +83 -0
- package/.claude/agents/architecture-designer.md +443 -0
- package/.claude/agents/bug-analyzer.md +382 -0
- package/.claude/agents/checklist-agent.md +175 -0
- package/.claude/agents/clarify-analyst.md +50 -0
- package/.claude/agents/code-reviewer.md +71 -0
- package/.claude/agents/codex-analyzer.md +39 -0
- package/.claude/agents/compatibility-checker.md +580 -0
- package/.claude/agents/consistency-checker.md +532 -0
- package/.claude/agents/impact-analyzer.md +441 -0
- package/.claude/agents/planner.md +230 -0
- package/.claude/agents/prd-writer.md +320 -0
- package/.claude/agents/project-guidelines-generator.md +1329 -0
- package/.claude/agents/qa-tester.md +313 -0
- package/.claude/agents/release-manager.md +295 -0
- package/.claude/agents/security-reviewer.md +314 -0
- package/.claude/agents/style-guide-generator.md +458 -0
- package/.claude/agents/tech-architect.md +516 -0
- package/.claude/agents/ui-designer.md +485 -0
- package/.claude/commands/code-review-high.md +58 -0
- package/.claude/commands/core-architecture.md +429 -0
- package/.claude/commands/core-guidelines.md +486 -0
- package/.claude/commands/core-roadmap.md +439 -0
- package/.claude/commands/core-style.md +293 -0
- package/.claude/commands/flow-archive.md +245 -0
- package/.claude/commands/flow-checklist.md +260 -0
- package/.claude/commands/flow-clarify.md +136 -0
- package/.claude/commands/flow-constitution.md +82 -0
- package/.claude/commands/flow-dev.md +134 -0
- package/.claude/commands/flow-epic.md +150 -0
- package/.claude/commands/flow-fix.md +104 -0
- package/.claude/commands/flow-ideate.md +214 -0
- package/.claude/commands/flow-init.md +313 -0
- package/.claude/commands/flow-new.md +394 -0
- package/.claude/commands/flow-prd.md +131 -0
- package/.claude/commands/flow-qa.md +93 -0
- package/.claude/commands/flow-release.md +92 -0
- package/.claude/commands/flow-restart.md +98 -0
- package/.claude/commands/flow-status.md +64 -0
- package/.claude/commands/flow-tech.md +142 -0
- package/.claude/commands/flow-ui.md +189 -0
- package/.claude/commands/flow-update.md +111 -0
- package/.claude/commands/flow-upgrade.md +115 -0
- package/.claude/commands/flow-verify.md +96 -0
- package/.claude/commands/problem-analyzer.md +60 -0
- package/.claude/config/quality-rules.yml +161 -0
- package/.claude/docs/SPEC_KIT_CONSTITUTION_ANALYSIS.md +426 -0
- package/.claude/docs/design/consistency-conflict-detection-algorithms.md +658 -0
- package/.claude/docs/design/intent-driven-input-design.md +380 -0
- package/.claude/docs/design/prd-version-management-design.md +437 -0
- package/.claude/docs/guides/INIT_TROUBLESHOOTING.md +117 -0
- package/.claude/docs/guides/NEW_TROUBLESHOOTING.md +151 -0
- package/.claude/docs/guides/ROADMAP_TROUBLESHOOTING.md +188 -0
- package/.claude/docs/guides/TASK_COMPLETION_MARKING.md +338 -0
- package/.claude/docs/templates/ARCHITECTURE_TEMPLATE.md +633 -0
- package/.claude/docs/templates/BACKLOG_TEMPLATE.md +261 -0
- package/.claude/docs/templates/CHECKLIST_TEMPLATE.md +52 -0
- package/.claude/docs/templates/CLARIFICATION_REPORT_TEMPLATE.md +206 -0
- package/.claude/docs/templates/CODE_REVIEW_TEMPLATE.md +71 -0
- package/.claude/docs/templates/EPIC_TEMPLATE.md +805 -0
- package/.claude/docs/templates/INIT_FLOW_TEMPLATE.md +213 -0
- package/.claude/docs/templates/INTENT_CLARIFICATION_TEMPLATE.md +57 -0
- package/.claude/docs/templates/NEW_ORCHESTRATION_TEMPLATE.md +148 -0
- package/.claude/docs/templates/PRD_TEMPLATE.md +562 -0
- package/.claude/docs/templates/RESEARCH_TEMPLATE.md +276 -0
- package/.claude/docs/templates/REVIEW-HIGH.md +57 -0
- package/.claude/docs/templates/ROADMAP_DIALOGUE_TEMPLATE.md +198 -0
- package/.claude/docs/templates/ROADMAP_TEMPLATE.md +310 -0
- package/.claude/docs/templates/STYLE_TEMPLATE.md +1266 -0
- package/.claude/docs/templates/TASKS_TEMPLATE.md +523 -0
- package/.claude/docs/templates/TECH_DESIGN_TEMPLATE.md +1019 -0
- package/.claude/docs/templates/UI_PROTOTYPE_TEMPLATE.md +1436 -0
- package/.claude/guides/agent-guides/agent-coordination-guide.md +459 -0
- package/.claude/guides/project-guidelines-system.md +463 -0
- package/.claude/guides/technical-guides/datetime-handling-guide.md +563 -0
- package/.claude/guides/technical-guides/git-github-guide.md +642 -0
- package/.claude/guides/technical-guides/test-execution-guide.md +618 -0
- package/.claude/guides/workflow-guides/bug-fix-orchestrator.md +217 -0
- package/.claude/guides/workflow-guides/flow-orchestrator.md +282 -0
- package/.claude/hooks/checklist-gate.js +397 -0
- package/.claude/hooks/error-handling-reminder.sh +12 -0
- package/.claude/hooks/error-handling-reminder.ts +459 -0
- package/.claude/hooks/post-tool-use-tracker.sh +280 -0
- package/.claude/hooks/pre-tool-use-guardrail.sh +36 -0
- package/.claude/hooks/pre-tool-use-guardrail.ts +342 -0
- package/.claude/hooks/skill-activation-prompt.sh +36 -0
- package/.claude/hooks/skill-activation-prompt.ts +214 -0
- package/.claude/hooks/state/skills-used-test-guard.json +3 -0
- package/.claude/rules/devflow-conventions.md +305 -0
- package/.claude/rules/project-constitution.md +748 -0
- package/.claude/schemas/constitution.schema.json +43 -0
- package/.claude/scripts/analyze-upgrade-impact.sh +200 -0
- package/.claude/scripts/archive-requirement.sh +351 -0
- package/.claude/scripts/calculate-checklist-completion.sh +243 -0
- package/.claude/scripts/calculate-quarter.sh +206 -0
- package/.claude/scripts/check-dependencies.sh +409 -0
- package/.claude/scripts/check-prerequisites.sh +232 -0
- package/.claude/scripts/check-task-status.sh +264 -0
- package/.claude/scripts/checklist-errors.sh +131 -0
- package/.claude/scripts/common.sh +570 -0
- package/.claude/scripts/consolidate-research.sh +182 -0
- package/.claude/scripts/create-requirement.sh +426 -0
- package/.claude/scripts/export-contracts.sh +117 -0
- package/.claude/scripts/extract-data-model.sh +78 -0
- package/.claude/scripts/generate-clarification-questions.sh +377 -0
- package/.claude/scripts/generate-clarification-report.sh +463 -0
- package/.claude/scripts/generate-quickstart.sh +146 -0
- package/.claude/scripts/generate-research-tasks.sh +157 -0
- package/.claude/scripts/generate-status-report.sh +523 -0
- package/.claude/scripts/generate-tech-analysis.sh +46 -0
- package/.claude/scripts/locate-requirement-in-roadmap.sh +233 -0
- package/.claude/scripts/manage-constitution.sh +602 -0
- package/.claude/scripts/mark-task-complete.sh +198 -0
- package/.claude/scripts/populate-research-tasks.sh +259 -0
- package/.claude/scripts/recover-workflow.sh +460 -0
- package/.claude/scripts/run-clarify-scan.sh +601 -0
- package/.claude/scripts/run-high-review.sh +62 -0
- package/.claude/scripts/run-problem-analysis.sh +68 -0
- package/.claude/scripts/setup-epic.sh +173 -0
- package/.claude/scripts/sync-roadmap-progress.sh +300 -0
- package/.claude/scripts/sync-task-marks.sh +199 -0
- package/.claude/scripts/test-clarify-scan.sh +515 -0
- package/.claude/scripts/update-agent-context.sh +806 -0
- package/.claude/scripts/validate-constitution.sh +567 -0
- package/.claude/scripts/validate-hooks.sh +487 -0
- package/.claude/scripts/validate-research.sh +332 -0
- package/.claude/scripts/validate-scope-boundary.sh +493 -0
- package/.claude/scripts/verify-setup.sh +37 -0
- package/.claude/settings.json +76 -0
- package/.claude/skills/_reference-implementations/README.md +96 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/SKILL.md +302 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/architecture-overview.md +451 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/async-and-errors.md +307 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/complete-examples.md +638 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/configuration.md +275 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/database-patterns.md +224 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/middleware-guide.md +213 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/routing-and-controllers.md +756 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/sentry-and-monitoring.md +336 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/services-and-repositories.md +789 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/testing-guide.md +235 -0
- package/.claude/skills/_reference-implementations/backend-express-prisma/resources/validation-patterns.md +754 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/SKILL.md +399 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/common-patterns.md +331 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/complete-examples.md +872 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/component-patterns.md +502 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/data-fetching.md +767 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/file-organization.md +502 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/loading-and-error-states.md +501 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/performance.md +406 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/routing-guide.md +364 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/styling-guide.md +428 -0
- package/.claude/skills/_reference-implementations/frontend-react-mui/resources/typescript-standards.md +418 -0
- package/.claude/skills/cc-devflow-orchestrator/SKILL.md +229 -0
- package/.claude/skills/constitution-guardian/SKILL.md +306 -0
- package/.claude/skills/devflow-constitution-quick-ref/SKILL.md +374 -0
- package/.claude/skills/devflow-file-standards/SKILL.md +353 -0
- package/.claude/skills/devflow-tdd-enforcer/SKILL.md +192 -0
- package/.claude/skills/skill-developer/ADVANCED.md +197 -0
- package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +306 -0
- package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +152 -0
- package/.claude/skills/skill-developer/SKILL.md +426 -0
- package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +315 -0
- package/.claude/skills/skill-developer/TRIGGER_TYPES.md +305 -0
- package/.claude/skills/skill-developer/TROUBLESHOOTING.md +514 -0
- package/.claude/skills/skill-rules.json +213 -0
- package/.claude/tests/README.md +300 -0
- package/.claude/tests/TODO.md +69 -0
- package/.claude/tests/__pycache__/test_analyze_upgrade_impact.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_consolidate_research.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_export_contracts.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_extract_data_model.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_generate_quickstart.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/__pycache__/test_generate_research_tasks.cpython-311-pytest-7.2.2.pyc +0 -0
- package/.claude/tests/constitution/run_all_constitution_tests.sh +111 -0
- package/.claude/tests/constitution/test_agent_assignment.sh +207 -0
- package/.claude/tests/constitution/test_article_coverage.sh +201 -0
- package/.claude/tests/constitution/test_template_completeness.sh +150 -0
- package/.claude/tests/constitution/test_version_consistency.sh +120 -0
- package/.claude/tests/fixtures/spec_delta_full.md +16 -0
- package/.claude/tests/fixtures/tasks_progress_sample.md +5 -0
- package/.claude/tests/run-all-tests.sh +229 -0
- package/.claude/tests/scripts/run.sh +30 -0
- package/.claude/tests/scripts/test-framework.sh +128 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh +511 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak +504 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak2 +505 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak3 +506 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak4 +507 -0
- package/.claude/tests/scripts/test_check_prerequisites.sh.bak5 +508 -0
- package/.claude/tests/scripts/test_check_task_status.sh +499 -0
- package/.claude/tests/scripts/test_common.sh +244 -0
- package/.claude/tests/scripts/test_generate_status_report.sh +71 -0
- package/.claude/tests/scripts/test_mark_task_complete.sh +441 -0
- package/.claude/tests/scripts/test_mark_task_complete.sh.backup +410 -0
- package/.claude/tests/scripts/test_recover_workflow.sh +304 -0
- package/.claude/tests/scripts/test_setup_epic.sh +437 -0
- package/.claude/tests/scripts/test_sync_task_marks.sh +196 -0
- package/.claude/tests/scripts/test_validate_constitution.sh +74 -0
- package/.claude/tests/scripts/test_validate_research.sh +462 -0
- package/.claude/tests/slugify.bats +82 -0
- package/.claude/tests/test-framework.sh +732 -0
- package/.claude/tests/test_analyze_upgrade_impact.py +34 -0
- package/.claude/tests/test_consolidate_research.py +48 -0
- package/.claude/tests/test_export_contracts.py +43 -0
- package/.claude/tests/test_extract_data_model.py +33 -0
- package/.claude/tests/test_generate_quickstart.py +50 -0
- package/.claude/tests/test_generate_research_tasks.py +52 -0
- package/.claude/tsc-cache/6e64f818-6398-49ca-8623-581a9af85c44/edited-files.log +1 -0
- package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +1 -0
- package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/edited-files.log +1 -0
- package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +1 -0
- package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/edited-files.log +1 -0
- package/CHANGELOG.md +507 -0
- package/LICENSE +21 -0
- package/README.md +534 -0
- package/README.zh-CN.md +530 -0
- package/bin/adapt.js +240 -0
- package/bin/cc-devflow-cli.js +185 -0
- package/bin/cc-devflow.js +78 -0
- package/config/adapters.yml +5 -0
- package/config/schema/adapters.schema.json +44 -0
- package/docs/CLAUDE.md +26 -0
- package/docs/commands/README.md +61 -0
- package/docs/commands/README.zh-CN.md +55 -0
- package/docs/commands/core-roadmap.md +106 -0
- package/docs/commands/core-roadmap.zh-CN.md +102 -0
- package/docs/commands/core-style.md +405 -0
- package/docs/commands/core-style.zh-CN.md +405 -0
- package/docs/commands/flow-init.md +134 -0
- package/docs/commands/flow-init.zh-CN.md +163 -0
- package/docs/commands/flow-new.md +274 -0
- package/docs/commands/flow-new.zh-CN.md +270 -0
- package/docs/guides/getting-started.md +204 -0
- package/docs/guides/getting-started.zh-CN.md +152 -0
- package/lib/adapters/adapter-interface.js +57 -0
- package/lib/adapters/claude-adapter.js +74 -0
- package/lib/adapters/codex-adapter.js +40 -0
- package/lib/adapters/config-validator.js +68 -0
- package/lib/adapters/logger.js +42 -0
- package/lib/adapters/registry.js +153 -0
- package/lib/compiler/CLAUDE.md +92 -0
- package/lib/compiler/__tests__/drift.test.js +215 -0
- package/lib/compiler/__tests__/errors.test.js +184 -0
- package/lib/compiler/__tests__/incremental.test.js +174 -0
- package/lib/compiler/__tests__/integration.test.js +174 -0
- package/lib/compiler/__tests__/manifest.test.js +233 -0
- package/lib/compiler/__tests__/parser.test.js +456 -0
- package/lib/compiler/__tests__/schemas.test.js +301 -0
- package/lib/compiler/__tests__/skills-registry.test.js +125 -0
- package/lib/compiler/__tests__/transformer.test.js +286 -0
- package/lib/compiler/emitters/antigravity-emitter.js +171 -0
- package/lib/compiler/emitters/base-emitter.js +73 -0
- package/lib/compiler/emitters/codex-emitter.js +52 -0
- package/lib/compiler/emitters/cursor-emitter.js +31 -0
- package/lib/compiler/emitters/index.js +50 -0
- package/lib/compiler/emitters/qwen-emitter.js +39 -0
- package/lib/compiler/errors.js +119 -0
- package/lib/compiler/index.js +256 -0
- package/lib/compiler/manifest.js +242 -0
- package/lib/compiler/parser.js +258 -0
- package/lib/compiler/platforms.js +113 -0
- package/lib/compiler/resource-copier.js +320 -0
- package/lib/compiler/rules-emitters/__tests__/antigravity-rules-emitter.test.js +191 -0
- package/lib/compiler/rules-emitters/__tests__/codex-rules-emitter.test.js +109 -0
- package/lib/compiler/rules-emitters/__tests__/cursor-rules-emitter.test.js +123 -0
- package/lib/compiler/rules-emitters/__tests__/qwen-rules-emitter.test.js +123 -0
- package/lib/compiler/rules-emitters/antigravity-rules-emitter.js +253 -0
- package/lib/compiler/rules-emitters/base-rules-emitter.js +83 -0
- package/lib/compiler/rules-emitters/codex-rules-emitter.js +116 -0
- package/lib/compiler/rules-emitters/cursor-rules-emitter.js +98 -0
- package/lib/compiler/rules-emitters/index.js +71 -0
- package/lib/compiler/rules-emitters/qwen-rules-emitter.js +70 -0
- package/lib/compiler/schemas.js +144 -0
- package/lib/compiler/skills-registry.js +225 -0
- package/lib/compiler/transformer.js +236 -0
- package/package.json +50 -0
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Validate Constitution compliance for cc-devflow
|
|
4
|
+
#
|
|
5
|
+
# This script checks code and documentation against CC-DevFlow Constitution v2.0.0.
|
|
6
|
+
# Validates all 10 Constitutional Articles (Article I-X).
|
|
7
|
+
# Inspired by spec-kit's quality gate philosophy.
|
|
8
|
+
#
|
|
9
|
+
# Constitution Reference: .claude/constitution/project-constitution.md
|
|
10
|
+
# Article I: Quality First
|
|
11
|
+
# Article II: Architectural Consistency
|
|
12
|
+
# Article III: Security First
|
|
13
|
+
# Article IV: Performance Accountability
|
|
14
|
+
# Article V: Maintainability
|
|
15
|
+
# Article VI: Test-First Development
|
|
16
|
+
# Article VII: Simplicity Gate
|
|
17
|
+
# Article VIII: Anti-Abstraction
|
|
18
|
+
# Article IX: Integration-First Testing
|
|
19
|
+
# Article X: Requirement Boundary
|
|
20
|
+
#
|
|
21
|
+
# Usage: ./validate-constitution.sh [TARGET] [OPTIONS]
|
|
22
|
+
#
|
|
23
|
+
# ARGUMENTS:
|
|
24
|
+
# TARGET Optional target to validate (file, directory, or REQ-ID)
|
|
25
|
+
# If not specified, validates current requirement
|
|
26
|
+
#
|
|
27
|
+
# OPTIONS:
|
|
28
|
+
# --type TYPE Validation type: code, docs, prd, epic, tasks, all (default: all)
|
|
29
|
+
# --severity LEVEL Minimum severity to report: info, warning, error (default: warning)
|
|
30
|
+
# --fix Attempt to auto-fix issues where possible
|
|
31
|
+
# --json Output in JSON format
|
|
32
|
+
# --verbose, -v Verbose output with detailed explanations
|
|
33
|
+
# --help, -h Show help message
|
|
34
|
+
#
|
|
35
|
+
# VALIDATION TYPES:
|
|
36
|
+
# code Validate source code against Constitution principles
|
|
37
|
+
# docs Validate documentation completeness
|
|
38
|
+
# prd Validate PRD against Constitution checklist
|
|
39
|
+
# epic Validate Epic against Constitution checklist
|
|
40
|
+
# tasks Validate Tasks against TDD and Constitution principles
|
|
41
|
+
# all Run all validation types
|
|
42
|
+
#
|
|
43
|
+
# EXAMPLES:
|
|
44
|
+
# # Validate current requirement (all types)
|
|
45
|
+
# ./validate-constitution.sh
|
|
46
|
+
#
|
|
47
|
+
# # Validate specific file
|
|
48
|
+
# ./validate-constitution.sh src/api/users.ts --type code
|
|
49
|
+
#
|
|
50
|
+
# # Validate PRD only
|
|
51
|
+
# ./validate-constitution.sh REQ-123 --type prd
|
|
52
|
+
#
|
|
53
|
+
# # Validate with auto-fix
|
|
54
|
+
# ./validate-constitution.sh --type code --fix
|
|
55
|
+
#
|
|
56
|
+
# # JSON output for CI/CD
|
|
57
|
+
# ./validate-constitution.sh --json
|
|
58
|
+
|
|
59
|
+
set -e
|
|
60
|
+
|
|
61
|
+
# Parse command line arguments
|
|
62
|
+
TARGET=""
|
|
63
|
+
VALIDATION_TYPE="all"
|
|
64
|
+
SEVERITY="warning"
|
|
65
|
+
AUTO_FIX=false
|
|
66
|
+
JSON_MODE=false
|
|
67
|
+
VERBOSE=false
|
|
68
|
+
|
|
69
|
+
while [[ $# -gt 0 ]]; do
|
|
70
|
+
case "$1" in
|
|
71
|
+
--type)
|
|
72
|
+
VALIDATION_TYPE="$2"
|
|
73
|
+
shift 2
|
|
74
|
+
;;
|
|
75
|
+
--severity)
|
|
76
|
+
SEVERITY="$2"
|
|
77
|
+
shift 2
|
|
78
|
+
;;
|
|
79
|
+
--fix)
|
|
80
|
+
AUTO_FIX=true
|
|
81
|
+
shift
|
|
82
|
+
;;
|
|
83
|
+
--json)
|
|
84
|
+
JSON_MODE=true
|
|
85
|
+
shift
|
|
86
|
+
;;
|
|
87
|
+
--verbose|-v)
|
|
88
|
+
VERBOSE=true
|
|
89
|
+
shift
|
|
90
|
+
;;
|
|
91
|
+
--help|-h)
|
|
92
|
+
cat << 'EOF'
|
|
93
|
+
Usage: validate-constitution.sh [TARGET] [OPTIONS]
|
|
94
|
+
|
|
95
|
+
Validate code and documentation against CC-DevFlow Constitution principles.
|
|
96
|
+
|
|
97
|
+
ARGUMENTS:
|
|
98
|
+
TARGET Optional target (file, directory, or REQ-ID)
|
|
99
|
+
Defaults to current requirement
|
|
100
|
+
|
|
101
|
+
OPTIONS:
|
|
102
|
+
--type TYPE Validation type: code, docs, prd, epic, tasks, all
|
|
103
|
+
Default: all
|
|
104
|
+
--severity LEVEL Minimum severity: info, warning, error
|
|
105
|
+
Default: warning
|
|
106
|
+
--fix Attempt to auto-fix issues
|
|
107
|
+
--json Output in JSON format
|
|
108
|
+
--verbose, -v Verbose output with explanations
|
|
109
|
+
--help, -h Show this help message
|
|
110
|
+
|
|
111
|
+
VALIDATION TYPES:
|
|
112
|
+
code Source code validation (NO PARTIAL IMPLEMENTATION, etc.)
|
|
113
|
+
docs Documentation completeness
|
|
114
|
+
prd PRD Constitution checklist
|
|
115
|
+
epic Epic Constitution checklist
|
|
116
|
+
tasks Tasks TDD compliance and Constitution checks
|
|
117
|
+
all All validation types
|
|
118
|
+
|
|
119
|
+
CONSTITUTION PRINCIPLES CHECKED:
|
|
120
|
+
1. Quality First: NO PARTIAL IMPLEMENTATION, NO SIMPLIFICATION
|
|
121
|
+
2. Architectural Consistency: NO CODE DUPLICATION, CONSISTENT NAMING
|
|
122
|
+
3. Security First: NO HARDCODED SECRETS, INPUT VALIDATION
|
|
123
|
+
4. Performance: NO RESOURCE LEAKS
|
|
124
|
+
5. Maintainability: NO DEAD CODE, FILE SIZE LIMIT
|
|
125
|
+
|
|
126
|
+
EXAMPLES:
|
|
127
|
+
# Validate current requirement
|
|
128
|
+
./validate-constitution.sh
|
|
129
|
+
|
|
130
|
+
# Validate specific file
|
|
131
|
+
./validate-constitution.sh src/users.ts --type code
|
|
132
|
+
|
|
133
|
+
# Validate PRD with verbose output
|
|
134
|
+
./validate-constitution.sh REQ-123 --type prd --verbose
|
|
135
|
+
|
|
136
|
+
# Validate and auto-fix
|
|
137
|
+
./validate-constitution.sh --type code --fix
|
|
138
|
+
|
|
139
|
+
# CI/CD integration
|
|
140
|
+
./validate-constitution.sh --json --severity error
|
|
141
|
+
|
|
142
|
+
EXIT CODES:
|
|
143
|
+
0 - All validations passed
|
|
144
|
+
1 - Validation errors found
|
|
145
|
+
2 - Invalid arguments or configuration
|
|
146
|
+
|
|
147
|
+
EOF
|
|
148
|
+
exit 0
|
|
149
|
+
;;
|
|
150
|
+
-*)
|
|
151
|
+
echo "ERROR: Unknown option '$1'. Use --help for usage information." >&2
|
|
152
|
+
exit 2
|
|
153
|
+
;;
|
|
154
|
+
*)
|
|
155
|
+
if [[ -z "$TARGET" ]]; then
|
|
156
|
+
TARGET="$1"
|
|
157
|
+
else
|
|
158
|
+
echo "ERROR: Too many arguments. Use --help for usage information." >&2
|
|
159
|
+
exit 2
|
|
160
|
+
fi
|
|
161
|
+
shift
|
|
162
|
+
;;
|
|
163
|
+
esac
|
|
164
|
+
done
|
|
165
|
+
|
|
166
|
+
# Validate arguments
|
|
167
|
+
case "$VALIDATION_TYPE" in
|
|
168
|
+
code|docs|prd|epic|tasks|all) ;;
|
|
169
|
+
*)
|
|
170
|
+
echo "ERROR: Invalid validation type: $VALIDATION_TYPE" >&2
|
|
171
|
+
echo "Valid types: code, docs, prd, epic, tasks, all" >&2
|
|
172
|
+
exit 2
|
|
173
|
+
;;
|
|
174
|
+
esac
|
|
175
|
+
|
|
176
|
+
case "$SEVERITY" in
|
|
177
|
+
info|warning|error) ;;
|
|
178
|
+
*)
|
|
179
|
+
echo "ERROR: Invalid severity level: $SEVERITY" >&2
|
|
180
|
+
echo "Valid levels: info, warning, error" >&2
|
|
181
|
+
exit 2
|
|
182
|
+
;;
|
|
183
|
+
esac
|
|
184
|
+
|
|
185
|
+
# Source common functions
|
|
186
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
187
|
+
source "$SCRIPT_DIR/common.sh"
|
|
188
|
+
|
|
189
|
+
# Get repository root
|
|
190
|
+
REPO_ROOT=$(get_repo_root)
|
|
191
|
+
|
|
192
|
+
# Initialize validation results
|
|
193
|
+
TOTAL_ISSUES=0
|
|
194
|
+
ERROR_COUNT=0
|
|
195
|
+
WARNING_COUNT=0
|
|
196
|
+
INFO_COUNT=0
|
|
197
|
+
declare -a ISSUES=()
|
|
198
|
+
|
|
199
|
+
# Add issue to results
|
|
200
|
+
# Args: $1 - severity, $2 - category, $3 - message, $4 - file (optional), $5 - line (optional)
|
|
201
|
+
add_issue() {
|
|
202
|
+
local severity="$1"
|
|
203
|
+
local category="$2"
|
|
204
|
+
local message="$3"
|
|
205
|
+
local file="${4:-""}"
|
|
206
|
+
local line="${5:-""}"
|
|
207
|
+
|
|
208
|
+
TOTAL_ISSUES=$((TOTAL_ISSUES + 1))
|
|
209
|
+
|
|
210
|
+
case "$severity" in
|
|
211
|
+
error) ERROR_COUNT=$((ERROR_COUNT + 1)) ;;
|
|
212
|
+
warning) WARNING_COUNT=$((WARNING_COUNT + 1)) ;;
|
|
213
|
+
info) INFO_COUNT=$((INFO_COUNT + 1)) ;;
|
|
214
|
+
esac
|
|
215
|
+
|
|
216
|
+
# Check if we should report this severity
|
|
217
|
+
case "$SEVERITY" in
|
|
218
|
+
error)
|
|
219
|
+
[[ "$severity" != "error" ]] && return
|
|
220
|
+
;;
|
|
221
|
+
warning)
|
|
222
|
+
[[ "$severity" == "info" ]] && return
|
|
223
|
+
;;
|
|
224
|
+
info)
|
|
225
|
+
# Report all
|
|
226
|
+
;;
|
|
227
|
+
esac
|
|
228
|
+
|
|
229
|
+
if $JSON_MODE; then
|
|
230
|
+
ISSUES+=("{\"severity\":\"$severity\",\"category\":\"$category\",\"message\":\"$message\",\"file\":\"$file\",\"line\":\"$line\"}")
|
|
231
|
+
else
|
|
232
|
+
local icon="ℹ️"
|
|
233
|
+
case "$severity" in
|
|
234
|
+
error) icon="❌" ;;
|
|
235
|
+
warning) icon="⚠️" ;;
|
|
236
|
+
esac
|
|
237
|
+
|
|
238
|
+
if [[ -n "$file" ]]; then
|
|
239
|
+
if [[ -n "$line" ]]; then
|
|
240
|
+
echo "$icon [$severity] $category: $message ($file:$line)" >&2
|
|
241
|
+
else
|
|
242
|
+
echo "$icon [$severity] $category: $message ($file)" >&2
|
|
243
|
+
fi
|
|
244
|
+
else
|
|
245
|
+
echo "$icon [$severity] $category: $message" >&2
|
|
246
|
+
fi
|
|
247
|
+
|
|
248
|
+
if $VERBOSE; then
|
|
249
|
+
case "$category" in
|
|
250
|
+
"NO_PARTIAL_IMPLEMENTATION")
|
|
251
|
+
echo " → Constitution: 质量至上 - 禁止部分实现和占位符" >&2
|
|
252
|
+
;;
|
|
253
|
+
"NO_HARDCODED_SECRETS")
|
|
254
|
+
echo " → Constitution: 安全优先 - 禁止硬编码敏感信息" >&2
|
|
255
|
+
;;
|
|
256
|
+
"NO_CODE_DUPLICATION")
|
|
257
|
+
echo " → Constitution: 架构一致性 - 必须复用现有代码" >&2
|
|
258
|
+
;;
|
|
259
|
+
"NO_RESOURCE_LEAKS")
|
|
260
|
+
echo " → Constitution: 性能责任 - 资源必须正确释放" >&2
|
|
261
|
+
;;
|
|
262
|
+
"NO_DEAD_CODE")
|
|
263
|
+
echo " → Constitution: 可维护性 - 删除未使用的代码" >&2
|
|
264
|
+
;;
|
|
265
|
+
"FILE_SIZE_LIMIT")
|
|
266
|
+
echo " → Constitution: 可维护性 - 单文件不超过500行" >&2
|
|
267
|
+
;;
|
|
268
|
+
esac
|
|
269
|
+
fi
|
|
270
|
+
fi
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
# Validate source code files
|
|
274
|
+
validate_code() {
|
|
275
|
+
local target="$1"
|
|
276
|
+
|
|
277
|
+
if ! $JSON_MODE; then
|
|
278
|
+
echo "Validating source code against Constitution..." >&2
|
|
279
|
+
fi
|
|
280
|
+
|
|
281
|
+
# Find source files
|
|
282
|
+
local files=()
|
|
283
|
+
if [[ -f "$target" ]]; then
|
|
284
|
+
files=("$target")
|
|
285
|
+
elif [[ -d "$target" ]]; then
|
|
286
|
+
while IFS= read -r file; do
|
|
287
|
+
files+=("$file")
|
|
288
|
+
done < <(find "$target" -type f \( -name "*.ts" -o -name "*.js" -o -name "*.py" -o -name "*.sh" \) 2>/dev/null || true)
|
|
289
|
+
else
|
|
290
|
+
# Default to src/ if exists
|
|
291
|
+
if [[ -d "$REPO_ROOT/src" ]]; then
|
|
292
|
+
while IFS= read -r file; do
|
|
293
|
+
files+=("$file")
|
|
294
|
+
done < <(find "$REPO_ROOT/src" -type f \( -name "*.ts" -o -name "*.js" -o -name "*.py" \) 2>/dev/null || true)
|
|
295
|
+
fi
|
|
296
|
+
fi
|
|
297
|
+
|
|
298
|
+
# Validate each file
|
|
299
|
+
for file in "${files[@]}"; do
|
|
300
|
+
[[ ! -f "$file" ]] && continue
|
|
301
|
+
|
|
302
|
+
# Check file size (500 lines limit)
|
|
303
|
+
local line_count=$(wc -l < "$file" 2>/dev/null || echo "0")
|
|
304
|
+
if [[ "$line_count" -gt 500 ]]; then
|
|
305
|
+
add_issue "warning" "FILE_SIZE_LIMIT" "File exceeds 500 lines ($line_count lines)" "$file"
|
|
306
|
+
fi
|
|
307
|
+
|
|
308
|
+
# Check for partial implementation markers
|
|
309
|
+
if grep -qE "(TODO|FIXME|XXX|HACK|placeholder|to be implemented|coming soon|not implemented)" "$file" 2>/dev/null; then
|
|
310
|
+
local line=$(grep -nE "(TODO|FIXME|XXX|HACK|placeholder|to be implemented|coming soon|not implemented)" "$file" 2>/dev/null | head -1 | cut -d: -f1)
|
|
311
|
+
add_issue "error" "NO_PARTIAL_IMPLEMENTATION" "Partial implementation or placeholder detected" "$file" "$line"
|
|
312
|
+
fi
|
|
313
|
+
|
|
314
|
+
# Check for hardcoded secrets
|
|
315
|
+
if grep -qE "(password|secret|api_key|token|private_key)\s*=\s*['\"][^'\"]+['\"]" "$file" 2>/dev/null; then
|
|
316
|
+
local line=$(grep -nE "(password|secret|api_key|token|private_key)\s*=\s*['\"][^'\"]+['\"]" "$file" 2>/dev/null | head -1 | cut -d: -f1)
|
|
317
|
+
add_issue "error" "NO_HARDCODED_SECRETS" "Potential hardcoded secret detected" "$file" "$line"
|
|
318
|
+
fi
|
|
319
|
+
|
|
320
|
+
# Check for resource leaks (unclosed connections, file handles)
|
|
321
|
+
if grep -qE "(open\(|connect\(|new.*Connection)" "$file" 2>/dev/null; then
|
|
322
|
+
if ! grep -qE "(close\(|disconnect\(|finally|with )" "$file" 2>/dev/null; then
|
|
323
|
+
add_issue "warning" "NO_RESOURCE_LEAKS" "Potential resource leak - no cleanup detected" "$file"
|
|
324
|
+
fi
|
|
325
|
+
fi
|
|
326
|
+
|
|
327
|
+
# Check for commented-out code (dead code)
|
|
328
|
+
local commented_lines
|
|
329
|
+
commented_lines=$(grep -cE "^\s*(#|//)\s*(def |function |class |const |let |var )" "$file" 2>/dev/null || true)
|
|
330
|
+
commented_lines=${commented_lines:-0}
|
|
331
|
+
if [[ "$commented_lines" -gt 3 ]]; then
|
|
332
|
+
add_issue "warning" "NO_DEAD_CODE" "Excessive commented-out code detected ($commented_lines lines)" "$file"
|
|
333
|
+
fi
|
|
334
|
+
done
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
# Validate documentation completeness
|
|
338
|
+
validate_docs() {
|
|
339
|
+
if ! $JSON_MODE; then
|
|
340
|
+
echo "Validating documentation completeness..." >&2
|
|
341
|
+
fi
|
|
342
|
+
|
|
343
|
+
# Get requirement paths
|
|
344
|
+
eval $(get_requirement_paths)
|
|
345
|
+
|
|
346
|
+
if [[ -z "$REQ_ID" ]]; then
|
|
347
|
+
add_issue "info" "DOCS" "No active requirement found, skipping documentation validation"
|
|
348
|
+
return
|
|
349
|
+
fi
|
|
350
|
+
|
|
351
|
+
# Check required documents
|
|
352
|
+
local required_docs=("PRD.md" "EPIC.md" "TASKS.md")
|
|
353
|
+
for doc in "${required_docs[@]}"; do
|
|
354
|
+
if [[ ! -f "$REQ_DIR/$doc" ]]; then
|
|
355
|
+
add_issue "warning" "DOCS" "Missing required document: $doc" "$REQ_DIR"
|
|
356
|
+
fi
|
|
357
|
+
done
|
|
358
|
+
|
|
359
|
+
# Check README.md
|
|
360
|
+
if [[ ! -f "$REQ_DIR/README.md" ]]; then
|
|
361
|
+
add_issue "info" "DOCS" "Missing README.md" "$REQ_DIR"
|
|
362
|
+
fi
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
# Validate PRD Constitution checklist
|
|
366
|
+
validate_prd() {
|
|
367
|
+
if ! $JSON_MODE; then
|
|
368
|
+
echo "Validating PRD Constitution compliance..." >&2
|
|
369
|
+
fi
|
|
370
|
+
|
|
371
|
+
eval $(get_requirement_paths)
|
|
372
|
+
|
|
373
|
+
if [[ ! -f "$PRD_FILE" ]]; then
|
|
374
|
+
add_issue "error" "PRD" "PRD.md not found" "$PRD_FILE"
|
|
375
|
+
return
|
|
376
|
+
fi
|
|
377
|
+
|
|
378
|
+
# Check for Constitution Check section
|
|
379
|
+
if ! grep -q "## Constitution Check" "$PRD_FILE" 2>/dev/null; then
|
|
380
|
+
add_issue "error" "PRD" "Missing Constitution Check section" "$PRD_FILE"
|
|
381
|
+
fi
|
|
382
|
+
|
|
383
|
+
# Check NO PARTIAL IMPLEMENTATION checkbox
|
|
384
|
+
if ! grep -q "NO PARTIAL IMPLEMENTATION" "$PRD_FILE" 2>/dev/null; then
|
|
385
|
+
add_issue "error" "PRD" "Missing NO PARTIAL IMPLEMENTATION check" "$PRD_FILE"
|
|
386
|
+
fi
|
|
387
|
+
|
|
388
|
+
# Check NO HARDCODED SECRETS checkbox
|
|
389
|
+
if ! grep -q "NO HARDCODED SECRETS" "$PRD_FILE" 2>/dev/null; then
|
|
390
|
+
add_issue "error" "PRD" "Missing NO HARDCODED SECRETS check" "$PRD_FILE"
|
|
391
|
+
fi
|
|
392
|
+
|
|
393
|
+
# Check INVEST criteria for user stories
|
|
394
|
+
if ! grep -q "INVEST" "$PRD_FILE" 2>/dev/null; then
|
|
395
|
+
add_issue "warning" "PRD" "No mention of INVEST criteria for user stories" "$PRD_FILE"
|
|
396
|
+
fi
|
|
397
|
+
|
|
398
|
+
# Check for placeholders
|
|
399
|
+
local placeholder_count
|
|
400
|
+
placeholder_count=$(grep -c "{{.*}}" "$PRD_FILE" 2>/dev/null || true)
|
|
401
|
+
placeholder_count=${placeholder_count:-0}
|
|
402
|
+
if [[ "$placeholder_count" -gt 0 ]]; then
|
|
403
|
+
add_issue "error" "PRD" "Unfilled placeholders detected ($placeholder_count)" "$PRD_FILE"
|
|
404
|
+
fi
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
# Validate Epic Constitution checklist
|
|
408
|
+
validate_epic() {
|
|
409
|
+
if ! $JSON_MODE; then
|
|
410
|
+
echo "Validating Epic Constitution compliance..." >&2
|
|
411
|
+
fi
|
|
412
|
+
|
|
413
|
+
eval $(get_requirement_paths)
|
|
414
|
+
|
|
415
|
+
if [[ ! -f "$EPIC_FILE" ]]; then
|
|
416
|
+
add_issue "warning" "EPIC" "EPIC.md not found" "$EPIC_FILE"
|
|
417
|
+
return
|
|
418
|
+
fi
|
|
419
|
+
|
|
420
|
+
# Check for Constitution Check section
|
|
421
|
+
if ! grep -q "## Constitution Check" "$EPIC_FILE" 2>/dev/null; then
|
|
422
|
+
add_issue "error" "EPIC" "Missing Constitution Check section" "$EPIC_FILE"
|
|
423
|
+
fi
|
|
424
|
+
|
|
425
|
+
# Check for TDD phases
|
|
426
|
+
if ! grep -q "Phase 2.*Tests First" "$EPIC_FILE" 2>/dev/null; then
|
|
427
|
+
add_issue "error" "EPIC" "Missing TDD Phase 2 (Tests First)" "$EPIC_FILE"
|
|
428
|
+
fi
|
|
429
|
+
|
|
430
|
+
# Check for TEST VERIFICATION CHECKPOINT
|
|
431
|
+
if ! grep -q "TEST VERIFICATION CHECKPOINT" "$EPIC_FILE" 2>/dev/null; then
|
|
432
|
+
add_issue "error" "EPIC" "Missing TEST VERIFICATION CHECKPOINT" "$EPIC_FILE"
|
|
433
|
+
fi
|
|
434
|
+
|
|
435
|
+
# Check for placeholders
|
|
436
|
+
local placeholder_count
|
|
437
|
+
placeholder_count=$(grep -c "{{.*}}" "$EPIC_FILE" 2>/dev/null || true)
|
|
438
|
+
placeholder_count=${placeholder_count:-0}
|
|
439
|
+
if [[ "$placeholder_count" -gt 0 ]]; then
|
|
440
|
+
add_issue "warning" "EPIC" "Unfilled placeholders detected ($placeholder_count)" "$EPIC_FILE"
|
|
441
|
+
fi
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
# Validate Tasks TDD compliance
|
|
445
|
+
validate_tasks() {
|
|
446
|
+
if ! $JSON_MODE; then
|
|
447
|
+
echo "Validating Tasks TDD compliance..." >&2
|
|
448
|
+
fi
|
|
449
|
+
|
|
450
|
+
eval $(get_requirement_paths)
|
|
451
|
+
local tasks_file="$REQ_DIR/TASKS.md"
|
|
452
|
+
|
|
453
|
+
if [[ ! -f "$tasks_file" ]]; then
|
|
454
|
+
add_issue "warning" "TASKS" "TASKS.md not found" "$tasks_file"
|
|
455
|
+
return
|
|
456
|
+
fi
|
|
457
|
+
|
|
458
|
+
# Check for Phase 2: Tests First
|
|
459
|
+
if ! grep -q "## Phase 2.*Tests First" "$tasks_file" 2>/dev/null; then
|
|
460
|
+
add_issue "error" "TASKS" "Missing Phase 2: Tests First" "$tasks_file"
|
|
461
|
+
fi
|
|
462
|
+
|
|
463
|
+
# Check for TEST VERIFICATION CHECKPOINT
|
|
464
|
+
if ! grep -q "TEST VERIFICATION CHECKPOINT" "$tasks_file" 2>/dev/null; then
|
|
465
|
+
add_issue "error" "TASKS" "Missing TEST VERIFICATION CHECKPOINT" "$tasks_file"
|
|
466
|
+
fi
|
|
467
|
+
|
|
468
|
+
# Check that Phase 2 comes before Phase 3
|
|
469
|
+
local phase2_line=$(grep -n "## Phase 2" "$tasks_file" 2>/dev/null | cut -d: -f1 | head -1)
|
|
470
|
+
local phase3_line=$(grep -n "## Phase 3" "$tasks_file" 2>/dev/null | cut -d: -f1 | head -1)
|
|
471
|
+
|
|
472
|
+
if [[ -n "$phase2_line" && -n "$phase3_line" && "$phase2_line" -gt "$phase3_line" ]]; then
|
|
473
|
+
add_issue "error" "TASKS" "Phase 2 must come before Phase 3 (TDD violation)" "$tasks_file"
|
|
474
|
+
fi
|
|
475
|
+
|
|
476
|
+
# Check for Constitution Check section
|
|
477
|
+
if ! grep -q "Constitution Check" "$tasks_file" 2>/dev/null; then
|
|
478
|
+
add_issue "warning" "TASKS" "Missing Constitution Check section" "$tasks_file"
|
|
479
|
+
fi
|
|
480
|
+
|
|
481
|
+
# Check for Dependencies section
|
|
482
|
+
if ! grep -q "## Dependencies" "$tasks_file" 2>/dev/null; then
|
|
483
|
+
add_issue "info" "TASKS" "Missing Dependencies section" "$tasks_file"
|
|
484
|
+
fi
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
# Main validation logic
|
|
488
|
+
main() {
|
|
489
|
+
# Determine target
|
|
490
|
+
if [[ -z "$TARGET" ]]; then
|
|
491
|
+
# No target specified, use current requirement
|
|
492
|
+
eval $(get_requirement_paths)
|
|
493
|
+
if [[ -n "$REQ_ID" ]]; then
|
|
494
|
+
TARGET="$REQ_DIR"
|
|
495
|
+
else
|
|
496
|
+
TARGET="$REPO_ROOT"
|
|
497
|
+
fi
|
|
498
|
+
elif [[ "$TARGET" =~ ^(REQ|BUG)-[0-9]+$ ]]; then
|
|
499
|
+
# Target is a requirement ID
|
|
500
|
+
TARGET=$(get_req_dir "$REPO_ROOT" "$TARGET")
|
|
501
|
+
fi
|
|
502
|
+
|
|
503
|
+
# Run validations based on type
|
|
504
|
+
case "$VALIDATION_TYPE" in
|
|
505
|
+
code)
|
|
506
|
+
validate_code "$TARGET"
|
|
507
|
+
;;
|
|
508
|
+
docs)
|
|
509
|
+
validate_docs
|
|
510
|
+
;;
|
|
511
|
+
prd)
|
|
512
|
+
validate_prd
|
|
513
|
+
;;
|
|
514
|
+
epic)
|
|
515
|
+
validate_epic
|
|
516
|
+
;;
|
|
517
|
+
tasks)
|
|
518
|
+
validate_tasks
|
|
519
|
+
;;
|
|
520
|
+
all)
|
|
521
|
+
validate_code "$TARGET"
|
|
522
|
+
validate_docs
|
|
523
|
+
validate_prd
|
|
524
|
+
validate_epic
|
|
525
|
+
validate_tasks
|
|
526
|
+
;;
|
|
527
|
+
esac
|
|
528
|
+
|
|
529
|
+
# Output results
|
|
530
|
+
if $JSON_MODE; then
|
|
531
|
+
local issues_json=$(printf '%s,' "${ISSUES[@]}" | sed 's/,$//')
|
|
532
|
+
printf '{"%s":%d,"%s":%d,"%s":%d,"%s":%d,"%s":[%s]}\n' \
|
|
533
|
+
"total_issues" "$TOTAL_ISSUES" \
|
|
534
|
+
"errors" "$ERROR_COUNT" \
|
|
535
|
+
"warnings" "$WARNING_COUNT" \
|
|
536
|
+
"info" "$INFO_COUNT" \
|
|
537
|
+
"issues" "$issues_json"
|
|
538
|
+
else
|
|
539
|
+
echo "" >&2
|
|
540
|
+
echo "════════════════════════════════════════" >&2
|
|
541
|
+
echo "Constitution Validation Summary" >&2
|
|
542
|
+
echo "════════════════════════════════════════" >&2
|
|
543
|
+
echo "Total Issues: $TOTAL_ISSUES" >&2
|
|
544
|
+
echo " Errors: $ERROR_COUNT" >&2
|
|
545
|
+
echo " Warnings: $WARNING_COUNT" >&2
|
|
546
|
+
echo " Info: $INFO_COUNT" >&2
|
|
547
|
+
echo "" >&2
|
|
548
|
+
|
|
549
|
+
if [[ "$ERROR_COUNT" -eq 0 && "$WARNING_COUNT" -eq 0 ]]; then
|
|
550
|
+
echo "✅ All Constitution validations passed!" >&2
|
|
551
|
+
elif [[ "$ERROR_COUNT" -eq 0 ]]; then
|
|
552
|
+
echo "⚠️ Validation completed with warnings" >&2
|
|
553
|
+
else
|
|
554
|
+
echo "❌ Validation failed with errors" >&2
|
|
555
|
+
fi
|
|
556
|
+
fi
|
|
557
|
+
|
|
558
|
+
# Exit code
|
|
559
|
+
if [[ "$ERROR_COUNT" -gt 0 ]]; then
|
|
560
|
+
exit 1
|
|
561
|
+
else
|
|
562
|
+
exit 0
|
|
563
|
+
fi
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
# Run main
|
|
567
|
+
main
|