tiger-agent 0.2.4 → 0.2.5
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
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function getLegacyRootMirrorPath(filePath) {
|
|
5
|
+
const canonical = path.resolve(filePath);
|
|
6
|
+
const candidate = path.resolve(process.cwd(), path.basename(canonical));
|
|
7
|
+
|
|
8
|
+
if (candidate === canonical) return null;
|
|
9
|
+
if (!fs.existsSync(candidate)) return null;
|
|
10
|
+
|
|
11
|
+
return candidate;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function syncLegacyRootMirror(filePath) {
|
|
15
|
+
const canonical = path.resolve(filePath);
|
|
16
|
+
const legacy = getLegacyRootMirrorPath(canonical);
|
|
17
|
+
if (!legacy) return;
|
|
18
|
+
|
|
19
|
+
const content = fs.readFileSync(canonical, 'utf8');
|
|
20
|
+
fs.writeFileSync(legacy, content, 'utf8');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function writeContextFile(filePath, content) {
|
|
24
|
+
const canonical = path.resolve(filePath);
|
|
25
|
+
fs.writeFileSync(canonical, content, 'utf8');
|
|
26
|
+
syncLegacyRootMirror(canonical);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function appendContextFile(filePath, content) {
|
|
30
|
+
const canonical = path.resolve(filePath);
|
|
31
|
+
fs.appendFileSync(canonical, content, 'utf8');
|
|
32
|
+
syncLegacyRootMirror(canonical);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
writeContextFile,
|
|
37
|
+
appendContextFile,
|
|
38
|
+
syncLegacyRootMirror
|
|
39
|
+
};
|
|
@@ -2,6 +2,7 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { dataDir } = require('../config');
|
|
4
4
|
const { ensureDir } = require('../utils');
|
|
5
|
+
const { writeContextFile, syncLegacyRootMirror } = require('./contextFileMirrors');
|
|
5
6
|
|
|
6
7
|
const files = ['soul.md', 'human.md', 'human2.md', 'ownskill.md'];
|
|
7
8
|
|
|
@@ -10,8 +11,10 @@ function ensureContextFiles() {
|
|
|
10
11
|
for (const name of files) {
|
|
11
12
|
const full = path.join(dataDir, name);
|
|
12
13
|
if (!fs.existsSync(full)) {
|
|
13
|
-
|
|
14
|
+
writeContextFile(full, `# ${name.replace('.md', '')}\n\n`);
|
|
15
|
+
continue;
|
|
14
16
|
}
|
|
17
|
+
syncLegacyRootMirror(full);
|
|
15
18
|
}
|
|
16
19
|
}
|
|
17
20
|
|
package/src/agent/mainAgent.js
CHANGED
|
@@ -12,6 +12,7 @@ const {
|
|
|
12
12
|
memoryIngestMinChars
|
|
13
13
|
} = require('../config');
|
|
14
14
|
const { loadContextFiles } = require('./contextFiles');
|
|
15
|
+
const { writeContextFile, appendContextFile } = require('./contextFileMirrors');
|
|
15
16
|
const { tools, callTool } = require('./toolbox');
|
|
16
17
|
const {
|
|
17
18
|
ensureConversation,
|
|
@@ -98,7 +99,7 @@ async function maybeUpdateHumanFile(userText, assistantText) {
|
|
|
98
99
|
if (!append) return;
|
|
99
100
|
|
|
100
101
|
const block = `\n## Update ${new Date().toISOString()}\n${append}\n`;
|
|
101
|
-
|
|
102
|
+
appendContextFile(path.resolve(human2.full), block);
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
function buildSystemPrompt(contextText, memoriesText) {
|
|
@@ -173,7 +174,7 @@ async function maybeUpdateOwnSkillSummary(conversationIdValue) {
|
|
|
173
174
|
|
|
174
175
|
const next = String(message.content || '').trim();
|
|
175
176
|
if (!next) return;
|
|
176
|
-
|
|
177
|
+
writeContextFile(path.resolve(ownSkillPath), `${next}\n`);
|
|
177
178
|
setMeta(OWNSKILL_META_KEY, Date.now());
|
|
178
179
|
}
|
|
179
180
|
|
|
@@ -209,7 +210,7 @@ async function maybeUpdateSoulSummary(conversationIdValue) {
|
|
|
209
210
|
|
|
210
211
|
const next = String(message.content || '').trim();
|
|
211
212
|
if (!next) return;
|
|
212
|
-
|
|
213
|
+
writeContextFile(path.resolve(soulPath), `${next}\n`);
|
|
213
214
|
setMeta(SOUL_META_KEY, Date.now());
|
|
214
215
|
}
|
|
215
216
|
|
|
@@ -3,6 +3,7 @@ const path = require('path');
|
|
|
3
3
|
const { chatCompletion, embedText } = require('../llmClient');
|
|
4
4
|
const { dataDir, embeddingsEnabled, reflectionUpdateHours } = require('../config');
|
|
5
5
|
const { addMemory, getMeta, setMeta, getMessagesSince, getRecentMessagesAll } = require('./db');
|
|
6
|
+
const { writeContextFile } = require('./contextFileMirrors');
|
|
6
7
|
|
|
7
8
|
const REFLECTION_META_KEY = 'memory_reflection_last_run_ts';
|
|
8
9
|
const MAX_MESSAGE_SCAN = 600;
|
|
@@ -67,7 +68,7 @@ function appendTimestampedBullets(filePath, heading, bullets, stamp) {
|
|
|
67
68
|
const withHeading = ensureHeading(existing, heading);
|
|
68
69
|
const lines = bullets.map((line) => `- [${stamp}] ${line}`).join('\n');
|
|
69
70
|
const next = `${withHeading.trimEnd()}\n${lines}\n`;
|
|
70
|
-
|
|
71
|
+
writeContextFile(full, next);
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
function appendHuman2Update(filePath, payload, stampIso) {
|
|
@@ -80,7 +81,7 @@ function appendHuman2Update(filePath, payload, stampIso) {
|
|
|
80
81
|
for (const w of payload.successfulWorkflows) lines.push(`- Workflow: ${w}`);
|
|
81
82
|
if (!lines.length) return;
|
|
82
83
|
const block = `\n## Update ${stampIso}\n${lines.join('\n')}\n`;
|
|
83
|
-
|
|
84
|
+
writeContextFile(full, `${existing.trimEnd()}${block}`);
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
async function generateReflection(rows, sinceIso, untilIso) {
|