sinapse-ai 1.12.2 → 1.14.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 (244) hide show
  1. package/.claude/CLAUDE.md +2 -2
  2. package/.claude/rules/agent-memory-imports.md +4 -0
  3. package/.sinapse-ai/cli/commands/pro/index.js +8 -48
  4. package/.sinapse-ai/constitution.md +6 -2
  5. package/.sinapse-ai/data/entity-registry.yaml +63 -429
  6. package/.sinapse-ai/development/agents/analyst/MEMORY.md +19 -0
  7. package/.sinapse-ai/development/agents/architect/MEMORY.md +52 -0
  8. package/.sinapse-ai/development/agents/data-engineer/MEMORY.md +55 -0
  9. package/.sinapse-ai/development/agents/developer/MEMORY.md +53 -0
  10. package/.sinapse-ai/development/agents/devops/MEMORY.md +56 -0
  11. package/.sinapse-ai/development/agents/product-lead/MEMORY.md +53 -0
  12. package/.sinapse-ai/development/agents/project-lead/MEMORY.md +53 -0
  13. package/.sinapse-ai/development/agents/quality-gate/MEMORY.md +52 -0
  14. package/.sinapse-ai/development/agents/snps-orqx.md +15 -0
  15. package/.sinapse-ai/development/agents/sprint-lead/MEMORY.md +53 -0
  16. package/.sinapse-ai/development/agents/squad-creator.md +15 -0
  17. package/.sinapse-ai/development/agents/ux/MEMORY.md +21 -0
  18. package/.sinapse-ai/development/templates/chrome-brain/knowledge-base/chrome-brain.md +2 -2
  19. package/.sinapse-ai/infrastructure/scripts/ide-sync/index.js +15 -0
  20. package/.sinapse-ai/infrastructure/scripts/validate-agents.js +159 -8
  21. package/.sinapse-ai/install-manifest.yaml +16 -152
  22. package/AGENTS.md +13 -2
  23. package/CHANGELOG.md +135 -3
  24. package/README.en.md +1 -1
  25. package/README.md +6 -26
  26. package/bin/cli.js +2 -7
  27. package/bin/commands/install.js +19 -257
  28. package/bin/commands/update.js +18 -78
  29. package/bin/lib/command-generator.js +261 -0
  30. package/bin/lib/prompts.js +2 -65
  31. package/bin/modules/chrome-brain-installer.js +2 -1
  32. package/bin/postinstall.js +6 -6
  33. package/docs/getting-started.md +0 -1
  34. package/docs/pt/getting-started.md +1 -1
  35. package/docs/security/dependabot-triage.md +17 -17
  36. package/package.json +6 -3
  37. package/packages/installer/src/wizard/i18n.js +3 -204
  38. package/packages/installer/src/wizard/index.js +1 -1
  39. package/packages/installer/src/wizard/questions.js +5 -368
  40. package/packages/installer/src/wizard/wizard.js +0 -9
  41. package/scripts/generate-install-manifest.js +6 -0
  42. package/scripts/validate-changelog-tags.js +97 -0
  43. package/scripts/validate-no-personal-leaks.js +184 -28
  44. package/scripts/validate-schemas.js +55 -10
  45. package/scripts/validate-story-meta.js +25 -12
  46. package/squads/claude-code-mastery/agents/claude-mastery-chief.md +15 -1
  47. package/squads/claude-code-mastery/agents/config-engineer.md +15 -0
  48. package/squads/claude-code-mastery/agents/hooks-architect.md +27 -20
  49. package/squads/claude-code-mastery/agents/mcp-integrator.md +15 -0
  50. package/squads/claude-code-mastery/agents/project-integrator.md +15 -0
  51. package/squads/claude-code-mastery/agents/roadmap-sentinel.md +15 -0
  52. package/squads/claude-code-mastery/agents/skill-craftsman.md +15 -0
  53. package/squads/claude-code-mastery/agents/swarm-orqx.md +15 -0
  54. package/squads/claude-code-mastery/tasks/audit-setup.md +1 -1
  55. package/squads/squad-animations/agents/animation-interpreter.md +15 -0
  56. package/squads/squad-animations/agents/animation-performance-engineer.md +15 -0
  57. package/squads/squad-animations/agents/animations-orqx.md +13 -0
  58. package/squads/squad-animations/agents/css-motion-artist.md +15 -0
  59. package/squads/squad-animations/agents/generative-particle-engineer.md +15 -0
  60. package/squads/squad-animations/agents/motion-choreographer.md +15 -0
  61. package/squads/squad-animations/agents/scroll-narrative-engineer.md +15 -0
  62. package/squads/squad-animations/agents/shader-artist.md +15 -0
  63. package/squads/squad-animations/agents/threejs-architect.md +15 -0
  64. package/squads/squad-brand/agents/brand-archetype-strategist.md +13 -0
  65. package/squads/squad-brand/agents/brand-auditor.md +15 -0
  66. package/squads/squad-brand/agents/brand-collateral-designer.md +15 -0
  67. package/squads/squad-brand/agents/brand-compiler.md +13 -0
  68. package/squads/squad-brand/agents/brand-creative-engineer.md +15 -0
  69. package/squads/squad-brand/agents/brand-culture-architect.md +15 -0
  70. package/squads/squad-brand/agents/brand-growth-strategist.md +15 -0
  71. package/squads/squad-brand/agents/brand-identity-designer.md +15 -0
  72. package/squads/squad-brand/agents/brand-motion-vfx.md +15 -0
  73. package/squads/squad-brand/agents/brand-naming-specialist.md +15 -0
  74. package/squads/squad-brand/agents/brand-orqx.md +13 -0
  75. package/squads/squad-brand/agents/brand-positioning-strategist.md +15 -0
  76. package/squads/squad-brand/agents/brand-sonic-designer.md +15 -0
  77. package/squads/squad-brand/agents/brand-strategist.md +15 -0
  78. package/squads/squad-brand/agents/brand-system-architect.md +15 -0
  79. package/squads/squad-cloning/agents/agent-forger.md +15 -0
  80. package/squads/squad-cloning/agents/cloning-orqx.md +15 -0
  81. package/squads/squad-cloning/agents/cognitive-extractor.md +15 -0
  82. package/squads/squad-cloning/agents/content-capturer.md +15 -0
  83. package/squads/squad-cloning/agents/kb-architect.md +15 -0
  84. package/squads/squad-cloning/agents/mind-synthesizer.md +15 -0
  85. package/squads/squad-cloning/agents/sop-extractor.md +15 -0
  86. package/squads/squad-cloning/agents/source-hunter.md +13 -0
  87. package/squads/squad-cloning/agents/squad-assembler.md +15 -0
  88. package/squads/squad-commercial/agents/commercial-orqx.md +13 -0
  89. package/squads/squad-commercial/agents/cs-business-auditor.md +15 -0
  90. package/squads/squad-commercial/agents/cs-client-success.md +15 -0
  91. package/squads/squad-commercial/agents/cs-crm-specialist.md +15 -0
  92. package/squads/squad-commercial/agents/cs-funnel-architect.md +15 -0
  93. package/squads/squad-commercial/agents/cs-lead-generation-strategist.md +15 -0
  94. package/squads/squad-commercial/agents/cs-offer-designer.md +15 -0
  95. package/squads/squad-commercial/agents/cs-revops-analyst.md +15 -0
  96. package/squads/squad-commercial/agents/cs-sales-closer.md +13 -0
  97. package/squads/squad-commercial/agents/cs-sales-enablement.md +15 -0
  98. package/squads/squad-content/agents/content-analyst.md +13 -0
  99. package/squads/squad-content/agents/content-engineer.md +15 -0
  100. package/squads/squad-content/agents/content-governor.md +13 -0
  101. package/squads/squad-content/agents/content-orqx.md +13 -0
  102. package/squads/squad-content/agents/editorial-strategist.md +15 -0
  103. package/squads/squad-content/agents/platform-specialist.md +15 -0
  104. package/squads/squad-content/agents/signal-intelligence.md +13 -0
  105. package/squads/squad-copy/agents/ad-copywriter.md +13 -0
  106. package/squads/squad-copy/agents/brand-voice-writer.md +15 -0
  107. package/squads/squad-copy/agents/conversion-writer.md +13 -0
  108. package/squads/squad-copy/agents/copy-editor.md +15 -0
  109. package/squads/squad-copy/agents/copy-orqx.md +13 -0
  110. package/squads/squad-copy/agents/copy-strategist.md +15 -0
  111. package/squads/squad-copy/agents/direct-response-writer.md +15 -0
  112. package/squads/squad-copy/agents/email-sequence-strategist.md +15 -0
  113. package/squads/squad-copy/agents/funnel-copywriter.md +15 -0
  114. package/squads/squad-copy/agents/headline-specialist.md +13 -0
  115. package/squads/squad-copy/agents/long-form-writer.md +15 -0
  116. package/squads/squad-copy/agents/persuasion-psychologist.md +15 -0
  117. package/squads/squad-copy/agents/proof-architect.md +15 -0
  118. package/squads/squad-council/agents/brene-brown.md +13 -0
  119. package/squads/squad-council/agents/charlie-munger.md +13 -0
  120. package/squads/squad-council/agents/council-orqx.md +13 -0
  121. package/squads/squad-council/agents/derek-sivers.md +13 -0
  122. package/squads/squad-council/agents/naval-ravikant.md +13 -0
  123. package/squads/squad-council/agents/patrick-lencioni.md +15 -0
  124. package/squads/squad-council/agents/peter-thiel.md +13 -0
  125. package/squads/squad-council/agents/ray-dalio.md +13 -0
  126. package/squads/squad-council/agents/reid-hoffman.md +13 -0
  127. package/squads/squad-council/agents/simon-sinek.md +15 -0
  128. package/squads/squad-council/agents/yvon-chouinard.md +13 -0
  129. package/squads/squad-courses/agents/assessment-creator.md +15 -0
  130. package/squads/squad-courses/agents/content-writer.md +15 -0
  131. package/squads/squad-courses/agents/courses-orqx.md +15 -0
  132. package/squads/squad-courses/agents/curriculum-designer.md +15 -0
  133. package/squads/squad-courses/agents/launch-strategist.md +15 -0
  134. package/squads/squad-courses/agents/lesson-architect.md +15 -0
  135. package/squads/squad-courses/agents/production-director.md +13 -0
  136. package/squads/squad-courses/agents/slide-designer.md +15 -0
  137. package/squads/squad-cybersecurity/agents/cloud-security-engineer.md +15 -0
  138. package/squads/squad-cybersecurity/agents/compliance-officer.md +15 -0
  139. package/squads/squad-cybersecurity/agents/cyber-orqx.md +15 -0
  140. package/squads/squad-cybersecurity/agents/incident-responder.md +15 -0
  141. package/squads/squad-cybersecurity/agents/network-security-engineer.md +15 -0
  142. package/squads/squad-cybersecurity/agents/penetration-tester.md +15 -0
  143. package/squads/squad-cybersecurity/agents/soc-analyst.md +15 -0
  144. package/squads/squad-cybersecurity/agents/threat-analyst.md +15 -0
  145. package/squads/squad-design/agents/cro-persuasion.md +15 -0
  146. package/squads/squad-design/agents/design-orqx.md +13 -0
  147. package/squads/squad-design/agents/design-system.md +15 -0
  148. package/squads/squad-design/agents/dx-accessibility-specialist.md +15 -0
  149. package/squads/squad-design/agents/dx-design-system-architect.md +15 -0
  150. package/squads/squad-design/agents/dx-frontend-engineer.md +15 -0
  151. package/squads/squad-design/agents/dx-interaction-designer.md +15 -0
  152. package/squads/squad-design/agents/dx-performance-engineer.md +15 -0
  153. package/squads/squad-design/agents/dx-ui-designer.md +15 -0
  154. package/squads/squad-design/agents/dx-ux-strategist.md +15 -0
  155. package/squads/squad-design/agents/platform-aesthetic-director.md +15 -0
  156. package/squads/squad-design/agents/premium-packaging-strategist.md +15 -0
  157. package/squads/squad-design/agents/product-surface-director.md +15 -0
  158. package/squads/squad-design/agents/ux-designer.md +15 -0
  159. package/squads/squad-finance/agents/budget-controller.md +15 -0
  160. package/squads/squad-finance/agents/cost-optimizer.md +15 -0
  161. package/squads/squad-finance/agents/finance-orqx.md +15 -0
  162. package/squads/squad-finance/agents/fiscal-compliance-br.md +15 -0
  163. package/squads/squad-finance/agents/forecast-strategist.md +15 -0
  164. package/squads/squad-finance/agents/pricing-strategist.md +15 -0
  165. package/squads/squad-finance/agents/profitability-analyst.md +15 -0
  166. package/squads/squad-finance/agents/revenue-analyst.md +15 -0
  167. package/squads/squad-growth/agents/ga-analytics-engineer.md +15 -0
  168. package/squads/squad-growth/agents/ga-campaign-analyst.md +15 -0
  169. package/squads/squad-growth/agents/ga-cro-specialist.md +15 -0
  170. package/squads/squad-growth/agents/ga-data-analyst.md +13 -0
  171. package/squads/squad-growth/agents/ga-growth-hacker.md +15 -0
  172. package/squads/squad-growth/agents/ga-seo-strategist.md +15 -0
  173. package/squads/squad-growth/agents/growth-orqx.md +15 -0
  174. package/squads/squad-paidmedia/agents/campaign-analyst.md +15 -0
  175. package/squads/squad-paidmedia/agents/creative-strategist.md +15 -0
  176. package/squads/squad-paidmedia/agents/cro-specialist.md +15 -0
  177. package/squads/squad-paidmedia/agents/google-ads-specialist.md +15 -0
  178. package/squads/squad-paidmedia/agents/meta-ads-specialist.md +15 -0
  179. package/squads/squad-paidmedia/agents/paidmedia-orqx.md +15 -0
  180. package/squads/squad-paidmedia/agents/performance-engineer.md +15 -0
  181. package/squads/squad-paidmedia/agents/pm-creative-performance-analyst.md +15 -0
  182. package/squads/squad-paidmedia/agents/pm-youtube-ads-specialist.md +15 -0
  183. package/squads/squad-product/agents/product-orqx.md +13 -1
  184. package/squads/squad-product/agents/ps-client-product-manager.md +13 -1
  185. package/squads/squad-product/agents/ps-delivery-manager.md +13 -1
  186. package/squads/squad-product/agents/ps-discovery-lead.md +15 -1
  187. package/squads/squad-product/agents/ps-product-analyst.md +15 -1
  188. package/squads/squad-product/agents/ps-product-ops-specialist.md +15 -1
  189. package/squads/squad-product/agents/ps-product-strategist.md +15 -1
  190. package/squads/squad-research/agents/audience-intelligence.md +15 -0
  191. package/squads/squad-research/agents/competitive-intelligence.md +15 -0
  192. package/squads/squad-research/agents/data-synthesizer.md +15 -0
  193. package/squads/squad-research/agents/deep-researcher.md +15 -0
  194. package/squads/squad-research/agents/market-analyst.md +15 -0
  195. package/squads/squad-research/agents/research-orqx.md +15 -0
  196. package/squads/squad-research/agents/trend-forecaster.md +15 -0
  197. package/squads/squad-storytelling/agents/blake-snyder.md +13 -0
  198. package/squads/squad-storytelling/agents/dan-harmon.md +13 -0
  199. package/squads/squad-storytelling/agents/joseph-campbell.md +13 -0
  200. package/squads/squad-storytelling/agents/keith-johnstone.md +13 -0
  201. package/squads/squad-storytelling/agents/kindra-hall.md +15 -0
  202. package/squads/squad-storytelling/agents/marshall-ganz.md +15 -0
  203. package/squads/squad-storytelling/agents/nancy-duarte.md +15 -0
  204. package/squads/squad-storytelling/agents/oren-klaff.md +15 -0
  205. package/squads/squad-storytelling/agents/park-howell.md +13 -0
  206. package/squads/squad-storytelling/agents/storytelling-orqx.md +13 -0
  207. package/.sinapse-ai/core/grounding/README.md +0 -83
  208. package/.sinapse-ai/core/grounding/brand.cjs +0 -29
  209. package/.sinapse-ai/core/grounding/config-loader.cjs +0 -52
  210. package/.sinapse-ai/core/grounding/design-system.cjs +0 -29
  211. package/.sinapse-ai/core/grounding/vault.cjs +0 -36
  212. package/.sinapse-ai/development/scripts/approval-workflow.js +0 -643
  213. package/.sinapse-ai/development/scripts/backup-manager.js +0 -607
  214. package/.sinapse-ai/development/scripts/branch-manager.js +0 -390
  215. package/.sinapse-ai/development/scripts/code-quality-improver.js +0 -1329
  216. package/.sinapse-ai/development/scripts/commit-message-generator.js +0 -850
  217. package/.sinapse-ai/development/scripts/conflict-resolver.js +0 -675
  218. package/.sinapse-ai/development/scripts/dependency-analyzer.js +0 -638
  219. package/.sinapse-ai/development/scripts/diff-generator.js +0 -352
  220. package/.sinapse-ai/development/scripts/git-wrapper.js +0 -462
  221. package/.sinapse-ai/development/scripts/modification-validator.js +0 -555
  222. package/.sinapse-ai/development/scripts/performance-analyzer.js +0 -758
  223. package/.sinapse-ai/development/scripts/refactoring-suggester.js +0 -1148
  224. package/.sinapse-ai/development/scripts/rollback-handler.js +0 -531
  225. package/.sinapse-ai/development/scripts/security-checker.js +0 -359
  226. package/.sinapse-ai/development/scripts/template-engine.js +0 -240
  227. package/.sinapse-ai/development/scripts/template-validator.js +0 -279
  228. package/.sinapse-ai/development/scripts/test-generator.js +0 -844
  229. package/.sinapse-ai/development/scripts/transaction-manager.js +0 -590
  230. package/.sinapse-ai/development/scripts/yaml-validator.js +0 -397
  231. package/.sinapse-ai/hooks/sinapse-brand-grounding.cjs +0 -162
  232. package/.sinapse-ai/hooks/sinapse-ds-grounding.cjs +0 -211
  233. package/.sinapse-ai/hooks/sinapse-vault-grounding.cjs +0 -194
  234. package/bin/lib/register-grounding-hooks.js +0 -145
  235. package/docs/guides/agents/traces/execution-traces.zip +0 -0
  236. package/docs/guides/grounding-setup.md +0 -154
  237. package/docs/guides/workflows/SINAPSE-WORKFLOWS.zip +0 -0
  238. package/packages/installer/src/pro/pro-scaffolder.js +0 -449
  239. package/packages/installer/src/wizard/grounding-config.js +0 -131
  240. package/packages/installer/src/wizard/pro-setup.js +0 -1439
  241. package/packages/installer/templates/README.md +0 -16
  242. package/packages/installer/templates/brand-routing.example.json +0 -12
  243. package/packages/installer/templates/ds-routing.example.json +0 -12
  244. package/packages/installer/templates/vault-routing.example.json +0 -12
