vantuz 3.4.2 → 3.5.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/LICENSE +45 -45
- package/admin-keygen.js +51 -0
- package/cli.js +685 -585
- package/config.js +733 -733
- package/core/agent-loop.js +190 -190
- package/core/ai-provider.js +298 -261
- package/core/automation.js +523 -523
- package/core/brand-analyst.js +101 -0
- package/core/channels.js +167 -167
- package/core/dashboard.js +230 -230
- package/core/database.js +135 -37
- package/core/eia-monitor.js +3 -1
- package/core/engine.js +648 -636
- package/core/gateway.js +447 -447
- package/core/learning.js +214 -214
- package/core/license.js +113 -0
- package/core/marketplace-adapter.js +168 -168
- package/core/memory.js +190 -190
- package/core/migrations/001-initial-schema.sql +1 -1
- package/core/queue.js +120 -120
- package/core/self-healer.js +314 -314
- package/core/unified-product.js +214 -214
- package/core/vision-service.js +113 -113
- package/index.js +217 -174
- package/modules/crm/sentiment-crm.js +231 -231
- package/modules/healer/listing-healer.js +201 -201
- package/modules/oracle/predictor.js +214 -214
- package/modules/researcher/agent.js +169 -169
- package/modules/team/agents/base.js +92 -92
- package/modules/team/agents/dev.js +33 -33
- package/modules/team/agents/josh.js +40 -40
- package/modules/team/agents/marketing.js +33 -33
- package/modules/team/agents/milo.js +36 -36
- package/modules/team/index.js +78 -78
- package/modules/team/shared-memory.js +87 -87
- package/modules/war-room/competitor-tracker.js +250 -250
- package/modules/war-room/pricing-engine.js +308 -308
- package/nodes/warehouse.js +238 -238
- package/onboard.js +1 -1
- package/package.json +7 -5
- package/platforms/pttavm.js +14 -14
- package/plugins/vantuz/index.js +528 -528
- package/plugins/vantuz/memory/hippocampus.js +465 -465
- package/plugins/vantuz/package.json +20 -20
- package/plugins/vantuz/platforms/_template.js +118 -118
- package/plugins/vantuz/platforms/amazon.js +236 -236
- package/plugins/vantuz/platforms/ciceksepeti.js +166 -166
- package/plugins/vantuz/platforms/hepsiburada.js +180 -180
- package/plugins/vantuz/platforms/index.js +165 -165
- package/plugins/vantuz/platforms/n11.js +229 -229
- package/plugins/vantuz/platforms/pazarama.js +154 -154
- package/plugins/vantuz/platforms/pttavm.js +127 -127
- package/plugins/vantuz/platforms/trendyol.js +326 -326
- package/plugins/vantuz/services/alerts.js +253 -253
- package/plugins/vantuz/services/license.js +34 -34
- package/plugins/vantuz/services/scheduler.js +232 -232
- package/plugins/vantuz/tools/analytics.js +152 -152
- package/plugins/vantuz/tools/crossborder.js +187 -187
- package/plugins/vantuz/tools/nl-parser.js +211 -211
- package/plugins/vantuz/tools/product.js +110 -110
- package/plugins/vantuz/tools/quick-report.js +175 -175
- package/plugins/vantuz/tools/repricer.js +314 -314
- package/plugins/vantuz/tools/sentiment.js +115 -115
- package/plugins/vantuz/tools/vision.js +257 -257
- package/private.pem +28 -0
- package/public.pem +9 -0
- package/server/app.js +260 -260
- package/server/public/index.html +514 -514
- package/start.bat +33 -33
- package/vantuz.sqlite +0 -0
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
// modules/team/agents/marketing.js
|
|
2
|
-
import { BaseAgent } from './base.js';
|
|
3
|
-
import { sentimentTool } from '
|
|
4
|
-
|
|
5
|
-
export class MarketingAgent extends BaseAgent {
|
|
6
|
-
constructor(api) {
|
|
7
|
-
super('Marketing', 'Marketing Researcher', { api });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async getSystemPrompt() {
|
|
11
|
-
const base = await super.getSystemPrompt();
|
|
12
|
-
return `${base}
|
|
13
|
-
|
|
14
|
-
## SENİN ÖZEL ROLÜN: PAZARLAMA AJANI
|
|
15
|
-
- Yaratıcı, trendleri takip eden ve meraklı birisin.
|
|
16
|
-
- **Sorumlulukların**:
|
|
17
|
-
- Sosyal medya için içerik fikirleri üretmek.
|
|
18
|
-
- Müşteri duyarlılığını (yorumlar, sorular) izlemek.
|
|
19
|
-
- SEO optimizasyonları.
|
|
20
|
-
- **Araçlar**:
|
|
21
|
-
- Duygu Analizi (Sentiment)
|
|
22
|
-
- Vision AI (ürün fotoğrafları için)
|
|
23
|
-
|
|
24
|
-
## GÜNLÜK RUTİN
|
|
25
|
-
- Her gün 3 içerik fikri sun.
|
|
26
|
-
- Negatif yorum trendlerini kontrol et.
|
|
27
|
-
`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async analyzeSentiment(productId) {
|
|
31
|
-
return await sentimentTool.execute({ productId, platform: 'all', period: '7d' }, this.context);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
// modules/team/agents/marketing.js
|
|
2
|
+
import { BaseAgent } from './base.js';
|
|
3
|
+
import { sentimentTool } from '../../../plugins/vantuz/tools/sentiment.js';
|
|
4
|
+
|
|
5
|
+
export class MarketingAgent extends BaseAgent {
|
|
6
|
+
constructor(api) {
|
|
7
|
+
super('Marketing', 'Marketing Researcher', { api });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async getSystemPrompt() {
|
|
11
|
+
const base = await super.getSystemPrompt();
|
|
12
|
+
return `${base}
|
|
13
|
+
|
|
14
|
+
## SENİN ÖZEL ROLÜN: PAZARLAMA AJANI
|
|
15
|
+
- Yaratıcı, trendleri takip eden ve meraklı birisin.
|
|
16
|
+
- **Sorumlulukların**:
|
|
17
|
+
- Sosyal medya için içerik fikirleri üretmek.
|
|
18
|
+
- Müşteri duyarlılığını (yorumlar, sorular) izlemek.
|
|
19
|
+
- SEO optimizasyonları.
|
|
20
|
+
- **Araçlar**:
|
|
21
|
+
- Duygu Analizi (Sentiment)
|
|
22
|
+
- Vision AI (ürün fotoğrafları için)
|
|
23
|
+
|
|
24
|
+
## GÜNLÜK RUTİN
|
|
25
|
+
- Her gün 3 içerik fikri sun.
|
|
26
|
+
- Negatif yorum trendlerini kontrol et.
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async analyzeSentiment(productId) {
|
|
31
|
+
return await sentimentTool.execute({ productId, platform: 'all', period: '7d' }, this.context);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
// modules/team/agents/milo.js
|
|
2
|
-
import { BaseAgent } from './base.js';
|
|
3
|
-
import sharedMemory from '../shared-memory.js';
|
|
4
|
-
|
|
5
|
-
export class MiloAgent extends BaseAgent {
|
|
6
|
-
constructor(api) {
|
|
7
|
-
super('Milo', 'Strategy Lead', { api });
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
async getSystemPrompt() {
|
|
11
|
-
const base = await super.getSystemPrompt();
|
|
12
|
-
return `${base}
|
|
13
|
-
|
|
14
|
-
## SENİN ÖZEL ROLÜN: MILO (STRATEJİ LİDERİ)
|
|
15
|
-
- Sen takım liderisin. Kendine güvenen, karizmatik ve büyük resmi gören birisin.
|
|
16
|
-
- **Sorumlulukların**:
|
|
17
|
-
- Takımı yönetmek (Josh, Pazarlama, Yazılım).
|
|
18
|
-
- Haftalık hedefleri GOALS.md dosyasına girmek.
|
|
19
|
-
- Diğer ajanlardan gelen raporları sentezlemek.
|
|
20
|
-
- Üst düzey kararlar almak.
|
|
21
|
-
- **Araçlar**:
|
|
22
|
-
- Diğer ajanlardan rapor isteyebilirsin.
|
|
23
|
-
- GOALS.md dosyasını güncelleyebilirsin.
|
|
24
|
-
|
|
25
|
-
## GÜNLÜK RUTİN
|
|
26
|
-
- Gece yapılan ilerlemeyi incele.
|
|
27
|
-
- Sabah toplantı özetini yayınla.
|
|
28
|
-
- Gün sonu özeti geç.
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async setGoal(goalText) {
|
|
33
|
-
sharedMemory.writeFile('GOALS.md', `# Current Goals & OKRs\n\n${goalText}`);
|
|
34
|
-
return 'Goals updated successfully.';
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
// modules/team/agents/milo.js
|
|
2
|
+
import { BaseAgent } from './base.js';
|
|
3
|
+
import sharedMemory from '../shared-memory.js';
|
|
4
|
+
|
|
5
|
+
export class MiloAgent extends BaseAgent {
|
|
6
|
+
constructor(api) {
|
|
7
|
+
super('Milo', 'Strategy Lead', { api });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async getSystemPrompt() {
|
|
11
|
+
const base = await super.getSystemPrompt();
|
|
12
|
+
return `${base}
|
|
13
|
+
|
|
14
|
+
## SENİN ÖZEL ROLÜN: MILO (STRATEJİ LİDERİ)
|
|
15
|
+
- Sen takım liderisin. Kendine güvenen, karizmatik ve büyük resmi gören birisin.
|
|
16
|
+
- **Sorumlulukların**:
|
|
17
|
+
- Takımı yönetmek (Josh, Pazarlama, Yazılım).
|
|
18
|
+
- Haftalık hedefleri GOALS.md dosyasına girmek.
|
|
19
|
+
- Diğer ajanlardan gelen raporları sentezlemek.
|
|
20
|
+
- Üst düzey kararlar almak.
|
|
21
|
+
- **Araçlar**:
|
|
22
|
+
- Diğer ajanlardan rapor isteyebilirsin.
|
|
23
|
+
- GOALS.md dosyasını güncelleyebilirsin.
|
|
24
|
+
|
|
25
|
+
## GÜNLÜK RUTİN
|
|
26
|
+
- Gece yapılan ilerlemeyi incele.
|
|
27
|
+
- Sabah toplantı özetini yayınla.
|
|
28
|
+
- Gün sonu özeti geç.
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async setGoal(goalText) {
|
|
33
|
+
sharedMemory.writeFile('GOALS.md', `# Current Goals & OKRs\n\n${goalText}`);
|
|
34
|
+
return 'Goals updated successfully.';
|
|
35
|
+
}
|
|
36
|
+
}
|
package/modules/team/index.js
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
// modules/team/index.js
|
|
2
|
-
import { MiloAgent } from './agents/milo.js';
|
|
3
|
-
import { JoshAgent } from './agents/josh.js';
|
|
4
|
-
import { MarketingAgent } from './agents/marketing.js';
|
|
5
|
-
import { DevAgent } from './agents/dev.js';
|
|
6
|
-
import sharedMemory from './shared-memory.js';
|
|
7
|
-
import { log } from '../../core/ai-provider.js';
|
|
8
|
-
|
|
9
|
-
class TeamModule {
|
|
10
|
-
constructor(api) {
|
|
11
|
-
this.api = api;
|
|
12
|
-
this.agents = {};
|
|
13
|
-
this.initialized = false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async initialize() {
|
|
17
|
-
if (this.initialized) return;
|
|
18
|
-
|
|
19
|
-
this.agents = {
|
|
20
|
-
milo: new MiloAgent(this.api),
|
|
21
|
-
josh: new JoshAgent(this.api),
|
|
22
|
-
marketing: new MarketingAgent(this.api),
|
|
23
|
-
dev: new DevAgent(this.api)
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// Ensure shared memory structure
|
|
27
|
-
sharedMemory.ensureStructure();
|
|
28
|
-
|
|
29
|
-
this.initialized = true;
|
|
30
|
-
log('INFO', 'Team Module initialized with agents: Milo, Josh, Marketing, Dev');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getAgent(name) {
|
|
34
|
-
return this.agents[name.toLowerCase()];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async chat(agentName, message, depth = 0) {
|
|
38
|
-
if (depth > 3) return "Hata: Çok fazla delegasyon döngüsü (max 3).";
|
|
39
|
-
|
|
40
|
-
const agent = this.getAgent(agentName);
|
|
41
|
-
if (!agent) {
|
|
42
|
-
return `Agent '${agentName}' bulunamadı. Mevcut: ${Object.keys(this.agents).join(', ')}`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let response = await agent.process(message);
|
|
46
|
-
|
|
47
|
-
// Delegasyon Kontrolü: [DELEGATE: TargetAgent Message]
|
|
48
|
-
const delegateMatch = response.match(/\[DELEGATE:\s*(\w+)\s+(.*?)\]/i);
|
|
49
|
-
if (delegateMatch) {
|
|
50
|
-
const targetAgentName = delegateMatch[1];
|
|
51
|
-
const targetMessage = delegateMatch[2];
|
|
52
|
-
|
|
53
|
-
log('INFO', `Delegasyon: ${agentName} -> ${targetAgentName}: ${targetMessage}`);
|
|
54
|
-
|
|
55
|
-
const delegateResponse = await this.chat(targetAgentName, targetMessage, depth + 1);
|
|
56
|
-
|
|
57
|
-
// Cevabı orijinal ajana geri bildir ve nihai cevabı al
|
|
58
|
-
const followupMessage = `[SİSTEM]: ${targetAgentName} şu cevabı verdi: "${delegateResponse}". Buna göre kullanıcıya nihai cevabını ver.`;
|
|
59
|
-
response = await agent.process(followupMessage);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return response;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async broadcast(message) {
|
|
66
|
-
const results = {};
|
|
67
|
-
for (const [name, agent] of Object.entries(this.agents)) {
|
|
68
|
-
results[name] = await agent.process(message);
|
|
69
|
-
}
|
|
70
|
-
return results;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getSharedMemory() {
|
|
74
|
-
return sharedMemory;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default TeamModule;
|
|
1
|
+
// modules/team/index.js
|
|
2
|
+
import { MiloAgent } from './agents/milo.js';
|
|
3
|
+
import { JoshAgent } from './agents/josh.js';
|
|
4
|
+
import { MarketingAgent } from './agents/marketing.js';
|
|
5
|
+
import { DevAgent } from './agents/dev.js';
|
|
6
|
+
import sharedMemory from './shared-memory.js';
|
|
7
|
+
import { log } from '../../core/ai-provider.js';
|
|
8
|
+
|
|
9
|
+
class TeamModule {
|
|
10
|
+
constructor(api) {
|
|
11
|
+
this.api = api;
|
|
12
|
+
this.agents = {};
|
|
13
|
+
this.initialized = false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async initialize() {
|
|
17
|
+
if (this.initialized) return;
|
|
18
|
+
|
|
19
|
+
this.agents = {
|
|
20
|
+
milo: new MiloAgent(this.api),
|
|
21
|
+
josh: new JoshAgent(this.api),
|
|
22
|
+
marketing: new MarketingAgent(this.api),
|
|
23
|
+
dev: new DevAgent(this.api)
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Ensure shared memory structure
|
|
27
|
+
sharedMemory.ensureStructure();
|
|
28
|
+
|
|
29
|
+
this.initialized = true;
|
|
30
|
+
log('INFO', 'Team Module initialized with agents: Milo, Josh, Marketing, Dev');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getAgent(name) {
|
|
34
|
+
return this.agents[name.toLowerCase()];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async chat(agentName, message, depth = 0) {
|
|
38
|
+
if (depth > 3) return "Hata: Çok fazla delegasyon döngüsü (max 3).";
|
|
39
|
+
|
|
40
|
+
const agent = this.getAgent(agentName);
|
|
41
|
+
if (!agent) {
|
|
42
|
+
return `Agent '${agentName}' bulunamadı. Mevcut: ${Object.keys(this.agents).join(', ')}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let response = await agent.process(message);
|
|
46
|
+
|
|
47
|
+
// Delegasyon Kontrolü: [DELEGATE: TargetAgent Message]
|
|
48
|
+
const delegateMatch = response.match(/\[DELEGATE:\s*(\w+)\s+(.*?)\]/i);
|
|
49
|
+
if (delegateMatch) {
|
|
50
|
+
const targetAgentName = delegateMatch[1];
|
|
51
|
+
const targetMessage = delegateMatch[2];
|
|
52
|
+
|
|
53
|
+
log('INFO', `Delegasyon: ${agentName} -> ${targetAgentName}: ${targetMessage}`);
|
|
54
|
+
|
|
55
|
+
const delegateResponse = await this.chat(targetAgentName, targetMessage, depth + 1);
|
|
56
|
+
|
|
57
|
+
// Cevabı orijinal ajana geri bildir ve nihai cevabı al
|
|
58
|
+
const followupMessage = `[SİSTEM]: ${targetAgentName} şu cevabı verdi: "${delegateResponse}". Buna göre kullanıcıya nihai cevabını ver.`;
|
|
59
|
+
response = await agent.process(followupMessage);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return response;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async broadcast(message) {
|
|
66
|
+
const results = {};
|
|
67
|
+
for (const [name, agent] of Object.entries(this.agents)) {
|
|
68
|
+
results[name] = await agent.process(message);
|
|
69
|
+
}
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getSharedMemory() {
|
|
74
|
+
return sharedMemory;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default TeamModule;
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
// modules/team/shared-memory.js
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { log } from '../../core/ai-provider.js';
|
|
5
|
-
|
|
6
|
-
const TEAM_DIR = path.join(process.cwd(), 'workspace', 'team');
|
|
7
|
-
|
|
8
|
-
export class SharedMemory {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.ensureStructure();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
ensureStructure() {
|
|
14
|
-
if (!fs.existsSync(TEAM_DIR)) {
|
|
15
|
-
fs.mkdirSync(TEAM_DIR, { recursive: true });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Standart dosyaların varlığını kontrol et
|
|
19
|
-
const defaults = {
|
|
20
|
-
'GOALS.md': '# Mevcut Hedefler & OKR\'lar\n\nHenüz bir hedef belirlenmedi.',
|
|
21
|
-
'DECISIONS.md': '# Karar Günlüğü\n\nHenüz bir karar alınmadı.',
|
|
22
|
-
'PROJECT_STATUS.md': '# Proje Durumu\n\nDurum: Başlatılıyor...'
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
for (const [file, content] of Object.entries(defaults)) {
|
|
26
|
-
const filePath = path.join(TEAM_DIR, file);
|
|
27
|
-
if (!fs.existsSync(filePath)) {
|
|
28
|
-
fs.writeFileSync(filePath, content, 'utf-8');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getAgentDir(agentName) {
|
|
34
|
-
const dir = path.join(TEAM_DIR, 'agents', agentName);
|
|
35
|
-
if (!fs.existsSync(dir)) {
|
|
36
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
37
|
-
}
|
|
38
|
-
return dir;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
readFile(filename) {
|
|
42
|
-
try {
|
|
43
|
-
const filePath = path.join(TEAM_DIR, filename);
|
|
44
|
-
if (fs.existsSync(filePath)) {
|
|
45
|
-
return fs.readFileSync(filePath, 'utf-8');
|
|
46
|
-
}
|
|
47
|
-
} catch (e) {
|
|
48
|
-
log('ERROR', `SharedMemory read failed: ${filename}`, { error: e.message });
|
|
49
|
-
}
|
|
50
|
-
return '';
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
writeFile(filename, content) {
|
|
54
|
-
try {
|
|
55
|
-
const filePath = path.join(TEAM_DIR, filename);
|
|
56
|
-
fs.writeFileSync(filePath, content, 'utf-8');
|
|
57
|
-
log('INFO', `SharedMemory updated: ${filename}`);
|
|
58
|
-
return true;
|
|
59
|
-
} catch (e) {
|
|
60
|
-
log('ERROR', `SharedMemory write failed: ${filename}`, { error: e.message });
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
appendFile(filename, content) {
|
|
66
|
-
try {
|
|
67
|
-
const filePath = path.join(TEAM_DIR, filename);
|
|
68
|
-
const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 19);
|
|
69
|
-
const formatted = `\n\n### [${timestamp}] Update\n${content}`;
|
|
70
|
-
fs.appendFileSync(filePath, formatted, 'utf-8');
|
|
71
|
-
return true;
|
|
72
|
-
} catch (e) {
|
|
73
|
-
log('ERROR', `SharedMemory append failed: ${filename}`, { error: e.message });
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
getEverything() {
|
|
79
|
-
return {
|
|
80
|
-
goals: this.readFile('GOALS.md'),
|
|
81
|
-
decisions: this.readFile('DECISIONS.md'),
|
|
82
|
-
status: this.readFile('PROJECT_STATUS.md')
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export default new SharedMemory();
|
|
1
|
+
// modules/team/shared-memory.js
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { log } from '../../core/ai-provider.js';
|
|
5
|
+
|
|
6
|
+
const TEAM_DIR = path.join(process.cwd(), 'workspace', 'team');
|
|
7
|
+
|
|
8
|
+
export class SharedMemory {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.ensureStructure();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
ensureStructure() {
|
|
14
|
+
if (!fs.existsSync(TEAM_DIR)) {
|
|
15
|
+
fs.mkdirSync(TEAM_DIR, { recursive: true });
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Standart dosyaların varlığını kontrol et
|
|
19
|
+
const defaults = {
|
|
20
|
+
'GOALS.md': '# Mevcut Hedefler & OKR\'lar\n\nHenüz bir hedef belirlenmedi.',
|
|
21
|
+
'DECISIONS.md': '# Karar Günlüğü\n\nHenüz bir karar alınmadı.',
|
|
22
|
+
'PROJECT_STATUS.md': '# Proje Durumu\n\nDurum: Başlatılıyor...'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
for (const [file, content] of Object.entries(defaults)) {
|
|
26
|
+
const filePath = path.join(TEAM_DIR, file);
|
|
27
|
+
if (!fs.existsSync(filePath)) {
|
|
28
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getAgentDir(agentName) {
|
|
34
|
+
const dir = path.join(TEAM_DIR, 'agents', agentName);
|
|
35
|
+
if (!fs.existsSync(dir)) {
|
|
36
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
37
|
+
}
|
|
38
|
+
return dir;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
readFile(filename) {
|
|
42
|
+
try {
|
|
43
|
+
const filePath = path.join(TEAM_DIR, filename);
|
|
44
|
+
if (fs.existsSync(filePath)) {
|
|
45
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
46
|
+
}
|
|
47
|
+
} catch (e) {
|
|
48
|
+
log('ERROR', `SharedMemory read failed: ${filename}`, { error: e.message });
|
|
49
|
+
}
|
|
50
|
+
return '';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
writeFile(filename, content) {
|
|
54
|
+
try {
|
|
55
|
+
const filePath = path.join(TEAM_DIR, filename);
|
|
56
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
57
|
+
log('INFO', `SharedMemory updated: ${filename}`);
|
|
58
|
+
return true;
|
|
59
|
+
} catch (e) {
|
|
60
|
+
log('ERROR', `SharedMemory write failed: ${filename}`, { error: e.message });
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
appendFile(filename, content) {
|
|
66
|
+
try {
|
|
67
|
+
const filePath = path.join(TEAM_DIR, filename);
|
|
68
|
+
const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 19);
|
|
69
|
+
const formatted = `\n\n### [${timestamp}] Update\n${content}`;
|
|
70
|
+
fs.appendFileSync(filePath, formatted, 'utf-8');
|
|
71
|
+
return true;
|
|
72
|
+
} catch (e) {
|
|
73
|
+
log('ERROR', `SharedMemory append failed: ${filename}`, { error: e.message });
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
getEverything() {
|
|
79
|
+
return {
|
|
80
|
+
goals: this.readFile('GOALS.md'),
|
|
81
|
+
decisions: this.readFile('DECISIONS.md'),
|
|
82
|
+
status: this.readFile('PROJECT_STATUS.md')
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default new SharedMemory();
|