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,643 +0,0 @@
1
- const fs = require('fs').promises;
2
- const path = require('path');
3
- const chalk = require('chalk');
4
- const inquirer = require('inquirer');
5
-
6
- /**
7
- * Approval workflow for SINAPSE-FULLSTACK framework
8
- * Manages approval process for high-impact modifications
9
- */
10
- class ApprovalWorkflow {
11
- constructor(options = {}) {
12
- this.rootPath = options.rootPath || process.cwd();
13
- this.approvalThresholds = {
14
- low: { auto_approve: true, requires_review: false },
15
- medium: { auto_approve: false, requires_review: true },
16
- high: { auto_approve: false, requires_review: true, requires_approval: true },
17
- critical: { auto_approve: false, requires_review: true, requires_approval: true, requires_multiple_approvers: true }
18
- };
19
- this.approvalHistory = [];
20
- this.pendingApprovals = new Map();
21
- this.approvalRules = new Map();
22
- this.initializeApprovalRules();
23
- }
24
-
25
- /**
26
- * Initialize default approval rules
27
- */
28
- initializeApprovalRules() {
29
- // Component type rules
30
- this.approvalRules.set('agent_modification', {
31
- risk_threshold: 'medium',
32
- required_approvers: 1,
33
- timeout_hours: 24,
34
- auto_approve_conditions: ['low_risk', 'has_tests', 'non_breaking']
35
- });
36
-
37
- this.approvalRules.set('workflow_modification', {
38
- risk_threshold: 'medium',
39
- required_approvers: 1,
40
- timeout_hours: 48,
41
- auto_approve_conditions: ['low_risk', 'has_tests']
42
- });
43
-
44
- this.approvalRules.set('core_util_modification', {
45
- risk_threshold: 'low',
46
- required_approvers: 2,
47
- timeout_hours: 72,
48
- auto_approve_conditions: ['minimal_risk', 'comprehensive_tests']
49
- });
50
-
51
- // Modification type rules
52
- this.approvalRules.set('component_removal', {
53
- risk_threshold: 'low',
54
- required_approvers: 2,
55
- timeout_hours: 168, // 1 week
56
- auto_approve_conditions: [] // Never auto-approve removals
57
- });
58
-
59
- this.approvalRules.set('breaking_change', {
60
- risk_threshold: 'low',
61
- required_approvers: 2,
62
- timeout_hours: 96,
63
- auto_approve_conditions: []
64
- });
65
- }
66
-
67
- /**
68
- * Process approval request for impact report
69
- */
70
- async processApprovalRequest(impactReport, options = {}) {
71
- const requestId = `approval-${Date.now()}`;
72
-
73
- try {
74
- console.log(chalk.blue(`🔍 Processing approval request for: ${impactReport.targetComponent.path}`));
75
-
76
- const _config = {
77
- skip_approval: options.skip_approval || false,
78
- auto_approve_low_risk: options.auto_approve_low_risk !== false,
79
- timeout_hours: options.timeout_hours || 24,
80
- required_approvers: options.required_approvers,
81
- ...options
82
- };
83
-
84
- // Determine approval requirements
85
- const approvalRequirements = await this.determineApprovalRequirements(impactReport, config);
86
-
87
- // Check if modification can be auto-approved
88
- const autoApprovalResult = await this.checkAutoApproval(impactReport, approvalRequirements);
89
-
90
- if (autoApprovalResult.can_auto_approve) {
91
- const approvalResult = await this.executeAutoApproval(impactReport, autoApprovalResult, requestId);
92
- return approvalResult;
93
- }
94
-
95
- // Manual approval required
96
- const approvalResult = await this.executeManualApproval(
97
- impactReport,
98
- approvalRequirements,
99
- config,
100
- requestId
101
- );
102
-
103
- return approvalResult;
104
-
105
- } catch (_error) {
106
- console.error(chalk.red(`Approval process failed: ${error.message}`));
107
- throw error;
108
- }
109
- }
110
-
111
- /**
112
- * Determine approval requirements based on impact analysis
113
- */
114
- async determineApprovalRequirements(impactReport, config) {
115
- const requirements = {
116
- approval_needed: false,
117
- risk_level: impactReport.riskAssessment.overallRisk,
118
- risk_score: impactReport.riskAssessment.riskScore,
119
- required_approvers: 1,
120
- timeout_hours: 24,
121
- review_criteria: [],
122
- blocking_issues: []
123
- };
124
-
125
- const riskLevel = impactReport.riskAssessment.overallRisk;
126
- const thresholds = this.approvalThresholds[riskLevel];
127
-
128
- // Basic approval requirements from risk level
129
- if (thresholds) {
130
- requirements.approval_needed = !thresholds.auto_approve;
131
- requirements.requires_review = thresholds.requires_review;
132
- requirements.requires_approval = thresholds.requires_approval;
133
- requirements.requires_multiple_approvers = thresholds.requires_multiple_approvers;
134
- }
135
-
136
- // Component-specific rules
137
- const componentRule = this.getComponentApprovalRule(impactReport.targetComponent);
138
- if (componentRule) {
139
- requirements.required_approvers = Math.max(requirements.required_approvers, componentRule.required_approvers);
140
- requirements.timeout_hours = Math.max(requirements.timeout_hours, componentRule.timeout_hours);
141
- }
142
-
143
- // Modification-specific rules
144
- const modificationRule = this.getModificationApprovalRule(impactReport.modificationType);
145
- if (modificationRule) {
146
- requirements.required_approvers = Math.max(requirements.required_approvers, modificationRule.required_approvers);
147
- requirements.timeout_hours = Math.max(requirements.timeout_hours, modificationRule.timeout_hours);
148
- }
149
-
150
- // Critical issues that block auto-approval
151
- if (impactReport.riskAssessment.criticalIssues.length > 0) {
152
- requirements.approval_needed = true;
153
- requirements.blocking_issues = impactReport.riskAssessment.criticalIssues.map(issue => issue.description);
154
- }
155
-
156
- // High-impact propagation
157
- if (impactReport.propagationAnalysis.criticalPaths?.length > 2) {
158
- requirements.approval_needed = true;
159
- requirements.review_criteria.push('Multiple critical propagation paths require review');
160
- }
161
-
162
- // Many affected components
163
- if (impactReport.summary.affectedComponents > 20) {
164
- requirements.approval_needed = true;
165
- requirements.review_criteria.push('Large number of affected components requires careful review');
166
- }
167
-
168
- // Breaking changes
169
- const hasBreakingChanges = impactReport.propagationAnalysis.directEffects?.some(
170
- effect => effect.changeType?.severity === 'breaking'
171
- ) || false;
172
-
173
- if (hasBreakingChanges) {
174
- requirements.approval_needed = true;
175
- requirements.required_approvers = Math.max(requirements.required_approvers, 2);
176
- requirements.review_criteria.push('Breaking changes require multiple approvers');
177
- }
178
-
179
- // Security-sensitive modifications
180
- if (impactReport.riskAssessment.riskDimensions?.security_risk?.score >= 6) {
181
- requirements.approval_needed = true;
182
- requirements.review_criteria.push('Security-sensitive modification requires approval');
183
- }
184
-
185
- return requirements;
186
- }
187
-
188
- /**
189
- * Check if modification can be auto-approved
190
- */
191
- async checkAutoApproval(impactReport, requirements) {
192
- const result = {
193
- can_auto_approve: false,
194
- reasons: [],
195
- conditions_met: [],
196
- conditions_failed: []
197
- };
198
-
199
- // Never auto-approve if manual approval is explicitly needed
200
- if (requirements.approval_needed) {
201
- result.reasons.push('Manual approval explicitly required due to risk level or critical issues');
202
- return result;
203
- }
204
-
205
- // Never auto-approve critical risk modifications
206
- if (impactReport.riskAssessment.overallRisk === 'critical') {
207
- result.reasons.push('Critical risk level requires manual approval');
208
- return result;
209
- }
210
-
211
- // Never auto-approve component removals
212
- if (impactReport.modificationType === 'remove') {
213
- result.reasons.push('Component removal always requires manual approval');
214
- return result;
215
- }
216
-
217
- // Check auto-approval conditions
218
- const autoApprovalConditions = await this.evaluateAutoApprovalConditions(impactReport);
219
-
220
- if (autoApprovalConditions.all_conditions_met) {
221
- result.can_auto_approve = true;
222
- result.conditions_met = autoApprovalConditions.met_conditions;
223
- result.reasons.push('All auto-approval conditions satisfied');
224
- } else {
225
- result.conditions_failed = autoApprovalConditions.failed_conditions;
226
- result.reasons.push('Auto-approval conditions not met');
227
- }
228
-
229
- return result;
230
- }
231
-
232
- /**
233
- * Evaluate auto-approval conditions
234
- */
235
- async evaluateAutoApprovalConditions(impactReport) {
236
- const conditions = {
237
- low_risk: impactReport.riskAssessment.overallRisk === 'low',
238
- minimal_impact: impactReport.summary.affectedComponents <= 5,
239
- no_critical_issues: impactReport.riskAssessment.criticalIssues.length === 0,
240
- no_breaking_changes: !this.hasBreakingChanges(impactReport),
241
- has_tests: await this.componentHasTests(impactReport.targetComponent),
242
- small_change: this.isSmallChange(impactReport),
243
- no_security_risk: impactReport.riskAssessment.riskDimensions?.security_risk?.score < 5
244
- };
245
-
246
- const metConditions = Object.entries(conditions)
247
- .filter(([condition, met]) => met)
248
- .map(([condition]) => condition);
249
-
250
- const failedConditions = Object.entries(conditions)
251
- .filter(([condition, met]) => !met)
252
- .map(([condition]) => condition);
253
-
254
- // Require at least 5 out of 7 conditions for auto-approval
255
- const requiredConditions = 5;
256
- const allConditionsMet = metConditions.length >= requiredConditions;
257
-
258
- return {
259
- all_conditions_met: allConditionsMet,
260
- met_conditions: metConditions,
261
- failed_conditions: failedConditions,
262
- condition_score: `${metConditions.length}/${Object.keys(conditions).length}`
263
- };
264
- }
265
-
266
- /**
267
- * Execute auto-approval
268
- */
269
- async executeAutoApproval(impactReport, autoApprovalResult, requestId) {
270
- const approval = {
271
- request_id: requestId,
272
- target_component: impactReport.targetComponent.path,
273
- modification_type: impactReport.modificationType,
274
- approval_status: 'auto_approved',
275
- approval_type: 'automatic',
276
- risk_level: impactReport.riskAssessment.overallRisk,
277
- auto_approval_reasons: autoApprovalResult.reasons,
278
- conditions_met: autoApprovalResult.conditions_met,
279
- approved_by: 'system_auto_approval',
280
- approved_at: new Date().toISOString(),
281
- valid_until: this.calculateExpirationTime(24), // Auto-approvals valid for 24 hours
282
- metadata: {
283
- impact_summary: impactReport.summary,
284
- approval_confidence: this.calculateApprovalConfidence(autoApprovalResult)
285
- }
286
- };
287
-
288
- // Log approval
289
- await this.logApproval(approval);
290
-
291
- console.log(chalk.green(`✅ Auto-approved: ${impactReport.targetComponent.path}`));
292
- console.log(chalk.gray(` Risk level: ${impactReport.riskAssessment.overallRisk}`));
293
- console.log(chalk.gray(` Conditions met: ${autoApprovalResult.conditions_met.length}`));
294
-
295
- return approval;
296
- }
297
-
298
- /**
299
- * Execute manual approval process
300
- */
301
- async executeManualApproval(impactReport, requirements, config, requestId) {
302
- console.log(chalk.yellow(`\n⚠️ MANUAL APPROVAL REQUIRED`));
303
- console.log(chalk.gray(`Component: ${impactReport.targetComponent.path}`));
304
- console.log(chalk.gray(`Risk Level: ${impactReport.riskAssessment.overallRisk.toUpperCase()}`));
305
- console.log(chalk.gray(`Affected Components: ${impactReport.summary.affectedComponents}`));
306
-
307
- if (requirements.blocking_issues.length > 0) {
308
- console.log(chalk.red(`\nBlocking Issues:`));
309
- requirements.blocking_issues.forEach((issue, index) => {
310
- console.log(chalk.red(` ${index + 1}. ${issue}`));
311
- });
312
- }
313
-
314
- if (requirements.review_criteria.length > 0) {
315
- console.log(chalk.yellow(`\nReview Criteria:`));
316
- requirements.review_criteria.forEach((criteria, index) => {
317
- console.log(chalk.yellow(` ${index + 1}. ${criteria}`));
318
- });
319
- }
320
-
321
- // Display key recommendations
322
- if (impactReport.riskAssessment.recommendations.length > 0) {
323
- console.log(chalk.blue(`\nKey Recommendations:`));
324
- impactReport.riskAssessment.recommendations.slice(0, 3).forEach((rec, index) => {
325
- console.log(chalk.blue(` ${index + 1}. ${rec.title}`));
326
- console.log(chalk.gray(` ${rec.description}`));
327
- });
328
- }
329
-
330
- // Approval prompt
331
- const approvalQuestions = await this.buildApprovalQuestions(impactReport, requirements);
332
- const approvalAnswers = await inquirer.prompt(approvalQuestions);
333
-
334
- const approval = {
335
- request_id: requestId,
336
- target_component: impactReport.targetComponent.path,
337
- modification_type: impactReport.modificationType,
338
- approval_status: approvalAnswers.approved ? 'approved' : 'rejected',
339
- approval_type: 'manual',
340
- risk_level: impactReport.riskAssessment.overallRisk,
341
- approved_by: approvalAnswers.approver_name || 'user',
342
- approved_at: new Date().toISOString(),
343
- approval_reason: approvalAnswers.approval_reason,
344
- conditions_acknowledged: approvalAnswers.conditions_acknowledged || false,
345
- valid_until: this.calculateExpirationTime(requirements.timeout_hours),
346
- requirements_met: requirements,
347
- metadata: {
348
- impact_summary: impactReport.summary,
349
- approval_answers: approvalAnswers
350
- }
351
- };
352
-
353
- // Add approval conditions if approved
354
- if (approvalAnswers.approved) {
355
- approval.approval_conditions = approvalAnswers.approval_conditions;
356
- approval.monitoring_required = approvalAnswers.monitoring_required || false;
357
- approval.rollback_plan_required = approvalAnswers.rollback_plan || false;
358
- } else {
359
- approval.rejection_reason = approvalAnswers.rejection_reason;
360
- approval.recommended_actions = approvalAnswers.recommended_actions;
361
- }
362
-
363
- // Log approval decision
364
- await this.logApproval(approval);
365
-
366
- if (approvalAnswers.approved) {
367
- console.log(chalk.green(`\n✅ Manual approval granted`));
368
- console.log(chalk.gray(` Approved by: ${approval.approved_by}`));
369
- console.log(chalk.gray(` Valid until: ${new Date(approval.valid_until).toLocaleString()}`));
370
-
371
- if (approval.approval_conditions) {
372
- console.log(chalk.blue(` Conditions: ${approval.approval_conditions}`));
373
- }
374
- } else {
375
- console.log(chalk.red(`\n❌ Approval rejected`));
376
- console.log(chalk.gray(` Reason: ${approval.rejection_reason}`));
377
- }
378
-
379
- return approval;
380
- }
381
-
382
- /**
383
- * Build approval question flow
384
- */
385
- async buildApprovalQuestions(impactReport, requirements) {
386
- const questions = [];
387
-
388
- // Main approval question
389
- questions.push({
390
- type: 'confirm',
391
- name: 'approved',
392
- message: `Approve ${impactReport.modificationType} of ${impactReport.targetComponent.path}?`,
393
- default: false
394
- });
395
-
396
- // Conditional questions based on approval
397
- questions.push({
398
- type: 'input',
399
- name: 'approver_name',
400
- message: 'Enter your name/identifier:',
401
- when: (answers) => answers.approved,
402
- validate: (input) => input.length > 0 || 'Name is required'
403
- });
404
-
405
- questions.push({
406
- type: 'input',
407
- name: 'approval_reason',
408
- message: 'Reason for approval:',
409
- when: (answers) => answers.approved,
410
- default: 'Impact analysis reviewed and acceptable'
411
- });
412
-
413
- // High-risk additional questions
414
- if (requirements.risk_level === 'high' || requirements.risk_level === 'critical') {
415
- questions.push({
416
- type: 'confirm',
417
- name: 'conditions_acknowledged',
418
- message: 'Do you acknowledge all risk factors and recommendations?',
419
- when: (answers) => answers.approved,
420
- default: false
421
- });
422
-
423
- questions.push({
424
- type: 'input',
425
- name: 'approval_conditions',
426
- message: 'Enter any approval conditions or requirements:',
427
- when: (answers) => answers.approved && answers.conditions_acknowledged,
428
- default: 'Standard monitoring and rollback procedures apply'
429
- });
430
-
431
- questions.push({
432
- type: 'confirm',
433
- name: 'monitoring_required',
434
- message: 'Require enhanced monitoring after deployment?',
435
- when: (answers) => answers.approved,
436
- default: true
437
- });
438
-
439
- questions.push({
440
- type: 'confirm',
441
- name: 'rollback_plan',
442
- message: 'Require documented rollback plan?',
443
- when: (answers) => answers.approved,
444
- default: true
445
- });
446
- }
447
-
448
- // Rejection questions
449
- questions.push({
450
- type: 'input',
451
- name: 'rejection_reason',
452
- message: 'Reason for rejection:',
453
- when: (answers) => !answers.approved,
454
- validate: (input) => input.length > 0 || 'Rejection reason is required'
455
- });
456
-
457
- questions.push({
458
- type: 'input',
459
- name: 'recommended_actions',
460
- message: 'Recommended actions before resubmission:',
461
- when: (answers) => !answers.approved,
462
- default: 'Address critical issues and reduce risk factors'
463
- });
464
-
465
- return questions;
466
- }
467
-
468
- /**
469
- * Log approval decision for audit trail
470
- */
471
- async logApproval(approval) {
472
- // Add to approval history
473
- this.approvalHistory.push({
474
- request_id: approval.request_id,
475
- component: approval.target_component,
476
- status: approval.approval_status,
477
- risk_level: approval.risk_level,
478
- approved_by: approval.approved_by,
479
- timestamp: approval.approved_at
480
- });
481
-
482
- // Write to audit log file
483
- try {
484
- const logDir = path.join(this.rootPath, '.sinapse', 'audit');
485
- await fs.mkdir(logDir, { recursive: true });
486
-
487
- const logFile = path.join(logDir, 'approval_log.jsonl');
488
- const logEntry = JSON.stringify(approval) + '\n';
489
-
490
- await fs.appendFile(logFile, logEntry);
491
-
492
- console.log(chalk.gray(` Approval logged to audit trail`));
493
-
494
- } catch (_error) {
495
- console.warn(chalk.yellow(`Failed to write approval log: ${error.message}`));
496
- }
497
- }
498
-
499
- // Helper methods
500
-
501
- getComponentApprovalRule(component) {
502
- if (component.type === 'agent') {
503
- return this.approvalRules.get('agent_modification');
504
- } else if (component.type === 'workflow') {
505
- return this.approvalRules.get('workflow_modification');
506
- } else if (component.type === 'util' && component.path.includes('core')) {
507
- return this.approvalRules.get('core_util_modification');
508
- }
509
- return null;
510
- }
511
-
512
- getModificationApprovalRule(modificationType) {
513
- if (modificationType === 'remove') {
514
- return this.approvalRules.get('component_removal');
515
- }
516
- return null;
517
- }
518
-
519
- hasBreakingChanges(impactReport) {
520
- return impactReport.propagationAnalysis.directEffects?.some(
521
- effect => effect.changeType?.severity === 'breaking'
522
- ) || false;
523
- }
524
-
525
- async componentHasTests(component) {
526
- const testPaths = [
527
- path.join(this.rootPath, 'tests', 'unit', component.type, `${component.name}.test.js`),
528
- path.join(this.rootPath, 'tests', 'integration', component.type, `${component.name}.integration.test.js`),
529
- path.join(this.rootPath, 'test', `${component.name}.test.js`)
530
- ];
531
-
532
- for (const testPath of testPaths) {
533
- try {
534
- await fs.access(testPath);
535
- return true;
536
- } catch (_error) {
537
- // File doesn't exist, continue
538
- }
539
- }
540
-
541
- return false;
542
- }
543
-
544
- isSmallChange(impactReport) {
545
- return impactReport.summary.affectedComponents <= 3 &&
546
- impactReport.summary.propagationDepth <= 2;
547
- }
548
-
549
- calculateExpirationTime(hours) {
550
- const now = new Date();
551
- now.setHours(now.getHours() + hours);
552
- return now.toISOString();
553
- }
554
-
555
- calculateApprovalConfidence(autoApprovalResult) {
556
- const conditionsMet = autoApprovalResult.conditions_met.length;
557
- const totalConditions = 7; // Based on evaluateAutoApprovalConditions
558
- return Math.round((conditionsMet / totalConditions) * 100);
559
- }
560
-
561
- /**
562
- * Check if approval is still valid
563
- */
564
- isApprovalValid(approval) {
565
- const now = new Date();
566
- const validUntil = new Date(approval.valid_until);
567
- return now < validUntil;
568
- }
569
-
570
- /**
571
- * Get approval history
572
- */
573
- getApprovalHistory(options = {}) {
574
- const history = {
575
- total_approvals: this.approvalHistory.length,
576
- approval_stats: this.calculateApprovalStats(),
577
- recent_approvals: this.approvalHistory.slice(-10)
578
- };
579
-
580
- if (options.component) {
581
- history.component_approvals = this.approvalHistory.filter(
582
- approval => approval.component === options.component
583
- );
584
- }
585
-
586
- if (options.risk_level) {
587
- history.risk_level_approvals = this.approvalHistory.filter(
588
- approval => approval.risk_level === options.risk_level
589
- );
590
- }
591
-
592
- return history;
593
- }
594
-
595
- calculateApprovalStats() {
596
- const stats = {
597
- approved: 0,
598
- rejected: 0,
599
- auto_approved: 0,
600
- by_risk_level: { low: 0, medium: 0, high: 0, critical: 0 }
601
- };
602
-
603
- this.approvalHistory.forEach(approval => {
604
- if (approval.status === 'approved') stats.approved++;
605
- else if (approval.status === 'rejected') stats.rejected++;
606
- else if (approval.status === 'auto_approved') stats.auto_approved++;
607
-
608
- stats.by_risk_level[approval.risk_level]++;
609
- });
610
-
611
- return stats;
612
- }
613
-
614
- /**
615
- * Get pending approvals
616
- */
617
- getPendingApprovals() {
618
- return Array.from(this.pendingApprovals.values());
619
- }
620
-
621
- /**
622
- * Clear expired approvals
623
- */
624
- clearExpiredApprovals() {
625
- const now = new Date();
626
- let clearedCount = 0;
627
-
628
- for (const [requestId, approval] of this.pendingApprovals) {
629
- if (new Date(approval.valid_until) < now) {
630
- this.pendingApprovals.delete(requestId);
631
- clearedCount++;
632
- }
633
- }
634
-
635
- if (clearedCount > 0) {
636
- console.log(chalk.gray(`Cleared ${clearedCount} expired approvals`));
637
- }
638
-
639
- return clearedCount;
640
- }
641
- }
642
-
643
- module.exports = ApprovalWorkflow;