|
| 1 | +import { readFileSync, writeFileSync } from 'fs'; |
| 2 | +import { resolve } from 'path'; |
| 3 | + |
| 4 | +const DIR = new URL('.', import.meta.url).pathname; |
| 5 | + |
| 6 | +interface CompetitorData { |
| 7 | + name: string; |
| 8 | + url: string; |
| 9 | + platform: string; |
| 10 | + protocols: Record<string, boolean>; |
| 11 | + schemaEntityTypes: number; |
| 12 | + faqQuestions: number; |
| 13 | + notes: string; |
| 14 | +} |
| 15 | + |
| 16 | +interface DifferentiationResult { |
| 17 | + test: 'differentiation'; |
| 18 | + timestamp: string; |
| 19 | + nous: SiteMetrics; |
| 20 | + competitors: Array<SiteMetrics & { name: string }>; |
| 21 | + nousAdvantages: string[]; |
| 22 | + competitorAdvantages: string[]; |
| 23 | + protocolMultiple: Record<string, number>; |
| 24 | + classification: 'strong' | 'moderate' | 'weak'; |
| 25 | + reasoning: string; |
| 26 | +} |
| 27 | + |
| 28 | +interface SiteMetrics { |
| 29 | + protocolCount: number; |
| 30 | + protocolsPresent: string[]; |
| 31 | + schemaEntityTypes: number; |
| 32 | + faqQuestions: number; |
| 33 | + richtnessScore: number; |
| 34 | +} |
| 35 | + |
| 36 | +function computeRichness(protocols: number, schemaTypes: number, faqQs: number): number { |
| 37 | + return (protocols * 10) + (schemaTypes * 5) + (faqQs * 2); |
| 38 | +} |
| 39 | + |
| 40 | +// Nous metrics (from actual dist/ outputs) |
| 41 | +const nousProtocols = [ |
| 42 | + 'schemaJsonLd', 'faqPage', 'a2aAgentCard', 'llmsTxt', 'llmsFullTxt', |
| 43 | + 'mcpResources', 'ragChunks', 'agentsJson', 'openapi', 'agentsMd', |
| 44 | + 'codeExamples', 'crossRefs', |
| 45 | +]; |
| 46 | +const nous: SiteMetrics = { |
| 47 | + protocolCount: 12, |
| 48 | + protocolsPresent: nousProtocols, |
| 49 | + schemaEntityTypes: 4, |
| 50 | + faqQuestions: 128, |
| 51 | + richtnessScore: computeRichness(12, 4, 128), |
| 52 | +}; |
| 53 | + |
| 54 | +// Competitor metrics |
| 55 | +const competitorData: { competitors: CompetitorData[] } = JSON.parse( |
| 56 | + readFileSync(resolve(DIR, 'gap2-results', 'competitor-data.json'), 'utf-8') |
| 57 | +); |
| 58 | + |
| 59 | +const competitorMetrics = competitorData.competitors.map(c => { |
| 60 | + const present = Object.entries(c.protocols).filter(([, v]) => v).map(([k]) => k); |
| 61 | + return { |
| 62 | + name: c.name, |
| 63 | + protocolCount: present.length, |
| 64 | + protocolsPresent: present, |
| 65 | + schemaEntityTypes: c.schemaEntityTypes, |
| 66 | + faqQuestions: c.faqQuestions, |
| 67 | + richtnessScore: computeRichness(present.length, c.schemaEntityTypes, c.faqQuestions), |
| 68 | + }; |
| 69 | +}); |
| 70 | + |
| 71 | +// Compute advantages |
| 72 | +const nousAdvantages: string[] = []; |
| 73 | +const competitorAdvantages: string[] = []; |
| 74 | + |
| 75 | +const uniqueToNous = nousProtocols.filter(p => |
| 76 | + competitorMetrics.every(c => !c.protocolsPresent.includes(p)) |
| 77 | +); |
| 78 | +if (uniqueToNous.length > 0) { |
| 79 | + nousAdvantages.push(`${uniqueToNous.length} protocols unique to Nous: ${uniqueToNous.join(', ')}`); |
| 80 | +} |
| 81 | +if (nous.faqQuestions > 0 && competitorMetrics.every(c => c.faqQuestions === 0)) { |
| 82 | + nousAdvantages.push(`Generates ${nous.faqQuestions} FAQ questions from documentation content; no competitor produces FAQ structured data`); |
| 83 | +} |
| 84 | +if (nous.schemaEntityTypes > Math.max(...competitorMetrics.map(c => c.schemaEntityTypes))) { |
| 85 | + nousAdvantages.push(`${nous.schemaEntityTypes} Schema.org entity types vs 0 from competitors`); |
| 86 | +} |
| 87 | + |
| 88 | +for (const c of competitorMetrics) { |
| 89 | + for (const p of c.protocolsPresent) { |
| 90 | + if (!nousProtocols.includes(p)) { |
| 91 | + competitorAdvantages.push(`${c.name} has ${p} which Nous does not emit`); |
| 92 | + } |
| 93 | + } |
| 94 | +} |
| 95 | +if (competitorAdvantages.length === 0) { |
| 96 | + competitorAdvantages.push('None identified'); |
| 97 | +} |
| 98 | + |
| 99 | +// Protocol multiples |
| 100 | +const protocolMultiple: Record<string, number> = {}; |
| 101 | +for (const c of competitorMetrics) { |
| 102 | + protocolMultiple[c.name] = c.protocolCount > 0 ? nous.protocolCount / c.protocolCount : Infinity; |
| 103 | +} |
| 104 | + |
| 105 | +// Classification |
| 106 | +const avgMultiple = Object.values(protocolMultiple).reduce((a, b) => a + (b === Infinity ? 10 : b), 0) / Object.values(protocolMultiple).length; |
| 107 | +let classification: 'strong' | 'moderate' | 'weak'; |
| 108 | +let reasoning: string; |
| 109 | + |
| 110 | +if (avgMultiple > 3 && nous.faqQuestions > 0 && nous.schemaEntityTypes > 2) { |
| 111 | + classification = 'strong'; |
| 112 | + reasoning = `Nous emits ${nous.protocolCount} protocols vs an average of ${(competitorMetrics.reduce((s, c) => s + c.protocolCount, 0) / competitorMetrics.length).toFixed(1)} from competitors (${avgMultiple.toFixed(1)}x multiple). Nous generates ${nous.faqQuestions} FAQ questions and ${nous.schemaEntityTypes} Schema.org entity types that no competitor produces. The differentiation is structural: Nous emits agent-readability protocols that competitors have not implemented.`; |
| 113 | +} else if (avgMultiple > 1.5) { |
| 114 | + classification = 'moderate'; |
| 115 | + reasoning = `Nous has a measurable advantage but competitors cover some of the same protocols.`; |
| 116 | +} else { |
| 117 | + classification = 'weak'; |
| 118 | + reasoning = `Competitors match or approach Nous on protocol coverage.`; |
| 119 | +} |
| 120 | + |
| 121 | +const result: DifferentiationResult = { |
| 122 | + test: 'differentiation', |
| 123 | + timestamp: new Date().toISOString(), |
| 124 | + nous, |
| 125 | + competitors: competitorMetrics, |
| 126 | + nousAdvantages, |
| 127 | + competitorAdvantages, |
| 128 | + protocolMultiple, |
| 129 | + classification, |
| 130 | + reasoning, |
| 131 | +}; |
| 132 | + |
| 133 | +writeFileSync(resolve(DIR, 'gap2-results', 'differentiation.json'), JSON.stringify(result, null, 2)); |
| 134 | + |
| 135 | +console.log(`Differentiation: ${classification.toUpperCase()}`); |
| 136 | +console.log(` ${reasoning}`); |
| 137 | +console.log(` Nous richness: ${nous.richtnessScore}`); |
| 138 | +for (const c of competitorMetrics) { |
| 139 | + console.log(` ${c.name} richness: ${c.richtnessScore} (${protocolMultiple[c.name] === Infinity ? '∞' : protocolMultiple[c.name].toFixed(1)}x protocol gap)`); |
| 140 | +} |
| 141 | +console.log(` Nous advantages: ${nousAdvantages.length}`); |
| 142 | +console.log(` Competitor advantages: ${competitorAdvantages.join('; ')}`); |
0 commit comments