kiro-spec-engine 1.4.3 → 1.5.2
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/CHANGELOG.md +86 -4
- package/README.md +16 -0
- package/README.zh.md +380 -0
- package/bin/kiro-spec-engine.js +102 -44
- package/docs/adoption-guide.md +53 -0
- package/docs/document-governance.md +864 -0
- package/docs/spec-numbering-guide.md +348 -0
- package/docs/spec-workflow.md +65 -0
- package/docs/troubleshooting.md +339 -0
- package/docs/zh/spec-numbering-guide.md +348 -0
- package/lib/adoption/adoption-strategy.js +22 -6
- package/lib/adoption/conflict-resolver.js +239 -0
- package/lib/adoption/diff-viewer.js +226 -0
- package/lib/backup/selective-backup.js +207 -0
- package/lib/commands/adopt.js +95 -10
- package/lib/commands/docs.js +717 -0
- package/lib/commands/doctor.js +141 -3
- package/lib/commands/status.js +77 -5
- package/lib/governance/archive-tool.js +231 -0
- package/lib/governance/cleanup-tool.js +237 -0
- package/lib/governance/config-manager.js +186 -0
- package/lib/governance/diagnostic-engine.js +271 -0
- package/lib/governance/execution-logger.js +243 -0
- package/lib/governance/file-scanner.js +285 -0
- package/lib/governance/hooks-manager.js +333 -0
- package/lib/governance/reporter.js +337 -0
- package/lib/governance/validation-engine.js +181 -0
- package/package.json +7 -7
|
@@ -0,0 +1,864 @@
|
|
|
1
|
+
# Document Governance Guide
|
|
2
|
+
|
|
3
|
+
> Automated document lifecycle management for kse projects
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Version**: 1.0.0
|
|
8
|
+
**Last Updated**: 2026-01-24
|
|
9
|
+
**Audience**: All Users
|
|
10
|
+
**Estimated Time**: 15 minutes
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
The **Document Governance System** automatically enforces document lifecycle management rules in your kse project. It helps you maintain clean, well-organized documentation by detecting violations, cleaning up temporary files, validating structure, and organizing artifacts.
|
|
17
|
+
|
|
18
|
+
### What is Document Governance?
|
|
19
|
+
|
|
20
|
+
Document governance ensures your project follows these rules:
|
|
21
|
+
|
|
22
|
+
1. **Root Directory** - Only 4 markdown files allowed: `README.md`, `README.zh.md`, `CHANGELOG.md`, `CONTRIBUTING.md`
|
|
23
|
+
2. **Spec Structure** - Each Spec must have `requirements.md`, `design.md`, `tasks.md`
|
|
24
|
+
3. **Artifact Organization** - Spec artifacts must be in subdirectories: `reports/`, `scripts/`, `tests/`, `results/`, `docs/`
|
|
25
|
+
4. **No Temporary Files** - Temporary documents (like `*-SUMMARY.md`, `SESSION-*.md`) must be deleted after use
|
|
26
|
+
|
|
27
|
+
### Why Use Document Governance?
|
|
28
|
+
|
|
29
|
+
- ✅ **Maintain Clean Structure** - Prevent document clutter
|
|
30
|
+
- ✅ **Enforce Standards** - Consistent documentation across projects
|
|
31
|
+
- ✅ **Automate Cleanup** - Remove temporary files automatically
|
|
32
|
+
- ✅ **Prevent Violations** - Git hooks block non-compliant commits
|
|
33
|
+
- ✅ **Track Compliance** - Statistics and reports over time
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
38
|
+
|
|
39
|
+
### 1. Check Your Project's Compliance
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
kse docs diagnose
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Output:**
|
|
46
|
+
```
|
|
47
|
+
🔥 Document Governance Diagnostic
|
|
48
|
+
|
|
49
|
+
⚠️ Found 3 violation(s)
|
|
50
|
+
|
|
51
|
+
Root Violations (2)
|
|
52
|
+
❌ /project/MVP-PLAN.md
|
|
53
|
+
Unexpected markdown file in root directory
|
|
54
|
+
→ Move to appropriate Spec or delete if temporary
|
|
55
|
+
|
|
56
|
+
❌ /project/SESSION-2024-01-20.md
|
|
57
|
+
Temporary document should be deleted
|
|
58
|
+
→ Delete this file (temporary session notes)
|
|
59
|
+
|
|
60
|
+
Spec Violations (1)
|
|
61
|
+
⚠️ /project/.kiro/specs/01-00-user-login/analysis-report.md
|
|
62
|
+
Artifact not in subdirectory
|
|
63
|
+
→ Move to reports/ subdirectory
|
|
64
|
+
|
|
65
|
+
💡 Recommended Actions
|
|
66
|
+
• Run 'kse docs cleanup' to remove temporary files
|
|
67
|
+
• Run 'kse docs archive --spec 01-00-user-login' to organize artifacts
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 2. Clean Up Temporary Files
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
# Preview what would be deleted
|
|
74
|
+
kse docs cleanup --dry-run
|
|
75
|
+
|
|
76
|
+
# Actually delete temporary files
|
|
77
|
+
kse docs cleanup
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 3. Organize Spec Artifacts
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Preview what would be moved
|
|
84
|
+
kse docs archive --spec 01-00-user-login --dry-run
|
|
85
|
+
|
|
86
|
+
# Actually move artifacts to subdirectories
|
|
87
|
+
kse docs archive --spec 01-00-user-login
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### 4. Validate Structure
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Validate root directory
|
|
94
|
+
kse docs validate
|
|
95
|
+
|
|
96
|
+
# Validate all Specs
|
|
97
|
+
kse docs validate --all
|
|
98
|
+
|
|
99
|
+
# Validate specific Spec
|
|
100
|
+
kse docs validate --spec 01-00-user-login
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 5. Prevent Future Violations
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Install Git pre-commit hook
|
|
107
|
+
kse docs hooks install
|
|
108
|
+
|
|
109
|
+
# Now commits will be blocked if violations exist
|
|
110
|
+
git commit -m "Add feature"
|
|
111
|
+
# → Validation runs automatically
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Commands Reference
|
|
117
|
+
|
|
118
|
+
### `kse docs diagnose`
|
|
119
|
+
|
|
120
|
+
Scan your project for document violations.
|
|
121
|
+
|
|
122
|
+
**Usage:**
|
|
123
|
+
```bash
|
|
124
|
+
kse docs diagnose
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**What it checks:**
|
|
128
|
+
- Root directory for non-allowed markdown files
|
|
129
|
+
- Root directory for temporary documents
|
|
130
|
+
- Spec directories for missing required files
|
|
131
|
+
- Spec directories for misplaced artifacts
|
|
132
|
+
- Spec directories for temporary documents
|
|
133
|
+
|
|
134
|
+
**Output:**
|
|
135
|
+
- List of all violations with locations
|
|
136
|
+
- Severity level (error, warning, info)
|
|
137
|
+
- Specific recommendations for each violation
|
|
138
|
+
- Summary statistics
|
|
139
|
+
|
|
140
|
+
**Exit codes:**
|
|
141
|
+
- `0` - Project is compliant
|
|
142
|
+
- `1` - Violations found
|
|
143
|
+
|
|
144
|
+
**Example:**
|
|
145
|
+
```bash
|
|
146
|
+
$ kse docs diagnose
|
|
147
|
+
|
|
148
|
+
🔥 Document Governance Diagnostic
|
|
149
|
+
|
|
150
|
+
✅ Project is compliant
|
|
151
|
+
All documents follow the lifecycle management rules.
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### `kse docs cleanup`
|
|
157
|
+
|
|
158
|
+
Remove temporary documents from your project.
|
|
159
|
+
|
|
160
|
+
**Usage:**
|
|
161
|
+
```bash
|
|
162
|
+
kse docs cleanup [options]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Options:**
|
|
166
|
+
- `--dry-run`, `--dry` - Preview without deleting
|
|
167
|
+
- `--interactive`, `-i` - Prompt for each file
|
|
168
|
+
- `--spec <name>` - Only clean specific Spec
|
|
169
|
+
|
|
170
|
+
**What it removes:**
|
|
171
|
+
- Files matching temporary patterns:
|
|
172
|
+
- `*-SUMMARY.md`
|
|
173
|
+
- `SESSION-*.md`
|
|
174
|
+
- `*-COMPLETE.md`
|
|
175
|
+
- `TEMP-*.md`
|
|
176
|
+
- `WIP-*.md`
|
|
177
|
+
- `MVP-*.md`
|
|
178
|
+
|
|
179
|
+
**Examples:**
|
|
180
|
+
|
|
181
|
+
**Preview cleanup:**
|
|
182
|
+
```bash
|
|
183
|
+
$ kse docs cleanup --dry-run
|
|
184
|
+
|
|
185
|
+
🔥 Cleanup Preview (Dry Run)
|
|
186
|
+
|
|
187
|
+
Would delete 3 file(s):
|
|
188
|
+
|
|
189
|
+
🗑️ /project/MVP-PLAN.md
|
|
190
|
+
🗑️ /project/SESSION-2024-01-20.md
|
|
191
|
+
🗑️ /project/.kiro/specs/01-00-user-login/TEMP-notes.md
|
|
192
|
+
|
|
193
|
+
Run without --dry-run to actually delete these files
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Interactive cleanup:**
|
|
197
|
+
```bash
|
|
198
|
+
$ kse docs cleanup --interactive
|
|
199
|
+
|
|
200
|
+
Delete /project/MVP-PLAN.md? (y/n): y
|
|
201
|
+
✓ Deleted
|
|
202
|
+
|
|
203
|
+
Delete /project/SESSION-2024-01-20.md? (y/n): n
|
|
204
|
+
✗ Skipped
|
|
205
|
+
|
|
206
|
+
Deleted 1 file(s)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Clean specific Spec:**
|
|
210
|
+
```bash
|
|
211
|
+
$ kse docs cleanup --spec 01-00-user-login
|
|
212
|
+
|
|
213
|
+
🔥 Cleanup Complete
|
|
214
|
+
|
|
215
|
+
Deleted 1 file(s):
|
|
216
|
+
🗑️ .kiro/specs/01-00-user-login/TEMP-notes.md
|
|
217
|
+
|
|
218
|
+
✅ Cleanup completed successfully
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
**Exit codes:**
|
|
222
|
+
- `0` - Cleanup successful
|
|
223
|
+
- `1` - Cleanup completed with errors
|
|
224
|
+
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
### `kse docs validate`
|
|
228
|
+
|
|
229
|
+
Validate document structure against governance rules.
|
|
230
|
+
|
|
231
|
+
**Usage:**
|
|
232
|
+
```bash
|
|
233
|
+
kse docs validate [options]
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Options:**
|
|
237
|
+
- `--spec <name>` - Validate specific Spec
|
|
238
|
+
- `--all` - Validate all Specs
|
|
239
|
+
|
|
240
|
+
**What it validates:**
|
|
241
|
+
- Root directory has only allowed markdown files
|
|
242
|
+
- Spec directories have required files (requirements.md, design.md, tasks.md)
|
|
243
|
+
- Spec subdirectories follow naming conventions
|
|
244
|
+
- No misplaced artifacts
|
|
245
|
+
|
|
246
|
+
**Examples:**
|
|
247
|
+
|
|
248
|
+
**Validate root directory:**
|
|
249
|
+
```bash
|
|
250
|
+
$ kse docs validate
|
|
251
|
+
|
|
252
|
+
🔥 Document Structure Validation
|
|
253
|
+
|
|
254
|
+
✅ Validation passed
|
|
255
|
+
All document structures are compliant.
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Validate with errors:**
|
|
259
|
+
```bash
|
|
260
|
+
$ kse docs validate --all
|
|
261
|
+
|
|
262
|
+
🔥 Document Structure Validation
|
|
263
|
+
|
|
264
|
+
❌ 2 error(s):
|
|
265
|
+
|
|
266
|
+
❌ .kiro/specs/02-00-api-feature/requirements.md
|
|
267
|
+
Missing required file: requirements.md
|
|
268
|
+
→ Create requirements.md in 02-00-api-feature
|
|
269
|
+
|
|
270
|
+
❌ /project/NOTES.md
|
|
271
|
+
Unexpected markdown file in root directory
|
|
272
|
+
→ Move to appropriate location or delete if temporary
|
|
273
|
+
|
|
274
|
+
⚠️ 1 warning(s):
|
|
275
|
+
|
|
276
|
+
⚠️ .kiro/specs/01-00-user-login/script.js
|
|
277
|
+
Artifact not in subdirectory
|
|
278
|
+
→ Move to appropriate subdirectory (reports, scripts, tests, results, docs)
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
**Exit codes:**
|
|
282
|
+
- `0` - Validation passed
|
|
283
|
+
- `1` - Validation failed
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
### `kse docs archive`
|
|
288
|
+
|
|
289
|
+
Organize Spec artifacts into proper subdirectories.
|
|
290
|
+
|
|
291
|
+
**Usage:**
|
|
292
|
+
```bash
|
|
293
|
+
kse docs archive --spec <spec-name> [options]
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Options:**
|
|
297
|
+
- `--spec <name>` - **Required** - Spec to archive
|
|
298
|
+
- `--dry-run`, `--dry` - Preview without moving
|
|
299
|
+
|
|
300
|
+
**What it does:**
|
|
301
|
+
- Identifies unorganized files in Spec directory
|
|
302
|
+
- Determines appropriate subdirectory based on file type:
|
|
303
|
+
- **scripts/** - `.js`, `.py`, `.sh`, files with "script" in name
|
|
304
|
+
- **reports/** - Files with "report", "analysis", "summary" in name
|
|
305
|
+
- **tests/** - `.test.js`, `.spec.js`, files with "test" in name
|
|
306
|
+
- **results/** - Files with "result", "output" in name
|
|
307
|
+
- **docs/** - Other documentation files
|
|
308
|
+
- Creates subdirectories if they don't exist
|
|
309
|
+
- Moves files to appropriate locations
|
|
310
|
+
|
|
311
|
+
**Examples:**
|
|
312
|
+
|
|
313
|
+
**Preview archive:**
|
|
314
|
+
```bash
|
|
315
|
+
$ kse docs archive --spec 01-00-user-login --dry-run
|
|
316
|
+
|
|
317
|
+
🔥 Archive Preview (Dry Run)
|
|
318
|
+
|
|
319
|
+
Would move 3 file(s):
|
|
320
|
+
|
|
321
|
+
📦 analysis-report.md
|
|
322
|
+
→ .kiro/specs/01-00-user-login/reports/analysis-report.md
|
|
323
|
+
|
|
324
|
+
📦 test-script.js
|
|
325
|
+
→ .kiro/specs/01-00-user-login/scripts/test-script.js
|
|
326
|
+
|
|
327
|
+
📦 implementation-guide.md
|
|
328
|
+
→ .kiro/specs/01-00-user-login/docs/implementation-guide.md
|
|
329
|
+
|
|
330
|
+
Run without --dry-run to actually move these files
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
**Actually archive:**
|
|
334
|
+
```bash
|
|
335
|
+
$ kse docs archive --spec 01-00-user-login
|
|
336
|
+
|
|
337
|
+
🔥 Archive Complete
|
|
338
|
+
|
|
339
|
+
Moved 3 file(s):
|
|
340
|
+
📦 analysis-report.md → reports/analysis-report.md
|
|
341
|
+
📦 test-script.js → scripts/test-script.js
|
|
342
|
+
📦 implementation-guide.md → docs/implementation-guide.md
|
|
343
|
+
|
|
344
|
+
✅ Archive completed successfully
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Exit codes:**
|
|
348
|
+
- `0` - Archive successful
|
|
349
|
+
- `1` - Archive completed with errors
|
|
350
|
+
- `2` - Invalid arguments (missing --spec)
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
### `kse docs hooks`
|
|
355
|
+
|
|
356
|
+
Manage Git hooks for document governance.
|
|
357
|
+
|
|
358
|
+
**Usage:**
|
|
359
|
+
```bash
|
|
360
|
+
kse docs hooks <action>
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Actions:**
|
|
364
|
+
- `install` - Install pre-commit hook
|
|
365
|
+
- `uninstall` - Remove pre-commit hook
|
|
366
|
+
- `status` - Check if hooks are installed
|
|
367
|
+
|
|
368
|
+
**What the hook does:**
|
|
369
|
+
- Runs `kse docs validate` before each commit
|
|
370
|
+
- Blocks commit if violations are found
|
|
371
|
+
- Shows violations and how to fix them
|
|
372
|
+
- Can be bypassed with `git commit --no-verify`
|
|
373
|
+
|
|
374
|
+
**Examples:**
|
|
375
|
+
|
|
376
|
+
**Install hooks:**
|
|
377
|
+
```bash
|
|
378
|
+
$ kse docs hooks install
|
|
379
|
+
|
|
380
|
+
🔧 Installing document governance hooks...
|
|
381
|
+
|
|
382
|
+
✅ Pre-commit hook installed successfully
|
|
383
|
+
Backup created at: .git/hooks/pre-commit.backup
|
|
384
|
+
|
|
385
|
+
The pre-commit hook will now validate documents before each commit.
|
|
386
|
+
To bypass validation, use: git commit --no-verify
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
**Check status:**
|
|
390
|
+
```bash
|
|
391
|
+
$ kse docs hooks status
|
|
392
|
+
|
|
393
|
+
🔍 Checking Git hooks status...
|
|
394
|
+
|
|
395
|
+
✅ Document governance hooks are installed
|
|
396
|
+
Pre-commit validation is active
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
**Uninstall hooks:**
|
|
400
|
+
```bash
|
|
401
|
+
$ kse docs hooks uninstall
|
|
402
|
+
|
|
403
|
+
🔧 Uninstalling document governance hooks...
|
|
404
|
+
|
|
405
|
+
✅ Pre-commit hook removed successfully
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**Hook in action:**
|
|
409
|
+
```bash
|
|
410
|
+
$ git commit -m "Add feature"
|
|
411
|
+
|
|
412
|
+
Running document governance validation...
|
|
413
|
+
|
|
414
|
+
❌ Validation failed - commit blocked
|
|
415
|
+
|
|
416
|
+
Found 2 violation(s):
|
|
417
|
+
• /project/TEMP-notes.md - Temporary file in root
|
|
418
|
+
• .kiro/specs/01-00-user-login/script.js - Misplaced artifact
|
|
419
|
+
|
|
420
|
+
Fix violations and try again, or use --no-verify to bypass.
|
|
421
|
+
|
|
422
|
+
Run 'kse docs diagnose' for details.
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**Exit codes:**
|
|
426
|
+
- `0` - Operation successful
|
|
427
|
+
- `1` - Operation failed
|
|
428
|
+
|
|
429
|
+
---
|
|
430
|
+
|
|
431
|
+
### `kse docs config`
|
|
432
|
+
|
|
433
|
+
Display or modify document governance configuration.
|
|
434
|
+
|
|
435
|
+
**Usage:**
|
|
436
|
+
```bash
|
|
437
|
+
kse docs config [options]
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
**Options:**
|
|
441
|
+
- `--set <key> <value>` - Set configuration value
|
|
442
|
+
- `--reset` - Reset to defaults
|
|
443
|
+
|
|
444
|
+
**Configuration keys:**
|
|
445
|
+
- `root-allowed-files` - Allowed markdown files in root
|
|
446
|
+
- `spec-subdirs` - Recognized Spec subdirectories
|
|
447
|
+
- `temporary-patterns` - Patterns for temporary files
|
|
448
|
+
|
|
449
|
+
**Examples:**
|
|
450
|
+
|
|
451
|
+
**Display configuration:**
|
|
452
|
+
```bash
|
|
453
|
+
$ kse docs config
|
|
454
|
+
|
|
455
|
+
⚙️ Document Governance Configuration
|
|
456
|
+
|
|
457
|
+
Root Allowed Files:
|
|
458
|
+
• README.md
|
|
459
|
+
• README.zh.md
|
|
460
|
+
• CHANGELOG.md
|
|
461
|
+
• CONTRIBUTING.md
|
|
462
|
+
|
|
463
|
+
Spec Subdirectories:
|
|
464
|
+
• reports
|
|
465
|
+
• scripts
|
|
466
|
+
• tests
|
|
467
|
+
• results
|
|
468
|
+
• docs
|
|
469
|
+
|
|
470
|
+
Temporary Patterns:
|
|
471
|
+
• *-SUMMARY.md
|
|
472
|
+
• SESSION-*.md
|
|
473
|
+
• *-COMPLETE.md
|
|
474
|
+
• TEMP-*.md
|
|
475
|
+
• WIP-*.md
|
|
476
|
+
• MVP-*.md
|
|
477
|
+
|
|
478
|
+
Configuration file: .kiro/config/docs.json
|
|
479
|
+
To modify: kse docs config --set <key> <value>
|
|
480
|
+
To reset: kse docs config --reset
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
**Set configuration:**
|
|
484
|
+
```bash
|
|
485
|
+
$ kse docs config --set root-allowed-files "README.md,CUSTOM.md,LICENSE.md"
|
|
486
|
+
|
|
487
|
+
✅ Configuration updated: root-allowed-files
|
|
488
|
+
New value: README.md, CUSTOM.md, LICENSE.md
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**Reset configuration:**
|
|
492
|
+
```bash
|
|
493
|
+
$ kse docs config --reset
|
|
494
|
+
|
|
495
|
+
⚠️ Resetting configuration to defaults...
|
|
496
|
+
|
|
497
|
+
✅ Configuration reset to defaults
|
|
498
|
+
Run "kse docs config" to view current configuration
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**Exit codes:**
|
|
502
|
+
- `0` - Operation successful
|
|
503
|
+
- `1` - Operation failed
|
|
504
|
+
- `2` - Invalid arguments
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
### `kse docs stats`
|
|
509
|
+
|
|
510
|
+
Display document compliance statistics.
|
|
511
|
+
|
|
512
|
+
**Usage:**
|
|
513
|
+
```bash
|
|
514
|
+
kse docs stats
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
**What it shows:**
|
|
518
|
+
- Total governance tool executions
|
|
519
|
+
- Executions by tool (diagnostic, cleanup, validation, archive)
|
|
520
|
+
- Total violations found over time
|
|
521
|
+
- Violations by type
|
|
522
|
+
- Cleanup actions taken
|
|
523
|
+
- Archive actions taken
|
|
524
|
+
- Errors encountered
|
|
525
|
+
|
|
526
|
+
**Example:**
|
|
527
|
+
```bash
|
|
528
|
+
$ kse docs stats
|
|
529
|
+
|
|
530
|
+
📊 Document Compliance Statistics
|
|
531
|
+
|
|
532
|
+
Summary:
|
|
533
|
+
• Total Executions: 15
|
|
534
|
+
• Total Violations Found: 23
|
|
535
|
+
• Total Cleanup Actions: 12
|
|
536
|
+
• Total Archive Actions: 8
|
|
537
|
+
• Total Errors: 1
|
|
538
|
+
|
|
539
|
+
Executions by Tool:
|
|
540
|
+
• diagnostic: 5
|
|
541
|
+
• cleanup: 4
|
|
542
|
+
• validation: 3
|
|
543
|
+
• archive: 3
|
|
544
|
+
|
|
545
|
+
Violations by Type:
|
|
546
|
+
• root_violation: 10
|
|
547
|
+
• misplaced_artifact: 8
|
|
548
|
+
• temporary_document: 5
|
|
549
|
+
|
|
550
|
+
Recent Activity:
|
|
551
|
+
• 2024-01-24: Cleaned 3 files
|
|
552
|
+
• 2024-01-23: Found 5 violations
|
|
553
|
+
• 2024-01-22: Archived 4 files
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
**Exit codes:**
|
|
557
|
+
- `0` - Always successful
|
|
558
|
+
|
|
559
|
+
---
|
|
560
|
+
|
|
561
|
+
### `kse docs report`
|
|
562
|
+
|
|
563
|
+
Generate a comprehensive compliance report.
|
|
564
|
+
|
|
565
|
+
**Usage:**
|
|
566
|
+
```bash
|
|
567
|
+
kse docs report
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
**What it generates:**
|
|
571
|
+
- Markdown report with all statistics
|
|
572
|
+
- Violations over time
|
|
573
|
+
- Cleanup actions over time
|
|
574
|
+
- Recent executions with details
|
|
575
|
+
- Saved to `.kiro/reports/document-compliance-{date}.md`
|
|
576
|
+
|
|
577
|
+
**Example:**
|
|
578
|
+
```bash
|
|
579
|
+
$ kse docs report
|
|
580
|
+
|
|
581
|
+
✅ Compliance report generated
|
|
582
|
+
Saved to: .kiro/reports/document-compliance-2024-01-24.md
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
**Report contents:**
|
|
586
|
+
```markdown
|
|
587
|
+
# Document Compliance Report
|
|
588
|
+
|
|
589
|
+
**Generated:** 2024-01-24T10:30:00.000Z
|
|
590
|
+
|
|
591
|
+
## Summary
|
|
592
|
+
- **Total Executions:** 15
|
|
593
|
+
- **Total Violations Found:** 23
|
|
594
|
+
- **Total Cleanup Actions:** 12
|
|
595
|
+
...
|
|
596
|
+
|
|
597
|
+
## Violations by Type
|
|
598
|
+
| Type | Count |
|
|
599
|
+
|------|-------|
|
|
600
|
+
| root_violation | 10 |
|
|
601
|
+
| misplaced_artifact | 8 |
|
|
602
|
+
...
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
**Exit codes:**
|
|
606
|
+
- `0` - Report generated successfully
|
|
607
|
+
|
|
608
|
+
---
|
|
609
|
+
|
|
610
|
+
## Best Practices
|
|
611
|
+
|
|
612
|
+
### Daily Workflow
|
|
613
|
+
|
|
614
|
+
**1. Start of day - Check compliance:**
|
|
615
|
+
```bash
|
|
616
|
+
kse docs diagnose
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
**2. Before committing - Validate:**
|
|
620
|
+
```bash
|
|
621
|
+
kse docs validate --all
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
**3. End of feature - Clean up:**
|
|
625
|
+
```bash
|
|
626
|
+
kse docs cleanup
|
|
627
|
+
kse docs archive --spec your-spec
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
### Spec Lifecycle
|
|
631
|
+
|
|
632
|
+
**When creating a Spec:**
|
|
633
|
+
```bash
|
|
634
|
+
# 1. Create Spec
|
|
635
|
+
kse create-spec 01-00-new-feature
|
|
636
|
+
|
|
637
|
+
# 2. Verify structure
|
|
638
|
+
kse docs validate --spec 01-00-new-feature
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
**During development:**
|
|
642
|
+
```bash
|
|
643
|
+
# Keep artifacts organized
|
|
644
|
+
kse docs archive --spec 01-00-new-feature --dry-run
|
|
645
|
+
# Review what would be moved, then:
|
|
646
|
+
kse docs archive --spec 01-00-new-feature
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
**When completing a Spec:**
|
|
650
|
+
```bash
|
|
651
|
+
# 1. Clean up temporary files
|
|
652
|
+
kse docs cleanup --spec 01-00-new-feature
|
|
653
|
+
|
|
654
|
+
# 2. Organize all artifacts
|
|
655
|
+
kse docs archive --spec 01-00-new-feature
|
|
656
|
+
|
|
657
|
+
# 3. Validate final structure
|
|
658
|
+
kse docs validate --spec 01-00-new-feature
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
### Team Collaboration
|
|
662
|
+
|
|
663
|
+
**Project setup:**
|
|
664
|
+
```bash
|
|
665
|
+
# 1. Install hooks for all team members
|
|
666
|
+
kse docs hooks install
|
|
667
|
+
|
|
668
|
+
# 2. Configure project-specific rules (if needed)
|
|
669
|
+
kse docs config --set root-allowed-files "README.md,README.zh.md,CHANGELOG.md,CONTRIBUTING.md,LICENSE.md"
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
**Code review:**
|
|
673
|
+
```bash
|
|
674
|
+
# Check compliance before reviewing
|
|
675
|
+
kse docs diagnose
|
|
676
|
+
|
|
677
|
+
# Generate report for team
|
|
678
|
+
kse docs report
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
### Automation
|
|
682
|
+
|
|
683
|
+
**CI/CD Integration:**
|
|
684
|
+
```yaml
|
|
685
|
+
# .github/workflows/document-governance.yml
|
|
686
|
+
name: Document Governance
|
|
687
|
+
|
|
688
|
+
on: [push, pull_request]
|
|
689
|
+
|
|
690
|
+
jobs:
|
|
691
|
+
validate:
|
|
692
|
+
runs-on: ubuntu-latest
|
|
693
|
+
steps:
|
|
694
|
+
- uses: actions/checkout@v2
|
|
695
|
+
- uses: actions/setup-node@v2
|
|
696
|
+
- run: npm install -g kiro-spec-engine
|
|
697
|
+
- run: kse docs diagnose
|
|
698
|
+
- run: kse docs validate --all
|
|
699
|
+
```
|
|
700
|
+
|
|
701
|
+
**Pre-commit hook (automatic):**
|
|
702
|
+
```bash
|
|
703
|
+
# Install once
|
|
704
|
+
kse docs hooks install
|
|
705
|
+
|
|
706
|
+
# Now every commit is validated automatically
|
|
707
|
+
git commit -m "Add feature"
|
|
708
|
+
# → Validation runs automatically
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
---
|
|
712
|
+
|
|
713
|
+
## Configuration
|
|
714
|
+
|
|
715
|
+
### Default Configuration
|
|
716
|
+
|
|
717
|
+
The default configuration is:
|
|
718
|
+
|
|
719
|
+
```json
|
|
720
|
+
{
|
|
721
|
+
"rootAllowedFiles": [
|
|
722
|
+
"README.md",
|
|
723
|
+
"README.zh.md",
|
|
724
|
+
"CHANGELOG.md",
|
|
725
|
+
"CONTRIBUTING.md"
|
|
726
|
+
],
|
|
727
|
+
"specSubdirs": [
|
|
728
|
+
"reports",
|
|
729
|
+
"scripts",
|
|
730
|
+
"tests",
|
|
731
|
+
"results",
|
|
732
|
+
"docs"
|
|
733
|
+
],
|
|
734
|
+
"temporaryPatterns": [
|
|
735
|
+
"*-SUMMARY.md",
|
|
736
|
+
"SESSION-*.md",
|
|
737
|
+
"*-COMPLETE.md",
|
|
738
|
+
"TEMP-*.md",
|
|
739
|
+
"WIP-*.md",
|
|
740
|
+
"MVP-*.md"
|
|
741
|
+
]
|
|
742
|
+
}
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
### Customizing Configuration
|
|
746
|
+
|
|
747
|
+
**Add custom allowed files:**
|
|
748
|
+
```bash
|
|
749
|
+
kse docs config --set root-allowed-files "README.md,README.zh.md,CHANGELOG.md,CONTRIBUTING.md,LICENSE.md,SECURITY.md"
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
**Add custom subdirectories:**
|
|
753
|
+
```bash
|
|
754
|
+
kse docs config --set spec-subdirs "reports,scripts,tests,results,docs,diagrams,examples"
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
**Add custom temporary patterns:**
|
|
758
|
+
```bash
|
|
759
|
+
kse docs config --set temporary-patterns "*-SUMMARY.md,SESSION-*.md,*-COMPLETE.md,TEMP-*.md,WIP-*.md,MVP-*.md,DRAFT-*.md"
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
### Configuration File Location
|
|
763
|
+
|
|
764
|
+
Configuration is stored in `.kiro/config/docs.json`
|
|
765
|
+
|
|
766
|
+
You can also edit this file directly:
|
|
767
|
+
|
|
768
|
+
```json
|
|
769
|
+
{
|
|
770
|
+
"rootAllowedFiles": ["README.md", "CUSTOM.md"],
|
|
771
|
+
"specSubdirs": ["reports", "scripts", "custom"],
|
|
772
|
+
"temporaryPatterns": ["*-TEMP.md"]
|
|
773
|
+
}
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
---
|
|
777
|
+
|
|
778
|
+
## Troubleshooting
|
|
779
|
+
|
|
780
|
+
See the [Troubleshooting Guide](troubleshooting.md#document-governance-issues) for common issues and solutions.
|
|
781
|
+
|
|
782
|
+
### Quick Fixes
|
|
783
|
+
|
|
784
|
+
**"Permission denied" errors:**
|
|
785
|
+
```bash
|
|
786
|
+
# Check file permissions
|
|
787
|
+
ls -la .kiro/
|
|
788
|
+
|
|
789
|
+
# Fix if needed
|
|
790
|
+
chmod -R u+w .kiro/
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
**"Not a git repository" (for hooks):**
|
|
794
|
+
```bash
|
|
795
|
+
# Initialize git first
|
|
796
|
+
git init
|
|
797
|
+
|
|
798
|
+
# Then install hooks
|
|
799
|
+
kse docs hooks install
|
|
800
|
+
```
|
|
801
|
+
|
|
802
|
+
**"Configuration file corrupted":**
|
|
803
|
+
```bash
|
|
804
|
+
# Reset to defaults
|
|
805
|
+
kse docs config --reset
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
**"Cleanup not removing files":**
|
|
809
|
+
```bash
|
|
810
|
+
# Check if files match temporary patterns
|
|
811
|
+
kse docs diagnose
|
|
812
|
+
|
|
813
|
+
# Use interactive mode to confirm
|
|
814
|
+
kse docs cleanup --interactive
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
---
|
|
818
|
+
|
|
819
|
+
## Related Documentation
|
|
820
|
+
|
|
821
|
+
- **[Spec Workflow Guide](spec-workflow.md)** - Understanding Specs
|
|
822
|
+
- **[Command Reference](command-reference.md)** - All kse commands
|
|
823
|
+
- **[Troubleshooting Guide](troubleshooting.md)** - Common issues
|
|
824
|
+
- **[Quick Start Guide](quick-start.md)** - Getting started
|
|
825
|
+
|
|
826
|
+
---
|
|
827
|
+
|
|
828
|
+
## Summary
|
|
829
|
+
|
|
830
|
+
**Document Governance Commands:**
|
|
831
|
+
- `kse docs diagnose` - Find violations
|
|
832
|
+
- `kse docs cleanup` - Remove temporary files
|
|
833
|
+
- `kse docs validate` - Check structure
|
|
834
|
+
- `kse docs archive` - Organize artifacts
|
|
835
|
+
- `kse docs hooks` - Manage Git hooks
|
|
836
|
+
- `kse docs config` - Configure rules
|
|
837
|
+
- `kse docs stats` - View statistics
|
|
838
|
+
- `kse docs report` - Generate report
|
|
839
|
+
|
|
840
|
+
**Quick Workflow:**
|
|
841
|
+
```bash
|
|
842
|
+
# 1. Check compliance
|
|
843
|
+
kse docs diagnose
|
|
844
|
+
|
|
845
|
+
# 2. Fix violations
|
|
846
|
+
kse docs cleanup
|
|
847
|
+
kse docs archive --spec your-spec
|
|
848
|
+
|
|
849
|
+
# 3. Validate
|
|
850
|
+
kse docs validate --all
|
|
851
|
+
|
|
852
|
+
# 4. Prevent future violations
|
|
853
|
+
kse docs hooks install
|
|
854
|
+
```
|
|
855
|
+
|
|
856
|
+
**Start using document governance:** 🚀
|
|
857
|
+
```bash
|
|
858
|
+
kse docs diagnose
|
|
859
|
+
```
|
|
860
|
+
|
|
861
|
+
---
|
|
862
|
+
|
|
863
|
+
**Version**: 1.0.0
|
|
864
|
+
**Last Updated**: 2026-01-24
|