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,332 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# validate-research.sh - Research.md 质量验证脚本
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# Purpose: 验证 research.md 是否符合 spec-kit Decision/Rationale/Alternatives 格式
|
|
6
|
+
# 确保无 TODO 占位符、无空章节、格式完整
|
|
7
|
+
#
|
|
8
|
+
# Usage:
|
|
9
|
+
# validate-research.sh <REQ_DIR> [--strict]
|
|
10
|
+
#
|
|
11
|
+
# Exit Codes:
|
|
12
|
+
# 0 - 验证通过
|
|
13
|
+
# 1 - 验证失败(输出具体错误)
|
|
14
|
+
#
|
|
15
|
+
# Constitution Compliance:
|
|
16
|
+
# - Article X.1 (Forced Clarification): 检查 NEEDS CLARIFICATION 标记
|
|
17
|
+
# - Article X.2 (No Speculation): 禁止推测性技术细节
|
|
18
|
+
# - Article I.1 (Complete Implementation): 禁止 TODO/PLACEHOLDER
|
|
19
|
+
# =============================================================================
|
|
20
|
+
|
|
21
|
+
set -euo pipefail
|
|
22
|
+
|
|
23
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
24
|
+
# Configuration
|
|
25
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
28
|
+
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
29
|
+
|
|
30
|
+
# shellcheck source=.claude/scripts/common.sh
|
|
31
|
+
source "$SCRIPT_DIR/common.sh"
|
|
32
|
+
|
|
33
|
+
STRICT_MODE=false
|
|
34
|
+
|
|
35
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
36
|
+
# Usage
|
|
37
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
usage() {
|
|
40
|
+
cat <<'USAGE'
|
|
41
|
+
Usage: validate-research.sh <REQ_DIR> [--strict]
|
|
42
|
+
|
|
43
|
+
Validates research.md quality and structure:
|
|
44
|
+
- Checks for mandatory sections (Research Summary, Decisions, etc.)
|
|
45
|
+
- Validates Decision/Rationale/Alternatives blocks
|
|
46
|
+
- Detects TODO placeholders and empty content
|
|
47
|
+
- Verifies NEEDS CLARIFICATION markers
|
|
48
|
+
|
|
49
|
+
Arguments:
|
|
50
|
+
REQ_DIR Path to requirement directory (e.g., devflow/requirements/REQ-123)
|
|
51
|
+
--strict Exit with code 1 if any validation fails (default: warnings only)
|
|
52
|
+
|
|
53
|
+
Examples:
|
|
54
|
+
validate-research.sh devflow/requirements/REQ-123
|
|
55
|
+
validate-research.sh devflow/requirements/REQ-123 --strict
|
|
56
|
+
USAGE
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
60
|
+
# Argument Parsing
|
|
61
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
if [[ $# -lt 1 ]] || [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]]; then
|
|
64
|
+
usage
|
|
65
|
+
exit 0
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
REQ_DIR="$1"
|
|
69
|
+
shift
|
|
70
|
+
|
|
71
|
+
while [[ $# -gt 0 ]]; do
|
|
72
|
+
case "$1" in
|
|
73
|
+
--strict)
|
|
74
|
+
STRICT_MODE=true
|
|
75
|
+
shift
|
|
76
|
+
;;
|
|
77
|
+
*)
|
|
78
|
+
echo "❌ Unknown option: $1" >&2
|
|
79
|
+
usage
|
|
80
|
+
exit 1
|
|
81
|
+
;;
|
|
82
|
+
esac
|
|
83
|
+
done
|
|
84
|
+
|
|
85
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
86
|
+
# Validation Functions
|
|
87
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
88
|
+
|
|
89
|
+
validate_file_exists() {
|
|
90
|
+
local research_md="$REQ_DIR/research/research.md"
|
|
91
|
+
|
|
92
|
+
if [[ ! -f "$research_md" ]]; then
|
|
93
|
+
echo "❌ LEVEL 1 FAILED: research.md not found at $research_md"
|
|
94
|
+
return 1
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
echo "✅ LEVEL 1 PASSED: research.md exists"
|
|
98
|
+
return 0
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
validate_structure() {
|
|
102
|
+
local research_md="$REQ_DIR/research/research.md"
|
|
103
|
+
local errors=0
|
|
104
|
+
|
|
105
|
+
echo "🔍 LEVEL 2: Validating structure..."
|
|
106
|
+
|
|
107
|
+
# 必需章节检查
|
|
108
|
+
local required_sections=(
|
|
109
|
+
"Research Summary"
|
|
110
|
+
"Decisions"
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
for section in "${required_sections[@]}"; do
|
|
114
|
+
if ! grep -qE "^##\s+$section" "$research_md"; then
|
|
115
|
+
echo " ❌ Missing section: ## $section"
|
|
116
|
+
((errors++))
|
|
117
|
+
else
|
|
118
|
+
echo " ✅ Found section: ## $section"
|
|
119
|
+
fi
|
|
120
|
+
done
|
|
121
|
+
|
|
122
|
+
# 检查至少有一个 Decision block
|
|
123
|
+
if ! grep -qE "^###\s+R[0-9]+" "$research_md"; then
|
|
124
|
+
echo " ❌ No Decision blocks found (expected ### R001, R002, etc.)"
|
|
125
|
+
((errors++))
|
|
126
|
+
else
|
|
127
|
+
local decision_count
|
|
128
|
+
decision_count=$(grep -cE "^###\s+R[0-9]+" "$research_md" || echo 0)
|
|
129
|
+
echo " ✅ Found $decision_count Decision block(s)"
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
if [[ $errors -eq 0 ]]; then
|
|
133
|
+
echo "✅ LEVEL 2 PASSED: Structure valid"
|
|
134
|
+
return 0
|
|
135
|
+
else
|
|
136
|
+
echo "❌ LEVEL 2 FAILED: $errors structure error(s)"
|
|
137
|
+
return 1
|
|
138
|
+
fi
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
validate_content_quality() {
|
|
142
|
+
local research_md="$REQ_DIR/research/research.md"
|
|
143
|
+
local errors=0
|
|
144
|
+
|
|
145
|
+
echo "🔍 LEVEL 3: Validating content quality..."
|
|
146
|
+
|
|
147
|
+
# 检查 TODO 占位符
|
|
148
|
+
local todo_count
|
|
149
|
+
todo_count=$(grep -ciE "TODO|FIXME|XXX|PLACEHOLDER" "$research_md" 2>/dev/null || echo "0")
|
|
150
|
+
todo_count=$(echo "$todo_count" | head -1) # 只取第一行
|
|
151
|
+
if [[ $todo_count -gt 0 ]]; then
|
|
152
|
+
echo " ❌ Found $todo_count TODO/PLACEHOLDER marker(s):"
|
|
153
|
+
grep -niE "TODO|FIXME|XXX|PLACEHOLDER" "$research_md" | head -5 | while IFS= read -r line; do
|
|
154
|
+
echo " $line"
|
|
155
|
+
done
|
|
156
|
+
((errors++))
|
|
157
|
+
else
|
|
158
|
+
echo " ✅ No TODO/PLACEHOLDER markers"
|
|
159
|
+
fi
|
|
160
|
+
|
|
161
|
+
# 检查 {{PLACEHOLDER}} 格式
|
|
162
|
+
local placeholder_count
|
|
163
|
+
placeholder_count=$(grep -coE '\{\{[^}]+\}\}' "$research_md" 2>/dev/null || echo "0")
|
|
164
|
+
placeholder_count=$(echo "$placeholder_count" | head -1) # 只取第一行
|
|
165
|
+
if [[ $placeholder_count -gt 0 ]]; then
|
|
166
|
+
echo " ❌ Found $placeholder_count {{PLACEHOLDER}} marker(s)"
|
|
167
|
+
grep -nE '\{\{[^}]+\}\}' "$research_md" | head -5 | while IFS= read -r line; do
|
|
168
|
+
echo " $line"
|
|
169
|
+
done
|
|
170
|
+
((errors++))
|
|
171
|
+
else
|
|
172
|
+
echo " ✅ No {{PLACEHOLDER}} markers"
|
|
173
|
+
fi
|
|
174
|
+
|
|
175
|
+
# 检查 Decision/Rationale/Alternatives 完整性
|
|
176
|
+
local decision_blocks
|
|
177
|
+
decision_blocks=$(grep -cE "^###\s+R[0-9]+" "$research_md" 2>/dev/null || echo "0")
|
|
178
|
+
decision_blocks=$(echo "$decision_blocks" | head -1) # 只取第一行
|
|
179
|
+
|
|
180
|
+
if [[ $decision_blocks -gt 0 ]]; then
|
|
181
|
+
echo " 🔍 Checking $decision_blocks Decision block(s)..."
|
|
182
|
+
|
|
183
|
+
local incomplete_blocks=0
|
|
184
|
+
while IFS= read -r block_line; do
|
|
185
|
+
local block_num
|
|
186
|
+
block_num=$(echo "$block_line" | grep -oE "R[0-9]+")
|
|
187
|
+
|
|
188
|
+
# 检查该 block 是否有 Decision/Rationale/Alternatives
|
|
189
|
+
local has_decision has_rationale has_alternatives
|
|
190
|
+
has_decision=$(grep -cE "^- Decision:|^- \*\*Decision\*\*:" "$research_md" 2>/dev/null || echo "0")
|
|
191
|
+
has_decision=$(echo "$has_decision" | head -1)
|
|
192
|
+
has_rationale=$(grep -cE "^- Rationale:|^- \*\*Rationale\*\*:" "$research_md" 2>/dev/null || echo "0")
|
|
193
|
+
has_rationale=$(echo "$has_rationale" | head -1)
|
|
194
|
+
has_alternatives=$(grep -cE "^- Alternatives considered:|^- \*\*Alternatives Considered\*\*:" "$research_md" 2>/dev/null || echo "0")
|
|
195
|
+
has_alternatives=$(echo "$has_alternatives" | head -1)
|
|
196
|
+
|
|
197
|
+
if [[ $has_decision -eq 0 ]] || [[ $has_rationale -eq 0 ]] || [[ $has_alternatives -eq 0 ]]; then
|
|
198
|
+
echo " ❌ Block $block_num: incomplete (missing Decision/Rationale/Alternatives)"
|
|
199
|
+
((incomplete_blocks++))
|
|
200
|
+
fi
|
|
201
|
+
done < <(grep -nE "^###\s+R[0-9]+" "$research_md")
|
|
202
|
+
|
|
203
|
+
if [[ $incomplete_blocks -gt 0 ]]; then
|
|
204
|
+
echo " ❌ $incomplete_blocks block(s) incomplete"
|
|
205
|
+
((errors++))
|
|
206
|
+
else
|
|
207
|
+
echo " ✅ All Decision blocks complete"
|
|
208
|
+
fi
|
|
209
|
+
fi
|
|
210
|
+
|
|
211
|
+
# 检查空章节
|
|
212
|
+
if grep -qE "^##.*\n\n_No research" "$research_md"; then
|
|
213
|
+
echo " ⚠️ Found empty sections (acceptable if research not started)"
|
|
214
|
+
fi
|
|
215
|
+
|
|
216
|
+
if [[ $errors -eq 0 ]]; then
|
|
217
|
+
echo "✅ LEVEL 3 PASSED: Content quality valid"
|
|
218
|
+
return 0
|
|
219
|
+
else
|
|
220
|
+
echo "❌ LEVEL 3 FAILED: $errors content error(s)"
|
|
221
|
+
return 1
|
|
222
|
+
fi
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
validate_constitution() {
|
|
226
|
+
local research_md="$REQ_DIR/research/research.md"
|
|
227
|
+
local errors=0
|
|
228
|
+
|
|
229
|
+
echo "🔍 LEVEL 4: Constitution compliance check..."
|
|
230
|
+
|
|
231
|
+
# Article X.1 (Forced Clarification)
|
|
232
|
+
local needs_clarification_count
|
|
233
|
+
needs_clarification_count=$(grep -ciE "NEEDS CLARIFICATION" "$research_md" 2>/dev/null || echo "0")
|
|
234
|
+
needs_clarification_count=$(echo "$needs_clarification_count" | head -1) # 只取第一行
|
|
235
|
+
if [[ $needs_clarification_count -gt 0 ]]; then
|
|
236
|
+
echo " ✅ Article X.1: Found $needs_clarification_count NEEDS CLARIFICATION marker(s)"
|
|
237
|
+
else
|
|
238
|
+
echo " ℹ️ Article X.1: No unresolved questions (acceptable if research complete)"
|
|
239
|
+
fi
|
|
240
|
+
|
|
241
|
+
# Article X.2 (No Speculation) - 检查推测性语言
|
|
242
|
+
local speculation_patterns=(
|
|
243
|
+
"might|maybe|probably|possibly|perhaps"
|
|
244
|
+
"could be|should be|would be"
|
|
245
|
+
"in the future|future-proof|预留|扩展性"
|
|
246
|
+
)
|
|
247
|
+
|
|
248
|
+
for pattern in "${speculation_patterns[@]}"; do
|
|
249
|
+
if grep -qiE "$pattern" "$research_md"; then
|
|
250
|
+
echo " ⚠️ Article X.2: Found speculative language: '$pattern'"
|
|
251
|
+
echo " (Review context - acceptable if explaining rationale)"
|
|
252
|
+
fi
|
|
253
|
+
done
|
|
254
|
+
|
|
255
|
+
# Article I.1 (Complete Implementation)
|
|
256
|
+
if grep -qiE "暂时|临时|简化版|simplified|temporary|partial" "$research_md"; then
|
|
257
|
+
echo " ❌ Article I.1: Found partial implementation language"
|
|
258
|
+
((errors++))
|
|
259
|
+
else
|
|
260
|
+
echo " ✅ Article I.1: No partial implementation markers"
|
|
261
|
+
fi
|
|
262
|
+
|
|
263
|
+
if [[ $errors -eq 0 ]]; then
|
|
264
|
+
echo "✅ LEVEL 4 PASSED: Constitution compliant"
|
|
265
|
+
return 0
|
|
266
|
+
else
|
|
267
|
+
echo "❌ LEVEL 4 FAILED: $errors constitution violation(s)"
|
|
268
|
+
return 1
|
|
269
|
+
fi
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
273
|
+
# Main Execution
|
|
274
|
+
# ────────────────────────────────────────────────────────────────────────────
|
|
275
|
+
|
|
276
|
+
main() {
|
|
277
|
+
echo "════════════════════════════════════════════════════════════════════════"
|
|
278
|
+
echo "Research.md Quality Validation"
|
|
279
|
+
echo "════════════════════════════════════════════════════════════════════════"
|
|
280
|
+
echo "REQ_DIR: $REQ_DIR"
|
|
281
|
+
echo "MODE: $(if $STRICT_MODE; then echo "STRICT (fail on errors)"; else echo "LENIENT (warnings only)"; fi)"
|
|
282
|
+
echo ""
|
|
283
|
+
|
|
284
|
+
local total_errors=0
|
|
285
|
+
|
|
286
|
+
# Run all validation levels
|
|
287
|
+
validate_file_exists || ((total_errors++))
|
|
288
|
+
echo ""
|
|
289
|
+
|
|
290
|
+
validate_structure || ((total_errors++))
|
|
291
|
+
echo ""
|
|
292
|
+
|
|
293
|
+
validate_content_quality || ((total_errors++))
|
|
294
|
+
echo ""
|
|
295
|
+
|
|
296
|
+
validate_constitution || ((total_errors++))
|
|
297
|
+
echo ""
|
|
298
|
+
|
|
299
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
300
|
+
# Final Report
|
|
301
|
+
# ──────────────────────────────────────────────────────────────────────────
|
|
302
|
+
|
|
303
|
+
echo "════════════════════════════════════════════════════════════════════════"
|
|
304
|
+
if [[ $total_errors -eq 0 ]]; then
|
|
305
|
+
echo "✅ ALL VALIDATIONS PASSED"
|
|
306
|
+
echo "research.md is ready for /flow-prd"
|
|
307
|
+
echo "════════════════════════════════════════════════════════════════════════"
|
|
308
|
+
return 0
|
|
309
|
+
else
|
|
310
|
+
echo "❌ VALIDATION FAILED: $total_errors level(s) failed"
|
|
311
|
+
echo ""
|
|
312
|
+
echo "Next Steps:"
|
|
313
|
+
echo " 1. Review errors above"
|
|
314
|
+
echo " 2. Update research.md to fix issues"
|
|
315
|
+
echo " 3. Re-run: validate-research.sh $REQ_DIR"
|
|
316
|
+
echo ""
|
|
317
|
+
echo "Common Fixes:"
|
|
318
|
+
echo " - Remove TODO markers → Fill with actual decisions"
|
|
319
|
+
echo " - Add missing sections → Use RESEARCH_TEMPLATE.md"
|
|
320
|
+
echo " - Complete Decision blocks → Add Rationale + Alternatives"
|
|
321
|
+
echo "════════════════════════════════════════════════════════════════════════"
|
|
322
|
+
|
|
323
|
+
if $STRICT_MODE; then
|
|
324
|
+
return 1
|
|
325
|
+
else
|
|
326
|
+
echo "⚠️ Running in LENIENT mode - returning success despite errors"
|
|
327
|
+
return 0
|
|
328
|
+
fi
|
|
329
|
+
fi
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
main
|