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.
- package/.claude/CLAUDE.md +2 -2
- package/.claude/rules/agent-memory-imports.md +4 -0
- package/.sinapse-ai/cli/commands/pro/index.js +8 -48
- package/.sinapse-ai/constitution.md +6 -2
- package/.sinapse-ai/data/entity-registry.yaml +63 -429
- package/.sinapse-ai/development/agents/analyst/MEMORY.md +19 -0
- package/.sinapse-ai/development/agents/architect/MEMORY.md +52 -0
- package/.sinapse-ai/development/agents/data-engineer/MEMORY.md +55 -0
- package/.sinapse-ai/development/agents/developer/MEMORY.md +53 -0
- package/.sinapse-ai/development/agents/devops/MEMORY.md +56 -0
- package/.sinapse-ai/development/agents/product-lead/MEMORY.md +53 -0
- package/.sinapse-ai/development/agents/project-lead/MEMORY.md +53 -0
- package/.sinapse-ai/development/agents/quality-gate/MEMORY.md +52 -0
- package/.sinapse-ai/development/agents/snps-orqx.md +15 -0
- package/.sinapse-ai/development/agents/sprint-lead/MEMORY.md +53 -0
- package/.sinapse-ai/development/agents/squad-creator.md +15 -0
- package/.sinapse-ai/development/agents/ux/MEMORY.md +21 -0
- package/.sinapse-ai/development/templates/chrome-brain/knowledge-base/chrome-brain.md +2 -2
- package/.sinapse-ai/infrastructure/scripts/ide-sync/index.js +15 -0
- package/.sinapse-ai/infrastructure/scripts/validate-agents.js +159 -8
- package/.sinapse-ai/install-manifest.yaml +16 -152
- package/AGENTS.md +13 -2
- package/CHANGELOG.md +135 -3
- package/README.en.md +1 -1
- package/README.md +6 -26
- package/bin/cli.js +2 -7
- package/bin/commands/install.js +19 -257
- package/bin/commands/update.js +18 -78
- package/bin/lib/command-generator.js +261 -0
- package/bin/lib/prompts.js +2 -65
- package/bin/modules/chrome-brain-installer.js +2 -1
- package/bin/postinstall.js +6 -6
- package/docs/getting-started.md +0 -1
- package/docs/pt/getting-started.md +1 -1
- package/docs/security/dependabot-triage.md +17 -17
- package/package.json +6 -3
- package/packages/installer/src/wizard/i18n.js +3 -204
- package/packages/installer/src/wizard/index.js +1 -1
- package/packages/installer/src/wizard/questions.js +5 -368
- package/packages/installer/src/wizard/wizard.js +0 -9
- package/scripts/generate-install-manifest.js +6 -0
- package/scripts/validate-changelog-tags.js +97 -0
- package/scripts/validate-no-personal-leaks.js +184 -28
- package/scripts/validate-schemas.js +55 -10
- package/scripts/validate-story-meta.js +25 -12
- package/squads/claude-code-mastery/agents/claude-mastery-chief.md +15 -1
- package/squads/claude-code-mastery/agents/config-engineer.md +15 -0
- package/squads/claude-code-mastery/agents/hooks-architect.md +27 -20
- package/squads/claude-code-mastery/agents/mcp-integrator.md +15 -0
- package/squads/claude-code-mastery/agents/project-integrator.md +15 -0
- package/squads/claude-code-mastery/agents/roadmap-sentinel.md +15 -0
- package/squads/claude-code-mastery/agents/skill-craftsman.md +15 -0
- package/squads/claude-code-mastery/agents/swarm-orqx.md +15 -0
- package/squads/claude-code-mastery/tasks/audit-setup.md +1 -1
- package/squads/squad-animations/agents/animation-interpreter.md +15 -0
- package/squads/squad-animations/agents/animation-performance-engineer.md +15 -0
- package/squads/squad-animations/agents/animations-orqx.md +13 -0
- package/squads/squad-animations/agents/css-motion-artist.md +15 -0
- package/squads/squad-animations/agents/generative-particle-engineer.md +15 -0
- package/squads/squad-animations/agents/motion-choreographer.md +15 -0
- package/squads/squad-animations/agents/scroll-narrative-engineer.md +15 -0
- package/squads/squad-animations/agents/shader-artist.md +15 -0
- package/squads/squad-animations/agents/threejs-architect.md +15 -0
- package/squads/squad-brand/agents/brand-archetype-strategist.md +13 -0
- package/squads/squad-brand/agents/brand-auditor.md +15 -0
- package/squads/squad-brand/agents/brand-collateral-designer.md +15 -0
- package/squads/squad-brand/agents/brand-compiler.md +13 -0
- package/squads/squad-brand/agents/brand-creative-engineer.md +15 -0
- package/squads/squad-brand/agents/brand-culture-architect.md +15 -0
- package/squads/squad-brand/agents/brand-growth-strategist.md +15 -0
- package/squads/squad-brand/agents/brand-identity-designer.md +15 -0
- package/squads/squad-brand/agents/brand-motion-vfx.md +15 -0
- package/squads/squad-brand/agents/brand-naming-specialist.md +15 -0
- package/squads/squad-brand/agents/brand-orqx.md +13 -0
- package/squads/squad-brand/agents/brand-positioning-strategist.md +15 -0
- package/squads/squad-brand/agents/brand-sonic-designer.md +15 -0
- package/squads/squad-brand/agents/brand-strategist.md +15 -0
- package/squads/squad-brand/agents/brand-system-architect.md +15 -0
- package/squads/squad-cloning/agents/agent-forger.md +15 -0
- package/squads/squad-cloning/agents/cloning-orqx.md +15 -0
- package/squads/squad-cloning/agents/cognitive-extractor.md +15 -0
- package/squads/squad-cloning/agents/content-capturer.md +15 -0
- package/squads/squad-cloning/agents/kb-architect.md +15 -0
- package/squads/squad-cloning/agents/mind-synthesizer.md +15 -0
- package/squads/squad-cloning/agents/sop-extractor.md +15 -0
- package/squads/squad-cloning/agents/source-hunter.md +13 -0
- package/squads/squad-cloning/agents/squad-assembler.md +15 -0
- package/squads/squad-commercial/agents/commercial-orqx.md +13 -0
- package/squads/squad-commercial/agents/cs-business-auditor.md +15 -0
- package/squads/squad-commercial/agents/cs-client-success.md +15 -0
- package/squads/squad-commercial/agents/cs-crm-specialist.md +15 -0
- package/squads/squad-commercial/agents/cs-funnel-architect.md +15 -0
- package/squads/squad-commercial/agents/cs-lead-generation-strategist.md +15 -0
- package/squads/squad-commercial/agents/cs-offer-designer.md +15 -0
- package/squads/squad-commercial/agents/cs-revops-analyst.md +15 -0
- package/squads/squad-commercial/agents/cs-sales-closer.md +13 -0
- package/squads/squad-commercial/agents/cs-sales-enablement.md +15 -0
- package/squads/squad-content/agents/content-analyst.md +13 -0
- package/squads/squad-content/agents/content-engineer.md +15 -0
- package/squads/squad-content/agents/content-governor.md +13 -0
- package/squads/squad-content/agents/content-orqx.md +13 -0
- package/squads/squad-content/agents/editorial-strategist.md +15 -0
- package/squads/squad-content/agents/platform-specialist.md +15 -0
- package/squads/squad-content/agents/signal-intelligence.md +13 -0
- package/squads/squad-copy/agents/ad-copywriter.md +13 -0
- package/squads/squad-copy/agents/brand-voice-writer.md +15 -0
- package/squads/squad-copy/agents/conversion-writer.md +13 -0
- package/squads/squad-copy/agents/copy-editor.md +15 -0
- package/squads/squad-copy/agents/copy-orqx.md +13 -0
- package/squads/squad-copy/agents/copy-strategist.md +15 -0
- package/squads/squad-copy/agents/direct-response-writer.md +15 -0
- package/squads/squad-copy/agents/email-sequence-strategist.md +15 -0
- package/squads/squad-copy/agents/funnel-copywriter.md +15 -0
- package/squads/squad-copy/agents/headline-specialist.md +13 -0
- package/squads/squad-copy/agents/long-form-writer.md +15 -0
- package/squads/squad-copy/agents/persuasion-psychologist.md +15 -0
- package/squads/squad-copy/agents/proof-architect.md +15 -0
- package/squads/squad-council/agents/brene-brown.md +13 -0
- package/squads/squad-council/agents/charlie-munger.md +13 -0
- package/squads/squad-council/agents/council-orqx.md +13 -0
- package/squads/squad-council/agents/derek-sivers.md +13 -0
- package/squads/squad-council/agents/naval-ravikant.md +13 -0
- package/squads/squad-council/agents/patrick-lencioni.md +15 -0
- package/squads/squad-council/agents/peter-thiel.md +13 -0
- package/squads/squad-council/agents/ray-dalio.md +13 -0
- package/squads/squad-council/agents/reid-hoffman.md +13 -0
- package/squads/squad-council/agents/simon-sinek.md +15 -0
- package/squads/squad-council/agents/yvon-chouinard.md +13 -0
- package/squads/squad-courses/agents/assessment-creator.md +15 -0
- package/squads/squad-courses/agents/content-writer.md +15 -0
- package/squads/squad-courses/agents/courses-orqx.md +15 -0
- package/squads/squad-courses/agents/curriculum-designer.md +15 -0
- package/squads/squad-courses/agents/launch-strategist.md +15 -0
- package/squads/squad-courses/agents/lesson-architect.md +15 -0
- package/squads/squad-courses/agents/production-director.md +13 -0
- package/squads/squad-courses/agents/slide-designer.md +15 -0
- package/squads/squad-cybersecurity/agents/cloud-security-engineer.md +15 -0
- package/squads/squad-cybersecurity/agents/compliance-officer.md +15 -0
- package/squads/squad-cybersecurity/agents/cyber-orqx.md +15 -0
- package/squads/squad-cybersecurity/agents/incident-responder.md +15 -0
- package/squads/squad-cybersecurity/agents/network-security-engineer.md +15 -0
- package/squads/squad-cybersecurity/agents/penetration-tester.md +15 -0
- package/squads/squad-cybersecurity/agents/soc-analyst.md +15 -0
- package/squads/squad-cybersecurity/agents/threat-analyst.md +15 -0
- package/squads/squad-design/agents/cro-persuasion.md +15 -0
- package/squads/squad-design/agents/design-orqx.md +13 -0
- package/squads/squad-design/agents/design-system.md +15 -0
- package/squads/squad-design/agents/dx-accessibility-specialist.md +15 -0
- package/squads/squad-design/agents/dx-design-system-architect.md +15 -0
- package/squads/squad-design/agents/dx-frontend-engineer.md +15 -0
- package/squads/squad-design/agents/dx-interaction-designer.md +15 -0
- package/squads/squad-design/agents/dx-performance-engineer.md +15 -0
- package/squads/squad-design/agents/dx-ui-designer.md +15 -0
- package/squads/squad-design/agents/dx-ux-strategist.md +15 -0
- package/squads/squad-design/agents/platform-aesthetic-director.md +15 -0
- package/squads/squad-design/agents/premium-packaging-strategist.md +15 -0
- package/squads/squad-design/agents/product-surface-director.md +15 -0
- package/squads/squad-design/agents/ux-designer.md +15 -0
- package/squads/squad-finance/agents/budget-controller.md +15 -0
- package/squads/squad-finance/agents/cost-optimizer.md +15 -0
- package/squads/squad-finance/agents/finance-orqx.md +15 -0
- package/squads/squad-finance/agents/fiscal-compliance-br.md +15 -0
- package/squads/squad-finance/agents/forecast-strategist.md +15 -0
- package/squads/squad-finance/agents/pricing-strategist.md +15 -0
- package/squads/squad-finance/agents/profitability-analyst.md +15 -0
- package/squads/squad-finance/agents/revenue-analyst.md +15 -0
- package/squads/squad-growth/agents/ga-analytics-engineer.md +15 -0
- package/squads/squad-growth/agents/ga-campaign-analyst.md +15 -0
- package/squads/squad-growth/agents/ga-cro-specialist.md +15 -0
- package/squads/squad-growth/agents/ga-data-analyst.md +13 -0
- package/squads/squad-growth/agents/ga-growth-hacker.md +15 -0
- package/squads/squad-growth/agents/ga-seo-strategist.md +15 -0
- package/squads/squad-growth/agents/growth-orqx.md +15 -0
- package/squads/squad-paidmedia/agents/campaign-analyst.md +15 -0
- package/squads/squad-paidmedia/agents/creative-strategist.md +15 -0
- package/squads/squad-paidmedia/agents/cro-specialist.md +15 -0
- package/squads/squad-paidmedia/agents/google-ads-specialist.md +15 -0
- package/squads/squad-paidmedia/agents/meta-ads-specialist.md +15 -0
- package/squads/squad-paidmedia/agents/paidmedia-orqx.md +15 -0
- package/squads/squad-paidmedia/agents/performance-engineer.md +15 -0
- package/squads/squad-paidmedia/agents/pm-creative-performance-analyst.md +15 -0
- package/squads/squad-paidmedia/agents/pm-youtube-ads-specialist.md +15 -0
- package/squads/squad-product/agents/product-orqx.md +13 -1
- package/squads/squad-product/agents/ps-client-product-manager.md +13 -1
- package/squads/squad-product/agents/ps-delivery-manager.md +13 -1
- package/squads/squad-product/agents/ps-discovery-lead.md +15 -1
- package/squads/squad-product/agents/ps-product-analyst.md +15 -1
- package/squads/squad-product/agents/ps-product-ops-specialist.md +15 -1
- package/squads/squad-product/agents/ps-product-strategist.md +15 -1
- package/squads/squad-research/agents/audience-intelligence.md +15 -0
- package/squads/squad-research/agents/competitive-intelligence.md +15 -0
- package/squads/squad-research/agents/data-synthesizer.md +15 -0
- package/squads/squad-research/agents/deep-researcher.md +15 -0
- package/squads/squad-research/agents/market-analyst.md +15 -0
- package/squads/squad-research/agents/research-orqx.md +15 -0
- package/squads/squad-research/agents/trend-forecaster.md +15 -0
- package/squads/squad-storytelling/agents/blake-snyder.md +13 -0
- package/squads/squad-storytelling/agents/dan-harmon.md +13 -0
- package/squads/squad-storytelling/agents/joseph-campbell.md +13 -0
- package/squads/squad-storytelling/agents/keith-johnstone.md +13 -0
- package/squads/squad-storytelling/agents/kindra-hall.md +15 -0
- package/squads/squad-storytelling/agents/marshall-ganz.md +15 -0
- package/squads/squad-storytelling/agents/nancy-duarte.md +15 -0
- package/squads/squad-storytelling/agents/oren-klaff.md +15 -0
- package/squads/squad-storytelling/agents/park-howell.md +13 -0
- package/squads/squad-storytelling/agents/storytelling-orqx.md +13 -0
- package/.sinapse-ai/core/grounding/README.md +0 -83
- package/.sinapse-ai/core/grounding/brand.cjs +0 -29
- package/.sinapse-ai/core/grounding/config-loader.cjs +0 -52
- package/.sinapse-ai/core/grounding/design-system.cjs +0 -29
- package/.sinapse-ai/core/grounding/vault.cjs +0 -36
- package/.sinapse-ai/development/scripts/approval-workflow.js +0 -643
- package/.sinapse-ai/development/scripts/backup-manager.js +0 -607
- package/.sinapse-ai/development/scripts/branch-manager.js +0 -390
- package/.sinapse-ai/development/scripts/code-quality-improver.js +0 -1329
- package/.sinapse-ai/development/scripts/commit-message-generator.js +0 -850
- package/.sinapse-ai/development/scripts/conflict-resolver.js +0 -675
- package/.sinapse-ai/development/scripts/dependency-analyzer.js +0 -638
- package/.sinapse-ai/development/scripts/diff-generator.js +0 -352
- package/.sinapse-ai/development/scripts/git-wrapper.js +0 -462
- package/.sinapse-ai/development/scripts/modification-validator.js +0 -555
- package/.sinapse-ai/development/scripts/performance-analyzer.js +0 -758
- package/.sinapse-ai/development/scripts/refactoring-suggester.js +0 -1148
- package/.sinapse-ai/development/scripts/rollback-handler.js +0 -531
- package/.sinapse-ai/development/scripts/security-checker.js +0 -359
- package/.sinapse-ai/development/scripts/template-engine.js +0 -240
- package/.sinapse-ai/development/scripts/template-validator.js +0 -279
- package/.sinapse-ai/development/scripts/test-generator.js +0 -844
- package/.sinapse-ai/development/scripts/transaction-manager.js +0 -590
- package/.sinapse-ai/development/scripts/yaml-validator.js +0 -397
- package/.sinapse-ai/hooks/sinapse-brand-grounding.cjs +0 -162
- package/.sinapse-ai/hooks/sinapse-ds-grounding.cjs +0 -211
- package/.sinapse-ai/hooks/sinapse-vault-grounding.cjs +0 -194
- package/bin/lib/register-grounding-hooks.js +0 -145
- package/docs/guides/agents/traces/execution-traces.zip +0 -0
- package/docs/guides/grounding-setup.md +0 -154
- package/docs/guides/workflows/SINAPSE-WORKFLOWS.zip +0 -0
- package/packages/installer/src/pro/pro-scaffolder.js +0 -449
- package/packages/installer/src/wizard/grounding-config.js +0 -131
- package/packages/installer/src/wizard/pro-setup.js +0 -1439
- package/packages/installer/templates/README.md +0 -16
- package/packages/installer/templates/brand-routing.example.json +0 -12
- package/packages/installer/templates/ds-routing.example.json +0 -12
- package/packages/installer/templates/vault-routing.example.json +0 -12
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Template Validator for SINAPSE-FULLSTACK
|
|
3
|
-
* Validates component templates for required structure and placeholders
|
|
4
|
-
* @module template-validator
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const fs = require('fs-extra');
|
|
8
|
-
const _path = require('path');
|
|
9
|
-
const _yaml = require('js-yaml');
|
|
10
|
-
const TemplateEngine = require('./template-engine');
|
|
11
|
-
|
|
12
|
-
class TemplateValidator {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.engine = new TemplateEngine();
|
|
15
|
-
this.requiredVariables = {
|
|
16
|
-
agent: [
|
|
17
|
-
'AGENT_NAME',
|
|
18
|
-
'AGENT_ID',
|
|
19
|
-
'AGENT_TITLE',
|
|
20
|
-
'AGENT_ICON',
|
|
21
|
-
'WHEN_TO_USE',
|
|
22
|
-
'PERSONA_ROLE',
|
|
23
|
-
'PERSONA_STYLE',
|
|
24
|
-
'PERSONA_IDENTITY',
|
|
25
|
-
'PERSONA_FOCUS'
|
|
26
|
-
],
|
|
27
|
-
task: [
|
|
28
|
-
'TASK_TITLE',
|
|
29
|
-
'TASK_ID',
|
|
30
|
-
'AGENT_NAME',
|
|
31
|
-
'VERSION',
|
|
32
|
-
'TASK_DESCRIPTION',
|
|
33
|
-
'OUTPUT_DESCRIPTION'
|
|
34
|
-
],
|
|
35
|
-
workflow: [
|
|
36
|
-
'WORKFLOW_ID',
|
|
37
|
-
'WORKFLOW_NAME',
|
|
38
|
-
'WORKFLOW_DESCRIPTION',
|
|
39
|
-
'WORKFLOW_VERSION',
|
|
40
|
-
'WORKFLOW_TYPE',
|
|
41
|
-
'AUTHOR',
|
|
42
|
-
'CREATED_DATE',
|
|
43
|
-
'LAST_MODIFIED'
|
|
44
|
-
]
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Validate a template file
|
|
50
|
-
* @param {string} templatePath - Path to template file
|
|
51
|
-
* @param {string} templateType - Type of template (agent, task, workflow)
|
|
52
|
-
* @returns {Promise<Object>} Validation result
|
|
53
|
-
*/
|
|
54
|
-
async validateTemplateFile(templatePath, templateType) {
|
|
55
|
-
try {
|
|
56
|
-
const template = await fs.readFile(templatePath, 'utf8');
|
|
57
|
-
return this.validateTemplate(template, templateType);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
return {
|
|
60
|
-
valid: false,
|
|
61
|
-
errors: [`Failed to read template file: ${error.message}`]
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Validate a template string
|
|
68
|
-
* @param {string} template - Template content
|
|
69
|
-
* @param {string} templateType - Type of template
|
|
70
|
-
* @returns {Object} Validation result
|
|
71
|
-
*/
|
|
72
|
-
validateTemplate(template, templateType) {
|
|
73
|
-
const errors = [];
|
|
74
|
-
const warnings = [];
|
|
75
|
-
|
|
76
|
-
// Check template type is valid
|
|
77
|
-
if (!this.requiredVariables[templateType]) {
|
|
78
|
-
return {
|
|
79
|
-
valid: false,
|
|
80
|
-
errors: [`Unknown template type: ${templateType}`]
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Validate required variables
|
|
85
|
-
const requiredVars = this.requiredVariables[templateType];
|
|
86
|
-
const validation = this.engine.validateTemplate(template, requiredVars);
|
|
87
|
-
|
|
88
|
-
if (!validation.valid) {
|
|
89
|
-
errors.push(`Missing required variables: ${validation.missing.join(', ')}`);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Check for balanced conditionals
|
|
93
|
-
const conditionalCheck = this.checkBalancedConditionals(template);
|
|
94
|
-
if (!conditionalCheck.valid) {
|
|
95
|
-
errors.push(...conditionalCheck.errors);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Check for balanced loops
|
|
99
|
-
const loopCheck = this.checkBalancedLoops(template);
|
|
100
|
-
if (!loopCheck.valid) {
|
|
101
|
-
errors.push(...loopCheck.errors);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Template-specific validation
|
|
105
|
-
const specificCheck = this.validateSpecificTemplate(template, templateType);
|
|
106
|
-
if (!specificCheck.valid) {
|
|
107
|
-
errors.push(...specificCheck.errors);
|
|
108
|
-
}
|
|
109
|
-
warnings.push(...specificCheck.warnings);
|
|
110
|
-
|
|
111
|
-
// Check for potential security issues
|
|
112
|
-
const securityCheck = this.checkSecurityIssues(template);
|
|
113
|
-
if (!securityCheck.valid) {
|
|
114
|
-
errors.push(...securityCheck.errors);
|
|
115
|
-
}
|
|
116
|
-
warnings.push(...securityCheck.warnings);
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
valid: errors.length === 0,
|
|
120
|
-
errors,
|
|
121
|
-
warnings,
|
|
122
|
-
variables: this.engine.getTemplateVariables(template)
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Check for balanced conditional blocks
|
|
128
|
-
* @private
|
|
129
|
-
*/
|
|
130
|
-
checkBalancedConditionals(template) {
|
|
131
|
-
const errors = [];
|
|
132
|
-
const openTags = template.match(/\{\{#IF_([^}]+)\}\}/g) || [];
|
|
133
|
-
const closeTags = template.match(/\{\{\/IF_([^}]+)\}\}/g) || [];
|
|
134
|
-
|
|
135
|
-
const openConditions = openTags.map(tag => tag.match(/IF_([^}]+)/)[1]);
|
|
136
|
-
const closeConditions = closeTags.map(tag => tag.match(/IF_([^}]+)/)[1]);
|
|
137
|
-
|
|
138
|
-
// Check each open has a close
|
|
139
|
-
for (const condition of openConditions) {
|
|
140
|
-
if (!closeConditions.includes(condition)) {
|
|
141
|
-
errors.push(`Unclosed conditional: {{#IF_${condition}}}`);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Check each close has an open
|
|
146
|
-
for (const condition of closeConditions) {
|
|
147
|
-
if (!openConditions.includes(condition)) {
|
|
148
|
-
errors.push(`Unexpected closing tag: {{/IF_${condition}}}`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return { valid: errors.length === 0, errors };
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Check for balanced loop blocks
|
|
157
|
-
* @private
|
|
158
|
-
*/
|
|
159
|
-
checkBalancedLoops(template) {
|
|
160
|
-
const errors = [];
|
|
161
|
-
const openTags = template.match(/\{\{#EACH_([^}]+)\}\}/g) || [];
|
|
162
|
-
const closeTags = template.match(/\{\{\/EACH_([^}]+)\}\}/g) || [];
|
|
163
|
-
|
|
164
|
-
const openLoops = openTags.map(tag => tag.match(/EACH_([^}]+)/)[1]);
|
|
165
|
-
const closeLoops = closeTags.map(tag => tag.match(/EACH_([^}]+)/)[1]);
|
|
166
|
-
|
|
167
|
-
// Check each open has a close
|
|
168
|
-
for (const loop of openLoops) {
|
|
169
|
-
if (!closeLoops.includes(loop)) {
|
|
170
|
-
errors.push(`Unclosed loop: {{#EACH_${loop}}}`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Check each close has an open
|
|
175
|
-
for (const loop of closeLoops) {
|
|
176
|
-
if (!openLoops.includes(loop)) {
|
|
177
|
-
errors.push(`Unexpected closing tag: {{/EACH_${loop}}}`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return { valid: errors.length === 0, errors };
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Template-specific validation
|
|
186
|
-
* @private
|
|
187
|
-
*/
|
|
188
|
-
validateSpecificTemplate(template, templateType) {
|
|
189
|
-
const errors = [];
|
|
190
|
-
const warnings = [];
|
|
191
|
-
|
|
192
|
-
switch (templateType) {
|
|
193
|
-
case 'agent':
|
|
194
|
-
// Check for YAML structure
|
|
195
|
-
if (!template.includes('agent:') || !template.includes('persona:')) {
|
|
196
|
-
errors.push('Agent template must include agent: and persona: sections');
|
|
197
|
-
}
|
|
198
|
-
if (!template.includes('commands:')) {
|
|
199
|
-
warnings.push('Agent template should include commands: section');
|
|
200
|
-
}
|
|
201
|
-
break;
|
|
202
|
-
|
|
203
|
-
case 'task':
|
|
204
|
-
// Check for markdown headers
|
|
205
|
-
if (!template.includes('# {{TASK_TITLE}}')) {
|
|
206
|
-
warnings.push('Task template should start with # {{TASK_TITLE}}');
|
|
207
|
-
}
|
|
208
|
-
if (!template.includes('## Workflow')) {
|
|
209
|
-
warnings.push('Task template should include ## Workflow section');
|
|
210
|
-
}
|
|
211
|
-
break;
|
|
212
|
-
|
|
213
|
-
case 'workflow':
|
|
214
|
-
// Check for YAML structure
|
|
215
|
-
if (!template.includes('workflow:') || !template.includes('steps:')) {
|
|
216
|
-
errors.push('Workflow template must include workflow: and steps: sections');
|
|
217
|
-
}
|
|
218
|
-
if (!template.includes('metadata:')) {
|
|
219
|
-
warnings.push('Workflow template should include metadata: section');
|
|
220
|
-
}
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return { valid: errors.length === 0, errors, warnings };
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Check for potential security issues in template
|
|
229
|
-
* @private
|
|
230
|
-
*/
|
|
231
|
-
checkSecurityIssues(template) {
|
|
232
|
-
const errors = [];
|
|
233
|
-
const warnings = [];
|
|
234
|
-
|
|
235
|
-
// Check for dangerous patterns
|
|
236
|
-
const dangerousPatterns = [
|
|
237
|
-
{ pattern: /eval\s*\(/, message: 'Template contains eval() - security risk' },
|
|
238
|
-
{ pattern: /Function\s*\(/, message: 'Template contains Function() - security risk' },
|
|
239
|
-
{ pattern: /require\s*\([^'"]+\)/, message: 'Dynamic require detected - potential security risk' },
|
|
240
|
-
{ pattern: /<script/i, message: 'Script tags detected in template' }
|
|
241
|
-
];
|
|
242
|
-
|
|
243
|
-
for (const { pattern, message } of dangerousPatterns) {
|
|
244
|
-
if (pattern.test(template)) {
|
|
245
|
-
errors.push(message);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// Check for suspicious patterns
|
|
250
|
-
if (template.includes('__proto__') || template.includes('constructor')) {
|
|
251
|
-
warnings.push('Template contains potentially dangerous property access');
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return { valid: errors.length === 0, errors, warnings };
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Get required variables for a template type
|
|
259
|
-
* @param {string} templateType - Type of template
|
|
260
|
-
* @returns {string[]} Array of required variable names
|
|
261
|
-
*/
|
|
262
|
-
getRequiredVariables(templateType) {
|
|
263
|
-
return this.requiredVariables[templateType] || [];
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Add custom required variables for a template type
|
|
268
|
-
* @param {string} templateType - Type of template
|
|
269
|
-
* @param {string[]} variables - Additional required variables
|
|
270
|
-
*/
|
|
271
|
-
addRequiredVariables(templateType, variables) {
|
|
272
|
-
if (!this.requiredVariables[templateType]) {
|
|
273
|
-
this.requiredVariables[templateType] = [];
|
|
274
|
-
}
|
|
275
|
-
this.requiredVariables[templateType].push(...variables);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
module.exports = TemplateValidator;
|