@@ -1,397 +0,0 @@
1
- /**
2
- * YAML Validator for SINAPSE Developer Meta-Agent
3
- * Ensures YAML files maintain proper structure and syntax
4
- */
5
-
6
- const yaml = require('js-yaml');
7
- const fs = require('fs-extra');
8
-
9
- class YAMLValidator {
10
- constructor() {
11
- this.validationRules = {
12
- agent: {
13
- required: ['agent', 'persona', 'commands'],
14
- optional: ['dependencies', 'security', 'customization'],
15
- structure: {
16
- agent: {
17
- required: ['name', 'id', 'title', 'icon', 'whenToUse'],
18
- optional: ['customization']
19
- },
20
- persona: {
21
- required: ['role', 'style', 'identity', 'focus'],
22
- optional: []
23
- }
24
- }
25
- },
26
- manifest: {
27
- required: ['bundle', 'agents'],
28
- optional: ['workflows'],
29
- structure: {
30
- bundle: {
31
- required: ['name', 'icon', 'description'],
32
- optional: []
33
- }
34
- }
35
- },
36
- workflow: {
37
- required: ['workflow', 'stages'],
38
- optional: ['transitions', 'resources', 'validation'],
39
- structure: {
40
- workflow: {
41
- required: ['id', 'name', 'description', 'type', 'scope'],
42
- optional: []
43
- }
44
- }
45
- }
46
- };
47
- }
48
-
49
- /**
50
- * Validate YAML content
51
- */
52
- async validate(content, type = 'general') {
53
- const results = {
54
- valid: true,
55
- errors: [],
56
- warnings: [],
57
- parsed: null
58
- };
59
-
60
- try {
61
- // Parse YAML
62
- results.parsed = yaml.load(content, {
63
- schema: yaml.SAFE_SCHEMA,
64
- onWarning: (warning) => {
65
- results.warnings.push({
66
- type: 'yaml_warning',
67
- message: warning.toString()
68
- });
69
- }
70
- });
71
-
72
- // Type-specific validation
73
- if (type !== 'general' && this.validationRules[type]) {
74
- this.validateStructure(results.parsed, type, results);
75
- }
76
-
77
- // General validations
78
- this.validateGeneral(results.parsed, results);
79
-
80
- } catch (error) {
81
- results.valid = false;
82
- results.errors.push({
83
- type: 'parse_error',
84
- message: error.message,
85
- line: error.mark ? error.mark.line : null,
86
- column: error.mark ? error.mark.column : null
87
- });
88
- }
89
-
90
- return results;
91
- }
92
-
93
- /**
94
- * Validate YAML file
95
- */
96
- async validateFile(filePath, type = 'general') {
97
- try {
98
- const content = await fs.readFile(filePath, 'utf8');
99
- const results = await this.validate(content, type);
100
- results.filePath = filePath;
101
- return results;
102
- } catch (error) {
103
- return {
104
- valid: false,
105
- filePath,
106
- errors: [{
107
- type: 'file_error',
108
- message: `Could not read file: ${error.message}`
109
- }]
110
- };
111
- }
112
- }
113
-
114
- /**
115
- * Validate structure based on type
116
- */
117
- validateStructure(data, type, results) {
118
- const rules = this.validationRules[type];
119
-
120
- // Check required top-level fields
121
- for (const field of rules.required) {
122
- if (!data.hasOwnProperty(field)) {
123
- results.valid = false;
124
- results.errors.push({
125
- type: 'missing_required',
126
- field,
127
- message: `Missing required field: ${field}`
128
- });
129
- }
130
- }
131
-
132
- // Check structure of specific fields
133
- if (rules.structure) {
134
- for (const [field, fieldRules] of Object.entries(rules.structure)) {
135
- if (data[field]) {
136
- this.validateFieldStructure(
137
- data[field],
138
- field,
139
- fieldRules,
140
- results
141
- );
142
- }
143
- }
144
- }
145
-
146
- // Warn about unknown fields
147
- const allKnownFields = [
148
- ...(rules.required || []),
149
- ...(rules.optional || [])
150
- ];
151
-
152
- for (const field of Object.keys(data)) {
153
- if (!allKnownFields.includes(field)) {
154
- results.warnings.push({
155
- type: 'unknown_field',
156
- field,
157
- message: `Unknown field: ${field}`
158
- });
159
- }
160
- }
161
- }
162
-
163
- /**
164
- * Validate field structure
165
- */
166
- validateFieldStructure(data, fieldName, rules, results) {
167
- // Check required subfields
168
- for (const subfield of rules.required || []) {
169
- if (!data.hasOwnProperty(subfield)) {
170
- results.valid = false;
171
- results.errors.push({
172
- type: 'missing_required',
173
- field: `${fieldName}.${subfield}`,
174
- message: `Missing required field: ${fieldName}.${subfield}`
175
- });
176
- }
177
- }
178
-
179
- // Check field types
180
- this.validateFieldTypes(data, fieldName, results);
181
- }
182
-
183
- /**
184
- * Validate field types
185
- */
186
- validateFieldTypes(data, fieldName, results) {
187
- for (const [key, value] of Object.entries(data)) {
188
- const fullPath = `${fieldName}.${key}`;
189
-
190
- // Check for null/undefined
191
- if (value === null || value === undefined) {
192
- results.warnings.push({
193
- type: 'null_value',
194
- field: fullPath,
195
- message: `Null or undefined value at ${fullPath}`
196
- });
197
- }
198
-
199
- // Type-specific checks
200
- if (key === 'id' || key === 'name') {
201
- if (typeof value !== 'string' || value.trim() === '') {
202
- results.errors.push({
203
- type: 'invalid_type',
204
- field: fullPath,
205
- message: `${fullPath} must be a non-empty string`
206
- });
207
- }
208
- }
209
-
210
- if (key === 'icon' && typeof value === 'string') {
211
- // Check if it's a valid emoji or icon string
212
- if (value.length === 0) {
213
- results.warnings.push({
214
- type: 'empty_icon',
215
- field: fullPath,
216
- message: 'Icon field is empty'
217
- });
218
- }
219
- }
220
- }
221
- }
222
-
223
- /**
224
- * General validations for all YAML
225
- */
226
- validateGeneral(data, results) {
227
- // Check for circular references
228
- try {
229
- JSON.stringify(data);
230
- } catch (error) {
231
- if (error.message.includes('circular')) {
232
- results.valid = false;
233
- results.errors.push({
234
- type: 'circular_reference',
235
- message: 'Circular reference detected in YAML structure'
236
- });
237
- }
238
- }
239
-
240
- // Check for excessively deep nesting
241
- const maxDepth = this.getMaxDepth(data);
242
- if (maxDepth > 10) {
243
- results.warnings.push({
244
- type: 'deep_nesting',
245
- depth: maxDepth,
246
- message: `Deep nesting detected (${maxDepth} levels)`
247
- });
248
- }
249
- }
250
-
251
- /**
252
- * Get maximum depth of object
253
- */
254
- getMaxDepth(obj, currentDepth = 0) {
255
- if (typeof obj !== 'object' || obj === null) {
256
- return currentDepth;
257
- }
258
-
259
- let maxDepth = currentDepth;
260
- for (const value of Object.values(obj)) {
261
- if (typeof value === 'object') {
262
- const depth = this.getMaxDepth(value, currentDepth + 1);
263
- maxDepth = Math.max(maxDepth, depth);
264
- }
265
- }
266
-
267
- return maxDepth;
268
- }
269
-
270
- /**
271
- * Fix common YAML issues
272
- */
273
- async autoFix(content, type = 'general') {
274
- let fixed = content;
275
-
276
- // Fix common indentation issues
277
- fixed = this.fixIndentation(fixed);
278
-
279
- // Fix quote issues
280
- fixed = this.fixQuotes(fixed);
281
-
282
- // Validate the fixed content
283
- const validation = await this.validate(fixed, type);
284
-
285
- return {
286
- content: fixed,
287
- validation,
288
- changed: content !== fixed
289
- };
290
- }
291
-
292
- /**
293
- * Fix indentation issues
294
- * @param {string} content - YAML content to fix
295
- * @returns {string} Fixed YAML content
296
- */
297
- fixIndentation(content) {
298
- const lines = content.split('\n');
299
- const fixedLines = [];
300
- const indentStack = [0];
301
- let currentLevel = 0;
302
-
303
- for (let i = 0; i < lines.length; i++) {
304
- const line = lines[i];
305
- const trimmed = line.trim();
306
-
307
- // Skip empty lines and comments
308
- if (!trimmed || trimmed.startsWith('#')) {
309
- fixedLines.push(line);
310
- continue;
311
- }
312
-
313
- // Handle list items
314
- if (trimmed.startsWith('-')) {
315
- const baseIndent = indentStack[indentStack.length - 1];
316
- fixedLines.push(' '.repeat(baseIndent) + trimmed);
317
-
318
- // If list item has a key-value pair, prepare for nested content
319
- if (trimmed.includes(':') && !trimmed.endsWith(':')) {
320
- const afterDash = trimmed.substring(1).trim();
321
- if (afterDash.includes(':')) {
322
- currentLevel = baseIndent + 2;
323
- }
324
- }
325
- }
326
- // Handle key-value pairs
327
- else if (trimmed.includes(':')) {
328
- // Find appropriate indent level
329
- const colonIndex = trimmed.indexOf(':');
330
- const _key = trimmed.substring(0, colonIndex);
331
-
332
- // Pop stack until we find the right level
333
- while (indentStack.length > 1 &&
334
- line.length - line.trimStart().length < indentStack[indentStack.length - 1]) {
335
- indentStack.pop();
336
- }
337
-
338
- currentLevel = indentStack[indentStack.length - 1];
339
- fixedLines.push(' '.repeat(currentLevel) + trimmed);
340
-
341
- // If this opens a new block, push new indent level
342
- if (trimmed.endsWith(':') || (i + 1 < lines.length && lines[i + 1].trim() &&
343
- lines[i + 1].length - lines[i + 1].trimStart().length > currentLevel)) {
344
- indentStack.push(currentLevel + 2);
345
- }
346
- } else {
347
- // Regular content line
348
- fixedLines.push(' '.repeat(currentLevel) + trimmed);
349
- }
350
- }
351
-
352
- return fixedLines.join('\n');
353
- }
354
-
355
- /**
356
- * Fix quote issues
357
- */
358
- fixQuotes(content) {
359
- // Fix unquoted strings that need quotes
360
- return content.replace(
361
- /^(\s*\w+):\s*([^"'\n]*[:{}\[\]|>&*!%@`][^"'\n]*)$/gm,
362
- '$1: "$2"'
363
- );
364
- }
365
-
366
- /**
367
- * Generate validation report
368
- */
369
- generateReport(validation) {
370
- const report = [];
371
-
372
- report.push(`YAML Validation Report`);
373
- report.push(`=====================`);
374
- report.push(`Valid: ${validation.valid ? '✅ Yes' : '❌ No'}`);
375
-
376
- if (validation.errors.length > 0) {
377
- report.push(`\nErrors (${validation.errors.length}):`);
378
- for (const error of validation.errors) {
379
- report.push(` - ${error.message}`);
380
- if (error.line) {
381
- report.push(` Line: ${error.line}, Column: ${error.column}`);
382
- }
383
- }
384
- }
385
-
386
- if (validation.warnings.length > 0) {
387
- report.push(`\nWarnings (${validation.warnings.length}):`);
388
- for (const warning of validation.warnings) {
389
- report.push(` - ${warning.message}`);
390
- }
391
- }
392
-
393
- return report.join('\n');
394
- }
395
- }
396
-
397
- module.exports = YAMLValidator;
@@ -1,162 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
4
- /**
5
- * SINAPSE Brand Grounding Hook — UserPromptSubmit (framework-shipped).
6
- *
7
- * @story GA-1.6
8
- *
9
- * Reads `~/.claude/sinapse-ai-config.yaml` `brand` section and, when enabled,
10
- * injects the first 2000 chars of the user's brandbook as `<brand-grounding>`
11
- * context.
12
- */
13
-
14
- const fs = require('fs');
15
- const os = require('os');
16
- const path = require('path');
17
-
18
- const HOOK_TIMEOUT_MS = 3500;
19
- const MAX_INJECTION_SIZE = 2000;
20
- const MAX_BRAND_PREVIEW = 2000;
21
- const MIN_PROMPT_CHARS = 10;
22
- const CONFIG_PATH = path.join(os.homedir(), '.claude', 'sinapse-ai-config.yaml');
23
-
24
- function readStdin() {
25
- return new Promise((resolve) => {
26
- let data = '';
27
- let settled = false;
28
- const finish = (val) => { if (!settled) { settled = true; resolve(val); } };
29
- try {
30
- process.stdin.setEncoding('utf8');
31
- process.stdin.on('error', () => finish(null));
32
- process.stdin.on('data', (chunk) => { data += chunk; });
33
- process.stdin.on('end', () => {
34
- try { finish(JSON.parse(data)); } catch { finish(null); }
35
- });
36
- } catch {
37
- finish(null);
38
- }
39
- });
40
- }
41
-
42
- // Story 10.47: delegate to the shared grounding config loader instead of
43
- // duplicating the read+parse. The require is guarded so the hook stays
44
- // fail-open even if the shared module is somehow absent at runtime.
45
- function loadConfig() {
46
- try {
47
- return require('../core/grounding/config-loader.cjs').loadGroundingConfig(CONFIG_PATH);
48
- } catch {
49
- return null;
50
- }
51
- }
52
-
53
- function getSection(cfg, name) {
54
- if (!cfg || !cfg.grounding) return null;
55
- const s = cfg.grounding[name];
56
- if (!s || typeof s !== 'object' || !s.enabled) return null;
57
- return s;
58
- }
59
-
60
- function readBrandbook(brandbookPath) {
61
- try {
62
- if (!brandbookPath || !fs.existsSync(brandbookPath)) return null;
63
- const stat = fs.statSync(brandbookPath);
64
- let target = brandbookPath;
65
- if (stat.isDirectory()) {
66
- const candidates = ['brandbook.md', 'README.md', 'guidelines.md', 'brand.md'];
67
- target = null;
68
- for (const c of candidates) {
69
- const full = path.join(brandbookPath, c);
70
- if (fs.existsSync(full)) { target = full; break; }
71
- }
72
- if (!target) {
73
- const mds = fs.readdirSync(brandbookPath).filter((f) => f.endsWith('.md'));
74
- if (mds.length > 0) target = path.join(brandbookPath, mds[0]);
75
- }
76
- if (!target) return null;
77
- }
78
- let content = fs.readFileSync(target, 'utf8');
79
- if (content.length > MAX_BRAND_PREVIEW) {
80
- content = content.substring(0, MAX_BRAND_PREVIEW) + '\n[...truncated...]';
81
- }
82
- return content;
83
- } catch {
84
- return null;
85
- }
86
- }
87
-
88
- function buildInjection(section, brandContent) {
89
- const profileName = section.profileName || 'Custom Brand';
90
- const parts = [];
91
- parts.push(`<brand-grounding name="${profileName}">`);
92
- parts.push(`Brand detectada: ${profileName}`);
93
- if (brandContent) {
94
- parts.push('--- BRANDBOOK (primeiros 2000 chars) ---');
95
- parts.push(brandContent);
96
- } else {
97
- parts.push('(brandbookPath nao encontrado ou vazio)');
98
- }
99
- parts.push('</brand-grounding>');
100
-
101
- let full = parts.join('\n');
102
- if (full.length > MAX_INJECTION_SIZE) {
103
- const trailer = '\n[...truncated...]\n</brand-grounding>';
104
- full = full.substring(0, MAX_INJECTION_SIZE - trailer.length) + trailer;
105
- }
106
- return full;
107
- }
108
-
109
- async function main() {
110
- const input = await readStdin();
111
- if (!input || typeof input !== 'object') return;
112
-
113
- const userPrompt = input.prompt || input.user_prompt || input.message || '';
114
- if (typeof userPrompt !== 'string' || userPrompt.trim().length < MIN_PROMPT_CHARS) return;
115
-
116
- // Anti-double-injection
117
- if (userPrompt.includes('<brand-grounding')) return;
118
-
119
- const cfg = loadConfig();
120
- const section = getSection(cfg, 'brand');
121
- if (!section || !section.brandbookPath) return;
122
-
123
- const brandContent = readBrandbook(section.brandbookPath);
124
- const context = buildInjection(section, brandContent);
125
-
126
- const output = JSON.stringify({
127
- hookSpecificOutput: {
128
- hookEventName: 'UserPromptSubmit',
129
- additionalContext: context,
130
- },
131
- });
132
-
133
- await new Promise((resolve) => {
134
- let settled = false;
135
- const finish = () => { if (!settled) { settled = true; resolve(); } };
136
- try {
137
- const flushed = process.stdout.write(output, () => finish());
138
- if (flushed) setImmediate(finish);
139
- } catch {
140
- finish();
141
- }
142
- });
143
- }
144
-
145
- function run() {
146
- const timer = setTimeout(() => process.exit(0), HOOK_TIMEOUT_MS);
147
- timer.unref();
148
- main()
149
- .then(() => { clearTimeout(timer); process.exitCode = 0; })
150
- .catch(() => { clearTimeout(timer); process.exitCode = 0; });
151
- }
152
-
153
- if (require.main === module) run();
154
-
155
- module.exports = {
156
- loadConfig,
157
- getSection,
158
- readBrandbook,
159
- buildInjection,
160
- CONFIG_PATH,
161
- MAX_INJECTION_SIZE,
162
- };