@timmeck/marketing-brain 0.2.0 → 0.3.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/README.md +28 -13
- package/dist/cli/colors.d.ts +11 -24
- package/dist/cli/colors.js +3 -46
- package/dist/cli/colors.js.map +1 -1
- package/dist/cli/commands/dashboard.js +1 -1
- package/dist/cli/commands/peers.d.ts +2 -0
- package/dist/cli/commands/peers.js +38 -0
- package/dist/cli/commands/peers.js.map +1 -0
- package/dist/config.js +3 -3
- package/dist/db/connection.d.ts +1 -2
- package/dist/db/connection.js +1 -18
- package/dist/db/connection.js.map +1 -1
- package/dist/hooks/post-tool-use.d.ts +2 -0
- package/dist/hooks/post-tool-use.js +182 -0
- package/dist/hooks/post-tool-use.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/ipc/__tests__/protocol.test.d.ts +1 -0
- package/dist/ipc/__tests__/protocol.test.js +129 -0
- package/dist/ipc/__tests__/protocol.test.js.map +1 -0
- package/dist/ipc/client.d.ts +1 -13
- package/dist/ipc/client.js +1 -92
- package/dist/ipc/client.js.map +1 -1
- package/dist/ipc/protocol.d.ts +1 -8
- package/dist/ipc/protocol.js +1 -28
- package/dist/ipc/protocol.js.map +1 -1
- package/dist/ipc/router.js +8 -0
- package/dist/ipc/router.js.map +1 -1
- package/dist/ipc/server.d.ts +1 -14
- package/dist/ipc/server.js +1 -129
- package/dist/ipc/server.js.map +1 -1
- package/dist/marketing-core.d.ts +1 -0
- package/dist/marketing-core.js +6 -1
- package/dist/marketing-core.js.map +1 -1
- package/dist/mcp/server.js +5 -60
- package/dist/mcp/server.js.map +1 -1
- package/dist/types/ipc.types.d.ts +1 -11
- package/dist/utils/__tests__/hash.test.d.ts +1 -0
- package/dist/utils/__tests__/hash.test.js +30 -0
- package/dist/utils/__tests__/hash.test.js.map +1 -0
- package/dist/utils/__tests__/paths.test.d.ts +1 -0
- package/dist/utils/__tests__/paths.test.js +63 -0
- package/dist/utils/__tests__/paths.test.js.map +1 -0
- package/dist/utils/events.d.ts +4 -8
- package/dist/utils/events.js +2 -14
- package/dist/utils/events.js.map +1 -1
- package/dist/utils/hash.d.ts +1 -1
- package/dist/utils/hash.js +1 -4
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/logger.d.ts +3 -2
- package/dist/utils/logger.js +8 -35
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/paths.d.ts +2 -1
- package/dist/utils/paths.js +4 -13
- package/dist/utils/paths.js.map +1 -1
- package/package.json +2 -1
- package/.mcp.json +0 -9
- package/src/api/server.ts +0 -86
- package/src/cli/colors.ts +0 -59
- package/src/cli/commands/campaign.ts +0 -66
- package/src/cli/commands/config.ts +0 -168
- package/src/cli/commands/dashboard.ts +0 -165
- package/src/cli/commands/doctor.ts +0 -110
- package/src/cli/commands/export.ts +0 -40
- package/src/cli/commands/import.ts +0 -84
- package/src/cli/commands/insights.ts +0 -44
- package/src/cli/commands/learn.ts +0 -24
- package/src/cli/commands/network.ts +0 -71
- package/src/cli/commands/post.ts +0 -47
- package/src/cli/commands/query.ts +0 -108
- package/src/cli/commands/rules.ts +0 -27
- package/src/cli/commands/start.ts +0 -100
- package/src/cli/commands/status.ts +0 -73
- package/src/cli/commands/stop.ts +0 -33
- package/src/cli/commands/suggest.ts +0 -64
- package/src/cli/ipc-helper.ts +0 -22
- package/src/cli/update-check.ts +0 -63
- package/src/config.ts +0 -110
- package/src/dashboard/renderer.ts +0 -136
- package/src/dashboard/server.ts +0 -140
- package/src/db/connection.ts +0 -22
- package/src/db/migrations/001_core_schema.ts +0 -63
- package/src/db/migrations/002_learning_schema.ts +0 -46
- package/src/db/migrations/003_synapse_schema.ts +0 -27
- package/src/db/migrations/004_insights_schema.ts +0 -38
- package/src/db/migrations/005_fts_indexes.ts +0 -77
- package/src/db/migrations/index.ts +0 -62
- package/src/db/repositories/audience.repository.ts +0 -53
- package/src/db/repositories/campaign.repository.ts +0 -72
- package/src/db/repositories/engagement.repository.ts +0 -108
- package/src/db/repositories/insight.repository.ts +0 -100
- package/src/db/repositories/post.repository.ts +0 -123
- package/src/db/repositories/rule.repository.ts +0 -87
- package/src/db/repositories/strategy.repository.ts +0 -82
- package/src/db/repositories/synapse.repository.ts +0 -148
- package/src/db/repositories/template.repository.ts +0 -76
- package/src/index.ts +0 -69
- package/src/ipc/client.ts +0 -110
- package/src/ipc/protocol.ts +0 -35
- package/src/ipc/router.ts +0 -126
- package/src/ipc/server.ts +0 -140
- package/src/learning/confidence-scorer.ts +0 -36
- package/src/learning/learning-engine.ts +0 -254
- package/src/marketing-core.ts +0 -285
- package/src/mcp/server.ts +0 -72
- package/src/mcp/tools.ts +0 -216
- package/src/research/research-engine.ts +0 -226
- package/src/services/analytics.service.ts +0 -73
- package/src/services/audience.service.ts +0 -40
- package/src/services/campaign.service.ts +0 -80
- package/src/services/insight.service.ts +0 -54
- package/src/services/post.service.ts +0 -116
- package/src/services/rule.service.ts +0 -90
- package/src/services/strategy.service.ts +0 -53
- package/src/services/synapse.service.ts +0 -32
- package/src/services/template.service.ts +0 -50
- package/src/synapses/activation.ts +0 -80
- package/src/synapses/decay.ts +0 -38
- package/src/synapses/hebbian.ts +0 -68
- package/src/synapses/pathfinder.ts +0 -81
- package/src/synapses/synapse-manager.ts +0 -115
- package/src/types/config.types.ts +0 -79
- package/src/types/ipc.types.ts +0 -8
- package/src/types/post.types.ts +0 -156
- package/src/types/synapse.types.ts +0 -43
- package/src/utils/events.ts +0 -44
- package/src/utils/hash.ts +0 -5
- package/src/utils/logger.ts +0 -48
- package/src/utils/paths.ts +0 -19
- package/tsconfig.json +0 -18
package/src/types/post.types.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
export type Platform = 'x' | 'reddit' | 'linkedin' | 'bluesky' | 'mastodon' | 'threads' | 'other';
|
|
2
|
-
export type PostFormat = 'text' | 'image' | 'video' | 'carousel' | 'thread' | 'article' | 'poll';
|
|
3
|
-
export type PostStatus = 'draft' | 'scheduled' | 'published' | 'archived';
|
|
4
|
-
|
|
5
|
-
export interface Post {
|
|
6
|
-
id: number;
|
|
7
|
-
campaign_id: number | null;
|
|
8
|
-
platform: Platform;
|
|
9
|
-
content: string;
|
|
10
|
-
format: PostFormat;
|
|
11
|
-
hashtags: string | null;
|
|
12
|
-
url: string | null;
|
|
13
|
-
published_at: string | null;
|
|
14
|
-
fingerprint: string;
|
|
15
|
-
status: PostStatus;
|
|
16
|
-
created_at: string;
|
|
17
|
-
updated_at: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface PostCreate {
|
|
21
|
-
campaign_id?: number | null;
|
|
22
|
-
platform: Platform;
|
|
23
|
-
content: string;
|
|
24
|
-
format?: PostFormat;
|
|
25
|
-
hashtags?: string;
|
|
26
|
-
url?: string;
|
|
27
|
-
published_at?: string;
|
|
28
|
-
status?: PostStatus;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface Engagement {
|
|
32
|
-
id: number;
|
|
33
|
-
post_id: number;
|
|
34
|
-
timestamp: string;
|
|
35
|
-
likes: number;
|
|
36
|
-
comments: number;
|
|
37
|
-
shares: number;
|
|
38
|
-
impressions: number;
|
|
39
|
-
clicks: number;
|
|
40
|
-
saves: number;
|
|
41
|
-
reach: number;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface EngagementCreate {
|
|
45
|
-
post_id: number;
|
|
46
|
-
likes?: number;
|
|
47
|
-
comments?: number;
|
|
48
|
-
shares?: number;
|
|
49
|
-
impressions?: number;
|
|
50
|
-
clicks?: number;
|
|
51
|
-
saves?: number;
|
|
52
|
-
reach?: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface Campaign {
|
|
56
|
-
id: number;
|
|
57
|
-
name: string;
|
|
58
|
-
brand: string | null;
|
|
59
|
-
goal: string | null;
|
|
60
|
-
platform: string | null;
|
|
61
|
-
status: string;
|
|
62
|
-
created_at: string;
|
|
63
|
-
updated_at: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface CampaignCreate {
|
|
67
|
-
name: string;
|
|
68
|
-
brand?: string;
|
|
69
|
-
goal?: string;
|
|
70
|
-
platform?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export interface Audience {
|
|
74
|
-
id: number;
|
|
75
|
-
name: string;
|
|
76
|
-
platform: Platform | null;
|
|
77
|
-
demographics: string | null;
|
|
78
|
-
interests: string | null;
|
|
79
|
-
created_at: string;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface Strategy {
|
|
83
|
-
id: number;
|
|
84
|
-
post_id: number | null;
|
|
85
|
-
description: string;
|
|
86
|
-
approach: string | null;
|
|
87
|
-
outcome: string | null;
|
|
88
|
-
confidence: number;
|
|
89
|
-
created_at: string;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface StrategyCreate {
|
|
93
|
-
post_id?: number;
|
|
94
|
-
description: string;
|
|
95
|
-
approach?: string;
|
|
96
|
-
outcome?: string;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export interface ContentTemplate {
|
|
100
|
-
id: number;
|
|
101
|
-
name: string;
|
|
102
|
-
structure: string;
|
|
103
|
-
example: string | null;
|
|
104
|
-
platform: Platform | null;
|
|
105
|
-
avg_engagement: number;
|
|
106
|
-
use_count: number;
|
|
107
|
-
created_at: string;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export interface ContentTemplateCreate {
|
|
111
|
-
name: string;
|
|
112
|
-
structure: string;
|
|
113
|
-
example?: string;
|
|
114
|
-
platform?: Platform;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export interface MarketingRule {
|
|
118
|
-
id: number;
|
|
119
|
-
pattern: string;
|
|
120
|
-
recommendation: string;
|
|
121
|
-
confidence: number;
|
|
122
|
-
trigger_count: number;
|
|
123
|
-
success_count: number;
|
|
124
|
-
active: number;
|
|
125
|
-
created_at: string;
|
|
126
|
-
updated_at: string;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export interface RuleCreate {
|
|
130
|
-
pattern: string;
|
|
131
|
-
recommendation: string;
|
|
132
|
-
confidence?: number;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export interface Insight {
|
|
136
|
-
id: number;
|
|
137
|
-
type: string;
|
|
138
|
-
title: string;
|
|
139
|
-
description: string;
|
|
140
|
-
confidence: number;
|
|
141
|
-
priority: number;
|
|
142
|
-
campaign_id: number | null;
|
|
143
|
-
active: number;
|
|
144
|
-
expires_at: string | null;
|
|
145
|
-
created_at: string;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
export interface InsightCreate {
|
|
149
|
-
type: string;
|
|
150
|
-
title: string;
|
|
151
|
-
description: string;
|
|
152
|
-
confidence?: number;
|
|
153
|
-
priority?: number;
|
|
154
|
-
campaign_id?: number | null;
|
|
155
|
-
expires_at?: string;
|
|
156
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
export type NodeType =
|
|
2
|
-
| 'post'
|
|
3
|
-
| 'campaign'
|
|
4
|
-
| 'strategy'
|
|
5
|
-
| 'template'
|
|
6
|
-
| 'rule'
|
|
7
|
-
| 'audience'
|
|
8
|
-
| 'insight';
|
|
9
|
-
|
|
10
|
-
export type SynapseType =
|
|
11
|
-
| 'belongs_to'
|
|
12
|
-
| 'similar_to'
|
|
13
|
-
| 'engages_with'
|
|
14
|
-
| 'improves'
|
|
15
|
-
| 'prevents'
|
|
16
|
-
| 'recommends'
|
|
17
|
-
| 'generated_from'
|
|
18
|
-
| 'cross_promotes'
|
|
19
|
-
| 'informs'
|
|
20
|
-
| 'co_occurs';
|
|
21
|
-
|
|
22
|
-
export interface SynapseRecord {
|
|
23
|
-
id: number;
|
|
24
|
-
source_type: NodeType;
|
|
25
|
-
source_id: number;
|
|
26
|
-
target_type: NodeType;
|
|
27
|
-
target_id: number;
|
|
28
|
-
synapse_type: SynapseType;
|
|
29
|
-
weight: number;
|
|
30
|
-
activation_count: number;
|
|
31
|
-
last_activated_at: string;
|
|
32
|
-
metadata: string | null;
|
|
33
|
-
created_at: string;
|
|
34
|
-
updated_at: string;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface NetworkStats {
|
|
38
|
-
totalNodes: number;
|
|
39
|
-
totalSynapses: number;
|
|
40
|
-
avgWeight: number;
|
|
41
|
-
nodesByType: Record<NodeType, number>;
|
|
42
|
-
synapsesByType: Record<SynapseType, number>;
|
|
43
|
-
}
|
package/src/utils/events.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'node:events';
|
|
2
|
-
|
|
3
|
-
export interface MarketingEvents {
|
|
4
|
-
'post:created': { postId: number; campaignId: number | null; platform: string };
|
|
5
|
-
'post:published': { postId: number; platform: string };
|
|
6
|
-
'engagement:updated': { postId: number; engagementId: number };
|
|
7
|
-
'strategy:reported': { strategyId: number; postId: number };
|
|
8
|
-
'rule:learned': { ruleId: number; pattern: string };
|
|
9
|
-
'rule:triggered': { ruleId: number; postId: number };
|
|
10
|
-
'template:created': { templateId: number; platform: string };
|
|
11
|
-
'campaign:created': { campaignId: number; name: string };
|
|
12
|
-
'insight:created': { insightId: number; type: string };
|
|
13
|
-
'synapse:created': { synapseId: number; sourceType: string; targetType: string };
|
|
14
|
-
'synapse:strengthened': { synapseId: number; newWeight: number };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type MarketingEventName = keyof MarketingEvents;
|
|
18
|
-
|
|
19
|
-
export class TypedEventBus extends EventEmitter {
|
|
20
|
-
emit<K extends MarketingEventName>(event: K, data: MarketingEvents[K]): boolean {
|
|
21
|
-
return super.emit(event, data);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
on<K extends MarketingEventName>(event: K, listener: (data: MarketingEvents[K]) => void): this {
|
|
25
|
-
return super.on(event, listener);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
once<K extends MarketingEventName>(event: K, listener: (data: MarketingEvents[K]) => void): this {
|
|
29
|
-
return super.once(event, listener);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
off<K extends MarketingEventName>(event: K, listener: (data: MarketingEvents[K]) => void): this {
|
|
33
|
-
return super.off(event, listener);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let busInstance: TypedEventBus | null = null;
|
|
38
|
-
|
|
39
|
-
export function getEventBus(): TypedEventBus {
|
|
40
|
-
if (!busInstance) {
|
|
41
|
-
busInstance = new TypedEventBus();
|
|
42
|
-
}
|
|
43
|
-
return busInstance;
|
|
44
|
-
}
|
package/src/utils/hash.ts
DELETED
package/src/utils/logger.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import winston from 'winston';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { getDataDir } from './paths.js';
|
|
4
|
-
|
|
5
|
-
const { combine, timestamp, printf, colorize } = winston.format;
|
|
6
|
-
|
|
7
|
-
const logFormat = printf(({ level, message, timestamp, ...meta }) => {
|
|
8
|
-
const metaStr = Object.keys(meta).length ? ` ${JSON.stringify(meta)}` : '';
|
|
9
|
-
return `${timestamp} [${level}]${metaStr} ${message}`;
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
let loggerInstance: winston.Logger | null = null;
|
|
13
|
-
|
|
14
|
-
export function createLogger(opts?: { level?: string; file?: string; maxSize?: number; maxFiles?: number }): winston.Logger {
|
|
15
|
-
if (loggerInstance) return loggerInstance;
|
|
16
|
-
|
|
17
|
-
const level = opts?.level ?? process.env['MARKETING_BRAIN_LOG_LEVEL'] ?? 'info';
|
|
18
|
-
const logFile = opts?.file ?? path.join(getDataDir(), 'marketing-brain.log');
|
|
19
|
-
const maxSize = opts?.maxSize ?? 10 * 1024 * 1024;
|
|
20
|
-
const maxFiles = opts?.maxFiles ?? 3;
|
|
21
|
-
|
|
22
|
-
const transports: winston.transport[] = [
|
|
23
|
-
new winston.transports.File({
|
|
24
|
-
filename: logFile,
|
|
25
|
-
maxsize: maxSize,
|
|
26
|
-
maxFiles,
|
|
27
|
-
format: combine(timestamp(), logFormat),
|
|
28
|
-
}),
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
if (process.env['NODE_ENV'] !== 'production') {
|
|
32
|
-
transports.push(
|
|
33
|
-
new winston.transports.Console({
|
|
34
|
-
format: combine(colorize(), timestamp(), logFormat),
|
|
35
|
-
})
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
loggerInstance = winston.createLogger({ level, transports });
|
|
40
|
-
return loggerInstance;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function getLogger(): winston.Logger {
|
|
44
|
-
if (!loggerInstance) {
|
|
45
|
-
return createLogger();
|
|
46
|
-
}
|
|
47
|
-
return loggerInstance;
|
|
48
|
-
}
|
package/src/utils/paths.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
|
|
4
|
-
export function normalizePath(filePath: string): string {
|
|
5
|
-
return filePath.replace(/\\/g, '/');
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function getDataDir(): string {
|
|
9
|
-
const envDir = process.env['MARKETING_BRAIN_DATA_DIR'];
|
|
10
|
-
if (envDir) return path.resolve(envDir);
|
|
11
|
-
return path.join(os.homedir(), '.marketing-brain');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getPipeName(name: string = 'marketing-brain'): string {
|
|
15
|
-
if (process.platform === 'win32') {
|
|
16
|
-
return `\\\\.\\pipe\\${name}`;
|
|
17
|
-
}
|
|
18
|
-
return path.join(os.tmpdir(), `${name}.sock`);
|
|
19
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"forceConsistentCasingInFileNames": true,
|
|
10
|
-
"outDir": "dist",
|
|
11
|
-
"rootDir": "src",
|
|
12
|
-
"declaration": true,
|
|
13
|
-
"sourceMap": true,
|
|
14
|
-
"resolveJsonModule": true
|
|
15
|
-
},
|
|
16
|
-
"include": ["src/**/*"],
|
|
17
|
-
"exclude": ["node_modules", "dist"]
|
|
18
|
-
}
|