ausername-12345 commited on
Commit ·
f778cb2
1
Parent(s): ac5ce1f
minimal prompt; trim history to 20 entries
Browse files- src/agent.js +10 -11
src/agent.js
CHANGED
|
@@ -12,17 +12,7 @@ const fs = require('fs');
|
|
| 12 |
const projectRoot = path.resolve(__dirname, '..');
|
| 13 |
|
| 14 |
function systemPrompt() {
|
| 15 |
-
return
|
| 16 |
-
`${AGENT_NAME}. To read a file respond EXACTLY like:`,
|
| 17 |
-
'```read public/index.html```',
|
| 18 |
-
'',
|
| 19 |
-
'To write a file, respond EXACTLY like (the write keyword must be right after the opening backticks):',
|
| 20 |
-
'```write public/app.js',
|
| 21 |
-
'// entire file content here',
|
| 22 |
-
'```',
|
| 23 |
-
'',
|
| 24 |
-
'Be concise. Actually edit files - do NOT just describe edits.',
|
| 25 |
-
].join('\n');
|
| 26 |
}
|
| 27 |
|
| 28 |
function makeLogEntry(type, fields = {}) {
|
|
@@ -146,9 +136,18 @@ function createAgent(io) {
|
|
| 146 |
pushLog(makeLogEntry('assistant', { content: "I've gone through a few iterations without wrapping up - pausing here. What would you like next?" }));
|
| 147 |
}
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
async function handleUserMessage(text) {
|
| 150 |
const trimmed = String(text || '').trim();
|
| 151 |
if (!trimmed) return;
|
|
|
|
| 152 |
llmHistory.push({ role: 'user', content: trimmed });
|
| 153 |
pushLog(makeLogEntry('user', { content: trimmed }));
|
| 154 |
await runLoop();
|
|
|
|
| 12 |
const projectRoot = path.resolve(__dirname, '..');
|
| 13 |
|
| 14 |
function systemPrompt() {
|
| 15 |
+
return `${AGENT_NAME}. Do it: \`\`\`read path\`\`\` to read, \`\`\`write path\n...\`\`\` to write. Actually edit, dont describe.`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
|
| 18 |
function makeLogEntry(type, fields = {}) {
|
|
|
|
| 136 |
pushLog(makeLogEntry('assistant', { content: "I've gone through a few iterations without wrapping up - pausing here. What would you like next?" }));
|
| 137 |
}
|
| 138 |
|
| 139 |
+
const MAX_HISTORY = 20;
|
| 140 |
+
|
| 141 |
+
function trimHistory() {
|
| 142 |
+
while (llmHistory.length > MAX_HISTORY) {
|
| 143 |
+
llmHistory.shift();
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
async function handleUserMessage(text) {
|
| 148 |
const trimmed = String(text || '').trim();
|
| 149 |
if (!trimmed) return;
|
| 150 |
+
trimHistory();
|
| 151 |
llmHistory.push({ role: 'user', content: trimmed });
|
| 152 |
pushLog(makeLogEntry('user', { content: trimmed }));
|
| 153 |
await runLoop();
|