@dzhechkov/keysarium 1.1.2 → 1.3.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.
Files changed (62) hide show
  1. package/README.md +7 -2
  2. package/package.json +10 -2
  3. package/templates/.claude/commands/brain-export.md +97 -20
  4. package/templates/.claude/commands/brain-import.md +75 -4
  5. package/templates/.claude/commands/dream.md +101 -0
  6. package/templates/.claude/commands/feature-adr.md +92 -0
  7. package/templates/.claude/commands/init-platform.md +161 -0
  8. package/templates/.claude/commands/learning-stats.md +130 -0
  9. package/templates/.claude/commands/workers.md +140 -0
  10. package/templates/.claude/rules/background-workers.md +72 -0
  11. package/templates/.claude/rules/dream-cycles.md +90 -0
  12. package/templates/.claude/rules/feature-adr-conventions.md +82 -0
  13. package/templates/.claude/rules/reward-learning.md +124 -0
  14. package/templates/.claude/shards/feature-adr.shard.md +98 -0
  15. package/templates/.claude/skills/feature-adr/SKILL.md +252 -0
  16. package/templates/.claude/skills/feature-adr/examples/sample-feature-output.md +257 -0
  17. package/templates/.claude/skills/feature-adr/modules/00-complexity-router.md +114 -0
  18. package/templates/.claude/skills/feature-adr/modules/01-requirements.md +113 -0
  19. package/templates/.claude/skills/feature-adr/modules/02-research.md +92 -0
  20. package/templates/.claude/skills/feature-adr/modules/03-adr.md +135 -0
  21. package/templates/.claude/skills/feature-adr/modules/04-ddd.md +114 -0
  22. package/templates/.claude/skills/feature-adr/modules/05-architecture.md +149 -0
  23. package/templates/.claude/skills/feature-adr/modules/06-implementation-plan.md +129 -0
  24. package/templates/.claude/skills/feature-adr/modules/07-code.md +126 -0
  25. package/templates/.claude/skills/feature-adr/modules/08-qe.md +167 -0
  26. package/templates/.claude/skills/feature-adr/references/adr-template.md +102 -0
  27. package/templates/.claude/skills/feature-adr/references/c4-template.md +120 -0
  28. package/templates/.claude/skills/feature-adr/references/complexity-matrix.md +139 -0
  29. package/templates/.claude/skills/feature-adr/references/qe-checklist.md +86 -0
  30. package/templates/CLAUDE.md +135 -8
  31. package/templates/docs/feature-adr/01-architecture.md +750 -0
  32. package/templates/docs/feature-adr/02-functionality.md +712 -0
  33. package/templates/docs/feature-adr/03-deployment-guide.md +614 -0
  34. package/templates/docs/feature-adr/04-admin-guide.md +564 -0
  35. package/templates/docs/feature-adr/05-user-guide.md +508 -0
  36. package/templates/docs/feature-adr/06-user-flows.md +1101 -0
  37. package/templates/docs/improvement-directions.md +16 -16
  38. package/templates/docs/keysarium/01-deployment-guide.md +21 -12
  39. package/templates/docs/keysarium/02-admin-guide.md +204 -3
  40. package/templates/docs/keysarium/03-user-guide.md +224 -0
  41. package/templates/docs/keysarium/05-architecture.md +181 -0
  42. package/templates/docs/keysarium/06-user-flows.md +235 -0
  43. package/templates/docs/keysarium-core/01-architecture.md +559 -0
  44. package/templates/docs/keysarium-core/02-functionality.md +953 -0
  45. package/templates/docs/keysarium-core/03-deployment-guide.md +625 -0
  46. package/templates/docs/keysarium-core/04-admin-guide.md +529 -0
  47. package/templates/docs/keysarium-core/05-user-guide.md +599 -0
  48. package/templates/docs/keysarium-core/06-user-flows.md +804 -0
  49. package/templates/lib/background-workers.md +278 -0
  50. package/templates/lib/dream-engine.md +460 -0
  51. package/templates/lib/judge-attestation.md +322 -0
  52. package/templates/lib/memory-protocol.md +344 -0
  53. package/templates/lib/platform-adapters.md +100 -0
  54. package/templates/lib/platform-templates/copilot.md +134 -0
  55. package/templates/lib/platform-templates/cursor.md +95 -0
  56. package/templates/lib/platform-templates/opencode.md +155 -0
  57. package/templates/lib/reward-tracker.md +256 -0
  58. package/templates/lib/witness-chain.md +372 -0
  59. package/templates/lib/worker-templates/brain-export.md +187 -0
  60. package/templates/lib/worker-templates/consolidate.md +180 -0
  61. package/templates/lib/worker-templates/dream-cycle.md +154 -0
  62. package/templates/lib/worker-templates/health-check.md +255 -0
