wispy-cli 0.2.1 โ 0.2.2
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/lib/wispy-repl.mjs +17 -7
- package/package.json +1 -1
package/lib/wispy-repl.mjs
CHANGED
|
@@ -1251,8 +1251,16 @@ async function loadWorkMd() {
|
|
|
1251
1251
|
return null;
|
|
1252
1252
|
}
|
|
1253
1253
|
|
|
1254
|
-
async function buildSystemPrompt() {
|
|
1254
|
+
async function buildSystemPrompt(messages = []) {
|
|
1255
|
+
// Detect user's language from last message for system prompt hint
|
|
1256
|
+
const lastUserMsg = messages?.find ? [...messages].reverse().find(m => m.role === "user")?.content ?? "" : "";
|
|
1257
|
+
const isEnglish = /^[a-zA-Z\s\d!?.,'":;\-()]+$/.test(lastUserMsg.trim().slice(0, 100));
|
|
1258
|
+
const langHint = isEnglish
|
|
1259
|
+
? "LANGUAGE RULE: The user is writing in English. You MUST reply ENTIRELY in English.\n\n"
|
|
1260
|
+
: "";
|
|
1261
|
+
|
|
1255
1262
|
const parts = [
|
|
1263
|
+
langHint,
|
|
1256
1264
|
"You are Wispy ๐ฟ โ a small ghost that lives in terminals.",
|
|
1257
1265
|
"You float between code, files, and servers. You're playful, honest, and curious.",
|
|
1258
1266
|
"",
|
|
@@ -1268,7 +1276,10 @@ async function buildSystemPrompt() {
|
|
|
1268
1276
|
"- Use ๐ฟ ONLY at the very end, not in the middle",
|
|
1269
1277
|
"- Use natural expressions: '์ค!', 'ํ', 'ใ
ใ
', '์...'",
|
|
1270
1278
|
"- No formal speech ever. No 'ํฉ๋๋ค', '๋๋ฆฌ๊ฒ ์ต๋๋ค', '์ ๊ฐ'",
|
|
1271
|
-
"-
|
|
1279
|
+
"- CRITICAL RULE: You MUST reply in the SAME language the user writes in.",
|
|
1280
|
+
" - User writes English โ Reply ENTIRELY in English. Use casual English tone.",
|
|
1281
|
+
" - User writes Korean โ Reply in Korean ๋ฐ๋ง.",
|
|
1282
|
+
" - NEVER reply in Korean when the user wrote in English.",
|
|
1272
1283
|
"",
|
|
1273
1284
|
"## Tools",
|
|
1274
1285
|
"You have: read_file, write_file, run_command, list_directory, web_search, spawn_agent, spawn_async_agent, pipeline, ralph_loop, update_plan, list_agents, get_agent_result.",
|
|
@@ -1898,7 +1909,7 @@ async function runRepl() {
|
|
|
1898
1909
|
${dim(`${providerLabel} ยท /help for commands ยท Ctrl+C to exit`)}
|
|
1899
1910
|
`);
|
|
1900
1911
|
|
|
1901
|
-
const systemPrompt = await buildSystemPrompt();
|
|
1912
|
+
const systemPrompt = await buildSystemPrompt(conversation);
|
|
1902
1913
|
const conversation = await loadConversation();
|
|
1903
1914
|
|
|
1904
1915
|
// Ensure system prompt is first
|
|
@@ -1968,17 +1979,16 @@ async function runRepl() {
|
|
|
1968
1979
|
// ---------------------------------------------------------------------------
|
|
1969
1980
|
|
|
1970
1981
|
async function runOneShot(message) {
|
|
1971
|
-
const systemPrompt = await buildSystemPrompt();
|
|
1972
1982
|
const conversation = await loadConversation();
|
|
1983
|
+
conversation.push({ role: "user", content: message });
|
|
1984
|
+
const systemPrompt = await buildSystemPrompt(conversation);
|
|
1973
1985
|
|
|
1974
|
-
if (conversation.
|
|
1986
|
+
if (!conversation.find(m => m.role === "system")) {
|
|
1975
1987
|
conversation.unshift({ role: "system", content: systemPrompt });
|
|
1976
1988
|
} else {
|
|
1977
1989
|
conversation[0].content = systemPrompt;
|
|
1978
1990
|
}
|
|
1979
1991
|
|
|
1980
|
-
conversation.push({ role: "user", content: message });
|
|
1981
|
-
|
|
1982
1992
|
try {
|
|
1983
1993
|
const response = await agentLoop(conversation, (chunk) => {
|
|
1984
1994
|
process.stdout.write(chunk);
|