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.
Files changed (195) hide show
  1. package/AGENTS.md +53 -0
  2. package/CHANGELOG.md +198 -0
  3. package/LICENSE +21 -0
  4. package/README.md +96 -0
  5. package/ROADMAP.md +131 -0
  6. package/RULES.md +202 -0
  7. package/SYSTEM.md +201 -0
  8. package/agents/INDEX.md +40 -0
  9. package/agents/architect-agent.json +15 -0
  10. package/agents/bug-hunter-agent.json +14 -0
  11. package/agents/database-agent.json +14 -0
  12. package/agents/devops-agent.json +15 -0
  13. package/agents/docs-agent.json +15 -0
  14. package/agents/pm-agent.json +14 -0
  15. package/agents/professor-agent.json +15 -0
  16. package/agents/security-agent.json +14 -0
  17. package/agents/senior-engineer-agent.json +16 -0
  18. package/agents/techlead-agent.json +15 -0
  19. package/architecture/clean-architecture.md +98 -0
  20. package/architecture/cqrs-specialist.md +102 -0
  21. package/architecture/ddd-specialist.md +97 -0
  22. package/architecture/event-driven-architect.md +79 -0
  23. package/architecture/hexagonal-architecture.md +96 -0
  24. package/architecture/microservices-expert.md +83 -0
  25. package/architecture/monolith-expert.md +67 -0
  26. package/architecture/repository-pattern.md +73 -0
  27. package/architecture/unit-of-work.md +92 -0
  28. package/backend/README.md +29 -0
  29. package/bin/nexus.js +8 -0
  30. package/core/compression-engine.md +194 -0
  31. package/core/context-engine.md +239 -0
  32. package/core/decision-engine.md +377 -0
  33. package/core/evolution-engine.md +169 -0
  34. package/core/planning-engine.md +201 -0
  35. package/core/quality-gates.md +233 -0
  36. package/core/reflection-engine.md +182 -0
  37. package/core/skill-resolver.json +169 -0
  38. package/core/token-manager.md +152 -0
  39. package/database/database-engineer.md +244 -0
  40. package/database/mysql-specialist.md +61 -0
  41. package/database/postgresql-specialist.md +70 -0
  42. package/database/redis-specialist.md +73 -0
  43. package/database/sql-optimizer.md +95 -0
  44. package/database/sqlserver-specialist.md +69 -0
  45. package/devops/ci-cd-specialist.md +101 -0
  46. package/devops/devops-engineer.md +358 -0
  47. package/devops/docker-expert.md +105 -0
  48. package/devops/git-expert.md +76 -0
  49. package/devops/git-flow-specialist.md +71 -0
  50. package/devops/kubernetes-specialist.md +84 -0
  51. package/devops/linux-specialist.md +82 -0
  52. package/devops/windows-specialist.md +43 -0
  53. package/dist/cli/commands/compile.d.ts +2 -0
  54. package/dist/cli/commands/compile.d.ts.map +1 -0
  55. package/dist/cli/commands/compile.js +44 -0
  56. package/dist/cli/commands/compile.js.map +1 -0
  57. package/dist/cli/commands/doctor.d.ts +2 -0
  58. package/dist/cli/commands/doctor.d.ts.map +1 -0
  59. package/dist/cli/commands/doctor.js +88 -0
  60. package/dist/cli/commands/doctor.js.map +1 -0
  61. package/dist/cli/commands/init.d.ts +2 -0
  62. package/dist/cli/commands/init.d.ts.map +1 -0
  63. package/dist/cli/commands/init.js +26 -0
  64. package/dist/cli/commands/init.js.map +1 -0
  65. package/dist/cli/commands/list.d.ts +2 -0
  66. package/dist/cli/commands/list.d.ts.map +1 -0
  67. package/dist/cli/commands/list.js +50 -0
  68. package/dist/cli/commands/list.js.map +1 -0
  69. package/dist/cli/commands/run.d.ts +2 -0
  70. package/dist/cli/commands/run.d.ts.map +1 -0
  71. package/dist/cli/commands/run.js +49 -0
  72. package/dist/cli/commands/run.js.map +1 -0
  73. package/dist/cli/index.d.ts +2 -0
  74. package/dist/cli/index.d.ts.map +1 -0
  75. package/dist/cli/index.js +72 -0
  76. package/dist/cli/index.js.map +1 -0
  77. package/dist/index.d.ts +3 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +3 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/installer.d.ts +5 -0
  82. package/dist/installer.d.ts.map +1 -0
  83. package/dist/installer.js +86 -0
  84. package/dist/installer.js.map +1 -0
  85. package/dist/postinstall.d.ts +2 -0
  86. package/dist/postinstall.d.ts.map +1 -0
  87. package/dist/postinstall.js +8 -0
  88. package/dist/postinstall.js.map +1 -0
  89. package/frontend/README.md +19 -0
  90. package/memory/context-recovery.md +49 -0
  91. package/memory/conversation-summarizer.md +65 -0
  92. package/memory/long-term-project-memory.md +58 -0
  93. package/memory/memory-manager.md +299 -0
  94. package/memory/session-compression.md +182 -0
  95. package/memory/smart-recall.md +37 -0
  96. package/optimization/compact-example.md +87 -0
  97. package/optimization/cost-optimizer.md +53 -0
  98. package/optimization/prompt-optimizer.md +194 -0
  99. package/optimization/token-audit.md +177 -0
  100. package/optimization/token-reducer.md +202 -0
  101. package/package.json +67 -0
  102. package/security/owasp-auditor.md +249 -0
  103. package/security/pentest-reviewer.md +109 -0
  104. package/security/security-engineer.md +238 -0
  105. package/skills/INDEX.md +434 -0
  106. package/skills/accessibility-reviewer.md +63 -0
  107. package/skills/agentic-coding.md +56 -0
  108. package/skills/ai-agent/SKILL.md +107 -0
  109. package/skills/ai-agent-dev/SKILL.md +117 -0
  110. package/skills/alternative-solution-generator.md +72 -0
  111. package/skills/architecture-patterns/SKILL.md +113 -0
  112. package/skills/breaking-change-detector.md +84 -0
  113. package/skills/bug-hunter.md +234 -0
  114. package/skills/bug-prevention.md +75 -0
  115. package/skills/chaos-engineering/SKILL.md +108 -0
  116. package/skills/clean-code-validator.md +218 -0
  117. package/skills/cloud-architect/SKILL.md +78 -0
  118. package/skills/cloud-infra/SKILL.md +99 -0
  119. package/skills/code-auditor.md +24 -0
  120. package/skills/complexity-analyzer.md +102 -0
  121. package/skills/confidence-estimator.md +53 -0
  122. package/skills/continuous-improvement.md +46 -0
  123. package/skills/continuous-learning-engine.md +51 -0
  124. package/skills/cto-advisor.md +66 -0
  125. package/skills/data-engineer/SKILL.md +76 -0
  126. package/skills/data-engineering/SKILL.md +82 -0
  127. package/skills/debug-specialist.md +215 -0
  128. package/skills/dependency-analyzer.md +78 -0
  129. package/skills/design-pattern-advisor.md +78 -0
  130. package/skills/documentation-writer.md +66 -0
  131. package/skills/dry-kiss-yagni-validator.md +114 -0
  132. package/skills/economia-tokens/SKILL.md +40 -0
  133. package/skills/er-diagram-builder.md +85 -0
  134. package/skills/feature-flags/SKILL.md +95 -0
  135. package/skills/frontend/SKILL.md +327 -0
  136. package/skills/frontend-dev/SKILL.md +178 -0
  137. package/skills/graphql/SKILL.md +104 -0
  138. package/skills/hallucination-detection.md +49 -0
  139. package/skills/handoff-sessao/SKILL.md +32 -0
  140. package/skills/i18n-l10n/SKILL.md +103 -0
  141. package/skills/iac-terraform/SKILL.md +98 -0
  142. package/skills/legacy-migration/SKILL.md +91 -0
  143. package/skills/logging-expert.md +78 -0
  144. package/skills/mcp-server-dev.md +33 -0
  145. package/skills/memoria-projeto/SKILL.md +49 -0
  146. package/skills/mobile-dev/SKILL.md +82 -0
  147. package/skills/mobile-engineer/SKILL.md +74 -0
  148. package/skills/monitoring-specialist.md +59 -0
  149. package/skills/observability-expert.md +60 -0
  150. package/skills/performance-optimizer.md +239 -0
  151. package/skills/principal-engineer.md +55 -0
  152. package/skills/privacy-engineer/SKILL.md +79 -0
  153. package/skills/professor-modo/SKILL.md +33 -0
  154. package/skills/project-manager.md +74 -0
  155. package/skills/prompt-engineering.md +27 -0
  156. package/skills/qa/SKILL.md +231 -0
  157. package/skills/qa-engineer/SKILL.md +222 -0
  158. package/skills/readme-generator.md +42 -0
  159. package/skills/refactoring-specialist.md +250 -0
  160. package/skills/release-planner.md +70 -0
  161. package/skills/requirement-analyzer.md +65 -0
  162. package/skills/risk-analyzer.md +73 -0
  163. package/skills/root-cause-analyzer.md +210 -0
  164. package/skills/scalability-expert.md +73 -0
  165. package/skills/security-privacy/SKILL.md +98 -0
  166. package/skills/self-correction.md +54 -0
  167. package/skills/self-critique.md +42 -0
  168. package/skills/senior-code-reviewer.md +193 -0
  169. package/skills/sequence-diagram-builder.md +56 -0
  170. package/skills/serverless-edge/SKILL.md +103 -0
  171. package/skills/software-architect.md +356 -0
  172. package/skills/solid-validator.md +332 -0
  173. package/skills/sre-reliability/SKILL.md +115 -0
  174. package/skills/staff-engineer.md +61 -0
  175. package/skills/task-planner.md +61 -0
  176. package/skills/tech-lead.md +59 -0
  177. package/skills/technical-debt-analyzer.md +81 -0
  178. package/skills/technical-writer.md +39 -0
  179. package/skills/tradeoff-analyzer.md +79 -0
  180. package/skills/uml-generator.md +72 -0
  181. package/skills/ux-reviewer.md +61 -0
  182. package/skills/wasm/SKILL.md +133 -0
  183. package/skills/web-perf-engineer/SKILL.md +75 -0
  184. package/skills/web-perf-seo/SKILL.md +111 -0
  185. package/skills/websocket-realtime/SKILL.md +107 -0
  186. package/teaching/adaptive-teaching.md +37 -0
  187. package/teaching/code-explainer.md +172 -0
  188. package/teaching/interactive-teaching.md +41 -0
  189. package/teaching/learning-tracker.md +63 -0
  190. package/teaching/mentor-mode.md +200 -0
  191. package/teaching/professor-mode.md +222 -0
  192. package/testing/e2e-test-engineer.md +68 -0
  193. package/testing/integration-test-engineer.md +74 -0
  194. package/testing/mocking-specialist.md +78 -0
  195. 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.