zaileys 2.2.6 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent/skills/codebase-mapper/SKILL.md +226 -0
- package/.agent/skills/context-compressor/SKILL.md +201 -0
- package/.agent/skills/context-fetch/SKILL.md +184 -0
- package/.agent/skills/context-health-monitor/SKILL.md +105 -0
- package/.agent/skills/debugger/SKILL.md +273 -0
- package/.agent/skills/empirical-validation/SKILL.md +97 -0
- package/.agent/skills/executor/SKILL.md +465 -0
- package/.agent/skills/plan-checker/SKILL.md +283 -0
- package/.agent/skills/planner/SKILL.md +485 -0
- package/.agent/skills/token-budget/SKILL.md +166 -0
- package/.agent/skills/verifier/SKILL.md +421 -0
- package/.agent/workflows/add-phase.md +96 -0
- package/.agent/workflows/add-todo.md +69 -0
- package/.agent/workflows/audit-milestone.md +107 -0
- package/.agent/workflows/check-todos.md +80 -0
- package/.agent/workflows/complete-milestone.md +135 -0
- package/.agent/workflows/debug.md +235 -0
- package/.agent/workflows/discuss-phase.md +103 -0
- package/.agent/workflows/execute.md +325 -0
- package/.agent/workflows/health.md +122 -0
- package/.agent/workflows/help.md +96 -0
- package/.agent/workflows/insert-phase.md +109 -0
- package/.agent/workflows/install.md +152 -0
- package/.agent/workflows/list-phase-assumptions.md +82 -0
- package/.agent/workflows/map.md +394 -0
- package/.agent/workflows/new-milestone.md +126 -0
- package/.agent/workflows/new-project.md +368 -0
- package/.agent/workflows/pause.md +176 -0
- package/.agent/workflows/plan-milestone-gaps.md +116 -0
- package/.agent/workflows/plan.md +380 -0
- package/.agent/workflows/progress.md +90 -0
- package/.agent/workflows/quick.md +128 -0
- package/.agent/workflows/remove-phase.md +139 -0
- package/.agent/workflows/research-phase.md +160 -0
- package/.agent/workflows/resume.md +131 -0
- package/.agent/workflows/update.md +203 -0
- package/.agent/workflows/verify.md +263 -0
- package/.agent/workflows/web-search.md +121 -0
- package/.agent/workflows/whats-new.md +80 -0
- package/.gemini/GEMINI.md +67 -0
- package/.gsd/DEBUG.md +26 -0
- package/.gsd/GSD-STYLE.md +272 -0
- package/.gsd/PROJECT_RULES.md +256 -0
- package/.gsd/ROADMAP.md +38 -0
- package/.gsd/SPEC.md +16 -0
- package/.gsd/STATE.md +10 -0
- package/.gsd/adapters/CLAUDE.md +77 -0
- package/.gsd/adapters/GEMINI.md +92 -0
- package/.gsd/adapters/GPT_OSS.md +130 -0
- package/.gsd/docs/model-selection-playbook.md +128 -0
- package/.gsd/docs/runbook.md +296 -0
- package/.gsd/docs/token-optimization-guide.md +207 -0
- package/.gsd/model_capabilities.yaml +108 -0
- package/.gsd/phases/1/1-PLAN.md +44 -0
- package/.gsd/phases/1/2-PLAN.md +54 -0
- package/.gsd/phases/1/3-PLAN.md +46 -0
- package/.gsd/phases/1/4-PLAN.md +39 -0
- package/.gsd/phases/2/2-1-SUMMARY.md +8 -0
- package/.gsd/phases/2/2-PLAN.md +47 -0
- package/.gsd/phases/3/3-1-SUMMARY.md +8 -0
- package/.gsd/phases/3/3-PLAN.md +43 -0
- package/.gsd/phases/4/4-1-PLAN.md +44 -0
- package/.gsd/phases/4/4-1-SUMMARY.md +8 -0
- package/.gsd/phases/4/4-2-PLAN.md +59 -0
- package/.gsd/phases/4/4-2-SUMMARY.md +8 -0
- package/.gsd/phases/4/4-3-PLAN.md +42 -0
- package/.gsd/phases/4/4-3-SUMMARY.md +8 -0
- package/.gsd/phases/4/VERIFICATION.md +8 -0
- package/.gsd/phases/5/1-SUMMARY.md +5 -0
- package/.gsd/phases/5/5-PLAN.md +47 -0
- package/.gsd/phases/5/RESEARCH.md +24 -0
- package/.gsd/phases/5/VERIFICATION.md +8 -0
- package/.gsd/phases/6/1-SUMMARY.md +6 -0
- package/.gsd/phases/6/6-PLAN.md +46 -0
- package/.gsd/phases/6/RESEARCH.md +33 -0
- package/.gsd/phases/6/VERIFICATION.md +7 -0
- package/.gsd/phases/7/1-SUMMARY.md +12 -0
- package/.gsd/phases/7/7-PLAN.md +78 -0
- package/.gsd/phases/7/VERIFICATION.md +7 -0
- package/.gsd/templates/DEBUG.md +123 -0
- package/.gsd/templates/PLAN.md +90 -0
- package/.gsd/templates/RESEARCH.md +75 -0
- package/.gsd/templates/SUMMARY.md +103 -0
- package/.gsd/templates/UAT.md +168 -0
- package/.gsd/templates/VERIFICATION.md +70 -0
- package/.gsd/templates/architecture.md +67 -0
- package/.gsd/templates/context.md +91 -0
- package/.gsd/templates/decisions.md +37 -0
- package/.gsd/templates/discovery.md +122 -0
- package/.gsd/templates/journal.md +46 -0
- package/.gsd/templates/milestone.md +91 -0
- package/.gsd/templates/phase-summary.md +52 -0
- package/.gsd/templates/project.md +124 -0
- package/.gsd/templates/requirements.md +92 -0
- package/.gsd/templates/roadmap.md +103 -0
- package/.gsd/templates/spec.md +51 -0
- package/.gsd/templates/sprint.md +57 -0
- package/.gsd/templates/stack.md +62 -0
- package/.gsd/templates/state.md +92 -0
- package/.gsd/templates/state_snapshot.md +132 -0
- package/.gsd/templates/todo.md +32 -0
- package/.gsd/templates/token_report.md +79 -0
- package/.gsd/templates/user-setup.md +116 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/LICENSE +21 -21
- package/README.MD +1280 -1231
- package/commitlint.config.js +3 -0
- package/dist/index.d.mts +1397 -908
- package/dist/index.d.ts +1397 -908
- package/dist/index.js +29 -28
- package/dist/index.mjs +29 -28
- package/package.json +11 -27
- package/tsconfig.json +19 -19
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Token Optimization Guide
|
|
2
|
+
|
|
3
|
+
> Practical strategies for reducing token consumption while maintaining quality.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Why Token Optimization Matters
|
|
8
|
+
|
|
9
|
+
| Issue | Impact |
|
|
10
|
+
|-------|--------|
|
|
11
|
+
| Excessive file loading | Higher costs, slower responses |
|
|
12
|
+
| Context accumulation | Quality degradation after 50% |
|
|
13
|
+
| Re-reading files | Wasted tokens on understood content |
|
|
14
|
+
| Full files when snippets suffice | 10x token usage |
|
|
15
|
+
|
|
16
|
+
**Goal:** Maximize output quality per token spent.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## The Token Efficiency Stack
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
┌─────────────────────────────────────┐
|
|
24
|
+
│ 1. Search-First (context-fetch) │ ← Find before loading
|
|
25
|
+
├─────────────────────────────────────┤
|
|
26
|
+
│ 2. Budget Tracking (token-budget) │ ← Know your limits
|
|
27
|
+
├─────────────────────────────────────┤
|
|
28
|
+
│ 3. Compression (context-compressor)│ ← Minimize footprint
|
|
29
|
+
├─────────────────────────────────────┤
|
|
30
|
+
│ 4. Health Monitoring │ ← Prevent degradation
|
|
31
|
+
└─────────────────────────────────────┘
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Quick Reference: Token Costs
|
|
37
|
+
|
|
38
|
+
### By Content Type
|
|
39
|
+
|
|
40
|
+
| Type | Tokens/Line | 100 Lines = |
|
|
41
|
+
|------|-------------|-------------|
|
|
42
|
+
| Dense code | 6 | ~600 tokens |
|
|
43
|
+
| Standard code | 4 | ~400 tokens |
|
|
44
|
+
| Markdown | 3 | ~300 tokens |
|
|
45
|
+
| Sparse YAML | 2 | ~200 tokens |
|
|
46
|
+
|
|
47
|
+
### By File Size
|
|
48
|
+
|
|
49
|
+
| File Lines | Strategy |
|
|
50
|
+
|------------|----------|
|
|
51
|
+
| <50 | Load freely |
|
|
52
|
+
| 50-200 | Outline first |
|
|
53
|
+
| 200-500 | Search + snippets |
|
|
54
|
+
| 500+ | Never load fully |
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Optimization Patterns
|
|
59
|
+
|
|
60
|
+
### Pattern 1: Search → Outline → Target
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Step 1: Search for "handlePayment"
|
|
64
|
+
→ Found in: payment.ts:45, checkout.ts:120
|
|
65
|
+
|
|
66
|
+
Step 2: Get outline of payment.ts
|
|
67
|
+
→ L45-80: handlePayment function
|
|
68
|
+
|
|
69
|
+
Step 3: Load only L45-80
|
|
70
|
+
→ 35 lines (~140 tokens) vs 400 lines (~1600 tokens)
|
|
71
|
+
→ Saved: ~90%
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Pattern 2: Summarize After Understanding
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
After reading auth.ts:
|
|
78
|
+
|
|
79
|
+
## Summary: auth.ts
|
|
80
|
+
- Exports: login, logout, validateToken
|
|
81
|
+
- Pattern: Express middleware
|
|
82
|
+
- DB: queries users table
|
|
83
|
+
- JWT: uses jose library
|
|
84
|
+
|
|
85
|
+
Next time: Reference summary, don't reload
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Pattern 3: Progressive Disclosure
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
Need: Understand login flow
|
|
92
|
+
|
|
93
|
+
Level 1: Outline
|
|
94
|
+
→ "login at L45, uses validateCredentials at L67"
|
|
95
|
+
→ Often sufficient
|
|
96
|
+
|
|
97
|
+
Level 2: Key function
|
|
98
|
+
→ Load L45-65 only
|
|
99
|
+
→ Understand core logic
|
|
100
|
+
|
|
101
|
+
Level 3: Dependencies
|
|
102
|
+
→ Load validateCredentials (L67-85)
|
|
103
|
+
→ Only if L2 insufficient
|
|
104
|
+
|
|
105
|
+
Level 4: Full file
|
|
106
|
+
→ Last resort, re-compress after
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Anti-Patterns to Avoid
|
|
112
|
+
|
|
113
|
+
### ❌ The "Context Dump"
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
BAD:
|
|
117
|
+
"Let me read all the files in src/ to understand the project"
|
|
118
|
+
→ 50 files × 200 lines × 4 tokens = 40,000 tokens
|
|
119
|
+
|
|
120
|
+
GOOD:
|
|
121
|
+
"Let me search for 'main entry' and 'router'"
|
|
122
|
+
→ 2 targeted searches, ~500 tokens
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### ❌ The "Just In Case" Load
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
BAD:
|
|
129
|
+
"Loading utils.ts in case I need it later"
|
|
130
|
+
→ Probably won't need it, wasted tokens
|
|
131
|
+
|
|
132
|
+
GOOD:
|
|
133
|
+
"Noting utils.ts exists, will load if needed"
|
|
134
|
+
→ Zero tokens until actually needed
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### ❌ The Re-Read
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
BAD:
|
|
141
|
+
"Reading config.ts again to check the port"
|
|
142
|
+
→ Already read it twice = 1200 tokens
|
|
143
|
+
|
|
144
|
+
GOOD:
|
|
145
|
+
"From my earlier analysis, port is on L15"
|
|
146
|
+
→ Zero additional tokens
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Budget Checkpoints
|
|
152
|
+
|
|
153
|
+
### Before Starting Work
|
|
154
|
+
|
|
155
|
+
```markdown
|
|
156
|
+
□ Do I know my current budget usage?
|
|
157
|
+
□ Have I tried searching before loading?
|
|
158
|
+
□ Am I loading files I've already understood?
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### During Execution
|
|
162
|
+
|
|
163
|
+
```markdown
|
|
164
|
+
□ Am I at >50%? Time to compress.
|
|
165
|
+
□ Am I re-reading files? Use summaries.
|
|
166
|
+
□ Can I use outline instead of full file?
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### After Each Wave
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
□ Have I compressed context for next wave?
|
|
173
|
+
□ Are summaries documented in STATE.md?
|
|
174
|
+
□ Would a fresh session be more efficient?
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Integration with GSD
|
|
180
|
+
|
|
181
|
+
| GSD Workflow | Token Optimization |
|
|
182
|
+
|--------------|-------------------|
|
|
183
|
+
| `/map` | Generate outline, not full read |
|
|
184
|
+
| `/plan` | Budget estimate per task |
|
|
185
|
+
| `/execute` | Load minimal per task |
|
|
186
|
+
| `/verify` | Targeted evidence only |
|
|
187
|
+
| `/pause` | Compress and dump state |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Metrics
|
|
192
|
+
|
|
193
|
+
Track these for improvement:
|
|
194
|
+
|
|
195
|
+
| Metric | Good | Poor |
|
|
196
|
+
|--------|------|------|
|
|
197
|
+
| Files fully loaded | <3 per wave | 10+ |
|
|
198
|
+
| Search:Load ratio | 3:1 | 1:3 |
|
|
199
|
+
| Re-reads | 0 | 3+ |
|
|
200
|
+
| Budget at wave end | <50% | >70% |
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
*See also:*
|
|
205
|
+
- *[.agent/skills/token-budget/SKILL.md](.agent/skills/token-budget/SKILL.md)*
|
|
206
|
+
- *[.agent/skills/context-compressor/SKILL.md](.agent/skills/context-compressor/SKILL.md)*
|
|
207
|
+
- *[PROJECT_RULES.md](PROJECT_RULES.md) — Token Efficiency Rules*
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Model Capabilities Registry
|
|
2
|
+
#
|
|
3
|
+
# This file is OPTIONAL. GSD works without it.
|
|
4
|
+
# If present, it provides guidance for model selection.
|
|
5
|
+
#
|
|
6
|
+
# Usage: Reference this file when choosing models by capability.
|
|
7
|
+
# Do NOT make any workflow depend on this file existing.
|
|
8
|
+
|
|
9
|
+
# Capability definitions
|
|
10
|
+
capabilities:
|
|
11
|
+
thinking_mode:
|
|
12
|
+
description: "Extended reasoning with internal monologue"
|
|
13
|
+
benefits:
|
|
14
|
+
- Better for complex planning
|
|
15
|
+
- Improved debugging hypotheses
|
|
16
|
+
- More thorough architecture analysis
|
|
17
|
+
|
|
18
|
+
long_context:
|
|
19
|
+
description: "Context window > 100k tokens"
|
|
20
|
+
benefits:
|
|
21
|
+
- Can analyze multiple files at once
|
|
22
|
+
- Better for large refactors
|
|
23
|
+
- Full codebase reviews
|
|
24
|
+
|
|
25
|
+
tools:
|
|
26
|
+
description: "Function/tool calling support"
|
|
27
|
+
benefits:
|
|
28
|
+
- Execute verification commands
|
|
29
|
+
- Interact with external systems
|
|
30
|
+
- Structured outputs
|
|
31
|
+
|
|
32
|
+
speed_tier:
|
|
33
|
+
description: "Response latency tier"
|
|
34
|
+
values:
|
|
35
|
+
- fast: "< 2s average, good for iteration"
|
|
36
|
+
- standard: "2-5s average, balanced"
|
|
37
|
+
- reasoning: "> 5s average, deep analysis"
|
|
38
|
+
|
|
39
|
+
# Example model profiles (illustrative, not exhaustive)
|
|
40
|
+
# These show how to categorize models by capability type.
|
|
41
|
+
|
|
42
|
+
profiles:
|
|
43
|
+
# Fast iteration models
|
|
44
|
+
fast_coder:
|
|
45
|
+
speed_tier: fast
|
|
46
|
+
thinking_mode: false
|
|
47
|
+
long_context: false
|
|
48
|
+
tools: true
|
|
49
|
+
best_for:
|
|
50
|
+
- Quick edits
|
|
51
|
+
- Simple implementations
|
|
52
|
+
- Frequent iteration cycles
|
|
53
|
+
examples:
|
|
54
|
+
- "Flash/Turbo variants"
|
|
55
|
+
- "Smaller parameter models"
|
|
56
|
+
|
|
57
|
+
# Standard balanced models
|
|
58
|
+
standard:
|
|
59
|
+
speed_tier: standard
|
|
60
|
+
thinking_mode: false
|
|
61
|
+
long_context: true
|
|
62
|
+
tools: true
|
|
63
|
+
best_for:
|
|
64
|
+
- Most development tasks
|
|
65
|
+
- Moderate refactoring
|
|
66
|
+
- General coding
|
|
67
|
+
examples:
|
|
68
|
+
- "Pro/Standard variants"
|
|
69
|
+
- "Mid-tier models"
|
|
70
|
+
|
|
71
|
+
# Deep reasoning models
|
|
72
|
+
reasoning:
|
|
73
|
+
speed_tier: reasoning
|
|
74
|
+
thinking_mode: true
|
|
75
|
+
long_context: true
|
|
76
|
+
tools: true
|
|
77
|
+
best_for:
|
|
78
|
+
- Architecture planning
|
|
79
|
+
- Complex debugging
|
|
80
|
+
- Security analysis
|
|
81
|
+
examples:
|
|
82
|
+
- "Thinking/Reasoning variants"
|
|
83
|
+
- "Advanced reasoning models"
|
|
84
|
+
|
|
85
|
+
# Phase recommendations (suggestions, not requirements)
|
|
86
|
+
phase_recommendations:
|
|
87
|
+
planning:
|
|
88
|
+
preferred_profile: reasoning
|
|
89
|
+
reason: "Complex decisions benefit from extended thinking"
|
|
90
|
+
|
|
91
|
+
implementation:
|
|
92
|
+
preferred_profile: fast_coder
|
|
93
|
+
reason: "Frequent iteration needs speed"
|
|
94
|
+
|
|
95
|
+
refactoring:
|
|
96
|
+
preferred_profile: standard
|
|
97
|
+
reason: "Balance of context and speed"
|
|
98
|
+
|
|
99
|
+
debugging:
|
|
100
|
+
preferred_profile: reasoning
|
|
101
|
+
reason: "Hypothesis generation needs depth"
|
|
102
|
+
|
|
103
|
+
review:
|
|
104
|
+
preferred_profile: standard
|
|
105
|
+
reason: "Large context for full diffs"
|
|
106
|
+
|
|
107
|
+
# IMPORTANT: This file is for guidance only.
|
|
108
|
+
# Never fail a workflow because a specific model capability is missing.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 1
|
|
3
|
+
plan: 1
|
|
4
|
+
wave: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plan 1.1: Database Configuration & Auth State
|
|
8
|
+
|
|
9
|
+
## Objective
|
|
10
|
+
Migrate fundamental DB configuration handling and authentication module to LMDB.
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
- src/Config/database.ts
|
|
14
|
+
- src/Auth/state.ts
|
|
15
|
+
|
|
16
|
+
## Tasks
|
|
17
|
+
|
|
18
|
+
<task type="auto">
|
|
19
|
+
<name>Configure Native LMDB</name>
|
|
20
|
+
<files>src/Config/database.ts</files>
|
|
21
|
+
<action>
|
|
22
|
+
- Import `open` from `lmdb`.
|
|
23
|
+
- Change `CredsDatabase`, `KeysDatabase`, and `WaDatabase` to return native `lmdb` instances calling `open({ path: ..., compression: true/false })` natively.
|
|
24
|
+
- Remove JetDB-specific configurations like flushMode, hotThreshold that don't apply directly.
|
|
25
|
+
</action>
|
|
26
|
+
<verify>npm run build</verify>
|
|
27
|
+
<done>database.ts is updated to use solely lmdb.</done>
|
|
28
|
+
</task>
|
|
29
|
+
|
|
30
|
+
<task type="auto">
|
|
31
|
+
<name>Migrate Auth State to LMDB</name>
|
|
32
|
+
<files>src/Auth/state.ts</files>
|
|
33
|
+
<action>
|
|
34
|
+
- Update type handling for `credsDb` and `keysDb`.
|
|
35
|
+
- Replace `keysDb.batchSet(operations)` and `keysDb.batchDelete(deleteKeys)` with a single native LMDB `transaction(() => { ... })` combining `put` and `remove` calls.
|
|
36
|
+
- Remove `.flush()` if unnecessary (LMDB auto-syncs), or ignore as it's safe to drop.
|
|
37
|
+
</action>
|
|
38
|
+
<verify>npm run build</verify>
|
|
39
|
+
<done>Authentication state reads and writes natively using lmdb.</done>
|
|
40
|
+
</task>
|
|
41
|
+
|
|
42
|
+
## Success Criteria
|
|
43
|
+
- [ ] database.ts returns LMDB instances.
|
|
44
|
+
- [ ] state.ts successfully manipulates those instances directly.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 1
|
|
3
|
+
plan: 2
|
|
4
|
+
wave: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plan 1.2: Refactor Health, Client and Cleanup Logic
|
|
8
|
+
|
|
9
|
+
## Objective
|
|
10
|
+
Migrate secondary database consumers (Health Manager, Background Cleanup, Client API) to LMDB.
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
- src/Classes/client.ts
|
|
14
|
+
- src/Library/health-manager.ts
|
|
15
|
+
- src/Library/cleanup-manager.ts
|
|
16
|
+
|
|
17
|
+
## Tasks
|
|
18
|
+
|
|
19
|
+
<task type="auto">
|
|
20
|
+
<name>Update Client Database Return Type</name>
|
|
21
|
+
<files>src/Classes/client.ts</files>
|
|
22
|
+
<action>
|
|
23
|
+
- Update the return type of the `db(scope)` to `RootDatabase` from `lmdb` instead of `JetDB`.
|
|
24
|
+
- Drop `JetDB` import.
|
|
25
|
+
</action>
|
|
26
|
+
<verify>npx tsc --noEmit</verify>
|
|
27
|
+
<done>Client TS types reflect LMDB Database instance correctly.</done>
|
|
28
|
+
</task>
|
|
29
|
+
|
|
30
|
+
<task type="auto">
|
|
31
|
+
<name>Migrate Health Manager Session Repairs</name>
|
|
32
|
+
<files>src/Library/health-manager.ts</files>
|
|
33
|
+
<action>
|
|
34
|
+
- Replace JetDB `.batchDelete(keys)` with LMDB `transaction(() => ...)` deleting the keys via `.remove()`.
|
|
35
|
+
- Delete the `keysDb.flush()` call.
|
|
36
|
+
</action>
|
|
37
|
+
<verify>npx tsc --noEmit</verify>
|
|
38
|
+
<done>Health manager appropriately issues deletes using LMDB's API.</done>
|
|
39
|
+
</task>
|
|
40
|
+
|
|
41
|
+
<task type="auto">
|
|
42
|
+
<name>Migrate Cleanup Manager Queries</name>
|
|
43
|
+
<files>src/Library/cleanup-manager.ts</files>
|
|
44
|
+
<action>
|
|
45
|
+
- Convert complex `.query().where().get()` filter to a fast LMDB `.getRange()` filtering values or scanning keys that contain timestamps.
|
|
46
|
+
- Because LMDB items might have different schemas, ensure iteration only fetches values parsing their timestamps cleanly, or implement secondary indexes later if too slow.
|
|
47
|
+
- Alternatively, migrate to storing time-sorted keys if necessary. Keep it simple: loop through keys and check JSON value timestamp.
|
|
48
|
+
</action>
|
|
49
|
+
<verify>npx tsc --noEmit</verify>
|
|
50
|
+
<done>Cleanup manager safely scans and bulk deletes old elements using LMDB directly.</done>
|
|
51
|
+
</task>
|
|
52
|
+
|
|
53
|
+
## Success Criteria
|
|
54
|
+
- [ ] Classes correctly access LMDB native methods.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 1
|
|
3
|
+
plan: 3
|
|
4
|
+
wave: 2
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plan 1.3: Refactor Listener Messages & Socket
|
|
8
|
+
|
|
9
|
+
## Objective
|
|
10
|
+
Migrate complex message parsing queries from JetDB's API structure to LMDB.
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
- src/Listener/messages.ts
|
|
14
|
+
- src/Listener/index.ts
|
|
15
|
+
- src/Config/socket.ts
|
|
16
|
+
|
|
17
|
+
## Tasks
|
|
18
|
+
|
|
19
|
+
<task type="auto">
|
|
20
|
+
<name>Migrate Message Upserts & Indexes</name>
|
|
21
|
+
<files>src/Listener/index.ts</files>
|
|
22
|
+
<action>
|
|
23
|
+
- Instead of `db.batchUpsert('messages', messages, 'key.id')`, use an LMDB transaction to iterate over models and `.put(item.key.id, item)`.
|
|
24
|
+
- Drop `.createIndex()` as LMDB doesn't natively use that wrapper technique. We can rely on primary key lookups if `key.id` is the main PK.
|
|
25
|
+
</action>
|
|
26
|
+
<verify>npx tsc --noEmit</verify>
|
|
27
|
+
<done>Listener correctly transaction-saves batch array payloads into LMDB.</done>
|
|
28
|
+
</task>
|
|
29
|
+
|
|
30
|
+
<task type="auto">
|
|
31
|
+
<name>Rewrite Message Retrieve Queries</name>
|
|
32
|
+
<files>
|
|
33
|
+
src/Listener/messages.ts
|
|
34
|
+
src/Config/socket.ts
|
|
35
|
+
</files>
|
|
36
|
+
<action>
|
|
37
|
+
- Replace JetDB `.getByIndex('messages', 'key.id', key.id)` and `.query(output.roomId).where('key.id', '=', universalId).first()` with simple native DB operations like `.get(key.id)` since we will model the DB to be keyed by `key.id`.
|
|
38
|
+
- Update schema logic: `put(item.key.id, item)` natively provides instant `.get(item.key.id)` without index lookups.
|
|
39
|
+
</action>
|
|
40
|
+
<verify>npx tsc --noEmit</verify>
|
|
41
|
+
<done>Message handlers directly retrieve and decode items from LMDB database nodes using direct `.get()` operations.</done>
|
|
42
|
+
</task>
|
|
43
|
+
|
|
44
|
+
## Success Criteria
|
|
45
|
+
- [ ] No `.query(...)` calls remain in the Listeners codebase.
|
|
46
|
+
- [ ] Batch transactions successfully execute insertions.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 1
|
|
3
|
+
plan: 4
|
|
4
|
+
wave: 3
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plan 1.4: Dependencies & Final Build Verification
|
|
8
|
+
|
|
9
|
+
## Objective
|
|
10
|
+
Finalize the dependency manifest and perform a complete TypeScript build to catch any lingering `jetdb` interfaces.
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
- package.json
|
|
14
|
+
|
|
15
|
+
## Tasks
|
|
16
|
+
|
|
17
|
+
<task type="auto">
|
|
18
|
+
<name>Update Package Dependencies</name>
|
|
19
|
+
<files>package.json</files>
|
|
20
|
+
<action>
|
|
21
|
+
- Drop `jetdb` completely from `dependencies`/`devDependencies`.
|
|
22
|
+
- Ensure `lmdb` is present in dependencies.
|
|
23
|
+
</action>
|
|
24
|
+
<verify>npm list jetdb --depth=0 || true</verify>
|
|
25
|
+
<done>package.json correctly declares lmdb.</done>
|
|
26
|
+
</task>
|
|
27
|
+
|
|
28
|
+
<task type="auto">
|
|
29
|
+
<name>Verify Production Build</name>
|
|
30
|
+
<files>src/*</files>
|
|
31
|
+
<action>
|
|
32
|
+
- Run `pnpm run build` or `npm run build` to verify standard TSC emissions succeed without syntax or structural property errors concerning missing jetdb functionality across the workspace.
|
|
33
|
+
</action>
|
|
34
|
+
<verify>npm run build</verify>
|
|
35
|
+
<done>Build finishes successfully with exit code 0.</done>
|
|
36
|
+
</task>
|
|
37
|
+
|
|
38
|
+
## Success Criteria
|
|
39
|
+
- [ ] Build verifies entirely.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Plan 2.1 Summary
|
|
2
|
+
|
|
3
|
+
## What was done
|
|
4
|
+
- **Refactor Object Helpers**: Eliminated the bulky custom 15-line nested path retrieval algorithm in `src/Utils/helper.ts` -> `pickKeysFromArray`. Simplified the empty check parameters logic utilizing `radashi.get` and `radashi.isEmpty`.
|
|
5
|
+
- **Refactor Chunking Integrations**: Safely migrated the `500` index slicing array mechanism spanning across Database operations in both `src/Library/cleanup-manager.ts` and `src/Auth/state.ts`. Utilized the concise `radashi.cluster(array, size)` iterator.
|
|
6
|
+
|
|
7
|
+
## Verification
|
|
8
|
+
- `pnpm tsc --noEmit` returned exactly `0` errors, proving the native drop-in typings provided by `.cluster` match natively with the codebase iteration loops.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 2
|
|
3
|
+
plan: 1
|
|
4
|
+
wave: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plan 2.1: Native to Radashi Optimization
|
|
8
|
+
|
|
9
|
+
## Objective
|
|
10
|
+
Convert bloated, boilerplate native javascript abstractions (such as nested object retrieval and array chunking) to clean, elegant Radashi utility methods `radashi.get`, `radashi.isEmpty`, and `radashi.cluster`. This shrinks the codebase, reduces cognitive load, and leverages reliable community-tested utility patterns without adding extra dependencies.
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
- .gsd/ROADMAP.md
|
|
14
|
+
- src/Utils/helper.ts
|
|
15
|
+
- src/Library/cleanup-manager.ts
|
|
16
|
+
- src/Auth/state.ts
|
|
17
|
+
|
|
18
|
+
## Tasks
|
|
19
|
+
|
|
20
|
+
<task type="auto">
|
|
21
|
+
<name>Refactor Object Helpers</name>
|
|
22
|
+
<files>src/Utils/helper.ts</files>
|
|
23
|
+
<action>
|
|
24
|
+
- Refactor `pickKeysFromArray`. Radashi's `get(obj, path)` can completely replace the 15+ lines of the `getNested` custom path parser algorithm.
|
|
25
|
+
- Rewrite custom `isEmpty` function. We can use `radashi.isEmpty()` alongside a `.trim()` check to maintain space-only string detection.
|
|
26
|
+
- Replace `findNestedByKeys` iterations with pure functional Radashi implementations.
|
|
27
|
+
</action>
|
|
28
|
+
<verify>pnpm tsc --noEmit</verify>
|
|
29
|
+
<done>Boilerplate manual loops inside `helper.ts` are eliminated, leveraging minimal lines with Radashi object traversals.</done>
|
|
30
|
+
</task>
|
|
31
|
+
|
|
32
|
+
<task type="auto">
|
|
33
|
+
<name>Refactor Chunking Integrations</name>
|
|
34
|
+
<files>src/Library/cleanup-manager.ts, src/Auth/state.ts</files>
|
|
35
|
+
<action>
|
|
36
|
+
- Both `cleanup-manager.ts` and `state.ts` contain manual 500-size array slicing chunk mechanisms.
|
|
37
|
+
- Replace `for (let i = 0; i < operations.length; i += chunkSize) { const chunk = operations.slice(...) }` with an elegant iteration over `radashi.cluster`(array, size).
|
|
38
|
+
- Ensure asynchronous arrays `Promise.all()` operate smoothly on the returned sub-matrices.
|
|
39
|
+
</action>
|
|
40
|
+
<verify>pnpm tsc --noEmit</verify>
|
|
41
|
+
<done>Array partitioning is successfully replaced with `radashi.cluster` leading to less cognitive complexity.</done>
|
|
42
|
+
</task>
|
|
43
|
+
|
|
44
|
+
## Success Criteria
|
|
45
|
+
- [ ] Nested path abstractions (`obj[arrayKey][index]`) are successfully abstracted via `radashi.get`
|
|
46
|
+
- [ ] Array chunking `slice` boilerplate loops are replaced natively with `radashi.cluster(arr, 500)`
|
|
47
|
+
- [ ] TypeScript validations complete with exactly `0` errors.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Plan 3.1 Summary
|
|
2
|
+
|
|
3
|
+
## What was done
|
|
4
|
+
- **Refactor Text Normalizer**: Dropped the heavy `unorm` module from `src/Utils/validate.ts`. Replaced `unorm.nfkd(char)` and `unorm.nfkc(char)` looping mechanics entirely with modern, faster V8 operations `.normalize('NFKD')` and `.normalize('NFKC')`.
|
|
5
|
+
- **Clear Dependencies**: Removed the `unorm` entry from `package.json` utilizing `pnpm remove unorm`.
|
|
6
|
+
|
|
7
|
+
## Verification
|
|
8
|
+
- `pnpm tsc --noEmit && pnpm build` finished flawlessly, signifying the JavaScript Unicode implementation operates as intended across transpiled CommonJS and ESM scopes.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 3
|
|
3
|
+
plan: 1
|
|
4
|
+
wave: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plan 3.1: Native Unicode V8 Normalization
|
|
8
|
+
|
|
9
|
+
## Objective
|
|
10
|
+
Remove the `unorm` library from `package.json` entirely. Utilize native Javascript `String.prototype.normalize()` which natively supports `NFKD` and `NFKC` parsing without external dependency injections, optimizing overall application bundle size and memory usage.
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
- `src/Utils/validate.ts`
|
|
14
|
+
- `package.json`
|
|
15
|
+
|
|
16
|
+
## Tasks
|
|
17
|
+
|
|
18
|
+
<task type="auto">
|
|
19
|
+
<name>Refactor Text Normalizer</name>
|
|
20
|
+
<files>src/Utils/validate.ts</files>
|
|
21
|
+
<action>
|
|
22
|
+
- Remove the `unorm` import block.
|
|
23
|
+
- Rewrite `.map((char) => unorm.nfkd(char))` into native Javascript: `.map((char) => char.normalize('NFKD'))`
|
|
24
|
+
- Rewrite `.map((char) => unorm.nfkc(char))` into native Javascript: `.map((char) => char.normalize('NFKC'))`
|
|
25
|
+
</action>
|
|
26
|
+
<verify>pnpm tsc --noEmit</verify>
|
|
27
|
+
<done>Text normalization succeeds using purely standard internal string iterations without `unorm` fallback.</done>
|
|
28
|
+
</task>
|
|
29
|
+
|
|
30
|
+
<task type="auto">
|
|
31
|
+
<name>Clear Dependencies</name>
|
|
32
|
+
<files>package.json</files>
|
|
33
|
+
<action>
|
|
34
|
+
- Remove `"unorm": "^1.6.0"` from `"dependencies"`.
|
|
35
|
+
- Run an installation cleanup.
|
|
36
|
+
</action>
|
|
37
|
+
<verify>bun pm ls</verify>
|
|
38
|
+
<done>Package directory explicitly flags `unorm` as non-existent.</done>
|
|
39
|
+
</task>
|
|
40
|
+
|
|
41
|
+
## Success Criteria
|
|
42
|
+
- [ ] Codebase compiles natively via `tsc` with `0` errors.
|
|
43
|
+
- [ ] No footprint of `unorm` exists in `package.json`.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
phase: 4
|
|
3
|
+
plan: 1
|
|
4
|
+
wave: 1
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Plan 4.1: Setup Valibot and Wrapper Migration
|
|
8
|
+
|
|
9
|
+
## Objective
|
|
10
|
+
Uninstall `zod` and `zod-validation-error`. Install completely modular `valibot` dependency. Replace the library validation wrapper with `valibot` semantics (`v.safeParse` and `v.summarize`/`v.flatten`).
|
|
11
|
+
|
|
12
|
+
## Context
|
|
13
|
+
- `package.json`
|
|
14
|
+
- `src/Library/zod.ts` (This file should be renamed to `src/Library/valibot.ts`!)
|
|
15
|
+
|
|
16
|
+
## Tasks
|
|
17
|
+
|
|
18
|
+
<task type="auto">
|
|
19
|
+
<name>Dependency Swap</name>
|
|
20
|
+
<files>package.json</files>
|
|
21
|
+
<action>
|
|
22
|
+
- Execute `pnpm remove zod zod-validation-error`.
|
|
23
|
+
- Execute `pnpm add valibot`.
|
|
24
|
+
</action>
|
|
25
|
+
<verify>bun pm ls</verify>
|
|
26
|
+
<done>package.json explicitly lists `valibot` and omits entirely `zod` and `zod-validation-error`.</done>
|
|
27
|
+
</task>
|
|
28
|
+
|
|
29
|
+
<task type="auto">
|
|
30
|
+
<name>Implement Valibot Wrapper</name>
|
|
31
|
+
<files>src/Library/zod.ts</files>
|
|
32
|
+
<action>
|
|
33
|
+
- Rename the file gracefully from `src/Library/zod.ts` to `src/Library/valibot.ts`.
|
|
34
|
+
- Drop `zod` and `fromError` imports. Import `* as v from 'valibot'`.
|
|
35
|
+
- Create an export `parseValibot = <T extends v.BaseSchema<any, any, any>>(schema: T, data: unknown)` that executes `v.safeParse`.
|
|
36
|
+
- If `result.issues` exist, extract and throw an Error via `v.summarize(result.issues)` or by joining `v.flatten()`.
|
|
37
|
+
</action>
|
|
38
|
+
<verify>test -f src/Library/valibot.ts && ! test -f src/Library/zod.ts</verify>
|
|
39
|
+
<done>Wrapper has successfully transitioned to `valibot` with functional Error reporting.</done>
|
|
40
|
+
</task>
|
|
41
|
+
|
|
42
|
+
## Success Criteria
|
|
43
|
+
- [ ] Dependencies swapped cleanly.
|
|
44
|
+
- [ ] `valibot.ts` gracefully replaces `zod.ts`.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Plan 4.1 Summary
|
|
2
|
+
|
|
3
|
+
## What was done
|
|
4
|
+
- **Dependency Swap**: Ran `pnpm remove zod zod-validation-error` and `pnpm add valibot`.
|
|
5
|
+
- **Implement Wrapper**: Replaced `src/Library/zod.ts` with `src/Library/valibot.ts`. Implemented a `parseValibot()` higher-order validation wrapper throwing formatted stringified `v.flatten()` errors securely.
|
|
6
|
+
|
|
7
|
+
## Verification
|
|
8
|
+
- Dependencies matched specifications and `parseValibot` wraps inputs correctly.
|