izanagi-ai 2.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/AGENTS.md +53 -0
- package/CHANGELOG.md +198 -0
- package/LICENSE +21 -0
- package/README.md +96 -0
- package/ROADMAP.md +131 -0
- package/RULES.md +202 -0
- package/SYSTEM.md +201 -0
- package/agents/INDEX.md +40 -0
- package/agents/architect-agent.json +15 -0
- package/agents/bug-hunter-agent.json +14 -0
- package/agents/database-agent.json +14 -0
- package/agents/devops-agent.json +15 -0
- package/agents/docs-agent.json +15 -0
- package/agents/pm-agent.json +14 -0
- package/agents/professor-agent.json +15 -0
- package/agents/security-agent.json +14 -0
- package/agents/senior-engineer-agent.json +16 -0
- package/agents/techlead-agent.json +15 -0
- package/architecture/clean-architecture.md +98 -0
- package/architecture/cqrs-specialist.md +102 -0
- package/architecture/ddd-specialist.md +97 -0
- package/architecture/event-driven-architect.md +79 -0
- package/architecture/hexagonal-architecture.md +96 -0
- package/architecture/microservices-expert.md +83 -0
- package/architecture/monolith-expert.md +67 -0
- package/architecture/repository-pattern.md +73 -0
- package/architecture/unit-of-work.md +92 -0
- package/backend/README.md +29 -0
- package/bin/nexus.js +8 -0
- package/core/compression-engine.md +194 -0
- package/core/context-engine.md +239 -0
- package/core/decision-engine.md +377 -0
- package/core/evolution-engine.md +169 -0
- package/core/planning-engine.md +201 -0
- package/core/quality-gates.md +233 -0
- package/core/reflection-engine.md +182 -0
- package/core/skill-resolver.json +169 -0
- package/core/token-manager.md +152 -0
- package/database/database-engineer.md +244 -0
- package/database/mysql-specialist.md +61 -0
- package/database/postgresql-specialist.md +70 -0
- package/database/redis-specialist.md +73 -0
- package/database/sql-optimizer.md +95 -0
- package/database/sqlserver-specialist.md +69 -0
- package/devops/ci-cd-specialist.md +101 -0
- package/devops/devops-engineer.md +358 -0
- package/devops/docker-expert.md +105 -0
- package/devops/git-expert.md +76 -0
- package/devops/git-flow-specialist.md +71 -0
- package/devops/kubernetes-specialist.md +84 -0
- package/devops/linux-specialist.md +82 -0
- package/devops/windows-specialist.md +43 -0
- package/dist/cli/commands/compile.d.ts +2 -0
- package/dist/cli/commands/compile.d.ts.map +1 -0
- package/dist/cli/commands/compile.js +44 -0
- package/dist/cli/commands/compile.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +2 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +88 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +26 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/list.d.ts +2 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +50 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/run.d.ts +2 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +49 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +72 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/installer.d.ts +5 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +86 -0
- package/dist/installer.js.map +1 -0
- package/dist/postinstall.d.ts +2 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +8 -0
- package/dist/postinstall.js.map +1 -0
- package/frontend/README.md +19 -0
- package/memory/context-recovery.md +49 -0
- package/memory/conversation-summarizer.md +65 -0
- package/memory/long-term-project-memory.md +58 -0
- package/memory/memory-manager.md +299 -0
- package/memory/session-compression.md +182 -0
- package/memory/smart-recall.md +37 -0
- package/optimization/compact-example.md +87 -0
- package/optimization/cost-optimizer.md +53 -0
- package/optimization/prompt-optimizer.md +194 -0
- package/optimization/token-audit.md +177 -0
- package/optimization/token-reducer.md +202 -0
- package/package.json +67 -0
- package/security/owasp-auditor.md +249 -0
- package/security/pentest-reviewer.md +109 -0
- package/security/security-engineer.md +238 -0
- package/skills/INDEX.md +434 -0
- package/skills/accessibility-reviewer.md +63 -0
- package/skills/agentic-coding.md +56 -0
- package/skills/ai-agent/SKILL.md +107 -0
- package/skills/ai-agent-dev/SKILL.md +117 -0
- package/skills/alternative-solution-generator.md +72 -0
- package/skills/architecture-patterns/SKILL.md +113 -0
- package/skills/breaking-change-detector.md +84 -0
- package/skills/bug-hunter.md +234 -0
- package/skills/bug-prevention.md +75 -0
- package/skills/chaos-engineering/SKILL.md +108 -0
- package/skills/clean-code-validator.md +218 -0
- package/skills/cloud-architect/SKILL.md +78 -0
- package/skills/cloud-infra/SKILL.md +99 -0
- package/skills/code-auditor.md +24 -0
- package/skills/complexity-analyzer.md +102 -0
- package/skills/confidence-estimator.md +53 -0
- package/skills/continuous-improvement.md +46 -0
- package/skills/continuous-learning-engine.md +51 -0
- package/skills/cto-advisor.md +66 -0
- package/skills/data-engineer/SKILL.md +76 -0
- package/skills/data-engineering/SKILL.md +82 -0
- package/skills/debug-specialist.md +215 -0
- package/skills/dependency-analyzer.md +78 -0
- package/skills/design-pattern-advisor.md +78 -0
- package/skills/documentation-writer.md +66 -0
- package/skills/dry-kiss-yagni-validator.md +114 -0
- package/skills/economia-tokens/SKILL.md +40 -0
- package/skills/er-diagram-builder.md +85 -0
- package/skills/feature-flags/SKILL.md +95 -0
- package/skills/frontend/SKILL.md +327 -0
- package/skills/frontend-dev/SKILL.md +178 -0
- package/skills/graphql/SKILL.md +104 -0
- package/skills/hallucination-detection.md +49 -0
- package/skills/handoff-sessao/SKILL.md +32 -0
- package/skills/i18n-l10n/SKILL.md +103 -0
- package/skills/iac-terraform/SKILL.md +98 -0
- package/skills/legacy-migration/SKILL.md +91 -0
- package/skills/logging-expert.md +78 -0
- package/skills/mcp-server-dev.md +33 -0
- package/skills/memoria-projeto/SKILL.md +49 -0
- package/skills/mobile-dev/SKILL.md +82 -0
- package/skills/mobile-engineer/SKILL.md +74 -0
- package/skills/monitoring-specialist.md +59 -0
- package/skills/observability-expert.md +60 -0
- package/skills/performance-optimizer.md +239 -0
- package/skills/principal-engineer.md +55 -0
- package/skills/privacy-engineer/SKILL.md +79 -0
- package/skills/professor-modo/SKILL.md +33 -0
- package/skills/project-manager.md +74 -0
- package/skills/prompt-engineering.md +27 -0
- package/skills/qa/SKILL.md +231 -0
- package/skills/qa-engineer/SKILL.md +222 -0
- package/skills/readme-generator.md +42 -0
- package/skills/refactoring-specialist.md +250 -0
- package/skills/release-planner.md +70 -0
- package/skills/requirement-analyzer.md +65 -0
- package/skills/risk-analyzer.md +73 -0
- package/skills/root-cause-analyzer.md +210 -0
- package/skills/scalability-expert.md +73 -0
- package/skills/security-privacy/SKILL.md +98 -0
- package/skills/self-correction.md +54 -0
- package/skills/self-critique.md +42 -0
- package/skills/senior-code-reviewer.md +193 -0
- package/skills/sequence-diagram-builder.md +56 -0
- package/skills/serverless-edge/SKILL.md +103 -0
- package/skills/software-architect.md +356 -0
- package/skills/solid-validator.md +332 -0
- package/skills/sre-reliability/SKILL.md +115 -0
- package/skills/staff-engineer.md +61 -0
- package/skills/task-planner.md +61 -0
- package/skills/tech-lead.md +59 -0
- package/skills/technical-debt-analyzer.md +81 -0
- package/skills/technical-writer.md +39 -0
- package/skills/tradeoff-analyzer.md +79 -0
- package/skills/uml-generator.md +72 -0
- package/skills/ux-reviewer.md +61 -0
- package/skills/wasm/SKILL.md +133 -0
- package/skills/web-perf-engineer/SKILL.md +75 -0
- package/skills/web-perf-seo/SKILL.md +111 -0
- package/skills/websocket-realtime/SKILL.md +107 -0
- package/teaching/adaptive-teaching.md +37 -0
- package/teaching/code-explainer.md +172 -0
- package/teaching/interactive-teaching.md +41 -0
- package/teaching/learning-tracker.md +63 -0
- package/teaching/mentor-mode.md +200 -0
- package/teaching/professor-mode.md +222 -0
- package/testing/e2e-test-engineer.md +68 -0
- package/testing/integration-test-engineer.md +74 -0
- package/testing/mocking-specialist.md +78 -0
- package/testing/unit-test-engineer.md +209 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Memory: Memory Manager
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0
|
|
4
|
+
> Priority: Critical
|
|
5
|
+
> Dependencies: Context Engine, Compression Engine
|
|
6
|
+
> Compatibility: ">=1.0.0"
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Identity
|
|
11
|
+
|
|
12
|
+
The Memory Manager is the persistent storage layer of Nexus AI. It maintains three tiers of memory — Session, Project, and Long Term — with automatic compression, relevance-based recall, and a knowledge graph for cross-session pattern detection.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Architecture
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
┌──────────────────────────────────────────────────────┐
|
|
20
|
+
│ MEMORY MANAGER │
|
|
21
|
+
│ │
|
|
22
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌────────────┐ │
|
|
23
|
+
│ │ Session │ │ Project │ │ Long Term │ │
|
|
24
|
+
│ │ Memory │ │ Memory │ │ Memory │ │
|
|
25
|
+
│ │ (volatile) │ │ (persistent) │ │(persistent)│ │
|
|
26
|
+
│ └──────┬───────┘ └──────┬───────┘ └─────┬──────┘ │
|
|
27
|
+
│ │ │ │ │
|
|
28
|
+
│ └─────────────────┼────────────────┘ │
|
|
29
|
+
│ │ │
|
|
30
|
+
│ ▼ │
|
|
31
|
+
│ ┌────────────────────────┐ │
|
|
32
|
+
│ │ Knowledge Graph │ │
|
|
33
|
+
│ │ (entities + edges) │ │
|
|
34
|
+
│ └───────────┬────────────┘ │
|
|
35
|
+
│ │ │
|
|
36
|
+
│ ▼ │
|
|
37
|
+
│ ┌────────────────────────┐ │
|
|
38
|
+
│ │ Recall Engine │ │
|
|
39
|
+
│ │ (query + relevance) │ │
|
|
40
|
+
│ └────────────────────────┘ │
|
|
41
|
+
└──────────────────────────────────────────────────────┘
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Memory Tiers
|
|
47
|
+
|
|
48
|
+
### Session Memory
|
|
49
|
+
|
|
50
|
+
| Property | Value |
|
|
51
|
+
|----------|-------|
|
|
52
|
+
| Duration | Current conversation only |
|
|
53
|
+
| Persistence | None (lost on session end) |
|
|
54
|
+
| Max tokens | 1024 |
|
|
55
|
+
| Contains | Current task context, recent decisions, active errors |
|
|
56
|
+
| Compression | Auto at 80% capacity |
|
|
57
|
+
|
|
58
|
+
### Project Memory
|
|
59
|
+
|
|
60
|
+
| Property | Value |
|
|
61
|
+
|----------|-------|
|
|
62
|
+
| Duration | Across sessions for same project |
|
|
63
|
+
| Persistence | File-based (project-memory.json) |
|
|
64
|
+
| Max tokens | 4096 |
|
|
65
|
+
| Contains | Project type, tech stack, architecture decisions, conventions, recurring patterns |
|
|
66
|
+
| Compression | Auto at 70% capacity |
|
|
67
|
+
|
|
68
|
+
### Long Term Memory
|
|
69
|
+
|
|
70
|
+
| Property | Value |
|
|
71
|
+
|----------|-------|
|
|
72
|
+
| Duration | Across all projects and sessions |
|
|
73
|
+
| Persistence | File-based (long-term-memory.json) |
|
|
74
|
+
| Max tokens | 8192 |
|
|
75
|
+
| Contains | User preferences, communication style, recurring mistakes, skill evolution, learning progress |
|
|
76
|
+
| Compression | Auto at 60% capacity |
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Storage Format
|
|
81
|
+
|
|
82
|
+
### Session (volatile, in-context)
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"session_id": "sess-abc123",
|
|
87
|
+
"started_at": "2026-07-17T11:00:00Z",
|
|
88
|
+
"tasks": [
|
|
89
|
+
{
|
|
90
|
+
"task_id": "task-001",
|
|
91
|
+
"classification": "new_feature",
|
|
92
|
+
"decisions": ["Use JWT over sessions", "Use PostgreSQL"],
|
|
93
|
+
"errors": [],
|
|
94
|
+
"patterns": []
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
"active_context": {
|
|
98
|
+
"current_skill": "backend-engineer",
|
|
99
|
+
"token_used": 1234,
|
|
100
|
+
"compression_level": "none"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Project (persistent, file-based)
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"project_id": "proj-xyz789",
|
|
110
|
+
|
|
111
|
+
"type": "web_app",
|
|
112
|
+
"tech_stack": {
|
|
113
|
+
"backend": "Laravel 11",
|
|
114
|
+
"frontend": "React + Tailwind",
|
|
115
|
+
"database": "PostgreSQL 16",
|
|
116
|
+
"cache": "Redis"
|
|
117
|
+
},
|
|
118
|
+
"architecture": {
|
|
119
|
+
"pattern": "Layered (Controller → Service → Repository)",
|
|
120
|
+
"decisions": [
|
|
121
|
+
{
|
|
122
|
+
"id": "adr-001",
|
|
123
|
+
"decision": "Use JWT in httpOnly cookies",
|
|
124
|
+
"reason": "XSS protection vs localStorage",
|
|
125
|
+
"date": "2026-07-15"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
"conventions": {
|
|
130
|
+
"naming": "camelCase for JS, snake_case for PHP",
|
|
131
|
+
"testing": "Pest for unit, Cypress for E2E"
|
|
132
|
+
},
|
|
133
|
+
"error_history": [
|
|
134
|
+
{
|
|
135
|
+
"error": "SQL injection vector in UserController",
|
|
136
|
+
"fix": "Use parameterized queries",
|
|
137
|
+
"count": 2,
|
|
138
|
+
"last_seen": "2026-07-16"
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"last_updated": "2026-07-17T10:00:00Z"
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Long Term (persistent, file-based)
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"user_id": "user-default",
|
|
150
|
+
"preferences": {
|
|
151
|
+
"communication_style": "concise",
|
|
152
|
+
"teaching_level": "intermediate",
|
|
153
|
+
"teaching_style": "examples_first"
|
|
154
|
+
},
|
|
155
|
+
"recurring_patterns": {
|
|
156
|
+
"token_waste": {
|
|
157
|
+
"count": 5,
|
|
158
|
+
"last_skill": "backend-engineer",
|
|
159
|
+
"resolved": false
|
|
160
|
+
},
|
|
161
|
+
"forget_security": {
|
|
162
|
+
"count": 2,
|
|
163
|
+
"last_skill": "software-architect",
|
|
164
|
+
"resolved": true
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
"skill_evolution": [
|
|
168
|
+
{
|
|
169
|
+
"skill": "backend-engineer",
|
|
170
|
+
"version": "1.1.0",
|
|
171
|
+
"changes": ["Reduced token budget by 10%"],
|
|
172
|
+
"date": "2026-07-17"
|
|
173
|
+
}
|
|
174
|
+
],
|
|
175
|
+
"learning_progress": {
|
|
176
|
+
"completed_lessons": ["SOLID", "Clean Architecture"],
|
|
177
|
+
"current_lesson": "CQRS",
|
|
178
|
+
"struggling_topics": ["Event Sourcing"]
|
|
179
|
+
},
|
|
180
|
+
"last_updated": "2026-07-17T12:00:00Z"
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Knowledge Graph
|
|
187
|
+
|
|
188
|
+
The Knowledge Graph stores entities and relationships extracted from project and long-term memory.
|
|
189
|
+
|
|
190
|
+
### Entity Types
|
|
191
|
+
|
|
192
|
+
- `decision` — architectural or technical decision
|
|
193
|
+
- `error` — bug or mistake with fix
|
|
194
|
+
- `pattern` — recurring structure or approach
|
|
195
|
+
- `technology` — tool, framework, library
|
|
196
|
+
- `concept` — design pattern, principle, methodology
|
|
197
|
+
- `user_preference` — user's explicit preferences
|
|
198
|
+
|
|
199
|
+
### Edge Types
|
|
200
|
+
|
|
201
|
+
- `led_to` — decision led to outcome
|
|
202
|
+
- `caused` — decision caused error
|
|
203
|
+
- `solved_by` — error solved by fix
|
|
204
|
+
- `related_to` — two entities are related
|
|
205
|
+
- `uses` — project uses technology
|
|
206
|
+
- `conflicts_with` — two decisions or technologies conflict
|
|
207
|
+
|
|
208
|
+
### Example
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
[Use JWT] ──led_to──> [XSS Protection]
|
|
212
|
+
│ │
|
|
213
|
+
│ ├──solved_by──> [httpOnly Cookies]
|
|
214
|
+
│ │
|
|
215
|
+
└──caused──> [Frontend needs token refresh logic]
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
## Recall Engine
|
|
221
|
+
|
|
222
|
+
### Query Flow
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
1. Receive query from Context Engine
|
|
226
|
+
2. Tokenize query into keywords
|
|
227
|
+
3. Search all 3 tiers in order:
|
|
228
|
+
a. Session memory (fastest)
|
|
229
|
+
b. Project memory
|
|
230
|
+
c. Long term memory
|
|
231
|
+
4. Score each result by relevance:
|
|
232
|
+
score = keyword_match * 0.4 + recency * 0.3 + relation_depth * 0.3
|
|
233
|
+
5. If score > 0.5: return full entry
|
|
234
|
+
6. If score > 0.3: return compressed summary
|
|
235
|
+
7. If score < 0.3: skip
|
|
236
|
+
8. Limit results to budget
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Recall Budget
|
|
240
|
+
|
|
241
|
+
| Priority | Max Items | Max Tokens |
|
|
242
|
+
|----------|-----------|------------|
|
|
243
|
+
| Critical | 3 | 300 |
|
|
244
|
+
| High | 2 | 200 |
|
|
245
|
+
| Medium | 1 | 100 |
|
|
246
|
+
| Low | 0 | 0 |
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Compression Triggers
|
|
251
|
+
|
|
252
|
+
| Tier | Trigger | Strategy |
|
|
253
|
+
|------|---------|----------|
|
|
254
|
+
| Session | > 80% capacity | Remove oldest 30% of task history |
|
|
255
|
+
| Project | > 70% capacity | Summarize old decisions, keep active ones |
|
|
256
|
+
| Long Term | > 60% capacity | Archive patterns with count < 3 |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Rules
|
|
261
|
+
|
|
262
|
+
### Always
|
|
263
|
+
|
|
264
|
+
- ✅ Save decisions immediately after they are made.
|
|
265
|
+
- ✅ Compress before storage if tier is near capacity.
|
|
266
|
+
- ✅ Log every read and write for traceability.
|
|
267
|
+
- ✅ Respect recall budgets strictly.
|
|
268
|
+
|
|
269
|
+
### Never
|
|
270
|
+
|
|
271
|
+
- ❌ Store raw conversation history in project or long term memory.
|
|
272
|
+
- ❌ Store secrets, passwords, or API keys.
|
|
273
|
+
- ❌ Exceed storage budget for any tier.
|
|
274
|
+
- ❌ Return irrelevant memory (score < 0.3).
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Metrics
|
|
279
|
+
|
|
280
|
+
| Metric | Target | How to Measure |
|
|
281
|
+
|--------|--------|---------------|
|
|
282
|
+
| Recall precision | ≥ 80% | Relevant results / total results |
|
|
283
|
+
| Recall recall | ≥ 90% | Relevant results returned / relevant results available |
|
|
284
|
+
| Storage usage | ≤ 80% per tier | Current size / max size |
|
|
285
|
+
| Write latency | < 50ms | Time to store entry |
|
|
286
|
+
| Read latency | < 30ms | Time to retrieve entry |
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Changelog
|
|
291
|
+
|
|
292
|
+
### 1.0.0 (2026-07-17)
|
|
293
|
+
|
|
294
|
+
- Initial release
|
|
295
|
+
- 3-tier memory architecture
|
|
296
|
+
- JSON-based persistent storage
|
|
297
|
+
- Knowledge Graph with 6 entity types and 6 edge types
|
|
298
|
+
- Relevance-based recall engine with scoring algorithm
|
|
299
|
+
- Auto-compression at tier capacity thresholds
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Memory: Session Compression
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0
|
|
4
|
+
> Priority: Medium
|
|
5
|
+
> Dependencies: Memory Manager, Compression Engine
|
|
6
|
+
> Compatibility: ">=1.0.0"
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Identity
|
|
11
|
+
|
|
12
|
+
Session Compression reduces the entire conversation history into a dense, high-signal summary that preserves decisions, errors, action items, and key facts while removing all conversational overhead. It is activated at session end or when the context budget is critically low.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Goals
|
|
17
|
+
|
|
18
|
+
- Compress an entire session (up to 10k tokens) into ≤ 200 tokens.
|
|
19
|
+
- Preserve 100% of decisions, errors, and action items.
|
|
20
|
+
- Preserve user preferences and level.
|
|
21
|
+
- Enable seamless session recovery on reconnect.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Compression Ratio Targets
|
|
26
|
+
|
|
27
|
+
| Session Length | Compressed Size | Ratio |
|
|
28
|
+
|---------------|----------------|-------|
|
|
29
|
+
| 2,000 tokens | 100 tokens | 20:1 |
|
|
30
|
+
| 5,000 tokens | 150 tokens | 33:1 |
|
|
31
|
+
| 10,000 tokens | 200 tokens | 50:1 |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Extraction Categories
|
|
36
|
+
|
|
37
|
+
Only the following categories are preserved. Everything else is discarded.
|
|
38
|
+
|
|
39
|
+
| Category | Priority | Preserve Format | Max Tokens |
|
|
40
|
+
|----------|----------|----------------|-----------|
|
|
41
|
+
| **Decisions** | Critical | Decision + reason | 50 |
|
|
42
|
+
| **Errors & Fixes** | Critical | Error + cause + fix | 50 |
|
|
43
|
+
| **Action Items** | High | Action + owner + status | 30 |
|
|
44
|
+
| **User Preferences** | High | Exact preference | 20 |
|
|
45
|
+
| **User Level** | High | Level + changes detected | 10 |
|
|
46
|
+
| **Architecture** | Medium | Pattern + key components | 20 |
|
|
47
|
+
| **Skill Updates** | Medium | Skill + change | 10 |
|
|
48
|
+
| **Patterns** | Low | Pattern description | 10 |
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Compression Algorithm
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
function compress_session(session):
|
|
56
|
+
summary = {
|
|
57
|
+
session_id: session.id,
|
|
58
|
+
duration: session.duration,
|
|
59
|
+
token_count: session.token_count,
|
|
60
|
+
compressed_tokens: 0,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Extract decisions
|
|
64
|
+
decisions = extract_all(session.messages, pattern="decided|chose|selected")
|
|
65
|
+
summary.decisions = deduplicate(decisions)
|
|
66
|
+
|
|
67
|
+
// Extract errors
|
|
68
|
+
errors = extract_all(session.messages, pattern="error|bug|fix|issue")
|
|
69
|
+
summary.errors = deduplicate(errors)
|
|
70
|
+
|
|
71
|
+
// Extract action items
|
|
72
|
+
actions = extract_all(session.messages, pattern="next|todo|follow.up|need to")
|
|
73
|
+
summary.action_items = deduplicate(actions)
|
|
74
|
+
|
|
75
|
+
// Extract user data
|
|
76
|
+
summary.user_preferences = session.user_preferences
|
|
77
|
+
summary.user_level = session.user_level
|
|
78
|
+
|
|
79
|
+
// Extract skill changes
|
|
80
|
+
summary.skill_updates = session.evolution_log
|
|
81
|
+
|
|
82
|
+
// Compress to fit budget
|
|
83
|
+
while size(summary) > 200:
|
|
84
|
+
summary.patterns = [] // Drop lowest priority
|
|
85
|
+
if size(summary) > 200:
|
|
86
|
+
summary.architecture = truncate(summary.architecture)
|
|
87
|
+
if size(summary) > 200:
|
|
88
|
+
summary.skill_updates = truncate(summary.skill_updates)
|
|
89
|
+
|
|
90
|
+
return summary
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Compressed Session Format
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
session_summary:
|
|
99
|
+
session_id: "sess-abc123"
|
|
100
|
+
duration: "45 min"
|
|
101
|
+
tokens_saved: 4560
|
|
102
|
+
|
|
103
|
+
decisions:
|
|
104
|
+
- "Use JWT in httpOnly cookies (XSS protection)"
|
|
105
|
+
- "Use PostgreSQL over MySQL (JSONB support needed)"
|
|
106
|
+
- "Monolith for MVP, microservices later"
|
|
107
|
+
|
|
108
|
+
errors_and_fixes:
|
|
109
|
+
- "Str::contains() TypeError → null check added"
|
|
110
|
+
- "N+1 on posts/index → eager loading added"
|
|
111
|
+
|
|
112
|
+
action_items:
|
|
113
|
+
- "Add rate limiting to auth endpoints"
|
|
114
|
+
- "Write integration tests for payment flow"
|
|
115
|
+
|
|
116
|
+
user:
|
|
117
|
+
level: "intermediate"
|
|
118
|
+
preferences:
|
|
119
|
+
style: "concise"
|
|
120
|
+
teaching: "examples_first"
|
|
121
|
+
|
|
122
|
+
architecture:
|
|
123
|
+
pattern: "Layered (Controller → Service → Repository)"
|
|
124
|
+
stack: "Laravel 11, PostgreSQL 16, React + Tailwind"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Session Recovery
|
|
130
|
+
|
|
131
|
+
When a user returns after a session break, the compressed summary is loaded into context:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
"Welcome back. Last time we worked on the blog API. Here's where we left off:
|
|
135
|
+
- Architecture: Layered with Laravel 11 + React
|
|
136
|
+
- Completed: Auth system, Post CRUD
|
|
137
|
+
- Pending: Comments feature, rate limiting
|
|
138
|
+
- Open items: Add rate limiting to auth endpoints
|
|
139
|
+
- Your level: Intermediate (progressing well with Eloquent)
|
|
140
|
+
Would you like to continue where we left off or start something new?"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Rules
|
|
146
|
+
|
|
147
|
+
### Always
|
|
148
|
+
|
|
149
|
+
- ✅ Compress at session end or when budget is critically low.
|
|
150
|
+
- ✅ Preserve all decisions, errors, and action items.
|
|
151
|
+
- ✅ Enable seamless session recovery.
|
|
152
|
+
- ✅ Track compression ratio and tokens saved.
|
|
153
|
+
|
|
154
|
+
### Never
|
|
155
|
+
|
|
156
|
+
- ❌ Preserve conversational filler or greetings.
|
|
157
|
+
- ❌ Preserve multiple expressions of the same decision.
|
|
158
|
+
- ❌ Preserve code examples (they are in project memory).
|
|
159
|
+
- ❌ Exceed 200 tokens for compressed session.
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Metrics
|
|
164
|
+
|
|
165
|
+
| Metric | Target | How to Measure |
|
|
166
|
+
|--------|--------|---------------|
|
|
167
|
+
| Compression ratio | ≥ 20:1 | Original / compressed |
|
|
168
|
+
| Decision preservation | 100% | Decisions in summary / decisions in session |
|
|
169
|
+
| Recovery quality | User can resume without re-explaining | Follow-up question rate after recovery |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Changelog
|
|
174
|
+
|
|
175
|
+
### 1.0.0 (2026-07-17)
|
|
176
|
+
|
|
177
|
+
- Initial release
|
|
178
|
+
- 7 extraction categories with priority levels
|
|
179
|
+
- 200-token maximum summary size
|
|
180
|
+
- Compression algorithm with priority-based truncation
|
|
181
|
+
- Session recovery prompt format
|
|
182
|
+
- Decision, error, action item extraction patterns
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Memory: Smart Recall
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: Medium
|
|
4
|
+
> Dependencies: Memory Manager, Knowledge Graph
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Smart Recall retrieves the most relevant information from all memory tiers for a given context. Uses relevance scoring based on keyword matching, recency, and relationship depth.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Relevance Scoring
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
score = keyword_match(0.4) + recency(0.3) + relation_depth(0.3)
|
|
19
|
+
|
|
20
|
+
Thresholds:
|
|
21
|
+
> 0.7: Full recall (complete entry)
|
|
22
|
+
> 0.4: Summary (compressed entry)
|
|
23
|
+
< 0.4: Skip
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Recall Triggers
|
|
27
|
+
|
|
28
|
+
- User mentions a topic previously discussed
|
|
29
|
+
- Current task matches a past task category
|
|
30
|
+
- Error pattern matches a known issue
|
|
31
|
+
- User asks "what did we decide about X?"
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Changelog
|
|
36
|
+
|
|
37
|
+
### 1.0.0 — Initial release. Scoring, triggers.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Exemplo: Skill Compacta vs Atual
|
|
2
|
+
|
|
3
|
+
> Demonstração da economia de tokens com o novo formato.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Antes (850 tokens) — `skills/bug-hunter.md`
|
|
8
|
+
|
|
9
|
+
```markdown
|
|
10
|
+
# Skill: Bug Hunter
|
|
11
|
+
|
|
12
|
+
> Version 1.0.0 | Priority: High
|
|
13
|
+
> Dependencies: Debug Specialist, Root Cause Analyzer
|
|
14
|
+
> Compatibility: ">=1.0.0"
|
|
15
|
+
|
|
16
|
+
## Identity
|
|
17
|
+
|
|
18
|
+
The Bug Hunter systematically investigates errors, exceptions, and unexpected behavior...
|
|
19
|
+
|
|
20
|
+
## Goals
|
|
21
|
+
|
|
22
|
+
- Reproduce every bug
|
|
23
|
+
- Isolate minimal reproduction case
|
|
24
|
+
- Find root cause, not symptom
|
|
25
|
+
|
|
26
|
+
## Triggers
|
|
27
|
+
|
|
28
|
+
| Condition | Action |
|
|
29
|
+
|-----------|--------|
|
|
30
|
+
| task == "bug" | Full protocol |
|
|
31
|
+
| User shares error | Parse/investigate |
|
|
32
|
+
|
|
33
|
+
## Steps
|
|
34
|
+
|
|
35
|
+
1. Collect intelligence
|
|
36
|
+
2. Reproduce
|
|
37
|
+
3. Isolate
|
|
38
|
+
4. Understand root cause
|
|
39
|
+
5. Design fix
|
|
40
|
+
6. Apply fix
|
|
41
|
+
7. Verify
|
|
42
|
+
8. Document
|
|
43
|
+
|
|
44
|
+
## Rules
|
|
45
|
+
|
|
46
|
+
### Always
|
|
47
|
+
- Reproduce before fixing
|
|
48
|
+
|
|
49
|
+
### Never
|
|
50
|
+
- Fix without reproducing
|
|
51
|
+
|
|
52
|
+
## Metrics...
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Depois (320 tokens) — mesmo conteúdo
|
|
58
|
+
|
|
59
|
+
```yaml
|
|
60
|
+
---
|
|
61
|
+
v: 1.0.0 | p: high
|
|
62
|
+
deps: [debug, root-cause]
|
|
63
|
+
triggers: [bug, error, crash]
|
|
64
|
+
budget: 500
|
|
65
|
+
---
|
|
66
|
+
# Bug Hunter — protocolo 8 passos
|
|
67
|
+
|
|
68
|
+
## Steps
|
|
69
|
+
1. collect_intel — erro exato, input, ambiente, mudanças recentes
|
|
70
|
+
2. reproduce — script mínimo que reproduz
|
|
71
|
+
3. isolate — busca binária (comenta metade, testa, repete)
|
|
72
|
+
4. understand — 5 Whys, causa raiz
|
|
73
|
+
5. design_fix — 2+ abordagens, escolhe a mínima
|
|
74
|
+
6. apply — código + test que falha sem o fix
|
|
75
|
+
7. verify — test passa, sem regressão
|
|
76
|
+
8. document — causa, fix, prevenção
|
|
77
|
+
|
|
78
|
+
## Always
|
|
79
|
+
- Reproduzir antes de qualquer fix
|
|
80
|
+
- Teste de regressão obrigatório
|
|
81
|
+
|
|
82
|
+
## Never
|
|
83
|
+
- "talvez isso resolva" — sem chute
|
|
84
|
+
- Pular reprodução
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**Economia: 850 → 320 tokens (-62%).**
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Optimization: Cost Optimizer
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: Low
|
|
4
|
+
> Dependencies: Token Manager, DevOps Engineer
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Cost Optimizer tracks and reduces operational costs: API calls, infrastructure, and tooling.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Token Cost Tracking
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
token_cost:
|
|
19
|
+
model: "GPT-4o"
|
|
20
|
+
input: "$2.50 / 1M tokens"
|
|
21
|
+
output: "$10.00 / 1M tokens"
|
|
22
|
+
|
|
23
|
+
session:
|
|
24
|
+
tokens: 12,340
|
|
25
|
+
cost: $0.15
|
|
26
|
+
|
|
27
|
+
monthly_estimate:
|
|
28
|
+
sessions: 200
|
|
29
|
+
tokens: ~2.5M
|
|
30
|
+
cost: ~$15
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Optimization Strategies
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
token:
|
|
37
|
+
- Compress prompts (20-40% savings)
|
|
38
|
+
- Use shorter response formats
|
|
39
|
+
- Cache common responses
|
|
40
|
+
- Batch similar requests
|
|
41
|
+
|
|
42
|
+
infrastructure:
|
|
43
|
+
- Right-size cloud resources
|
|
44
|
+
- Use reserved instances (50-70% savings)
|
|
45
|
+
- Auto-scale down at night/weekends
|
|
46
|
+
- Use spot instances for batch jobs
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Changelog
|
|
52
|
+
|
|
53
|
+
### 1.0.0 — Initial release. Token cost tracking, optimization strategies.
|