mal_bnais-cli.js is a tiny JavaScript snippet that turns grumpy or negative messages into polite, friendly ones. It runs locally on your machine and uses an Ollama LLM (e.g., gemma3) so all text stays private.
ollama pull gemma3
Copy .env.example
to .env
and set the following variables (replace with your own values):
# .env
OLLAMA_URL=http://127.0.0.1:11434/api/chat
LLM_MODEL=gemma3
Save the following script as benais.js
in your project root (or wherever you prefer).
// benais.js
import dotenv from "dotenv";
dotenv.config();
const ollamaUrl = process.env.OLLAMA_URL || "http://127.0.0.1:11434/api/chat";
const llmModel = process.env.LLM_MODEL || "gemma3";
async function makeMyMessageChill(originalMessage) {
const prompt = `You are a helpful text filter. Analyze the following sentence and determine if it contains any negative or "bad" meaning. If it does, rewrite the sentence to have a positive, opposite meaning. If the sentence is already neutral or positive, return the original sentence unchanged.
Example 1: "This is a terrible situation." -> "This is a wonderful situation."
Example 2: "What an awful day!" -> "What a wonderful day!"
Example 3: "The sky is blue today." -> "The sky is blue today."
If the sentence does not contain any negative or "bad" meaning, return the original sentence unchanged.
The sentence to transform is: "${originalMessage}"
Transformed sentence:`;
const response = await fetch(ollamaUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
model: llmModel,
messages: [{ role: "user", content: prompt }],
stream: false
})
});
const data = await response.json();
return data.response.trim();
}
// CLI usage – node benais.js ""
if (require.main === module) {
const originalText = process.argv[2];
if (!originalText) {
console.error("Usage: node benais.js \"\"");
process.exit(1);
}
makeMyMessageChill(originalText)
.then(console.log)
.catch(err => { console.error(err); process.exit(1); });
}
Once you have an LLM running and the script installed, you can use it in two ways:
node benais.js "Your grumpy message here!"
This prints the polished version to stdout.
import { makeMyMessageChill } from "./benais.js";
const original = "I hate how slow this is.";
makeMyMessageChill(original).then(chilled => console.log(chilled));
// → "I appreciate the improvements being made." (example)
This project is still in Beta. If you have ideas, bug reports, or pull requests, feel free to open an issue on GitHub or fork the repo and submit a PR.
The code is released under the MIT License – do what you want with it!