dev-playbooks 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.
- package/LICENSE +21 -0
- package/README.md +463 -0
- package/bin/devbooks.js +986 -0
- package/package.json +41 -0
- package/skills/Skill-Development-Guide.md +249 -0
- package/skills/Skills-Usage-Guide.md +447 -0
- package/skills/_shared/context-detection-template.md +315 -0
- package/skills/_shared/mcp-enhancement-template.md +144 -0
- package/skills/_shared/references/universal-gating-protocol.md +114 -0
- package/skills/_template/config-discovery-template.md +126 -0
- package/skills/devbooks-brownfield-bootstrap/SKILL.md +168 -0
- package/skills/devbooks-brownfield-bootstrap/references/10-glossary-template.md +42 -0
- package/skills/devbooks-brownfield-bootstrap/references/brownfield-bootstrap-prompt.md +115 -0
- package/skills/devbooks-brownfield-bootstrap/references/brownfield-bootstrap.md +96 -0
- package/skills/devbooks-brownfield-bootstrap/references/code-navigation-strategy.md +203 -0
- package/skills/devbooks-brownfield-bootstrap/scripts/cod-update.sh +357 -0
- package/skills/devbooks-brownfield-bootstrap/templates/project-profile-template.md +172 -0
- package/skills/devbooks-c4-map/SKILL.md +151 -0
- package/skills/devbooks-c4-map/references/c4-architecture-map-prompt.md +33 -0
- package/skills/devbooks-c4-map/references/layered-constraint-checklist.md +185 -0
- package/skills/devbooks-code-review/SKILL.md +175 -0
- package/skills/devbooks-code-review/references/code-review-prompt.md +100 -0
- package/skills/devbooks-code-review/references/code-smell-cheatsheet.md +498 -0
- package/skills/devbooks-code-review/references/pr-template-and-guidelines.md +321 -0
- package/skills/devbooks-code-review/references/resource-management-review-checklist.md +311 -0
- package/skills/devbooks-coder/SKILL.md +219 -0
- package/skills/devbooks-coder/references/code-implementation-prompt.md +74 -0
- package/skills/devbooks-coder/references/coding-style-guidelines.md +351 -0
- package/skills/devbooks-coder/references/error-code-standard.md +463 -0
- package/skills/devbooks-coder/references/logging-standard.md +329 -0
- package/skills/devbooks-coder/references/low-risk-modification-techniques.md +275 -0
- package/skills/devbooks-delivery-workflow/SKILL.md +217 -0
- package/skills/devbooks-delivery-workflow/references/9-change-verification-traceability-template.md +133 -0
- package/skills/devbooks-delivery-workflow/references/delivery-acceptance-workflow.md +177 -0
- package/skills/devbooks-delivery-workflow/references/prototype-production-dual-track.md +169 -0
- package/skills/devbooks-delivery-workflow/scripts/ac-trace-check.sh +330 -0
- package/skills/devbooks-delivery-workflow/scripts/audit-scope.sh +262 -0
- package/skills/devbooks-delivery-workflow/scripts/change-check.sh +1039 -0
- package/skills/devbooks-delivery-workflow/scripts/change-codemod-scaffold.sh +135 -0
- package/skills/devbooks-delivery-workflow/scripts/change-evidence.sh +152 -0
- package/skills/devbooks-delivery-workflow/scripts/change-scaffold.sh +467 -0
- package/skills/devbooks-delivery-workflow/scripts/change-spec-delta-scaffold.sh +135 -0
- package/skills/devbooks-delivery-workflow/scripts/constitution-check.sh +237 -0
- package/skills/devbooks-delivery-workflow/scripts/env-match-check.sh +128 -0
- package/skills/devbooks-delivery-workflow/scripts/fitness-check.sh +365 -0
- package/skills/devbooks-delivery-workflow/scripts/guardrail-check.sh +516 -0
- package/skills/devbooks-delivery-workflow/scripts/handoff-check.sh +141 -0
- package/skills/devbooks-delivery-workflow/scripts/hygiene-check.sh +340 -0
- package/skills/devbooks-delivery-workflow/scripts/migrate-from-openspec.sh +385 -0
- package/skills/devbooks-delivery-workflow/scripts/migrate-to-v2-gates.sh +202 -0
- package/skills/devbooks-delivery-workflow/scripts/progress-dashboard.sh +319 -0
- package/skills/devbooks-delivery-workflow/scripts/prototype-promote.sh +341 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-preview.sh +203 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-promote.sh +118 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-rollback.sh +124 -0
- package/skills/devbooks-delivery-workflow/scripts/spec-stage.sh +117 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-all.sh +78 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-npm-package.sh +123 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-openspec-free.sh +81 -0
- package/skills/devbooks-delivery-workflow/scripts/verify-slash-commands.sh +146 -0
- package/skills/devbooks-delivery-workflow/templates/handoff.md +50 -0
- package/skills/devbooks-design-backport/SKILL.md +73 -0
- package/skills/devbooks-design-backport/references/design-backport-prompt.md +132 -0
- package/skills/devbooks-design-doc/SKILL.md +121 -0
- package/skills/devbooks-design-doc/references/design-doc-prompt.md +188 -0
- package/skills/devbooks-design-doc/references/microservice-design-checklist.md +149 -0
- package/skills/devbooks-design-doc/references/privacy-compliance-checklist.md +240 -0
- package/skills/devbooks-entropy-monitor/SKILL.md +188 -0
- package/skills/devbooks-entropy-monitor/references/entropy-metrics-methodology.md +218 -0
- package/skills/devbooks-entropy-monitor/scripts/entropy-measure.sh +449 -0
- package/skills/devbooks-entropy-monitor/scripts/entropy-report.sh +303 -0
- package/skills/devbooks-entropy-monitor/templates/thresholds.json +99 -0
- package/skills/devbooks-federation/SKILL.md +264 -0
- package/skills/devbooks-federation/scripts/federation-check.sh +144 -0
- package/skills/devbooks-federation/templates/federation.yaml +89 -0
- package/skills/devbooks-impact-analysis/SKILL.md +135 -0
- package/skills/devbooks-impact-analysis/references/impact-analysis-prompt.md +82 -0
- package/skills/devbooks-impact-analysis/scripts/graph-cache.sh +214 -0
- package/skills/devbooks-implementation-plan/SKILL.md +83 -0
- package/skills/devbooks-implementation-plan/references/implementation-plan-prompt.md +95 -0
- package/skills/devbooks-index-bootstrap/SKILL.md +240 -0
- package/skills/devbooks-proposal-author/SKILL.md +83 -0
- package/skills/devbooks-proposal-author/references/proposal-authoring-prompt.md +66 -0
- package/skills/devbooks-proposal-challenger/SKILL.md +86 -0
- package/skills/devbooks-proposal-challenger/references/ethics-and-compliance-checklist.md +176 -0
- package/skills/devbooks-proposal-challenger/references/proposal-challenge-prompt.md +57 -0
- package/skills/devbooks-proposal-debate-workflow/SKILL.md +78 -0
- package/skills/devbooks-proposal-debate-workflow/references/11-proposal-debate-template.md +35 -0
- package/skills/devbooks-proposal-debate-workflow/references/proposal-debate-workflow.md +24 -0
- package/skills/devbooks-proposal-debate-workflow/scripts/proposal-debate-check.sh +102 -0
- package/skills/devbooks-proposal-judge/SKILL.md +78 -0
- package/skills/devbooks-proposal-judge/references/proposal-judge-prompt.md +37 -0
- package/skills/devbooks-router/SKILL.md +346 -0
- package/skills/devbooks-spec-contract/SKILL.md +191 -0
- package/skills/devbooks-spec-contract/references/api-design-guide.md +349 -0
- package/skills/devbooks-spec-contract/references/contract-and-data-definition-prompt.md +85 -0
- package/skills/devbooks-spec-contract/references/implicit-change-detection-prompt.md +183 -0
- package/skills/devbooks-spec-contract/references/spec-change-prompt.md +63 -0
- package/skills/devbooks-spec-contract/scripts/implicit-change-detect.sh +378 -0
- package/skills/devbooks-spec-gardener/SKILL.md +73 -0
- package/skills/devbooks-spec-gardener/references/spec-gardener-prompt.md +41 -0
- package/skills/devbooks-test-owner/SKILL.md +173 -0
- package/skills/devbooks-test-owner/references/9-change-verification-traceability-template.md +133 -0
- package/skills/devbooks-test-owner/references/async-system-test-strategy.md +316 -0
- package/skills/devbooks-test-owner/references/decoupling-techniques-cheatsheet.md +269 -0
- package/skills/devbooks-test-owner/references/test-code-prompt.md +171 -0
- package/skills/devbooks-test-owner/references/test-driven-development.md +351 -0
- package/skills/devbooks-test-owner/references/test-layering-strategy.md +281 -0
- package/skills/devbooks-test-reviewer/SKILL.md +189 -0
- package/templates/.devbooks/config.yaml +88 -0
- package/templates/claude-commands/devbooks/apply.md +38 -0
- package/templates/claude-commands/devbooks/archive.md +33 -0
- package/templates/claude-commands/devbooks/backport.md +19 -0
- package/templates/claude-commands/devbooks/bootstrap.md +20 -0
- package/templates/claude-commands/devbooks/c4.md +20 -0
- package/templates/claude-commands/devbooks/challenger.md +19 -0
- package/templates/claude-commands/devbooks/code.md +20 -0
- package/templates/claude-commands/devbooks/debate.md +20 -0
- package/templates/claude-commands/devbooks/delivery.md +20 -0
- package/templates/claude-commands/devbooks/design.md +20 -0
- package/templates/claude-commands/devbooks/entropy.md +19 -0
- package/templates/claude-commands/devbooks/federation.md +19 -0
- package/templates/claude-commands/devbooks/gardener.md +19 -0
- package/templates/claude-commands/devbooks/impact.md +19 -0
- package/templates/claude-commands/devbooks/index.md +19 -0
- package/templates/claude-commands/devbooks/judge.md +19 -0
- package/templates/claude-commands/devbooks/plan.md +20 -0
- package/templates/claude-commands/devbooks/proposal.md +20 -0
- package/templates/claude-commands/devbooks/quick.md +43 -0
- package/templates/claude-commands/devbooks/review.md +20 -0
- package/templates/claude-commands/devbooks/router.md +19 -0
- package/templates/claude-commands/devbooks/spec.md +20 -0
- package/templates/claude-commands/devbooks/test-review.md +19 -0
- package/templates/claude-commands/devbooks/test.md +20 -0
- package/templates/dev-playbooks/changes/.gitkeep +1 -0
- package/templates/dev-playbooks/constitution.md +116 -0
- package/templates/dev-playbooks/project.md +96 -0
- package/templates/dev-playbooks/scripts/.gitkeep +1 -0
- package/templates/dev-playbooks/specs/_meta/anti-patterns/.gitkeep +2 -0
- package/templates/dev-playbooks/specs/_meta/glossary.md +48 -0
- package/templates/dev-playbooks/specs/_meta/project-profile.md +79 -0
- package/templates/dev-playbooks/specs/architecture/fitness-rules.md +95 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# DevBooks federation check script
|
|
3
|
+
# Purpose: detect whether changes touch federation contracts and generate an impact report
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Color output
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
NC='\033[0m'
|
|
13
|
+
|
|
14
|
+
echo_info() { echo -e "${GREEN}[Federation]${NC} $1"; }
|
|
15
|
+
echo_warn() { echo -e "${YELLOW}[Federation]${NC} $1"; }
|
|
16
|
+
echo_error() { echo -e "${RED}[Federation]${NC} $1"; }
|
|
17
|
+
|
|
18
|
+
# Argument parsing
|
|
19
|
+
PROJECT_ROOT="."
|
|
20
|
+
CHANGE_FILES=""
|
|
21
|
+
OUTPUT=""
|
|
22
|
+
QUIET=false
|
|
23
|
+
|
|
24
|
+
while [[ $# -gt 0 ]]; do
|
|
25
|
+
case $1 in
|
|
26
|
+
--project-root) PROJECT_ROOT="$2"; shift 2 ;;
|
|
27
|
+
--change-files) CHANGE_FILES="$2"; shift 2 ;;
|
|
28
|
+
--output) OUTPUT="$2"; shift 2 ;;
|
|
29
|
+
--quiet) QUIET=true; shift ;;
|
|
30
|
+
-h|--help)
|
|
31
|
+
echo "usage: federation-check.sh [options]"
|
|
32
|
+
echo ""
|
|
33
|
+
echo "Options:"
|
|
34
|
+
echo " --project-root <dir> Project root (default: .)"
|
|
35
|
+
echo " --change-files <list> Changed files (comma-separated)"
|
|
36
|
+
echo " --output <file> Output report path"
|
|
37
|
+
echo " --quiet Quiet mode"
|
|
38
|
+
exit 0
|
|
39
|
+
;;
|
|
40
|
+
*) echo_error "Unknown argument: $1"; exit 1 ;;
|
|
41
|
+
esac
|
|
42
|
+
done
|
|
43
|
+
|
|
44
|
+
cd "$PROJECT_ROOT"
|
|
45
|
+
|
|
46
|
+
# Find federation config
|
|
47
|
+
FEDERATION_CONFIG=""
|
|
48
|
+
if [ -f ".devbooks/federation.yaml" ]; then
|
|
49
|
+
FEDERATION_CONFIG=".devbooks/federation.yaml"
|
|
50
|
+
elif [ -f "dev-playbooks/federation.yaml" ]; then
|
|
51
|
+
FEDERATION_CONFIG="dev-playbooks/federation.yaml"
|
|
52
|
+
fi
|
|
53
|
+
|
|
54
|
+
if [ -z "$FEDERATION_CONFIG" ]; then
|
|
55
|
+
[ "$QUIET" = false ] && echo_info "No federation config found; skipping"
|
|
56
|
+
exit 0
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
[ "$QUIET" = false ] && echo_info "Using federation config: $FEDERATION_CONFIG"
|
|
60
|
+
|
|
61
|
+
# If no changed files were provided, try to read them from git
|
|
62
|
+
if [ -z "$CHANGE_FILES" ]; then
|
|
63
|
+
if [ -d ".git" ]; then
|
|
64
|
+
CHANGE_FILES=$(git diff --cached --name-only 2>/dev/null | tr '\n' ',' | sed 's/,$//')
|
|
65
|
+
if [ -z "$CHANGE_FILES" ]; then
|
|
66
|
+
CHANGE_FILES=$(git diff --name-only HEAD~1 2>/dev/null | tr '\n' ',' | sed 's/,$//')
|
|
67
|
+
fi
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
if [ -z "$CHANGE_FILES" ]; then
|
|
72
|
+
[ "$QUIET" = false ] && echo_info "No changed files; skipping"
|
|
73
|
+
exit 0
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
[ "$QUIET" = false ] && echo_info "Checking changed files: $CHANGE_FILES"
|
|
77
|
+
|
|
78
|
+
# Extract contract patterns (simple implementation: parse contracts lines from YAML)
|
|
79
|
+
CONTRACT_PATTERNS=$(grep -E "^\s+-\s+\"" "$FEDERATION_CONFIG" 2>/dev/null | sed 's/.*"\([^"]*\)".*/\1/' | tr '\n' '|' | sed 's/|$//')
|
|
80
|
+
|
|
81
|
+
if [ -z "$CONTRACT_PATTERNS" ]; then
|
|
82
|
+
[ "$QUIET" = false ] && echo_info "No contract patterns defined; skipping"
|
|
83
|
+
exit 0
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
# Detect whether changes touch contracts
|
|
87
|
+
CONTRACT_CHANGES=""
|
|
88
|
+
IFS=',' read -ra FILES <<< "$CHANGE_FILES"
|
|
89
|
+
for file in "${FILES[@]}"; do
|
|
90
|
+
if echo "$file" | grep -qE "$CONTRACT_PATTERNS"; then
|
|
91
|
+
CONTRACT_CHANGES="$CONTRACT_CHANGES$file,"
|
|
92
|
+
fi
|
|
93
|
+
done
|
|
94
|
+
CONTRACT_CHANGES=${CONTRACT_CHANGES%,}
|
|
95
|
+
|
|
96
|
+
if [ -z "$CONTRACT_CHANGES" ]; then
|
|
97
|
+
[ "$QUIET" = false ] && echo_info "No contract files changed"
|
|
98
|
+
exit 0
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# Contract changes found
|
|
102
|
+
echo_warn "Contract changes detected: $CONTRACT_CHANGES"
|
|
103
|
+
|
|
104
|
+
# Generate report
|
|
105
|
+
REPORT=$(cat << EOF
|
|
106
|
+
# Cross-repository impact analysis report
|
|
107
|
+
|
|
108
|
+
> Auto-generated on $(date +%Y-%m-%d)
|
|
109
|
+
> Federation config: $FEDERATION_CONFIG
|
|
110
|
+
|
|
111
|
+
## Contract changes
|
|
112
|
+
|
|
113
|
+
The following files match federation contracts:
|
|
114
|
+
|
|
115
|
+
$(echo "$CONTRACT_CHANGES" | tr ',' '\n' | while read f; do echo "- \`$f\`"; done)
|
|
116
|
+
|
|
117
|
+
## Recommended actions
|
|
118
|
+
|
|
119
|
+
1. [ ] Confirm change type (Breaking / Deprecation / Enhancement / Patch)
|
|
120
|
+
2. [ ] Run \`devbooks-federation\` for full cross-repo impact analysis
|
|
121
|
+
3. [ ] If breaking, notify downstream consumers
|
|
122
|
+
4. [ ] Update CHANGELOG
|
|
123
|
+
|
|
124
|
+
## Downstream consumers
|
|
125
|
+
|
|
126
|
+
$(grep -A20 "downstreams:" "$FEDERATION_CONFIG" 2>/dev/null | grep -E "^\s+-\s+name:" | sed 's/.*name:\s*"\([^"]*\)".*/- \1/' || echo "(see federation.yaml)")
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
> Tip: use the \`devbooks-federation\` skill for full analysis
|
|
131
|
+
EOF
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
# Output report
|
|
135
|
+
if [ -n "$OUTPUT" ]; then
|
|
136
|
+
echo "$REPORT" > "$OUTPUT"
|
|
137
|
+
echo_info "Report generated: $OUTPUT"
|
|
138
|
+
else
|
|
139
|
+
echo ""
|
|
140
|
+
echo "$REPORT"
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
# Return non-zero to indicate contract changes
|
|
144
|
+
exit 1
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# DevBooks cross-repo federation config template
|
|
2
|
+
# Purpose: define multi-repo dependencies and impact-analysis boundaries
|
|
3
|
+
#
|
|
4
|
+
# Install:
|
|
5
|
+
# cp this-file .devbooks/federation.yaml
|
|
6
|
+
# # or
|
|
7
|
+
# cp this-file dev-playbooks/federation.yaml
|
|
8
|
+
#
|
|
9
|
+
# Usage:
|
|
10
|
+
# - devbooks-impact-analysis auto-detects this file and analyzes cross-repo boundaries
|
|
11
|
+
# - guardrail-check.sh --check-federation verifies federation constraints
|
|
12
|
+
|
|
13
|
+
# Federation config version
|
|
14
|
+
version: "1.0"
|
|
15
|
+
|
|
16
|
+
# Current repository info
|
|
17
|
+
current:
|
|
18
|
+
name: "my-service"
|
|
19
|
+
type: "service" # service | library | shared | monorepo-package
|
|
20
|
+
owner: "team-a"
|
|
21
|
+
|
|
22
|
+
# Upstream dependencies (repos this repo depends on)
|
|
23
|
+
upstreams:
|
|
24
|
+
- name: "shared-types"
|
|
25
|
+
repo: "org/shared-types"
|
|
26
|
+
# Optional: specify the exact modules/APIs depended on
|
|
27
|
+
contracts:
|
|
28
|
+
- "src/types/user.ts"
|
|
29
|
+
- "src/types/order.ts"
|
|
30
|
+
# Version constraint
|
|
31
|
+
version: "^2.0.0"
|
|
32
|
+
# Change notification
|
|
33
|
+
notify_on_change: true
|
|
34
|
+
|
|
35
|
+
- name: "auth-sdk"
|
|
36
|
+
repo: "org/auth-sdk"
|
|
37
|
+
contracts:
|
|
38
|
+
- "src/client.ts"
|
|
39
|
+
version: ">=1.5.0"
|
|
40
|
+
|
|
41
|
+
# Downstream consumers (repos that depend on this repo)
|
|
42
|
+
downstreams:
|
|
43
|
+
- name: "web-app"
|
|
44
|
+
repo: "org/web-app"
|
|
45
|
+
# Contracts exposed to this consumer
|
|
46
|
+
contracts:
|
|
47
|
+
- "src/api/v1/**"
|
|
48
|
+
- "src/events/published.ts"
|
|
49
|
+
|
|
50
|
+
- name: "mobile-app"
|
|
51
|
+
repo: "org/mobile-app"
|
|
52
|
+
contracts:
|
|
53
|
+
- "src/api/v1/**"
|
|
54
|
+
|
|
55
|
+
# Federation rules
|
|
56
|
+
rules:
|
|
57
|
+
# Contract change rules
|
|
58
|
+
contract_change:
|
|
59
|
+
# Change types that must notify downstream consumers
|
|
60
|
+
notify_types:
|
|
61
|
+
- breaking # breaking changes
|
|
62
|
+
- deprecation # deprecation notices
|
|
63
|
+
# Notification channels
|
|
64
|
+
notify_channels:
|
|
65
|
+
- github_issue # create an issue in downstream repos
|
|
66
|
+
- slack # send Slack notification (requires webhook)
|
|
67
|
+
|
|
68
|
+
# Version compatibility
|
|
69
|
+
compatibility:
|
|
70
|
+
# Minimum number of prior versions to support
|
|
71
|
+
min_supported_versions: 2
|
|
72
|
+
# Minimum days from deprecation to removal
|
|
73
|
+
deprecation_period_days: 30
|
|
74
|
+
|
|
75
|
+
# Impact analysis boundary
|
|
76
|
+
impact_analysis:
|
|
77
|
+
# Max analysis depth (how many repos deep)
|
|
78
|
+
max_depth: 2
|
|
79
|
+
# Whether to include test code
|
|
80
|
+
include_tests: false
|
|
81
|
+
|
|
82
|
+
# Local development (optional)
|
|
83
|
+
local_dev:
|
|
84
|
+
# Local repository path mapping
|
|
85
|
+
paths:
|
|
86
|
+
shared-types: "../shared-types"
|
|
87
|
+
auth-sdk: "../auth-sdk"
|
|
88
|
+
# Whether to use local linking
|
|
89
|
+
use_local_links: true
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: devbooks-impact-analysis
|
|
3
|
+
description: devbooks-impact-analysis: Performs impact analysis before cross-module/cross-file/external contract changes, producing the Impact section (Scope/Impacts/Risks/Minimal Diff/Open Questions) that can be directly written to proposal.md. Use when the user mentions "impact analysis/change scope control/reference lookup/affected modules/compatibility risks" etc.
|
|
4
|
+
tools:
|
|
5
|
+
- Glob
|
|
6
|
+
- Grep
|
|
7
|
+
- Read
|
|
8
|
+
- Bash
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# DevBooks: Impact Analysis
|
|
12
|
+
|
|
13
|
+
## Prerequisites: Configuration Discovery (Protocol Agnostic)
|
|
14
|
+
|
|
15
|
+
- `<truth-root>`: Current truth directory root
|
|
16
|
+
- `<change-root>`: Change package directory root
|
|
17
|
+
|
|
18
|
+
Before execution, **must** search for configuration in the following order (stop when found):
|
|
19
|
+
1. `.devbooks/config.yaml` (if exists) -> Parse and use the mappings within
|
|
20
|
+
2. `dev-playbooks/project.md` (if exists) -> DevBooks 2.0 protocol, use default mappings
|
|
21
|
+
4. `project.md` (if exists) -> template protocol, use default mappings
|
|
22
|
+
5. If still unable to determine -> **Stop and ask the user**
|
|
23
|
+
|
|
24
|
+
**Key Constraints**:
|
|
25
|
+
- If `agents_doc` (rules document) is specified in the configuration, **must read that document first** before performing any operations
|
|
26
|
+
- Do not guess directory roots
|
|
27
|
+
- Do not skip reading the rules document
|
|
28
|
+
|
|
29
|
+
## Output Location
|
|
30
|
+
|
|
31
|
+
- Recommended: Write to the Impact section of `<change-root>/<change-id>/proposal.md` (or create a separate analysis document and backfill later)
|
|
32
|
+
|
|
33
|
+
## Execution Method
|
|
34
|
+
|
|
35
|
+
1) First read and follow: `_shared/references/universal-gating-protocol.md` (Verifiability + Structural Quality Gate).
|
|
36
|
+
2) Use `Grep` to search for symbol references, `Glob` to find related files.
|
|
37
|
+
3) Strictly follow the complete prompt to output Impact Analysis Markdown: `references/impact-analysis-prompt.md`.
|
|
38
|
+
|
|
39
|
+
## Output Format
|
|
40
|
+
|
|
41
|
+
```markdown
|
|
42
|
+
## Impact Analysis
|
|
43
|
+
|
|
44
|
+
### Scope
|
|
45
|
+
- Direct impact: X files
|
|
46
|
+
- Indirect impact: Y files
|
|
47
|
+
|
|
48
|
+
### Impacts
|
|
49
|
+
| File | Impact Type | Risk Level |
|
|
50
|
+
|------|-------------|------------|
|
|
51
|
+
| ... | Direct call | High |
|
|
52
|
+
|
|
53
|
+
### Risks
|
|
54
|
+
- ...
|
|
55
|
+
|
|
56
|
+
### Minimal Diff
|
|
57
|
+
- ...
|
|
58
|
+
|
|
59
|
+
### Open Questions
|
|
60
|
+
- ...
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Context Awareness
|
|
66
|
+
|
|
67
|
+
This Skill automatically detects context before execution and selects the appropriate analysis scope.
|
|
68
|
+
|
|
69
|
+
Detection rules reference: `skills/_shared/context-detection-template.md`
|
|
70
|
+
|
|
71
|
+
### Detection Flow
|
|
72
|
+
|
|
73
|
+
1. Detect whether a change package exists
|
|
74
|
+
2. Detect whether the `proposal.md` already has an Impact section
|
|
75
|
+
3. Detect whether CKB index is available (enhances analysis capability)
|
|
76
|
+
|
|
77
|
+
### Modes Supported by This Skill
|
|
78
|
+
|
|
79
|
+
| Mode | Trigger Condition | Behavior |
|
|
80
|
+
|------|-------------------|----------|
|
|
81
|
+
| **New Analysis** | Impact section does not exist | Perform complete impact analysis |
|
|
82
|
+
| **Incremental Analysis** | Impact exists, new changes present | Update affected files list |
|
|
83
|
+
| **Enhanced Analysis** | CKB index available | Use call graph for precise analysis |
|
|
84
|
+
| **Basic Analysis** | CKB index unavailable | Use Grep text search for analysis |
|
|
85
|
+
|
|
86
|
+
### Detection Output Example
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
Detection Results:
|
|
90
|
+
- proposal.md: Exists, Impact section missing
|
|
91
|
+
- CKB Index: Available
|
|
92
|
+
- Run Mode: New Analysis + Enhanced Mode
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## MCP Enhancement
|
|
98
|
+
|
|
99
|
+
This Skill supports MCP runtime enhancement, automatically detecting and enabling advanced features.
|
|
100
|
+
|
|
101
|
+
MCP enhancement rules reference: `skills/_shared/mcp-enhancement-template.md`
|
|
102
|
+
|
|
103
|
+
### Required MCP Services
|
|
104
|
+
|
|
105
|
+
| Service | Purpose | Timeout |
|
|
106
|
+
|---------|---------|---------|
|
|
107
|
+
| `mcp__ckb__analyzeImpact` | Symbol-level impact analysis | 2s |
|
|
108
|
+
| `mcp__ckb__findReferences` | Precise reference lookup | 2s |
|
|
109
|
+
| `mcp__ckb__getCallGraph` | Call graph analysis | 2s |
|
|
110
|
+
| `mcp__ckb__getStatus` | Detect CKB index availability | 2s |
|
|
111
|
+
|
|
112
|
+
### Detection Flow
|
|
113
|
+
|
|
114
|
+
1. Call `mcp__ckb__getStatus` (2s timeout)
|
|
115
|
+
2. If CKB available -> Use `analyzeImpact` and `findReferences` for precise analysis
|
|
116
|
+
3. If timeout or failure -> Fallback to basic mode (Grep text search)
|
|
117
|
+
|
|
118
|
+
### Enhanced Mode vs Basic Mode
|
|
119
|
+
|
|
120
|
+
| Feature | Enhanced Mode | Basic Mode |
|
|
121
|
+
|---------|---------------|------------|
|
|
122
|
+
| Reference Lookup | Symbol-level precise matching | Text Grep search |
|
|
123
|
+
| Impact Scope | Call graph transitive analysis | Direct reference counting |
|
|
124
|
+
| Risk Assessment | Quantified based on call depth | Estimated based on file count |
|
|
125
|
+
| Cross-module Analysis | Automatic module boundary recognition | Requires manual scope specification |
|
|
126
|
+
|
|
127
|
+
### Fallback Notice
|
|
128
|
+
|
|
129
|
+
When MCP is unavailable, output the following notice:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
Warning: CKB unavailable, using Grep text search for impact analysis.
|
|
133
|
+
Analysis results may not be precise. Recommend running /devbooks:index to generate index and re-analyze.
|
|
134
|
+
```
|
|
135
|
+
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Impact Analysis Prompt
|
|
2
|
+
|
|
3
|
+
> **Role**: You are the strongest mind in system analysis, combining the wisdom of Michael Feathers (dependency analysis and legacy code), Sam Newman (service boundaries and impact control), and Martin Fowler (refactoring risk assessment). Your analysis must meet expert-level standards.
|
|
4
|
+
|
|
5
|
+
Highest directive (top priority):
|
|
6
|
+
- Before executing this prompt, read `_shared/references/universal-gating-protocol.md` and follow all protocols within it.
|
|
7
|
+
|
|
8
|
+
You are the "Impact Analyst." Your goal is to produce an **actionable impact analysis and change-scope control** before any cross-module/cross-file change, reducing consistency errors and omissions in large projects.
|
|
9
|
+
|
|
10
|
+
Applicable scenarios:
|
|
11
|
+
- Refactoring, cross-module changes, external interface/data contract changes, architecture boundary adjustments
|
|
12
|
+
- You have semantic indexing/impact analysis capability (e.g., CKB/CodeMCP), or at least LSP/reference lookup capability
|
|
13
|
+
|
|
14
|
+
Input materials (provided by me):
|
|
15
|
+
- Change intent (1–3 sentences)
|
|
16
|
+
- Design doc (if any): `<change-root>/<change-id>/design.md`
|
|
17
|
+
- Current truth source: `<truth-root>/`
|
|
18
|
+
- Codebase (read-only analysis)
|
|
19
|
+
|
|
20
|
+
Hard constraints (must follow):
|
|
21
|
+
- Impact analysis first, code later
|
|
22
|
+
- No "decorative/surface refactors" unless they directly reduce risk for this change
|
|
23
|
+
- Output must be directly usable in the Impact section of `proposal.md`
|
|
24
|
+
|
|
25
|
+
Tool priority:
|
|
26
|
+
1) Semantic index/impact analysis (preferred): references, call chains, dependency chains, impacted symbols/modules
|
|
27
|
+
2) LSP: references/definitions/type diagnostics
|
|
28
|
+
3) Degraded fallback: `rg` full-text search (must state lower confidence)
|
|
29
|
+
|
|
30
|
+
Output format (MECE):
|
|
31
|
+
1) Scope
|
|
32
|
+
- In / Out
|
|
33
|
+
2) **Change Type Classification** (new, required):
|
|
34
|
+
- Based on GoF "8 causes of redesign," mark which category/categories this change falls into:
|
|
35
|
+
- [ ] **Specific class creation**: objects created by explicit class names (should move to factory/abstract factory)
|
|
36
|
+
- [ ] **Algorithm dependency**: depends on a specific algorithm implementation (should be encapsulated via strategy)
|
|
37
|
+
- [ ] **Platform dependency**: depends on specific hardware/OS/external platform (should be isolated via abstract factory/bridge)
|
|
38
|
+
- [ ] **Representation/implementation dependency**: depends on internal object structure (should isolate via interface)
|
|
39
|
+
- [ ] **Feature extension**: new features/operations needed (design extension points rather than modify core)
|
|
40
|
+
- [ ] **Object responsibility change**: object responsibilities are changing (check single-responsibility violation)
|
|
41
|
+
- [ ] **Subsystem/module replacement**: entire subsystem replacement (must have clear module boundaries)
|
|
42
|
+
- [ ] **Interface contract change**: external interface changes (must have versioning strategy)
|
|
43
|
+
- **Notation**: check applicable items and briefly state the impact scope
|
|
44
|
+
3) Impacts
|
|
45
|
+
- A. External contracts (API/events/schema)
|
|
46
|
+
- B. Data and migration (DB/replay/idempotency)
|
|
47
|
+
- C. Modules and dependencies (boundaries/call direction/cycle risk)
|
|
48
|
+
- D. Tests and verification (anchors to add/update; snapshot tests prioritized for refactor/migration)
|
|
49
|
+
- **E. Bounded Context boundaries** (new, required):
|
|
50
|
+
- Does this change cross Bounded Contexts?
|
|
51
|
+
- If cross-context: do we need to introduce or update ACL (Anti-Corruption Layer)?
|
|
52
|
+
- ACL checklist:
|
|
53
|
+
- Are external system/API changes isolated by ACL? (External model changes must not leak into internal models)
|
|
54
|
+
- Are there direct calls to external APIs bypassing the adapter layer?
|
|
55
|
+
- If adding external dependency: suggested ACL interface definition
|
|
56
|
+
4) Compatibility and Risks
|
|
57
|
+
- Breaking changes (explicitly mark if any)
|
|
58
|
+
- Migration/rollback paths
|
|
59
|
+
5) Minimal Diff Strategy
|
|
60
|
+
- Preferred change points (1–3 "convergence points")
|
|
61
|
+
- Explicitly forbidden change types (avoid scope creep)
|
|
62
|
+
6) **Pinch Point Identification and Minimal Test Set** (new, required)
|
|
63
|
+
- **Pinch Point definition**: nodes where multiple call paths converge; tests here cover all downstream paths
|
|
64
|
+
- **Identification method**:
|
|
65
|
+
- Analyze call chains to find "many-in-one-out" convergence points
|
|
66
|
+
- Prefer: public interfaces, service entry points, data transformation layers, event handlers
|
|
67
|
+
- Tool assist: `LSP findReferences` -> functions/classes called from multiple places
|
|
68
|
+
- **Output format**:
|
|
69
|
+
```
|
|
70
|
+
Pinch Points:
|
|
71
|
+
- [PP-1] `OrderService.processOrder()` - 3 call paths converge
|
|
72
|
+
- [PP-2] `PaymentGateway.execute()` - 2 call paths converge
|
|
73
|
+
|
|
74
|
+
Minimal test set:
|
|
75
|
+
- 1 test at PP-1 -> covers OrderController/BatchProcessor/EventHandler
|
|
76
|
+
- 1 test at PP-2 -> covers CheckoutFlow/RefundFlow
|
|
77
|
+
- Estimated tests: 2 (instead of 5 per path)
|
|
78
|
+
```
|
|
79
|
+
- **ROI principle**: test count equals pinch point count, not call path count
|
|
80
|
+
7) Open Questions (<= 3)
|
|
81
|
+
|
|
82
|
+
Start the impact analysis in Markdown now; do not output extra explanations.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# DevBooks graph cache manager
|
|
3
|
+
# Purpose: cache common CKB MCP query results to reduce repeated queries
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
CACHE_DIR=".devbooks/cache/graph"
|
|
8
|
+
CACHE_TTL=3600 # default TTL: 1 hour (seconds)
|
|
9
|
+
|
|
10
|
+
# Color output
|
|
11
|
+
GREEN='\033[0;32m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
NC='\033[0m'
|
|
14
|
+
|
|
15
|
+
echo_info() { echo -e "${GREEN}[Cache]${NC} $1"; }
|
|
16
|
+
echo_warn() { echo -e "${YELLOW}[Cache]${NC} $1"; }
|
|
17
|
+
|
|
18
|
+
# Argument parsing
|
|
19
|
+
ACTION=""
|
|
20
|
+
KEY=""
|
|
21
|
+
VALUE=""
|
|
22
|
+
TTL=$CACHE_TTL
|
|
23
|
+
|
|
24
|
+
while [[ $# -gt 0 ]]; do
|
|
25
|
+
case $1 in
|
|
26
|
+
get|set|clear|status|warm) ACTION="$1"; shift ;;
|
|
27
|
+
--key) KEY="$2"; shift 2 ;;
|
|
28
|
+
--value) VALUE="$2"; shift 2 ;;
|
|
29
|
+
--ttl) TTL="$2"; shift 2 ;;
|
|
30
|
+
--project-root) cd "$2"; shift 2 ;;
|
|
31
|
+
-h|--help)
|
|
32
|
+
echo "usage: graph-cache.sh <action> [options]"
|
|
33
|
+
echo ""
|
|
34
|
+
echo "Actions:"
|
|
35
|
+
echo " get Get cache"
|
|
36
|
+
echo " set Set cache"
|
|
37
|
+
echo " clear Clear cache"
|
|
38
|
+
echo " status Show cache status"
|
|
39
|
+
echo " warm Warm cache"
|
|
40
|
+
echo ""
|
|
41
|
+
echo "Options:"
|
|
42
|
+
echo " --key <name> Cache key"
|
|
43
|
+
echo " --value <data> Cache value"
|
|
44
|
+
echo " --ttl <seconds> Cache TTL (default: 3600)"
|
|
45
|
+
echo " --project-root Project root"
|
|
46
|
+
exit 0
|
|
47
|
+
;;
|
|
48
|
+
*) shift ;;
|
|
49
|
+
esac
|
|
50
|
+
done
|
|
51
|
+
|
|
52
|
+
# Ensure cache directory exists
|
|
53
|
+
mkdir -p "$CACHE_DIR"
|
|
54
|
+
|
|
55
|
+
# Compute cache file path
|
|
56
|
+
get_cache_file() {
|
|
57
|
+
local key="$1"
|
|
58
|
+
local hash=$(echo "$key" | md5sum | cut -d' ' -f1)
|
|
59
|
+
echo "$CACHE_DIR/${hash}.json"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# Check whether cache is valid
|
|
63
|
+
is_cache_valid() {
|
|
64
|
+
local cache_file="$1"
|
|
65
|
+
local ttl="${2:-$CACHE_TTL}"
|
|
66
|
+
|
|
67
|
+
if [ ! -f "$cache_file" ]; then
|
|
68
|
+
return 1
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
local file_age=$(( $(date +%s) - $(stat -f%m "$cache_file" 2>/dev/null || stat -c%Y "$cache_file" 2>/dev/null) ))
|
|
72
|
+
|
|
73
|
+
if [ $file_age -gt $ttl ]; then
|
|
74
|
+
return 1
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
return 0
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Get cache
|
|
81
|
+
cache_get() {
|
|
82
|
+
local cache_file=$(get_cache_file "$KEY")
|
|
83
|
+
|
|
84
|
+
if is_cache_valid "$cache_file" "$TTL"; then
|
|
85
|
+
cat "$cache_file"
|
|
86
|
+
return 0
|
|
87
|
+
else
|
|
88
|
+
return 1
|
|
89
|
+
fi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# Set cache
|
|
93
|
+
cache_set() {
|
|
94
|
+
local cache_file=$(get_cache_file "$KEY")
|
|
95
|
+
|
|
96
|
+
# Write cache metadata
|
|
97
|
+
cat > "$cache_file" << EOF
|
|
98
|
+
{
|
|
99
|
+
"key": "$KEY",
|
|
100
|
+
"timestamp": $(date +%s),
|
|
101
|
+
"ttl": $TTL,
|
|
102
|
+
"data": $VALUE
|
|
103
|
+
}
|
|
104
|
+
EOF
|
|
105
|
+
|
|
106
|
+
echo_info "cached: $KEY"
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# Clear cache
|
|
110
|
+
cache_clear() {
|
|
111
|
+
if [ -n "$KEY" ]; then
|
|
112
|
+
local cache_file=$(get_cache_file "$KEY")
|
|
113
|
+
rm -f "$cache_file"
|
|
114
|
+
echo_info "cleared: $KEY"
|
|
115
|
+
else
|
|
116
|
+
rm -rf "$CACHE_DIR"/*
|
|
117
|
+
echo_info "cleared all cache entries"
|
|
118
|
+
fi
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# Show cache status
|
|
122
|
+
cache_status() {
|
|
123
|
+
echo "=== DevBooks graph cache status ==="
|
|
124
|
+
echo ""
|
|
125
|
+
|
|
126
|
+
if [ ! -d "$CACHE_DIR" ] || [ -z "$(ls -A "$CACHE_DIR" 2>/dev/null)" ]; then
|
|
127
|
+
echo "cache is empty"
|
|
128
|
+
return
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
local total=0
|
|
132
|
+
local valid=0
|
|
133
|
+
local expired=0
|
|
134
|
+
|
|
135
|
+
echo "| Key | Size | Age | Status |"
|
|
136
|
+
echo "|-----|------|------|------|"
|
|
137
|
+
|
|
138
|
+
for cache_file in "$CACHE_DIR"/*.json; do
|
|
139
|
+
if [ -f "$cache_file" ]; then
|
|
140
|
+
total=$((total + 1))
|
|
141
|
+
|
|
142
|
+
local size=$(du -h "$cache_file" | cut -f1)
|
|
143
|
+
local age=$(( ($(date +%s) - $(stat -f%m "$cache_file" 2>/dev/null || stat -c%Y "$cache_file" 2>/dev/null)) ))
|
|
144
|
+
local age_min=$((age / 60))
|
|
145
|
+
|
|
146
|
+
local key=$(jq -r '.key // "unknown"' "$cache_file" 2>/dev/null || echo "unknown")
|
|
147
|
+
local ttl=$(jq -r '.ttl // 3600' "$cache_file" 2>/dev/null || echo 3600)
|
|
148
|
+
|
|
149
|
+
local status="✅ valid"
|
|
150
|
+
if [ $age -gt $ttl ]; then
|
|
151
|
+
status="❌ expired"
|
|
152
|
+
expired=$((expired + 1))
|
|
153
|
+
else
|
|
154
|
+
valid=$((valid + 1))
|
|
155
|
+
fi
|
|
156
|
+
|
|
157
|
+
# Truncate long keys
|
|
158
|
+
if [ ${#key} -gt 30 ]; then
|
|
159
|
+
key="${key:0:27}..."
|
|
160
|
+
fi
|
|
161
|
+
|
|
162
|
+
echo "| $key | $size | ${age_min}m | $status |"
|
|
163
|
+
fi
|
|
164
|
+
done
|
|
165
|
+
|
|
166
|
+
echo ""
|
|
167
|
+
echo "total: $total entries; $valid valid; $expired expired"
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
# Warm cache (common queries)
|
|
171
|
+
cache_warm() {
|
|
172
|
+
echo_info "warming cache..."
|
|
173
|
+
|
|
174
|
+
# Check whether a SCIP index exists
|
|
175
|
+
if [ ! -f "index.scip" ]; then
|
|
176
|
+
echo_warn "SCIP index not found; cannot warm graph cache"
|
|
177
|
+
return 1
|
|
178
|
+
fi
|
|
179
|
+
|
|
180
|
+
# Cache common query results
|
|
181
|
+
# Note: actual MCP calls must be executed in Claude Code.
|
|
182
|
+
# Here we only clean expired cache and keep placeholders.
|
|
183
|
+
|
|
184
|
+
# Clean expired cache
|
|
185
|
+
for cache_file in "$CACHE_DIR"/*.json; do
|
|
186
|
+
if [ -f "$cache_file" ]; then
|
|
187
|
+
if ! is_cache_valid "$cache_file"; then
|
|
188
|
+
rm -f "$cache_file"
|
|
189
|
+
echo_info "removed expired: $(basename "$cache_file")"
|
|
190
|
+
fi
|
|
191
|
+
fi
|
|
192
|
+
done
|
|
193
|
+
|
|
194
|
+
echo_info "cache warm-up complete"
|
|
195
|
+
echo ""
|
|
196
|
+
echo "Tip: in Claude Code, run these commands to warm common queries:"
|
|
197
|
+
echo " - mcp__ckb__getArchitecture(depth=2)"
|
|
198
|
+
echo " - mcp__ckb__getHotspots(limit=20)"
|
|
199
|
+
echo " - mcp__ckb__listKeyConcepts(limit=12)"
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
# Main
|
|
203
|
+
case "$ACTION" in
|
|
204
|
+
get) cache_get ;;
|
|
205
|
+
set) cache_set ;;
|
|
206
|
+
clear) cache_clear ;;
|
|
207
|
+
status) cache_status ;;
|
|
208
|
+
warm) cache_warm ;;
|
|
209
|
+
*)
|
|
210
|
+
echo "error: specify an action: get, set, clear, status, warm"
|
|
211
|
+
echo "hint: use -h for help"
|
|
212
|
+
exit 1
|
|
213
|
+
;;
|
|
214
|
+
esac
|