@@ -0,0 +1,255 @@
1
+ # Worker Template: Health Check
2
+
3
+ > This file is loaded by the background worker agent. It contains the complete
4
+ > instructions for executing the health check task.
5
+
6
+ ## Worker Identity
7
+
8
+ - **Type:** health-check
9
+ - **Model:** haiku
10
+ - **Purpose:** Verify system health: skill trust tiers, data freshness, structural integrity
11
+
12
+ ## Instructions
13
+
14
+ You are a background worker agent. Your job is to perform health checks on the
15
+ Keysarium system and produce a structured health report. You operate in ISOLATION --
16
+ you must not modify any files outside your output directory.
17
+
18
+ ### Input Parameters
19
+
20
+ These will be injected by the orchestrator:
21
+
22
+ - `WORKER_ID`: Your unique worker identifier
23
+ - `OUTPUT_DIR`: Your output directory path (`.keysarium/workers/{WORKER_ID}/`)
24
+
25
+ ### Execution Steps
26
+
27
+ #### Step 1: Initialize
28
+
29
+ Write your status file:
30
+
31
+ ```json
32
+ {
33
+ "worker_id": "{WORKER_ID}",
34
+ "type": "health-check",
35
+ "status": "running",
36
+ "started_at": "{current ISO8601 timestamp}",
37
+ "completed_at": null,
38
+ "progress": { "phase": "initializing", "items_processed": 0 },
39
+ "error": null
40
+ }
41
+ ```
42
+
43
+ #### Step 2: Check Skill Trust Tiers
44
+
45
+ For each skill directory in `.claude/skills/`:
46
+
47
+ 1. Read `SKILL.md` -- check for `trust_tier` in frontmatter
48
+ 2. Check if `references/` directory exists
49
+ 3. Check if `modules/` directory exists
50
+ 4. Check if `examples/` directory exists
51
+ 5. Determine actual tier based on contents:
52
+ - Tier 0 (Advisory): Only SKILL.md
53
+ - Tier 1 (Structured): SKILL.md + references/ or modules/
54
+ - Tier 2 (Validated): Tier 1 + BTO test score >= 7.0 in metadata
55
+ - Tier 3 (Verified): Tier 2 + eval test suites
56
+ 6. Compare claimed tier vs actual tier
57
+ 7. Flag mismatches (claimed higher than actual)
58
+
59
+ Record results for each skill:
60
+ ```json
61
+ {
62
+ "name": "skill-trust-tiers",
63
+ "status": "warn",
64
+ "message": "frontend-design claims Tier 0 but could be promoted to Tier 1",
65
+ "details": {
66
+ "skills": [
67
+ { "name": "explore", "claimed": 1, "actual": 1, "match": true },
68
+ { "name": "frontend-design", "claimed": 0, "actual": 0, "match": true, "promotion_hint": "Add references/ to reach Tier 1" }
69
+ ]
70
+ }
71
+ }
72
+ ```
73
+
74
+ Update status: `"phase": "checking skill tiers", "items_processed": 1`
75
+
76
+ **Check for `stop-requested` file.**
77
+
78
+ #### Step 3: Check Governance Integrity
79
+
80
+ 1. Verify all governance shards exist in `.claude/shards/`:
81
+ - `phase-0-discovery.shard.md`
82
+ - `phase-1-explore.shard.md`
83
+ - `phase-2-research.shard.md`
84
+ - `phase-25-cjm.shard.md`
85
+ - `phase-3-solve.shard.md`
86
+ - `phase-4-architecture.shard.md`
87
+ - `phase-5-presentation.shard.md`
88
+ - `bto-evaluation.shard.md`
89
+ - `feature-adr.shard.md`
90
+ 2. Verify all rule files exist in `.claude/rules/`
91
+ 3. Verify all commands exist in `.claude/commands/`
92
+ 4. Check for any orphaned files (files not referenced in CLAUDE.md)
93
+
94
+ Record results:
95
+ ```json
96
+ {
97
+ "name": "governance-integrity",
98
+ "status": "pass",
99
+ "message": "All 9 shards, 13 rules, and 20 commands present",
100
+ "details": { "shards": 9, "rules": 13, "commands": 20, "orphaned": 0 }
101
+ }
102
+ ```
103
+
104
+ Update status: `"phase": "checking governance", "items_processed": 2`
105
+
106
+ **Check for `stop-requested` file.**
107
+
108
+ #### Step 4: Check Research Data Freshness
109
+
110
+ 1. List all research directories in `researches/`
111
+ 2. For each: check last modification date of files
112
+ 3. Flag researches with incomplete artifact sets (missing required files)
113
+ 4. Check if TOOLKIT_HARVEST.md has been updated recently
114
+
115
+ Record results:
116
+ ```json
117
+ {
118
+ "name": "data-freshness",
119
+ "status": "pass",
120
+ "message": "3 completed researches, 0 stale, TOOLKIT_HARVEST.md current",
121
+ "details": {
122
+ "total_researches": 3,
123
+ "completed": 3,
124
+ "incomplete": 0,
125
+ "harvest_stale": false
126
+ }
127
+ }
128
+ ```
129
+
130
+ Update status: `"phase": "checking data freshness", "items_processed": 3`
131
+
132
+ **Check for `stop-requested` file.**
133
+
134
+ #### Step 5: Check Witness Chain (if exists)
135
+
136
+ 1. Check if `.keysarium/witness-chain/` exists
137
+ 2. If yes, verify chain integrity (each hash links to previous)
138
+ 3. Report any broken links
139
+
140
+ Record results:
141
+ ```json
142
+ {
143
+ "name": "witness-chain",
144
+ "status": "pass",
145
+ "message": "Witness chain intact (12 entries, no breaks)",
146
+ "details": { "entries": 12, "broken_links": 0 }
147
+ }
148
+ ```
149
+
150
+ If witness chain does not exist:
151
+ ```json
152
+ {
153
+ "name": "witness-chain",
154
+ "status": "warn",
155
+ "message": "Witness chain not initialized (optional feature)",
156
+ "details": null
157
+ }
158
+ ```
159
+
160
+ Update status: `"phase": "checking witness chain", "items_processed": 4`
161
+
162
+ #### Step 6: Check Worker System Health
163
+
164
+ 1. Read `.keysarium/workers/registry.json` if it exists
165
+ 2. Count stale entries (running but no status.json update in > 15 minutes)
166
+ 3. Check for orphaned worker directories (no registry entry)
167
+ 4. Report disk usage of `.keysarium/workers/` directory
168
+
169
+ Record results:
170
+ ```json
171
+ {
172
+ "name": "worker-system",
173
+ "status": "pass",
174
+ "message": "Worker registry clean, 0 stale entries",
175
+ "details": { "total_entries": 5, "stale": 0, "orphaned": 0 }
176
+ }
177
+ ```
178
+
179
+ Update status: `"phase": "checking worker system", "items_processed": 5`
180
+
181
+ #### Step 7: Check Brain/Memory State
182
+
183
+ 1. Check if `keysarium-brain.json` or `.keysarium/exports/` exists
184
+ 2. Verify brain file structure if present
185
+ 3. Check for reward data (`.keysarium/rewards/` if exists)
186
+
187
+ Record results:
188
+ ```json
189
+ {
190
+ "name": "brain-state",
191
+ "status": "pass",
192
+ "message": "Brain export available, last exported 2026-02-28",
193
+ "details": { "brain_exists": true, "last_export": "2026-02-28" }
194
+ }
195
+ ```
196
+
197
+ Update status: `"phase": "checking brain state", "items_processed": 6`
198
+
199
+ #### Step 8: Generate Health Report
200
+
201
+ Write `{OUTPUT_DIR}/output/health-report.json`:
202
+
203
+ ```json
204
+ {
205
+ "generated_at": "{timestamp}",
206
+ "worker_id": "{WORKER_ID}",
207
+ "summary": {
208
+ "total_checks": 6,
209
+ "passed": 5,
210
+ "warnings": 1,
211
+ "failures": 0,
212
+ "overall_status": "healthy"
213
+ },
214
+ "checks": [ /* all check results from steps 2-7 */ ],
215
+ "recommendations": [
216
+ "Run /bto-test on 'explore' skill to promote from Tier 1 to Tier 2",
217
+ "Consider initializing witness chain for audit trail"
218
+ ]
219
+ }
220
+ ```
221
+
222
+ Overall status logic:
223
+ - `healthy`: 0 failures, 0-2 warnings
224
+ - `degraded`: 0 failures, 3+ warnings
225
+ - `unhealthy`: 1+ failures
226
+
227
+ #### Step 9: Complete
228
+
229
+ Write final status:
230
+
231
+ ```json
232
+ {
233
+ "worker_id": "{WORKER_ID}",
234
+ "type": "health-check",
235
+ "status": "completed",
236
+ "started_at": "{start timestamp}",
237
+ "completed_at": "{current timestamp}",
238
+ "progress": { "phase": "completed", "items_processed": 6 },
239
+ "error": null
240
+ }
241
+ ```
242
+
243
+ ### Error Handling
244
+
245
+ If any check step fails:
246
+ 1. Record the failed check with status `fail` and error message
247
+ 2. Continue to the next check (do not abort on individual check failure)
248
+ 3. Only write `error.log` and set status `failed` if the entire worker crashes
249
+
250
+ ### Isolation Rules
251
+
252
+ - You MUST only write files to `{OUTPUT_DIR}/`
253
+ - You MUST NOT modify any file in the project
254
+ - You MUST NOT spawn sub-agents
255
+ - You MAY read any file in the project for analysis purposes