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,194 @@
1
+ # Optimization: Prompt Optimizer
2
+
3
+ > Version 1.0.0
4
+ > Priority: High
5
+ > Dependencies: Token Manager, Compression Engine
6
+ > Compatibility: ">=1.0.0"
7
+
8
+ ---
9
+
10
+ ## Identity
11
+
12
+ The Prompt Optimizer restructures incoming user prompts to be maximally efficient for the LLM. It strips noise, reformats ambiguity into clarity, extracts implicit requirements, and structures the prompt for optimal reasoning — all before the Decision Engine classifies it.
13
+
14
+ ---
15
+
16
+ ## Goals
17
+
18
+ - Reduce prompt token count by 20-40% before processing.
19
+ - Extract implicit requirements the user didn't state.
20
+ - Structure ambiguous requests into clear, actionable tasks.
21
+ - Remove filler, repetition, and conversational noise.
22
+ - Preserve every meaningful piece of information.
23
+
24
+ ---
25
+
26
+ ## Optimization Passes
27
+
28
+ ### Pass 1: Noise Removal
29
+
30
+ Remove elements that add no semantic value:
31
+
32
+ - Greetings: "Hey, how are you? Hope you're doing well..."
33
+ - Fillers: "I was wondering if maybe you could possibly..." → "Can you..."
34
+ - Apologies: "Sorry if this is a dumb question but..."
35
+ - Meta: "I'm not sure if this makes sense but..."
36
+ - Repetition: Same question asked 3 different ways
37
+
38
+ **Savings: 10-20%**
39
+
40
+ ### Pass 2: Implicit Extraction
41
+
42
+ Extract requirements the user implied but didn't state:
43
+
44
+ ```
45
+ Input: "Create a login page"
46
+ Extracted:
47
+ - Framework: Laravel (from project context)
48
+ - Auth method: JWT (from project memory)
49
+ - DB: PostgreSQL (from project memory)
50
+ - Needs: registration, login, logout, password reset (implicit)
51
+ - Security: rate limiting, password hashing, CSRF (implied by best practice)
52
+ ```
53
+
54
+ **Adds ~50-100 tokens of high-value context.**
55
+
56
+ ### Pass 3: Ambiguity Resolution
57
+
58
+ Flag and resolve ambiguous statements:
59
+
60
+ ```
61
+ Input: "Make it secure"
62
+ → Which aspect? Auth? Input validation? Encryption? All of the above?
63
+ → Resolution: "Apply OWASP security standards to all endpoints"
64
+ ```
65
+
66
+ If ambiguity cannot be resolved from context:
67
+
68
+ ```
69
+ → Flag for clarification
70
+ → "You mentioned 'Make it secure' — should I focus on auth, input validation,
71
+ or a full OWASP audit?"
72
+ ```
73
+
74
+ ### Pass 4: Structuring
75
+
76
+ Convert free-form input into structured format:
77
+
78
+ ```
79
+ BEFORE:
80
+ "I need to build an API for my blog. Users should be able to create posts and
81
+ comment on them. Oh and I need categories too. And authentication obviously.
82
+ Make it fast."
83
+
84
+ AFTER:
85
+ ## Project: Blog API
86
+ ## Requirements:
87
+ - Authentication (users can register, login, logout)
88
+ - Posts CRUD (create, read, update, delete)
89
+ - Comments (users can comment on posts)
90
+ - Categories (posts belong to categories)
91
+ ## Constraints:
92
+ - Performance is a priority
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Optimized Prompt Format
98
+
99
+ ```yaml
100
+ optimized_prompt:
101
+ original_length: 247
102
+ optimized_length: 134
103
+ savings: "46%"
104
+
105
+ task:
106
+ type: "new_feature"
107
+ title: "Blog API with auth, posts, comments, categories"
108
+
109
+ requirements:
110
+ - "User authentication (register, login, logout)"
111
+ - "Post CRUD with categories"
112
+ - "Comment on posts"
113
+
114
+ constraints:
115
+ - "Performance is priority"
116
+ - "Uses Laravel + PostgreSQL (from project context)"
117
+
118
+ implicit:
119
+ - "Needs input validation"
120
+ - "Needs authorization (user can only edit own posts)"
121
+ - "Needs API rate limiting"
122
+ - "Needs pagination for listing"
123
+
124
+ clarifications_needed: []
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Algorithm
130
+
131
+ ```
132
+ function optimize_prompt(raw_input):
133
+ // Pass 1: Remove noise
134
+ cleaned = remove_noise(raw_input)
135
+
136
+ // Pass 2: Extract implicit requirements
137
+ context = load_project_context()
138
+ implicit = extract_implicit(cleaned, context)
139
+
140
+ // Pass 3: Detect ambiguity
141
+ ambiguities = detect_ambiguity(cleaned)
142
+
143
+ // Pass 4: Structure
144
+ structured = structure_prompt(cleaned, implicit)
145
+
146
+ return {
147
+ optimized: structured,
148
+ clarifications: ambiguities,
149
+ savings: 1 - (len(structured) / len(raw_input))
150
+ }
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Rules
156
+
157
+ ### Always
158
+
159
+ - ✅ Remove noise before processing.
160
+ - ✅ Extract implicit requirements from project context.
161
+ - ✅ Flag unresolved ambiguity for clarification.
162
+ - ✅ Structure into machine-readable format.
163
+ - ✅ Track token savings.
164
+
165
+ ### Never
166
+
167
+ - ❌ Remove requirements, even if they seem implied.
168
+ - ❌ Guess when project context is insufficient — ask.
169
+ - ❌ Over-structure to the point of losing natural meaning.
170
+ - ❌ Add requirements the user didn't ask for or imply.
171
+
172
+ ---
173
+
174
+ ## Metrics
175
+
176
+ | Metric | Target | How to Measure |
177
+ |--------|--------|---------------|
178
+ | Token savings | 20-40% | Original vs optimized length |
179
+ | Implicit extraction accuracy | ≥ 80% | Extracted items confirmed by user |
180
+ | Clarification rate | ≤ 15% | Prompts needing user clarification |
181
+ | Requirement completeness | 100% | All user requirements preserved in output |
182
+
183
+ ---
184
+
185
+ ## Changelog
186
+
187
+ ### 1.0.0 (2026-07-17)
188
+
189
+ - Initial release
190
+ - 4 optimization passes (noise, implicit, ambiguity, structure)
191
+ - Implicit requirement extraction from project context
192
+ - Ambiguity detection algorithm
193
+ - Structured YAML output format
194
+ - Token savings tracking
@@ -0,0 +1,177 @@
1
+ # Token Optimization Audit
2
+
3
+ > Análise de consumo atual + plano de redução de 40-60%.
4
+
5
+ ---
6
+
7
+ ## 1. Diagnóstico — Onde os tokens estão sendo gastos
8
+
9
+ ### 1.1 Estruturas Repetidas (principal vilão)
10
+
11
+ Cada uma das 98 skills repete o mesmo molde:
12
+
13
+ ```
14
+ > Version X | Priority: X
15
+ > Dependencies: ...
16
+ > Compatibility: ...
17
+
18
+ ## Identity (2-3 parágrafos)
19
+ ## Goals (lista)
20
+ ## Triggers (tabela)
21
+ ## Checklist
22
+ ## Examples (before/after)
23
+ ## Changelog
24
+ ```
25
+
26
+ **Custo:** ~400 tokens repetidos por skill × 98 skills = **~39.200 tokens** de boilerplate.
27
+
28
+ ### 1.2 YAML Frontmatter vs Formato Atual
29
+
30
+ O formato atual usa markdown com cabeçalhos. YAML inline seria mais compacto.
31
+
32
+ ### 1.3 Descrições Prolixas
33
+
34
+ Muitas skills explicam o óbvio. Exemplo real:
35
+
36
+ ```
37
+ "We designed this schema with the goal of..."
38
+ → "Schema 3NF com índices em FK, WHERE, ORDER BY."
39
+ ```
40
+
41
+ ### 1.4 Checklists Duplicadas
42
+
43
+ OWASP checklist aparece em `security-engineer.md` e `owasp-auditor.md`. Idem para SOLID, Clean Code, etc.
44
+
45
+ ---
46
+
47
+ ## 2. Plano de Redução por Técnica
48
+
49
+ ### Técnica A — Skill Template Compacto (economia: 35%)
50
+
51
+ Substituir o cabeçalho verbose por YAML inline:
52
+
53
+ ```yaml
54
+ # ANTES (79 tokens)
55
+ > Version 1.0.0 | Priority: High
56
+ > Dependencies: Software Architect, Database Engineer, Security Engineer
57
+ > Compatibility: ">=1.0.0"
58
+
59
+ ## Identity
60
+ Responsável por projetar a arquitetura...
61
+
62
+ # DEPOIS (28 tokens)
63
+ v: 1.0.0 | p: high | deps: [architect, db, security]
64
+ ```
65
+
66
+ **Impacto:** 39.200 → 14.000 tokens (economia de ~25.200 tokens em carga inicial).
67
+
68
+ ### Técnica B — Unificar Checklists Duplicadas (economia: 15%)
69
+
70
+ Checklists que aparecem em múltiplos lugares viram referências:
71
+
72
+ ```
73
+ # ANTES
74
+ skills/security-engineer.md tem OWASP checklist (150 tokens)
75
+ security/owasp-auditor.md tem OWASP checklist (150 tokens)
76
+
77
+ # DEPOIS
78
+ security/owasp-checklist.md (única fonte)
79
+ Referenciado por: security-engineer.md, owasp-auditor.md, pentest-reviewer.md
80
+ ```
81
+
82
+ **Impacto:** elimina ~300 tokens duplicados por checklist unificada.
83
+
84
+ ### Técnica C — Short IDs para Skills (economia: 8%)
85
+
86
+ Usar IDs curtos nas chains:
87
+
88
+ ```
89
+ # ANTES
90
+ "skills/software-architect", "skills/senior-code-reviewer"
91
+
92
+ # DEPOIS
93
+ "architect", "reviewer"
94
+ ```
95
+
96
+ **Impacto:** reduz ~15 tokens por referência em agents.json.
97
+
98
+ ### Técnica D — Remover "Changelog" de Skills Individuais (economia: 5%)
99
+
100
+ Changelog de cada skill individual raramente é lido. Manter só no CHANGELOG.md central.
101
+
102
+ **Impacto:** ~30 tokens por skill × 98 = ~2.940 tokens.
103
+
104
+ ### Técnica E — Comprimir Descrições (economia: 20%)
105
+
106
+ Reduzir identity/goals para 1 linha cada:
107
+
108
+ ```
109
+ # ANTES (60 tokens)
110
+ "Responsável por projetar a arquitetura de software antes que qualquer código seja escrito. É a primeira skill ativada em projetos novos."
111
+
112
+ # DEPOIS (20 tokens)
113
+ "Arquiteta antes de codificar. Ativada primeiro em projetos novos."
114
+ ```
115
+
116
+ ---
117
+
118
+ ## 3. Estimativa de Economia Total
119
+
120
+ | Técnica | Tokens Salvos | % | Esforço |
121
+ |---------|--------------|---|---------|
122
+ | A — Template compacto | ~25.200 | 35% | Alto (reescrever 98 skills) |
123
+ | B — Checklists unificadas | ~4.500 | 15% | Médio (extrair 10 checklists) |
124
+ | C — Short IDs | ~2.000 | 8% | Baixo (sed nos agents) |
125
+ | D — Remove changelogs | ~2.940 | 5% | Baixo (sed global) |
126
+ | E — Descrições comprimidas | ~14.000 | 20% | Alto (revisão manual) |
127
+ | **Total** | **~48.640** | **~55%** | — |
128
+
129
+ ---
130
+
131
+ ## 4. Ações Imediatas (baixo esforço, alto retorno)
132
+
133
+ ### 4.1 Template Compacto para Skills Novas
134
+
135
+ Toda skill nova usa este formato:
136
+
137
+ ```yaml
138
+ ---
139
+ v: 1.0.0
140
+ p: high
141
+ deps: [skill-a, skill-b]
142
+ triggers: [new_project, new_feature]
143
+ budget: 500
144
+ ---
145
+ ```
146
+
147
+ ### 4.2 Unificar Checklists Agora
148
+
149
+ | Checklist | Dono | Skills que referenciam |
150
+ |-----------|------|----------------------|
151
+ | OWASP Top 10 | security/owasp-checklist.md | security-engineer, owasp-auditor, pentest-reviewer |
152
+ | SOLID | quality/solid-checklist.md | solid-validator, clean-code-validator, code-reviewer |
153
+ | Performance | quality/perf-checklist.md | performance-optimizer, scalability-expert |
154
+ | Acessibilidade | quality/a11y-checklist.md | accessibility-reviewer, ux-reviewer, frontend-engineer |
155
+
156
+ ### 4.3 Short IDs nos Agents
157
+
158
+ ```json
159
+ // agents/architect-agent.json
160
+ "skills": ["architect", "clean-arch", "ddd", "cqrs"]
161
+ // Resolve para skills/software-architect.md, architecture/clean-architecture.md, etc.
162
+ ```
163
+
164
+ ---
165
+
166
+ ## 5. Meta
167
+
168
+ | Métrica | Atual | Alvo | Prazo |
169
+ |---------|-------|------|-------|
170
+ | Tokens para carregar tudo | ~88.000 | ≤ 40.000 | v2.0 |
171
+ | Tokens por skill (média) | ~900 | ≤ 400 | v2.0 |
172
+ | Checklists duplicadas | 12 | 0 | v1.1 |
173
+ | Boilerplate por skill | ~400 | ~100 | v2.0 |
174
+
175
+ ---
176
+
177
+ > "O melhor token é o que você não gasta."
@@ -0,0 +1,202 @@
1
+ # Optimization: Token Reducer
2
+
3
+ > Version 1.0.0
4
+ > Priority: High
5
+ > Dependencies: Compression Engine, Context Engine
6
+ > Compatibility: ">=1.0.0"
7
+
8
+ ---
9
+
10
+ ## Identity
11
+
12
+ The Token Reducer works alongside the Compression Engine to proactively reduce token consumption before content is generated. It applies techniques like shortening prompts, removing redundant instructions, and choosing compact output formats — all without losing meaning.
13
+
14
+ ---
15
+
16
+ ## Goals
17
+
18
+ - Reduce prompt tokens by 20-40% before generation.
19
+ - Reduce output tokens by 15-30% through format optimization.
20
+ - Eliminate all redundant instructions and meta-commentary.
21
+ - Choose the most token-efficient format for every output type.
22
+
23
+ ---
24
+
25
+ ## Reduction Techniques
26
+
27
+ ### Technique 1: Shorten Instructions
28
+
29
+ Remove redundant meta-instructions that are already encoded in the skill.
30
+
31
+ ```
32
+ BEFORE:
33
+ "Now I will analyze the requirements you provided and think about what architecture would be best for your project. Let me consider the different options available..."
34
+
35
+ AFTER:
36
+ "## Architecture Analysis"
37
+ ```
38
+
39
+ **Savings: ~40 tokens per occurrence.**
40
+
41
+ ### Technique 2: Compact Lists
42
+
43
+ Use compact list format instead of verbose bullet points.
44
+
45
+ ```
46
+ BEFORE:
47
+ "- First, we need to create a migration file for the users table
48
+ - Second, we create the User model with the necessary relationships
49
+ - Third, we implement the AuthController with login and register methods"
50
+
51
+ AFTER:
52
+ "1. Users migration
53
+ 2. User model (relationships)
54
+ 3. AuthController (login, register)"
55
+ ```
56
+
57
+ **Savings: ~30 tokens per list.**
58
+
59
+ ### Technique 3: No Meta-Commentary
60
+
61
+ Eliminate sentences about what the AI is doing or about to do.
62
+
63
+ ```
64
+ BEFORE: "Let me now generate the code for the controller. I'll make sure to include proper validation and error handling."
65
+
66
+ AFTER: (just the code)
67
+ ```
68
+
69
+ **Savings: ~20 tokens per occurrence.**
70
+
71
+ ### Technique 4: Use Shorthand Headers
72
+
73
+ ```
74
+ BEFORE: "## Analysis of Requirements"
75
+ AFTER: "## Requirements"
76
+
77
+ BEFORE: "## Description of the Architecture Pattern"
78
+ AFTER: "## Architecture"
79
+
80
+ BEFORE: "## Implementation Details and Code Examples"
81
+ AFTER: "## Implementation"
82
+ ```
83
+
84
+ **Savings: ~10 tokens per header.**
85
+
86
+ ### Technique 5: Remove Redundant Code Comments
87
+
88
+ When code is self-explanatory, omit comments.
89
+
90
+ ```
91
+ // ❌ Verbose
92
+ $user = User::find($id); // Find the user by their ID from the database
93
+
94
+ // ✅ Clean
95
+ $user = User::find($id);
96
+ ```
97
+
98
+ **Savings: ~15 tokens per comment.**
99
+
100
+ ### Technique 6: Compact Error Messages
101
+
102
+ ```
103
+ BEFORE: "An error occurred while processing your request. Please try again later."
104
+ AFTER: "Error processing request. Try again later."
105
+ ```
106
+
107
+ **Savings: ~10 tokens per message.**
108
+
109
+ ---
110
+
111
+ ## Format Selection
112
+
113
+ Choose the most token-efficient format based on content type:
114
+
115
+ | Content Type | Best Format | Token Savings vs Default |
116
+ |-------------|-------------|------------------------|
117
+ | Code | Code block (```) | Baseline |
118
+ | Config | YAML | 20% vs JSON |
119
+ | Data | JSON compact (no spaces) | 30% vs pretty-print |
120
+ | List | Markdown list | Baseline |
121
+ | Table | Pipe table | 30% vs HTML table |
122
+ | Decision | YAML | 40% vs prose |
123
+ | Report | YAML + prose mix | 25% vs all prose |
124
+ | Teaching | Short code + explanation | 35% vs long explanation |
125
+
126
+ ---
127
+
128
+ ## Algorithm
129
+
130
+ ```
131
+ function reduce_prompt(prompt):
132
+ techniques = [
133
+ shorten_instructions,
134
+ remove_meta_commentary,
135
+ compact_headers,
136
+ remove_redundant_examples,
137
+ ]
138
+
139
+ for technique in techniques:
140
+ if size(prompt) > target:
141
+ prompt = technique(prompt)
142
+
143
+ return prompt
144
+
145
+
146
+ function reduce_output(output, format):
147
+ if format == "code":
148
+ output = remove_redundant_comments(output)
149
+ output = compact_imports(output)
150
+
151
+ elif format == "list":
152
+ output = use_compact_list(output)
153
+
154
+ elif format == "decision":
155
+ output = use_yaml_format(output)
156
+
157
+ elif format == "teaching":
158
+ output = prioritize_code_over_explanation(output)
159
+
160
+ return output
161
+ ```
162
+
163
+ ---
164
+
165
+ ## Rules
166
+
167
+ ### Always
168
+
169
+ - ✅ Reduce prompt tokens before every generation.
170
+ - ✅ Choose the most token-efficient format for the content.
171
+ - ✅ Remove meta-commentary about what the AI is doing.
172
+ - ✅ Use compact lists over verbose bullet points.
173
+
174
+ ### Never
175
+
176
+ - ❌ Reduce content that would make it unclear or ambiguous.
177
+ - ❌ Remove security-critical explanations.
178
+ - ❌ Eliminate necessary context for understanding.
179
+ - ❌ Sacrifice teaching quality for token savings.
180
+
181
+ ---
182
+
183
+ ## Metrics
184
+
185
+ | Metric | Target | How to Measure |
186
+ |--------|--------|---------------|
187
+ | Prompt reduction | 20-40% | Original vs reduced size |
188
+ | Output reduction | 15-30% | Original vs reduced size |
189
+ | Clarity retention | ≥ 95% | User follow-up clarification rate |
190
+ | Format efficiency | Optimal per type | Tokens per content type |
191
+
192
+ ---
193
+
194
+ ## Changelog
195
+
196
+ ### 1.0.0 (2026-07-17)
197
+
198
+ - Initial release
199
+ - 6 reduction techniques
200
+ - Format selection matrix for 8 content types
201
+ - Prompt and output reduction algorithms
202
+ - Teaching quality preservation rules
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "izanagi-ai",
3
+ "version": "2.0.0",
4
+ "description": "Modular Skill-Oriented AI Prompt & Agent Framework for Autonomous Software Engineering",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "type": "module",
9
+ "bin": {
10
+ "nexus": "./bin/nexus.js",
11
+ "nexusai": "./bin/nexus.js"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "bin",
16
+ "agents",
17
+ "architecture",
18
+ "backend",
19
+ "core",
20
+ "database",
21
+ "devops",
22
+ "frontend",
23
+ "memory",
24
+ "optimization",
25
+ "security",
26
+ "skills",
27
+ "teaching",
28
+ "testing",
29
+ "SYSTEM.md",
30
+ "RULES.md",
31
+ "AGENTS.md",
32
+ "CHANGELOG.md",
33
+ "ROADMAP.md"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsc",
37
+ "prepare": "npm run build",
38
+ "postinstall": "node dist/postinstall.js",
39
+ "start": "node bin/nexus.js",
40
+ "doctor": "node bin/nexus.js doctor",
41
+ "list": "node bin/nexus.js list"
42
+ },
43
+ "keywords": [
44
+ "nexusai",
45
+ "ai",
46
+ "agents",
47
+ "prompt-engineering",
48
+ "skills",
49
+ "cli",
50
+ "llm",
51
+ "code-generation",
52
+ "autonomous-agents"
53
+ ],
54
+ "author": "Pedro Henrique Sanches Leal",
55
+ "license": "MIT",
56
+ "engines": {
57
+ "node": ">=18.0.0"
58
+ },
59
+ "devDependencies": {
60
+ "@types/node": "^20.19.43",
61
+ "typescript": "^5.9.3"
62
+ },
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "git+https://github.com/pedrohenriquesanchesleal4-debug/NexusAi.git"
66
+ }
67
+ }