sinapse-ai 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/.claude/hooks/mind-clone-governance.py +212 -212
  2. package/.claude/hooks/read-protection.py +152 -152
  3. package/.claude/hooks/slug-validation.py +175 -175
  4. package/.claude/hooks/sql-governance.py +183 -183
  5. package/.sinapse-ai/development/templates/service-template/README.md.hbs +159 -159
  6. package/.sinapse-ai/development/templates/service-template/__tests__/index.test.ts.hbs +238 -238
  7. package/.sinapse-ai/development/templates/service-template/client.ts.hbs +404 -404
  8. package/.sinapse-ai/development/templates/service-template/errors.ts.hbs +183 -183
  9. package/.sinapse-ai/development/templates/service-template/index.ts.hbs +121 -121
  10. package/.sinapse-ai/development/templates/service-template/package.json.hbs +88 -88
  11. package/.sinapse-ai/development/templates/service-template/types.ts.hbs +146 -146
  12. package/.sinapse-ai/development/templates/squad-template/LICENSE +22 -22
  13. package/.sinapse-ai/infrastructure/templates/coderabbit.yaml.template +280 -280
  14. package/.sinapse-ai/infrastructure/templates/config/env.example +16 -16
  15. package/.sinapse-ai/infrastructure/templates/config/gitignore-additions.tmpl +59 -59
  16. package/.sinapse-ai/infrastructure/templates/github/CODEOWNERS.template +12 -12
  17. package/.sinapse-ai/infrastructure/templates/github-workflows/ci.yml.template +170 -170
  18. package/.sinapse-ai/infrastructure/templates/github-workflows/pr-automation.yml.template +331 -331
  19. package/.sinapse-ai/infrastructure/templates/github-workflows/release.yml.template +197 -197
  20. package/.sinapse-ai/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +19 -19
  21. package/.sinapse-ai/infrastructure/templates/gitignore/gitignore-node.tmpl +86 -86
  22. package/.sinapse-ai/infrastructure/templates/gitignore/gitignore-python.tmpl +146 -146
  23. package/.sinapse-ai/infrastructure/templates/gitignore/gitignore-sinapse-base.tmpl +64 -64
  24. package/.sinapse-ai/infrastructure/templates/safe-collab/CODEOWNERS.template +16 -16
  25. package/.sinapse-ai/infrastructure/templates/sinapse-sync.yaml.template +183 -183
  26. package/.sinapse-ai/install-manifest.yaml +55 -55
  27. package/.sinapse-ai/local-config.yaml.template +65 -65
  28. package/.sinapse-ai/monitor/hooks/lib/__init__.py +2 -2
  29. package/.sinapse-ai/monitor/hooks/lib/enrich.py +59 -59
  30. package/.sinapse-ai/monitor/hooks/lib/send_event.py +48 -48
  31. package/.sinapse-ai/monitor/hooks/notification.py +30 -30
  32. package/.sinapse-ai/monitor/hooks/post_tool_use.py +46 -46
  33. package/.sinapse-ai/monitor/hooks/pre_compact.py +30 -30
  34. package/.sinapse-ai/monitor/hooks/pre_tool_use.py +41 -41
  35. package/.sinapse-ai/monitor/hooks/stop.py +30 -30
  36. package/.sinapse-ai/monitor/hooks/subagent_stop.py +30 -30
  37. package/.sinapse-ai/monitor/hooks/user_prompt_submit.py +39 -39
  38. package/.sinapse-ai/product/templates/adr.hbs +126 -126
  39. package/.sinapse-ai/product/templates/dbdr.hbs +242 -242
  40. package/.sinapse-ai/product/templates/epic.hbs +213 -213
  41. package/.sinapse-ai/product/templates/pmdr.hbs +187 -187
  42. package/.sinapse-ai/product/templates/prd-v2.0.hbs +217 -217
  43. package/.sinapse-ai/product/templates/prd.hbs +202 -202
  44. package/.sinapse-ai/product/templates/story.hbs +264 -264
  45. package/.sinapse-ai/product/templates/task.hbs +171 -171
  46. package/.sinapse-ai/product/templates/tmpl-comment-on-examples.sql +159 -159
  47. package/.sinapse-ai/product/templates/tmpl-migration-script.sql +92 -92
  48. package/.sinapse-ai/product/templates/tmpl-rls-granular-policies.sql +105 -105
  49. package/.sinapse-ai/product/templates/tmpl-rls-kiss-policy.sql +11 -11
  50. package/.sinapse-ai/product/templates/tmpl-rls-roles.sql +136 -136
  51. package/.sinapse-ai/product/templates/tmpl-rls-simple.sql +78 -78
  52. package/.sinapse-ai/product/templates/tmpl-rls-tenant.sql +153 -153
  53. package/.sinapse-ai/product/templates/tmpl-rollback-script.sql +78 -78
  54. package/.sinapse-ai/product/templates/tmpl-seed-data.sql +141 -141
  55. package/.sinapse-ai/product/templates/tmpl-smoke-test.sql +17 -17
  56. package/.sinapse-ai/product/templates/tmpl-staging-copy-merge.sql +140 -140
  57. package/.sinapse-ai/product/templates/tmpl-stored-proc.sql +141 -141
  58. package/.sinapse-ai/product/templates/tmpl-trigger.sql +153 -153
  59. package/.sinapse-ai/product/templates/tmpl-view-materialized.sql +134 -134
  60. package/.sinapse-ai/product/templates/tmpl-view.sql +178 -178
  61. package/LICENSE +63 -63
  62. package/package.json +1 -1
  63. package/packages/sinapse-install/bin/edmcp.js +0 -0
  64. package/packages/sinapse-install/bin/sinapse-install.js +0 -0
  65. package/scripts/check-markdown-links.py +352 -352
  66. package/.sinapse-ai/lib/build.json +0 -1
