dev-playbooks 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/package.json +1 -1
- package/skills/Skills-Usage-Guide.md +0 -22
- package/skills/_shared/mcp-enhancement-template.md +0 -1
- package/skills/devbooks-brownfield-bootstrap/SKILL.md +184 -139
- package/skills/devbooks-code-review/SKILL.md +1 -1
- package/skills/devbooks-design-doc/SKILL.md +75 -0
- package/skills/devbooks-router/SKILL.md +3 -3
- package/skills/devbooks-spec-gardener/SKILL.md +56 -0
- package/templates/dev-playbooks/README.md +0 -1
- package/templates/dev-playbooks/docs/devbooks-setup-guide.md +1 -2
- package/skills/devbooks-c4-map/SKILL.md +0 -151
- package/skills/devbooks-c4-map/references/c4-architecture-map-prompt.md +0 -33
- package/skills/devbooks-c4-map/references/layered-constraint-checklist.md +0 -185
package/README.md
CHANGED
|
@@ -178,7 +178,6 @@ Run devbooks-spec-gardener skill for change add-oauth2
|
|
|
178
178
|
| devbooks-proposal-debate-workflow | Triangle debate (Author/Challenger/Judge) |
|
|
179
179
|
| devbooks-design-doc | Create a design doc |
|
|
180
180
|
| devbooks-spec-contract | Define specs & contracts |
|
|
181
|
-
| devbooks-c4-map | Generate a C4 map |
|
|
182
181
|
| devbooks-implementation-plan | Create an implementation plan |
|
|
183
182
|
|
|
184
183
|
### Apply stage
|
package/package.json
CHANGED
|
@@ -171,28 +171,6 @@ If you are not using DevBooks, replace `dev-playbooks/specs` / `dev-playbooks/ch
|
|
|
171
171
|
|
|
172
172
|
---
|
|
173
173
|
|
|
174
|
-
## `devbooks-c4-map` (C4 Map Maintainer)
|
|
175
|
-
|
|
176
|
-
- Purpose: maintain/update the authoritative C4 architecture map (truth) and produce a C4 Delta per change.
|
|
177
|
-
- When to use:
|
|
178
|
-
- Proposal stage: describe boundary/dependency direction changes in `design.md` (C4 Delta only; do not modify current truth)
|
|
179
|
-
- Review/archive stage: change is implemented; update the authoritative map at `(<truth-root>/architecture/c4.md)`
|
|
180
|
-
- Copy-paste prompts:
|
|
181
|
-
- Proposal stage (C4 Delta only; do not edit current truth):
|
|
182
|
-
```text
|
|
183
|
-
You are C4 Map Maintainer. Explicitly use `devbooks-c4-map`, but during proposal stage do NOT modify `dev-playbooks/specs/architecture/c4.md` (current truth).
|
|
184
|
-
First read: `dev-playbooks/specs/architecture/c4.md` (if present) + `dev-playbooks/changes/<change-id>/proposal.md` + `dev-playbooks/changes/<change-id>/design.md`.
|
|
185
|
-
Output: a **C4 Delta** section that I can paste into `dev-playbooks/changes/<change-id>/design.md` (C1/C2/C3 add/modify/remove + dependency direction changes + suggested architecture guardrails/fitness tests).
|
|
186
|
-
```
|
|
187
|
-
- Review/archive stage (update current truth map):
|
|
188
|
-
```text
|
|
189
|
-
You are C4 Map Maintainer. Explicitly use `devbooks-c4-map`.
|
|
190
|
-
First read: `dev-playbooks/specs/architecture/c4.md` (if present) + `dev-playbooks/changes/<change-id>/design.md` + relevant code changes (to confirm the change is real).
|
|
191
|
-
Update (or create a minimal skeleton with TODOs): `dev-playbooks/specs/architecture/c4.md`.
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
---
|
|
195
|
-
|
|
196
174
|
## `devbooks-implementation-plan` (Planner / tasks.md)
|
|
197
175
|
|
|
198
176
|
- Purpose: derive an implementation plan `tasks.md` from `design.md` (critical path / side quests / checkpoints), tied to verification anchors (must not reference `tests/`).
|
|
@@ -91,7 +91,6 @@ The following Skills depend on MCP and require the full MCP Enhancement section:
|
|
|
91
91
|
| devbooks-index-bootstrap | mcp__ckb__getStatus | Index status detection |
|
|
92
92
|
| devbooks-federation | mcp__ckb__*, mcp__github__* | Cross-repo analysis |
|
|
93
93
|
| devbooks-router | mcp__ckb__getStatus | Index availability detection |
|
|
94
|
-
| devbooks-c4-map | mcp__ckb__getArchitecture | Module dependency graph |
|
|
95
94
|
| devbooks-spec-contract | mcp__ckb__findReferences | Reference detection |
|
|
96
95
|
| devbooks-entropy-monitor | mcp__ckb__getHotspots | Hotspot trend analysis |
|
|
97
96
|
| devbooks-delivery-workflow | mcp__ckb__getStatus | Index detection |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: devbooks-brownfield-bootstrap
|
|
3
|
-
description: devbooks-brownfield-bootstrap
|
|
3
|
+
description: "devbooks-brownfield-bootstrap: Brownfield project initialization. When the truth directory is empty, generate project profile, glossary, baseline specs, and minimum verification anchors to avoid 'patching specs while changing behavior'. Use when user says 'brownfield init/baseline specs/project profile/establish glossary/onboard legacy project to context protocol' etc."
|
|
4
4
|
tools:
|
|
5
5
|
- Glob
|
|
6
6
|
- Grep
|
|
@@ -15,217 +15,262 @@ tools:
|
|
|
15
15
|
- mcp__ckb__getModuleOverview
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
# DevBooks
|
|
18
|
+
# DevBooks: Brownfield Bootstrap
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## Prerequisites: Configuration Discovery (Protocol Agnostic)
|
|
21
21
|
|
|
22
|
-
- `<truth-root
|
|
23
|
-
- `<change-root
|
|
24
|
-
- `<devbooks-root
|
|
22
|
+
- `<truth-root>`: Current truth directory root
|
|
23
|
+
- `<change-root>`: Change package directory root
|
|
24
|
+
- `<devbooks-root>`: DevBooks management directory (usually `dev-playbooks/`)
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
1. `.devbooks/config.yaml
|
|
28
|
-
2. `dev-playbooks/project.md
|
|
29
|
-
4. `project.md
|
|
30
|
-
5.
|
|
26
|
+
Before execution, **must** search for configuration in the following order (stop when found):
|
|
27
|
+
1. `.devbooks/config.yaml` (if exists) → Parse and use its mappings
|
|
28
|
+
2. `dev-playbooks/project.md` (if exists) → DevBooks 2.0 protocol, use default mappings
|
|
29
|
+
4. `project.md` (if exists) → Template protocol, use default mappings
|
|
30
|
+
5. If still unable to determine → **Create DevBooks directory structure and initialize basic configuration**
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
32
|
+
**Key Constraints**:
|
|
33
|
+
- If configuration specifies `agents_doc` (rules document), **must read that document first** before executing any operations
|
|
34
|
+
- Do not guess directory roots
|
|
35
|
+
- Do not skip reading rules document
|
|
36
36
|
|
|
37
37
|
---
|
|
38
38
|
|
|
39
|
-
##
|
|
39
|
+
## Core Responsibilities
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
Brownfield project initialization includes the following responsibilities:
|
|
42
42
|
|
|
43
|
-
### 1.
|
|
43
|
+
### 1. Basic Configuration File Initialization
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Check and create in `<devbooks-root>/` (usually `dev-playbooks/`):
|
|
46
46
|
|
|
47
|
-
|
|
|
48
|
-
|
|
49
|
-
| `constitution.md` |
|
|
50
|
-
| `project.md` |
|
|
47
|
+
| File | Purpose | Creation Condition |
|
|
48
|
+
|------|---------|-------------------|
|
|
49
|
+
| `constitution.md` | Project constitution (GIP principles) | When file doesn't exist |
|
|
50
|
+
| `project.md` | Project context (tech stack/conventions) | When file doesn't exist |
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
- `constitution.md
|
|
55
|
-
- `project.md
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
52
|
+
**Creation Method**:
|
|
53
|
+
- **Not simple template copying**, but customized content based on code analysis results
|
|
54
|
+
- `constitution.md`: Based on default GIP principles, can be adjusted according to project characteristics
|
|
55
|
+
- `project.md`: Filled based on code analysis results:
|
|
56
|
+
- Tech stack (language/framework/database)
|
|
57
|
+
- Development conventions (code style/testing strategy/Git workflow)
|
|
58
|
+
- Domain context (core concepts/role definitions)
|
|
59
|
+
- Directory root mappings
|
|
60
60
|
|
|
61
|
-
### 2.
|
|
61
|
+
### 2. Project Profile and Metadata
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
Generate in `<truth-root>/_meta/`:
|
|
64
64
|
|
|
65
|
-
|
|
|
66
|
-
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
65
|
+
| Artifact | Path | Description |
|
|
66
|
+
|----------|------|-------------|
|
|
67
|
+
| Project profile | `_meta/project-profile.md` | Detailed technical profile with three-layer architecture |
|
|
68
|
+
| Glossary | `_meta/glossary.md` | Unified language table (optional but recommended) |
|
|
69
|
+
| Domain concepts | `_meta/key-concepts.md` | Concepts extracted by CKB (enhanced mode) |
|
|
70
70
|
|
|
71
|
-
### 3.
|
|
71
|
+
### 3. Architecture Analysis Artifacts
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
Generate in `<truth-root>/architecture/`:
|
|
74
74
|
|
|
75
|
-
|
|
|
76
|
-
|
|
77
|
-
|
|
|
78
|
-
|
|
|
75
|
+
| Artifact | Path | Data Source |
|
|
76
|
+
|----------|------|-------------|
|
|
77
|
+
| **C4 Architecture Map** | `architecture/c4.md` | Comprehensive analysis + CKB (enhanced mode) |
|
|
78
|
+
| Module dependency graph | `architecture/module-graph.md` | `mcp__ckb__getArchitecture` |
|
|
79
|
+
| Technical debt hotspots | `architecture/hotspots.md` | `mcp__ckb__getHotspots` |
|
|
80
|
+
| Layering constraints | `architecture/layering-constraints.md` | Code analysis (optional) |
|
|
79
81
|
|
|
80
|
-
|
|
82
|
+
> **Design Decision**: C4 architecture map is now generated by brownfield-bootstrap during initialization. Subsequent architecture changes are recorded in design.md's Architecture Impact section and merged by spec-gardener during archiving.
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
### 4. Baseline Change Package
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
|
87
|
-
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
86
|
+
Generate in `<change-root>/<baseline-id>/`:
|
|
87
|
+
|
|
88
|
+
| Artifact | Description |
|
|
89
|
+
|----------|-------------|
|
|
90
|
+
| `proposal.md` | Baseline scope, In/Out, risks |
|
|
91
|
+
| `design.md` | Current state inventory (capability inventory) |
|
|
92
|
+
| `specs/<cap>/spec.md` | Baseline spec deltas (mainly ADDED) |
|
|
93
|
+
| `verification.md` | Minimum verification anchor plan |
|
|
90
94
|
|
|
91
95
|
---
|
|
92
96
|
|
|
93
|
-
## COD
|
|
97
|
+
## COD Model Generation (Code Overview & Dependencies)
|
|
98
|
+
|
|
99
|
+
Automatically generate project's "code map" during initialization (requires CKB MCP Server available, otherwise skip):
|
|
100
|
+
|
|
101
|
+
### Auto-generated Artifacts
|
|
102
|
+
|
|
103
|
+
| Artifact | Path | Data Source |
|
|
104
|
+
|----------|------|-------------|
|
|
105
|
+
| **C4 Architecture Map** | `<truth-root>/architecture/c4.md` | Comprehensive analysis |
|
|
106
|
+
| Module dependency graph | `<truth-root>/architecture/module-graph.md` | `mcp__ckb__getArchitecture` |
|
|
107
|
+
| Technical debt hotspots | `<truth-root>/architecture/hotspots.md` | `mcp__ckb__getHotspots` |
|
|
108
|
+
| Domain concepts | `<truth-root>/_meta/key-concepts.md` | `mcp__ckb__listKeyConcepts` |
|
|
109
|
+
| Project profile | `<truth-root>/_meta/project-profile.md` | Comprehensive analysis |
|
|
110
|
+
|
|
111
|
+
### C4 Architecture Map Generation Rules
|
|
112
|
+
|
|
113
|
+
C4 map generated during initialization should include:
|
|
114
|
+
|
|
115
|
+
1. **Context Level**: System's relationship with external actors (users, external systems)
|
|
116
|
+
2. **Container Level**: Containers within the system (applications, databases, services)
|
|
117
|
+
3. **Component Level**: Components within main containers (modules, classes)
|
|
118
|
+
|
|
119
|
+
**Output Format**:
|
|
120
|
+
|
|
121
|
+
```markdown
|
|
122
|
+
# C4 Architecture Map
|
|
94
123
|
|
|
95
|
-
|
|
124
|
+
## System Context
|
|
96
125
|
|
|
97
|
-
|
|
126
|
+
[Describe system boundaries and external interactions]
|
|
98
127
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
|
102
|
-
|
|
103
|
-
|
|
|
104
|
-
|
|
128
|
+
## Container Diagram
|
|
129
|
+
|
|
130
|
+
| Container | Tech Stack | Responsibility |
|
|
131
|
+
|-----------|------------|----------------|
|
|
132
|
+
| <name> | <tech> | <responsibility> |
|
|
133
|
+
|
|
134
|
+
## Component Diagram
|
|
135
|
+
|
|
136
|
+
### <Container Name>
|
|
137
|
+
|
|
138
|
+
| Component | Responsibility | Dependencies |
|
|
139
|
+
|-----------|----------------|--------------|
|
|
140
|
+
| <name> | <responsibility> | <dependencies> |
|
|
141
|
+
|
|
142
|
+
## Architecture Guardrails
|
|
143
|
+
|
|
144
|
+
### Layering Constraints
|
|
145
|
+
|
|
146
|
+
| Layer | Can Depend On | Cannot Depend On |
|
|
147
|
+
|-------|---------------|------------------|
|
|
148
|
+
| <layer> | <allowed> | <forbidden> |
|
|
149
|
+
```
|
|
105
150
|
|
|
106
|
-
###
|
|
151
|
+
### Hotspot Calculation Formula
|
|
107
152
|
|
|
108
153
|
```
|
|
109
|
-
|
|
154
|
+
Hotspot Score = Change Frequency × Cyclomatic Complexity
|
|
110
155
|
```
|
|
111
156
|
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
-
|
|
157
|
+
- **High Hotspot** (score > threshold): Frequent changes + high complexity = Bug-dense area
|
|
158
|
+
- **Dormant Debt** (high complexity + low frequency): Temporarily safe but needs attention
|
|
159
|
+
- **Active Healthy** (high frequency + low complexity): Normal maintenance area
|
|
115
160
|
|
|
116
|
-
###
|
|
161
|
+
### Boundary Identification
|
|
117
162
|
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
163
|
+
Automatically distinguish:
|
|
164
|
+
- **User Code**: `src/`, `lib/`, `app/` etc. (modifiable)
|
|
165
|
+
- **Library Code**: `node_modules/`, `vendor/`, `.venv/` etc. (immutable interface)
|
|
166
|
+
- **Generated Code**: `dist/`, `build/`, `*.generated.*` etc. (manual modification prohibited)
|
|
122
167
|
|
|
123
|
-
###
|
|
168
|
+
### Execution Flow
|
|
124
169
|
|
|
125
|
-
1)
|
|
126
|
-
-
|
|
127
|
-
-
|
|
170
|
+
1) **Check Graph Index**: Call `mcp__ckb__getStatus`
|
|
171
|
+
- If SCIP available → Use graph-based analysis
|
|
172
|
+
- If unavailable → Prompt to generate index or use Git history analysis
|
|
128
173
|
|
|
129
|
-
2)
|
|
174
|
+
2) **Generate COD Artifacts**:
|
|
130
175
|
```bash
|
|
131
|
-
#
|
|
176
|
+
# Get module architecture
|
|
132
177
|
mcp__ckb__getArchitecture(depth=2, includeExternalDeps=false)
|
|
133
178
|
|
|
134
|
-
#
|
|
179
|
+
# Get hotspots (last 30 days)
|
|
135
180
|
mcp__ckb__getHotspots(limit=20)
|
|
136
181
|
|
|
137
|
-
#
|
|
182
|
+
# Get domain concepts
|
|
138
183
|
mcp__ckb__listKeyConcepts(limit=12)
|
|
139
184
|
```
|
|
140
185
|
|
|
141
|
-
3)
|
|
186
|
+
3) **Generate Project Profile**: Integrate above data + traditional analysis
|
|
142
187
|
|
|
143
|
-
##
|
|
188
|
+
## Reference Scaffolds and Templates
|
|
144
189
|
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
190
|
+
- Workflow: `references/brownfield-bootstrap.md`
|
|
191
|
+
- Code navigation strategy: `references/code-navigation-strategy.md`
|
|
192
|
+
- **Project profile template (three-layer architecture)**: `templates/project-profile-template.md`
|
|
193
|
+
- One-time prompt: `references/brownfield-bootstrap-prompt.md`
|
|
194
|
+
- Template (as needed): `references/glossary-template.md`
|
|
150
195
|
|
|
151
196
|
---
|
|
152
197
|
|
|
153
|
-
##
|
|
198
|
+
## Context Awareness
|
|
154
199
|
|
|
155
|
-
|
|
200
|
+
This Skill automatically detects context before execution and selects the appropriate initialization scope.
|
|
156
201
|
|
|
157
|
-
|
|
202
|
+
Detection rules reference: `skills/_shared/context-detection-template.md`
|
|
158
203
|
|
|
159
|
-
###
|
|
204
|
+
### Detection Flow
|
|
160
205
|
|
|
161
|
-
1.
|
|
162
|
-
2.
|
|
163
|
-
3.
|
|
164
|
-
4.
|
|
165
|
-
5.
|
|
206
|
+
1. Detect if `<devbooks-root>/constitution.md` exists
|
|
207
|
+
2. Detect if `<devbooks-root>/project.md` exists
|
|
208
|
+
3. Detect if `<truth-root>/` is empty or basically empty
|
|
209
|
+
4. Detect if CKB index is available
|
|
210
|
+
5. Detect project scale and language stack
|
|
166
211
|
|
|
167
|
-
###
|
|
212
|
+
### Modes Supported by This Skill
|
|
168
213
|
|
|
169
|
-
|
|
|
170
|
-
|
|
171
|
-
|
|
|
172
|
-
|
|
|
173
|
-
|
|
|
174
|
-
|
|
|
175
|
-
|
|
|
176
|
-
|
|
|
214
|
+
| Mode | Trigger Condition | Behavior |
|
|
215
|
+
|------|-------------------|----------|
|
|
216
|
+
| **Full New Init** | devbooks-root doesn't exist or is empty | Create complete directory structure + constitution + project + profile |
|
|
217
|
+
| **Supplement Config** | constitution/project missing | Only supplement missing configuration files |
|
|
218
|
+
| **Complete Init** | truth-root is empty | Generate all basic artifacts (profile/baseline/verification) |
|
|
219
|
+
| **Incremental Init** | truth-root partially exists | Only supplement missing artifacts |
|
|
220
|
+
| **Enhanced Mode** | CKB index available | Use graph analysis to generate more precise profile |
|
|
221
|
+
| **Basic Mode** | CKB index unavailable | Use traditional analysis methods |
|
|
177
222
|
|
|
178
|
-
###
|
|
223
|
+
### Detection Output Example
|
|
179
224
|
|
|
180
225
|
```
|
|
181
|
-
|
|
182
|
-
- devbooks-root
|
|
183
|
-
- constitution.md
|
|
184
|
-
- project.md
|
|
185
|
-
- truth-root
|
|
186
|
-
- CKB
|
|
187
|
-
-
|
|
188
|
-
-
|
|
226
|
+
Detection Results:
|
|
227
|
+
- devbooks-root: Exists
|
|
228
|
+
- constitution.md: Doesn't exist → Will create
|
|
229
|
+
- project.md: Doesn't exist → Will create
|
|
230
|
+
- truth-root: Empty
|
|
231
|
+
- CKB index: Available
|
|
232
|
+
- Project scale: Medium (~50K LOC)
|
|
233
|
+
- Running mode: Supplement Config + Complete Init + Enhanced Mode
|
|
189
234
|
```
|
|
190
235
|
|
|
191
236
|
---
|
|
192
237
|
|
|
193
|
-
## MCP
|
|
238
|
+
## MCP Enhancement
|
|
194
239
|
|
|
195
|
-
|
|
240
|
+
This Skill supports MCP runtime enhancement, automatically detecting and enabling advanced features.
|
|
196
241
|
|
|
197
|
-
MCP
|
|
242
|
+
MCP enhancement rules reference: `skills/_shared/mcp-enhancement-template.md`
|
|
198
243
|
|
|
199
|
-
###
|
|
244
|
+
### Required MCP Services
|
|
200
245
|
|
|
201
|
-
|
|
|
202
|
-
|
|
203
|
-
| `mcp__ckb__getStatus` |
|
|
204
|
-
| `mcp__ckb__getArchitecture` |
|
|
205
|
-
| `mcp__ckb__getHotspots` |
|
|
206
|
-
| `mcp__ckb__listKeyConcepts` |
|
|
207
|
-
| `mcp__ckb__getModuleOverview` |
|
|
246
|
+
| Service | Purpose | Timeout |
|
|
247
|
+
|---------|---------|---------|
|
|
248
|
+
| `mcp__ckb__getStatus` | Detect CKB index availability | 2s |
|
|
249
|
+
| `mcp__ckb__getArchitecture` | Get module dependency graph | 2s |
|
|
250
|
+
| `mcp__ckb__getHotspots` | Get technical debt hotspots | 2s |
|
|
251
|
+
| `mcp__ckb__listKeyConcepts` | Get domain concepts | 2s |
|
|
252
|
+
| `mcp__ckb__getModuleOverview` | Get module overview | 2s |
|
|
208
253
|
|
|
209
|
-
###
|
|
254
|
+
### Detection Flow
|
|
210
255
|
|
|
211
|
-
1.
|
|
212
|
-
2.
|
|
213
|
-
3.
|
|
256
|
+
1. Call `mcp__ckb__getStatus` (2s timeout)
|
|
257
|
+
2. If CKB available → Use graph-based analysis to generate COD artifacts
|
|
258
|
+
3. If timeout or failure → Degrade to traditional analysis (Git history + file statistics)
|
|
214
259
|
|
|
215
|
-
###
|
|
260
|
+
### Enhanced Mode vs Basic Mode
|
|
216
261
|
|
|
217
|
-
|
|
|
218
|
-
|
|
219
|
-
|
|
|
220
|
-
|
|
|
221
|
-
|
|
|
222
|
-
|
|
|
262
|
+
| Feature | Enhanced Mode | Basic Mode |
|
|
263
|
+
|---------|---------------|------------|
|
|
264
|
+
| Module dependency graph | CKB getArchitecture | Directory structure inference |
|
|
265
|
+
| Technical debt hotspots | CKB getHotspots | Git log statistics |
|
|
266
|
+
| Domain concepts | CKB listKeyConcepts | Naming analysis |
|
|
267
|
+
| Boundary identification | Precise module boundaries | Directory conventions |
|
|
223
268
|
|
|
224
|
-
###
|
|
269
|
+
### Degradation Notice
|
|
225
270
|
|
|
226
|
-
|
|
271
|
+
When MCP is unavailable, output the following notice:
|
|
227
272
|
|
|
228
273
|
```
|
|
229
|
-
|
|
230
|
-
|
|
274
|
+
Warning: CKB unavailable, using traditional analysis methods to generate project profile.
|
|
275
|
+
For more precise architecture analysis, run devbooks-index-bootstrap skill to generate index.
|
|
231
276
|
```
|
|
@@ -35,7 +35,7 @@ Before execution, **must** search for configuration in the following order (stop
|
|
|
35
35
|
- Code formatting
|
|
36
36
|
|
|
37
37
|
### 2. Dependency Health Review
|
|
38
|
-
- Layer constraint compliance (see
|
|
38
|
+
- Layer constraint compliance (see `<truth-root>/architecture/c4.md`)
|
|
39
39
|
- Circular dependency detection
|
|
40
40
|
- Internal module encapsulation (prohibit deep imports of *Internal files)
|
|
41
41
|
- Dependency direction correctness
|
|
@@ -74,6 +74,81 @@ The following change types **require** updating corresponding documentation:
|
|
|
74
74
|
| New commands/CLI parameters | User guide |
|
|
75
75
|
| External API changes | API documentation |
|
|
76
76
|
|
|
77
|
+
## Architecture Impact Statement (Required)
|
|
78
|
+
|
|
79
|
+
Design documents **must** include an "Architecture Impact" section declaring the impact of this change on system architecture. This is a key mechanism to ensure architecture changes go through verification closed-loops.
|
|
80
|
+
|
|
81
|
+
> **Design Decision**: C4 architecture changes are no longer written directly to the truth directory by a standalone `devbooks-c4-map` skill. Instead, they are part of design.md and merged into truth by `devbooks-spec-gardener` after change acceptance.
|
|
82
|
+
|
|
83
|
+
### Template
|
|
84
|
+
|
|
85
|
+
```markdown
|
|
86
|
+
## Architecture Impact
|
|
87
|
+
|
|
88
|
+
<!-- Required: Choose one of the following -->
|
|
89
|
+
|
|
90
|
+
### No Architecture Changes
|
|
91
|
+
|
|
92
|
+
- [x] This change does not affect module boundaries, dependency directions, or component structure
|
|
93
|
+
- Reason: <Brief explanation of why there's no architecture impact>
|
|
94
|
+
|
|
95
|
+
### Has Architecture Changes
|
|
96
|
+
|
|
97
|
+
#### C4 Level Impact
|
|
98
|
+
|
|
99
|
+
| Level | Change Type | Impact Description |
|
|
100
|
+
|-------|-------------|-------------------|
|
|
101
|
+
| Context | None / Add / Modify / Delete | <description> |
|
|
102
|
+
| Container | None / Add / Modify / Delete | <description> |
|
|
103
|
+
| Component | None / Add / Modify / Delete | <description> |
|
|
104
|
+
|
|
105
|
+
#### Container Changes
|
|
106
|
+
|
|
107
|
+
- [Add/Modify/Delete] `<container-name>`: <change description>
|
|
108
|
+
|
|
109
|
+
#### Component Changes
|
|
110
|
+
|
|
111
|
+
- [Add/Modify/Delete] `<component-name>` in `<container>`: <change description>
|
|
112
|
+
|
|
113
|
+
#### Dependency Changes
|
|
114
|
+
|
|
115
|
+
| Source | Target | Change Type | Notes |
|
|
116
|
+
|--------|--------|-------------|-------|
|
|
117
|
+
| `<source>` | `<target>` | Add/Delete/Direction Change | <notes> |
|
|
118
|
+
|
|
119
|
+
#### Layering Constraint Impact
|
|
120
|
+
|
|
121
|
+
- [ ] This change follows existing layering constraints
|
|
122
|
+
- [ ] This change requires modifying layering constraints (explain below)
|
|
123
|
+
|
|
124
|
+
Layering constraint modification notes: <if any>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Detection Rules
|
|
128
|
+
|
|
129
|
+
When executing design-doc skill, **must check** the following conditions to determine architecture changes:
|
|
130
|
+
|
|
131
|
+
| Check Item | Detection Method | Has Architecture Change |
|
|
132
|
+
|------------|------------------|------------------------|
|
|
133
|
+
| New/deleted directories | Check changed file paths | May affect module boundaries |
|
|
134
|
+
| Cross-module imports | Check import statement changes | May affect dependency direction |
|
|
135
|
+
| New external dependencies | Check package.json/go.mod etc. | Affects Container level |
|
|
136
|
+
| New services/processes | Check Dockerfile/docker-compose | Affects Container level |
|
|
137
|
+
| New API endpoint groups | Check route definitions | May affect Component level |
|
|
138
|
+
|
|
139
|
+
### Trigger Rules
|
|
140
|
+
|
|
141
|
+
The following change types **require** filling in architecture change details:
|
|
142
|
+
|
|
143
|
+
| Change Type | Requirement |
|
|
144
|
+
|-------------|-------------|
|
|
145
|
+
| New module/directory | Must describe Component changes |
|
|
146
|
+
| New service/container | Must describe Container changes |
|
|
147
|
+
| Modified inter-module dependencies | Must describe dependency changes |
|
|
148
|
+
| Introduced new external system | Must describe Context changes |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
77
152
|
## Execution Method
|
|
78
153
|
|
|
79
154
|
1) First read and follow: `_shared/references/universal-gating-protocol.md` (verifiability + structural quality gates).
|
|
@@ -108,7 +108,7 @@ impact_profile:
|
|
|
108
108
|
| Impact Field | Value | Auto-Append Skill |
|
|
109
109
|
|--------------|-------|-------------------|
|
|
110
110
|
| `external_api: true` | - | `devbooks-spec-contract` |
|
|
111
|
-
| `architecture_boundary: true` | - | `devbooks-
|
|
111
|
+
| `architecture_boundary: true` | - | `devbooks-design-doc` (ensure Architecture Impact section is complete) |
|
|
112
112
|
| `cross_repo: true` | - | `devbooks-federation` |
|
|
113
113
|
| `risk_level: high` | - | `devbooks-proposal-debate-workflow` |
|
|
114
114
|
| `affected_modules` count > 5 | - | `devbooks-impact-analysis` (deep analysis) |
|
|
@@ -125,7 +125,7 @@ impact_profile:
|
|
|
125
125
|
|
|
126
126
|
### Recommended (Based on Impact Analysis)
|
|
127
127
|
4. `devbooks-spec-contract skill` → specs/** (detected external_api: true)
|
|
128
|
-
5. `devbooks-
|
|
128
|
+
5. `devbooks-design-doc skill` → design.md Architecture Impact section (detected architecture_boundary: true)
|
|
129
129
|
|
|
130
130
|
### Optional
|
|
131
131
|
6. `devbooks-impact-analysis skill` → Deep impact analysis (affected_modules > 5)
|
|
@@ -182,7 +182,7 @@ Append as needed (add only when conditions are met):
|
|
|
182
182
|
- **Obvious risks/controversies/trade-offs**: `devbooks-proposal-debate-workflow` (Author/Challenger/Judge, write back to Decision Log after debate)
|
|
183
183
|
- **External behavior/contract/data invariant changes**: `devbooks-spec-contract` → `(<change-root>/<change-id>/specs/**)` + `design.md` Contract section
|
|
184
184
|
- If you need "deterministic spec delta file creation/avoid path errors": `change-spec-delta-scaffold.sh <change-id> <capability> ...`
|
|
185
|
-
- **Module boundary/dependency direction/architecture shape changes**: `devbooks-
|
|
185
|
+
- **Module boundary/dependency direction/architecture shape changes**: Ensure `devbooks-design-doc` outputs complete Architecture Impact section → merged to `(<truth-root>/architecture/c4.md)` by `devbooks-spec-gardener` during archiving
|
|
186
186
|
|
|
187
187
|
Hard constraint reminders:
|
|
188
188
|
- Proposal phase prohibits writing implementation code; implementation happens in apply phase with tests/gates as completion criteria.
|
|
@@ -27,6 +27,62 @@ Before execution, **must** search for configuration in the following order (stop
|
|
|
27
27
|
- Do not guess directory roots
|
|
28
28
|
- Do not skip reading the rules document
|
|
29
29
|
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Core Responsibilities
|
|
33
|
+
|
|
34
|
+
### 1. Spec Merge and Maintenance
|
|
35
|
+
|
|
36
|
+
During archive phase, merge change package spec artifacts into `<truth-root>`:
|
|
37
|
+
|
|
38
|
+
| Source Path | Target Path | Merge Strategy |
|
|
39
|
+
|-------------|-------------|----------------|
|
|
40
|
+
| `<change-root>/<change-id>/specs/**` | `<truth-root>/specs/**` | Incremental merge |
|
|
41
|
+
| `<change-root>/<change-id>/contracts/**` | `<truth-root>/contracts/**` | Versioned merge |
|
|
42
|
+
|
|
43
|
+
### 2. C4 Architecture Map Merge (New)
|
|
44
|
+
|
|
45
|
+
> **Design Decision**: C4 architecture changes are now recorded in design.md's Architecture Impact section and merged into truth by spec-gardener during archiving.
|
|
46
|
+
|
|
47
|
+
During archive phase, detect and merge architecture changes:
|
|
48
|
+
|
|
49
|
+
| Detection Source | Target Path | Merge Logic |
|
|
50
|
+
|------------------|-------------|-------------|
|
|
51
|
+
| "Architecture Impact" section in `<change-root>/<change-id>/design.md` | `<truth-root>/architecture/c4.md` | Incremental update |
|
|
52
|
+
|
|
53
|
+
**C4 Merge Flow**:
|
|
54
|
+
|
|
55
|
+
1. **Detect Architecture Changes**: Parse "Architecture Impact" section in `design.md`
|
|
56
|
+
2. **Determine If Merge Needed**:
|
|
57
|
+
- If "No Architecture Changes" is checked → Skip merge
|
|
58
|
+
- If "Has Architecture Changes" → Execute merge
|
|
59
|
+
3. **Execute Merge**:
|
|
60
|
+
- Read `<truth-root>/architecture/c4.md` (create if doesn't exist)
|
|
61
|
+
- Update corresponding sections based on Architecture Impact descriptions
|
|
62
|
+
- Update Container/Component tables
|
|
63
|
+
- Update dependency relationships
|
|
64
|
+
- Update layering constraints (if changed)
|
|
65
|
+
4. **Record Merge Log**: Append change record at end of c4.md
|
|
66
|
+
|
|
67
|
+
**Merge Output Format** (appended to c4.md):
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
## Change History
|
|
71
|
+
|
|
72
|
+
| Date | Change ID | Impact Summary |
|
|
73
|
+
|------|-----------|----------------|
|
|
74
|
+
| <date> | <change-id> | <brief description of architecture changes> |
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. Deduplication and Cleanup
|
|
78
|
+
|
|
79
|
+
Execute in maintenance mode:
|
|
80
|
+
|
|
81
|
+
- Detect duplicate spec definitions
|
|
82
|
+
- Clean up obsolete/deprecated specs
|
|
83
|
+
- Organize directory structure
|
|
84
|
+
- Fix consistency issues
|
|
85
|
+
|
|
30
86
|
## Execution Method
|
|
31
87
|
|
|
32
88
|
1) First read and follow: `_shared/references/universal-gating-protocol.md` (verifiability + structural quality gates).
|
|
@@ -178,7 +178,6 @@ Run devbooks-spec-gardener skill for change add-oauth2
|
|
|
178
178
|
| devbooks-proposal-debate-workflow | Triangle debate (Author/Challenger/Judge) |
|
|
179
179
|
| devbooks-design-doc | Create a design doc |
|
|
180
180
|
| devbooks-spec-contract | Define specs & contracts |
|
|
181
|
-
| devbooks-c4-map | Generate a C4 map |
|
|
182
181
|
| devbooks-implementation-plan | Create an implementation plan |
|
|
183
182
|
|
|
184
183
|
### Apply stage
|
|
@@ -132,8 +132,7 @@ Each change must declare which gates are covered; missing items require reasons:
|
|
|
132
132
|
| Test Owner | `devbooks-test-owner` | `verification.md` + `tests/` |
|
|
133
133
|
| Coder | `devbooks-coder` | Implement per tasks (no tests) |
|
|
134
134
|
| Reviewer | `devbooks-code-review` | Review feedback |
|
|
135
|
-
| Spec Gardener | `devbooks-spec-gardener` | Archive pruning |
|
|
136
|
-
| C4 Map | `devbooks-c4-map` | `architecture/c4.md` |
|
|
135
|
+
| Spec Gardener | `devbooks-spec-gardener` | Archive pruning + C4 merge |
|
|
137
136
|
| Design Backport | `devbooks-design-backport` | Backport design gaps |
|
|
138
137
|
|
|
139
138
|
### Workflow-Based
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: devbooks-c4-map
|
|
3
|
-
description: devbooks-c4-map: Maintain/update the project's C4 architecture map (current truth) and output C4 Delta based on changes. Use when user says "draw architecture diagram/C4/boundaries/dependency direction/module map/architecture map maintenance" etc.
|
|
4
|
-
tools:
|
|
5
|
-
- Glob
|
|
6
|
-
- Grep
|
|
7
|
-
- Read
|
|
8
|
-
- Write
|
|
9
|
-
- Edit
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# DevBooks: C4 Architecture Map
|
|
13
|
-
|
|
14
|
-
## Prerequisites: Configuration Discovery (Protocol Agnostic)
|
|
15
|
-
|
|
16
|
-
- `<truth-root>`: Current truth directory root
|
|
17
|
-
- `<change-root>`: Change package directory root
|
|
18
|
-
|
|
19
|
-
Before execution, **must** search for configuration in the following order (stop when found):
|
|
20
|
-
1. `.devbooks/config.yaml` (if exists) → Parse and use the mappings within
|
|
21
|
-
2. `dev-playbooks/project.md` (if exists) → DevBooks 2.0 protocol, use default mappings
|
|
22
|
-
4. `project.md` (if exists) → template protocol, use default mappings
|
|
23
|
-
5. If still unable to determine → **Stop and ask the user**
|
|
24
|
-
|
|
25
|
-
**Key Constraints**:
|
|
26
|
-
- If `agents_doc` (rules document) is specified in the configuration, **must read that document first** before executing any operations
|
|
27
|
-
- Do not guess directory roots
|
|
28
|
-
- Do not skip reading the rules document
|
|
29
|
-
|
|
30
|
-
## Artifact Locations
|
|
31
|
-
|
|
32
|
-
- Authoritative C4 map: `<truth-root>/architecture/c4.md`
|
|
33
|
-
- Layering constraints definition: `<truth-root>/architecture/layering-constraints.md` (optional)
|
|
34
|
-
|
|
35
|
-
## Layering Dependency Constraints
|
|
36
|
-
|
|
37
|
-
Drawing from VS Code's layering architecture enforcement mechanism, the C4 map should include a **Layering Constraints** section:
|
|
38
|
-
|
|
39
|
-
### Layering Constraint Definition Rules
|
|
40
|
-
|
|
41
|
-
1. **Unidirectional Dependency Principle**: Upper layers may depend on lower layers; lower layers are prohibited from depending on upper layers
|
|
42
|
-
- Example: `base ← platform ← domain ← application ← ui`
|
|
43
|
-
- Arrow direction indicates "dependency direction"
|
|
44
|
-
|
|
45
|
-
2. **Environment Isolation Principle**: The `common` layer can only be referenced by `browser`/`node` layers, not the reverse
|
|
46
|
-
- `common`: Platform-agnostic code
|
|
47
|
-
- `browser`: Browser-specific code (DOM API)
|
|
48
|
-
- `node`: Node.js-specific code (fs, process)
|
|
49
|
-
|
|
50
|
-
3. **Contrib Reverse Isolation**: Contribution modules can only depend on core; core is prohibited from depending on contribution modules
|
|
51
|
-
- Example: `workbench/contrib/*` → `workbench/core` (allowed)
|
|
52
|
-
- Example: `workbench/core` → `workbench/contrib/*` (prohibited)
|
|
53
|
-
|
|
54
|
-
### Layering Constraints Output Format
|
|
55
|
-
|
|
56
|
-
The `## Architecture Guardrails` section in `c4.md` must include:
|
|
57
|
-
|
|
58
|
-
```markdown
|
|
59
|
-
### Layering Constraints
|
|
60
|
-
|
|
61
|
-
| Layer | May Depend On | Prohibited Dependencies |
|
|
62
|
-
|-------|---------------|------------------------|
|
|
63
|
-
| base | (none) | platform, domain, application, ui |
|
|
64
|
-
| platform | base | domain, application, ui |
|
|
65
|
-
| domain | base, platform | application, ui |
|
|
66
|
-
| application | base, platform, domain | ui |
|
|
67
|
-
| ui | base, platform, domain, application | (none) |
|
|
68
|
-
|
|
69
|
-
### Environment Constraints
|
|
70
|
-
|
|
71
|
-
| Environment | May Reference | Prohibited References |
|
|
72
|
-
|-------------|---------------|----------------------|
|
|
73
|
-
| common | (platform-agnostic libraries) | browser/*, node/* |
|
|
74
|
-
| browser | common/* | node/* |
|
|
75
|
-
| node | common/* | browser/* |
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Execution Method
|
|
79
|
-
|
|
80
|
-
1) First read and follow: `_shared/references/universal-gating-protocol.md` (verifiability + structural quality gating).
|
|
81
|
-
2) Strictly follow the complete prompt output: `references/c4-architecture-map-prompt.md`.
|
|
82
|
-
3) Reference the layering constraints checklist: `references/layered-constraint-checklist.md`.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## Context Awareness
|
|
87
|
-
|
|
88
|
-
This Skill automatically detects context before execution and selects the appropriate running mode.
|
|
89
|
-
|
|
90
|
-
Detection rules reference: `skills/_shared/context-detection-template.md`
|
|
91
|
-
|
|
92
|
-
### Detection Flow
|
|
93
|
-
|
|
94
|
-
1. Detect whether `<truth-root>/architecture/c4.md` exists
|
|
95
|
-
2. If change-id is provided, detect whether there are C4-related changes
|
|
96
|
-
3. Select running mode based on detection results
|
|
97
|
-
|
|
98
|
-
### Modes Supported by This Skill
|
|
99
|
-
|
|
100
|
-
| Mode | Trigger Condition | Behavior |
|
|
101
|
-
|------|-------------------|----------|
|
|
102
|
-
| **Create Mode** | `c4.md` does not exist | Analyze codebase, generate complete C4 diagrams at all levels (Context/Container/Component) |
|
|
103
|
-
| **Update Mode** | `c4.md` exists, changes need to be reflected | Read change content, output C4 Delta, update architecture diagram |
|
|
104
|
-
|
|
105
|
-
### Detection Output Example
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
Detection Results:
|
|
109
|
-
- Artifact existence: c4.md exists
|
|
110
|
-
- Change impact: Component-level changes detected (added templates/claude-commands/devbooks/ 15 files)
|
|
111
|
-
- Running mode: Update mode
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
## MCP Enhancement
|
|
117
|
-
|
|
118
|
-
This Skill supports MCP runtime enhancement, automatically detecting and enabling advanced features.
|
|
119
|
-
|
|
120
|
-
MCP enhancement rules reference: `skills/_shared/mcp-enhancement-template.md`
|
|
121
|
-
|
|
122
|
-
### Required MCP Services
|
|
123
|
-
|
|
124
|
-
| Service | Purpose | Timeout |
|
|
125
|
-
|---------|---------|---------|
|
|
126
|
-
| `mcp__ckb__getArchitecture` | Get module dependency graph | 2s |
|
|
127
|
-
| `mcp__ckb__getStatus` | Detect CKB index availability | 2s |
|
|
128
|
-
|
|
129
|
-
### Detection Flow
|
|
130
|
-
|
|
131
|
-
1. Call `mcp__ckb__getStatus` (2s timeout)
|
|
132
|
-
2. If CKB available → Call `mcp__ckb__getArchitecture` to get precise module dependencies
|
|
133
|
-
3. If timeout or failure → Fall back to directory structure-based inference
|
|
134
|
-
|
|
135
|
-
### Enhanced Mode vs Basic Mode
|
|
136
|
-
|
|
137
|
-
| Feature | Enhanced Mode | Basic Mode |
|
|
138
|
-
|---------|---------------|------------|
|
|
139
|
-
| Module identification | CKB precise boundaries | Directory structure inference |
|
|
140
|
-
| Dependency direction | Symbol-level analysis | Import statement matching |
|
|
141
|
-
| Cycle detection | Precise detection | Heuristic detection |
|
|
142
|
-
|
|
143
|
-
### Fallback Notice
|
|
144
|
-
|
|
145
|
-
When MCP is unavailable, output the following notice:
|
|
146
|
-
|
|
147
|
-
```
|
|
148
|
-
Warning: CKB unavailable, using directory structure to infer architecture.
|
|
149
|
-
Generated C4 diagrams may not be precise. Recommend running devbooks-index-bootstrap skill to generate index.
|
|
150
|
-
```
|
|
151
|
-
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# C4 Architecture Map Prompt
|
|
2
|
-
|
|
3
|
-
> **Role**: You are the strongest “architecture visualization brain” — combining the knowledge of Simon Brown (C4 model), Martin Fowler (architecture patterns), and Gregor Hohpe (enterprise integration). Your architecture map must meet that expert level.
|
|
4
|
-
|
|
5
|
-
Highest-priority instruction:
|
|
6
|
-
- Before executing this prompt, read `_shared/references/universal-gating-protocol.md` and follow all protocols in it.
|
|
7
|
-
|
|
8
|
-
You are the **C4 Map Maintainer**. Your goal is to maintain a **stable architecture map (Current Truth)** for a large project using C4 (Context/Container/Component), and ensure it provides actionable input for impact analysis, task decomposition, and architecture guardrails (fitness tests).
|
|
9
|
-
|
|
10
|
-
Key viewpoints:
|
|
11
|
-
- The “authoritative” C4 map should not be scattered across per-change design docs; it is a cross-change “current truth map”.
|
|
12
|
-
- Each change’s design doc should only include a **C4 Delta** (what is added/modified/removed), and the change package should include tasks to update the authoritative map.
|
|
13
|
-
|
|
14
|
-
Recommended location (not external-facing docs):
|
|
15
|
-
- Keep the authoritative C4 map in the “truth root”, for example:
|
|
16
|
-
- `<truth-root>/architecture/c4.md` (or an equivalent location you choose)
|
|
17
|
-
|
|
18
|
-
Inputs (provided by me):
|
|
19
|
-
- The current C4 map (if it exists)
|
|
20
|
-
- Current specs: `<truth-root>/`
|
|
21
|
-
- The design doc for this change: `<change-root>/<change-id>/design.md` (if this is an architecture change)
|
|
22
|
-
|
|
23
|
-
Output format (MECE):
|
|
24
|
-
1) C1: System Context (system boundary, external systems, primary users)
|
|
25
|
-
2) C2: Container (major containers/services/apps, interfaces and dependency direction)
|
|
26
|
-
3) C3: Component (expand only key containers; keep minimal)
|
|
27
|
-
4) Architecture Guardrails (recommended fitness tests, e.g., layering / no cycles / no boundary violations)
|
|
28
|
-
|
|
29
|
-
Diagram requirements:
|
|
30
|
-
- Mermaid is allowed; prefer text-readable expressions (avoid over-styling).
|
|
31
|
-
- Do not cover every detail; the goal is to align on boundaries and dependency direction.
|
|
32
|
-
|
|
33
|
-
Now output the C4 map in Markdown. Do not output extra explanations.
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
# Layering Constraints Checklist
|
|
2
|
-
|
|
3
|
-
Inspired by VS Code’s `code-layering.ts` and `layersChecker.ts`, this document defines practical checks for a layered architecture.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1) Layer Dependency Checks
|
|
8
|
-
|
|
9
|
-
### 1.1 Unidirectional Dependency Violations
|
|
10
|
-
|
|
11
|
-
**How to check**: scan `import`/`require` statements and validate dependency direction.
|
|
12
|
-
|
|
13
|
-
```typescript
|
|
14
|
-
// Violation: base layer importing platform layer
|
|
15
|
-
// src/base/utils.ts
|
|
16
|
-
import { ConfigService } from '../platform/config'; // ❌ violation
|
|
17
|
-
|
|
18
|
-
// Correct: platform layer importing base layer
|
|
19
|
-
// src/platform/config.ts
|
|
20
|
-
import { deepClone } from '../base/utils'; // ✅ allowed
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
**Example commands** (grep/rg):
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
# Check whether base illegally imports platform
|
|
27
|
-
rg "from ['\"].*platform" src/base/ --type ts
|
|
28
|
-
|
|
29
|
-
# Check whether common illegally imports browser/node
|
|
30
|
-
rg "from ['\"].*(browser|node)" src/common/ --type ts
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### 1.2 Environment Isolation Violations
|
|
34
|
-
|
|
35
|
-
| Environment | Forbidden APIs | Detection regex |
|
|
36
|
-
|------|-----------|---------|
|
|
37
|
-
| common | DOM API | `document\.|window\.|navigator\.` |
|
|
38
|
-
| common | Node API | `require\(['"]fs['"]\)|process\.|__dirname` |
|
|
39
|
-
| browser | Node API | `require\(['"]fs['"]\)|child_process` |
|
|
40
|
-
| node | DOM API | `document\.|window\.|DOM\.` |
|
|
41
|
-
|
|
42
|
-
### 1.3 contrib Reverse-Dependency Checks
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
# Check whether core illegally imports contrib
|
|
46
|
-
rg "from ['\"].*contrib" src/core/ --type ts
|
|
47
|
-
rg "from ['\"].*contrib" src/workbench/services/ --type ts
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
---
|
|
51
|
-
|
|
52
|
-
## 2) Layering Constraints Template
|
|
53
|
-
|
|
54
|
-
Add this to `<truth-root>/architecture/c4.md`:
|
|
55
|
-
|
|
56
|
-
```markdown
|
|
57
|
-
## Architecture Guardrails
|
|
58
|
-
|
|
59
|
-
### Layering Constraints
|
|
60
|
-
|
|
61
|
-
This project uses an N-layer architecture with dependency direction: `base ← platform ← domain ← application ← ui`
|
|
62
|
-
|
|
63
|
-
| Layer | Directory | Responsibility | Allowed deps | Forbidden deps |
|
|
64
|
-
|------|------|------|--------|----------|
|
|
65
|
-
| base | src/base/ | Utilities, cross-platform abstractions | (none) | all other layers |
|
|
66
|
-
| platform | src/platform/ | Platform services, dependency injection | base | domain, app, ui |
|
|
67
|
-
| domain | src/domain/ | Business logic, domain model | base, platform | app, ui |
|
|
68
|
-
| application | src/app/ | App services, use-case orchestration | base, platform, domain | ui |
|
|
69
|
-
| ui | src/ui/ | User interface, interaction logic | all layers | (none) |
|
|
70
|
-
|
|
71
|
-
### Environment Constraints
|
|
72
|
-
|
|
73
|
-
| Environment directory | Allowed | Forbidden |
|
|
74
|
-
|----------|--------|----------|
|
|
75
|
-
| */common/ | platform-agnostic libs | */browser/*, */node/* |
|
|
76
|
-
| */browser/ | */common/* | */node/* |
|
|
77
|
-
| */node/ | */common/* | */browser/* |
|
|
78
|
-
|
|
79
|
-
### Validation Commands
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# Layering violations check
|
|
83
|
-
npm run valid-layers-check
|
|
84
|
-
|
|
85
|
-
# Or check manually
|
|
86
|
-
rg "from ['\"].*platform" src/base/ --type ts && echo "FAIL: base→platform" || echo "OK"
|
|
87
|
-
```
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## 3) Severity Levels for Layering Violations
|
|
93
|
-
|
|
94
|
-
| Violation type | Severity | Handling |
|
|
95
|
-
|----------|----------|----------|
|
|
96
|
-
| Lower layer depends on upper layer | **Critical** | must fix immediately; block merge |
|
|
97
|
-
| common depends on browser/node | **Critical** | must fix immediately |
|
|
98
|
-
| Cross-layer deep import of Internal modules | **High** | use public APIs instead |
|
|
99
|
-
| core depends on contrib | **High** | violates extension-point design |
|
|
100
|
-
| Cyclic dependencies | **High** | requires refactoring/decoupling |
|
|
101
|
-
|
|
102
|
-
---
|
|
103
|
-
|
|
104
|
-
## 4) Integrating Layer Checks
|
|
105
|
-
|
|
106
|
-
### 4.1 Configure in ESLint (recommended)
|
|
107
|
-
|
|
108
|
-
```javascript
|
|
109
|
-
// eslint.config.js
|
|
110
|
-
module.exports = {
|
|
111
|
-
rules: {
|
|
112
|
-
'import/no-restricted-paths': ['error', {
|
|
113
|
-
zones: [
|
|
114
|
-
// base must not import platform
|
|
115
|
-
{ target: './src/base', from: './src/platform', message: 'base cannot import platform' },
|
|
116
|
-
// platform must not import domain
|
|
117
|
-
{ target: './src/platform', from: './src/domain', message: 'platform cannot import domain' },
|
|
118
|
-
// common must not import browser/node
|
|
119
|
-
{ target: './src/**/common', from: './src/**/browser', message: 'common cannot import browser' },
|
|
120
|
-
{ target: './src/**/common', from: './src/**/node', message: 'common cannot import node' },
|
|
121
|
-
]
|
|
122
|
-
}]
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### 4.2 Configure in TypeScript
|
|
128
|
-
|
|
129
|
-
Create a separate `tsconfig` for each layer:
|
|
130
|
-
|
|
131
|
-
```json
|
|
132
|
-
// tsconfig.base.json
|
|
133
|
-
{
|
|
134
|
-
"compilerOptions": {
|
|
135
|
-
"paths": {
|
|
136
|
-
// base layer can only see itself
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
"include": ["src/base/**/*"],
|
|
140
|
-
"exclude": ["src/platform/**/*", "src/domain/**/*"]
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
### 4.3 Configure in CI
|
|
145
|
-
|
|
146
|
-
```yaml
|
|
147
|
-
# .github/workflows/pr.yml
|
|
148
|
-
- name: Check layer constraints
|
|
149
|
-
run: |
|
|
150
|
-
# Check for layering violations
|
|
151
|
-
./scripts/valid-layers-check.sh || exit 1
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## 5) Layering Refactoring Guide
|
|
157
|
-
|
|
158
|
-
When a layering violation is found:
|
|
159
|
-
|
|
160
|
-
1. **Identify the reason**
|
|
161
|
-
- Is the dependency actually legitimate? (You may need to adjust the layering definition.)
|
|
162
|
-
- Can you decouple via interface abstractions?
|
|
163
|
-
- Should the code be moved to the correct layer?
|
|
164
|
-
|
|
165
|
-
2. **Decoupling strategies**
|
|
166
|
-
- **Dependency injection**: upper layers inject interfaces; lower layers do not depend on implementations
|
|
167
|
-
- **Events**: lower layers publish events; upper layers subscribe
|
|
168
|
-
- **Callbacks**: lower layers accept callback functions and avoid knowing callers
|
|
169
|
-
|
|
170
|
-
3. **Code movement**
|
|
171
|
-
- If the code belongs in a lower layer, move it to the correct location
|
|
172
|
-
- Update all import paths
|
|
173
|
-
- Run layer checks to confirm the fix
|
|
174
|
-
|
|
175
|
-
---
|
|
176
|
-
|
|
177
|
-
## 6) Review Checklist
|
|
178
|
-
|
|
179
|
-
During code review, check:
|
|
180
|
-
|
|
181
|
-
- [ ] Do new imports follow layer constraints?
|
|
182
|
-
- [ ] Are there deep imports into Internal modules?
|
|
183
|
-
- [ ] Does code under `common/` use platform-specific APIs?
|
|
184
|
-
- [ ] Does `core` import `contrib`?
|
|
185
|
-
- [ ] Are there cyclic dependencies?
|