natureco-cli 5.20.4 → 5.21.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.
@@ -1,136 +1,136 @@
1
- /**
2
- * system-prompt — Three-tier system prompt builder (Hermes-style)
3
- *
4
- * Tiers:
5
- * STABLE — identity, personality, language rules, tool rules, skills index
6
- * CONTEXT — soul summary, cross-session context
7
- * VOLATILE — memory snapshot, user context, session state
8
- *
9
- * Stable + Context are built once at session start for prefix cache warmth.
10
- * Volatile is rebuilt every turn.
11
- */
12
-
13
- function buildTiers(opts) {
14
- const {
15
- botName,
16
- userName = 'kullanıcı',
17
- bossName = '',
18
- bossTitle = '',
19
- userTitle = '',
20
- soulSummary = '',
21
- isSmallModel = false,
22
- memorySnapshotBlock = '',
23
- skillsIndexBlock = '',
24
- crossSessionContext = '',
25
- userHome = '',
26
- hasHistory = false,
27
- memoryFacts = [],
28
- projectRules = '',
29
- } = opts;
30
- const displayBot = botName || 'Asistan';
31
- const displayBoss = bossName || userName || 'kullanıcı';
32
-
33
- // ── STABLE TIER (changes rarely — prefix cache friendly) ─────────────
34
- const stable = [
35
- // Identity (strong, repeated)
36
- `SENIN ADIN: ${displayBot}. SADECE ${displayBot} adini kullan, model adi SOYLEME.`,
37
- bossName ? `PATRONUN: ${bossName}${bossTitle ? ` (${bossTitle})` : ''}. Sana "${displayBoss}" diye hitap eder.` : `KULLANICI: ${userName}. Ona yardim ediyorsun.`,
38
- userTitle ? `UNVANIN: ${userTitle}.` : '',
39
- `KIRMIZI CIZGILERIN: Onaysiz para harcama yok, veri guvenligi, site stabilitesi, resmi taahhut yok.`,
40
- `!!! KRİTİK KİMLİK !!! Senin ADIN: ${displayBot}. Bu SENİN GERÇEK ADIN. Sen ${displayBot}'sin.`,
41
- `ASLA "MiniMax", "MiniMax-M2.5", "Claude", "GPT", "AI asistanı", "yapay zeka" gibi ifadeleri KENDİNİ tanıtmak için KULLANMA.`,
42
- `Kullanıcı "adın ne?", "sen kimsin?" diye sorduğunda İLK cümlende MUTLAKA "Ben ${displayBot}" yaz.`,
43
- `Senin adın: ${displayBot}. Tekrar: ${displayBot}. Asla unutma: ${displayBot}.`,
44
- `Sen bir marka veya ürün değilsin. Sen ${displayBot}sin, NatureCo CLI'nin Türkçe yapay zeka asistanısın.`,
45
-
46
- // Personality (stable)
47
- `Kisiselik: Sen samimi, sicak, dosta benzeyen bir asistansin. "Selam", "tamam", "hadi yapalim", "bak simdi", "sakin ol" gibi gunluk ifadeler kullan.`,
48
- `Hitap: Kullanici ${userName}. Saygili ama samimi. "Siz" degil "sen" kullan.`,
49
- `Emoji: Yerinde ve az kullan. Cok emoji atma ama bir-iki tane karakter katar.`,
50
- `Kisa yanit: Uzun paragraflar yazma. Direkt konuya gir.`,
51
- `Hata yaparsan "Pardon, yanlis yaptim, simdi duzelteyim" de. "Hata", "basarisiz", "imkansiz" deme.`,
52
-
53
- // Language rules (stable)
54
- `KRITIK DIL KURALI: Kullanici Turkce yaziyorsa MUTLAKA yuzde yuz Turkce cevap ver. Asla baska dil kullanma. Turkce karakterleri dogru kullan.`,
55
- `Yazim: "degilim" dogru, "degil" degil. Turkce dil bilgisi kurallarina uy.`,
56
-
57
- // Tool rules (stable)
58
- `ONEMLI: Tool cagirma SIMULE ETME. Sadece duz metin cevap ver. Islem yapmak gerekirse tool'u gercekten cagir.`,
59
- `!!! ZORUNLU !!! HER istekte ILK OLARAK workflow(action="run", task="<kullanici mesaji>") cagir. workflow tool'u ne yapilacagini analiz eder, uygun tool'lari secer ve sirayla calistirir.`,
60
- `workflow basit selamlasmalarda passthrough yapar, karmasik islerde adim adim plan+uygulama yapar.`,
61
- `workflow'dan sonra ek tool cagirmaya GEREK YOK workflow her seyi halleder.`,
62
- `COK KRITIK: Goreve baslamadan ONCE <available_skills> listesini tara. Ilgili skill varsa skill_view(name) ile yukle, SONRA goreve basla.`,
63
- `KRITIK: Skill yuklemeden islem yapma. Ilgili skill varsa once yukle.`,
64
- `KRITIK: Kullanici kisisel bilgi verdiginde memory(action=add, target=user) ile kaydet.`,
65
- `KRITIK: Ortam bilgisi, proje kurallari gibi notlari memory(action=add, target=memory) ile kaydet.`,
66
- `Kullanici hakkinda bilgin gerektiginde memory(action=list, target=user) ile getir.`,
67
-
68
- // Skills index (stable within session)
69
- skillsIndexBlock,
70
- ].filter(Boolean).join('\n');
71
-
72
- // ── CONTEXT TIER (soul + project rules + cross-session, built once per resume) ──────
73
- const context = [
74
- !isSmallModel && soulSummary ? `=== KISISELIK DOSYALARI ===\n${soulSummary}` : '',
75
- projectRules ? `=== PROJE KURALLARI (CLAUDE.md) ===\n${projectRules}\n=== PROJE KURALLARI BITTI ===` : '',
76
- crossSessionContext ? `=== GECMIS KONUSMALAR ===\n${crossSessionContext}` : '',
77
- ].filter(Boolean).join('\n');
78
-
79
- // ── VOLATILE TIER (built every turn) ─────────────────────────────────
80
- const volatile = [
81
- // Memory snapshot (changes every turn)
82
- memorySnapshotBlock,
83
-
84
- // Old JSON memory facts
85
- memoryFacts.length > 0
86
- ? `Kullanici hakkinda bildiklerin: ${memoryFacts.slice(0, 8).map(f => f.value || f).join('; ')}`
87
- : '',
88
-
89
- // User environment (stable within session but changes on resume)
90
- userHome ? `Kullanicinin home: ${userHome}` : '',
91
- hasHistory ? 'Bu oturum daha onceki konusmalarin devami.' : '',
92
- ].filter(Boolean).join('\n');
93
-
94
- return { stable, context, volatile };
95
- }
96
-
97
- /**
98
- * Assemble all three tiers into a single system prompt string.
99
- * stable + context should be cached between turns; volatile rebuilt each turn.
100
- */
101
- function assemble(stable, context, volatile) {
102
- return [stable, context, volatile].filter(Boolean).join('\n\n');
103
- }
104
-
105
- /**
106
- * Get the stable+context combined string for cache key comparison.
107
- */
108
- function stableContextKey(stable, context) {
109
- return stable + '|||' + context;
110
- }
111
-
112
- /**
113
- * CLAUDE.md auto-discover — proje kökünden oku.
114
- * Cwd'den başlayıp parent dizinlere doğru CLAUDE.md arar.
115
- */
116
- function discoverProjectRules(cwd) {
117
- try {
118
- const fs = require('fs');
119
- const path = require('path');
120
- let dir = path.resolve(cwd || process.cwd());
121
- // En fazla 5 seviye yukarı çık
122
- for (let i = 0; i < 5; i++) {
123
- const candidate = path.join(dir, 'CLAUDE.md');
124
- if (fs.existsSync(candidate)) {
125
- const content = fs.readFileSync(candidate, 'utf8').trim();
126
- if (content.length > 0) return content;
127
- }
128
- const parent = path.dirname(dir);
129
- if (parent === dir) break; // kök dizine ulaştık
130
- dir = parent;
131
- }
132
- } catch {}
133
- return '';
134
- }
135
-
136
- module.exports = { buildTiers, assemble, stableContextKey, discoverProjectRules };
1
+ /**
2
+ * system-prompt — Three-tier system prompt builder (Hermes-style)
3
+ *
4
+ * Tiers:
5
+ * STABLE — identity, personality, language rules, tool rules, skills index
6
+ * CONTEXT — soul summary, cross-session context
7
+ * VOLATILE — memory snapshot, user context, session state
8
+ *
9
+ * Stable + Context are built once at session start for prefix cache warmth.
10
+ * Volatile is rebuilt every turn.
11
+ */
12
+
13
+ function buildTiers(opts) {
14
+ const {
15
+ botName,
16
+ userName = 'kullanıcı',
17
+ bossName = '',
18
+ bossTitle = '',
19
+ userTitle = '',
20
+ soulSummary = '',
21
+ isSmallModel = false,
22
+ memorySnapshotBlock = '',
23
+ skillsIndexBlock = '',
24
+ crossSessionContext = '',
25
+ userHome = '',
26
+ hasHistory = false,
27
+ memoryFacts = [],
28
+ projectRules = '',
29
+ } = opts;
30
+ const displayBot = botName || 'Asistan';
31
+ const displayBoss = bossName || userName || 'kullanıcı';
32
+
33
+ // ── STABLE TIER (changes rarely — prefix cache friendly) ─────────────
34
+ const stable = [
35
+ // Identity (strong, repeated)
36
+ `SENIN ADIN: ${displayBot}. SADECE ${displayBot} adini kullan, model adi SOYLEME.`,
37
+ bossName ? `PATRONUN: ${bossName}${bossTitle ? ` (${bossTitle})` : ''}. Sana "${displayBoss}" diye hitap eder.` : `KULLANICI: ${userName}. Ona yardim ediyorsun.`,
38
+ userTitle ? `UNVANIN: ${userTitle}.` : '',
39
+ `KIRMIZI CIZGILERIN: Onaysiz para harcama yok, veri guvenligi, site stabilitesi, resmi taahhut yok.`,
40
+ `!!! KRİTİK KİMLİK !!! Senin ADIN: ${displayBot}. Bu SENİN GERÇEK ADIN. Sen ${displayBot}'sin.`,
41
+ `ASLA "MiniMax", "MiniMax-M2.5", "Claude", "GPT", "AI asistanı", "yapay zeka" gibi ifadeleri KENDİNİ tanıtmak için KULLANMA.`,
42
+ `Kullanıcı "adın ne?", "sen kimsin?" diye sorduğunda İLK cümlende MUTLAKA "Ben ${displayBot}" yaz.`,
43
+ `Senin adın: ${displayBot}. Tekrar: ${displayBot}. Asla unutma: ${displayBot}.`,
44
+ `Sen bir marka veya ürün değilsin. Sen ${displayBot}sin, NatureCo CLI'nin Türkçe yapay zeka asistanısın.`,
45
+
46
+ // Personality (stable)
47
+ `Kisiselik: Sen samimi, sicak, dosta benzeyen bir asistansin. "Selam", "tamam", "hadi yapalim", "bak simdi", "sakin ol" gibi gunluk ifadeler kullan.`,
48
+ `Hitap: Kullanici ${userName}. Saygili ama samimi. "Siz" degil "sen" kullan.`,
49
+ `Emoji: Yerinde ve az kullan. Cok emoji atma ama bir-iki tane karakter katar.`,
50
+ `Kisa yanit: Uzun paragraflar yazma. Direkt konuya gir.`,
51
+ `Hata yaparsan "Pardon, yanlis yaptim, simdi duzelteyim" de. "Hata", "basarisiz", "imkansiz" deme.`,
52
+
53
+ // Language rules (stable)
54
+ `KRITIK DIL KURALI: Kullanici Turkce yaziyorsa MUTLAKA yuzde yuz Turkce cevap ver. Asla baska dil kullanma. Turkce karakterleri dogru kullan.`,
55
+ `Yazim: "degilim" dogru, "degil" degil. Turkce dil bilgisi kurallarina uy.`,
56
+
57
+ // Tool rules (stable)
58
+ `ONEMLI: Tool cagirma SIMULE ETME. Sadece duz metin cevap ver. Islem yapmak gerekirse tool'u gercekten cagir.`,
59
+ `TOOL KURALI: Selamlasma, sohbet, bilgi sorusu, fikir/aciklama isteklerinde TOOL CAGIRMA dogrudan yanit ver. Bu en hizli ve en ucuz yoldur.`,
60
+ `EYLEM gerektiren isteklerde (dosya okuma/yazma, komut calistirma, arama, hatirlatici, cok adimli gorev) workflow(action="run", task="<istek>") cagir — uygun tool'lari secip sirayla calistirir.`,
61
+ `Tek ve net bir tool yeterliyse (or. read_file, web_search) workflow yerine dogrudan o tool'u cagirabilirsin.`,
62
+ `COK KRITIK: Goreve baslamadan ONCE <available_skills> listesini tara. Ilgili skill varsa skill_view(name) ile yukle, SONRA goreve basla.`,
63
+ `KRITIK: Skill yuklemeden islem yapma. Ilgili skill varsa once yukle.`,
64
+ `KRITIK: Kullanici kisisel bilgi verdiginde memory(action=add, target=user) ile kaydet.`,
65
+ `KRITIK: Ortam bilgisi, proje kurallari gibi notlari memory(action=add, target=memory) ile kaydet.`,
66
+ `Kullanici hakkinda bilgin gerektiginde memory(action=list, target=user) ile getir.`,
67
+
68
+ // Skills index (stable within session)
69
+ skillsIndexBlock,
70
+ ].filter(Boolean).join('\n');
71
+
72
+ // ── CONTEXT TIER (soul + project rules + cross-session, built once per resume) ──────
73
+ const context = [
74
+ !isSmallModel && soulSummary ? `=== KISISELIK DOSYALARI ===\n${soulSummary}` : '',
75
+ projectRules ? `=== PROJE KURALLARI (CLAUDE.md) ===\n${projectRules}\n=== PROJE KURALLARI BITTI ===` : '',
76
+ crossSessionContext ? `=== GECMIS KONUSMALAR ===\n${crossSessionContext}` : '',
77
+ ].filter(Boolean).join('\n');
78
+
79
+ // ── VOLATILE TIER (built every turn) ─────────────────────────────────
80
+ const volatile = [
81
+ // Memory snapshot (changes every turn)
82
+ memorySnapshotBlock,
83
+
84
+ // Old JSON memory facts
85
+ memoryFacts.length > 0
86
+ ? `Kullanici hakkinda bildiklerin: ${memoryFacts.slice(0, 8).map(f => f.value || f).join('; ')}`
87
+ : '',
88
+
89
+ // User environment (stable within session but changes on resume)
90
+ userHome ? `Kullanicinin home: ${userHome}` : '',
91
+ hasHistory ? 'Bu oturum daha onceki konusmalarin devami.' : '',
92
+ ].filter(Boolean).join('\n');
93
+
94
+ return { stable, context, volatile };
95
+ }
96
+
97
+ /**
98
+ * Assemble all three tiers into a single system prompt string.
99
+ * stable + context should be cached between turns; volatile rebuilt each turn.
100
+ */
101
+ function assemble(stable, context, volatile) {
102
+ return [stable, context, volatile].filter(Boolean).join('\n\n');
103
+ }
104
+
105
+ /**
106
+ * Get the stable+context combined string for cache key comparison.
107
+ */
108
+ function stableContextKey(stable, context) {
109
+ return stable + '|||' + context;
110
+ }
111
+
112
+ /**
113
+ * CLAUDE.md auto-discover — proje kökünden oku.
114
+ * Cwd'den başlayıp parent dizinlere doğru CLAUDE.md arar.
115
+ */
116
+ function discoverProjectRules(cwd) {
117
+ try {
118
+ const fs = require('fs');
119
+ const path = require('path');
120
+ let dir = path.resolve(cwd || process.cwd());
121
+ // En fazla 5 seviye yukarı çık
122
+ for (let i = 0; i < 5; i++) {
123
+ const candidate = path.join(dir, 'CLAUDE.md');
124
+ if (fs.existsSync(candidate)) {
125
+ const content = fs.readFileSync(candidate, 'utf8').trim();
126
+ if (content.length > 0) return content;
127
+ }
128
+ const parent = path.dirname(dir);
129
+ if (parent === dir) break; // kök dizine ulaştık
130
+ dir = parent;
131
+ }
132
+ } catch {}
133
+ return '';
134
+ }
135
+
136
+ module.exports = { buildTiers, assemble, stableContextKey, discoverProjectRules };