@dzhechkov/keysarium 1.3.0 → 1.4.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/README.md +22 -9
- package/package.json +1 -1
- package/src/utils.js +1 -1
- package/templates/.claude/commands/brain-export.md +2 -0
- package/templates/.claude/commands/bto-benchmark.md +302 -0
- package/templates/.claude/commands/harvest.md +28 -46
- package/templates/.claude/rules/trust-tiers.md +1 -0
- package/templates/.claude/skills/knowledge-extractor/SKILL.md +254 -0
- package/templates/.claude/skills/knowledge-extractor/modules/01-extract.md +188 -0
- package/templates/.claude/skills/knowledge-extractor/modules/02-classify.md +99 -0
- package/templates/.claude/skills/knowledge-extractor/modules/03-gate.md +150 -0
- package/templates/.claude/skills/knowledge-extractor/modules/04-integrate.md +159 -0
- package/templates/.claude/skills/knowledge-extractor/references/artifact-categories.md +100 -0
- package/templates/.claude/skills/knowledge-extractor/references/maturity-model.md +94 -0
- package/templates/.claude/skills/knowledge-extractor/references/quality-gates.md +98 -0
- package/templates/.claude/skills/knowledge-extractor/templates/artifact-card.md +63 -0
- package/templates/.claude/skills/knowledge-extractor/templates/harvest-report.md +102 -0
- package/templates/CLAUDE.md +22 -8
- package/templates/docs/continuous-learning-guide.md +622 -0
- package/templates/docs/improvement-directions.md +8 -4
- package/templates/docs/keysarium-core/02-functionality.md +3 -1
- package/templates/docs/skills-bto/01-deployment-guide.md +1 -1
- package/templates/docs/skills-bto/02-admin-guide.md +4 -1
- package/templates/docs/skills-bto/03-user-guide.md +4 -3
- package/templates/docs/skills-bto/04-infrastructure-requirements.md +2 -1
- package/templates/docs/skills-bto/05-architecture.md +11 -11
- package/templates/docs/skills-bto/06-user-flows.md +2 -1
- package/templates/lib/dream-engine.md +1 -1
- package/templates/lib/memory-protocol.md +6 -2
- package/templates/lib/reward-tracker.md +6 -3
|
@@ -192,7 +192,7 @@ Options:
|
|
|
192
192
|
2. **Resolve path** — `{memory-root}/{domain}/` (сканируем все slug, не только текущий)
|
|
193
193
|
3. **Scan records** — читаем все `{stage}_*.json` файлы по matching stage
|
|
194
194
|
4. **Filter expired** — исключаем records где `expires_at < current_date`
|
|
195
|
-
5. **Sort** — по `reward` DESC, затем `timestamp` DESC
|
|
195
|
+
5. **Sort** — по `reward` DESC, затем `usage_count` DESC, затем `timestamp` DESC
|
|
196
196
|
6. **Limit** — top `max_results_per_query` записей (default 10)
|
|
197
197
|
7. **Enrich** — загружаем `_patterns/domain-patterns.json` для matching domain
|
|
198
198
|
|
|
@@ -230,6 +230,7 @@ Options:
|
|
|
230
230
|
2. Если `records` не пустые — review top 3 для relevant approaches
|
|
231
231
|
3. Если `patterns` не пустые — apply actionable advice
|
|
232
232
|
4. Если всё пустое (первый запуск) — продолжить нормально
|
|
233
|
+
5. **Increment usage_count** — для каждого применённого record (top 3) инкрементировать `usage_count` в файле и индексе
|
|
233
234
|
|
|
234
235
|
---
|
|
235
236
|
|
|
@@ -293,6 +294,7 @@ Options:
|
|
|
293
294
|
"context": { "..." },
|
|
294
295
|
"outcome": { "..." },
|
|
295
296
|
"promise_tag": "RESEARCH_PARANOID_PASSED",
|
|
297
|
+
"usage_count": 0,
|
|
296
298
|
"expires_at": "2026-05-15T14:30:00Z"
|
|
297
299
|
}
|
|
298
300
|
```
|
|
@@ -98,7 +98,7 @@ echo 'export ANTHROPIC_API_KEY="sk-ant-..."' >> ~/.bashrc
|
|
|
98
98
|
source ~/.bashrc
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
> **Токены и стоимость:** Полный BTO-цикл (BUILD + TEST + OPTIMIZE) потребляет примерно 100–200K токенов.
|
|
101
|
+
> **Токены и стоимость:** Полный BTO-цикл (BUILD + BENCHMARK + TEST + OPTIMIZE) потребляет примерно 100–200K токенов. BENCHMARK (B0-B3) добавляет ~3.5K токенов (B0/B1/B3 детерминистические, B2 consistency probe — 3× haiku). Детальная разбивка: BUILD ~22K, BENCHMARK ~3.5K, TEST Layer 2 ~19K (sonnet×3), OPTIMIZE 3 rounds ~131K. Итого ~175K токенов за полный прогон. Отдельный `/bto-benchmark` потребляет ~3.5K токенов, `/bto-test` с Layer 2 — около 15–20K токенов.
|
|
102
102
|
|
|
103
103
|
### 1.4. Git (опционально, но рекомендуется)
|
|
104
104
|
|
|
@@ -27,16 +27,19 @@
|
|
|
27
27
|
| Компонент | Путь | Назначение |
|
|
28
28
|
|-----------|------|------------|
|
|
29
29
|
| BTO Skill | `.claude/skills/bto/` | Основной оркестратор: загружается командами |
|
|
30
|
-
| SKILL.md | `.claude/skills/bto/SKILL.md` | Точка входа, документирует все
|
|
30
|
+
| SKILL.md | `.claude/skills/bto/SKILL.md` | Точка входа, документирует все четыре модуля |
|
|
31
31
|
| Модуль BUILD | `.claude/skills/bto/modules/build.md` | Протокол генерации артефактов |
|
|
32
|
+
| Модуль BENCHMARK | `.claude/skills/bto/modules/benchmark.md` | Детерминистический бенчмаркинг (B0-B3) |
|
|
32
33
|
| Модуль TEST | `.claude/skills/bto/modules/test.md` | Протокол мульти-агентной оценки |
|
|
33
34
|
| Модуль OPTIMIZE | `.claude/skills/bto/modules/optimize.md` | Протокол эволюционной оптимизации |
|
|
34
35
|
| Рубрики судей | `.claude/skills/bto/references/judge-rubrics.md` | Якорные точки для scoring |
|
|
35
36
|
| Паттерны оценки | `.claude/skills/bto/references/eval-patterns.md` | Паттерны мульти-агентной оценки |
|
|
36
37
|
| Методы оптимизации | `.claude/skills/bto/references/optimization-methods.md` | Методология оптимизации |
|
|
37
38
|
| Чеклист качества | `.claude/skills/bto/references/quality-checklist.md` | Детерминистические проверки Layer 0 |
|
|
39
|
+
| Golden samples | `.claude/skills/bto/references/golden-samples.md` | Эталонные структуры для бенчмаркинга |
|
|
38
40
|
| Команда /bto | `.claude/commands/bto.md` | Полный пайплайн |
|
|
39
41
|
| Команда /bto-build | `.claude/commands/bto-build.md` | BUILD-фаза отдельно |
|
|
42
|
+
| Команда /bto-benchmark | `.claude/commands/bto-benchmark.md` | BENCHMARK-фаза отдельно |
|
|
40
43
|
| Команда /bto-test | `.claude/commands/bto-test.md` | TEST-фаза отдельно |
|
|
41
44
|
| Команда /bto-optimize | `.claude/commands/bto-optimize.md` | OPTIMIZE-фаза отдельно |
|
|
42
45
|
| Правила quality gates | `.claude/rules/bto-quality-gates.md` | Автоматически применяемые правила |
|
|
@@ -20,13 +20,14 @@ This guide covers everything you need to use the BTO (Build-Test-Optimize) skill
|
|
|
20
20
|
|
|
21
21
|
## 1. Quick Start (5 minutes)
|
|
22
22
|
|
|
23
|
-
BTO gives you
|
|
23
|
+
BTO gives you five commands. Each can be used independently or together as a pipeline.
|
|
24
24
|
|
|
25
25
|
```
|
|
26
26
|
/bto-build [description] — Generate a new skill, command, rule, or agent template
|
|
27
|
+
/bto-benchmark [path] — Deterministic benchmarking against golden samples
|
|
27
28
|
/bto-test [path] — Evaluate an existing artifact through layered quality gates
|
|
28
29
|
/bto-optimize [path] — Improve an artifact through evolutionary optimization
|
|
29
|
-
/bto [path or description] — Full pipeline: BUILD → TEST → OPTIMIZE
|
|
30
|
+
/bto [path or description] — Full pipeline: BUILD → BENCHMARK → TEST → OPTIMIZE
|
|
30
31
|
```
|
|
31
32
|
|
|
32
33
|
### Your first BTO run
|
|
@@ -577,7 +578,7 @@ BTO does not automatically overwrite your artifact. It presents the optimized ve
|
|
|
577
578
|
|
|
578
579
|
## 5. Full BTO Pipeline with /bto
|
|
579
580
|
|
|
580
|
-
The `/bto` command runs BUILD, TEST, and OPTIMIZE in sequence for a complete quality lifecycle. Use it when starting a new artifact from scratch and wanting production-quality output with minimal manual intervention.
|
|
581
|
+
The `/bto` command runs BUILD, BENCHMARK, TEST, and OPTIMIZE in sequence for a complete quality lifecycle. Use it when starting a new artifact from scratch and wanting production-quality output with minimal manual intervention.
|
|
581
582
|
|
|
582
583
|
### Usage
|
|
583
584
|
|
|
@@ -251,9 +251,10 @@ Note: if convergence is detected after Round 2, Round 3 evaluation is skipped. T
|
|
|
251
251
|
| Stage | Est. tokens |
|
|
252
252
|
|-------|------------:|
|
|
253
253
|
| BUILD (QUICK mode, typical skill) | ~22,000 |
|
|
254
|
+
| BENCHMARK (B0-B3, incl. 3× haiku consistency probe) | ~3,500 |
|
|
254
255
|
| TEST (full, no meta-judge) | ~18,800 |
|
|
255
256
|
| OPTIMIZE (3 rounds) | ~131,000 |
|
|
256
|
-
| **Full /bto pipeline** | **~
|
|
257
|
+
| **Full /bto pipeline** | **~175,500** |
|
|
257
258
|
|
|
258
259
|
For a description-triggered build where DEEP mode is invoked: add approximately 10,000 tokens to the BUILD phase.
|
|
259
260
|
|
|
@@ -19,23 +19,23 @@
|
|
|
19
19
|
|
|
20
20
|
## Обзор системы и философия проектирования
|
|
21
21
|
|
|
22
|
-
`@dzhechkov/skills-bto` — это **Build-Test-Optimize (BTO)** скилл-пак для Claude Code, реализующий полный цикл создания, оценки и итеративного улучшения Claude Code артефактов. Система работает как standalone-инструмент и как интегрированный компонент пайплайна `@dzhechkov/keysarium`.
|
|
22
|
+
`@dzhechkov/skills-bto` — это **Build-Benchmark-Test-Optimize (BTO)** скилл-пак для Claude Code, реализующий полный цикл создания, бенчмаркинга, оценки и итеративного улучшения Claude Code артефактов. Система работает как standalone-инструмент и как интегрированный компонент пайплайна `@dzhechkov/keysarium`.
|
|
23
23
|
|
|
24
24
|
### Фундаментальная идея
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Промпт-инжиниринговые задачи имеют четыре отдельных фазы с принципиально разными требованиями:
|
|
27
27
|
|
|
28
28
|
```
|
|
29
|
-
BUILD TEST OPTIMIZE
|
|
30
|
-
────── ──── ────────
|
|
31
|
-
Генерация Оценка Улучшение
|
|
32
|
-
Требует: Требует: Требует:
|
|
33
|
-
• Творчество • Объективность • Управляемые мутации
|
|
34
|
-
• Структуру • Разные точки зр. • Быструю итерацию
|
|
35
|
-
• Domain знание •
|
|
29
|
+
BUILD BENCHMARK TEST OPTIMIZE
|
|
30
|
+
────── ───────── ──── ────────
|
|
31
|
+
Генерация Бенчмаркинг Оценка Улучшение
|
|
32
|
+
Требует: Требует: Требует: Требует:
|
|
33
|
+
• Творчество • Golden samples • Объективность • Управляемые мутации
|
|
34
|
+
• Структуру • Детерм. тесты • Разные точки зр. • Быструю итерацию
|
|
35
|
+
• Domain знание • Consistency probe • Экспертные судьи • Отбор лучших вариантов
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
BTO изолирует эти
|
|
38
|
+
BTO изолирует эти четыре режима в отдельные модули с чёткими контрактами на входе и выходе. Модули можно запускать независимо или последовательно как пайплайн.
|
|
39
39
|
|
|
40
40
|
### Ключевые принципы проектирования
|
|
41
41
|
|
|
@@ -717,7 +717,7 @@ Variant 3-B ──→ haiku eval ──→ score-3-B.txt ┘
|
|
|
717
717
|
|
|
718
718
|
## Диаграммы потоков данных
|
|
719
719
|
|
|
720
|
-
### Полный BTO пайплайн (BUILD → TEST → OPTIMIZE)
|
|
720
|
+
### Полный BTO пайплайн (BUILD → BENCHMARK → TEST → OPTIMIZE)
|
|
721
721
|
|
|
722
722
|
```mermaid
|
|
723
723
|
flowchart TD
|
|
@@ -947,8 +947,9 @@ flowchart LR
|
|
|
947
947
|
|
|
948
948
|
| Команда | Назначение | Минимальный вход | Стоимость |
|
|
949
949
|
|---------|-----------|-----------------|-----------|
|
|
950
|
-
| `/bto [path]` | Полный пайплайн BUILD→TEST→OPTIMIZE | Путь или описание | ~$0.
|
|
950
|
+
| `/bto [path]` | Полный пайплайн BUILD→BENCHMARK→TEST→OPTIMIZE | Путь или описание | ~$0.16 |
|
|
951
951
|
| `/bto-build [description]` | Только генерация | Текстовое описание | ~$0.01 |
|
|
952
|
+
| `/bto-benchmark [path]` | Детерминистический бенчмаркинг | Путь к артефакту | ~$0.001 |
|
|
952
953
|
| `/bto-test [path]` | Только оценка (full) | Путь к артефакту | ~$0.01 |
|
|
953
954
|
| `/bto-test [path] level=layer0` | Только Layer 0 | Путь к артефакту | $0 |
|
|
954
955
|
| `/bto-test [path] level=layer1` | Layer 0 + haiku | Путь к артефакту | ~$0.001 |
|
|
@@ -118,7 +118,7 @@ Location: `.keysarium/insights/trigger-state.json`
|
|
|
118
118
|
4. Scan all `*.json` files recursively under `.keysarium/memory/` (excluding `config.json`, `reward-summary.json`, `domain-patterns.json`).
|
|
119
119
|
5. Parse each as a RewardRecord (schema defined in `lib/memory-protocol.md`).
|
|
120
120
|
6. Exclude records where `expires_at < current_date`.
|
|
121
|
-
7. Sort by `reward` DESC, then `timestamp` DESC.
|
|
121
|
+
7. Sort by `reward` DESC, then `usage_count` DESC, then `timestamp` DESC. Records with higher usage_count carry more weight in concept graph construction.
|
|
122
122
|
8. Take top 200 records.
|
|
123
123
|
9. If fewer than 5 valid records, exit with status `insufficient_data`.
|
|
124
124
|
|
|
@@ -83,6 +83,7 @@ The index provides a compact catalog of all records, enabling targeted reads ins
|
|
|
83
83
|
"reward": 0.7,
|
|
84
84
|
"skill": "goap-research-ed25519",
|
|
85
85
|
"tier": "hot",
|
|
86
|
+
"usage_count": 0,
|
|
86
87
|
"file": "banking/bank_kc_automation/phase-2_2026-03-01T12-30-00.json",
|
|
87
88
|
"expires_at": "2026-08-28T12:30:00Z"
|
|
88
89
|
}
|
|
@@ -128,7 +129,7 @@ Call at the **start** of each pipeline phase to load relevant historical pattern
|
|
|
128
129
|
- Update `index.json`: set `tier` to `"cold"`, update `file` path
|
|
129
130
|
- Log: "Archived {count} records to cold storage in {domain}"
|
|
130
131
|
6. **Purge ancient records (v1.1):** Delete records from `_archive/` older than `tier_cold_days`. In v1.0 mode, delete records where `expires_at < current_date`. Update `index.json`. Log: "Purged {count} expired records from {domain}"
|
|
131
|
-
7. **Sort:** By `reward` DESC, then `timestamp` DESC. HOT and WARM records first; COLD records included only if result count < `max_results_per_query`.
|
|
132
|
+
7. **Sort:** By `reward` DESC, then `usage_count` DESC, then `timestamp` DESC. HOT and WARM records first; COLD records included only if result count < `max_results_per_query`. Records with higher usage_count are more battle-tested and should be preferred when rewards are equal.
|
|
132
133
|
8. **Limit:** Return top `max_results_per_query` records (default 10).
|
|
133
134
|
9. **Enrich:** Also load `.keysarium/memory/_patterns/domain-patterns.json` for matching domain patterns.
|
|
134
135
|
|
|
@@ -167,6 +168,7 @@ After calling `memory_query()`, the agent should:
|
|
|
167
168
|
2. If `records` is non-empty, review the top 3 records for relevant approaches
|
|
168
169
|
3. If `patterns` is non-empty, apply actionable advice to current phase execution
|
|
169
170
|
4. If both are empty (first run), proceed normally
|
|
171
|
+
5. **Increment usage_count:** For each record actually applied (top 3), increment `usage_count` in both the record file and the index entry. Records with higher usage_count are more proven — prioritize them in future queries.
|
|
170
172
|
|
|
171
173
|
## Protocol: memory_store(result, reward)
|
|
172
174
|
|
|
@@ -209,7 +211,7 @@ Call at each **checkpoint** after the user responds, to persist the phase outcom
|
|
|
209
211
|
4. **Generate filename:** `{phase}_{ISO-timestamp}.json` (e.g., `phase-2_2026-03-01T12-30-00.json`).
|
|
210
212
|
5. **Write file:** Write JSON to `.keysarium/memory/{domain}/{slug}/{filename}`.
|
|
211
213
|
6. **Update index (v1.1):** Read `.keysarium/memory/index.json` (or create if absent and tier config is present):
|
|
212
|
-
- Add record entry to `records` map: key = record id, value = `{domain, phase, slug, reward, skill, tier: "hot", file, expires_at}`
|
|
214
|
+
- Add record entry to `records` map: key = record id, value = `{domain, phase, slug, reward, skill, tier: "hot", usage_count: 0, file, expires_at}`
|
|
213
215
|
- Increment `record_count`
|
|
214
216
|
- Update `by_domain` aggregate: increment count, add slug if new, recalculate `avg_reward`
|
|
215
217
|
- Update `by_phase` aggregate: increment count, recalculate `avg_reward`
|
|
@@ -248,6 +250,7 @@ Call at each **checkpoint** after the user responds, to persist the phase outcom
|
|
|
248
250
|
"promise_emitted": "RESEARCH_PARANOID_PASSED"
|
|
249
251
|
},
|
|
250
252
|
"promise_tag": "RESEARCH_PARANOID_PASSED",
|
|
253
|
+
"usage_count": 0,
|
|
251
254
|
"expires_at": "2026-08-28T12:30:00Z"
|
|
252
255
|
}
|
|
253
256
|
```
|
|
@@ -277,6 +280,7 @@ Tier thresholds are configurable via `config.json` fields: `tier_hot_days`, `tie
|
|
|
277
280
|
"reward_label": "good",
|
|
278
281
|
"skill_used": "goap-research-ed25519",
|
|
279
282
|
"promise_tag": "RESEARCH_PARANOID_PASSED",
|
|
283
|
+
"usage_count": 3,
|
|
280
284
|
"summary": "User requested minor edits to competitor analysis section. ok, but expand the FinTech competitor section",
|
|
281
285
|
"archived_at": "2026-03-02T14:00:00Z",
|
|
282
286
|
"original_timestamp": "2026-01-01T12:00:00Z"
|
|
@@ -86,12 +86,14 @@ Group records by `skill_used` and cross-reference with domain:
|
|
|
86
86
|
"goap-research-ed25519": {
|
|
87
87
|
"overall_avg": 0.74,
|
|
88
88
|
"total_runs": 15,
|
|
89
|
+
"total_usage_count": 42,
|
|
89
90
|
"by_domain": {
|
|
90
|
-
"banking": { "avg": 0.65, "runs": 8 },
|
|
91
|
-
"retail": { "avg": 0.85, "runs": 7 }
|
|
91
|
+
"banking": { "avg": 0.65, "runs": 8, "usage_count": 18 },
|
|
92
|
+
"retail": { "avg": 0.85, "runs": 7, "usage_count": 24 }
|
|
92
93
|
},
|
|
93
94
|
"best_domain": "retail",
|
|
94
|
-
"worst_domain": "banking"
|
|
95
|
+
"worst_domain": "banking",
|
|
96
|
+
"most_reused_domain": "retail"
|
|
95
97
|
}
|
|
96
98
|
}
|
|
97
99
|
```
|
|
@@ -110,6 +112,7 @@ Analyze accumulated data to detect actionable patterns. Each pattern has a confi
|
|
|
110
112
|
| Improving Trend | Trend = "improving" for phase in domain | "{phase} quality is improving in {domain} domain" |
|
|
111
113
|
| Degrading Trend | Trend = "degrading" for phase in domain | "{phase} quality is degrading in {domain} -- investigate" |
|
|
112
114
|
| Time Overhead | Phase avg iterations > 2.0 in domain | "{domain} cases require more iterations in {phase}" |
|
|
115
|
+
| High Reuse | Record usage_count >= 5 | "Pattern from {slug}/{phase} is highly reused ({count} times) — consider promoting to a rule" |
|
|
113
116
|
|
|
114
117
|
**Confidence Calculation:**
|
|
115
118
|
```
|