@@ -1,212 +1,212 @@
1
- #!/usr/bin/env python3
2
- """
3
- Hook: Mind Clone Governance
4
-
5
- REGRA: Agents baseados em pessoas reais (mind clones) DEVEM passar pelo
6
- pipeline de extração de DNA antes de serem criados.
7
-
8
- Este hook intercepta Write/Edit em squads/*/agents/*.md e verifica:
9
- 1. Se é um mind clone (baseado em pessoa real)
10
- 2. Se existe DNA extraído correspondente
11
-
12
- NÃO BLOQUEIA:
13
- - Orchestrators (nome contém 'chief', 'orchestrator', 'chair')
14
- - Tool agents (nome contém 'validator', 'calculator', 'generator')
15
- - Process agents (nome contém 'architect', 'mapper', 'designer')
16
- - Edição de arquivo existente (apenas criação é bloqueada)
17
-
18
- Exit Codes:
19
- - 0: Permitido
20
- - 2: Bloqueado (mind clone sem DNA)
21
- """
22
-
23
- import json
24
- import sys
25
- import os
26
- import re
27
- from pathlib import Path
28
-
29
- # =============================================================================
30
- # CONFIGURAÇÃO
31
- # =============================================================================
32
-
33
- # Padrões que indicam que NÃO é um mind clone (agents funcionais)
34
- FUNCTIONAL_AGENT_PATTERNS = [
35
- # Orchestrators
36
- r'.*-chief$',
37
- r'.*-orchestrator$',
38
- r'.*-chair$',
39
- r'^orchestrator$',
40
-
41
- # Tool agents
42
- r'.*-validator$',
43
- r'.*-calculator$',
44
- r'.*-generator$',
45
- r'.*-extractor$',
46
- r'.*-analyzer$',
47
-
48
- # Process agents
49
- r'.*-architect$',
50
- r'.*-mapper$',
51
- r'.*-designer$',
52
- r'.*-engineer$',
53
-
54
- # Generic functional
55
- r'^tools?-.*',
56
- r'^process-.*',
57
- r'^workflow-.*',
58
- ]
59
-
60
- # Locais onde DNA pode estar
61
- DNA_LOCATIONS = [
62
- "squads/{pack}/data/minds/{agent_id}_dna.yaml",
63
- "squads/{pack}/data/minds/{agent_id}_dna.md",
64
- "squads/{pack}/data/{agent_id}-dna.yaml",
65
- "outputs/minds/{agent_id}/",
66
- ]
67
-
68
- # =============================================================================
69
- # LÓGICA DO HOOK
70
- # =============================================================================
71
-
72
- def get_project_root():
73
- """Obtém o root do projeto via variável de ambiente ou cwd."""
74
- return os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd())
75
-
76
- def extract_agent_info(file_path: str) -> tuple:
77
- """Extrai pack_name e agent_id do path."""
78
- # squads/{pack}/agents/{agent_id}.md
79
- match = re.match(r'.*/squads/([^/]+)/agents/([^/]+)\.md$', file_path)
80
- if match:
81
- return match.group(1), match.group(2)
82
- return None, None
83
-
84
- def is_functional_agent(agent_id: str) -> bool:
85
- """Verifica se o agent é funcional (não é mind clone)."""
86
- for pattern in FUNCTIONAL_AGENT_PATTERNS:
87
- if re.match(pattern, agent_id, re.IGNORECASE):
88
- return True
89
- return False
90
-
91
- def has_dna_extracted(project_root: str, pack_name: str, agent_id: str) -> tuple:
92
- """Verifica se existe DNA extraído para o agent."""
93
- for location_template in DNA_LOCATIONS:
94
- location = location_template.format(pack=pack_name, agent_id=agent_id)
95
- full_path = os.path.join(project_root, location)
96
-
97
- # Se é diretório, verificar se existe
98
- if location.endswith('/'):
99
- if os.path.isdir(full_path):
100
- return True, full_path
101
- # Se é arquivo, verificar se existe
102
- elif os.path.isfile(full_path):
103
- return True, full_path
104
-
105
- return False, None
106
-
107
- def file_already_exists(file_path: str) -> bool:
108
- """Verifica se o arquivo já existe (edit vs create)."""
109
- return os.path.isfile(file_path)
110
-
111
- def main():
112
- # Ler input do stdin
113
- try:
114
- input_data = json.load(sys.stdin)
115
- except json.JSONDecodeError:
116
- # Se não conseguir parsear, permitir (fail-open)
117
- sys.exit(0)
118
-
119
- tool_name = input_data.get("tool_name", "")
120
- tool_input = input_data.get("tool_input", {})
121
-
122
- # Só processar Write e Edit
123
- if tool_name not in ["Write", "Edit"]:
124
- sys.exit(0)
125
-
126
- file_path = tool_input.get("file_path", "")
127
- if not file_path:
128
- sys.exit(0)
129
-
130
- # Só processar arquivos em squads/*/agents/
131
- if "/squads/" not in file_path or "/agents/" not in file_path:
132
- sys.exit(0)
133
-
134
- if not file_path.endswith(".md"):
135
- sys.exit(0)
136
-
137
- project_root = get_project_root()
138
-
139
- # Extrair informações do path
140
- pack_name, agent_id = extract_agent_info(file_path)
141
- if not pack_name or not agent_id:
142
- sys.exit(0)
143
-
144
- # Se é agent funcional (não mind clone), permitir
145
- if is_functional_agent(agent_id):
146
- sys.exit(0)
147
-
148
- # Block 3b — fail-closed para edição de arquivo existente:
149
- # se o arquivo NÃO carrega o marker BEGIN PERSONA NOTICE, bloqueia.
150
- # (Antes era fail-open em arquivos existentes — todos os 22 personas
151
- # foram grandfathered em 2025 sem disclaimer. Decisão 1c do clinical
152
- # audit dim-7 exige disclaimer obrigatório agora.)
153
- if file_already_exists(file_path):
154
- try:
155
- with open(file_path, "r", encoding="utf-8") as fh:
156
- existing = fh.read()
157
- if "<!-- BEGIN PERSONA NOTICE" in existing:
158
- sys.exit(0)
159
- # Edição de mind clone existente sem o disclaimer.
160
- print(
161
- f"\nMIND CLONE GOVERNANCE: arquivo {agent_id}.md é uma persona simulada "
162
- "mas não carrega o marker '<!-- BEGIN PERSONA NOTICE -->'. "
163
- "Rode 'node scripts/apply-persona-disclaimer.js' antes de editar.",
164
- file=sys.stderr,
165
- )
166
- sys.exit(2)
167
- except Exception:
168
- # Fail-open em erros de leitura — preserva princípio "hook não derruba dev".
169
- sys.exit(0)
170
-
171
- # Verificar se existe DNA extraído
172
- has_dna, dna_path = has_dna_extracted(project_root, pack_name, agent_id)
173
-
174
- if has_dna:
175
- sys.exit(0)
176
-
177
- # BLOQUEAR: Tentando criar mind clone sem DNA
178
- error_message = f"""
179
- ╔══════════════════════════════════════════════════════════════════════════════╗
180
- ║ 🧬 MIND CLONE GOVERNANCE: DNA não encontrado ║
181
- ╠══════════════════════════════════════════════════════════════════════════════╣
182
- ║ ║
183
- ║ Agent: {agent_id:<60} ║
184
- ║ Pack: {pack_name:<60} ║
185
- ║ ║
186
- ║ PROBLEMA: Este parece ser um MIND CLONE (baseado em pessoa real), ║
187
- ║ mas não foi encontrado DNA extraído. ║
188
- ║ ║
189
- ║ Mind clones DEVEM passar pelo pipeline de extração: ║
190
- ║ 1. *collect-sources → Coletar fontes (livros, entrevistas, artigos) ║
191
- ║ 2. *extract-voice-dna → Extrair padrões linguísticos ║
192
- ║ 3. *extract-thinking-dna → Extrair frameworks e heurísticas ║
193
- ║ 4. *create-agent → Criar agent a partir do DNA ║
194
- ║ ║
195
- ║ LOCAIS VERIFICADOS: ║
196
- ║ • squads/{pack_name}/data/minds/{agent_id}_dna.yaml
197
- ║ • squads/{pack_name}/data/minds/{agent_id}_dna.md
198
- ║ • outputs/minds/{agent_id}/
199
- ║ ║
200
- ║ SOLUÇÕES: ║
201
- ║ 1. Execute o pipeline de clone: /squad-creator → *collect-sources ║
202
- ║ 2. OU se é agent FUNCIONAL, renomeie com sufixo: ║
203
- ║ -chief, -orchestrator, -validator, -architect, etc. ║
204
- ║ ║
205
- ╚══════════════════════════════════════════════════════════════════════════════╝
206
- """
207
- print(error_message, file=sys.stderr)
208
- sys.exit(2)
209
-
210
- if __name__ == "__main__":
211
- main()
212
-
1
+ #!/usr/bin/env python3
2
+ """
3
+ Hook: Mind Clone Governance
4
+
5
+ REGRA: Agents baseados em pessoas reais (mind clones) DEVEM passar pelo
6
+ pipeline de extração de DNA antes de serem criados.
7
+
8
+ Este hook intercepta Write/Edit em squads/*/agents/*.md e verifica:
9
+ 1. Se é um mind clone (baseado em pessoa real)
10
+ 2. Se existe DNA extraído correspondente
11
+
12
+ NÃO BLOQUEIA:
13
+ - Orchestrators (nome contém 'chief', 'orchestrator', 'chair')
14
+ - Tool agents (nome contém 'validator', 'calculator', 'generator')
15
+ - Process agents (nome contém 'architect', 'mapper', 'designer')
16
+ - Edição de arquivo existente (apenas criação é bloqueada)
17
+
18
+ Exit Codes:
19
+ - 0: Permitido
20
+ - 2: Bloqueado (mind clone sem DNA)
21
+ """
22
+
23
+ import json
24
+ import sys
25
+ import os
26
+ import re
27
+ from pathlib import Path
28
+
29
+ # =============================================================================
30
+ # CONFIGURAÇÃO
31
+ # =============================================================================
32
+
33
+ # Padrões que indicam que NÃO é um mind clone (agents funcionais)
34
+ FUNCTIONAL_AGENT_PATTERNS = [
35
+ # Orchestrators
36
+ r'.*-chief$',
37
+ r'.*-orchestrator$',
38
+ r'.*-chair$',
39
+ r'^orchestrator$',
40
+
41
+ # Tool agents
42
+ r'.*-validator$',
43
+ r'.*-calculator$',
44
+ r'.*-generator$',
45
+ r'.*-extractor$',
46
+ r'.*-analyzer$',
47
+
48
+ # Process agents
49
+ r'.*-architect$',
50
+ r'.*-mapper$',
51
+ r'.*-designer$',
52
+ r'.*-engineer$',
53
+
54
+ # Generic functional
55
+ r'^tools?-.*',
56
+ r'^process-.*',
57
+ r'^workflow-.*',
58
+ ]
59
+
60
+ # Locais onde DNA pode estar
61
+ DNA_LOCATIONS = [
62
+ "squads/{pack}/data/minds/{agent_id}_dna.yaml",
63
+ "squads/{pack}/data/minds/{agent_id}_dna.md",
64
+ "squads/{pack}/data/{agent_id}-dna.yaml",
65
+ "outputs/minds/{agent_id}/",
66
+ ]
67
+
68
+ # =============================================================================
69
+ # LÓGICA DO HOOK
70
+ # =============================================================================
71
+
72
+ def get_project_root():
73
+ """Obtém o root do projeto via variável de ambiente ou cwd."""
74
+ return os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd())
75
+
76
+ def extract_agent_info(file_path: str) -> tuple:
77
+ """Extrai pack_name e agent_id do path."""
78
+ # squads/{pack}/agents/{agent_id}.md
79
+ match = re.match(r'.*/squads/([^/]+)/agents/([^/]+)\.md$', file_path)
80
+ if match:
81
+ return match.group(1), match.group(2)
82
+ return None, None
83
+
84
+ def is_functional_agent(agent_id: str) -> bool:
85
+ """Verifica se o agent é funcional (não é mind clone)."""
86
+ for pattern in FUNCTIONAL_AGENT_PATTERNS:
87
+ if re.match(pattern, agent_id, re.IGNORECASE):
88
+ return True
89
+ return False
90
+
91
+ def has_dna_extracted(project_root: str, pack_name: str, agent_id: str) -> tuple:
92
+ """Verifica se existe DNA extraído para o agent."""
93
+ for location_template in DNA_LOCATIONS:
94
+ location = location_template.format(pack=pack_name, agent_id=agent_id)
95
+ full_path = os.path.join(project_root, location)
96
+
97
+ # Se é diretório, verificar se existe
98
+ if location.endswith('/'):
99
+ if os.path.isdir(full_path):
100
+ return True, full_path
101
+ # Se é arquivo, verificar se existe
102
+ elif os.path.isfile(full_path):
103
+ return True, full_path
104
+
105
+ return False, None
106
+
107
+ def file_already_exists(file_path: str) -> bool:
108
+ """Verifica se o arquivo já existe (edit vs create)."""
109
+ return os.path.isfile(file_path)
110
+
111
+ def main():
112
+ # Ler input do stdin
113
+ try:
114
+ input_data = json.load(sys.stdin)
115
+ except json.JSONDecodeError:
116
+ # Se não conseguir parsear, permitir (fail-open)
117
+ sys.exit(0)
118
+
119
+ tool_name = input_data.get("tool_name", "")
120
+ tool_input = input_data.get("tool_input", {})
121
+
122
+ # Só processar Write e Edit
123
+ if tool_name not in ["Write", "Edit"]:
124
+ sys.exit(0)
125
+
126
+ file_path = tool_input.get("file_path", "")
127
+ if not file_path:
128
+ sys.exit(0)
129
+
130
+ # Só processar arquivos em squads/*/agents/
131
+ if "/squads/" not in file_path or "/agents/" not in file_path:
132
+ sys.exit(0)
133
+
134
+ if not file_path.endswith(".md"):
135
+ sys.exit(0)
136
+
137
+ project_root = get_project_root()
138
+
139
+ # Extrair informações do path
140
+ pack_name, agent_id = extract_agent_info(file_path)
141
+ if not pack_name or not agent_id:
142
+ sys.exit(0)
143
+
144
+ # Se é agent funcional (não mind clone), permitir
145
+ if is_functional_agent(agent_id):
146
+ sys.exit(0)
147
+
148
+ # Block 3b — fail-closed para edição de arquivo existente:
149
+ # se o arquivo NÃO carrega o marker BEGIN PERSONA NOTICE, bloqueia.
150
+ # (Antes era fail-open em arquivos existentes — todos os 22 personas
151
+ # foram grandfathered em 2025 sem disclaimer. Decisão 1c do clinical
152
+ # audit dim-7 exige disclaimer obrigatório agora.)
153
+ if file_already_exists(file_path):
154
+ try:
155
+ with open(file_path, "r", encoding="utf-8") as fh:
156
+ existing = fh.read()
157
+ if "<!-- BEGIN PERSONA NOTICE" in existing:
158
+ sys.exit(0)
159
+ # Edição de mind clone existente sem o disclaimer.
160
+ print(
161
+ f"\nMIND CLONE GOVERNANCE: arquivo {agent_id}.md é uma persona simulada "
162
+ "mas não carrega o marker '<!-- BEGIN PERSONA NOTICE -->'. "
163
+ "Rode 'node scripts/apply-persona-disclaimer.js' antes de editar.",
164
+ file=sys.stderr,
165
+ )
166
+ sys.exit(2)
167
+ except Exception:
168
+ # Fail-open em erros de leitura — preserva princípio "hook não derruba dev".
169
+ sys.exit(0)
170
+
171
+ # Verificar se existe DNA extraído
172
+ has_dna, dna_path = has_dna_extracted(project_root, pack_name, agent_id)
173
+
174
+ if has_dna:
175
+ sys.exit(0)
176
+
177
+ # BLOQUEAR: Tentando criar mind clone sem DNA
178
+ error_message = f"""
179
+ ╔══════════════════════════════════════════════════════════════════════════════╗
180
+ ║ 🧬 MIND CLONE GOVERNANCE: DNA não encontrado ║
181
+ ╠══════════════════════════════════════════════════════════════════════════════╣
182
+ ║ ║
183
+ ║ Agent: {agent_id:<60} ║
184
+ ║ Pack: {pack_name:<60} ║
185
+ ║ ║
186
+ ║ PROBLEMA: Este parece ser um MIND CLONE (baseado em pessoa real), ║
187
+ ║ mas não foi encontrado DNA extraído. ║
188
+ ║ ║
189
+ ║ Mind clones DEVEM passar pelo pipeline de extração: ║
190
+ ║ 1. *collect-sources → Coletar fontes (livros, entrevistas, artigos) ║
191
+ ║ 2. *extract-voice-dna → Extrair padrões linguísticos ║
192
+ ║ 3. *extract-thinking-dna → Extrair frameworks e heurísticas ║
193
+ ║ 4. *create-agent → Criar agent a partir do DNA ║
194
+ ║ ║
195
+ ║ LOCAIS VERIFICADOS: ║
196
+ ║ • squads/{pack_name}/data/minds/{agent_id}_dna.yaml
197
+ ║ • squads/{pack_name}/data/minds/{agent_id}_dna.md
198
+ ║ • outputs/minds/{agent_id}/
199
+ ║ ║
200
+ ║ SOLUÇÕES: ║
201
+ ║ 1. Execute o pipeline de clone: /squad-creator → *collect-sources ║
202
+ ║ 2. OU se é agent FUNCIONAL, renomeie com sufixo: ║
203
+ ║ -chief, -orchestrator, -validator, -architect, etc. ║
204
+ ║ ║
205
+ ╚══════════════════════════════════════════════════════════════════════════════╝
206
+ """
207
+ print(error_message, file=sys.stderr)
208
+ sys.exit(2)
209
+
210
+ if __name__ == "__main__":
211
+ main()
212
+